From f2da9e4e065cbf21d5715bc7e29d3bfe8849f1ff Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Mon, 2 Jan 2006 09:07:27 +0000 Subject: [PATCH] Avoid setting the value when clicked outside the color ramp area, but still inside the view's bounds. Unfortunately this also 'hides' the bug mentioned in the previous commit. Now it calls SetTracking() on mousedown/up, so that an eventual subclass can check the tracking status git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15786 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ColorControl.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/kits/interface/ColorControl.cpp b/src/kits/interface/ColorControl.cpp index a4f1b5bc84..5e341c23a0 100644 --- a/src/kits/interface/ColorControl.cpp +++ b/src/kits/interface/ColorControl.cpp @@ -530,15 +530,19 @@ void BColorControl::MouseUp(BPoint point) { fFocusedComponent = 0; + SetTracking(false); } void BColorControl::MouseDown(BPoint point) { + BRect rect(0.0f, 0.0f, fColumns * fCellSize, Bounds().bottom); + if (!rect.Contains(point)) + return; + rgb_color color = ValueAsColor(); - BRect rect(0.0f, 0.0f, fColumns * fCellSize, Bounds().bottom); float rampsize = rect.bottom / 4; uint8 shade = (unsigned char)max_c(0, @@ -561,6 +565,7 @@ BColorControl::MouseDown(BPoint point) SetValue(color); Invoke(); + SetTracking(true); MakeFocus(); SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); } @@ -570,7 +575,7 @@ void BColorControl::MouseMoved(BPoint point, uint32 transit, const BMessage *message) { - if (fFocusedComponent == 0) + if (fFocusedComponent == 0 || !IsTracking()) return; rgb_color color = ValueAsColor(); @@ -578,7 +583,7 @@ BColorControl::MouseMoved(BPoint point, uint32 transit, BRect rect(0.0f, 0.0f, fColumns * fCellSize, Bounds().bottom); uint8 shade = (unsigned char)max_c(0, - min_c((point.x - 2) * 255 / (rect.Width() - 4.0f), 255)); + min_c((point.x - 2) * 255 / (rect.Width() - 4.0f), 255)); switch (fFocusedComponent) { case 1: