[haiku-commits] haiku: hrev45333 - src/preferences/appearance

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 3 Mar 2013 20:52:12 +0100 (CET)

hrev45333 adds 1 changeset to branch 'master'
old head: 703912cc4fd9b34b06f672df798fcebbadd609a5
new head: 97ef596f2707c3eeee881fee7f8175d6f282fbfb
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=97ef596+%5E703912c

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

97ef596: Fix color preview drawing bug in Appearance. Fixes #9501
  
  Also updated to use color constants intead of hardcoding colors. This draws a
  nice 3d-ish bevelled border around the color preview box.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

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

Revision:    hrev45333
Commit:      97ef596f2707c3eeee881fee7f8175d6f282fbfb
URL:         http://cgit.haiku-os.org/haiku/commit/?id=97ef596
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sun Mar  3 19:49:41 2013 UTC

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

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

1 file changed, 31 insertions(+), 17 deletions(-)
src/preferences/appearance/ColorPreview.cpp | 48 ++++++++++++++++---------

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

diff --git a/src/preferences/appearance/ColorPreview.cpp 
b/src/preferences/appearance/ColorPreview.cpp
index 81ce2bf..6dcbc04 100644
--- a/src/preferences/appearance/ColorPreview.cpp
+++ b/src/preferences/appearance/ColorPreview.cpp
@@ -45,25 +45,39 @@ ColorPreview::Draw(BRect update)
 
        if (is_rect) {
                if (is_enabled) {
-                       BRect r(Bounds());
-                       SetHighColor(184, 184, 184);
-                       StrokeRect(r);
+                       rgb_color background = 
ui_color(B_PANEL_BACKGROUND_COLOR);
+                       rgb_color shadow = tint_color(background, 
B_DARKEN_1_TINT);
+                       rgb_color darkShadow = tint_color(background, 
B_DARKEN_3_TINT);
+                       rgb_color light = tint_color(background, 
B_LIGHTEN_MAX_TINT);
+
+                       BRect bounds(Bounds());
+
+                       BeginLineArray(4);
+                       AddLine(BPoint(bounds.left, bounds.bottom),
+                       BPoint(bounds.left, bounds.top), shadow);
+                       AddLine(BPoint(bounds.left + 1.0, bounds.top),
+                       BPoint(bounds.right, bounds.top), shadow);
+                       AddLine(BPoint(bounds.right, bounds.top + 1.0),
+                       BPoint(bounds.right, bounds.bottom), light);
+                       AddLine(BPoint(bounds.right - 1.0, bounds.bottom),
+                       BPoint(bounds.left + 1.0, bounds.bottom), light);
+                       EndLineArray();
+                       bounds.InsetBy(1.0, 1.0);
+
+                       BeginLineArray(4);
+                       AddLine(BPoint(bounds.left, bounds.bottom),
+                       BPoint(bounds.left, bounds.top), darkShadow);
+                       AddLine(BPoint(bounds.left + 1.0, bounds.top),
+                       BPoint(bounds.right, bounds.top), darkShadow);
+                       AddLine(BPoint(bounds.right, bounds.top + 1.0),
+                       BPoint(bounds.right, bounds.bottom), background);
+                       AddLine(BPoint(bounds.right - 1.0, bounds.bottom),
+                       BPoint(bounds.left + 1.0, bounds.bottom), background);
+                       EndLineArray();
+                       bounds.InsetBy(1.0, 1.0);
 
-                       SetHighColor(255, 255, 255);
-                       StrokeLine(BPoint(r.right, r.top + 1), r.RightBottom());
-
-                       r.InsetBy(1, 1);
-
-                       SetHighColor(216, 216, 216);
-                       StrokeLine(r.RightTop(), r.RightBottom());
-
-                       SetHighColor(96, 96, 96);
-                       StrokeLine(r.LeftTop(), r.RightTop());
-                       StrokeLine(r.LeftTop(), r.LeftBottom());
-
-                       r.InsetBy(1, 1);
                        SetHighColor(color);
-                       FillRect(r);
+                       FillRect(bounds);
                } else {
                        SetHighColor(color);
                        FillRect(Bounds());


Other related posts:

  • » [haiku-commits] haiku: hrev45333 - src/preferences/appearance - jscipione