After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 738534 - Add ::edge-hit signal
Add ::edge-hit signal
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkScrolledWindow
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
: 696658 723856 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-10-14 14:39 UTC by Carlos Garnacho
Modified: 2014-10-20 17:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
scrolledwindow: Add ::edge-hit signal (3.49 KB, patch)
2014-10-14 14:40 UTC, Carlos Garnacho
committed Details | Review
quick example (3.28 KB, text/plain)
2014-10-15 02:17 UTC, Matthias Clasen
  Details

Description Carlos Garnacho 2014-10-14 14:39:30 UTC
In other (most touch oriented) toolkits/UIs it is a common pattern to trigger certain actions when a scrollable area hits some boundary, most usually with some edge resistance. Common actions are loading further data when hitting bottom, or reloading/updating if swiping downwards.

I'm attaching a patch that adds such signal to GtkScrolledWindow, the signal will trigger only once each time the overshoot limit is hit, so dragging further won't emit again, but releasing and dragging again will. The signal has a GtkPositionType argument so different actions can be implemented.

One caveat so far is that this only triggers if the scrolledwindow is is actually scrollable in the expected axis, being attached to overshooting as it is. This might need decoupling, but I can only think on a gtk_scrolled_window_set_edge_hit_sides(sw, side_flags) or a gtk_scrolled_window_set_edge_hit_enabled (sw, position_type, enabled) to allow edge-hit on non scrollable views, neither are specially appealing...
Comment 1 Carlos Garnacho 2014-10-14 14:40:46 UTC
Created attachment 288526 [details] [review]
scrolledwindow: Add ::edge-hit signal

This signal is emitted whenever user scrolling hits the overshoot
edge in the given direction. May be useful to add "reload" or "load
more" behaviors in apps.
Comment 2 Matthias Clasen 2014-10-15 01:02:01 UTC
an example to play with this would be fantastic
Comment 3 Matthias Clasen 2014-10-15 02:17:47 UTC
Created attachment 288558 [details]
quick example

Here is a quick example. Seems to work fine. One obvious problem with using this to replace a visible load-more button is that it only works for touch scrolling - if you are using a mouse, you'll never get beyond the first chunk...
Comment 4 Carlos Garnacho 2014-10-15 10:17:53 UTC
(In reply to comment #3)
> Here is a quick example. Seems to work fine. One obvious problem with using
> this to replace a visible load-more button is that it only works for touch
> scrolling - if you are using a mouse, you'll never get beyond the first
> chunk...

Thanks for making the example :), I forgot to mention that this sort of depends on bug #738533 for mice... with that one you can reach the overshoot limit (and have this triggered) for both pointers and touch.
Comment 5 Matthias Clasen 2014-10-19 20:53:13 UTC
Review of attachment 288526 [details] [review]:

::: gtk/gtkscrolledwindow.c
@@ +555,3 @@
+   * The ::edge-hit signal is emitted whenever user initiated scrolling
+   * makes the scrolledwindow firmly surpass (ie. with some edge resistance)
+   * the lower or upper limits defined by the adjustment in that orientation.

Might be good to mention here that checking for value == lower or value = upper - page is an alternative for when you want to trigger an action as soon as the edge is hit. Also, maybe edge-surpassed or edge-overshot might be a better name for this signal, in light of this fact.
Comment 6 Matthias Clasen 2014-10-20 03:35:37 UTC
*** Bug 723856 has been marked as a duplicate of this bug. ***
Comment 7 Matthias Clasen 2014-10-20 03:36:01 UTC
*** Bug 696658 has been marked as a duplicate of this bug. ***
Comment 8 Carlos Garnacho 2014-10-20 17:01:11 UTC
I've finally renamed the signal to ::edge-overshot and pushed. The commit also includes the (adapted) test in comment 3 on tests/