Some tweakings to the notificationsystem to make it look more like a regular alert.
Feel free to improve on it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42586 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -58,14 +58,15 @@ AppGroupView::Draw(BRect updateRect)
|
||||
be_bold_font->GetHeight(&fh);
|
||||
float labelOffset = fh.ascent + fh.leading;
|
||||
|
||||
BRect borderRect = Bounds().InsetByCopy(kEdgePadding, kEdgePadding);
|
||||
borderRect.top = labelOffset;
|
||||
|
||||
BRect textRect = borderRect;
|
||||
textRect.left = kEdgePadding * 2;
|
||||
textRect.right = textRect.left + be_bold_font->StringWidth(label.String())
|
||||
+ (kEdgePadding * 3);
|
||||
textRect.bottom = labelOffset;
|
||||
BRect textRect = Bounds();
|
||||
//textRect.left = kEdgePadding * 2;
|
||||
//textRect.right = textRect.left + be_bold_font->StringWidth(label.String())
|
||||
// + (kEdgePadding * 3);
|
||||
textRect.bottom = 2 * labelOffset;
|
||||
|
||||
BRect borderRect = Bounds().InsetByCopy(kEdgePadding, kEdgePadding);
|
||||
borderRect.top = 2 * labelOffset;
|
||||
|
||||
BRect closeCross = fCloseRect;
|
||||
closeCross.InsetBy(kSmallPadding, kSmallPadding);
|
||||
@@ -137,36 +138,24 @@ AppGroupView::Draw(BRect updateRect)
|
||||
SetFont(be_bold_font);
|
||||
SetPenSize(kPenSize);
|
||||
|
||||
// Draw the border
|
||||
PushState();
|
||||
SetHighColor(detailCol);
|
||||
// StrokeRoundRect(borderRect, kEdgePadding, kEdgePadding * 2);
|
||||
StrokeRect(borderRect);
|
||||
PopState();
|
||||
|
||||
SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||
FillRect(textRect, B_SOLID_LOW);
|
||||
|
||||
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||
|
||||
// Draw the collapse widget
|
||||
PushState();
|
||||
SetHighColor(detailCol);
|
||||
StrokeRoundRect(fCollapseRect, kSmallPadding, kSmallPadding);
|
||||
StrokeRoundRect(fCollapseRect, kSmallPadding, kSmallPadding);
|
||||
|
||||
BPoint expandHorStart(fCollapseRect.left + kSmallPadding, fCollapseRect.Height() / 2 + fCollapseRect.top);
|
||||
BPoint expandHorEnd(fCollapseRect.right - kSmallPadding, fCollapseRect.Height() / 2 + fCollapseRect.top);
|
||||
BPoint expandHorStart(fCollapseRect.left + kSmallPadding, fCollapseRect.Height() / 2 + fCollapseRect.top);
|
||||
BPoint expandHorEnd(fCollapseRect.right - kSmallPadding, fCollapseRect.Height() / 2 + fCollapseRect.top);
|
||||
|
||||
StrokeLine(expandHorStart, expandHorEnd);
|
||||
PopState();
|
||||
StrokeLine(expandHorStart, expandHorEnd);
|
||||
|
||||
// Draw the dismiss widget
|
||||
PushState();
|
||||
SetHighColor(detailCol);
|
||||
FillRect(fCloseRect, B_SOLID_LOW);
|
||||
StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding);
|
||||
|
||||
StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding);
|
||||
|
||||
StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
|
||||
StrokeLine(closeCross.RightTop(), closeCross.LeftBottom());
|
||||
PopState();
|
||||
StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
|
||||
StrokeLine(closeCross.RightTop(), closeCross.LeftBottom());
|
||||
|
||||
// Draw the label
|
||||
DrawString(label.String(), BPoint(fCollapseRect.right + kEdgePadding, labelOffset + kEdgePadding));
|
||||
@@ -310,7 +299,7 @@ AppGroupView::ResizeViews()
|
||||
font_height fh;
|
||||
be_bold_font->GetHeight(&fh);
|
||||
|
||||
float offset = fh.ascent + fh.leading + fh.descent;
|
||||
float offset = 2 * kEdgePadding + fh.ascent + fh.leading + fh.descent;
|
||||
int32 children = fInfo.size();
|
||||
|
||||
if (!fCollapsed) {
|
||||
@@ -318,7 +307,7 @@ AppGroupView::ResizeViews()
|
||||
|
||||
for (int32 i = 0; i < children; i++) {
|
||||
fInfo[i]->ResizeToPreferred();
|
||||
fInfo[i]->MoveTo(kEdgePadding + kPenSize, offset);
|
||||
fInfo[i]->MoveTo(0, offset);
|
||||
|
||||
offset += fInfo[i]->Bounds().Height();
|
||||
if (fInfo[i]->IsHidden())
|
||||
@@ -342,7 +331,7 @@ AppGroupView::ResizeViews()
|
||||
float labelOffset = fh.ascent + fh.leading;
|
||||
|
||||
BRect borderRect = Bounds().InsetByCopy(kEdgePadding, kEdgePadding);
|
||||
borderRect.top = labelOffset;
|
||||
borderRect.top = 2*labelOffset;
|
||||
|
||||
fCollapseRect = borderRect;
|
||||
fCollapseRect.right = fCollapseRect.left + kExpandSize;
|
||||
|
||||
@@ -77,11 +77,11 @@ BorderView::Draw(BRect rect)
|
||||
SetHighColor(tint_color(col_bg, B_DARKEN_2_TINT));
|
||||
|
||||
BRect content = Bounds();
|
||||
content.InsetBy(kBorderWidth, kBorderWidth);
|
||||
// content.InsetBy(kBorderWidth, kBorderWidth);
|
||||
content.top += text_pos + fh.descent + 2;
|
||||
|
||||
BRect content_line(content);
|
||||
content_line.InsetBy(-1, -1);
|
||||
// content_line.InsetBy(-1, -1);
|
||||
|
||||
StrokeRect(content_line);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ const char* kSmallIconAttribute = "BEOS:M:STD_ICON";
|
||||
const char* kLargeIconAttribute = "BEOS:L:STD_ICON";
|
||||
const char* kIconAttribute = "BEOS:ICON";
|
||||
|
||||
static const int kIconStripeWidth = 30;
|
||||
|
||||
property_info message_prop_list[] = {
|
||||
{ "type", {B_GET_PROPERTY, B_SET_PROPERTY, 0},
|
||||
{B_DIRECT_SPECIFIER, 0}, "get the notification type"},
|
||||
@@ -297,7 +299,14 @@ NotificationView::Draw(BRect updateRect)
|
||||
|
||||
// Icon size
|
||||
float iconSize = (float)fParent->IconSize();
|
||||
|
||||
|
||||
BRect stripeRect = Bounds();
|
||||
int32 iconLayoutScale = max_c(1, ((int32)be_plain_font->Size() + 15) / 16);
|
||||
stripeRect.right = kIconStripeWidth * iconLayoutScale;
|
||||
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||
FillRect(stripeRect);
|
||||
|
||||
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||
// Rectangle for icon and overlay icon
|
||||
BRect iconRect(0, 0, 0, 0);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <File.h>
|
||||
#include <NodeMonitor.h>
|
||||
#include <PropertyInfo.h>
|
||||
#include <private/interface/WindowPrivate.h>
|
||||
|
||||
#include "AppGroupView.h"
|
||||
#include "AppUsage.h"
|
||||
@@ -48,13 +49,13 @@ property_info main_prop_list[] = {
|
||||
const float kCloseSize = 8;
|
||||
const float kExpandSize = 8;
|
||||
const float kPenSize = 1;
|
||||
const float kEdgePadding = 5;
|
||||
const float kEdgePadding = 2;
|
||||
const float kSmallPadding = 2;
|
||||
|
||||
NotificationWindow::NotificationWindow()
|
||||
:
|
||||
BWindow(BRect(10, 10, 30, 30), B_TRANSLATE_MARK("Notification"),
|
||||
B_BORDERED_WINDOW, B_AVOID_FRONT | B_AVOID_FOCUS | B_NOT_CLOSABLE
|
||||
kLeftTitledWindowLook, B_FLOATING_ALL_WINDOW_FEEL, B_AVOID_FRONT | B_AVOID_FOCUS | B_NOT_CLOSABLE
|
||||
| B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE,
|
||||
B_ALL_WORKSPACES)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user