layout manager test
This commit is contained in:
parent
1218af7314
commit
5217d0dd64
@ -1,8 +1,10 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
components::render_panel::messages::{MonitorInputMsg, MonitorOutputMsg},
|
components::render_panel::messages::{MonitorInputMsg, MonitorOutputMsg},
|
||||||
data::Npz,
|
data::Npz,
|
||||||
|
dynamic_col::DynamicCol,
|
||||||
render::{predefined::color_mapper::BoundaryNorm, Layer, Render},
|
render::{predefined::color_mapper::BoundaryNorm, Layer, Render},
|
||||||
};
|
};
|
||||||
|
use glib::clone;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use super::sidebar::{sidebar::SideBarModel, Msg, SideBarOutputMsg};
|
use super::sidebar::{sidebar::SideBarModel, Msg, SideBarOutputMsg};
|
||||||
@ -39,22 +41,31 @@ impl AsyncComponent for MonitorModel {
|
|||||||
set_height_request: 500,
|
set_height_request: 500,
|
||||||
set_width_request: 700,
|
set_width_request: 700,
|
||||||
#[wrap(Some)]
|
#[wrap(Some)]
|
||||||
set_child=>k::Paned{
|
#[name="test"]
|
||||||
set_position: 1000,
|
set_child = &DynamicCol{
|
||||||
|
set_ratio: 0.5,
|
||||||
|
set_hexpand: true,
|
||||||
|
set_vexpand: true,
|
||||||
#[wrap(Some)]
|
#[wrap(Some)]
|
||||||
#[name="render"]
|
#[name="paned"]
|
||||||
set_start_child=>k::Box{
|
set_child=>k::Paned{
|
||||||
add_css_class: "rb",
|
set_position: top_level_window_unwrap.default_width() - model.sidebar_width,
|
||||||
set_margin_all: 5,
|
#[wrap(Some)]
|
||||||
Render{
|
#[name="render"]
|
||||||
|
set_start_child=>k::Frame{
|
||||||
add_css_class: "rb",
|
add_css_class: "rb",
|
||||||
#[watch]
|
set_margin_all: 5,
|
||||||
set_interior_layers: model.layers.clone(),
|
Render{
|
||||||
}
|
add_css_class: "rb",
|
||||||
},
|
#[watch]
|
||||||
#[wrap(Some)]
|
set_interior_layers: model.layers.clone(),
|
||||||
set_end_child=model.sidebar.widget(),
|
}
|
||||||
}
|
},
|
||||||
|
#[wrap(Some)]
|
||||||
|
set_end_child=model.sidebar.widget(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +88,14 @@ impl AsyncComponent for MonitorModel {
|
|||||||
sidebar,
|
sidebar,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let top_level_window = root.toplevel_window();
|
||||||
|
let top_level_window_unwrap = top_level_window.unwrap();
|
||||||
|
|
||||||
let widgets = view_output! {};
|
let widgets = view_output! {};
|
||||||
|
top_level_window_unwrap.connect_width_request_notify(|w| {
|
||||||
|
println!("window width: {}", w.width_request());
|
||||||
|
});
|
||||||
|
println!("window width: {}", widgets.test.get_start_width());
|
||||||
AsyncComponentParts { model, widgets }
|
AsyncComponentParts { model, widgets }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
src/dynamic_col/custom_layout/imp.rs
Normal file
0
src/dynamic_col/custom_layout/imp.rs
Normal file
1
src/dynamic_col/custom_layout/mod.rs
Normal file
1
src/dynamic_col/custom_layout/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
mod imp;
|
||||||
38
src/dynamic_col/imp.rs
Normal file
38
src/dynamic_col/imp.rs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
use adw::subclass::bin::BinImpl;
|
||||||
|
use gtk::glib;
|
||||||
|
use gtk::subclass::prelude::*;
|
||||||
|
use std::cell::{Cell, RefCell};
|
||||||
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
|
pub struct DynamicCol {
|
||||||
|
pub(super) ratio: RefCell<Option<f64>>,
|
||||||
|
width: Cell<i32>,
|
||||||
|
pub(super) start_width: Cell<i32>,
|
||||||
|
pub(super) end_width: Cell<i32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for DynamicCol {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
ratio: RefCell::new(None),
|
||||||
|
width: Cell::new(0),
|
||||||
|
start_width: Cell::new(0),
|
||||||
|
end_width: Cell::new(0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[glib::object_subclass]
|
||||||
|
impl ObjectSubclass for DynamicCol {
|
||||||
|
const NAME: &'static str = "DynamicCol";
|
||||||
|
type Type = super::DynamicCol;
|
||||||
|
type ParentType = gtk::Box;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ObjectImpl for DynamicCol {}
|
||||||
|
|
||||||
|
impl WidgetImpl for DynamicCol {}
|
||||||
|
|
||||||
|
impl BoxImpl for DynamicCol {}
|
||||||
|
|
||||||
|
impl WidgetImplExt for DynamicCol{}
|
||||||
52
src/dynamic_col/mod.rs
Normal file
52
src/dynamic_col/mod.rs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
mod imp;
|
||||||
|
mod custom_layout;
|
||||||
|
use glib::clone;
|
||||||
|
pub use glib::subclass::prelude::*;
|
||||||
|
use gtk::traits::WidgetExt;
|
||||||
|
use std::cell::{Ref, RefCell, RefMut};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
glib::wrapper! {
|
||||||
|
pub struct DynamicCol(ObjectSubclass<imp::DynamicCol>)
|
||||||
|
@extends gtk::Box, gtk::Widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for DynamicCol {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DynamicCol {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let this: Self = glib::Object::new();
|
||||||
|
this
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_ratio(&self, ratio: f64) {
|
||||||
|
let self_ = imp::DynamicCol::from_instance(self);
|
||||||
|
self_.ratio.replace(Some(ratio));
|
||||||
|
self.queue_resize();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_ratio(&self) -> Option<f64> {
|
||||||
|
let self_ = imp::DynamicCol::from_instance(self);
|
||||||
|
*self_.ratio.borrow()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_start_width(&self) -> i32 {
|
||||||
|
let self_ = imp::DynamicCol::from_instance(self);
|
||||||
|
self_.start_width.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_end_width(&self) -> i32 {
|
||||||
|
let self_ = imp::DynamicCol::from_instance(self);
|
||||||
|
self_.end_width.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test(&self) {
|
||||||
|
let imp = self.imp();
|
||||||
|
|
||||||
|
let manager = imp.layout_manager();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,13 +3,14 @@ use gtk::prelude::*;
|
|||||||
use gtk::{gio, glib, Application, ApplicationWindow};
|
use gtk::{gio, glib, Application, ApplicationWindow};
|
||||||
use relm4::menu;
|
use relm4::menu;
|
||||||
use relm4::RelmApp;
|
use relm4::RelmApp;
|
||||||
use tokio::runtime::Runtime;
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
mod chart;
|
mod chart;
|
||||||
mod components;
|
mod components;
|
||||||
mod coords;
|
mod coords;
|
||||||
mod data;
|
mod data;
|
||||||
mod dealers;
|
mod dealers;
|
||||||
|
mod dynamic_col;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod pipeline;
|
mod pipeline;
|
||||||
mod render;
|
mod render;
|
||||||
@ -26,7 +27,9 @@ fn main() {
|
|||||||
// Load GL pointers from epoxy (GL context management library used by GTK).
|
// Load GL pointers from epoxy (GL context management library used by GTK).
|
||||||
{
|
{
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let library = unsafe { libloading::os::unix::Library::new("libepoxy.0.dylib") }.unwrap();
|
let library =
|
||||||
|
unsafe { libloading::os::unix::Library::new("/opt/homebrew/lib/libepoxy.0.dylib") }
|
||||||
|
.unwrap();
|
||||||
#[cfg(all(unix, not(target_os = "macos")))]
|
#[cfg(all(unix, not(target_os = "macos")))]
|
||||||
let library = unsafe { libloading::os::unix::Library::new("libepoxy.so.0") }.unwrap();
|
let library = unsafe { libloading::os::unix::Library::new("libepoxy.so.0") }.unwrap();
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user