Greg Ercolano wrote:
> Here's what I've written for the get/set methods to control
> scroller size locally. Hopefully it's clear; let me know if
> it isn't.
>
> --- snip
>
> /**
> Gets the current size of the scrollbars' troughs, in pixels.
>
> By default this returns the value of the global Fl::scrollbar_size()
> unless this widget's scrollbar_size(int) has been changed.
IMHO we shouldn't do this. The get method should return what the
set method sets. Otherwise you can't know if the value is
the global value or a modified local value. E.g. the get method
would never return -1 (or 0, see below). And the get method
can't be inlined.
> \returns Scrollbar size in pixels.
> \see Fl::scrollbar_size(int)
> */
> int Fl_Browser_::scrollbar_size() const {
> return((scollbar_size_ == -1) ? Fl::scrollbar_size() : scrollbar_size_);
> }
Also, I feel that the "special value" that uses the global scrollbar size
would better be 0 instead of -1. This way we could internally write
w = scrollbar_size_ ? scrollbar_size_ : Fl::scrollbar_size.
It's not only because it's shorter, but also because 0 is "no value",
and it is an invalid value for scrollbar_size as well.
But maybe this is a matter of taste, and I could live with -1 as well.
> /**
> Sets the pixel size of the scrollbars' troughs to the \p size, in pixels.
>
> Normally you should not need this method, and should use
> Fl::scrollbar_size(int) instead, which manages the scrollbar size
> of ALL your widgets, so that your application has a consistent
> scrollbar size throughout. This is normally what you want.
>
> Only use THIS method if you really need to override the global
> scrollbar size. The need for this should be rare.
>
> Setting \p size to the special value of -1 causes the widget to
> track the global Fl::scrollbar_size(), which is the default.
-> Setting \p size to 0 causes the widget to
-> track the global Fl::scrollbar_size(), which is the default.
>
> \param[in] size Sets the scrollbar size in pixels.\n
> If -1 (default), scrollbar size tracks the global
> Fl::scrollbar_size()
dto.
> \see Fl::scrollbar_size()
> */
> void Fl_Browser_::scrollbar_size(int size) {
> scrollbar_size_ = size;
> }
>
> --- snip
To Mike's concerns: As long as we don't force the user to use different
scrollbar sizes, and the default is to use the global value everywhere,
I think that we _can_ leave the choice to the user (developer) and
implement a per-widget scrollbar size. And we document that it
should not be used for normal UI design.
Albrecht
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev