Add `TableBuilder::drag_to_scroll` (#3100)
* Add TableBuilder::drag_to_scroll * Add reference to ScrollArea::drag_to_scroll
This commit is contained in:
parent
dbe55ba46a
commit
043183a3a4
|
|
@ -159,6 +159,7 @@ fn to_sizing(columns: &[Column]) -> crate::sizing::Sizing {
|
||||||
|
|
||||||
struct TableScrollOptions {
|
struct TableScrollOptions {
|
||||||
vscroll: bool,
|
vscroll: bool,
|
||||||
|
drag_to_scroll: bool,
|
||||||
stick_to_bottom: bool,
|
stick_to_bottom: bool,
|
||||||
scroll_to_row: Option<(usize, Option<Align>)>,
|
scroll_to_row: Option<(usize, Option<Align>)>,
|
||||||
scroll_offset_y: Option<f32>,
|
scroll_offset_y: Option<f32>,
|
||||||
|
|
@ -171,6 +172,7 @@ impl Default for TableScrollOptions {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
vscroll: true,
|
vscroll: true,
|
||||||
|
drag_to_scroll: true,
|
||||||
stick_to_bottom: false,
|
stick_to_bottom: false,
|
||||||
scroll_to_row: None,
|
scroll_to_row: None,
|
||||||
scroll_offset_y: None,
|
scroll_offset_y: None,
|
||||||
|
|
@ -273,6 +275,14 @@ impl<'a> TableBuilder<'a> {
|
||||||
self.vscroll(vscroll)
|
self.vscroll(vscroll)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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
|
||||||
|
}
|
||||||
|
|
||||||
/// Should the scroll handle stick to the bottom position even as the content size changes
|
/// 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
|
/// dynamically? The scroll handle remains stuck until manually changed, and will become stuck
|
||||||
/// once again when repositioned to the bottom. Default: `false`.
|
/// once again when repositioned to the bottom. Default: `false`.
|
||||||
|
|
@ -555,6 +565,7 @@ impl<'a> Table<'a> {
|
||||||
|
|
||||||
let TableScrollOptions {
|
let TableScrollOptions {
|
||||||
vscroll,
|
vscroll,
|
||||||
|
drag_to_scroll,
|
||||||
stick_to_bottom,
|
stick_to_bottom,
|
||||||
scroll_to_row,
|
scroll_to_row,
|
||||||
scroll_offset_y,
|
scroll_offset_y,
|
||||||
|
|
@ -567,6 +578,7 @@ impl<'a> Table<'a> {
|
||||||
|
|
||||||
let mut scroll_area = ScrollArea::new([false, vscroll])
|
let mut scroll_area = ScrollArea::new([false, vscroll])
|
||||||
.auto_shrink([true; 2])
|
.auto_shrink([true; 2])
|
||||||
|
.drag_to_scroll(drag_to_scroll)
|
||||||
.stick_to_bottom(stick_to_bottom)
|
.stick_to_bottom(stick_to_bottom)
|
||||||
.min_scrolled_height(min_scrolled_height)
|
.min_scrolled_height(min_scrolled_height)
|
||||||
.max_height(max_scroll_height)
|
.max_height(max_scroll_height)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue