From 97ef596f2707c3eeee881fee7f8175d6f282fbfb Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sun, 3 Mar 2013 14:49:41 -0500 Subject: [PATCH] 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. --- src/preferences/appearance/ColorPreview.cpp | 42 ++++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/preferences/appearance/ColorPreview.cpp b/src/preferences/appearance/ColorPreview.cpp index 81ce2bf201..6dcbc04e37 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); - SetHighColor(255, 255, 255); - StrokeLine(BPoint(r.right, r.top + 1), r.RightBottom()); + BRect bounds(Bounds()); - r.InsetBy(1, 1); + 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); - SetHighColor(216, 216, 216); - StrokeLine(r.RightTop(), r.RightBottom()); + 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(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());