PS I'm working on MacOS with a clang compiler, fltk 1.4
Calling redraw() on a widget means to set all damage() bits in the
widget's status. If you do this inside draw() of the widget these
damage() bits will be cleared after draw() which means that you can't
effectively call redraw() inside draw(). You *may* call it on other
widgets but you should not assume any drawing order to avoid undefined
behavior.
> I attach my modified version of ScrollB which provides the behavior I
> think you want. I moved the invocation of move_to() outside the
> Scroll_B::draw()
> method, into a callback function for ScrollB's vertical scrollbar.
Excellent! Without checking the code in detail or testing it myself (I
only read your code quickly), this is generally how it should be done.
Thanks for investigating and helping!
> I attach my modified version of ScrollB which provides the behavior I
> think you want. I moved the invocation of move_to() outside the
> Scroll_B::draw()
> method, into a callback function for ScrollB's vertical scrollbar.Excellent! Without checking the code in detail or testing it myself (I
only read your code quickly), this is generally how it should be done.
Thanks for investigating and helping!
Great! works fine, many thanks. I was looking for a way to intercept the scrolling of the Fl_Scroll and only thought of the draw() function. It is of course much better to provide my own version of the callback() of the scrollbar.
On a further note, I was also trying to get my own scrollbars into an Fl_Scroll widget, but that looks like it cannot be done?
Many thanks for all the help.
What did you want to achieve by replacing the scrollbars with your own scrollbars? Was it only for a better look, or should your scrollbars have different features? I'm curious...
What did you want to achieve by replacing the scrollbars with your own scrollbars? Was it only for a better look, or should your scrollbars have different features? I'm curious...
Both. Many times I'd like to get rid of the arrow buttons at the ends as they're not always useful and have the slider button be just an oval box with no "grips". Also, the slider button gets really small when there is a long scroll (it's difficult to grab it with the mouse).
For a previous program I made a scrollbar that automatically disappears when you don't use it, and I will want to go there with the application I'm working on now. To get it done I had to implement my own Fl_Scroll ...
I can (for now) live with the fixed scrollbars, but I would certainly welcome an alternative version where I can put in my own.
On 8/15/22 11:16, geert karman wrote:
Also, the slider button gets really small when there is a long scroll (it's difficult to grab it with the mouse).
Hmm, this one interests me.
The slider tab should not get any smaller than the width of
the scrollbar itself.
(In other words the tab should not get smaller than a
"square").
We could probably provide a minimum size for the scrollbar
tab,
e.g. as some fractional part of the scrollbar's size, e.g. 1.0
would
be the current behavior.
On 8/15/22 11:16, geert karman wrote:
Also, the slider button gets really small when there is a long scroll (it's difficult to grab it with the mouse).
[..]
But if the scrollbar's tab is getting too small in your app as a square,
perhaps the scrollbar_size() needs to be larger, so that the tab is easier to grab.
This can be set universally throughout the app by setting Fl::scrollbar_size()
just before calling Fl::run() IIRC.
You might want to experiement with changing the global
scrollbar size
using the "unittests" program in the fltk test directory, and
play with the
"Scrollbar size" test, sliding the "Global Scroll Size"
around.
On 8/15/22 11:16, geert karman wrote:
Also, the slider button gets really small when there is a long scroll (it's difficult to grab it with the mouse).
Hmm, this one interests me.
The slider tab should not get any smaller than the width of the scrollbar itself.
(In other words the tab should not get smaller than a "square").
But if the scrollbar's tab is getting too small in your app as a square,
perhaps the scrollbar_size() needs to be larger, so that the tab is easier to grab.
This can be set universally throughout the app by setting Fl::scrollbar_size()
just before calling Fl::run() IIRC.
It seems it does ... [screenshot]
Ah, that looks like it's a "feature" of one of the non-default schemes
that FLTK provides, perhaps gtk+?
I can see where such a problem could be solved by a new method that
I mentioned, letting one control the minimum size of the tab.
I suppose such a method could maybe default to 0.0 ('default' behavior),
and allow non-zero numbers be a fractional size based on the width, so
that if the scrollbar_size were 10, and the minimum size were 1.0, the tab
would never get smaller than 10 pixels, regardless of the scheme().