From d7429f1469de21f1f3feb923ff22d2a7e0e8415f Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Sat, 4 Apr 2026 11:45:22 +0200 Subject: [PATCH] add remaining ContainerBuilder functions --- application/src/main.rs | 8 --- ui-rs/src/ui/container.rs | 129 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 8 deletions(-) diff --git a/application/src/main.rs b/application/src/main.rs index af437b4..775af6f 100644 --- a/application/src/main.rs +++ b/application/src/main.rs @@ -27,14 +27,6 @@ impl ui::Application for App { }); }); - obj.hbox(|_b| { - - }, - |obj| { - obj.button(|b|{ b.label("HButton X1"); }); - obj.button(|b|{ b.label("HButton X2"); }); - }); - obj.show(); } } diff --git a/ui-rs/src/ui/container.rs b/ui-rs/src/ui/container.rs index 4bccdac..a274afe 100644 --- a/ui-rs/src/ui/container.rs +++ b/ui-rs/src/ui/container.rs @@ -2,6 +2,7 @@ #[allow(unused_imports)] use std::ffi::{c_char, c_int, c_void}; +use std::ffi::CString; use crate::ui::ffi::*; use crate::ui::{toolkit}; @@ -130,6 +131,134 @@ impl<'a> ContainerBuilder<'a> { ui_container_finish(self.obj.ptr); } } + + pub fn fill(&mut self, fill: bool) -> &mut Self { + unsafe { + ui_container_args_set_fill(self.args, if fill { 1 } else { 0 }); + } + self + } + + pub fn hexpand(&mut self, value: bool) -> &mut Self { + unsafe { + ui_container_args_set_hexpand(self.args, if value { 1 } else { 0 }); + } + self + } + + pub fn vexpand(&mut self, value: bool) -> &mut Self { + unsafe { + ui_container_args_set_vexpand(self.args, if value { 1 } else { 0 }); + } + self + } + + pub fn hfill(&mut self, value: bool) -> &mut Self { + unsafe { + ui_container_args_set_hfill(self.args, if value { 1 } else { 0 }); + } + self + } + + pub fn vfill(&mut self, value: bool) -> &mut Self { + unsafe { + ui_container_args_set_vfill(self.args, if value { 1 } else { 0 }); + } + self + } + + pub fn override_defaults(&mut self, value: bool) -> &mut Self { + unsafe { + ui_container_args_set_override_defaults(self.args, if value { 1 } else { 0 }); + } + self + } + + pub fn margin(&mut self, value: i32) -> &mut Self { + unsafe { + ui_container_args_set_margin(self.args, value); + } + self + } + + pub fn margin_left(&mut self, value: i32) -> &mut Self { + unsafe { + ui_container_args_set_margin_left(self.args, value); + } + self + } + + pub fn margin_right(&mut self, value: i32) -> &mut Self { + unsafe { + ui_container_args_set_margin_right(self.args, value); + } + self + } + + pub fn margin_top(&mut self, value: i32) -> &mut Self { + unsafe { + ui_container_args_set_margin_top(self.args, value); + } + self + } + + pub fn margin_bottom(&mut self, value: i32) -> &mut Self { + unsafe { + ui_container_args_set_margin_bottom(self.args, value); + } + self + } + + pub fn colspan(&mut self, value: i32) -> &mut Self { + unsafe { + ui_container_args_set_colspan(self.args, value); + } + self + } + + pub fn rowspan(&mut self, value: i32) -> &mut Self { + unsafe { + ui_container_args_set_rowspan(self.args, value); + } + self + } + + pub fn name(&mut self, value: &str) -> &mut Self { + let cstr = CString::new(value).unwrap(); + unsafe { + ui_container_args_set_name(self.args, cstr.as_ptr()); + } + self + } + + pub fn style_class(&mut self, value: &str) -> &mut Self { + let cstr = CString::new(value).unwrap(); + unsafe { + ui_container_args_set_style_class(self.args, cstr.as_ptr()); + } + self + } + + pub fn spacing(&mut self, value: i32) -> &mut Self { + unsafe { + ui_container_args_set_spacing(self.args, value); + } + self + } + + pub fn columnspacing(&mut self, value: i32) -> &mut Self { + unsafe { + ui_container_args_set_columnspacing(self.args, value); + } + self + } + + pub fn rowspacing(&mut self, value: i32) -> &mut Self { + unsafe { + ui_container_args_set_rowspacing(self.args, value); + } + self + } } impl<'a> Drop for ContainerBuilder<'a> { -- 2.47.3