Avoid setting the value if it's the same as the current one. Sometimes the bitmap was drawn at the wrong position. BTW looks like sometimes the event mask set with SetMouseEventMask() isn't resetted when a MouseUp occurs. In fact, sometimes when I click on the window decorator (in Backgrounds), I still get MouseUp/Down event for the ColorControl

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15785 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-01-02 08:16:22 +00:00
parent 8e34360a9c
commit 264767162c

View File

@ -202,13 +202,16 @@ BColorControl::Archive(BMessage *archive, bool deep) const
void
BColorControl::SetValue(int32 color)
BColorControl::SetValue(int32 value)
{
if (Value() == value)
return;
rgb_color c1 = ValueAsColor();
rgb_color c2;
c2.red = (color & 0xFF000000) >> 24;
c2.green = (color & 0x00FF0000) >> 16;
c2.blue = (color & 0x0000FF00) >> 8;
c2.red = (value & 0xFF000000) >> 24;
c2.green = (value & 0x00FF0000) >> 16;
c2.blue = (value & 0x0000FF00) >> 8;
char string[4];
if (c1.red != c2.red) {
@ -226,6 +229,8 @@ BColorControl::SetValue(int32 color)
fBlueText->SetText(string);
}
BControl::SetValue(value);
// TODO: This causes lot of flickering
Invalidate();
@ -233,8 +238,6 @@ BColorControl::SetValue(int32 color)
Window()->UpdateIfNeeded();
UnlockLooper();
}
BControl::SetValue(color);
}
@ -311,7 +314,10 @@ BColorControl::Draw(BRect updateRect)
if (fOffscreenView->Bounds().Intersects(updateRect)) {
_UpdateOffscreen(updateRect);
DrawBitmap(fBitmap, updateRect.LeftTop());
BRegion region(updateRect);
ConstrainClippingRegion(&region);
DrawBitmap(fBitmap, B_ORIGIN);
ConstrainClippingRegion(NULL);
}
fBitmap->Unlock();