[haiku-commits] haiku: hrev49256 - in src/apps/icon-o-matic: gui generic/property/view generic/gui

  • From: janus2@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 9 Jun 2015 16:06:41 +0200 (CEST)

hrev49256 adds 1 changeset to branch 'master'
old head: 433838de9a4ba31d28ee952c578fd255eb3eda15
new head: 14f0e6d73d4ee697753149a03ebb0dff13bc0cc5
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=14f0e6d73d4e+%5E433838de9a4b

----------------------------------------------------------------------------

14f0e6d73d4e: Icon-o-Matic: list views use system colors

* Fixes #10840.
* Properties view needs more work for dark themes
(There is another ticket for that).

[ Janus <janus2@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision: hrev49256
Commit: 14f0e6d73d4ee697753149a03ebb0dff13bc0cc5
URL: http://cgit.haiku-os.org/haiku/commit/?id=14f0e6d73d4e
Author: Janus <janus2@xxxxxxxxx>
Date: Tue Jun 9 14:00:24 2015 UTC

Ticket: https://dev.haiku-os.org/ticket/10840

----------------------------------------------------------------------------

7 files changed, 88 insertions(+), 29 deletions(-)
src/apps/icon-o-matic/generic/gui/ListViews.cpp | 19 +++++++----
.../generic/property/view/PropertyItemView.cpp | 36 ++++++++++++++------
.../generic/property/view/PropertyListView.cpp | 4 +--
src/apps/icon-o-matic/gui/IconObjectListView.cpp | 8 ++++-
src/apps/icon-o-matic/gui/PathListView.cpp | 21 +++++++++---
src/apps/icon-o-matic/gui/StyleListView.cpp | 21 +++++++++---
.../icon-o-matic/gui/TransformerListView.cpp | 8 ++++-

----------------------------------------------------------------------------

diff --git a/src/apps/icon-o-matic/generic/gui/ListViews.cpp
b/src/apps/icon-o-matic/generic/gui/ListViews.cpp
index 70f6650..7eafc67 100644
--- a/src/apps/icon-o-matic/generic/gui/ListViews.cpp
+++ b/src/apps/icon-o-matic/generic/gui/ListViews.cpp
@@ -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
diff --git a/src/apps/icon-o-matic/generic/property/view/PropertyItemView.cpp
b/src/apps/icon-o-matic/generic/property/view/PropertyItemView.cpp
index 5f92776..2014ec6 100644
--- a/src/apps/icon-o-matic/generic/property/view/PropertyItemView.cpp
+++ b/src/apps/icon-o-matic/generic/property/view/PropertyItemView.cpp
@@ -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();
diff --git a/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp
b/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp
index 8550dc9..61ada6a 100644
--- a/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp
+++ b/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp
@@ -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);
}

diff --git a/src/apps/icon-o-matic/gui/IconObjectListView.cpp
b/src/apps/icon-o-matic/gui/IconObjectListView.cpp
index 09ef633..7c2ee4b 100644
--- a/src/apps/icon-o-matic/gui/IconObjectListView.cpp
+++ b/src/apps/icon-o-matic/gui/IconObjectListView.cpp
@@ -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());
diff --git a/src/apps/icon-o-matic/gui/PathListView.cpp
b/src/apps/icon-o-matic/gui/PathListView.cpp
index 61a3d27..41a52ce 100644
--- a/src/apps/icon-o-matic/gui/PathListView.cpp
+++ b/src/apps/icon-o-matic/gui/PathListView.cpp
@@ -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());
diff --git a/src/apps/icon-o-matic/gui/StyleListView.cpp
b/src/apps/icon-o-matic/gui/StyleListView.cpp
index a5a49d8..c3986a5 100644
--- a/src/apps/icon-o-matic/gui/StyleListView.cpp
+++ b/src/apps/icon-o-matic/gui/StyleListView.cpp
@@ -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());
diff --git a/src/apps/icon-o-matic/gui/TransformerListView.cpp
b/src/apps/icon-o-matic/gui/TransformerListView.cpp
index cf5b3a1..22c5adb 100644
--- a/src/apps/icon-o-matic/gui/TransformerListView.cpp
+++ b/src/apps/icon-o-matic/gui/TransformerListView.cpp
@@ -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());


Other related posts:

  • » [haiku-commits] haiku: hrev49256 - in src/apps/icon-o-matic: gui generic/property/view generic/gui - janus2