Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dispel-gui/src/view/editor/table_widget/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ pub(crate) struct State {
/// cached `viewport_height` stays fresh — programmatic scroll-to math
/// (arrow nav, highlight jumps) depends on it.
pub(crate) last_body_height: Option<f32>,
/// Shift modifier state — held while scrolling redirects vertical wheel
/// delta to horizontal scroll.
pub(crate) shift_pressed: bool,
}

/// Sub-region of a header cell. Used for hit-testing clicks and for hover
Expand Down
21 changes: 16 additions & 5 deletions dispel-gui/src/view/editor/table_widget/widget_trait_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,22 @@ impl<Message, Theme> Widget<Message, Theme, iced::Renderer> for TableWidget<'_,
}
let (dx, dy) = match delta {
mouse::ScrollDelta::Lines { x, y } => {
(-x * self.row_height, -y * self.row_height)
(-x * self.row_height * 3.0, -y * self.row_height * 3.0)
}
mouse::ScrollDelta::Pixels { x, y } => (-x, -y),
};
let new_x = state.scroll_offset.x + dx;
let new_y = state.scroll_offset.y + dy;
if self.apply_scroll(state, bounds, new_x, new_y, shell) {
shell.capture_event();
if state.shift_pressed {
let horiz = if dx != 0.0 { dx } else { dy };
let new_x = state.scroll_offset.x + horiz;
if self.apply_scroll(state, bounds, new_x, state.scroll_offset.y, shell) {
shell.capture_event();
}
} else {
let new_x = state.scroll_offset.x + dx;
let new_y = state.scroll_offset.y + dy;
if self.apply_scroll(state, bounds, new_x, new_y, shell) {
shell.capture_event();
}
}
}
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
Expand Down Expand Up @@ -239,6 +247,9 @@ impl<Message, Theme> Widget<Message, Theme, iced::Renderer> for TableWidget<'_,
shell.capture_event();
shell.request_redraw();
}
Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => {
state.shift_pressed = modifiers.shift();
}
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Right)) => {
let Some(p) = cursor.position_over(bounds) else {
return;
Expand Down