DeskCalc: fix live updating of button text color

When using the panel background color, always use the matching panel
text color from system preferences.

When using a custom color, compute appropriate light or dark text color
to go with it.

Change-Id: I107731efec03a8c9661b89e26255a4fe91def79b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3560
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
Adrien Destugues 2023-01-12 13:28:29 +01:00 committed by Adrien Destugues
parent c8a1650c73
commit b3099de672
2 changed files with 15 additions and 23 deletions

View File

@ -1376,28 +1376,22 @@ CalcView::_FlashKey(int32 key, uint32 flashFlags)
void
CalcView::_Colorize()
{
// calculate light and dark color from base color
fLightColor.red = (uint8)(fBaseColor.red * 1.25);
fLightColor.green = (uint8)(fBaseColor.green * 1.25);
fLightColor.blue = (uint8)(fBaseColor.blue * 1.25);
fLightColor.alpha = 255;
if (fHasCustomBaseColor) {
// keypad text color
if (fBaseColor.Brightness() > 100)
fButtonTextColor = (rgb_color){ 0, 0, 0, 255 };
else
fButtonTextColor = (rgb_color){ 255, 255, 255, 255 };
fDarkColor.red = (uint8)(fBaseColor.red * 0.75);
fDarkColor.green = (uint8)(fBaseColor.green * 0.75);
fDarkColor.blue = (uint8)(fBaseColor.blue * 0.75);
fDarkColor.alpha = 255;
// keypad text color
if (fBaseColor.Brightness() > 100)
fButtonTextColor = (rgb_color){ 0, 0, 0, 255 };
else
fButtonTextColor = (rgb_color){ 255, 255, 255, 255 };
// expression text color
if (fExpressionBGColor.Brightness() > 100)
fExpressionTextColor = (rgb_color){ 0, 0, 0, 255 };
else
fExpressionTextColor = (rgb_color){ 255, 255, 255, 255 };
// expression text color
if (fExpressionBGColor.Brightness() > 100)
fExpressionTextColor = (rgb_color){ 0, 0, 0, 255 };
else
fExpressionTextColor = (rgb_color){ 255, 255, 255, 255 };
} else {
fExpressionTextColor = ui_color(B_DOCUMENT_TEXT_COLOR);
fButtonTextColor = ui_color(B_PANEL_TEXT_COLOR);
}
}

View File

@ -122,8 +122,6 @@ class _EXPORT CalcView : public BView {
// color scheme
rgb_color fBaseColor;
rgb_color fLightColor;
rgb_color fDarkColor;
rgb_color fButtonTextColor;
rgb_color fExpressionBGColor;
rgb_color fExpressionTextColor;