From 6b82c26aba3ba9ab23f971adcba33dca0101c4d8 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Mon, 17 Aug 2026 20:54:05 +0200 Subject: [PATCH] small simplification --- ui-rs/src/ui/button.rs | 4 ++-- ui-rs/src/ui/container.rs | 50 +++++++++++++++++++-------------------- ui-rs/src/ui/list.rs | 4 ++-- ui-rs/src/ui/text.rs | 2 +- ui-rs/src/ui/window.rs | 6 ++--- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/ui-rs/src/ui/button.rs b/ui-rs/src/ui/button.rs index ded533b..5338f3f 100644 --- a/ui-rs/src/ui/button.rs +++ b/ui-rs/src/ui/button.rs @@ -424,7 +424,7 @@ impl<'a, T> ToggleBuilder<'a, T> { pub fn fill(&mut self, fill: bool) -> &mut Self { unsafe { - ui_toggle_args_set_fill(self.args, if fill { 1 } else { 0 }); + ui_toggle_args_set_fill(self.args, fill as c_int); } self } @@ -620,7 +620,7 @@ impl<'a, T> LinkButtonBuilder<'a, T> { pub fn fill(&mut self, fill: bool) -> &mut Self { unsafe { - ui_linkbutton_args_set_fill(self.args, if fill { 1 } else { 0 }); + ui_linkbutton_args_set_fill(self.args, fill as c_int); } self } diff --git a/ui-rs/src/ui/container.rs b/ui-rs/src/ui/container.rs index 83ec79b..c4b9ee8 100644 --- a/ui-rs/src/ui/container.rs +++ b/ui-rs/src/ui/container.rs @@ -309,42 +309,42 @@ impl<'a, T> ContainerBuilder<'a, T> { pub fn fill(&mut self, fill: bool) -> &mut Self { unsafe { - ui_container_args_set_fill(self.args, if fill { 1 } else { 0 }); + ui_container_args_set_fill(self.args, fill as c_int); } self } pub fn hexpand(&mut self, value: bool) -> &mut Self { unsafe { - ui_container_args_set_hexpand(self.args, if value { 1 } else { 0 }); + ui_container_args_set_hexpand(self.args, value as c_int); } self } pub fn vexpand(&mut self, value: bool) -> &mut Self { unsafe { - ui_container_args_set_vexpand(self.args, if value { 1 } else { 0 }); + ui_container_args_set_vexpand(self.args, value as c_int); } self } pub fn hfill(&mut self, value: bool) -> &mut Self { unsafe { - ui_container_args_set_hfill(self.args, if value { 1 } else { 0 }); + ui_container_args_set_hfill(self.args, value as c_int); } self } pub fn vfill(&mut self, value: bool) -> &mut Self { unsafe { - ui_container_args_set_vfill(self.args, if value { 1 } else { 0 }); + ui_container_args_set_vfill(self.args, value as c_int); } 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 }); + ui_container_args_set_override_defaults(self.args, value as c_int); } self } @@ -559,42 +559,42 @@ impl<'a, T> FrameBuilder<'a, T> { pub fn fill(&mut self, fill: bool) -> &mut Self { unsafe { - ui_frame_args_set_fill(self.args, if fill { 1 } else { 0 }); + ui_frame_args_set_fill(self.args, fill as c_int); } self } pub fn hexpand(&mut self, value: bool) -> &mut Self { unsafe { - ui_frame_args_set_hexpand(self.args, if value { 1 } else { 0 }); + ui_frame_args_set_hexpand(self.args, value as c_int); } self } pub fn vexpand(&mut self, value: bool) -> &mut Self { unsafe { - ui_frame_args_set_vexpand(self.args, if value { 1 } else { 0 }); + ui_frame_args_set_vexpand(self.args, value as c_int); } self } pub fn hfill(&mut self, value: bool) -> &mut Self { unsafe { - ui_frame_args_set_hfill(self.args, if value { 1 } else { 0 }); + ui_frame_args_set_hfill(self.args, value as c_int); } self } pub fn vfill(&mut self, value: bool) -> &mut Self { unsafe { - ui_frame_args_set_vfill(self.args, if value { 1 } else { 0 }); + ui_frame_args_set_vfill(self.args, value as c_int); } self } pub fn override_defaults(&mut self, value: bool) -> &mut Self { unsafe { - ui_frame_args_set_override_defaults(self.args, if value { 1 } else { 0 }); + ui_frame_args_set_override_defaults(self.args, value as c_int); } self } @@ -695,7 +695,7 @@ impl<'a, T> FrameBuilder<'a, T> { pub fn expanded(&mut self, value: bool) -> &mut Self { unsafe { - ui_frame_args_set_expanded(self.args, if value { 1 } else { 0 }); + ui_frame_args_set_expanded(self.args, value as c_int); } self } @@ -787,42 +787,42 @@ impl<'a, T> SplitPaneBuilder<'a, T> { pub fn fill(&mut self, fill: bool) -> &mut Self { unsafe { - ui_splitpane_args_set_fill(self.args, if fill { 1 } else { 0 }); + ui_splitpane_args_set_fill(self.args, fill as c_int); } self } pub fn hexpand(&mut self, value: bool) -> &mut Self { unsafe { - ui_splitpane_args_set_hexpand(self.args, if value { 1 } else { 0 }); + ui_splitpane_args_set_hexpand(self.args, value as c_int); } self } pub fn vexpand(&mut self, value: bool) -> &mut Self { unsafe { - ui_splitpane_args_set_vexpand(self.args, if value { 1 } else { 0 }); + ui_splitpane_args_set_vexpand(self.args, value as c_int); } self } pub fn hfill(&mut self, value: bool) -> &mut Self { unsafe { - ui_splitpane_args_set_hfill(self.args, if value { 1 } else { 0 }); + ui_splitpane_args_set_hfill(self.args, value as c_int); } self } pub fn vfill(&mut self, value: bool) -> &mut Self { unsafe { - ui_splitpane_args_set_vfill(self.args, if value { 1 } else { 0 }); + ui_splitpane_args_set_vfill(self.args, value as c_int); } self } pub fn override_defaults(&mut self, value: bool) -> &mut Self { unsafe { - ui_splitpane_args_set_override_defaults(self.args, if value { 1 } else { 0 }); + ui_splitpane_args_set_override_defaults(self.args, value as c_int); } self } @@ -1138,42 +1138,42 @@ impl<'a, T> TabViewBuilder<'a, T> { pub fn fill(&mut self, fill: bool) -> &mut Self { unsafe { - ui_tabview_args_set_fill(self.args, if fill { 1 } else { 0 }); + ui_tabview_args_set_fill(self.args, fill as c_int); } self } pub fn hexpand(&mut self, value: bool) -> &mut Self { unsafe { - ui_tabview_args_set_hexpand(self.args, if value { 1 } else { 0 }); + ui_tabview_args_set_hexpand(self.args, value as c_int); } self } pub fn vexpand(&mut self, value: bool) -> &mut Self { unsafe { - ui_tabview_args_set_vexpand(self.args, if value { 1 } else { 0 }); + ui_tabview_args_set_vexpand(self.args, value as c_int); } self } pub fn hfill(&mut self, value: bool) -> &mut Self { unsafe { - ui_tabview_args_set_hfill(self.args, if value { 1 } else { 0 }); + ui_tabview_args_set_hfill(self.args, value as c_int); } self } pub fn vfill(&mut self, value: bool) -> &mut Self { unsafe { - ui_tabview_args_set_vfill(self.args, if value { 1 } else { 0 }); + ui_tabview_args_set_vfill(self.args, value as c_int); } self } pub fn override_defaults(&mut self, value: bool) -> &mut Self { unsafe { - ui_tabview_args_set_override_defaults(self.args, if value { 1 } else { 0 }); + ui_tabview_args_set_override_defaults(self.args, value as c_int); } self } diff --git a/ui-rs/src/ui/list.rs b/ui-rs/src/ui/list.rs index bbb7c29..8e3555e 100644 --- a/ui-rs/src/ui/list.rs +++ b/ui-rs/src/ui/list.rs @@ -430,7 +430,7 @@ impl<'a, T, E> TableViewBuilder<'a, T, E> { pub fn fill(&mut self, fill: bool) -> &mut Self { unsafe { - ui_list_args_set_fill(self.args, if fill { 1 } else { 0 }); + ui_list_args_set_fill(self.args, fill as c_int); } self } @@ -657,7 +657,7 @@ impl<'a, T, E> SourceListBuilder<'a, T, E> { pub fn fill(&mut self, fill: bool) -> &mut Self { unsafe { - ui_sourcelist_args_set_fill(self.args, if fill { 1 } else { 0 }); + ui_sourcelist_args_set_fill(self.args, fill as c_int); } self } diff --git a/ui-rs/src/ui/text.rs b/ui-rs/src/ui/text.rs index ca67ffc..2d32120 100644 --- a/ui-rs/src/ui/text.rs +++ b/ui-rs/src/ui/text.rs @@ -464,7 +464,7 @@ impl<'a, T> TextFieldBuilder<'a, T> { pub fn fill(&mut self, fill: bool) -> &mut Self { unsafe { - ui_textfield_args_set_fill(self.args, if fill { 1 } else { 0 }); + ui_textfield_args_set_fill(self.args, fill as c_int); } self } diff --git a/ui-rs/src/ui/window.rs b/ui-rs/src/ui/window.rs index 8606175..9d22925 100644 --- a/ui-rs/src/ui/window.rs +++ b/ui-rs/src/ui/window.rs @@ -346,21 +346,21 @@ impl DialogWindowBuilder { pub fn modal(&mut self, val: bool) -> &mut Self { unsafe { - ui_dialogwindow_args_set_modal(self.args, if val { 1 } else { 2 }); + ui_dialogwindow_args_set_modal(self.args, val as c_int); } self } pub fn titlebar_buttons(&mut self, val: bool) -> &mut Self { unsafe { - ui_dialogwindow_args_set_titlebar_buttons(self.args, if val { 1 } else { 2 }); + ui_dialogwindow_args_set_titlebar_buttons(self.args, val as c_int); } self } pub fn show_closebutton(&mut self, val: bool) -> &mut Self { unsafe { - ui_dialogwindow_args_set_show_closebutton(self.args, if val { 1 } else { 2 }); + ui_dialogwindow_args_set_show_closebutton(self.args, val as c_int); } self } -- 2.52.0