From 04f884284c433bedf44c6279c8fa82fb620c6822 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 10 Dec 2014 11:33:58 +0100 Subject: [PATCH] Colorcontrol: show resulting colors in the slider Instead of showing plain red, green and blue color ramps, show what the color would be if you moved the sliders to each point. This is what was done on Mac OS classic and is also used in some other tools to help you targetting a particular color. It also limits the need for a color preview, which BColorControl currently doesn't include, forcing apps to implement one themselves. Fixes #3790 (the patch there didn't apply anymore, so I redid the work. Credits for the change should go to stpere). --- src/kits/interface/ColorControl.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/kits/interface/ColorControl.cpp b/src/kits/interface/ColorControl.cpp index 777413f8b5..4488cecb8c 100644 --- a/src/kits/interface/ColorControl.cpp +++ b/src/kits/interface/ColorControl.cpp @@ -19,6 +19,8 @@ #include #include +#include + #include #include #include @@ -280,20 +282,8 @@ BColorControl::SetValue(int32 value) Invalidate(_PaletteSelectorFrame(fSelectedPaletteColorIndex)); fPreviousSelectedPaletteColorIndex = fSelectedPaletteColorIndex; - } else { - if (c1.red != c2.red) { - _InvalidateSelector(1, c1, IsFocus() && fFocusedRamp == 1); - _InvalidateSelector(1, c2, IsFocus() && fFocusedRamp == 1); - } - if (c1.green != c2.green) { - _InvalidateSelector(2, c1, IsFocus() && fFocusedRamp == 2); - _InvalidateSelector(2, c2, IsFocus() && fFocusedRamp == 2); - } - if (c1.blue != c2.blue) { - _InvalidateSelector(3, c1, IsFocus() && fFocusedRamp == 3); - _InvalidateSelector(3, c2, IsFocus() && fFocusedRamp == 3); - } - } + } else if (c1 != c2) + Invalidate(); // Set the value here, since BTextControl will trigger // Window()->UpdateIfNeeded() which will cause us to draw the indicators @@ -472,10 +462,11 @@ BColorControl::_DrawColorArea(BView* target, BRect updateRect) } } } else { + rgb_color color = ValueAsColor(); rgb_color white = { 255, 255, 255, 255 }; - rgb_color red = { 255, 0, 0, 255 }; - rgb_color green = { 0, 255, 0, 255 }; - rgb_color blue = { 0, 0, 255, 255 }; + rgb_color red = { 255, color.green, color.blue, 255 }; + rgb_color green = { color.red, 255, color.blue, 255 }; + rgb_color blue = { color.red, color.green, 255, 255 }; rgb_color compColor = { 0, 0, 0, 255 }; if (!enabled) {