Icon-o-Matic: list views use system colors
* Fixes #10840. * Properties view needs more work for dark themes (There is another ticket for that).
This commit is contained in:
@@ -50,7 +50,10 @@ SimpleItem::Draw(BView *owner, BRect frame, uint32 flags)
|
||||
{
|
||||
DrawBackground(owner, frame, flags);
|
||||
// label
|
||||
owner->SetHighColor(0, 0, 0, 255);
|
||||
if (IsSelected())
|
||||
owner->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
|
||||
else
|
||||
owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||
font_height fh;
|
||||
owner->GetFontHeight(&fh);
|
||||
const char* text = Text();
|
||||
@@ -78,12 +81,14 @@ SimpleItem::DrawBackground(BView *owner, BRect frame, uint32 flags)
|
||||
frame.InsetBy(1.0, 1.0);
|
||||
}
|
||||
// figure out bg-color
|
||||
rgb_color color = (rgb_color){ 255, 255, 255, 255 };
|
||||
rgb_color color = ui_color(B_LIST_BACKGROUND_COLOR);
|
||||
|
||||
if (IsSelected())
|
||||
color = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR);
|
||||
|
||||
if (flags & FLAGS_TINTED_LINE)
|
||||
color = tint_color(color, 1.06);
|
||||
// background
|
||||
if (IsSelected())
|
||||
color = tint_color(color, (B_DARKEN_1_TINT + B_DARKEN_2_TINT) / 2.0);
|
||||
|
||||
owner->SetLowColor(color);
|
||||
owner->FillRect(frame, B_SOLID_LOW);
|
||||
}
|
||||
@@ -174,11 +179,11 @@ DragSortableListView::Draw(BRect updateRect)
|
||||
}
|
||||
updateRect.top = r.bottom + 1.0;
|
||||
if (updateRect.IsValid()) {
|
||||
SetLowColor(255, 255, 255, 255);
|
||||
SetLowColor(ui_color(B_LIST_BACKGROUND_COLOR));
|
||||
FillRect(updateRect, B_SOLID_LOW);
|
||||
}
|
||||
} else {
|
||||
SetLowColor(255, 255, 255, 255);
|
||||
SetLowColor(ui_color(B_LIST_BACKGROUND_COLOR));
|
||||
FillRect(updateRect, B_SOLID_LOW);
|
||||
}
|
||||
// drop anticipation indication
|
||||
|
||||
@@ -54,11 +54,15 @@ PropertyItemView::Draw(BRect updateRect)
|
||||
BRect b(Bounds());
|
||||
|
||||
// just draw background and label
|
||||
rgb_color labelColor = LowColor();
|
||||
if (fEnabled)
|
||||
labelColor = tint_color(labelColor, B_DARKEN_MAX_TINT);
|
||||
else
|
||||
labelColor = tint_color(labelColor, B_DISABLED_LABEL_TINT);
|
||||
rgb_color highColor = HighColor();
|
||||
rgb_color labelColor = highColor;
|
||||
|
||||
if (!fEnabled) {
|
||||
if (highColor.red + highColor.green + highColor.blue < 128 * 3)
|
||||
labelColor = tint_color(HighColor(), B_LIGHTEN_2_TINT);
|
||||
else
|
||||
labelColor = tint_color(HighColor(), B_DARKEN_2_TINT);
|
||||
}
|
||||
|
||||
SetHighColor(labelColor);
|
||||
BFont font;
|
||||
@@ -76,9 +80,17 @@ PropertyItemView::Draw(BRect updateRect)
|
||||
+ fh.ascent / 2.0)));
|
||||
|
||||
// draw a "separator" line behind the label
|
||||
SetHighColor(tint_color(LowColor(), B_DARKEN_1_TINT));
|
||||
|
||||
rgb_color lowColor = LowColor();
|
||||
// Dark Themes
|
||||
if (lowColor.red + lowColor.green + lowColor.blue > 128 * 3)
|
||||
SetHighColor(tint_color(LowColor(), B_DARKEN_1_TINT));
|
||||
else
|
||||
SetHighColor(tint_color(LowColor(), B_LIGHTEN_1_TINT));
|
||||
|
||||
StrokeLine(BPoint(b.left + fLabelWidth - 1.0, b.top),
|
||||
BPoint(b.left + fLabelWidth - 1.0, b.bottom), B_SOLID_HIGH);
|
||||
SetHighColor(highColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,10 +257,14 @@ PropertyItemView::UpdateObject()
|
||||
void
|
||||
PropertyItemView::_UpdateLowColor()
|
||||
{
|
||||
rgb_color lowColor = fParent ? fParent->LowColor() : kWhite;
|
||||
if (fSelected)
|
||||
lowColor = tint_color(lowColor, B_DARKEN_2_TINT);
|
||||
|
||||
rgb_color lowColor = fParent ? fParent->LowColor()
|
||||
: ui_color(B_LIST_BACKGROUND_COLOR);
|
||||
if (fSelected) {
|
||||
lowColor = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR);
|
||||
SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
|
||||
} else {
|
||||
SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||
}
|
||||
if (lowColor != LowColor()) {
|
||||
SetLowColor(lowColor);
|
||||
Invalidate();
|
||||
|
||||
@@ -102,8 +102,8 @@ PropertyListView::PropertyListView()
|
||||
fMouseWheelFilter(new MouseWheelFilter(this)),
|
||||
fTabFilter(new TabFilter(this))
|
||||
{
|
||||
SetLowColor(255, 255, 255, 255);
|
||||
SetHighColor(0, 0, 0, 255);
|
||||
SetLowColor(ui_color(B_LIST_BACKGROUND_COLOR));
|
||||
SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||
SetViewColor(B_TRANSPARENT_32_BIT);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,13 @@ IconObjectListView::Draw(BRect updateRect)
|
||||
const char* message3 = B_TRANSLATE_CONTEXT(
|
||||
"edit it's properties here.", "Empty property list - 3rd line");
|
||||
|
||||
SetHighColor(tint_color(LowColor(), B_DARKEN_2_TINT));
|
||||
// Dark Themes
|
||||
rgb_color lowColor = LowColor();
|
||||
if (lowColor.red + lowColor.green + lowColor.blue > 128 * 3)
|
||||
SetHighColor(tint_color(LowColor(), B_DARKEN_2_TINT));
|
||||
else
|
||||
SetHighColor(tint_color(LowColor(), B_LIGHTEN_2_TINT));
|
||||
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
BRect b(Bounds());
|
||||
|
||||
@@ -74,7 +74,10 @@ public:
|
||||
SimpleItem::DrawBackground(owner, itemFrame, flags);
|
||||
|
||||
// text
|
||||
owner->SetHighColor(0, 0, 0, 255);
|
||||
if (IsSelected())
|
||||
owner->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
|
||||
else
|
||||
owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||
font_height fh;
|
||||
owner->GetFontHeight(&fh);
|
||||
BString truncatedString(Text());
|
||||
@@ -93,19 +96,29 @@ public:
|
||||
|
||||
// mark
|
||||
BRect markRect = itemFrame;
|
||||
float MarkRectFillTint = B_DARKEN_1_TINT;
|
||||
float MarkRectBorderTint = 1.04;
|
||||
float MarkTint = B_DARKEN_4_TINT;
|
||||
// Dark Themes
|
||||
rgb_color lowColor = owner->LowColor();
|
||||
if (lowColor.red + lowColor.green + lowColor.blue < 128 * 3) {
|
||||
MarkRectFillTint = B_LIGHTEN_2_TINT;
|
||||
MarkRectBorderTint = 0.85;
|
||||
MarkTint = 0.1;
|
||||
}
|
||||
markRect.left += kBorderOffset;
|
||||
markRect.right = markRect.left + kMarkWidth;
|
||||
markRect.top = (markRect.top + markRect.bottom - kMarkWidth) / 2.0;
|
||||
markRect.bottom = markRect.top + kMarkWidth;
|
||||
owner->SetHighColor(tint_color(owner->LowColor(), B_DARKEN_1_TINT));
|
||||
owner->SetHighColor(tint_color(owner->LowColor(), MarkRectFillTint));
|
||||
owner->StrokeRect(markRect);
|
||||
markRect.InsetBy(1, 1);
|
||||
owner->SetHighColor(tint_color(owner->LowColor(), 1.04));
|
||||
owner->SetHighColor(tint_color(owner->LowColor(), MarkRectBorderTint));
|
||||
owner->FillRect(markRect);
|
||||
if (fMarked) {
|
||||
markRect.InsetBy(2, 2);
|
||||
owner->SetHighColor(tint_color(owner->LowColor(),
|
||||
B_DARKEN_4_TINT));
|
||||
MarkTint));
|
||||
owner->SetPenSize(2);
|
||||
owner->StrokeLine(markRect.LeftTop(), markRect.RightBottom());
|
||||
owner->StrokeLine(markRect.LeftBottom(), markRect.RightTop());
|
||||
|
||||
@@ -77,7 +77,10 @@ public:
|
||||
SimpleItem::DrawBackground(owner, itemFrame, flags);
|
||||
|
||||
// text
|
||||
owner->SetHighColor(0, 0, 0, 255);
|
||||
if (IsSelected())
|
||||
owner->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
|
||||
else
|
||||
owner->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||
font_height fh;
|
||||
owner->GetFontHeight(&fh);
|
||||
BString truncatedString(Text());
|
||||
@@ -96,19 +99,29 @@ public:
|
||||
|
||||
// mark
|
||||
BRect markRect = itemFrame;
|
||||
float MarkRectFillTint = B_DARKEN_1_TINT;
|
||||
float MarkRectBorderTint = 1.04;
|
||||
float MarkTint = B_DARKEN_4_TINT;
|
||||
// Dark Themes
|
||||
rgb_color lowColor = owner->LowColor();
|
||||
if (lowColor.red + lowColor.green + lowColor.blue < 128 * 3) {
|
||||
MarkRectFillTint = B_LIGHTEN_2_TINT;
|
||||
MarkRectBorderTint = 0.85;
|
||||
MarkTint = 0.1;
|
||||
}
|
||||
markRect.left += kBorderOffset;
|
||||
markRect.right = markRect.left + kMarkWidth;
|
||||
markRect.top = (markRect.top + markRect.bottom - kMarkWidth) / 2.0;
|
||||
markRect.bottom = markRect.top + kMarkWidth;
|
||||
owner->SetHighColor(tint_color(owner->LowColor(), B_DARKEN_1_TINT));
|
||||
owner->SetHighColor(tint_color(owner->LowColor(), MarkRectFillTint));
|
||||
owner->StrokeRect(markRect);
|
||||
markRect.InsetBy(1, 1);
|
||||
owner->SetHighColor(tint_color(owner->LowColor(), 1.04));
|
||||
owner->SetHighColor(tint_color(owner->LowColor(), MarkRectBorderTint));
|
||||
owner->FillRect(markRect);
|
||||
if (fMarked) {
|
||||
markRect.InsetBy(2, 2);
|
||||
owner->SetHighColor(tint_color(owner->LowColor(),
|
||||
B_DARKEN_4_TINT));
|
||||
MarkTint));
|
||||
owner->SetPenSize(2);
|
||||
owner->StrokeLine(markRect.LeftTop(), markRect.RightBottom());
|
||||
owner->StrokeLine(markRect.LeftBottom(), markRect.RightTop());
|
||||
|
||||
@@ -140,7 +140,13 @@ TransformerListView::Draw(BRect updateRect)
|
||||
const char* message2 = B_TRANSLATE_CONTEXT("to attach transformers.",
|
||||
"Empty transformers list - 2nd line");
|
||||
|
||||
SetHighColor(tint_color(LowColor(), B_DARKEN_2_TINT));
|
||||
// Dark Themes
|
||||
rgb_color lowColor = LowColor();
|
||||
if (lowColor.red + lowColor.green + lowColor.blue > 128 * 3)
|
||||
SetHighColor(tint_color(LowColor(), B_DARKEN_2_TINT));
|
||||
else
|
||||
SetHighColor(tint_color(LowColor(), B_LIGHTEN_2_TINT));
|
||||
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
BRect b(Bounds());
|
||||
|
||||
Reference in New Issue
Block a user