Applied patch by Pete Goodeve (with small coding style corrections)

which fixes vertical BSliders. (ticket #7548) Thanks a bunch!
+alpha


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41881 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2011-06-03 15:39:34 +00:00
parent 9536ec0297
commit f3997b74b3
2 changed files with 52 additions and 26 deletions
+28 -12
View File
@@ -889,10 +889,11 @@ BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
leftBarSide.right = sliderPosition - 1;
rightBarSide.left = sliderPosition;
} else {
// NOTE: position is reverse of coords
sliderPosition = floorf(rect.top + 2 + (rect.Height() - 2)
* sliderScale);
leftBarSide.bottom = sliderPosition - 1;
rightBarSide.top = sliderPosition;
* (1.0 - sliderScale));
leftBarSide.top = sliderPosition;
rightBarSide.bottom = sliderPosition - 1;
}
// fill the background for the corners, exclude the middle bar for now
@@ -1223,14 +1224,23 @@ BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
float center = (rect.left + rect.right) / 2;
float centerh = (rect.left + rect.right) / 2;
float centerv = (rect.top + rect.bottom) / 2;
BShape shape;
shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5));
shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5));
shape.LineTo(BPoint(center + 0.5, rect.top + 0.5));
shape.LineTo(BPoint(rect.left + 0.5, rect.bottom - 1 + 0.5));
if (orientation == B_HORIZONTAL) {
shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5));
shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5));
shape.LineTo(BPoint(centerh + 0.5, rect.top + 0.5));
shape.LineTo(BPoint(rect.left + 0.5, rect.bottom - 1 + 0.5));
} else {
shape.MoveTo(BPoint(rect.right + 0.5, rect.top + 0.5));
shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.bottom + 0.5));
shape.LineTo(BPoint(rect.left + 0.5, centerv + 0.5));
shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.top + 0.5));
}
shape.Close();
view->MovePenTo(BPoint(1, 1));
@@ -1247,9 +1257,15 @@ BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
rect.InsetBy(1, 1);
shape.Clear();
shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
shape.LineTo(BPoint(center + 0.5, rect.top));
if (orientation == B_HORIZONTAL) {
shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
shape.LineTo(BPoint(centerh + 0.5, rect.top));
} else {
shape.MoveTo(BPoint(rect.right + 1, rect.top));
shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
shape.LineTo(BPoint(rect.left, centerv + 0.5));
}
shape.Close();
BGradientLinear gradient;
+24 -14
View File
@@ -703,16 +703,15 @@ BSlider::SetValue(int32 value)
if (fOrientation == B_HORIZONTAL)
oldThumbFrame.top = BarFrame().top;
else
oldThumbFrame.right = BarFrame().right;
oldThumbFrame.left = BarFrame().left;
BControl::SetValueNoUpdate(value);
BRect invalid = oldThumbFrame | ThumbFrame();
if (Style() == B_TRIANGLE_THUMB) {
// 1) we need to take care of pixels touched because of
// anti-aliasing
// 2) we need to update the region with the focus mark as well
// (a method BSlider::FocusMarkFrame() would be nice as well)
// 1) We need to take care of pixels touched because of anti-aliasing.
// 2) We need to update the region with the focus mark as well. (A
// method BSlider::FocusMarkFrame() would be nice as well.)
if (fOrientation == B_HORIZONTAL) {
if (IsFocus())
invalid.bottom += 2;
@@ -1445,16 +1444,27 @@ BSlider::GetPreferredSize(float* _width, float* _height)
{
BSize preferredSize = PreferredSize();
if (_width) {
// *_width = preferredSize.width;
// NOTE: For compatibility reasons, the BSlider never shrinks
// horizontally. This only affects applications which do not
// use the new layout system.
*_width = max_c(Bounds().Width(), preferredSize.width);
}
if (Orientation() == B_HORIZONTAL) {
if (_width != NULL) {
// NOTE: For compatibility reasons, a horizontal BSlider
// never shrinks horizontally. This only affects applications
// which do not use the new layout system.
*_width = max_c(Bounds().Width(), preferredSize.width);
}
if (_height)
*_height = preferredSize.height;
if (_height != NULL)
*_height = preferredSize.height;
} else {
if (_width != NULL)
*_width = preferredSize.width;
if (_height != NULL) {
// NOTE: Similarly, a vertical BSlider never shrinks
// vertically. This only affects applications which do not
// use the new layout system.
*_height = max_c(Bounds().Height(), preferredSize.height);
}
}
}