BAlert: Make use of the new BControlLook::ComposeIconSize().
While we're at it, also use DefaultLabelSpacing instead of the icon size scaling factor.
This commit is contained in:
@@ -84,20 +84,12 @@ static const int kSemTimeOut = 50000;
|
||||
|
||||
static const int kButtonOffsetSpacing = 62;
|
||||
static const int kButtonUsualWidth = 55;
|
||||
static const int kIconStripeWidth = 30;
|
||||
static const int kIconStripeWidthFactor = 5;
|
||||
|
||||
static const int kWindowMinWidth = 310;
|
||||
static const int kWindowOffsetMinWidth = 335;
|
||||
|
||||
|
||||
static inline float
|
||||
icon_layout_scale()
|
||||
{
|
||||
float scale = be_plain_font->Size() / 12;
|
||||
return max_c(1, scale);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
@@ -585,9 +577,8 @@ BAlert::_CreateTypeIcon()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32 iconSize = (int32)(32 * icon_layout_scale());
|
||||
// Allocate the icon bitmap
|
||||
icon = new(std::nothrow) BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1),
|
||||
icon = new(std::nothrow) BBitmap(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(32)),
|
||||
0, B_RGBA32);
|
||||
if (icon == NULL || icon->InitCheck() < B_OK) {
|
||||
FTRACE((stderr, "BAlert::_CreateTypeIcon() - No memory for bitmap\n"));
|
||||
@@ -618,8 +609,8 @@ BAlert::_CreateTypeIcon()
|
||||
|
||||
// Handle color space conversion
|
||||
if (icon->ColorSpace() != B_CMAP8) {
|
||||
BIconUtils::ConvertFromCMAP8(rawIcon, iconSize, iconSize,
|
||||
iconSize, icon);
|
||||
BIconUtils::ConvertFromCMAP8(rawIcon, B_LARGE_ICON, B_LARGE_ICON,
|
||||
B_LARGE_ICON, icon);
|
||||
}
|
||||
|
||||
return icon;
|
||||
@@ -757,19 +748,21 @@ TAlertView::Archive(BMessage* archive, bool deep) const
|
||||
void
|
||||
TAlertView::GetPreferredSize(float* _width, float* _height)
|
||||
{
|
||||
float scale = icon_layout_scale();
|
||||
|
||||
if (_width != NULL) {
|
||||
if (fIconBitmap != NULL)
|
||||
*_width = 18 * scale + fIconBitmap->Bounds().Width();
|
||||
else
|
||||
if (fIconBitmap != NULL) {
|
||||
*_width = (be_control_look->DefaultLabelSpacing() * 2)
|
||||
+ fIconBitmap->Bounds().Width();
|
||||
} else {
|
||||
*_width = 0;
|
||||
}
|
||||
}
|
||||
if (_height != NULL) {
|
||||
if (fIconBitmap != NULL)
|
||||
*_height = 6 * scale + fIconBitmap->Bounds().Height();
|
||||
else
|
||||
if (fIconBitmap != NULL) {
|
||||
*_height = be_control_look->DefaultLabelSpacing()
|
||||
+ fIconBitmap->Bounds().Height();
|
||||
} else {
|
||||
*_height = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,15 +782,14 @@ TAlertView::Draw(BRect updateRect)
|
||||
|
||||
// Here's the fun stuff
|
||||
BRect stripeRect = Bounds();
|
||||
float iconLayoutScale = icon_layout_scale();
|
||||
stripeRect.right = kIconStripeWidth * iconLayoutScale;
|
||||
stripeRect.right = kIconStripeWidthFactor * be_control_look->DefaultLabelSpacing();
|
||||
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||
FillRect(stripeRect);
|
||||
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||
DrawBitmapAsync(fIconBitmap, BPoint(18 * iconLayoutScale,
|
||||
6 * iconLayoutScale));
|
||||
DrawBitmapAsync(fIconBitmap, BPoint(be_control_look->DefaultLabelSpacing() * 3,
|
||||
be_control_look->DefaultLabelSpacing()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user