Ticket #7548: vslider.diff

File vslider.diff, 3.8 KB (added by Pete, 8 years ago)

Patch for Slider.cpp and ControlLook.cpp

  • src/kits/interface/ControlLook.cpp

     
    890890        rightBarSide.left = sliderPosition;
    891891    } else {
    892892        sliderPosition = floorf(rect.top + 2 + (rect.Height() - 2)
    893             * sliderScale);
    894         leftBarSide.bottom = sliderPosition - 1;
    895         rightBarSide.top = sliderPosition;
     893            * (1.0 - sliderScale)); // position is reverse of coords
     894        leftBarSide.top = sliderPosition;
     895        rightBarSide.bottom = sliderPosition - 1;
    896896    }
    897897
    898898    // fill the background for the corners, exclude the middle bar for now
     
    12231223    view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);
    12241224    view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
    12251225
    1226     float center = (rect.left + rect.right) / 2;
     1226    float centerh = (rect.left + rect.right) / 2;
     1227    float centerv = (rect.top + rect.bottom) / 2;
    12271228
    12281229    BShape shape;
     1230    if (orientation == B_HORIZONTAL) {
    12291231    shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5));
    12301232    shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
    12311233    shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5));
    1232     shape.LineTo(BPoint(center + 0.5, rect.top + 0.5));
     1234    shape.LineTo(BPoint(centerh + 0.5, rect.top + 0.5));
    12331235    shape.LineTo(BPoint(rect.left + 0.5, rect.bottom - 1 + 0.5));
     1236    } else {
     1237    shape.MoveTo(BPoint(rect.right + 0.5, rect.top + 0.5));
     1238    shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5));
     1239    shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.bottom + 0.5));
     1240    shape.LineTo(BPoint( rect.left + 0.5, centerv + 0.5));
     1241    shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.top + 0.5));
     1242    }
    12341243    shape.Close();
    12351244
    12361245    view->MovePenTo(BPoint(1, 1));
     
    12471256
    12481257    rect.InsetBy(1, 1);
    12491258    shape.Clear();
    1250     shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
    1251     shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
    1252     shape.LineTo(BPoint(center + 0.5, rect.top));
     1259    if (orientation == B_HORIZONTAL) {
     1260        shape.MoveTo(BPoint(rect.left, rect.bottom + 1));
     1261        shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1));
     1262        shape.LineTo(BPoint(centerh + 0.5, rect.top));
     1263    } else {
     1264        shape.MoveTo(BPoint(rect.right+1, rect.top));
     1265        shape.LineTo(BPoint(rect.right+1, rect.bottom + 1));
     1266        shape.LineTo(BPoint( rect.left, centerv + 0.5));
     1267    }
    12531268    shape.Close();
    12541269
    12551270    BGradientLinear gradient;
  • src/kits/interface/Slider.cpp

     
    703703    if (fOrientation == B_HORIZONTAL)
    704704        oldThumbFrame.top = BarFrame().top;
    705705    else
    706         oldThumbFrame.right = BarFrame().right;
     706        // Haiku triangle thumb is on the right
     707        oldThumbFrame.left = BarFrame().left;
    707708
    708709    BControl::SetValueNoUpdate(value);
    709710    BRect invalid = oldThumbFrame | ThumbFrame();
     
    14451446{
    14461447    BSize preferredSize = PreferredSize();
    14471448
    1448     if (_width) {
    1449 //      *_width = preferredSize.width;
    1450         // NOTE: For compatibility reasons, the BSlider never shrinks
    1451         // horizontally. This only affects applications which do not
    1452         // use the new layout system.
    1453         *_width = max_c(Bounds().Width(), preferredSize.width);
     1449    if (Orientation() == B_HORIZONTAL) {
     1450        if (_width) {
     1451            // NOTE: For compatibility reasons, a Horixontal BSlider
     1452            // never shrinks horizontally. This only affects applications
     1453            // which do not use the new layout system.
     1454            *_width = max_c(Bounds().Width(), preferredSize.width);
     1455        }
     1456
     1457        if (_height)
     1458            *_height = preferredSize.height;
     1459    } else {
     1460        if (_width)
     1461            *_width = preferredSize.width;
     1462
     1463        if (_height)
     1464            // Similarly, a Vertical BSlider never shrinks
     1465            // verticall. This only affects applications which do not
     1466            // use the new layout system.
     1467            *_height = max_c(Bounds().Height(), preferredSize.height);
    14541468    }
    1455 
    1456     if (_height)
    1457         *_height = preferredSize.height;
    14581469}
    14591470
    14601471