diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index 6af0612928..0c13e18c2c 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -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; diff --git a/src/kits/interface/Slider.cpp b/src/kits/interface/Slider.cpp index 7c685c7602..0509f1d525 100644 --- a/src/kits/interface/Slider.cpp +++ b/src/kits/interface/Slider.cpp @@ -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); + } + } }