Fixed the remaining drawing bugs the test app revealed.

The block thumb frame is now left out when the bar background is filled
which reduces flicker.
Also, the background fill draw over the region occupied with the border
lines which also caused flicker.
The border lines still draw over the thumb area, and thus, may cause
noticeable flicker there when moving it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13345 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-06-29 13:03:58 +00:00
parent 09196077b8
commit 7af7a22216
1 changed files with 36 additions and 35 deletions

View File

@ -673,7 +673,10 @@ BSlider::Draw(BRect updateRect)
// clear out background
BRegion background(updateRect);
background.Exclude(BarFrame());
background.Exclude(ThumbFrame());
// ToDo: the thumb doesn't delete its background, so we still have to do it
//background.Exclude(ThumbFrame());
if (background.Frame().IsValid())
OffscreenView()->FillRegion(&background, B_SOLID_LOW);
@ -744,33 +747,43 @@ BSlider::DrawBar()
fillColor.green = (fFillColor.green + no_tint.green) / 2;
fillColor.blue = (fFillColor.blue + no_tint.blue) / 2;
}
if (fUseFillColor) {
// exclude the block thumb from the bar filling
BRect lowerFrame = frame.InsetByCopy(1, 1);
BRect upperFrame = lowerFrame;
if (Style() == B_BLOCK_THUMB) {
BRect thumbFrame = ThumbFrame();
if (fOrientation == B_HORIZONTAL) {
view->SetHighColor(barColor);
view->FillRect(BRect((float)floor(frame.left + 1 + Position() *
(frame.Width() - 2)), frame.top, frame.right, frame.bottom));
view->SetHighColor(fillColor);
view->FillRect(BRect(frame.left, frame.top,
(float)floor(frame.left + 1 + Position() * (frame.Width() - 2)),
frame.bottom));
lowerFrame.right = thumbFrame.left;
upperFrame.left = thumbFrame.right;
} else {
view->SetHighColor(barColor);
view->FillRect(BRect(frame.left, frame.top, frame.right,
(float)floor(frame.bottom - 1 - Position() * (frame.Height() - 2))));
view->SetHighColor(fillColor);
view->FillRect(BRect(frame.left,
(float)floor(frame.bottom - 1 - Position() *
(frame.Height() - 2)), frame.right, frame.bottom));
lowerFrame.top = thumbFrame.bottom;
upperFrame.bottom = thumbFrame.top;
}
} else if (fUseFillColor) {
if (fOrientation == B_HORIZONTAL) {
lowerFrame.right = floor(lowerFrame.left + Position() * lowerFrame.Width());
upperFrame.left = lowerFrame.right;
} else {
lowerFrame.top = floor(lowerFrame.bottom - Position() * lowerFrame.Height());
upperFrame.bottom = lowerFrame.top;
}
} else {
view->SetHighColor(barColor);
view->FillRect(frame);
}
view->SetHighColor(barColor);
view->FillRect(upperFrame);
if (Style() == B_BLOCK_THUMB || fUseFillColor) {
if (fUseFillColor)
view->SetHighColor(fillColor);
view->FillRect(lowerFrame);
}
// ToDo: don't stroke the lines over the thumb
view->SetHighColor(darken1);
view->StrokeLine(BPoint(frame.left, frame.top),
BPoint(frame.left + 1.0f, frame.top));
@ -852,17 +865,6 @@ BSlider::DrawHashMarks()
pos = _MinPosition();
if (fHashMarks & B_HASH_MARKS_BOTTOM) {
#if !USE_OFF_SCREEN_VIEW
if (Style() == B_TRIANGLE_THUMB) {
// ToDo: this is a temporary workaround to clean out some drawing
// left-overs when moving the thumb around - might flicker, so we
// should do it differently
BRect rect = frame;
rect.top = frame.bottom - 5;
FillRect(rect, B_SOLID_LOW);
}
#endif
view->BeginLineArray(fHashMarkCount * 2);
if (fOrientation == B_HORIZONTAL) {
@ -925,7 +927,6 @@ BSlider::DrawFocusMark()
BPoint(frame.left - 2.0f, frame.bottom));
}
}
}