small structural changes

This commit is contained in:
2024-11-08 11:33:29 +01:00
parent 5ff2866f26
commit da2b04c87e
5 changed files with 175 additions and 173 deletions
+20 -11
View File
@@ -61,8 +61,8 @@ macro_rules! element {
}
fn update_data(&mut self, width: usize, height: usize) {
self.width.try_set_size(width);
self.height.try_set_size(height);
self.width.try_set_value(width);
self.height.try_set_value(height);
for child in &mut self.children {
child.update_data(width, height);
}
@@ -174,14 +174,6 @@ macro_rules! parse_rsx_param {
osui::parse_rsx_param!($elem, $($rest)*);
};
($elem:expr, $($k:ident).+:$($rest:tt)*) => {
$elem.$($k).+ = ();
};
($elem:expr, $($k:ident).+:$($rest:tt)*) => {
$elem.$($k).+ = $v;
osui::parse_rsx_param!($elem, $($rest)*);
};
// For loop
($elem:expr, for ($($for:tt)*) { $($inner:tt)* } $($rest:tt)*) => {
for $($for)* {
@@ -245,6 +237,16 @@ macro_rules! rsx_elem {
}};
}
#[macro_export]
macro_rules! rsx_elem_raw {
($elem:path { $($inner:tt)* }) => {{
#[allow(unused_mut)]
let mut elem = $elem();
osui::parse_rsx_param!(elem, $($inner)*);
elem
}};
}
/// Macro for defining a structured representation of UI elements in OSUI.
///
/// # Example
@@ -261,7 +263,7 @@ macro_rules! rsx_elem {
#[macro_export]
macro_rules! rsx {
($($inner:tt)*) => {{
osui::rsx_elem!( osui::ui::div { $($inner)* } )
osui::rsx_elem_raw!( osui::ui::div { $($inner)* } )
}};
}
@@ -293,3 +295,10 @@ macro_rules! arc {
std::sync::Arc::new(std::sync::Mutex::new($a))
};
}
#[macro_export]
macro_rules! val {
($a:expr) => {
osui::Value::new($a)
};
}