test css
This commit is contained in:
parent
322461371f
commit
1218af7314
@ -44,7 +44,7 @@ tokio = { version = "1.35.1", features = ["time", "fs", "io-std", "macros", "num
|
|||||||
async-trait = "0.1.77"
|
async-trait = "0.1.77"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
relm4-icons = "0.6.0"
|
relm4-icons = {version="0.6.0",features=["add-filled","delete-filled","chevron-up-filled","chevron-down-filled"]}
|
||||||
# plotters-cairo = "0.5.0"
|
# plotters-cairo = "0.5.0"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -108,6 +108,7 @@ impl SimpleComponent for AppModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let app = relm4::main_application();
|
let app = relm4::main_application();
|
||||||
|
relm4_icons::initialize_icons();
|
||||||
app.set_menubar(Some(&main_menu));
|
app.set_menubar(Some(&main_menu));
|
||||||
|
|
||||||
let model = AppModel {
|
let model = AppModel {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use super::sidebar::{sidebar::SideBarModel, Msg, SideBarOutputMsg};
|
use super::sidebar::{sidebar::SideBarModel, Msg, SideBarOutputMsg};
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
|
use gtk::prelude::StyleContextExt;
|
||||||
use gtk::subclass::root;
|
use gtk::subclass::root;
|
||||||
use relm4::{
|
use relm4::{
|
||||||
component::{AsyncComponent, AsyncComponentParts},
|
component::{AsyncComponent, AsyncComponentParts},
|
||||||
@ -42,9 +43,14 @@ impl AsyncComponent for MonitorModel {
|
|||||||
set_position: 1000,
|
set_position: 1000,
|
||||||
#[wrap(Some)]
|
#[wrap(Some)]
|
||||||
#[name="render"]
|
#[name="render"]
|
||||||
set_start_child=&Render{
|
set_start_child=>k::Box{
|
||||||
#[watch]
|
add_css_class: "rb",
|
||||||
set_interior_layers: model.layers.clone(),
|
set_margin_all: 5,
|
||||||
|
Render{
|
||||||
|
add_css_class: "rb",
|
||||||
|
#[watch]
|
||||||
|
set_interior_layers: model.layers.clone(),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
#[wrap(Some)]
|
#[wrap(Some)]
|
||||||
set_end_child=model.sidebar.widget(),
|
set_end_child=model.sidebar.widget(),
|
||||||
|
|||||||
@ -21,12 +21,21 @@ pub struct BottomBarModel {
|
|||||||
msg: TestMsg,
|
msg: TestMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BottomBarModel {
|
||||||
|
pub fn new(icon: String) -> Self {
|
||||||
|
Self {
|
||||||
|
icon,
|
||||||
|
msg: TestMsg::Add,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[relm4::factory(pub)]
|
#[relm4::factory(pub)]
|
||||||
impl FactoryComponent for BottomBarModel {
|
impl FactoryComponent for BottomBarModel {
|
||||||
type ParentWidget = gtk::Box;
|
type ParentWidget = gtk::Box;
|
||||||
type ParentInput = Msg;
|
type ParentInput = Msg;
|
||||||
type Input = ();
|
type Input = ();
|
||||||
type Output = TextMsg;
|
type Output = TestMsg;
|
||||||
type Init = BottomBarModel;
|
type Init = BottomBarModel;
|
||||||
type CommandOutput = ();
|
type CommandOutput = ();
|
||||||
|
|
||||||
@ -34,8 +43,7 @@ impl FactoryComponent for BottomBarModel {
|
|||||||
#[root]
|
#[root]
|
||||||
gtk::Box{
|
gtk::Box{
|
||||||
gtk::Button{
|
gtk::Button{
|
||||||
#[wrap(Some)]
|
set_icon_name=self.icon.as_str(),
|
||||||
set_icon_name= model.icon.as_str(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +54,13 @@ impl FactoryComponent for BottomBarModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, message: Self::Input, sender: FactorySender<Self>) {
|
fn update(&mut self, message: Self::Input, sender: FactorySender<Self>) {
|
||||||
match message {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn forward_to_parent(_output: Self::Output) -> Option<Self::ParentInput> {
|
||||||
|
Some(match _output {
|
||||||
|
_ => Msg::None
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ pub struct SideBarModel {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Msg {
|
pub enum Msg {
|
||||||
RefreshList(Vec<Layer>),
|
RefreshList(Vec<Layer>),
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -64,7 +65,7 @@ impl SimpleComponent for SideBarModel {
|
|||||||
sender.output(
|
sender.output(
|
||||||
SideBarOutputMsg::NewLayer(
|
SideBarOutputMsg::NewLayer(
|
||||||
Layer::grid_render_layer_with_path(
|
Layer::grid_render_layer_with_path(
|
||||||
"/users/tsuki/projects/radar-g/test2.npz",
|
std::path::Path::new("./test2.npz"),
|
||||||
"DBZ".to_string(),
|
"DBZ".to_string(),
|
||||||
Npz,
|
Npz,
|
||||||
BoundaryNorm::default(),
|
BoundaryNorm::default(),
|
||||||
@ -83,10 +84,12 @@ impl SimpleComponent for SideBarModel {
|
|||||||
#[local]
|
#[local]
|
||||||
bottom_panel -> gtk::Notebook{
|
bottom_panel -> gtk::Notebook{
|
||||||
set_margin_top: 10,
|
set_margin_top: 10,
|
||||||
set_margin_bottom: 10,
|
set_margin_bottom: 5,
|
||||||
},
|
},
|
||||||
#[local_ref]
|
#[local_ref]
|
||||||
counter_box -> gtk::Box{}
|
counter_box -> gtk::Box{
|
||||||
|
set_spacing: 5,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -103,7 +106,16 @@ impl SimpleComponent for SideBarModel {
|
|||||||
let mut list_view_wrapper: TypedListView<LayerItem, gtk::SingleSelection> =
|
let mut list_view_wrapper: TypedListView<LayerItem, gtk::SingleSelection> =
|
||||||
TypedListView::with_sorting();
|
TypedListView::with_sorting();
|
||||||
|
|
||||||
let bottom_bar_vec = FactoryVecDeque::new(gtk::Box::default(), sender.input_sender());
|
let mut bottom_bar_vec = FactoryVecDeque::new(gtk::Box::default(), sender.input_sender());
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut bottom_bar_vec_guard = bottom_bar_vec.guard();
|
||||||
|
bottom_bar_vec_guard.push_back(BottomBarModel::new("add-filled".to_string()));
|
||||||
|
bottom_bar_vec_guard.push_back(BottomBarModel::new("delete-filled".to_string()));
|
||||||
|
bottom_bar_vec_guard.push_back(BottomBarModel::new("chevron-up-filled".to_string()));
|
||||||
|
bottom_bar_vec_guard.push_back(BottomBarModel::new("chevron-down-filled".to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
let model = SideBarModel {
|
let model = SideBarModel {
|
||||||
counter: 0,
|
counter: 0,
|
||||||
@ -121,7 +133,7 @@ impl SimpleComponent for SideBarModel {
|
|||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let counter_box = model.bottom_bar_vec.widgets();
|
let counter_box = model.bottom_bar_vec.widget();
|
||||||
|
|
||||||
layer_page.set_child(Some(my_view));
|
layer_page.set_child(Some(my_view));
|
||||||
layer_page.set_margin_horizontal(5);
|
layer_page.set_margin_horizontal(5);
|
||||||
@ -140,6 +152,8 @@ impl SimpleComponent for SideBarModel {
|
|||||||
.append(LayerItem::new(layer.name, true));
|
.append(LayerItem::new(layer.name, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -215,7 +215,7 @@ impl Render {
|
|||||||
renderer.set_screen_target(Some(fbo));
|
renderer.set_screen_target(Some(fbo));
|
||||||
let mut canvas = Canvas::new(renderer).expect("Cannot create canvas");
|
let mut canvas = Canvas::new(renderer).expect("Cannot create canvas");
|
||||||
canvas
|
canvas
|
||||||
.add_font_dir("/Users/tsuki/projects/radar-g/src/assets")
|
.add_font_dir(std::path::Path::new("./src/assets"))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
self.canvas.replace(Some(canvas));
|
self.canvas.replace(Some(canvas));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user