1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Make sure scroll bars are always visible (#2371)

* Nicer debug rectangles

* Move scrollbars into the clip-rect so they are always visible

* Improve table demo

* Add options for controlling inner and outer margin of the scroll bars

* Add line to changelog

* Update egui_extras changelog with recent Table improvements

* Refactor Table:s scroll options

* Add Table::auto_size

* Rename it auto_shrink
This commit is contained in:
Emil Ernerfeldt
2022-11-30 22:58:00 +01:00
committed by GitHub
parent 85f8eeb9d5
commit 7133818c59
8 changed files with 147 additions and 92 deletions

View File

@@ -7,6 +7,7 @@ enum ScrollDemo {
ManyLines,
LargeCanvas,
StickToEnd,
Bidirectional,
}
impl Default for ScrollDemo {
@@ -55,6 +56,7 @@ impl super::View for Scrolling {
"Scroll a large canvas",
);
ui.selectable_value(&mut self.demo, ScrollDemo::StickToEnd, "Stick to end");
ui.selectable_value(&mut self.demo, ScrollDemo::Bidirectional, "Bidirectional");
});
ui.separator();
match self.demo {
@@ -70,6 +72,14 @@ impl super::View for Scrolling {
ScrollDemo::StickToEnd => {
self.scroll_stick_to.ui(ui);
}
ScrollDemo::Bidirectional => {
egui::ScrollArea::both().show(ui, |ui| {
ui.style_mut().wrap = Some(false);
for _ in 0..100 {
ui.label(crate::LOREM_IPSUM);
}
});
}
}
}
}

View File

@@ -47,7 +47,7 @@ impl super::Demo for TableDemo {
}
}
const NUM_MANUAL_ROWS: usize = 32;
const NUM_MANUAL_ROWS: usize = 20;
impl super::View for TableDemo {
fn ui(&mut self, ui: &mut egui::Ui) {
@@ -101,11 +101,13 @@ impl super::View for TableDemo {
// Leave room for the source code link after the table demo:
use egui_extras::{Size, StripBuilder};
StripBuilder::new(ui)
.size(Size::remainder()) // for the table
.size(Size::remainder().at_least(100.0)) // for the table
.size(Size::exact(10.0)) // for the source code link
.vertical(|mut strip| {
strip.cell(|ui| {
self.table_ui(ui);
egui::ScrollArea::horizontal().show(ui, |ui| {
self.table_ui(ui);
});
});
strip.cell(|ui| {
ui.vertical_centered(|ui| {
@@ -133,7 +135,8 @@ impl TableDemo {
.resizable(true)
.clip(true),
)
.column(Column::remainder());
.column(Column::remainder())
.min_scrolled_height(0.0);
if let Some(row_nr) = self.scroll_to_row.take() {
table = table.scroll_to_row(row_nr, None);