layout manager test
This commit is contained in:
parent
1218af7314
commit
5217d0dd64
@ -1,8 +1,10 @@
|
||||
use crate::{
|
||||
components::render_panel::messages::{MonitorInputMsg, MonitorOutputMsg},
|
||||
data::Npz,
|
||||
dynamic_col::DynamicCol,
|
||||
render::{predefined::color_mapper::BoundaryNorm, Layer, Render},
|
||||
};
|
||||
use glib::clone;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::sidebar::{sidebar::SideBarModel, Msg, SideBarOutputMsg};
|
||||
@ -39,22 +41,31 @@ impl AsyncComponent for MonitorModel {
|
||||
set_height_request: 500,
|
||||
set_width_request: 700,
|
||||
#[wrap(Some)]
|
||||
set_child=>k::Paned{
|
||||
set_position: 1000,
|
||||
#[name="test"]
|
||||
set_child = &DynamicCol{
|
||||
set_ratio: 0.5,
|
||||
set_hexpand: true,
|
||||
set_vexpand: true,
|
||||
#[wrap(Some)]
|
||||
#[name="render"]
|
||||
set_start_child=>k::Box{
|
||||
add_css_class: "rb",
|
||||
set_margin_all: 5,
|
||||
Render{
|
||||
#[name="paned"]
|
||||
set_child=>k::Paned{
|
||||
set_position: top_level_window_unwrap.default_width() - model.sidebar_width,
|
||||
#[wrap(Some)]
|
||||
#[name="render"]
|
||||
set_start_child=>k::Frame{
|
||||
add_css_class: "rb",
|
||||
#[watch]
|
||||
set_interior_layers: model.layers.clone(),
|
||||
}
|
||||
},
|
||||
#[wrap(Some)]
|
||||
set_end_child=model.sidebar.widget(),
|
||||
}
|
||||
set_margin_all: 5,
|
||||
Render{
|
||||
add_css_class: "rb",
|
||||
#[watch]
|
||||
set_interior_layers: model.layers.clone(),
|
||||
}
|
||||
},
|
||||
#[wrap(Some)]
|
||||
set_end_child=model.sidebar.widget(),
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +88,14 @@ impl AsyncComponent for MonitorModel {
|
||||
sidebar,
|
||||
};
|
||||
|
||||
let top_level_window = root.toplevel_window();
|
||||
let top_level_window_unwrap = top_level_window.unwrap();
|
||||
|
||||
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 }
|
||||
}
|
||||
|
||||
|
||||
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 relm4::menu;
|
||||
use relm4::RelmApp;
|
||||
use tokio::runtime::Runtime;
|
||||
use std::ptr;
|
||||
use tokio::runtime::Runtime;
|
||||
mod chart;
|
||||
mod components;
|
||||
mod coords;
|
||||
mod data;
|
||||
mod dealers;
|
||||
mod dynamic_col;
|
||||
mod errors;
|
||||
mod pipeline;
|
||||
mod render;
|
||||
@ -26,7 +27,9 @@ fn main() {
|
||||
// Load GL pointers from epoxy (GL context management library used by GTK).
|
||||
{
|
||||
#[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")))]
|
||||
let library = unsafe { libloading::os::unix::Library::new("libepoxy.so.0") }.unwrap();
|
||||
#[cfg(windows)]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user