[haiku-development] Re: [RFC] BStringView HighColor

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Mon, 13 Jan 2014 18:51:03 -0500

On Mon, Jan 13, 2014 at 6:34 PM, François Revol <revol@xxxxxxx> wrote:
> On 13/01/2014 23:30, John Scipione wrote:
>> On Mon, Jan 13, 2014 at 4:52 PM, François Revol <revol@xxxxxxx> wrote:
>>> I noticed BStringView checks for the parent color and uses ui_color() as
>>> a fallback.
>>> I propose we also set the HighColor to ui_color(B_PANEL_TEXT_COLOR), but
>>> I'm not sure in which cases.
>>> I'd say if (color == ui_color(B_PANEL_BACKGROUND_COLOR)) (either it
>>> wasn't set, or the parent's is panel bg).
>>>
>>> Comments?
>>
>> What exactly is the problem because the default high and low colors
>> set in BView and are black and white respectively. You only want to
>> use the B_PANEL_TEXT_COLOR and B_PANEL_BACKGROUND_COLOR if you are
>> drawing a panel, which you can't say by default.
>
> Well, some themes do set B_PANEL_BACKGROUND_COLOR to black...

And those themes should set their B_PANEL_TEXT_COLOR to something
light so that it shows up correctly.

You'll have to go into more depth what the specific issue your having is.

The most common problem with dark themes is that we tend to apply a
B_DARKEN_x_TINT and B_LIGHTEN_x_TINT without detecting if the thing
we're tinting is light or dark and adjusting accordingly.

For example:

rgb_color textColor;
rgb_color highColor = ui_color(B_PANEL_TEXT_COLOR);

if (highColor.red + highColor.blue + highColor.green > 128 * 3)
    textColor = tint_color(highColor, B_DARKEN_2_TINT);
else
    textColor = tint_color(highColor, B_LIGHTEN_2_TINT);

Of course this is pretty tedious so ControlLook could give us some
convenience methods to abstract this out.

Other related posts: