From 44223de11a1d636ac3e744c28a45ea0b95780541 Mon Sep 17 00:00:00 2001 From: KYovchevski Date: Tue, 20 Jun 2023 15:26:28 +0200 Subject: [PATCH 1/2] Add TableBuilder::drag_to_scroll --- crates/egui_extras/src/table.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/egui_extras/src/table.rs b/crates/egui_extras/src/table.rs index 9966a8b9928..e7256743c61 100644 --- a/crates/egui_extras/src/table.rs +++ b/crates/egui_extras/src/table.rs @@ -157,6 +157,7 @@ fn to_sizing(columns: &[Column]) -> crate::sizing::Sizing { struct TableScrollOptions { vscroll: bool, + drag_to_scroll: bool, stick_to_bottom: bool, scroll_to_row: Option<(usize, Option)>, scroll_offset_y: Option, @@ -169,6 +170,7 @@ impl Default for TableScrollOptions { fn default() -> Self { Self { vscroll: true, + drag_to_scroll: true, stick_to_bottom: false, scroll_to_row: None, scroll_offset_y: None, @@ -271,6 +273,12 @@ impl<'a> TableBuilder<'a> { self.vscroll(vscroll) } + /// Enables scrolling the table's contents using mouse drag (default: `true`) + pub fn drag_to_scroll(mut self, drag_to_scroll: bool) -> Self { + self.scroll_options.drag_to_scroll = drag_to_scroll; + self + } + /// 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`. @@ -551,6 +559,7 @@ impl<'a> Table<'a> { let TableScrollOptions { vscroll, + drag_to_scroll, stick_to_bottom, scroll_to_row, scroll_offset_y, @@ -563,6 +572,7 @@ impl<'a> Table<'a> { let mut scroll_area = ScrollArea::new([false, vscroll]) .auto_shrink([true; 2]) + .drag_to_scroll(drag_to_scroll) .stick_to_bottom(stick_to_bottom) .min_scrolled_height(min_scrolled_height) .max_height(max_scroll_height) From 64a0646c591ad1c1e28a3c589efe5cd0e1581319 Mon Sep 17 00:00:00 2001 From: KYovchevski Date: Wed, 21 Jun 2023 10:12:44 +0200 Subject: [PATCH 2/2] Add reference to ScrollArea::drag_to_scroll --- crates/egui_extras/src/table.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/egui_extras/src/table.rs b/crates/egui_extras/src/table.rs index e7256743c61..0eed4c913e8 100644 --- a/crates/egui_extras/src/table.rs +++ b/crates/egui_extras/src/table.rs @@ -273,7 +273,9 @@ impl<'a> TableBuilder<'a> { self.vscroll(vscroll) } - /// Enables scrolling the table's contents using mouse drag (default: `true`) + /// Enables scrolling the table's contents using mouse drag (default: `true`). + /// + /// See [`ScrollArea::drag_to_scroll`] for more. pub fn drag_to_scroll(mut self, drag_to_scroll: bool) -> Self { self.scroll_options.drag_to_scroll = drag_to_scroll; self