So, from a mostly-fltk2 standpoint:
On 01/09/11 08:16, Roman Kantor wrote:
> I am not sure how styles changed in fltk 2 recently so forgive me if I am
> not completely accurate. There are a few things in f2 styling I did not like
> too much:
>
> 1) The styles tree follow closely the classes inheritance tree. However the
> widgets programatical inheritance do not match well appearance similarity
> (style
> parents inheritance) so you end up with lot of "default" styles and
> re-definition of values and appearance; inheritance becomes complicated,
> could be quite
> misleading and misses the point of having few places to control the
> properties.
There is actually a global NamedStyle that you can modify which modifies
*all* widgets; however poor 2.0 documentation kept this relatively
hidden from users. It did exist though! It was the "default" NamedStyle,
ftr.
You could then set values and appearances per-widget and then using
one-use styles, too, which seems similar to what Matthias has in mind.
> 2) because the value "0" means "inherit value from parent" and the chain of
> parents can be quite long, multiple recursive dereferencing(value digging)
> together
> with "if" condition can have some influence on performance.
This isn't really that true; the longest inheritance chain is 5 (in
FLTK1.3, not including anything you define yourself which might take it
up to no more than 10). Given that we're talking about memory that's on
the stack (i.e. recursion) here, which is usually incredibly fast, the
performance would be comparable to a for loop searching through an array
of ten elements; the pointer list is easier to maintain though.
> If the main advantage of styling is just to save some widget space then I do
> not thing its worth the effort. However I can see the advantage of single
> point of
> control of appearance.
>
> Another possibility - simpler, closer to fltk 1.x - would be setting&
> control of some global style rules: The constructor(s) of the widget(s) would
> just copy
> current values from these rules at the time of widget creation. User could
> control that at run time by swapping the values within these rules. This
> would not
> allow for later change but to be honest changes of properties (like font
> sizes) might need much more maintenance (eg font size migh require change of
> placement
> and/or size the widgets etc) than just change of a value within a style.
Well, they both save space *and* allow you fine-grained control of one
or all widget('s) looks. Certainly worth the effort!
Ben
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev