FLTK logo

Re: [fltk.general] Feature request: plastic scheme with faithful colors

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Feature request: plastic scheme with faithful colors Albrecht Schlosser Sep 23, 2021  
 
On 9/22/21 5:17 AM rs wrote:

This is simply a feature request for later versions, however if there are any known work arounds I would be keen to hear them.

In short, I want to use the plastic scheme in FLTK. Uniquely to this scheme, however, in the low-level drawing functions is a color averaging step which makes every color choice made by the developer more "gray".

This is one of the reasons I never use the plastic scheme.

I feel this is a very restrictive and unnecessary thing to do for several reasons:

     1. It is unpredictable - if I choose fl_rgb_color(255,0,0) I do not get red
     2. More significantly, some colors are simply not obtainable - there are hard "dark" and "light" limits which can't be overcome.

Good points.

The "usual" way to by-pass default drawing things (subclass the widget and provide its own draw method) isn't particularly helpful as the color averaging occurs deep deep down in the draw_box functions called at many points in the inheritance hierarchy,
Indeed, you'd have to subclasse *every* widget you're using. That's not really doable.

(Note also many widgets have their draw function set as private rather than protected, which sometimes makes that method awkward/not possible without replicated huge chunks of FLTK code even without the color issue).

That's not correct. All draw() methods are protected to emphasize that they should not be called from any context rather than a valid drawing context (I just examined all draw() methods in the docs). The docs tell how to use the virtual draw() method for a widget from another widget's draw() method (or in another vaid context):

"If you ever need to call another widget's draw method from within your own draw() method, e.g. for an embedded scrollbar, you can do it (because draw() is virtual) like this:

  Fl_Widget *s = &scrollbar; // scrollbar is an embedded Fl_Scrollbar
  s->draw(); // calls Fl_Scrollbar::draw()
"

https://www.fltk.org/doc-1.4/classFl__Widget.html#a1acb38c6b3cb40452ad02ccfeedbac8a

Well, I admit that it's not as easy as just calling draw() ...


As a concrete example, imagine I want to create a "dark theme" window with a black menu bar with white text whilst using the plastic theme, I simple can't make it darker than a middling grey color.

Moreover, the color averaging is unpredictable/inconsistent. I can set the menu bar box to FL_FLAT_BOX for aesthetic reasons (whilst keeping the plastic theme for the sake of the other widgets). If I do so the top level menu bar then *doesn't* perform the color averaging. But when you open the menus the pop up menu windows *do* perform the color averaging.

From my experience with trying to tweak the colors with this scheme the conclusion I keep coming to is that this color averaging simply should not be happening - its restrictive, not doing what the developer asks for, and not consistent.

Clearly backwards compatibility is an issue so I think a great feature would be some kind of "PlasticNeo" scheme where the color averaging is disabled.

If disabling the color averaging is all we need to do I'd rather add an option like Fl_Scheme::color_averaging(float average) (see below) to disable it (default would be enabled, of course). I believe this would be a better choice than duplicating the entire scheme.

... if there are any ways around this I would be glad to hear them.

I attach a patch which seems to mitigate the color averaging. I tried several values and the attached image shows the result of setting the average to 0.40f. You may want to play with the factor yourself. If that's what you want we could maybe add the option as described above or in a similar way.

The code shows that there is only one other occurrence of color averaging depending on the plastic scheme in Fl_Light_Button, which is not affected by the patch.

Please report if this is what you're looking for. Does it work? Which factor do you prefer?

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/fd50a8ff-ff5e-2cdb-4665-4e7fd61b73de%40online.de.

Attachment: plastic-0.40.png
Description: PNG image

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.