Remove dependence on color constants in ServerReadOnlyMemory.

This fixes a maintainance problem where you have to update this otherwise
unrelated file to keep it in sync whenever you add a color constant.

I've added a B_COLOR_WHICH_COUNT constant to the color_which enum which should
be updated to point to the newest color constants as new ones are added. I
reworked ServerReadOnlyMemory to use this constant instead of using to the
current largest color constant directly. If you use B_COLOR_WHICH_COUNT to
refer to a color in your code expect to get unpredictable and nonsensical
results. Most likely you'll get an undefined result which will return black
but don't depend on it.

The net effect of this is that ServerReadOnlyMemory doesn't need to be updated
anymore when new color constants are introduced but will continue to produce
correct results.

Eliminate kNumColors constant, replace it with B_COLOR_WHICH_COUNT
This commit is contained in:
John Scipione
2013-04-05 22:46:22 -04:00
parent 9f24981a56
commit 3302521556
4 changed files with 24 additions and 22 deletions
+8 -2
View File
@@ -331,9 +331,15 @@ enum color_which {
B_KEYBOARD_NAVIGATION_COLOR = B_NAVIGATION_BASE_COLOR,
B_MENU_SELECTION_BACKGROUND_COLOR = B_MENU_SELECTED_BACKGROUND_COLOR,
// These are deprecated -- do not use in new code. See BScreen for
// the replacement for B_DESKTOP_COLOR.
// Update this constant to be the largest color constant excluding
// 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 below and also update ServerReadOnlyMemory.h
B_COLOR_WHICH_COUNT = B_SCROLL_BAR_THUMB_COLOR + 3,
// The following constants are deprecated, do not use in new code.
B_DESKTOP_COLOR = 5
// see BScreen class for B_DESKTOP_COLOR replacement
};