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).
This commit is contained in:
Adrien Destugues 2014-12-10 11:33:58 +01:00
parent d18ae0336e
commit 04f884284c

View File

@ -19,6 +19,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <ControlLook.h>
#include <Bitmap.h>
#include <TextControl.h>
@ -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) {