diff --git a/headers/os/interface/ControlLook.h b/headers/os/interface/ControlLook.h index 4e6909b1d2..2727921390 100644 --- a/headers/os/interface/ControlLook.h +++ b/headers/os/interface/ControlLook.h @@ -48,6 +48,13 @@ public: | B_TOP_BORDER | B_BOTTOM_BORDER }; + enum { + B_LEFT_ARROW = 0, + B_RIGHT_ARROW = 1, + B_UP_ARROW = 2, + B_DOWN_ARROW = 3 + }; + enum { B_FOCUSED = 1 << 0, B_CLICKED = 1 << 1, // some controls activate on mouse up @@ -134,6 +141,13 @@ public: const rgb_color& base, uint32 flags, enum orientation orientation); + // TODO: Make virtual before R1 release + void DrawArrowShape(BView* view, + BRect& rect, const BRect& updateRect, + const rgb_color& base, uint32 direction, + uint32 flags = 0, + float tint = B_DARKEN_MAX_TINT); + virtual rgb_color SliderBarColor(const rgb_color& base); virtual void DrawSliderBar(BView* view, BRect rect, diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index c0e06e4f14..9d4e3f7ebb 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -686,6 +686,70 @@ BControlLook::DrawScrollBarBackground(BView* view, BRect& rect, } +void +BControlLook::DrawArrowShape(BView* view, BRect& rect, const BRect& updateRect, + const rgb_color& base, uint32 direction, uint32 flags, float tint) +{ + BPoint tri1, tri2, tri3; + float hInset = rect.Width() / 3; + float vInset = rect.Height() / 3; + rect.InsetBy(hInset, vInset); + + switch (direction) { + case B_LEFT_ARROW: + tri1.Set(rect.right, rect.top); + tri2.Set(rect.right - rect.Width() / 1.33, + (rect.top + rect.bottom + 1) /2 ); + tri3.Set(rect.right, rect.bottom + 1); + break; + case B_RIGHT_ARROW: + tri1.Set(rect.left, rect.bottom + 1); + tri2.Set(rect.left + rect.Width() / 1.33, + (rect.top + rect.bottom + 1) / 2); + tri3.Set(rect.left, rect.top); + break; + case B_UP_ARROW: + tri1.Set(rect.left, rect.bottom); + tri2.Set((rect.left + rect.right + 1) / 2, + rect.bottom - rect.Height() / 1.33); + tri3.Set(rect.right + 1, rect.bottom); + break; + case B_DOWN_ARROW: + default: + tri1.Set(rect.left, rect.top); + tri2.Set((rect.left + rect.right + 1) / 2, + rect.top + rect.Height() / 1.33); + tri3.Set(rect.right + 1, rect.top); + break; + } + // offset triangle if down + if (flags & B_ACTIVATED) + view->MovePenTo(BPoint(1, 1)); + else + view->MovePenTo(BPoint(0, 0)); + + BShape arrowShape; + arrowShape.MoveTo(tri1); + arrowShape.LineTo(tri2); + arrowShape.LineTo(tri3); + + if (flags & B_DISABLED) + tint = (tint + B_NO_TINT + B_NO_TINT) / 3; + + view->SetHighColor(tint_color(base, tint)); + + float penSize = view->PenSize(); + drawing_mode mode = view->DrawingMode(); + + view->SetPenSize(ceilf(hInset / 2.0)); + view->SetDrawingMode(B_OP_OVER); + view->StrokeShape(&arrowShape); + + view->SetPenSize(penSize); + view->SetDrawingMode(mode); +} + + rgb_color BControlLook::SliderBarColor(const rgb_color& base) {