start: switch to time series
This commit is contained in:
parent
024fb88cd1
commit
8a60c36240
@ -10,20 +10,22 @@ use relm4::{
|
||||
RelmObjectExt,
|
||||
};
|
||||
use std::{cell::RefCell, collections::HashMap, rc::Rc};
|
||||
use relm4::actions::{AccelsPlus, RelmAction};
|
||||
|
||||
use crate::{
|
||||
chart::Chart,
|
||||
data::Npz,
|
||||
widgets::render::{predefined::color_mapper::BoundaryNorm, Layer},
|
||||
};
|
||||
use crate::components::app::AppMsg;
|
||||
|
||||
use super::{
|
||||
bottom_bar::BottomBarModel,
|
||||
meta_data_list::{InfoColumn, MyListItem, TagColumn},
|
||||
};
|
||||
|
||||
relm4::new_action_group!(FileActionGroup, "file");
|
||||
relm4::new_stateless_action!(OpenAction, FileActionGroup, "open");
|
||||
relm4::new_action_group!(LayerActionGroup, "layer");
|
||||
relm4::new_stateless_action!(ToTime, LayerActionGroup, "to_time");
|
||||
pub struct SideBarModel {
|
||||
layers: Rc<RefCell<Vec<Layer>>>,
|
||||
counter: u8,
|
||||
@ -43,6 +45,7 @@ pub enum SideBarInputMsg {
|
||||
#[derive(Debug)]
|
||||
pub enum SideBarOutputMsg {
|
||||
NewLayer(Layer),
|
||||
SwitchToTimeSeries(usize)
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
@ -70,27 +73,6 @@ impl SimpleComponent for SideBarModel {
|
||||
#[name="meta_panel"]
|
||||
gtk::Notebook::builder().vexpand(true).hexpand(true).build() -> gtk::Notebook{}
|
||||
},
|
||||
// gtk::Button {
|
||||
// set_label: "Add Layers",
|
||||
// connect_clicked[sender] => move |_| {
|
||||
// },
|
||||
// },
|
||||
// gtk::Button {
|
||||
// set_label: "Add Layer",
|
||||
// connect_clicked[sender] => move |_| {
|
||||
// println!("hello");
|
||||
// sender.output(
|
||||
// SideBarOutputMsg::NewLayer(
|
||||
// Layer::grid_render_layer_with_path(
|
||||
// std::path::Path::new("./test2.npz"),
|
||||
// "DBZ".to_string(),
|
||||
// Npz,
|
||||
// BoundaryNorm::default(),
|
||||
// )
|
||||
// )
|
||||
// ).unwrap()
|
||||
// },
|
||||
// },
|
||||
},
|
||||
|
||||
#[wrap(Some)]
|
||||
@ -150,6 +132,13 @@ impl SimpleComponent for SideBarModel {
|
||||
|
||||
let mut bottom_bar_vec = FactoryVecDeque::new(gtk::Box::default(), sender.input_sender());
|
||||
|
||||
relm4::main_application().set_accelerators_for_action::<ToTime>(&["<primary>T"]);
|
||||
let action: RelmAction<ToTime> = {
|
||||
RelmAction::new_stateless(move |_| {
|
||||
sender.output(SideBarOutputMsg::SwitchToTimeSeries(0));
|
||||
})
|
||||
};
|
||||
|
||||
{
|
||||
let mut bottom_bar_vec_guard = bottom_bar_vec.guard();
|
||||
bottom_bar_vec_guard.push_back(BottomBarModel::new("add-filled".to_string()));
|
||||
@ -233,19 +222,7 @@ impl RelmListItem for LayerItem {
|
||||
fn setup(_item: >k::ListItem) -> (gtk::Box, Widgets) {
|
||||
relm4::menu! {
|
||||
main_menu: {
|
||||
"File" {
|
||||
"Open" => OpenAction,
|
||||
"Open Folder" => OpenAction,
|
||||
},
|
||||
"Edit" {
|
||||
"New Layer" => OpenAction,
|
||||
"Undo" => OpenAction,
|
||||
"Redo" => OpenAction,
|
||||
},
|
||||
"Plugins" {
|
||||
"Plugin1" => OpenAction,
|
||||
"Plugin2" => OpenAction,
|
||||
},
|
||||
"Bind To Time" => ToTime
|
||||
}
|
||||
}
|
||||
relm4::view! {
|
||||
|
||||
@ -38,9 +38,10 @@ impl CMS {
|
||||
let (w, h) = self.window_size;
|
||||
let (w, h) = (w as f64, h as f64);
|
||||
let (x, y) = (x - self.bounds.0, y - self.bounds.2);
|
||||
// TODO: check if the following line is correct : 1.0 - y / (self.bounds.3 - self.bounds.2)
|
||||
let (x, y) = (
|
||||
x / (self.bounds.1 - self.bounds.0),
|
||||
1.0 - y / (self.bounds.3 - self.bounds.2),
|
||||
y / (self.bounds.3 - self.bounds.2),
|
||||
);
|
||||
let (x, y) = (x * w, y * h);
|
||||
(x as f32, y as f32)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user