use crate::render::{imp, WindowCoord};
use femtovg::{ImageId, Paint, Color};
use geo_macros::Prj;
use geo_types::LineString;
use gtk::glib;
use gtk::subclass::prelude::*;
use ndarray::Array2;
use std::cell::RefCell;

#[derive(Prj, Default)]
pub struct ForegroundConfig {
    pub show_lat_lines: bool,
    pub show_lon_lines: bool,
    pub lat_lines: Vec<Vec<WindowCoord>>,
    pub lon_lines: Vec<Vec<WindowCoord>>,
    pub painter: Paint,
}

impl ForegroundConfig {
    pub fn new() -> Self {
        Self::default()
    }
}

#[derive(Default)]
pub struct ForegroundWidget {
    pub(super) config: RefCell<ForegroundConfig>,
    pub(super) dim1: RefCell<Option<Array2<f64>>>,
    pub(super) dim2: RefCell<Option<Array2<f64>>>,
    pub(super) image: RefCell<Option<ImageId>>,
    pub(super) data: RefCell<Option<Array2<LineString>>>,
    pub(super) color: RefCell<Option<Array2<Option<Color>>>>,
}

#[glib::object_subclass]
impl ObjectSubclass for ForegroundWidget {
    const NAME: &'static str = "ForegroundWidget";
    type Type = super::ForegroundWidget;
}

impl ObjectImpl for ForegroundWidget {}
