Appearance: Send only one color update message.

This will Batch the colors into one update, the app_server also
consolidates color updates, but does so based on timeframe. This will
prevent colors from beeing send in two different batches which may be
severall ms apart based on the batch timing

Change-Id: I9cdda57f07e1efb6ce685cd984a96ea95ae3190c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9094
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: John Scipione <[email protected]>
Reviewed-by: nephele nephele <[email protected]>
This commit is contained in:
Pascal Abresch
2025-11-16 21:04:58 +00:00
committed by nephele nephele
parent d640e20575
commit ac14f84c52
2 changed files with 30 additions and 32 deletions
+30 -31
View File
@@ -310,10 +310,13 @@ ColorsView::_SetColor(int32 index, rgb_color color)
void
ColorsView::_SetColor(color_which which, rgb_color color)
{
_SetOneColor(which, color);
fCurrentColors.SetColor(ui_color_name(which), color);
if (!fAutoSelectCheckBox->Value())
if (!fAutoSelectCheckBox->Value()) {
if (ui_color(which) != color)
set_ui_color(which, color);
return;
}
// Protect against accidentally overwriting colors.
if (ui_color(which) == color)
@@ -322,31 +325,35 @@ ColorsView::_SetColor(color_which which, rgb_color color)
if (which == B_PANEL_BACKGROUND_COLOR) {
const bool isDark = color.IsDark();
_SetOneColor(B_MENU_BACKGROUND_COLOR, color);
fCurrentColors.SetColor(ui_color_name(B_MENU_BACKGROUND_COLOR), color);
const rgb_color menuSelectedBackground
= tint_color(color, isDark ? 0.8 /* lighten "< 1" */ : B_DARKEN_2_TINT);
_SetOneColor(B_MENU_SELECTED_BACKGROUND_COLOR, menuSelectedBackground);
fCurrentColors.SetColor(ui_color_name(B_MENU_SELECTED_BACKGROUND_COLOR),
menuSelectedBackground);
const rgb_color controlBackground = tint_color(color,
0.84 /* lighten "< 1" */);
_SetOneColor(B_CONTROL_BACKGROUND_COLOR, controlBackground);
_SetOneColor(B_SCROLL_BAR_THUMB_COLOR, controlBackground);
fCurrentColors.SetColor(ui_color_name(B_CONTROL_BACKGROUND_COLOR), controlBackground);
fCurrentColors.SetColor(ui_color_name(B_SCROLL_BAR_THUMB_COLOR), controlBackground);
const rgb_color controlBorder
= tint_color(color, isDark ? 0.4875 : 1.20 /* lighten/darken "1.5" */);
_SetOneColor(B_CONTROL_BORDER_COLOR, controlBorder);
fCurrentColors.SetColor(ui_color_name(B_CONTROL_BORDER_COLOR), controlBorder);
const rgb_color windowBorder = tint_color(color, 0.75);
_SetOneColor(B_WINDOW_BORDER_COLOR, windowBorder);
fCurrentColors.SetColor(ui_color_name(B_WINDOW_BORDER_COLOR), windowBorder);
const rgb_color inactiveWindowBorder = tint_color(color, B_LIGHTEN_1_TINT);
_SetOneColor(B_WINDOW_INACTIVE_TAB_COLOR, inactiveWindowBorder);
_SetOneColor(B_WINDOW_INACTIVE_BORDER_COLOR, inactiveWindowBorder);
fCurrentColors.SetColor(ui_color_name(B_WINDOW_INACTIVE_TAB_COLOR),
inactiveWindowBorder);
fCurrentColors.SetColor(ui_color_name(B_WINDOW_INACTIVE_BORDER_COLOR),
inactiveWindowBorder);
const rgb_color listSelectedBackground
= tint_color(color, isDark ? 0.77 : 1.12 /* lighten/darken "< 1" */ );
_SetOneColor(B_LIST_SELECTED_BACKGROUND_COLOR, listSelectedBackground);
fCurrentColors.SetColor(ui_color_name(B_LIST_SELECTED_BACKGROUND_COLOR),
listSelectedBackground);
const color_which fromDefaults[] = {
B_MENU_ITEM_TEXT_COLOR,
@@ -371,18 +378,20 @@ ColorsView::_SetColor(color_which which, rgb_color color)
B_LINK_VISITED_COLOR,
};
for (size_t i = 0; i < B_COUNT_OF(fromDefaults); i++)
_SetOneColor(fromDefaults[i], BPrivate::GetSystemColor(fromDefaults[i], isDark));
fCurrentColors.SetColor(ui_color_name(fromDefaults[i])
, BPrivate::GetSystemColor(fromDefaults[i], isDark));
} else if (which == B_STATUS_BAR_COLOR) {
const hsl_color statusColorHSL = hsl_color::from_rgb(color);
hsl_color controlHighlight = statusColorHSL;
controlHighlight.saturation = max_c(0.2f, controlHighlight.saturation / 2.f);
_SetOneColor(B_CONTROL_HIGHLIGHT_COLOR, controlHighlight.to_rgb());
fCurrentColors.SetColor(ui_color_name(B_CONTROL_HIGHLIGHT_COLOR)
, controlHighlight.to_rgb());
hsl_color controlMark = statusColorHSL;
controlMark.saturation = max_c(0.2f, controlMark.saturation * 0.67f);
controlMark.lightness = max_c(0.25f, controlMark.lightness * 0.55f);
_SetOneColor(B_CONTROL_MARK_COLOR, controlMark.to_rgb());
fCurrentColors.SetColor(ui_color_name(B_CONTROL_MARK_COLOR), controlMark.to_rgb());
rgb_color keyboardNav; {
hsl_color keyboardNavHSL = statusColorHSL;
@@ -397,38 +406,28 @@ ColorsView::_SetColor(color_which which, rgb_color color)
else
keyboardNav.red = keyboardNav.blue = 0;
}
_SetOneColor(B_KEYBOARD_NAVIGATION_COLOR, keyboardNav);
fCurrentColors.SetColor(ui_color_name(B_KEYBOARD_NAVIGATION_COLOR), keyboardNav);
} else if (which == B_WINDOW_TAB_COLOR) {
const bool isDark = color.IsDark();
const hsl_color tabColorHSL = hsl_color::from_rgb(color);
const float tabColorSaturation
= tabColorHSL.saturation != 0 ? tabColorHSL.saturation : tabColorHSL.lightness;
_SetOneColor(B_WINDOW_TEXT_COLOR,
fCurrentColors.SetColor(ui_color_name(B_WINDOW_TEXT_COLOR),
BPrivate::GetSystemColor(B_WINDOW_TEXT_COLOR, isDark));
_SetOneColor(B_TOOL_TIP_TEXT_COLOR,
fCurrentColors.SetColor(ui_color_name(B_TOOL_TIP_TEXT_COLOR),
BPrivate::GetSystemColor(B_TOOL_TIP_TEXT_COLOR, isDark));
const rgb_color toolTipBackground = tint_color(color, isDark ? 1.7 : 0.15);
_SetOneColor(B_TOOL_TIP_BACKGROUND_COLOR, toolTipBackground);
fCurrentColors.SetColor(ui_color_name(B_TOOL_TIP_BACKGROUND_COLOR), toolTipBackground);
hsl_color success = hsl_color::from_rgb(BPrivate::GetSystemColor(B_SUCCESS_COLOR, isDark));
success.saturation = max_c(0.25f, tabColorSaturation * 0.68f);
_SetOneColor(B_SUCCESS_COLOR, success.to_rgb());
fCurrentColors.SetColor(ui_color_name(B_SUCCESS_COLOR), success.to_rgb());
hsl_color failure = hsl_color::from_rgb(BPrivate::GetSystemColor(B_FAILURE_COLOR, isDark));
failure.saturation = max_c(0.25f, tabColorSaturation);
_SetOneColor(B_FAILURE_COLOR, failure.to_rgb());
fCurrentColors.SetColor(ui_color_name(B_FAILURE_COLOR), failure.to_rgb());
}
}
void
ColorsView::_SetOneColor(color_which which, rgb_color color)
{
if (ui_color(which) == color)
return;
set_ui_color(which, color);
fCurrentColors.SetColor(ui_color_name(which), color);
set_ui_colors(&fCurrentColors);
}
-1
View File
@@ -54,7 +54,6 @@ private:
void _SetColor(int32 index, rgb_color color);
void _SetColor(color_which which, rgb_color color);
void _SetOneColor(color_which which, rgb_color color);
void _SetCurrentColor(rgb_color color);
void _SetUIColors(const BMessage& colors);