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
This commit is contained in:
Stefano Ceccherini 2006-01-02 09:07:27 +00:00
parent 264767162c
commit f2da9e4e06
1 changed files with 8 additions and 3 deletions

View File

@ -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: