* clamps the textcontrol input to 255
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25013 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
74158bb474
commit
e8fa461ae7
@ -236,9 +236,6 @@ BColorControl::SetLayout(BLayout* layout)
|
|||||||
void
|
void
|
||||||
BColorControl::SetValue(int32 value)
|
BColorControl::SetValue(int32 value)
|
||||||
{
|
{
|
||||||
if (Value() == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
rgb_color c1 = ValueAsColor();
|
rgb_color c1 = ValueAsColor();
|
||||||
rgb_color c2;
|
rgb_color c2;
|
||||||
c2.red = (value & 0xFF000000) >> 24;
|
c2.red = (value & 0xFF000000) >> 24;
|
||||||
@ -258,13 +255,6 @@ BColorControl::SetValue(int32 value)
|
|||||||
|
|
||||||
c2 = BScreen(Window()).ColorForIndex(fSelectedPaletteColorIndex);
|
c2 = BScreen(Window()).ColorForIndex(fSelectedPaletteColorIndex);
|
||||||
|
|
||||||
sprintf(string, "%d", c2.red);
|
|
||||||
fRedText->SetText(string);
|
|
||||||
sprintf(string, "%d", c2.green);
|
|
||||||
fGreenText->SetText(string);
|
|
||||||
sprintf(string, "%d", c2.blue);
|
|
||||||
fBlueText->SetText(string);
|
|
||||||
|
|
||||||
Invalidate(_PaletteSelectorFrame(fPreviousSelectedPaletteColorIndex));
|
Invalidate(_PaletteSelectorFrame(fPreviousSelectedPaletteColorIndex));
|
||||||
Invalidate(_PaletteSelectorFrame(fSelectedPaletteColorIndex));
|
Invalidate(_PaletteSelectorFrame(fSelectedPaletteColorIndex));
|
||||||
|
|
||||||
@ -274,9 +264,6 @@ BColorControl::SetValue(int32 value)
|
|||||||
BPoint p;
|
BPoint p;
|
||||||
|
|
||||||
if (c1.red != c2.red) {
|
if (c1.red != c2.red) {
|
||||||
sprintf(string, "%d", c2.red);
|
|
||||||
fRedText->SetText(string);
|
|
||||||
|
|
||||||
p = _SelectorPosition(_RampFrame(1), c1.red);
|
p = _SelectorPosition(_RampFrame(1), c1.red);
|
||||||
Invalidate(BRect(p.x - invalidateRadius, p.y - invalidateRadius,
|
Invalidate(BRect(p.x - invalidateRadius, p.y - invalidateRadius,
|
||||||
p.x + invalidateRadius, p.y + invalidateRadius));
|
p.x + invalidateRadius, p.y + invalidateRadius));
|
||||||
@ -285,11 +272,7 @@ BColorControl::SetValue(int32 value)
|
|||||||
Invalidate(BRect(p.x - invalidateRadius, p.y - invalidateRadius,
|
Invalidate(BRect(p.x - invalidateRadius, p.y - invalidateRadius,
|
||||||
p.x + invalidateRadius, p.y + invalidateRadius));
|
p.x + invalidateRadius, p.y + invalidateRadius));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c1.green != c2.green) {
|
if (c1.green != c2.green) {
|
||||||
sprintf(string, "%d", c2.green);
|
|
||||||
fGreenText->SetText(string);
|
|
||||||
|
|
||||||
p = _SelectorPosition(_RampFrame(2), c1.green);
|
p = _SelectorPosition(_RampFrame(2), c1.green);
|
||||||
Invalidate(BRect(p.x - invalidateRadius, p.y - invalidateRadius,
|
Invalidate(BRect(p.x - invalidateRadius, p.y - invalidateRadius,
|
||||||
p.x + invalidateRadius, p.y + invalidateRadius));
|
p.x + invalidateRadius, p.y + invalidateRadius));
|
||||||
@ -299,9 +282,6 @@ BColorControl::SetValue(int32 value)
|
|||||||
p.x + invalidateRadius, p.y + invalidateRadius));
|
p.x + invalidateRadius, p.y + invalidateRadius));
|
||||||
}
|
}
|
||||||
if (c1.blue != c2.blue) {
|
if (c1.blue != c2.blue) {
|
||||||
sprintf(string, "%d", c2.blue);
|
|
||||||
fBlueText->SetText(string);
|
|
||||||
|
|
||||||
p = _SelectorPosition(_RampFrame(3), c1.blue);
|
p = _SelectorPosition(_RampFrame(3), c1.blue);
|
||||||
Invalidate(BRect(p.x - invalidateRadius, p.y - invalidateRadius,
|
Invalidate(BRect(p.x - invalidateRadius, p.y - invalidateRadius,
|
||||||
p.x + invalidateRadius, p.y + invalidateRadius));
|
p.x + invalidateRadius, p.y + invalidateRadius));
|
||||||
@ -312,6 +292,19 @@ BColorControl::SetValue(int32 value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the textcontrols have to be updated even when the color
|
||||||
|
// hasn't changed since the value is clamped upstream
|
||||||
|
// and the textcontrols would still show the unclamped value
|
||||||
|
sprintf(string, "%d", c2.red);
|
||||||
|
fRedText->SetText(string);
|
||||||
|
sprintf(string, "%d", c2.green);
|
||||||
|
fGreenText->SetText(string);
|
||||||
|
sprintf(string, "%d", c2.blue);
|
||||||
|
fBlueText->SetText(string);
|
||||||
|
|
||||||
|
if (Value() == value)
|
||||||
|
return;
|
||||||
|
|
||||||
BControl::SetValueNoUpdate(value);
|
BControl::SetValueNoUpdate(value);
|
||||||
|
|
||||||
if (LockLooper()) {
|
if (LockLooper()) {
|
||||||
@ -373,14 +366,11 @@ BColorControl::MessageReceived(BMessage *message)
|
|||||||
case kMsgColorEntered:
|
case kMsgColorEntered:
|
||||||
{
|
{
|
||||||
rgb_color color;
|
rgb_color color;
|
||||||
color.red = /*min_c(*/strtol(fRedText->Text(), NULL, 10), 255/*)*/;
|
color.red = min_c(strtol(fRedText->Text(), NULL, 10), 255);
|
||||||
color.green = /*min_c(*/strtol(fGreenText->Text(), NULL, 10), 255/*)*/;
|
color.green = min_c(strtol(fGreenText->Text(), NULL, 10), 255);
|
||||||
color.blue = /*min_c(*/strtol(fBlueText->Text(), NULL, 10), 255/*)*/;
|
color.blue = min_c(strtol(fBlueText->Text(), NULL, 10), 255);
|
||||||
color.alpha = 255;
|
color.alpha = 255;
|
||||||
|
|
||||||
//TODO: text is not updated if the clamping
|
|
||||||
// gives the same value next time
|
|
||||||
|
|
||||||
SetValue(color);
|
SetValue(color);
|
||||||
Invoke();
|
Invoke();
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user