Work on constraint layout

This commit is contained in:
Michael Mikovsky
2025-10-29 14:18:23 -06:00
parent b46f2683ff
commit 1341c29dd1
10 changed files with 530 additions and 59 deletions
+14 -4
View File
@@ -1,12 +1,16 @@
use crate::views::{Bounds, View};
use crate::views::{Bounds, LayoutView, View};
pub struct VerticalLayout {
pub views: Vec<Box<dyn View>>,
pub views: Vec<Box<dyn LayoutView>>,
pub bounds: (Option<Bounds>, Option<Bounds>),
}
impl VerticalLayout {
pub fn new(views: Vec<Box<dyn View>>) -> Self {
Self { views }
pub fn new(views: Vec<Box<dyn LayoutView>>) -> Self {
Self {
views,
bounds: (None, None),
}
}
}
@@ -34,6 +38,12 @@ impl View for VerticalLayout {
}
}
}
}
impl LayoutView for VerticalLayout {
fn set_bounds(&mut self, width: Option<Bounds>, height: Option<Bounds>) {
self.bounds = (width, height);
}
fn bounds(&self, pw: f32, ph: f32) -> (Bounds, Bounds) {
let (mut maxx, mut totaly): (f32, f32) = (0., 0.);