diff --git a/headers/private/app/ServerReadOnlyMemory.h b/headers/private/app/ServerReadOnlyMemory.h index d9d1760c2c..238498111b 100644 --- a/headers/private/app/ServerReadOnlyMemory.h +++ b/headers/private/app/ServerReadOnlyMemory.h @@ -17,21 +17,21 @@ // B_SUCCESS_COLOR and B_FAILURE_COLOR. // If you add a constant with index greater than 100 you'll have to add // to the second operand. -static const int32 B_COLOR_WHICH_COUNT = B_SCROLL_BAR_THUMB_COLOR + 3; +static const int32 kColorWhichCount = B_SCROLL_BAR_THUMB_COLOR + 3; struct server_read_only_memory { - rgb_color colors[B_COLOR_WHICH_COUNT]; + rgb_color colors[kColorWhichCount]; }; static inline int32 color_which_to_index(color_which which) { - if (which <= B_COLOR_WHICH_COUNT - 3) + if (which <= kColorWhichCount - 3) return which - 1; if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR) - return which - B_SUCCESS_COLOR + B_COLOR_WHICH_COUNT - 3; + return which - B_SUCCESS_COLOR + kColorWhichCount - 3; return -1; } @@ -40,12 +40,12 @@ color_which_to_index(color_which which) static inline color_which index_to_color_which(int32 index) { - if (index >= 0 && index < B_COLOR_WHICH_COUNT) { - if ((color_which)index < B_COLOR_WHICH_COUNT - 3) + if (index >= 0 && index < kColorWhichCount) { + if ((color_which)index < kColorWhichCount - 3) return (color_which)(index + 1); else { return (color_which)(index + B_SUCCESS_COLOR - - B_COLOR_WHICH_COUNT - 3); + - kColorWhichCount - 3); } } diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index dec8d42a91..b712b4f4b9 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -69,7 +69,7 @@ menu_info *_menu_info_ptr_; extern "C" const char B_NOTIFICATION_SENDER[] = "be:sender"; -static const rgb_color _kDefaultColors[B_COLOR_WHICH_COUNT] = { +static const rgb_color _kDefaultColors[kColorWhichCount] = { {216, 216, 216, 255}, // B_PANEL_BACKGROUND_COLOR {216, 216, 216, 255}, // B_MENU_BACKGROUND_COLOR {255, 203, 0, 255}, // B_WINDOW_TAB_COLOR @@ -1071,7 +1071,7 @@ rgb_color ui_color(color_which which) { int32 index = color_which_to_index(which); - if (index < 0 || index >= B_COLOR_WHICH_COUNT) { + if (index < 0 || index >= kColorWhichCount) { fprintf(stderr, "ui_color(): unknown color_which %d\n", which); return make_color(0, 0, 0); } @@ -1090,7 +1090,7 @@ void set_ui_color(const color_which &which, const rgb_color &color) { int32 index = color_which_to_index(which); - if (index < 0 || index >= B_COLOR_WHICH_COUNT) { + if (index < 0 || index >= kColorWhichCount) { fprintf(stderr, "set_ui_color(): unknown color_which %d\n", which); return; } diff --git a/src/servers/app/DesktopSettings.cpp b/src/servers/app/DesktopSettings.cpp index 12646ae9f3..d6895b4657 100644 --- a/src/servers/app/DesktopSettings.cpp +++ b/src/servers/app/DesktopSettings.cpp @@ -78,7 +78,7 @@ DesktopSettingsPrivate::_SetDefaults() fWorkspacesRows = 2; memcpy(fShared.colors, BPrivate::kDefaultColors, - sizeof(rgb_color) * B_COLOR_WHICH_COUNT); + sizeof(rgb_color) * kColorWhichCount); gSubpixelAntialiasing = false; gDefaultHintingMode = HINTING_MODE_ON; @@ -292,7 +292,7 @@ DesktopSettingsPrivate::_Load() } // colors - for (int32 i = 0; i < B_COLOR_WHICH_COUNT; i++) { + for (int32 i = 0; i < kColorWhichCount; i++) { char colorName[12]; snprintf(colorName, sizeof(colorName), "color%" B_PRId32, (int32)index_to_color_which(i)); @@ -437,7 +437,7 @@ DesktopSettingsPrivate::Save(uint32 mask) settings.AddInt8("subpixel average weight", gSubpixelAverageWeight); settings.AddBool("subpixel ordering", gSubpixelOrderingRGB); - for (int32 i = 0; i < B_COLOR_WHICH_COUNT; i++) { + for (int32 i = 0; i < kColorWhichCount; i++) { char colorName[12]; snprintf(colorName, sizeof(colorName), "color%" B_PRId32, (int32)index_to_color_which(i)); @@ -650,7 +650,7 @@ void DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color) { int32 index = color_which_to_index(which); - if (index < 0 || index >= B_COLOR_WHICH_COUNT) + if (index < 0 || index >= kColorWhichCount) return; fShared.colors[index] = color; @@ -658,6 +658,7 @@ DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color) // otherwise we have to keep this duplication... if (which == B_MENU_BACKGROUND_COLOR) fMenuInfo.background_color = color; + Save(kAppearanceSettings); } @@ -667,8 +668,9 @@ DesktopSettingsPrivate::UIColor(color_which which) const { static const rgb_color invalidColor = {0, 0, 0, 0}; int32 index = color_which_to_index(which); - if (index < 0 || index >= B_COLOR_WHICH_COUNT) + if (index < 0 || index >= kColorWhichCount) return invalidColor; + return fShared.colors[index]; }