Rename B_COLOR_WHICH_COUNT to kColorWhichCount

This commit is contained in:
John Scipione
2013-04-16 03:44:42 -04:00
parent 376e5bb692
commit af84ce79da
3 changed files with 17 additions and 15 deletions
+7 -7
View File
@@ -17,21 +17,21 @@
// B_SUCCESS_COLOR and B_FAILURE_COLOR. // B_SUCCESS_COLOR and B_FAILURE_COLOR.
// If you add a constant with index greater than 100 you'll have to add // If you add a constant with index greater than 100 you'll have to add
// to the second operand. // 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 { struct server_read_only_memory {
rgb_color colors[B_COLOR_WHICH_COUNT]; rgb_color colors[kColorWhichCount];
}; };
static inline int32 static inline int32
color_which_to_index(color_which which) color_which_to_index(color_which which)
{ {
if (which <= B_COLOR_WHICH_COUNT - 3) if (which <= kColorWhichCount - 3)
return which - 1; return which - 1;
if (which >= B_SUCCESS_COLOR && which <= B_FAILURE_COLOR) 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; return -1;
} }
@@ -40,12 +40,12 @@ color_which_to_index(color_which which)
static inline color_which static inline color_which
index_to_color_which(int32 index) index_to_color_which(int32 index)
{ {
if (index >= 0 && index < B_COLOR_WHICH_COUNT) { if (index >= 0 && index < kColorWhichCount) {
if ((color_which)index < B_COLOR_WHICH_COUNT - 3) if ((color_which)index < kColorWhichCount - 3)
return (color_which)(index + 1); return (color_which)(index + 1);
else { else {
return (color_which)(index + B_SUCCESS_COLOR return (color_which)(index + B_SUCCESS_COLOR
- B_COLOR_WHICH_COUNT - 3); - kColorWhichCount - 3);
} }
} }
+3 -3
View File
@@ -69,7 +69,7 @@ menu_info *_menu_info_ptr_;
extern "C" const char B_NOTIFICATION_SENDER[] = "be:sender"; 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_PANEL_BACKGROUND_COLOR
{216, 216, 216, 255}, // B_MENU_BACKGROUND_COLOR {216, 216, 216, 255}, // B_MENU_BACKGROUND_COLOR
{255, 203, 0, 255}, // B_WINDOW_TAB_COLOR {255, 203, 0, 255}, // B_WINDOW_TAB_COLOR
@@ -1071,7 +1071,7 @@ rgb_color
ui_color(color_which which) ui_color(color_which which)
{ {
int32 index = color_which_to_index(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); fprintf(stderr, "ui_color(): unknown color_which %d\n", which);
return make_color(0, 0, 0); return make_color(0, 0, 0);
} }
@@ -1090,7 +1090,7 @@ void
set_ui_color(const color_which &which, const rgb_color &color) set_ui_color(const color_which &which, const rgb_color &color)
{ {
int32 index = color_which_to_index(which); 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); fprintf(stderr, "set_ui_color(): unknown color_which %d\n", which);
return; return;
} }
+7 -5
View File
@@ -78,7 +78,7 @@ DesktopSettingsPrivate::_SetDefaults()
fWorkspacesRows = 2; fWorkspacesRows = 2;
memcpy(fShared.colors, BPrivate::kDefaultColors, memcpy(fShared.colors, BPrivate::kDefaultColors,
sizeof(rgb_color) * B_COLOR_WHICH_COUNT); sizeof(rgb_color) * kColorWhichCount);
gSubpixelAntialiasing = false; gSubpixelAntialiasing = false;
gDefaultHintingMode = HINTING_MODE_ON; gDefaultHintingMode = HINTING_MODE_ON;
@@ -292,7 +292,7 @@ DesktopSettingsPrivate::_Load()
} }
// colors // colors
for (int32 i = 0; i < B_COLOR_WHICH_COUNT; i++) { for (int32 i = 0; i < kColorWhichCount; i++) {
char colorName[12]; char colorName[12];
snprintf(colorName, sizeof(colorName), "color%" B_PRId32, snprintf(colorName, sizeof(colorName), "color%" B_PRId32,
(int32)index_to_color_which(i)); (int32)index_to_color_which(i));
@@ -437,7 +437,7 @@ DesktopSettingsPrivate::Save(uint32 mask)
settings.AddInt8("subpixel average weight", gSubpixelAverageWeight); settings.AddInt8("subpixel average weight", gSubpixelAverageWeight);
settings.AddBool("subpixel ordering", gSubpixelOrderingRGB); 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]; char colorName[12];
snprintf(colorName, sizeof(colorName), "color%" B_PRId32, snprintf(colorName, sizeof(colorName), "color%" B_PRId32,
(int32)index_to_color_which(i)); (int32)index_to_color_which(i));
@@ -650,7 +650,7 @@ void
DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color) DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color)
{ {
int32 index = color_which_to_index(which); int32 index = color_which_to_index(which);
if (index < 0 || index >= B_COLOR_WHICH_COUNT) if (index < 0 || index >= kColorWhichCount)
return; return;
fShared.colors[index] = color; fShared.colors[index] = color;
@@ -658,6 +658,7 @@ DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color)
// otherwise we have to keep this duplication... // otherwise we have to keep this duplication...
if (which == B_MENU_BACKGROUND_COLOR) if (which == B_MENU_BACKGROUND_COLOR)
fMenuInfo.background_color = color; fMenuInfo.background_color = color;
Save(kAppearanceSettings); Save(kAppearanceSettings);
} }
@@ -667,8 +668,9 @@ DesktopSettingsPrivate::UIColor(color_which which) const
{ {
static const rgb_color invalidColor = {0, 0, 0, 0}; static const rgb_color invalidColor = {0, 0, 0, 0};
int32 index = color_which_to_index(which); int32 index = color_which_to_index(which);
if (index < 0 || index >= B_COLOR_WHICH_COUNT) if (index < 0 || index >= kColorWhichCount)
return invalidColor; return invalidColor;
return fShared.colors[index]; return fShared.colors[index];
} }