RE: [fltk.general] Setting color [General Use]

9 views
Skip to first unread message

MacArthur, Ian (Leonardo, UK)

unread,
Apr 12, 2017, 4:50:02 AM4/12/17
to fltkg...@googlegroups.com

> What is the best way of setting the color of a widget
> and all its sub widgets ?

Hi Håvard

I'm not entirely clear what you are asking. I think you are maybe wanting to set the (background?) colour of, say, a group widget, and have all the widgets contained within that group inherit the same colour?

Is that correct? Can you expand on the question a bit?

Cheers,
--
Ian


Leonardo MW Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

holm.h...@gmail.com

unread,
Apr 12, 2017, 7:21:03 AM4/12/17
to fltk.general, ian.ma...@leonardocompany.com

Hi Ian,

Yes you are right, I have a group widget and want to set the same color for the group widget, for all "children" and for all "grand children" and so on.
Or alternatively - and even better for my application, I want to make the group widget and all children a little bit darker.

When my application is used by night, the user wants to dim the light, he want to make the screen darker. When sun rises, the colors should be back to normal again..

Best regards and happy easter !
Håvard

Greg Ercolano

unread,
Apr 12, 2017, 11:49:59 AM4/12/17
to fltkg...@googlegroups.com
On 04/12/17 04:21, holm.h...@gmail.com wrote:
> When my application is used by night, the user wants to dim the light,
> he want to make the screen darker. When sun rises, the colors should be back to normal again..

I'd think the easiest way to bring the colors of the whole
app down would be to bring down the brightness of the entire
color map using Fl::set_color() for not just the background,
but for all colors in the 8 bit colormap: 0 - 255.

You can 'snapshot' the startup colormap (at the top of main,
or after the Fl::show(argc,argv), as I think that can affect
the colormap used) using Fl::get_color() and keep the rgb values
of all 256 colors in an array, e.g. rgb[256][3]. Then, as it gets
'dark' out, apply a scaled down version of that array using Fl::set_color().

That'd hit the entire application; menus, fonts, etc.

MacArthur, Ian (Leonardo, UK)

unread,
Apr 12, 2017, 12:36:29 PM4/12/17
to fltkg...@googlegroups.com
> > When my application is used by night, the user wants to dim the
> light,
> > he want to make the screen darker. When sun rises, the colors should
> be back to normal again..
>
> I'd think the easiest way to bring the colors of the whole
> app down would be to bring down the brightness of the entire
> color map using Fl::set_color() for not just the background,
> but for all colors in the 8 bit colormap: 0 - 255.
>
> You can 'snapshot' the startup colormap (at the top of main,
> or after the Fl::show(argc,argv), as I think that can affect
> the colormap used)

Yes, calling Fl::show(argc,argv) or Fl:get_system_colors() can change the base colour map; I know this because I got caught out by that just recently!



> using Fl::get_color() and keep the rgb values
> of all 256 colors in an array, e.g. rgb[256][3]. Then, as it gets
> 'dark' out, apply a scaled down version of that array using
> Fl::set_color().
>
> That'd hit the entire application; menus, fonts, etc.



MacArthur, Ian (Leonardo, UK)

unread,
Apr 12, 2017, 12:59:42 PM4/12/17
to fltkg...@googlegroups.com
> I'd think the easiest way to bring the colors of the whole
> app down would be to bring down the brightness of the entire
> color map using Fl::set_color() for not just the background,
> but for all colors in the 8 bit colormap: 0 - 255.
>
> You can 'snapshot' the startup colormap (at the top of main,
> or after the Fl::show(argc,argv), as I think that can affect
> the colormap used) using Fl::get_color() and keep the rgb values
> of all 256 colors in an array, e.g. rgb[256][3]. Then, as it gets
> 'dark' out, apply a scaled down version of that array using
> Fl::set_color().

Tried that; worked like a charm on this test box.

See attached...
box-test.cxx
Reply all
Reply to author
Forward
0 new messages