1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

Add support for reversed layouts

This commit is contained in:
Emil Ernerfeldt
2020-05-13 22:24:32 +02:00
parent d4204f03c0
commit cd1bbddaca
3 changed files with 99 additions and 31 deletions

View File

@@ -446,6 +446,7 @@ use crate::layout::*;
struct LayoutExample {
dir: Direction,
align: Option<Align>, // None == jusitifed
reversed: bool,
}
impl Default for LayoutExample {
@@ -453,6 +454,7 @@ impl Default for LayoutExample {
Self {
dir: Direction::Vertical,
align: Some(Align::Center),
reversed: false,
}
}
}
@@ -465,7 +467,12 @@ impl LayoutExample {
}
pub fn contents_ui(&mut self, ui: &mut Ui) {
ui.set_layout(Layout::from_dir_align(self.dir, self.align));
let layout = Layout::from_dir_align(self.dir, self.align);
if self.reversed {
ui.set_layout(layout.reverse());
} else {
ui.set_layout(layout);
}
ui.add(label!("Available space: {:?}", ui.available().size()));
if ui.add(Button::new("Reset")).clicked {
@@ -485,6 +492,8 @@ impl LayoutExample {
}
}
ui.add(Checkbox::new(&mut self.reversed, "Reversed"));
ui.add(Separator::new());
ui.add(label!("Align:"));