From bf41a1c034fda4d1566dcee0ecad472ab1654392 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 29 Dec 2007 15:26:37 +0000 Subject: [PATCH] Patch by cl21 (I really hope this isn't your real name :P ) which fixes the BColorControl flickering reported in bug #503. Thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23192 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ColorControl.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/ColorControl.cpp b/src/kits/interface/ColorControl.cpp index 762dc821c6..3758ce09b3 100644 --- a/src/kits/interface/ColorControl.cpp +++ b/src/kits/interface/ColorControl.cpp @@ -222,26 +222,46 @@ BColorControl::SetValue(int32 value) c2.blue = (value & 0x0000FF00) >> 8; char string[4]; + // values for calculating the selector rectangles for invalidation + // analogous to selector drawing in _DrawColorArea + float rampXGradient = (ceil(fColumns * fCellSize) - 4 - 7) / 255; + float rampSize = (Bounds().bottom - 2) / 4.0; + float x, y; + if (c1.red != c2.red) { sprintf(string, "%d", c2.red); fRedText->SetText(string); + + y = rampSize * 1.5; + x = 2 + c1.red * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); + x = 2 + c2.red * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); } if (c1.green != c2.green) { sprintf(string, "%d", c2.green); fGreenText->SetText(string); - } + y = rampSize * 2.5; + x = 2 + c1.green * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); + x = 2 + c2.green * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); + } if (c1.blue != c2.blue) { sprintf(string, "%d", c2.blue); fBlueText->SetText(string); + + y = rampSize * 3.5; + x = 2 + c1.blue * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); + x = 2 + c2.blue * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); } BControl::SetValueNoUpdate(value); - // TODO: This causes lot of flickering - Invalidate(); - if (LockLooper()) { Window()->UpdateIfNeeded(); UnlockLooper();