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:
parent
dbc35acfc9
commit
0e07be0657
@ -60,7 +60,6 @@ AppGroupView::Draw(BRect updateRect)
|
||||
|
||||
|
||||
BRect textRect = Bounds();
|
||||
//textRect.left = kEdgePadding * 2;
|
||||
//textRect.right = textRect.left + be_bold_font->StringWidth(label.String())
|
||||
// + (kEdgePadding * 3);
|
||||
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_1_TINT);
|
||||
|
||||
PushState();
|
||||
SetFont(be_bold_font);
|
||||
SetPenSize(kPenSize);
|
||||
|
||||
if (fCollapsed) {
|
||||
// Draw the expand widget
|
||||
PushState();
|
||||
SetFont(be_bold_font);
|
||||
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
|
||||
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);
|
||||
|
||||
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 + kEdgePadding, labelOffset + kEdgePadding));
|
||||
|
||||
BPoint expandVerStart(fCollapseRect.Width() / 2 + fCollapseRect.left, fCollapseRect.top + kSmallPadding);
|
||||
BPoint expandVerEnd(fCollapseRect.Width() / 2 + fCollapseRect.left, fCollapseRect.bottom - kSmallPadding);
|
||||
StrokeLine(expandVerStart, expandVerEnd);
|
||||
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();
|
||||
}
|
||||
@ -339,10 +295,10 @@ AppGroupView::ResizeViews()
|
||||
fCollapseRect.OffsetTo(kEdgePadding * 2, kEdgePadding * 1.5);
|
||||
|
||||
fCloseRect = borderRect;
|
||||
fCloseRect.right -= kEdgePadding * 4;
|
||||
fCloseRect.right -= kEdgePadding * 2;
|
||||
fCloseRect.top += kEdgePadding * 1.5;
|
||||
fCloseRect.left = fCloseRect.right - kCloseSize;
|
||||
fCloseRect.bottom = fCloseRect.top + kCloseSize;
|
||||
fCloseRect.OffsetTo(fCloseRect.left, kEdgePadding * 1.5);
|
||||
|
||||
fParent->ResizeAll();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ const char* kSmallIconAttribute = "BEOS:M:STD_ICON";
|
||||
const char* kLargeIconAttribute = "BEOS:L:STD_ICON";
|
||||
const char* kIconAttribute = "BEOS:ICON";
|
||||
|
||||
static const int kIconStripeWidth = 16;
|
||||
static const int kIconStripeWidth = 32;
|
||||
|
||||
property_info message_prop_list[] = {
|
||||
{ "type", {B_GET_PROPERTY, B_SET_PROPERTY, 0},
|
||||
@ -280,8 +280,7 @@ NotificationView::Draw(BRect updateRect)
|
||||
float iconSize = (float)fParent->IconSize();
|
||||
|
||||
BRect stripeRect = Bounds();
|
||||
int32 iconLayoutScale = max_c(1, ((int32)be_plain_font->Size() + 15) / 16);
|
||||
stripeRect.right = kIconStripeWidth * iconLayoutScale;
|
||||
stripeRect.right = kIconStripeWidth;
|
||||
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||
FillRect(stripeRect);
|
||||
|
||||
@ -291,23 +290,16 @@ NotificationView::Draw(BRect updateRect)
|
||||
|
||||
// Draw icon
|
||||
if (fBitmap) {
|
||||
LineInfo* appLine = fLines.back();
|
||||
font_height fh;
|
||||
appLine->font.GetHeight(&fh);
|
||||
|
||||
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;
|
||||
float ix = kIconStripeWidth - iconSize / 3.0;
|
||||
// Icon is centered around stripe right border
|
||||
float iy = (Bounds().Height() - iconSize) / 2.0;
|
||||
// Icon is vertically centered in view
|
||||
|
||||
if (fType == B_PROGRESS_NOTIFICATION)
|
||||
{
|
||||
// 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);
|
||||
DrawBitmapAsync(fBitmap, fBitmap->Bounds(), iconRect);
|
||||
@ -327,7 +319,7 @@ NotificationView::Draw(BRect updateRect)
|
||||
|
||||
// Draw the close widget
|
||||
BRect closeRect = Bounds();
|
||||
closeRect.InsetBy(kEdgePadding, kEdgePadding);
|
||||
closeRect.InsetBy(2 * kEdgePadding, 2 * kEdgePadding);
|
||||
closeRect.left = closeRect.right - kCloseSize;
|
||||
closeRect.bottom = closeRect.top + kCloseSize;
|
||||
|
||||
@ -488,15 +480,17 @@ NotificationView::SetText(const char* app, const char* title, const char* text,
|
||||
fTitle = title;
|
||||
fText = text;
|
||||
|
||||
float iconRight = kEdgePadding + kEdgePadding;
|
||||
float iconRight = kIconStripeWidth;
|
||||
if (fBitmap != NULL)
|
||||
iconRight += fParent->IconSize();
|
||||
iconRight += fParent->IconSize() * 0.75;
|
||||
else
|
||||
iconRight += 24;
|
||||
|
||||
font_height fh;
|
||||
be_bold_font->GetHeight(&fh);
|
||||
float fontHeight = ceilf(fh.leading) + ceilf(fh.descent)
|
||||
+ ceilf(fh.ascent);
|
||||
float y = fontHeight;
|
||||
float y = 2 * fontHeight;
|
||||
|
||||
// Title
|
||||
LineInfo* titleLine = new LineInfo;
|
||||
|
@ -56,7 +56,7 @@ NotificationWindow::NotificationWindow()
|
||||
:
|
||||
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
|
||||
| B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE,
|
||||
| B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_NOT_MOVABLE,
|
||||
B_ALL_WORKSPACES)
|
||||
{
|
||||
fBorder = new BorderView(Bounds(), "Notification");
|
||||
@ -371,57 +371,47 @@ void
|
||||
NotificationWindow::SetPosition()
|
||||
{
|
||||
BRect bounds = DecoratorFrame();
|
||||
float width = bounds.Width();
|
||||
float height = bounds.Height();
|
||||
float width = Bounds().Width() + 1;
|
||||
float height = Bounds().Height() + 1;
|
||||
|
||||
float leftOffset = Frame().left - DecoratorFrame().left;
|
||||
float topOffset = DecoratorFrame().top - Frame().top;
|
||||
float leftOffset = Frame().left - bounds.left;
|
||||
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 = 0, y = 0, sx, sy;
|
||||
float pad = 0;
|
||||
float x = Frame().left, y = Frame().top;
|
||||
// If we can't guess, don't move...
|
||||
|
||||
BDeskbar deskbar;
|
||||
BRect frame = deskbar.Frame();
|
||||
|
||||
switch (deskbar.Location()) {
|
||||
case B_DESKBAR_TOP:
|
||||
// Put it just under, top right corner
|
||||
y = frame.bottom + pad + topOffset;
|
||||
x = frame.right - width;
|
||||
y = frame.bottom + topOffset;
|
||||
x = frame.right - width - rightOffset;
|
||||
break;
|
||||
case B_DESKBAR_BOTTOM:
|
||||
// Put it just above, lower left corner
|
||||
sx = frame.right;
|
||||
sy = frame.top - height - pad;
|
||||
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;
|
||||
y = frame.top - height - bottomOffset;
|
||||
x = frame.right - width - rightOffset;
|
||||
break;
|
||||
case B_DESKBAR_RIGHT_TOP:
|
||||
// Put it just to the left of the deskbar
|
||||
sx = frame.left - width - pad;
|
||||
//sy = frame.top - height;
|
||||
x = sx;
|
||||
y = frame.top + pad;
|
||||
x = frame.left - width - rightOffset;
|
||||
y = frame.top + topOffset;
|
||||
break;
|
||||
case B_DESKBAR_LEFT_BOTTOM:
|
||||
// Put it to the right of the deskbar.
|
||||
sx = frame.right + pad;
|
||||
sy = frame.bottom;
|
||||
x = sx + leftOffset;
|
||||
y = sy - height - pad;
|
||||
case B_DESKBAR_LEFT_TOP:
|
||||
x = frame.right + leftOffset;
|
||||
y = frame.top + topOffset;
|
||||
break;
|
||||
case B_DESKBAR_RIGHT_BOTTOM:
|
||||
// Put it to the left of the deskbar.
|
||||
sx = frame.left - width - pad;
|
||||
sy = frame.bottom;
|
||||
y = sy - height - pad;
|
||||
x = sx;
|
||||
y = frame.bottom - height - bottomOffset;
|
||||
x = frame.left - width - rightOffset;
|
||||
break;
|
||||
case B_DESKBAR_LEFT_BOTTOM:
|
||||
y = frame.bottom - height - bottomOffset;
|
||||
x = frame.right + leftOffset;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user