Fl_Scroll: Add possibility to get notified when scroll position changes?

7 views
Skip to first unread message

Jakub Holý

unread,
Sep 9, 2022, 3:28:23 AM9/9/22
to fltk.coredev
Hello, awesome FLTK devs!

I find myself needing to get notified and run custom code when scrolling is happening / stops. Currently there seems no way to achieve that. Perhaps it would be generally useful if Fl_Scroll had callback(s) triggered when its x/yposition changes.

Background: I am making a file explorer for pictures, displaying thumbnails. For performance reasons I only show thumbnails of pictures in the visible viewport. When the user scrolls to a new position (or is scrolling slowly), I want to load and show also these newly visible pictures' thumbnails. Thus I want to trigger the image loading function when scrolling ends.

Obviously FLTK lived fine without this for many years and I was able to implement this by querying the scroll's yposition every 100ms, so it might not be worth the effort. But it would be nice.

Best regards, Jakub Holy

imacarthur

unread,
Sep 9, 2022, 3:35:53 AM9/9/22
to fltk.coredev
On Friday, 9 September 2022 at 08:28:23 UTC+1 jakub wrote:

I find myself needing to get notified and run custom code when scrolling is happening / stops. Currently there seems no way to achieve that. Perhaps it would be generally useful if Fl_Scroll had callback(s) triggered when its x/yposition changes.


This post is off-topic for this list (this list is about developing the library itself, not about developing using the library) and so this would be more appropriate in the  fltk.general list - though I note you have cross-posted there, so I'll pick this up over there...

Jakub Holý

unread,
Sep 9, 2022, 6:34:55 AM9/9/22
to fltk.coredev
I meant it not as a question but as a proposal to extend the existing api of Fl_Scroll, which only core devs can do.

I got now an advice to subclass it and leverage its scrollbar's callback, which sounds as a nice small solution. So perhaps there is no need to change anything.

Bill Spitzak

unread,
Sep 9, 2022, 11:40:02 AM9/9/22
to fltkc...@googlegroups.com
You could probably check this when draw() is called.

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/c4adbf2c-7695-4ad3-be1b-004768cf7395n%40googlegroups.com.

Bill Spitzak

unread,
Sep 9, 2022, 11:41:54 AM9/9/22
to fltkc...@googlegroups.com
Yea actually draw is right as it will also get resizes.
Just check at draw all the images that are now visible and load them if necessary.
Reply all
Reply to author
Forward
0 new messages