Skip to content

gtk4-ify scrolling continued (left/right panels, navigation, and geotagging) and add pinch-to-zoom on navigation widget#20801

Merged
TurboGit merged 3 commits intodarktable-org:masterfrom
dtorop:scrolling-gtkify-contd
Apr 22, 2026
Merged

gtk4-ify scrolling continued (left/right panels, navigation, and geotagging) and add pinch-to-zoom on navigation widget#20801
TurboGit merged 3 commits intodarktable-org:masterfrom
dtorop:scrolling-gtkify-contd

Conversation

@dtorop
Copy link
Copy Markdown
Contributor

@dtorop dtorop commented Apr 12, 2026

  • Clean up and improve the scrolling event controller setup functions. Eliminate dt_gui_connect_scroll_discrete() and merge it into dt_gui_connect_scroll().
  • Make the proxy scroll event controller handle whether (depending on modifier key) it should scroll a widget or the left/right panel. Note why still use GTK3-style "scroll-event" in one case, but note how to handle this in GTK4.
  • Use an event controller to allow scrolling of left/right borders to cause the corresponding panels to scroll. Make the handler (GTK4-style) scroll the GtkAdjustment directly, rather than sending the event to the widget (GTK3-style).
  • Use an event controller to scroll geotagging date/time.
  • Use an event controller to handle scrolling in navigation utility module in order to zoom or pan. Again, don't send events to the center view widget, but make them trigger the necessary zoom directly.
  • Add a pinch-to-zoom gesture in the navigation utility module to parallel the same gesture which is now available in the center view.
  • Make sure that zooming the navigation widget zooms, as possible, on the cursor position. (I used dt_dev_get_zoom_bounds() and then same hand-rolled math to make this work. If there's a better helper function for this, it could make that code simpler.)
  • Tidy variable names in _ui_init_panel_container_center() for clarity.

This looks to be part of a series of commits to make GTK4-ready scrolling handling.

dtorop added 3 commits April 12, 2026 15:03
- Merge discrete and non-discrete setup functions and use
  GTK_EVENT_CONTROLLER_SCROLL_DISCRETE flag to differentiate
- Scroll proxy function now handles propagating scroll events
  to left/right panels as this is a common pattern
- Move attenuation into a helper function
- Attenuate non-discrete smooth scroll events (important for MacOS)
- Assume that dt_gui_connect_scroll() is always called with a handler
  function, as it would be nonsensical to set up a scroll handler
  without a handler
- Add helper function to setup scroll controller
- Note that discrete scroll deltas can exceed 1
- Use new GtkEventControllerScroll code in geotagging utility module
Panel scroll events over modules (with appropriate modifier) or border
now change the GtkScrolledWindow's vertical GtkAdjustment, rather than
passing their event on via gtk_widget_event(). This keeps from
breaking kinetic scrolling and is more GTK4-ready. GTK4 seems to want
widgets to not pass events to other widgets, but instead, based on the
event, modify other widgets as needed.

Also:

- cleanup border scrolling: always scroll border, regardless of
  modifier keys
- acknowledge that still need to handle scroll-event in one case (when
  scrolling over panel) until convert to GTK4 as in GTK3, parent
  GtkScrolledWindow must use scroll-event to decide when to handle its
  own scrolling vs. allow its children to handle event
- move _scroll_attenuate() later
- tidy widget variable names in center panel init: for clarity, don't
  reuse variable names.
Handle scroll events via explicitly zooming/panning center view. This
appears to be more GTK4-sympathetic than passing the events to the
center view to handle. This also should produce better results. The
center view scroll/pan code called through dt_view_manager_scrolled()
also handled cases when the event interacts with a mask or color
picker. Scroll/pan on the navigation widget now goes directly to
dt_dev_zoom_move() which is the only case which we really need to
handle. Also, proxying scroll events through another widget makes
event controller behavior flaky as it is tied both to an event and a
widget.

Implement pinch-to-zoom behavior on the navigation thumbnail. This
matches corresponding behavior on the center view and allows for both
panning and zooming using a touchpad. Unlike pinch-to-zoom on the
center view, there is no "unconstrained" mode via control key
modifier, as it is hard to hold the control key and pinch and there is
no visual feedback in the navigation window once the center view
area exceeds the image area.

Make scroll-to-zoom (via mouse wheel) and pinch-to-zoom (via touchpad)
zoom in on the mouse cursor location by (laboriously) translating
navigation widget mouse coordinates to center view coordinates. Note
that this doesn't necessarily pan the view appropriately when zooming
in outside of the area of the image shown in the center view, but
works as expected in other cases.
@ralfbrown ralfbrown added the gtk4 label Apr 14, 2026
@TurboGit TurboGit added this to the 5.6 milestone Apr 15, 2026
@dtorop dtorop mentioned this pull request Apr 21, 2026
1 task
Copy link
Copy Markdown
Member

@TurboGit TurboGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TurboGit TurboGit merged commit 38ae3ce into darktable-org:master Apr 22, 2026
5 checks passed
@dtorop
Copy link
Copy Markdown
Contributor Author

dtorop commented Apr 22, 2026

Great! Very glad the cleanup of removing dt_gui_connect_scroll_discrete(). I'll continue to progressively move GTK3 "scroll-event" to use GtkEventControllerScroll via dt_gui_connect_scroll().

@dtorop dtorop deleted the scrolling-gtkify-contd branch April 22, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants