Added method to draw an arrow shape like that of the BScrollBar.
TODO: Adjust BScrollBar to use it. TODO: Make it virtual like the others, but I don't want to break Vision and other native Haiku apps just now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29630 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
49c80ab55d
commit
40a10e1c52
@ -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,
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user