2 * Copyright 2007-2016 Haiku, Inc.
3 * Distributed under the terms of the MIT License.
6 * Ryan Leavengood <leavengood@gmail.com>
7 * John Scipione <jscipione@gmail.com>
8 * Joseph Groover <looncraz@looncraz.net>
9 * Brian Hill <supernova@tycho.email>
13 #include "StripeView.h"
15 #include <LayoutUtils.h>
18 static const float kTopOffset
= 10.0f
;
19 static const int kIconStripeWidth
= 30;
22 StripeView::StripeView(BBitmap
& icon
)
24 BView("StripeView", B_WILL_DRAW
),
30 SetViewUIColor(B_PANEL_BACKGROUND_COLOR
);
32 if (fIcon
.IsValid()) {
33 fIconSize
= fIcon
.Bounds().Width();
34 // Use the same scaling as a BAlert
35 int32 scale
= icon_layout_scale();
36 fPreferredWidth
= 18 * scale
+ fIcon
.Bounds().Width();
37 fPreferredHeight
= 6 * scale
+ fIcon
.Bounds().Height();
43 StripeView::Draw(BRect updateRect
)
48 SetHighColor(ViewColor());
51 BRect stripeRect
= Bounds();
52 int32 iconLayoutScale
= icon_layout_scale();
53 stripeRect
.right
= kIconStripeWidth
* iconLayoutScale
;
54 SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT
));
57 SetDrawingMode(B_OP_ALPHA
);
58 SetBlendingMode(B_PIXEL_ALPHA
, B_ALPHA_OVERLAY
);
59 DrawBitmapAsync(&fIcon
, BPoint(stripeRect
.right
- (fIconSize
/ 2.0),
60 6 * iconLayoutScale
));
65 StripeView::PreferredSize()
67 return BSize(fPreferredWidth
, B_SIZE_UNSET
);
72 StripeView::GetPreferredSize(float* _width
, float* _height
)
75 *_width
= fPreferredWidth
;
78 *_height
= fPreferredHeight
;
85 return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
86 BSize(fPreferredWidth
, B_SIZE_UNLIMITED
));