mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Add emath::Vec2b, replacing egui_plot::AxisBools (#3543)
Thanks to `impl From<bool> for Vec2b` one can now shorten some builder
calls, like:
Previous:
```rust
egui::ScrollArea::vertical()
.auto_shrink([false; 2])
```
New:
```rust
egui::ScrollArea::vertical()
.auto_shrink(false)
```
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
//! | fixed size | all available space/minimum | 30% of available width | fixed size |
|
||||
//! Takes all available height, so if you want something below the table, put it in a strip.
|
||||
|
||||
use egui::{Align, NumExt as _, Rangef, Rect, Response, ScrollArea, Ui, Vec2};
|
||||
use egui::{Align, NumExt as _, Rangef, Rect, Response, ScrollArea, Ui, Vec2, Vec2b};
|
||||
|
||||
use crate::{
|
||||
layout::{CellDirection, CellSize},
|
||||
@@ -165,7 +165,7 @@ struct TableScrollOptions {
|
||||
scroll_offset_y: Option<f32>,
|
||||
min_scrolled_height: f32,
|
||||
max_scroll_height: f32,
|
||||
auto_shrink: [bool; 2],
|
||||
auto_shrink: Vec2b,
|
||||
}
|
||||
|
||||
impl Default for TableScrollOptions {
|
||||
@@ -178,7 +178,7 @@ impl Default for TableScrollOptions {
|
||||
scroll_offset_y: None,
|
||||
min_scrolled_height: 200.0,
|
||||
max_scroll_height: 800.0,
|
||||
auto_shrink: [true; 2],
|
||||
auto_shrink: Vec2b::TRUE,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,11 +335,11 @@ impl<'a> TableBuilder<'a> {
|
||||
/// * If true, add blank space outside the table, keeping the table small.
|
||||
/// * If false, add blank space inside the table, expanding the table to fit the containing ui.
|
||||
///
|
||||
/// Default: `[true; 2]`.
|
||||
/// Default: `true`.
|
||||
///
|
||||
/// See [`ScrollArea::auto_shrink`] for more.
|
||||
pub fn auto_shrink(mut self, auto_shrink: [bool; 2]) -> Self {
|
||||
self.scroll_options.auto_shrink = auto_shrink;
|
||||
pub fn auto_shrink(mut self, auto_shrink: impl Into<Vec2b>) -> Self {
|
||||
self.scroll_options.auto_shrink = auto_shrink.into();
|
||||
self
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ impl<'a> Table<'a> {
|
||||
let avail_rect = ui.available_rect_before_wrap();
|
||||
|
||||
let mut scroll_area = ScrollArea::new([false, vscroll])
|
||||
.auto_shrink([true; 2])
|
||||
.auto_shrink(true)
|
||||
.drag_to_scroll(drag_to_scroll)
|
||||
.stick_to_bottom(stick_to_bottom)
|
||||
.min_scrolled_height(min_scrolled_height)
|
||||
|
||||
Reference in New Issue
Block a user