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:
Adrien Destugues
2011-08-06 09:05:55 +00:00
parent 81e071b76e
commit 9dcd41a8af
4 changed files with 36 additions and 37 deletions
+21 -32
View File
@@ -58,14 +58,15 @@ AppGroupView::Draw(BRect updateRect)
be_bold_font->GetHeight(&fh); be_bold_font->GetHeight(&fh);
float labelOffset = fh.ascent + fh.leading; float labelOffset = fh.ascent + fh.leading;
BRect borderRect = Bounds().InsetByCopy(kEdgePadding, kEdgePadding);
borderRect.top = labelOffset;
BRect textRect = borderRect; BRect textRect = Bounds();
textRect.left = kEdgePadding * 2; //textRect.left = kEdgePadding * 2;
textRect.right = textRect.left + be_bold_font->StringWidth(label.String()) //textRect.right = textRect.left + be_bold_font->StringWidth(label.String())
+ (kEdgePadding * 3); // + (kEdgePadding * 3);
textRect.bottom = labelOffset; textRect.bottom = 2 * labelOffset;
BRect borderRect = Bounds().InsetByCopy(kEdgePadding, kEdgePadding);
borderRect.top = 2 * labelOffset;
BRect closeCross = fCloseRect; BRect closeCross = fCloseRect;
closeCross.InsetBy(kSmallPadding, kSmallPadding); closeCross.InsetBy(kSmallPadding, kSmallPadding);
@@ -137,36 +138,24 @@ AppGroupView::Draw(BRect updateRect)
SetFont(be_bold_font); SetFont(be_bold_font);
SetPenSize(kPenSize); SetPenSize(kPenSize);
// Draw the border SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
PushState();
SetHighColor(detailCol);
// StrokeRoundRect(borderRect, kEdgePadding, kEdgePadding * 2);
StrokeRect(borderRect);
PopState();
FillRect(textRect, B_SOLID_LOW); FillRect(textRect, B_SOLID_LOW);
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
// Draw the collapse widget // Draw the collapse widget
PushState(); StrokeRoundRect(fCollapseRect, kSmallPadding, kSmallPadding);
SetHighColor(detailCol);
StrokeRoundRect(fCollapseRect, kSmallPadding, kSmallPadding);
BPoint expandHorStart(fCollapseRect.left + 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); BPoint expandHorEnd(fCollapseRect.right - kSmallPadding, fCollapseRect.Height() / 2 + fCollapseRect.top);
StrokeLine(expandHorStart, expandHorEnd); StrokeLine(expandHorStart, expandHorEnd);
PopState();
// Draw the dismiss widget // Draw the dismiss widget
PushState(); StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding);
SetHighColor(detailCol);
FillRect(fCloseRect, B_SOLID_LOW);
StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding); StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
StrokeLine(closeCross.RightTop(), closeCross.LeftBottom());
StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
StrokeLine(closeCross.RightTop(), closeCross.LeftBottom());
PopState();
// Draw the label // Draw the label
DrawString(label.String(), BPoint(fCollapseRect.right + kEdgePadding, labelOffset + kEdgePadding)); DrawString(label.String(), BPoint(fCollapseRect.right + kEdgePadding, labelOffset + kEdgePadding));
@@ -310,7 +299,7 @@ AppGroupView::ResizeViews()
font_height fh; font_height fh;
be_bold_font->GetHeight(&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(); int32 children = fInfo.size();
if (!fCollapsed) { if (!fCollapsed) {
@@ -318,7 +307,7 @@ AppGroupView::ResizeViews()
for (int32 i = 0; i < children; i++) { for (int32 i = 0; i < children; i++) {
fInfo[i]->ResizeToPreferred(); fInfo[i]->ResizeToPreferred();
fInfo[i]->MoveTo(kEdgePadding + kPenSize, offset); fInfo[i]->MoveTo(0, offset);
offset += fInfo[i]->Bounds().Height(); offset += fInfo[i]->Bounds().Height();
if (fInfo[i]->IsHidden()) if (fInfo[i]->IsHidden())
@@ -342,7 +331,7 @@ AppGroupView::ResizeViews()
float labelOffset = fh.ascent + fh.leading; float labelOffset = fh.ascent + fh.leading;
BRect borderRect = Bounds().InsetByCopy(kEdgePadding, kEdgePadding); BRect borderRect = Bounds().InsetByCopy(kEdgePadding, kEdgePadding);
borderRect.top = labelOffset; borderRect.top = 2*labelOffset;
fCollapseRect = borderRect; fCollapseRect = borderRect;
fCollapseRect.right = fCollapseRect.left + kExpandSize; fCollapseRect.right = fCollapseRect.left + kExpandSize;
+2 -2
View File
@@ -77,11 +77,11 @@ BorderView::Draw(BRect rect)
SetHighColor(tint_color(col_bg, B_DARKEN_2_TINT)); SetHighColor(tint_color(col_bg, B_DARKEN_2_TINT));
BRect content = Bounds(); BRect content = Bounds();
content.InsetBy(kBorderWidth, kBorderWidth); // content.InsetBy(kBorderWidth, kBorderWidth);
content.top += text_pos + fh.descent + 2; content.top += text_pos + fh.descent + 2;
BRect content_line(content); BRect content_line(content);
content_line.InsetBy(-1, -1); // content_line.InsetBy(-1, -1);
StrokeRect(content_line); StrokeRect(content_line);
} }
+10 -1
View File
@@ -32,6 +32,8 @@ const char* kSmallIconAttribute = "BEOS:M:STD_ICON";
const char* kLargeIconAttribute = "BEOS:L:STD_ICON"; const char* kLargeIconAttribute = "BEOS:L:STD_ICON";
const char* kIconAttribute = "BEOS:ICON"; const char* kIconAttribute = "BEOS:ICON";
static const int kIconStripeWidth = 30;
property_info message_prop_list[] = { property_info message_prop_list[] = {
{ "type", {B_GET_PROPERTY, B_SET_PROPERTY, 0}, { "type", {B_GET_PROPERTY, B_SET_PROPERTY, 0},
{B_DIRECT_SPECIFIER, 0}, "get the notification type"}, {B_DIRECT_SPECIFIER, 0}, "get the notification type"},
@@ -297,7 +299,14 @@ NotificationView::Draw(BRect updateRect)
// Icon size // Icon size
float iconSize = (float)fParent->IconSize(); 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 // Rectangle for icon and overlay icon
BRect iconRect(0, 0, 0, 0); BRect iconRect(0, 0, 0, 0);
@@ -23,6 +23,7 @@
#include <File.h> #include <File.h>
#include <NodeMonitor.h> #include <NodeMonitor.h>
#include <PropertyInfo.h> #include <PropertyInfo.h>
#include <private/interface/WindowPrivate.h>
#include "AppGroupView.h" #include "AppGroupView.h"
#include "AppUsage.h" #include "AppUsage.h"
@@ -48,13 +49,13 @@ property_info main_prop_list[] = {
const float kCloseSize = 8; const float kCloseSize = 8;
const float kExpandSize = 8; const float kExpandSize = 8;
const float kPenSize = 1; const float kPenSize = 1;
const float kEdgePadding = 5; const float kEdgePadding = 2;
const float kSmallPadding = 2; const float kSmallPadding = 2;
NotificationWindow::NotificationWindow() NotificationWindow::NotificationWindow()
: :
BWindow(BRect(10, 10, 30, 30), B_TRANSLATE_MARK("Notification"), 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_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE,
B_ALL_WORKSPACES) B_ALL_WORKSPACES)
{ {