Update ListItem's to use menu item colors.

* Selected bg uses B_MENU_SELECTED_BACKGROUND_COLOR
* Selected text uses B_MENU_SELECTED_ITEM_TEXT_COLOR
* Unselected text uses B_MENU_ITEM_TEXT_COLOR

Update BStringItem, but also the custom Listitem code in the
Appearance and Locale preflets.
This commit is contained in:
John Scipione
2012-08-20 02:20:59 -04:00
parent 403bd97afc
commit 2c1f6c10ce
3 changed files with 40 additions and 21 deletions
+13 -7
View File
@@ -77,7 +77,7 @@ BStringItem::DrawItem(BView *owner, BRect frame, bool complete)
if (IsSelected() || complete) {
if (IsSelected()) {
owner->SetHighColor(tint_color(lowColor, B_DARKEN_2_TINT));
owner->SetHighColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR));
owner->SetLowColor(owner->HighColor());
} else
owner->SetHighColor(lowColor);
@@ -87,12 +87,18 @@ BStringItem::DrawItem(BView *owner, BRect frame, bool complete)
owner->MovePenTo(frame.left, frame.top + fBaselineOffset);
rgb_color black = {0, 0, 0, 255};
if (!IsEnabled())
owner->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
else
owner->SetHighColor(black);
if (!IsEnabled()) {
rgb_color textColor = ui_color(B_MENU_ITEM_TEXT_COLOR);
if (textColor.red + textColor.green + textColor.blue > 128 * 3)
owner->SetHighColor(tint_color(textColor, B_DARKEN_2_TINT));
else
owner->SetHighColor(tint_color(textColor, B_LIGHTEN_2_TINT));
} else {
if (IsSelected())
owner->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
else
owner->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
}
owner->DrawString(fText);
+13 -9
View File
@@ -32,7 +32,7 @@ ColorWhichItem::DrawItem(BView *owner, BRect frame, bool complete)
if (IsSelected() || complete) {
if (IsSelected()) {
owner->SetHighColor(tint_color(lowColor, B_DARKEN_2_TINT));
owner->SetHighColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR));
owner->SetLowColor(owner->HighColor());
} else
owner->SetHighColor(lowColor);
@@ -53,14 +53,18 @@ ColorWhichItem::DrawItem(BView *owner, BRect frame, bool complete)
owner->MovePenTo(frame.left + colorRect.Width() + 8, frame.top
+ BaselineOffset());
// TODO: Don't hardcode black here, calculate based on background
// color or use B_CONTROL_TEXT_COLOR constant.
rgb_color black = (rgb_color){ 0, 0, 0, 255 };
if (!IsEnabled())
owner->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
else
owner->SetHighColor(black);
if (!IsEnabled()) {
rgb_color textColor = ui_color(B_MENU_ITEM_TEXT_COLOR);
if (textColor.red + textColor.green + textColor.blue > 128 * 3)
owner->SetHighColor(tint_color(textColor, B_DARKEN_2_TINT));
else
owner->SetHighColor(tint_color(textColor, B_LIGHTEN_2_TINT));
} else {
if (IsSelected())
owner->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
else
owner->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
}
owner->DrawString(Text());
+14 -5
View File
@@ -70,6 +70,7 @@ LanguageListItem::DrawItemWithTextOffset(BView* owner, BRect frame,
color = ui_color(B_MENU_SELECTED_BACKGROUND_COLOR);
else
color = owner->ViewColor();
owner->SetHighColor(color);
owner->SetLowColor(color);
owner->FillRect(frame);
@@ -77,11 +78,19 @@ LanguageListItem::DrawItemWithTextOffset(BView* owner, BRect frame,
owner->SetLowColor(owner->ViewColor());
BString text = Text();
if (IsEnabled())
owner->SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
else {
owner->SetHighColor(tint_color(owner->LowColor(), B_DARKEN_3_TINT));
if (!IsEnabled()) {
rgb_color textColor = ui_color(B_MENU_ITEM_TEXT_COLOR);
if (textColor.red + textColor.green + textColor.blue > 128 * 3)
owner->SetHighColor(tint_color(textColor, B_DARKEN_2_TINT));
else
owner->SetHighColor(tint_color(textColor, B_LIGHTEN_2_TINT));
text << " [" << B_TRANSLATE("already chosen") << "]";
} else {
if (IsSelected())
owner->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
else
owner->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
}
owner->MovePenTo(frame.left + kLeftInset + textOffset,
@@ -359,7 +368,7 @@ LanguageListView::InitiateDrag(BPoint point, int32 dragIndex,
item->DrawItem(view, itemBounds);
itemBounds.top = itemBounds.bottom + 1.0;
}
// make a black frame arround the edge
// make a black frame around the edge
view->SetHighColor(0, 0, 0, 255);
view->StrokeRect(view->Bounds());
view->Sync();