From 264767162c0332e0c56922ab00554fdbf89472bf Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Mon, 2 Jan 2006 08:16:22 +0000 Subject: [PATCH] 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 --- src/kits/interface/ColorControl.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/kits/interface/ColorControl.cpp b/src/kits/interface/ColorControl.cpp index d7f1aa53d4..a4f1b5bc84 100644 --- a/src/kits/interface/ColorControl.cpp +++ b/src/kits/interface/ColorControl.cpp @@ -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(®ion); + DrawBitmap(fBitmap, B_ORIGIN); + ConstrainClippingRegion(NULL); } fBitmap->Unlock(); @@ -566,7 +572,7 @@ BColorControl::MouseMoved(BPoint point, uint32 transit, { if (fFocusedComponent == 0) return; - + rgb_color color = ValueAsColor(); BRect rect(0.0f, 0.0f, fColumns * fCellSize, Bounds().bottom);