diff --git a/egui/src/containers/scroll_area.rs b/egui/src/containers/scroll_area.rs index 01ef3568..56c1ab64 100644 --- a/egui/src/containers/scroll_area.rs +++ b/egui/src/containers/scroll_area.rs @@ -272,8 +272,8 @@ impl ScrollArea { /// it will remain focused on whatever content viewport the user left it on. If the scroll /// handle is dragged all the way to the right it will again become stuck and remain there /// until manually pulled from the end position. - pub fn stick_to_right(mut self) -> Self { - self.stick_to_end[0] = true; + pub fn stick_to_right(mut self, stick: bool) -> Self { + self.stick_to_end[0] = stick; self } @@ -283,8 +283,8 @@ impl ScrollArea { /// it will remain focused on whatever content viewport the user left it on. If the scroll /// handle is dragged to the bottom it will again become stuck and remain there until manually /// pulled from the end position. - pub fn stick_to_bottom(mut self) -> Self { - self.stick_to_end[1] = true; + pub fn stick_to_bottom(mut self, stick: bool) -> Self { + self.stick_to_end[1] = stick; self } } diff --git a/egui_demo_app/src/backend_panel.rs b/egui_demo_app/src/backend_panel.rs index 6ff02b6a..af88375b 100644 --- a/egui_demo_app/src/backend_panel.rs +++ b/egui_demo_app/src/backend_panel.rs @@ -371,7 +371,7 @@ impl EguiWindows { ui.separator(); egui::ScrollArea::vertical() - .stick_to_bottom() + .stick_to_bottom(true) .show(ui, |ui| { for event in output_event_history { ui.label(format!("{:?}", event)); diff --git a/egui_demo_lib/src/demo/scrolling.rs b/egui_demo_lib/src/demo/scrolling.rs index 62aba735..b375223b 100644 --- a/egui_demo_lib/src/demo/scrolling.rs +++ b/egui_demo_lib/src/demo/scrolling.rs @@ -271,7 +271,7 @@ impl super::View for ScrollStickTo { let text_style = TextStyle::Body; let row_height = ui.text_style_height(&text_style); - ScrollArea::vertical().stick_to_bottom().show_rows( + ScrollArea::vertical().stick_to_bottom(true).show_rows( ui, row_height, self.n_items, diff --git a/egui_extras/src/table.rs b/egui_extras/src/table.rs index 92431ae0..a2a6ce5b 100644 --- a/egui_extras/src/table.rs +++ b/egui_extras/src/table.rs @@ -110,8 +110,8 @@ impl<'a> TableBuilder<'a> { /// Should the scroll handle stick to the bottom position even as the content size changes /// dynamically? The scroll handle remains stuck until manually changed, and will become stuck /// once again when repositioned to the bottom. Default: `false`. - pub fn stick_to_bottom(mut self) -> Self { - self.stick_to_bottom = true; + pub fn stick_to_bottom(mut self, stick: bool) -> Self { + self.stick_to_bottom = stick; self } @@ -295,11 +295,9 @@ impl<'a> Table<'a> { let mut new_widths = widths.clone(); - let mut scroll_area = egui::ScrollArea::new([false, scroll]).auto_shrink([true; 2]); - - if stick_to_bottom { - scroll_area = scroll_area.stick_to_bottom(); - } + let scroll_area = egui::ScrollArea::new([false, scroll]) + .auto_shrink([true; 2]) + .stick_to_bottom(stick_to_bottom); scroll_area.show(ui, move |ui| { let layout = StripLayout::new(ui, CellDirection::Horizontal, clip, cell_layout);