rename Layout to StripLayout
This commit is contained in:
parent
275fa8c276
commit
2ec346e7f5
4 changed files with 16 additions and 16 deletions
|
@ -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 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.
|
/// In a horizontal strip, a `[StripLayout]` with horizontal `[CellDirection]` is used.
|
||||||
/// Its cells go from left to right inside this `[Layout]`.
|
/// 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.
|
/// Its cells go from left to right. And the lines go from top to bottom.
|
||||||
pub(crate) enum CellDirection {
|
pub(crate) enum CellDirection {
|
||||||
/// Cells go from left to right
|
/// Cells go from left to right
|
||||||
|
@ -24,8 +24,8 @@ pub(crate) enum CellDirection {
|
||||||
Vertical,
|
Vertical,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Positions cells in `[CellDirection]` and starts a new line on `[Layout::end_line]`
|
/// Positions cells in `[CellDirection]` and starts a new line on `[StripLayout::end_line]`
|
||||||
pub struct Layout<'l> {
|
pub struct StripLayout<'l> {
|
||||||
ui: &'l mut Ui,
|
ui: &'l mut Ui,
|
||||||
direction: CellDirection,
|
direction: CellDirection,
|
||||||
rect: Rect,
|
rect: Rect,
|
||||||
|
@ -33,7 +33,7 @@ pub struct Layout<'l> {
|
||||||
max: Pos2,
|
max: Pos2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'l> Layout<'l> {
|
impl<'l> StripLayout<'l> {
|
||||||
pub(crate) fn new(ui: &'l mut Ui, direction: CellDirection) -> Self {
|
pub(crate) fn new(ui: &'l mut Ui, direction: CellDirection) -> Self {
|
||||||
let rect = ui.available_rect_before_wrap();
|
let rect = ui.available_rect_before_wrap();
|
||||||
let pos = rect.left_top();
|
let pos = rect.left_top();
|
||||||
|
|
|
@ -16,7 +16,7 @@ mod table;
|
||||||
pub use crate::datepicker::DatePickerButton;
|
pub use crate::datepicker::DatePickerButton;
|
||||||
|
|
||||||
pub use crate::image::RetainedImage;
|
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::sizing::Size;
|
||||||
pub use crate::strip::*;
|
pub use crate::strip::*;
|
||||||
pub use crate::table::*;
|
pub use crate::table::*;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
layout::{CellDirection, CellSize, Layout},
|
layout::{CellDirection, CellSize, StripLayout},
|
||||||
sizing::Sizing,
|
sizing::Sizing,
|
||||||
Size,
|
Size,
|
||||||
};
|
};
|
||||||
|
@ -74,7 +74,7 @@ impl<'a> StripBuilder<'a> {
|
||||||
self.ui.available_rect_before_wrap().width() - self.ui.spacing().item_spacing.x,
|
self.ui.available_rect_before_wrap().width() - self.ui.spacing().item_spacing.x,
|
||||||
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 {
|
strip(Strip {
|
||||||
layout: &mut layout,
|
layout: &mut layout,
|
||||||
direction: CellDirection::Horizontal,
|
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.available_rect_before_wrap().height() - self.ui.spacing().item_spacing.y,
|
||||||
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 {
|
strip(Strip {
|
||||||
layout: &mut layout,
|
layout: &mut layout,
|
||||||
direction: CellDirection::Vertical,
|
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.
|
/// 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!
|
/// In contrast to normal egui behavior, strip cells do *not* grow with its children!
|
||||||
pub struct Strip<'a, 'b> {
|
pub struct Strip<'a, 'b> {
|
||||||
layout: &'b mut Layout<'a>,
|
layout: &'b mut StripLayout<'a>,
|
||||||
direction: CellDirection,
|
direction: CellDirection,
|
||||||
sizes: Vec<f32>,
|
sizes: Vec<f32>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
layout::{CellDirection, CellSize},
|
layout::{CellDirection, CellSize},
|
||||||
sizing::Sizing,
|
sizing::Sizing,
|
||||||
Layout, Size,
|
Size, StripLayout,
|
||||||
};
|
};
|
||||||
|
|
||||||
use egui::{Response, Ui};
|
use egui::{Response, Ui};
|
||||||
|
@ -108,7 +108,7 @@ impl<'a> TableBuilder<'a> {
|
||||||
);
|
);
|
||||||
let ui = self.ui;
|
let ui = self.ui;
|
||||||
{
|
{
|
||||||
let mut layout = Layout::new(ui, CellDirection::Horizontal);
|
let mut layout = StripLayout::new(ui, CellDirection::Horizontal);
|
||||||
{
|
{
|
||||||
let row = TableRow {
|
let row = TableRow {
|
||||||
layout: &mut layout,
|
layout: &mut layout,
|
||||||
|
@ -172,7 +172,7 @@ impl<'a> Table<'a> {
|
||||||
let end_y = ui.available_rect_before_wrap().bottom();
|
let end_y = ui.available_rect_before_wrap().bottom();
|
||||||
|
|
||||||
egui::ScrollArea::new([false, self.scroll]).show(ui, move |ui| {
|
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 {
|
body(TableBody {
|
||||||
layout,
|
layout,
|
||||||
|
@ -189,7 +189,7 @@ impl<'a> Table<'a> {
|
||||||
/// The body of a table.
|
/// The body of a table.
|
||||||
/// Is created by calling `body` on a [`Table`] (after adding a header row) or [`TableBuilder`] (without a header row).
|
/// Is created by calling `body` on a [`Table`] (after adding a header row) or [`TableBuilder`] (without a header row).
|
||||||
pub struct TableBody<'a> {
|
pub struct TableBody<'a> {
|
||||||
layout: Layout<'a>,
|
layout: StripLayout<'a>,
|
||||||
widths: Vec<f32>,
|
widths: Vec<f32>,
|
||||||
striped: bool,
|
striped: bool,
|
||||||
row_nr: usize,
|
row_nr: usize,
|
||||||
|
@ -273,7 +273,7 @@ impl<'a> Drop for TableBody<'a> {
|
||||||
/// The row of a table.
|
/// 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`].
|
/// 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> {
|
pub struct TableRow<'a, 'b> {
|
||||||
layout: &'b mut Layout<'a>,
|
layout: &'b mut StripLayout<'a>,
|
||||||
widths: Vec<f32>,
|
widths: Vec<f32>,
|
||||||
striped: bool,
|
striped: bool,
|
||||||
height: f32,
|
height: f32,
|
||||||
|
|
Loading…
Reference in a new issue