Browse Source

rename Layout to StripLayout

dynamic-grid
René Rössler 3 years ago
parent
commit
2ec346e7f5
  1. 12
      egui_extras/src/layout.rs
  2. 2
      egui_extras/src/lib.rs
  3. 8
      egui_extras/src/strip.rs
  4. 10
      egui_extras/src/table.rs

12
egui_extras/src/layout.rs

@ -12,10 +12,10 @@ pub(crate) enum CellSize {
///
/// In a strip there's only one line which goes in the direction of the strip:
///
/// In a horizontal strip, a `[Layout]` with horizontal `[CellDirection]` is used.
/// Its cells go from left to right inside this `[Layout]`.
/// In a horizontal strip, a `[StripLayout]` with horizontal `[CellDirection]` is used.
/// Its cells go from left to right inside this `[StripLayout]`.
///
/// In a table there's a `[Layout]` for each table row with a horizonal `[CellDirection]`.
/// In a table there's a `[StripLayout]` for each table row with a horizonal `[CellDirection]`.
/// Its cells go from left to right. And the lines go from top to bottom.
pub(crate) enum CellDirection {
/// Cells go from left to right
@ -24,8 +24,8 @@ pub(crate) enum CellDirection {
Vertical,
}
/// Positions cells in `[CellDirection]` and starts a new line on `[Layout::end_line]`
pub struct Layout<'l> {
/// Positions cells in `[CellDirection]` and starts a new line on `[StripLayout::end_line]`
pub struct StripLayout<'l> {
ui: &'l mut Ui,
direction: CellDirection,
rect: Rect,
@ -33,7 +33,7 @@ pub struct Layout<'l> {
max: Pos2,
}
impl<'l> Layout<'l> {
impl<'l> StripLayout<'l> {
pub(crate) fn new(ui: &'l mut Ui, direction: CellDirection) -> Self {
let rect = ui.available_rect_before_wrap();
let pos = rect.left_top();

2
egui_extras/src/lib.rs

@ -16,7 +16,7 @@ mod table;
pub use crate::datepicker::DatePickerButton;
pub use crate::image::RetainedImage;
pub(crate) use crate::layout::Layout;
pub(crate) use crate::layout::StripLayout;
pub use crate::sizing::Size;
pub use crate::strip::*;
pub use crate::table::*;

8
egui_extras/src/strip.rs

@ -1,5 +1,5 @@
use crate::{
layout::{CellDirection, CellSize, Layout},
layout::{CellDirection, CellSize, StripLayout},
sizing::Sizing,
Size,
};
@ -74,7 +74,7 @@ impl<'a> StripBuilder<'a> {
self.ui.available_rect_before_wrap().width() - self.ui.spacing().item_spacing.x,
self.ui.spacing().item_spacing.x,
);
let mut layout = Layout::new(self.ui, CellDirection::Horizontal);
let mut layout = StripLayout::new(self.ui, CellDirection::Horizontal);
strip(Strip {
layout: &mut layout,
direction: CellDirection::Horizontal,
@ -95,7 +95,7 @@ impl<'a> StripBuilder<'a> {
self.ui.available_rect_before_wrap().height() - self.ui.spacing().item_spacing.y,
self.ui.spacing().item_spacing.y,
);
let mut layout = Layout::new(self.ui, CellDirection::Vertical);
let mut layout = StripLayout::new(self.ui, CellDirection::Vertical);
strip(Strip {
layout: &mut layout,
direction: CellDirection::Vertical,
@ -108,7 +108,7 @@ impl<'a> StripBuilder<'a> {
/// A Strip of cells which go in one direction. Each cell has a fixed size.
/// In contrast to normal egui behavior, strip cells do *not* grow with its children!
pub struct Strip<'a, 'b> {
layout: &'b mut Layout<'a>,
layout: &'b mut StripLayout<'a>,
direction: CellDirection,
sizes: Vec<f32>,
}

10
egui_extras/src/table.rs

@ -6,7 +6,7 @@
use crate::{
layout::{CellDirection, CellSize},
sizing::Sizing,
Layout, Size,
Size, StripLayout,
};
use egui::{Response, Ui};
@ -108,7 +108,7 @@ impl<'a> TableBuilder<'a> {
);
let ui = self.ui;
{
let mut layout = Layout::new(ui, CellDirection::Horizontal);
let mut layout = StripLayout::new(ui, CellDirection::Horizontal);
{
let row = TableRow {
layout: &mut layout,
@ -172,7 +172,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, CellDirection::Horizontal);
let layout = StripLayout::new(ui, CellDirection::Horizontal);
body(TableBody {
layout,
@ -189,7 +189,7 @@ impl<'a> Table<'a> {
/// The body of a table.
/// Is created by calling `body` on a [`Table`] (after adding a header row) or [`TableBuilder`] (without a header row).
pub struct TableBody<'a> {
layout: Layout<'a>,
layout: StripLayout<'a>,
widths: Vec<f32>,
striped: bool,
row_nr: usize,
@ -273,7 +273,7 @@ impl<'a> Drop for TableBody<'a> {
/// The row of a table.
/// Is created by [`TableRow`] for each created [`TableBody::row`] or each visible row in rows created by calling [`TableBody::rows`].
pub struct TableRow<'a, 'b> {
layout: &'b mut Layout<'a>,
layout: &'b mut StripLayout<'a>,
widths: Vec<f32>,
striped: bool,
height: f32,

Loading…
Cancel
Save