From bbc3fabcab9a0937d4a788aaf49491d9ceb2d0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20R=C3=B6ssler?= Date: Wed, 9 Feb 2022 13:09:10 +0100 Subject: [PATCH] better documentation/naming of LineDirection --- egui_extras/src/grid.rs | 4 ++-- egui_extras/src/layout.rs | 16 +++++++++------- egui_extras/src/table.rs | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/egui_extras/src/grid.rs b/egui_extras/src/grid.rs index 5558c924..64382889 100644 --- a/egui_extras/src/grid.rs +++ b/egui_extras/src/grid.rs @@ -53,7 +53,7 @@ impl<'a> GridBuilder<'a> { self.ui.available_rect_before_wrap().width() - 2.0 * self.padding.outer, self.padding.inner, ); - let mut layout = Layout::new(self.ui, self.padding.clone(), LineDirection::TopToBottom); + let mut layout = Layout::new(self.ui, self.padding.clone(), LineDirection::Vertical); grid(Grid { layout: &mut layout, direction: GridDirection::Horizontal, @@ -72,7 +72,7 @@ impl<'a> GridBuilder<'a> { self.ui.available_rect_before_wrap().height() - 2.0 * self.padding.outer, self.padding.inner, ); - let mut layout = Layout::new(self.ui, self.padding.clone(), LineDirection::LeftToRight); + let mut layout = Layout::new(self.ui, self.padding.clone(), LineDirection::Horizontal); grid(Grid { layout: &mut layout, direction: GridDirection::Vertical, diff --git a/egui_extras/src/layout.rs b/egui_extras/src/layout.rs index 9636c8e4..787dd574 100644 --- a/egui_extras/src/layout.rs +++ b/egui_extras/src/layout.rs @@ -10,10 +10,12 @@ pub(crate) enum CellSize { } pub(crate) enum LineDirection { - /// Cells go from top to bottom - LeftToRight, + /// Cells go from top to bottom on each line + /// Lines go from left to right + Horizontal, /// Cells go from left to right - TopToBottom, + /// Lines go from top to bottom + Vertical, } /// Positions cells in `[LineDirection]` and starts a new line on `[Layout::end_line]` @@ -67,10 +69,10 @@ impl<'l> Layout<'l> { fn set_pos(&mut self, rect: Rect) { match self.direction { - LineDirection::LeftToRight => { + LineDirection::Horizontal => { self.pos.y = rect.bottom() + self.padding.inner; } - LineDirection::TopToBottom => { + LineDirection::Vertical => { self.pos.x = rect.right() + self.padding.inner; } } @@ -119,11 +121,11 @@ impl<'l> Layout<'l> { /// only needed for layouts with multiple lines, like Table pub fn end_line(&mut self) { match self.direction { - LineDirection::LeftToRight => { + LineDirection::Horizontal => { self.pos.x = self.max.x; self.pos.y = self.rect.top(); } - LineDirection::TopToBottom => { + LineDirection::Vertical => { self.pos.y = self.max.y; self.pos.x = self.rect.left(); } diff --git a/egui_extras/src/table.rs b/egui_extras/src/table.rs index 55dc9d65..172994b6 100644 --- a/egui_extras/src/table.rs +++ b/egui_extras/src/table.rs @@ -66,7 +66,7 @@ impl<'a> TableBuilder<'a> { ); let ui = self.ui; { - let mut layout = Layout::new(ui, self.padding.clone(), LineDirection::TopToBottom); + let mut layout = Layout::new(ui, self.padding.clone(), LineDirection::Vertical); { let row = TableRow { layout: &mut layout, @@ -131,7 +131,7 @@ impl<'a> Table<'a> { let end_y = ui.available_rect_before_wrap().bottom(); egui::ScrollArea::new([false, self.scroll]).show(ui, move |ui| { - let layout = Layout::new(ui, padding, LineDirection::TopToBottom); + let layout = Layout::new(ui, padding, LineDirection::Vertical); body(TableBody { layout,