mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 07:10:04 -04:00
Correctly align checkboxes and radiobuttons within justified layouts
This commit is contained in:
2
TODO.md
2
TODO.md
@@ -5,7 +5,7 @@ TODO-list for the Egui project. If you looking for something to do, look here.
|
|||||||
## Layout refactor
|
## Layout refactor
|
||||||
|
|
||||||
* Test `allocate_ui`
|
* Test `allocate_ui`
|
||||||
* Justified alignment of radio button and checkboxes
|
* Text wrapping
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
|
|
||||||
|
|||||||
@@ -389,6 +389,7 @@ impl LayoutDemo {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui.horizontal(|ui| {
|
||||||
ui.checkbox(&mut self.main_wrap, "Main wrap")
|
ui.checkbox(&mut self.main_wrap, "Main wrap")
|
||||||
.on_hover_text("Wrap when next widget doesn't fit the current row/column");
|
.on_hover_text("Wrap when next widget doesn't fit the current row/column");
|
||||||
|
|
||||||
@@ -396,9 +397,12 @@ impl LayoutDemo {
|
|||||||
if self.main_dir.is_horizontal() {
|
if self.main_dir.is_horizontal() {
|
||||||
ui.add(Slider::f32(&mut self.wrap_row_height, 0.0..=200.0).text("Row height"));
|
ui.add(Slider::f32(&mut self.wrap_row_height, 0.0..=200.0).text("Row height"));
|
||||||
} else {
|
} else {
|
||||||
ui.add(Slider::f32(&mut self.wrap_column_width, 0.0..=200.0).text("Column width"));
|
ui.add(
|
||||||
|
Slider::f32(&mut self.wrap_column_width, 0.0..=200.0).text("Column width"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.label("Cross Align:");
|
ui.label("Cross Align:");
|
||||||
|
|||||||
@@ -385,6 +385,7 @@ impl<'a> Widget for Checkbox<'a> {
|
|||||||
desired_size = desired_size.at_least(spacing.interact_size);
|
desired_size = desired_size.at_least(spacing.interact_size);
|
||||||
desired_size.y = desired_size.y.max(icon_width);
|
desired_size.y = desired_size.y.max(icon_width);
|
||||||
let rect = ui.allocate_space(desired_size);
|
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 id = ui.make_position_id();
|
||||||
let response = ui.interact(rect, id, Sense::click());
|
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 = desired_size.at_least(ui.style().spacing.interact_size);
|
||||||
desired_size.y = desired_size.y.max(icon_width);
|
desired_size.y = desired_size.y.max(icon_width);
|
||||||
let rect = ui.allocate_space(desired_size);
|
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 id = ui.make_position_id();
|
||||||
let response = ui.interact(rect, id, Sense::click());
|
let response = ui.interact(rect, id, Sense::click());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user