diff --git a/TODO.md b/TODO.md index 88b824d0..98b1b89d 100644 --- a/TODO.md +++ b/TODO.md @@ -5,7 +5,7 @@ TODO-list for the Egui project. If you looking for something to do, look here. ## Layout refactor * Test `allocate_ui` -* Justified alignment of radio button and checkboxes +* Text wrapping ## Misc diff --git a/egui/src/demos/demo_window.rs b/egui/src/demos/demo_window.rs index e45a4c1e..a264d1bf 100644 --- a/egui/src/demos/demo_window.rs +++ b/egui/src/demos/demo_window.rs @@ -389,16 +389,20 @@ impl LayoutDemo { } }); - ui.checkbox(&mut self.main_wrap, "Main wrap") - .on_hover_text("Wrap when next widget doesn't fit the current row/column"); + ui.horizontal(|ui| { + ui.checkbox(&mut self.main_wrap, "Main wrap") + .on_hover_text("Wrap when next widget doesn't fit the current row/column"); - if self.main_wrap { - if self.main_dir.is_horizontal() { - ui.add(Slider::f32(&mut self.wrap_row_height, 0.0..=200.0).text("Row height")); - } else { - ui.add(Slider::f32(&mut self.wrap_column_width, 0.0..=200.0).text("Column width")); + if self.main_wrap { + if self.main_dir.is_horizontal() { + ui.add(Slider::f32(&mut self.wrap_row_height, 0.0..=200.0).text("Row height")); + } else { + ui.add( + Slider::f32(&mut self.wrap_column_width, 0.0..=200.0).text("Column width"), + ); + } } - } + }); ui.horizontal(|ui| { ui.label("Cross Align:"); diff --git a/egui/src/widgets/mod.rs b/egui/src/widgets/mod.rs index 492f6230..f61d42d4 100644 --- a/egui/src/widgets/mod.rs +++ b/egui/src/widgets/mod.rs @@ -385,6 +385,7 @@ impl<'a> Widget for Checkbox<'a> { desired_size = desired_size.at_least(spacing.interact_size); desired_size.y = desired_size.y.max(icon_width); let rect = ui.allocate_space(desired_size); + let rect = ui.layout().align_size_within_rect(desired_size, rect); let id = ui.make_position_id(); let response = ui.interact(rect, id, Sense::click()); @@ -473,6 +474,8 @@ impl Widget for RadioButton { desired_size = desired_size.at_least(ui.style().spacing.interact_size); desired_size.y = desired_size.y.max(icon_width); let rect = ui.allocate_space(desired_size); + let rect = ui.layout().align_size_within_rect(desired_size, rect); + let id = ui.make_position_id(); let response = ui.interact(rect, id, Sense::click());