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:
@@ -889,10 +889,11 @@ BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
|
|||||||
leftBarSide.right = sliderPosition - 1;
|
leftBarSide.right = sliderPosition - 1;
|
||||||
rightBarSide.left = sliderPosition;
|
rightBarSide.left = sliderPosition;
|
||||||
} else {
|
} else {
|
||||||
|
// NOTE: position is reverse of coords
|
||||||
sliderPosition = floorf(rect.top + 2 + (rect.Height() - 2)
|
sliderPosition = floorf(rect.top + 2 + (rect.Height() - 2)
|
||||||
* sliderScale);
|
* (1.0 - sliderScale));
|
||||||
leftBarSide.bottom = sliderPosition - 1;
|
leftBarSide.top = sliderPosition;
|
||||||
rightBarSide.top = sliderPosition;
|
rightBarSide.bottom = sliderPosition - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill the background for the corners, exclude the middle bar for now
|
// 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->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
|
||||||
view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
|
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;
|
BShape shape;
|
||||||
shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5));
|
if (orientation == B_HORIZONTAL) {
|
||||||
shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
|
shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5));
|
||||||
shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5));
|
shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
|
||||||
shape.LineTo(BPoint(center + 0.5, rect.top + 0.5));
|
shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5));
|
||||||
shape.LineTo(BPoint(rect.left + 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();
|
shape.Close();
|
||||||
|
|
||||||
view->MovePenTo(BPoint(1, 1));
|
view->MovePenTo(BPoint(1, 1));
|
||||||
@@ -1247,9 +1257,15 @@ BControlLook::DrawSliderTriangle(BView* view, BRect& rect,
|
|||||||
|
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
shape.Clear();
|
shape.Clear();
|
||||||
shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
|
if (orientation == B_HORIZONTAL) {
|
||||||
shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
|
shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
|
||||||
shape.LineTo(BPoint(center + 0.5, rect.top));
|
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();
|
shape.Close();
|
||||||
|
|
||||||
BGradientLinear gradient;
|
BGradientLinear gradient;
|
||||||
|
|||||||
@@ -703,16 +703,15 @@ BSlider::SetValue(int32 value)
|
|||||||
if (fOrientation == B_HORIZONTAL)
|
if (fOrientation == B_HORIZONTAL)
|
||||||
oldThumbFrame.top = BarFrame().top;
|
oldThumbFrame.top = BarFrame().top;
|
||||||
else
|
else
|
||||||
oldThumbFrame.right = BarFrame().right;
|
oldThumbFrame.left = BarFrame().left;
|
||||||
|
|
||||||
BControl::SetValueNoUpdate(value);
|
BControl::SetValueNoUpdate(value);
|
||||||
BRect invalid = oldThumbFrame | ThumbFrame();
|
BRect invalid = oldThumbFrame | ThumbFrame();
|
||||||
|
|
||||||
if (Style() == B_TRIANGLE_THUMB) {
|
if (Style() == B_TRIANGLE_THUMB) {
|
||||||
// 1) we need to take care of pixels touched because of
|
// 1) We need to take care of pixels touched because of anti-aliasing.
|
||||||
// anti-aliasing
|
// 2) We need to update the region with the focus mark as well. (A
|
||||||
// 2) we need to update the region with the focus mark as well
|
// method BSlider::FocusMarkFrame() would be nice as well.)
|
||||||
// (a method BSlider::FocusMarkFrame() would be nice as well)
|
|
||||||
if (fOrientation == B_HORIZONTAL) {
|
if (fOrientation == B_HORIZONTAL) {
|
||||||
if (IsFocus())
|
if (IsFocus())
|
||||||
invalid.bottom += 2;
|
invalid.bottom += 2;
|
||||||
@@ -1445,16 +1444,27 @@ BSlider::GetPreferredSize(float* _width, float* _height)
|
|||||||
{
|
{
|
||||||
BSize preferredSize = PreferredSize();
|
BSize preferredSize = PreferredSize();
|
||||||
|
|
||||||
if (_width) {
|
if (Orientation() == B_HORIZONTAL) {
|
||||||
// *_width = preferredSize.width;
|
if (_width != NULL) {
|
||||||
// NOTE: For compatibility reasons, the BSlider never shrinks
|
// NOTE: For compatibility reasons, a horizontal BSlider
|
||||||
// horizontally. This only affects applications which do not
|
// never shrinks horizontally. This only affects applications
|
||||||
// use the new layout system.
|
// which do not use the new layout system.
|
||||||
*_width = max_c(Bounds().Width(), preferredSize.width);
|
*_width = max_c(Bounds().Width(), preferredSize.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_height)
|
if (_height != NULL)
|
||||||
*_height = preferredSize.height;
|
*_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user