better documentation/naming of LineDirection
This commit is contained in:
parent
6db4b929eb
commit
bbc3fabcab
3 changed files with 13 additions and 11 deletions
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue