More fixes to the notification windows :
* Rewrite the positionning code properly. There's a remaining bug when deskbar is on the left, but I think it comes from DecoratorFrame() Tweak the position of UI elements : * Shift the close cross a bit * Make the icon stripe the same as in alerts, and align the icon the same way * Adjust the text position, too AppGroupView: * remove the remaining "lines" in collapsed mode (looked like artifacts) * Grey out the title in collapsed mode git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42714 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -60,7 +60,6 @@ AppGroupView::Draw(BRect updateRect)
|
|||||||
|
|
||||||
|
|
||||||
BRect textRect = Bounds();
|
BRect textRect = Bounds();
|
||||||
//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 = 2 * labelOffset;
|
textRect.bottom = 2 * labelOffset;
|
||||||
@@ -75,92 +74,49 @@ AppGroupView::Draw(BRect updateRect)
|
|||||||
detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);
|
detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);
|
||||||
// detailCol = tint_color(detailCol, B_LIGHTEN_1_TINT);
|
// detailCol = tint_color(detailCol, B_LIGHTEN_1_TINT);
|
||||||
|
|
||||||
|
PushState();
|
||||||
|
SetFont(be_bold_font);
|
||||||
|
SetPenSize(kPenSize);
|
||||||
|
|
||||||
if (fCollapsed) {
|
if (fCollapsed) {
|
||||||
|
// Draw the expand widget
|
||||||
PushState();
|
PushState();
|
||||||
SetFont(be_bold_font);
|
SetHighColor(detailCol);
|
||||||
SetPenSize(kPenSize);
|
|
||||||
float linePos = textRect.top + textRect.Height() / 2;
|
|
||||||
|
|
||||||
// Draw the line to the expand widget
|
|
||||||
PushState();
|
|
||||||
SetHighColor(detailCol);
|
|
||||||
StrokeLine(BPoint(kEdgePadding, linePos), BPoint(fCollapseRect.left, linePos));
|
|
||||||
PopState();
|
|
||||||
|
|
||||||
// Draw the expand widget
|
|
||||||
PushState();
|
|
||||||
SetHighColor(detailCol);
|
|
||||||
StrokeRoundRect(fCollapseRect, kSmallPadding, kSmallPadding);
|
|
||||||
|
|
||||||
BPoint expandHorStart(fCollapseRect.left + kSmallPadding, fCollapseRect.Height() / 2 + fCollapseRect.top);
|
|
||||||
BPoint expandHorEnd(fCollapseRect.right - kSmallPadding, fCollapseRect.Height() / 2 + fCollapseRect.top);
|
|
||||||
StrokeLine(expandHorStart, expandHorEnd);
|
|
||||||
|
|
||||||
BPoint expandVerStart(fCollapseRect.Width() / 2 + fCollapseRect.left, fCollapseRect.top + kSmallPadding);
|
|
||||||
BPoint expandVerEnd(fCollapseRect.Width() / 2 + fCollapseRect.left, fCollapseRect.bottom - kSmallPadding);
|
|
||||||
StrokeLine(expandVerStart, expandVerEnd);
|
|
||||||
PopState();
|
|
||||||
|
|
||||||
// Draw the app title
|
|
||||||
DrawString(label.String(), BPoint(fCollapseRect.right + kEdgePadding, labelOffset + kEdgePadding));
|
|
||||||
|
|
||||||
// Draw the line from the label to the close widget
|
|
||||||
PushState();
|
|
||||||
SetHighColor(detailCol);
|
|
||||||
|
|
||||||
BPoint lineSeg2Start(textRect.right + kSmallPadding / 2, linePos);
|
|
||||||
BPoint lineSeg2End(fCloseRect.left, linePos);
|
|
||||||
StrokeLine(lineSeg2Start, lineSeg2End);
|
|
||||||
PopState();
|
|
||||||
|
|
||||||
// Draw the dismiss widget
|
|
||||||
PushState();
|
|
||||||
SetHighColor(detailCol);
|
|
||||||
|
|
||||||
StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding);
|
|
||||||
|
|
||||||
StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
|
|
||||||
StrokeLine(closeCross.RightTop(), closeCross.LeftBottom());
|
|
||||||
PopState();
|
|
||||||
|
|
||||||
// Draw the line from the dismiss widget
|
|
||||||
PushState();
|
|
||||||
SetHighColor(detailCol);
|
|
||||||
|
|
||||||
BPoint lineSeg3Start(fCloseRect.right, linePos);
|
|
||||||
BPoint lineSeg3End(borderRect.right, linePos);
|
|
||||||
StrokeLine(lineSeg3Start, lineSeg3End);
|
|
||||||
PopState();
|
|
||||||
|
|
||||||
PopState();
|
|
||||||
} else {
|
|
||||||
PushState();
|
|
||||||
SetFont(be_bold_font);
|
|
||||||
SetPenSize(kPenSize);
|
|
||||||
|
|
||||||
SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
|
||||||
FillRect(textRect, B_SOLID_LOW);
|
|
||||||
|
|
||||||
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
|
||||||
|
|
||||||
// Draw the collapse widget
|
|
||||||
StrokeRoundRect(fCollapseRect, kSmallPadding, kSmallPadding);
|
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);
|
||||||
|
|
||||||
// Draw the dismiss widget
|
BPoint expandVerStart(fCollapseRect.Width() / 2 + fCollapseRect.left, fCollapseRect.top + kSmallPadding);
|
||||||
StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding);
|
BPoint expandVerEnd(fCollapseRect.Width() / 2 + fCollapseRect.left, fCollapseRect.bottom - kSmallPadding);
|
||||||
|
StrokeLine(expandVerStart, expandVerEnd);
|
||||||
StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
|
|
||||||
StrokeLine(closeCross.RightTop(), closeCross.LeftBottom());
|
|
||||||
|
|
||||||
// Draw the label
|
|
||||||
DrawString(label.String(), BPoint(fCollapseRect.right + kEdgePadding, labelOffset + kEdgePadding));
|
|
||||||
PopState();
|
PopState();
|
||||||
|
|
||||||
|
SetHighColor(tint_color(ui_color(B_PANEL_TEXT_COLOR), B_LIGHTEN_1_TINT));
|
||||||
|
} else {
|
||||||
|
SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||||
|
FillRect(textRect, B_SOLID_LOW);
|
||||||
|
|
||||||
|
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
|
||||||
|
// Draw the collapse widget
|
||||||
|
StrokeRoundRect(fCollapseRect, kSmallPadding, kSmallPadding);
|
||||||
|
|
||||||
|
BPoint expandHorStart(fCollapseRect.left + kSmallPadding, fCollapseRect.Height() / 2 + fCollapseRect.top);
|
||||||
|
BPoint expandHorEnd(fCollapseRect.right - kSmallPadding, fCollapseRect.Height() / 2 + fCollapseRect.top);
|
||||||
|
|
||||||
|
StrokeLine(expandHorStart, expandHorEnd);
|
||||||
}
|
}
|
||||||
|
// Draw the dismiss widget
|
||||||
|
StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding);
|
||||||
|
|
||||||
|
StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
|
||||||
|
StrokeLine(closeCross.RightTop(), closeCross.LeftBottom());
|
||||||
|
|
||||||
|
// Draw the label
|
||||||
|
DrawString(label.String(), BPoint(fCollapseRect.right + 2 * kEdgePadding, labelOffset + kEdgePadding));
|
||||||
|
PopState();
|
||||||
|
|
||||||
Sync();
|
Sync();
|
||||||
}
|
}
|
||||||
@@ -339,10 +295,10 @@ AppGroupView::ResizeViews()
|
|||||||
fCollapseRect.OffsetTo(kEdgePadding * 2, kEdgePadding * 1.5);
|
fCollapseRect.OffsetTo(kEdgePadding * 2, kEdgePadding * 1.5);
|
||||||
|
|
||||||
fCloseRect = borderRect;
|
fCloseRect = borderRect;
|
||||||
fCloseRect.right -= kEdgePadding * 4;
|
fCloseRect.right -= kEdgePadding * 2;
|
||||||
|
fCloseRect.top += kEdgePadding * 1.5;
|
||||||
fCloseRect.left = fCloseRect.right - kCloseSize;
|
fCloseRect.left = fCloseRect.right - kCloseSize;
|
||||||
fCloseRect.bottom = fCloseRect.top + kCloseSize;
|
fCloseRect.bottom = fCloseRect.top + kCloseSize;
|
||||||
fCloseRect.OffsetTo(fCloseRect.left, kEdgePadding * 1.5);
|
|
||||||
|
|
||||||
fParent->ResizeAll();
|
fParent->ResizeAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ 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 = 16;
|
static const int kIconStripeWidth = 32;
|
||||||
|
|
||||||
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},
|
||||||
@@ -280,8 +280,7 @@ NotificationView::Draw(BRect updateRect)
|
|||||||
float iconSize = (float)fParent->IconSize();
|
float iconSize = (float)fParent->IconSize();
|
||||||
|
|
||||||
BRect stripeRect = Bounds();
|
BRect stripeRect = Bounds();
|
||||||
int32 iconLayoutScale = max_c(1, ((int32)be_plain_font->Size() + 15) / 16);
|
stripeRect.right = kIconStripeWidth;
|
||||||
stripeRect.right = kIconStripeWidth * iconLayoutScale;
|
|
||||||
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||||
FillRect(stripeRect);
|
FillRect(stripeRect);
|
||||||
|
|
||||||
@@ -291,23 +290,16 @@ NotificationView::Draw(BRect updateRect)
|
|||||||
|
|
||||||
// Draw icon
|
// Draw icon
|
||||||
if (fBitmap) {
|
if (fBitmap) {
|
||||||
LineInfo* appLine = fLines.back();
|
float ix = kIconStripeWidth - iconSize / 3.0;
|
||||||
font_height fh;
|
// Icon is centered around stripe right border
|
||||||
appLine->font.GetHeight(&fh);
|
float iy = (Bounds().Height() - iconSize) / 2.0;
|
||||||
|
// Icon is vertically centered in view
|
||||||
float title_bottom = appLine->location.y + fh.descent;
|
|
||||||
|
|
||||||
float ix = kEdgePadding;
|
|
||||||
float iy = 0;
|
|
||||||
if (fParent->Layout() == TitleAboveIcon)
|
|
||||||
iy = title_bottom + kEdgePadding + (Bounds().Height() - title_bottom
|
|
||||||
- kEdgePadding * 2 - iconSize) / 2;
|
|
||||||
else
|
|
||||||
iy = (Bounds().Height() - iconSize) / 2.0;
|
|
||||||
|
|
||||||
if (fType == B_PROGRESS_NOTIFICATION)
|
if (fType == B_PROGRESS_NOTIFICATION)
|
||||||
|
{
|
||||||
// Move icon up by half progress bar height if it's present
|
// Move icon up by half progress bar height if it's present
|
||||||
iy -= (progRect.Height() + kEdgePadding) / 2.0;
|
iy -= (progRect.Height() + kEdgePadding);
|
||||||
|
}
|
||||||
|
|
||||||
iconRect.Set(ix, iy, ix + iconSize - 1.0, iy + iconSize - 1.0);
|
iconRect.Set(ix, iy, ix + iconSize - 1.0, iy + iconSize - 1.0);
|
||||||
DrawBitmapAsync(fBitmap, fBitmap->Bounds(), iconRect);
|
DrawBitmapAsync(fBitmap, fBitmap->Bounds(), iconRect);
|
||||||
@@ -327,7 +319,7 @@ NotificationView::Draw(BRect updateRect)
|
|||||||
|
|
||||||
// Draw the close widget
|
// Draw the close widget
|
||||||
BRect closeRect = Bounds();
|
BRect closeRect = Bounds();
|
||||||
closeRect.InsetBy(kEdgePadding, kEdgePadding);
|
closeRect.InsetBy(2 * kEdgePadding, 2 * kEdgePadding);
|
||||||
closeRect.left = closeRect.right - kCloseSize;
|
closeRect.left = closeRect.right - kCloseSize;
|
||||||
closeRect.bottom = closeRect.top + kCloseSize;
|
closeRect.bottom = closeRect.top + kCloseSize;
|
||||||
|
|
||||||
@@ -488,15 +480,17 @@ NotificationView::SetText(const char* app, const char* title, const char* text,
|
|||||||
fTitle = title;
|
fTitle = title;
|
||||||
fText = text;
|
fText = text;
|
||||||
|
|
||||||
float iconRight = kEdgePadding + kEdgePadding;
|
float iconRight = kIconStripeWidth;
|
||||||
if (fBitmap != NULL)
|
if (fBitmap != NULL)
|
||||||
iconRight += fParent->IconSize();
|
iconRight += fParent->IconSize() * 0.75;
|
||||||
|
else
|
||||||
|
iconRight += 24;
|
||||||
|
|
||||||
font_height fh;
|
font_height fh;
|
||||||
be_bold_font->GetHeight(&fh);
|
be_bold_font->GetHeight(&fh);
|
||||||
float fontHeight = ceilf(fh.leading) + ceilf(fh.descent)
|
float fontHeight = ceilf(fh.leading) + ceilf(fh.descent)
|
||||||
+ ceilf(fh.ascent);
|
+ ceilf(fh.ascent);
|
||||||
float y = fontHeight;
|
float y = 2 * fontHeight;
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
LineInfo* titleLine = new LineInfo;
|
LineInfo* titleLine = new LineInfo;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ NotificationWindow::NotificationWindow()
|
|||||||
:
|
:
|
||||||
BWindow(BRect(0, 0, 0, 0), B_TRANSLATE_MARK("Notification"),
|
BWindow(BRect(0, 0, 0, 0), B_TRANSLATE_MARK("Notification"),
|
||||||
kLeftTitledWindowLook, B_FLOATING_ALL_WINDOW_FEEL, 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_NOT_MOVABLE,
|
||||||
B_ALL_WORKSPACES)
|
B_ALL_WORKSPACES)
|
||||||
{
|
{
|
||||||
fBorder = new BorderView(Bounds(), "Notification");
|
fBorder = new BorderView(Bounds(), "Notification");
|
||||||
@@ -371,57 +371,47 @@ void
|
|||||||
NotificationWindow::SetPosition()
|
NotificationWindow::SetPosition()
|
||||||
{
|
{
|
||||||
BRect bounds = DecoratorFrame();
|
BRect bounds = DecoratorFrame();
|
||||||
float width = bounds.Width();
|
float width = Bounds().Width() + 1;
|
||||||
float height = bounds.Height();
|
float height = Bounds().Height() + 1;
|
||||||
|
|
||||||
float leftOffset = Frame().left - DecoratorFrame().left;
|
float leftOffset = Frame().left - bounds.left;
|
||||||
float topOffset = DecoratorFrame().top - Frame().top;
|
float topOffset = Frame().top - bounds.top;
|
||||||
|
float rightOffset = bounds.right - Frame().right;
|
||||||
|
float bottomOffset = bounds.bottom - Frame().bottom;
|
||||||
|
// Size of the borders around the window
|
||||||
|
|
||||||
|
float x = Frame().left, y = Frame().top;
|
||||||
|
// If we can't guess, don't move...
|
||||||
|
|
||||||
float x = 0, y = 0, sx, sy;
|
|
||||||
float pad = 0;
|
|
||||||
BDeskbar deskbar;
|
BDeskbar deskbar;
|
||||||
BRect frame = deskbar.Frame();
|
BRect frame = deskbar.Frame();
|
||||||
|
|
||||||
switch (deskbar.Location()) {
|
switch (deskbar.Location()) {
|
||||||
case B_DESKBAR_TOP:
|
case B_DESKBAR_TOP:
|
||||||
// Put it just under, top right corner
|
// Put it just under, top right corner
|
||||||
y = frame.bottom + pad + topOffset;
|
y = frame.bottom + topOffset;
|
||||||
x = frame.right - width;
|
x = frame.right - width - rightOffset;
|
||||||
break;
|
break;
|
||||||
case B_DESKBAR_BOTTOM:
|
case B_DESKBAR_BOTTOM:
|
||||||
// Put it just above, lower left corner
|
// Put it just above, lower left corner
|
||||||
sx = frame.right;
|
y = frame.top - height - bottomOffset;
|
||||||
sy = frame.top - height - pad;
|
x = frame.right - width - rightOffset;
|
||||||
y = sy;
|
|
||||||
x = sx - width - pad;
|
|
||||||
break;
|
|
||||||
case B_DESKBAR_LEFT_TOP:
|
|
||||||
// Put it just to the right of the deskbar
|
|
||||||
sx = frame.right + pad;
|
|
||||||
//sy = frame.top - height;
|
|
||||||
x = sx + leftOffset;
|
|
||||||
y = frame.top + pad;
|
|
||||||
break;
|
break;
|
||||||
case B_DESKBAR_RIGHT_TOP:
|
case B_DESKBAR_RIGHT_TOP:
|
||||||
// Put it just to the left of the deskbar
|
x = frame.left - width - rightOffset;
|
||||||
sx = frame.left - width - pad;
|
y = frame.top + topOffset;
|
||||||
//sy = frame.top - height;
|
|
||||||
x = sx;
|
|
||||||
y = frame.top + pad;
|
|
||||||
break;
|
break;
|
||||||
case B_DESKBAR_LEFT_BOTTOM:
|
case B_DESKBAR_LEFT_TOP:
|
||||||
// Put it to the right of the deskbar.
|
x = frame.right + leftOffset;
|
||||||
sx = frame.right + pad;
|
y = frame.top + topOffset;
|
||||||
sy = frame.bottom;
|
|
||||||
x = sx + leftOffset;
|
|
||||||
y = sy - height - pad;
|
|
||||||
break;
|
break;
|
||||||
case B_DESKBAR_RIGHT_BOTTOM:
|
case B_DESKBAR_RIGHT_BOTTOM:
|
||||||
// Put it to the left of the deskbar.
|
y = frame.bottom - height - bottomOffset;
|
||||||
sx = frame.left - width - pad;
|
x = frame.left - width - rightOffset;
|
||||||
sy = frame.bottom;
|
break;
|
||||||
y = sy - height - pad;
|
case B_DESKBAR_LEFT_BOTTOM:
|
||||||
x = sx;
|
y = frame.bottom - height - bottomOffset;
|
||||||
|
x = frame.right + leftOffset;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user