* Removed unnecessary code and simplified some places in the drawing code paths.

* Calling BTextView::SetText() will invoke Window()->UpdateIfNeeded(), maybe
  since some recent changes only - we should perhaps look into this... (zooey),
  but the problem was that we called BControl::SetValueNoUpdate() after that,
  and thus we were drawing the color mark at the old offset and the invalidation
  in SetValue() was rendered effectless. Fixes #3719.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30784 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-05-18 00:20:07 +00:00
parent fa0fea5f25
commit 2627bad195
+14 -29
View File
@@ -246,7 +246,6 @@ BColorControl::SetValue(int32 value)
c2.green = (value & 0x00FF0000) >> 16; c2.green = (value & 0x00FF0000) >> 16;
c2.blue = (value & 0x0000FF00) >> 8; c2.blue = (value & 0x0000FF00) >> 8;
c2.alpha = 255; c2.alpha = 255;
char string[4];
if (fPaletteMode) { if (fPaletteMode) {
//workaround when two indexes have the same color //workaround when two indexes have the same color
@@ -296,25 +295,22 @@ BColorControl::SetValue(int32 value)
} }
} }
// Set the value here, since BTextControl will trigger
// Window()->UpdateIfNeeded() which will cause us to draw the indicators
// at the old offset.
if (Value() != value)
BControl::SetValueNoUpdate(value);
// the textcontrols have to be updated even when the color // the textcontrols have to be updated even when the color
// hasn't changed since the value is clamped upstream // hasn't changed since the value is clamped upstream
// and the textcontrols would still show the unclamped value // and the textcontrols would still show the unclamped value
char string[4];
sprintf(string, "%d", c2.red); sprintf(string, "%d", c2.red);
fRedText->SetText(string); fRedText->SetText(string);
sprintf(string, "%d", c2.green); sprintf(string, "%d", c2.green);
fGreenText->SetText(string); fGreenText->SetText(string);
sprintf(string, "%d", c2.blue); sprintf(string, "%d", c2.blue);
fBlueText->SetText(string); fBlueText->SetText(string);
if (Value() == value)
return;
BControl::SetValueNoUpdate(value);
if (LockLooper()) {
Window()->UpdateIfNeeded();
UnlockLooper();
}
} }
@@ -369,6 +365,7 @@ BColorControl::MessageReceived(BMessage *message)
switch (message->what) { switch (message->what) {
case kMsgColorEntered: case kMsgColorEntered:
{ {
printf("kMsgColorEntered\n");
rgb_color color; rgb_color color;
color.red = min_c(strtol(fRedText->Text(), NULL, 10), 255); color.red = min_c(strtol(fRedText->Text(), NULL, 10), 255);
color.green = min_c(strtol(fGreenText->Text(), NULL, 10), 255); color.green = min_c(strtol(fGreenText->Text(), NULL, 10), 255);
@@ -388,29 +385,17 @@ BColorControl::MessageReceived(BMessage *message)
void void
BColorControl::Draw(BRect updateRect) BColorControl::Draw(BRect updateRect)
{ {
if (fBitmap) { if (fBitmap)
if (!fBitmap->Lock())
return;
if (fOffscreenView->Bounds().Intersects(updateRect))
DrawBitmap(fBitmap, B_ORIGIN); DrawBitmap(fBitmap, B_ORIGIN);
else
fBitmap->Unlock();
_DrawSelectors(this);
} else {
_DrawColorArea(this, updateRect); _DrawColorArea(this, updateRect);
_DrawSelectors(this); _DrawSelectors(this);
} }
}
void void
BColorControl::_DrawColorArea(BView* target, BRect update) BColorControl::_DrawColorArea(BView* target, BRect update)
{ {
BRegion region(update);
target->ConstrainClippingRegion(&region);
BRect bevelRect = fPaletteFrame.InsetByCopy(-2.0,-2.0); //bevel BRect bevelRect = fPaletteFrame.InsetByCopy(-2.0,-2.0); //bevel
bool enabled = IsEnabled(); bool enabled = IsEnabled();
@@ -509,8 +494,6 @@ BColorControl::_DrawColorArea(BView* target, BRect update)
_ColorRamp(_RampFrame(2), target, green, compColor, 0, false, update); _ColorRamp(_RampFrame(2), target, green, compColor, 0, false, update);
_ColorRamp(_RampFrame(3), target, blue, compColor, 0, false, update); _ColorRamp(_RampFrame(3), target, blue, compColor, 0, false, update);
} }
target->ConstrainClippingRegion(NULL);
} }
@@ -711,6 +694,8 @@ BColorControl::MouseDown(BPoint point)
if (!fPaletteFrame.Contains(point)) if (!fPaletteFrame.Contains(point))
return; return;
MakeFocus();
if (fPaletteMode) { if (fPaletteMode) {
int column = (int) ( (point.x - fPaletteFrame.left) / fCellSize ); int column = (int) ( (point.x - fPaletteFrame.left) / fCellSize );
int row = (int) ( (point.y - fPaletteFrame.top) / fCellSize ); int row = (int) ( (point.y - fPaletteFrame.top) / fCellSize );
@@ -723,7 +708,8 @@ BColorControl::MouseDown(BPoint point)
rgb_color color = ValueAsColor(); rgb_color color = ValueAsColor();
uint8 shade = (unsigned char)max_c(0, uint8 shade = (unsigned char)max_c(0,
min_c((point.x - _RampFrame(0).left) * 255 / _RampFrame(0).Width(), 255)); min_c((point.x - _RampFrame(0).left) * 255 / _RampFrame(0).Width(),
255));
if (_RampFrame(0).Contains(point)) { if (_RampFrame(0).Contains(point)) {
color.red = color.green = color.blue = shade; color.red = color.green = color.blue = shade;
@@ -746,7 +732,6 @@ BColorControl::MouseDown(BPoint point)
Invoke(); Invoke();
SetTracking(true); SetTracking(true);
MakeFocus();
SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY|B_LOCK_WINDOW_FOCUS); SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY|B_LOCK_WINDOW_FOCUS);
} }