Even more work on notification window:
* Use the layout kit. That makes the code simpler. * Group headers now look like deskbar team entries. I had the answer just under my eyes all the time. * Folding and closing a group are back. However, folding does not work yet. * We need to select a better default "failure" color, as red looks a bit aggressive. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43170 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <ControlLook.h>
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
#include <GroupView.h>
|
#include <GroupView.h>
|
||||||
|
|
||||||
@@ -22,115 +23,140 @@
|
|||||||
#include "NotificationView.h"
|
#include "NotificationView.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const int kHeaderSize = 20;
|
||||||
|
|
||||||
|
|
||||||
AppGroupView::AppGroupView(NotificationWindow* win, const char* label)
|
AppGroupView::AppGroupView(NotificationWindow* win, const char* label)
|
||||||
:
|
:
|
||||||
BBox(B_FANCY_BORDER, (fView = new BGroupView(B_VERTICAL, 0))),
|
BGroupView("appGroup", B_VERTICAL, 0),
|
||||||
fLabel(label),
|
fLabel(label),
|
||||||
fParent(win),
|
fParent(win),
|
||||||
fCollapsed(false)
|
fCollapsed(false)
|
||||||
{
|
{
|
||||||
// If no group was specified we don't have any border or label
|
SetFlags(Flags() | B_WILL_DRAW);
|
||||||
if (label == NULL)
|
|
||||||
SetBorder(B_NO_BORDER);
|
|
||||||
else
|
|
||||||
SetLabel(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AppGroupView::~AppGroupView()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
void
|
|
||||||
AppGroupView::AttachedToWindow()
|
|
||||||
{
|
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
void
|
|
||||||
AppGroupView::Draw(BRect updateRect)
|
|
||||||
{
|
|
||||||
FillRect(Bounds(), B_SOLID_LOW);
|
|
||||||
|
|
||||||
BString label = fLabel;
|
|
||||||
if (fCollapsed)
|
|
||||||
label << " (" << fInfo.size() << ")";
|
|
||||||
|
|
||||||
font_height fh;
|
font_height fh;
|
||||||
be_bold_font->GetHeight(&fh);
|
be_bold_font->GetHeight(&fh);
|
||||||
float labelOffset = fh.ascent + fh.leading;
|
|
||||||
|
static_cast<BGroupLayout*>(GetLayout())->SetInsets(0, kHeaderSize, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BRect textRect = Bounds();
|
void
|
||||||
//textRect.right = textRect.left + be_bold_font->StringWidth(label.String())
|
AppGroupView::Draw(BRect updateRect)
|
||||||
// + (kEdgePadding * 3);
|
{
|
||||||
textRect.bottom = 2 * labelOffset;
|
rgb_color menuColor = ViewColor();
|
||||||
|
BRect bounds = Bounds();
|
||||||
BRect borderRect = Bounds().InsetByCopy(kEdgePadding, kEdgePadding);
|
rgb_color hilite = tint_color(menuColor, B_DARKEN_1_TINT);
|
||||||
borderRect.top = 2 * labelOffset;
|
rgb_color dark = tint_color(menuColor, B_DARKEN_2_TINT);
|
||||||
|
rgb_color vlight = tint_color(menuColor, B_LIGHTEN_2_TINT);
|
||||||
|
bounds.bottom = bounds.top + kHeaderSize;
|
||||||
|
|
||||||
BRect closeCross = fCloseRect;
|
// Draw the header background
|
||||||
closeCross.InsetBy(kSmallPadding, kSmallPadding);
|
if (be_control_look != NULL) {
|
||||||
|
SetHighColor(tint_color(menuColor, 1.22));
|
||||||
|
StrokeLine(bounds.LeftTop(), bounds.LeftBottom());
|
||||||
|
uint32 borders = BControlLook::B_TOP_BORDER
|
||||||
|
| BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER;
|
||||||
|
|
||||||
rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR);
|
be_control_look->DrawButtonBackground(this, bounds, bounds, menuColor,
|
||||||
detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);
|
0, borders);
|
||||||
// detailCol = tint_color(detailCol, B_LIGHTEN_1_TINT);
|
} else {
|
||||||
|
SetHighColor(vlight);
|
||||||
|
StrokeLine(bounds.LeftTop(), bounds.RightTop());
|
||||||
|
StrokeLine(BPoint(bounds.left, bounds.top + 1), bounds.LeftBottom());
|
||||||
|
SetHighColor(hilite);
|
||||||
|
StrokeLine(BPoint(bounds.left + 1, bounds.bottom),
|
||||||
|
bounds.RightBottom());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw the buttons
|
||||||
|
fCollapseRect.top = (kHeaderSize - kExpandSize) / 2;
|
||||||
|
fCollapseRect.left = kEdgePadding * 2;
|
||||||
|
fCollapseRect.right = fCollapseRect.left + 1.5 * kExpandSize;
|
||||||
|
fCollapseRect.bottom = fCollapseRect.top + kExpandSize;
|
||||||
|
|
||||||
|
fCloseRect = bounds;
|
||||||
|
fCloseRect.top = (kHeaderSize - kExpandSize) / 2;
|
||||||
|
fCloseRect.right -= kEdgePadding * 2;
|
||||||
|
fCloseRect.left = fCloseRect.right - kCloseSize;
|
||||||
|
fCloseRect.bottom = fCloseRect.top + kCloseSize;
|
||||||
|
|
||||||
|
if (be_control_look != NULL) {
|
||||||
|
uint32 arrowDirection = fCollapsed
|
||||||
|
? BControlLook::B_DOWN_ARROW : BControlLook::B_UP_ARROW;
|
||||||
|
be_control_look->DrawArrowShape(this, fCollapseRect, fCollapseRect,
|
||||||
|
LowColor(), arrowDirection, 0, B_DARKEN_3_TINT);
|
||||||
|
} else {
|
||||||
|
rgb_color outlineColor = {80, 80, 80, 255};
|
||||||
|
rgb_color middleColor = {200, 200, 200, 255};
|
||||||
|
|
||||||
|
SetDrawingMode(B_OP_OVER);
|
||||||
|
|
||||||
|
if (fCollapsed) {
|
||||||
|
BeginLineArray(6);
|
||||||
|
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 3, fCollapseRect.top + 1),
|
||||||
|
BPoint(fCollapseRect.left + 3, fCollapseRect.bottom - 1), outlineColor);
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 3, fCollapseRect.top + 1),
|
||||||
|
BPoint(fCollapseRect.left + 7, fCollapseRect.top + 5), outlineColor);
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 7, fCollapseRect.top + 5),
|
||||||
|
BPoint(fCollapseRect.left + 3, fCollapseRect.bottom - 1), outlineColor);
|
||||||
|
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 4, fCollapseRect.top + 3),
|
||||||
|
BPoint(fCollapseRect.left + 4, fCollapseRect.bottom - 3), middleColor);
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 5, fCollapseRect.top + 4),
|
||||||
|
BPoint(fCollapseRect.left + 5, fCollapseRect.bottom - 4), middleColor);
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 5, fCollapseRect.top + 5),
|
||||||
|
BPoint(fCollapseRect.left + 6, fCollapseRect.top + 5), middleColor);
|
||||||
|
EndLineArray();
|
||||||
|
} else {
|
||||||
|
// expanded state
|
||||||
|
|
||||||
|
BeginLineArray(6);
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 1, fCollapseRect.top + 3),
|
||||||
|
BPoint(fCollapseRect.right - 3, fCollapseRect.top + 3), outlineColor);
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 1, fCollapseRect.top + 3),
|
||||||
|
BPoint(fCollapseRect.left + 5, fCollapseRect.top + 7), outlineColor);
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 5, fCollapseRect.top + 7),
|
||||||
|
BPoint(fCollapseRect.right - 3, fCollapseRect.top + 3), outlineColor);
|
||||||
|
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 3, fCollapseRect.top + 4),
|
||||||
|
BPoint(fCollapseRect.right - 5, fCollapseRect.top + 4), middleColor);
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 4, fCollapseRect.top + 5),
|
||||||
|
BPoint(fCollapseRect.right - 6, fCollapseRect.top + 5), middleColor);
|
||||||
|
AddLine(BPoint(fCollapseRect.left + 5, fCollapseRect.top + 5),
|
||||||
|
BPoint(fCollapseRect.left + 5, fCollapseRect.top + 6), middleColor);
|
||||||
|
EndLineArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PushState();
|
|
||||||
SetFont(be_bold_font);
|
|
||||||
SetPenSize(kPenSize);
|
SetPenSize(kPenSize);
|
||||||
|
|
||||||
if (fCollapsed) {
|
|
||||||
// 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();
|
|
||||||
|
|
||||||
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
|
// Draw the dismiss widget
|
||||||
StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding);
|
BRect closeCross = fCloseRect;
|
||||||
|
closeCross.InsetBy(kSmallPadding, kSmallPadding);
|
||||||
|
rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR);
|
||||||
|
detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);
|
||||||
|
|
||||||
|
StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding);
|
||||||
StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
|
StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
|
||||||
StrokeLine(closeCross.RightTop(), closeCross.LeftBottom());
|
StrokeLine(closeCross.RightTop(), closeCross.LeftBottom());
|
||||||
|
|
||||||
// Draw the label
|
// Draw the label
|
||||||
DrawString(label.String(), BPoint(fCollapseRect.right + 2 * kEdgePadding, labelOffset + kEdgePadding));
|
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
PopState();
|
BString label = fLabel;
|
||||||
|
if (fCollapsed)
|
||||||
|
label << " (" << fInfo.size() << ")";
|
||||||
|
|
||||||
Sync();
|
SetFont(be_bold_font);
|
||||||
|
|
||||||
|
DrawString(label.String(), BPoint(fCollapseRect.right + 2 * kEdgePadding,
|
||||||
|
fCloseRect.bottom));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
|
||||||
|
void
|
||||||
AppGroupView::MouseDown(BPoint point)
|
AppGroupView::MouseDown(BPoint point)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
@@ -139,15 +165,38 @@ AppGroupView::MouseDown(BPoint point)
|
|||||||
|
|
||||||
int32 children = fInfo.size();
|
int32 children = fInfo.size();
|
||||||
for (int32 i = 0; i < children; i++) {
|
for (int32 i = 0; i < children; i++) {
|
||||||
fView->GetLayout()->RemoveView(fInfo[i]);
|
GetLayout()->RemoveView(fInfo[i]);
|
||||||
delete fInfo[i];
|
delete fInfo[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
fInfo.clear();
|
fInfo.clear();
|
||||||
|
|
||||||
|
// Remove ourselves from the parent view
|
||||||
|
BMessage message(kRemoveView);
|
||||||
|
message.AddPointer("view", this);
|
||||||
|
fParent->PostMessage(&message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fCollapseRect.Contains(point)) {
|
if (fCollapseRect.Contains(point)) {
|
||||||
fCollapsed = !fCollapsed;
|
fCollapsed = !fCollapsed;
|
||||||
|
int32 children = fInfo.size();
|
||||||
|
if (fCollapsed) {
|
||||||
|
for (int32 i = 0; i < children; i++) {
|
||||||
|
if (!fInfo[i]->IsHidden())
|
||||||
|
fInfo[i]->Hide();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int32 i = 0; i < children; i++) {
|
||||||
|
if (fInfo[i]->IsHidden())
|
||||||
|
fInfo[i]->Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
|
Invalidate(); // Need to redraw the collapse indicator and title
|
||||||
|
|
||||||
|
BMessage message(kRemoveView);
|
||||||
|
// Do not actually remive anything, but update size
|
||||||
|
fParent->PostMessage(&message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
@@ -170,14 +219,14 @@ AppGroupView::MessageReceived(BMessage* msg)
|
|||||||
|
|
||||||
if (vIt != fInfo.end()) {
|
if (vIt != fInfo.end()) {
|
||||||
fInfo.erase(vIt);
|
fInfo.erase(vIt);
|
||||||
fView->GetLayout()->RemoveView(view);
|
GetLayout()->RemoveView(view);
|
||||||
delete view;
|
delete view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ResizeViews();
|
||||||
|
|
||||||
if (Window() != NULL)
|
if (Window() != NULL)
|
||||||
Window()->PostMessage(msg);
|
Window()->PostMessage(msg);
|
||||||
|
|
||||||
_ResizeViews();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -197,7 +246,7 @@ AppGroupView::AddInfo(NotificationView* view)
|
|||||||
|
|
||||||
for (int32 i = 0; i < children; i++) {
|
for (int32 i = 0; i < children; i++) {
|
||||||
if (id == fInfo[i]->MessageID()) {
|
if (id == fInfo[i]->MessageID()) {
|
||||||
fView->GetLayout()->RemoveView(fInfo[i]);
|
GetLayout()->RemoveView(fInfo[i]);
|
||||||
delete fInfo[i];
|
delete fInfo[i];
|
||||||
|
|
||||||
fInfo[i] = view;
|
fInfo[i] = view;
|
||||||
@@ -208,36 +257,25 @@ AppGroupView::AddInfo(NotificationView* view)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found) {
|
||||||
fInfo.push_back(view);
|
fInfo.push_back(view);
|
||||||
fView->GetLayout()->AddView(view);
|
}
|
||||||
|
GetLayout()->AddView(view);
|
||||||
|
|
||||||
if (IsHidden())
|
if (IsHidden())
|
||||||
Show();
|
Show();
|
||||||
if (view->IsHidden())
|
if (view->IsHidden() && !fCollapsed)
|
||||||
view->Show();
|
view->Show();
|
||||||
|
|
||||||
_ResizeViews();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AppGroupView::_ResizeViews()
|
AppGroupView::_ResizeViews()
|
||||||
{
|
{
|
||||||
font_height fh;
|
|
||||||
be_bold_font->GetHeight(&fh);
|
|
||||||
|
|
||||||
float offset = 2 * kEdgePadding + fh.ascent + fh.leading + fh.descent;
|
|
||||||
int32 children = fInfo.size();
|
int32 children = fInfo.size();
|
||||||
|
|
||||||
if (!fCollapsed) {
|
if (!fCollapsed) {
|
||||||
offset += kEdgePadding + kPenSize;
|
|
||||||
|
|
||||||
for (int32 i = 0; i < children; i++) {
|
for (int32 i = 0; i < children; i++) {
|
||||||
fInfo[i]->ResizeToPreferred();
|
|
||||||
fInfo[i]->MoveTo(0, offset);
|
|
||||||
|
|
||||||
offset += fInfo[i]->Bounds().Height();
|
|
||||||
if (fInfo[i]->IsHidden())
|
if (fInfo[i]->IsHidden())
|
||||||
fInfo[i]->Show();
|
fInfo[i]->Show();
|
||||||
}
|
}
|
||||||
@@ -247,22 +285,9 @@ AppGroupView::_ResizeViews()
|
|||||||
fInfo[i]->Hide();
|
fInfo[i]->Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResizeTo(fParent->Width(), offset);
|
if (!IsHidden() && !HasChildren())
|
||||||
float labelOffset = fh.ascent + fh.leading;
|
Hide();
|
||||||
|
fParent->Layout(true);
|
||||||
BRect borderRect = Bounds().InsetByCopy(kEdgePadding, kEdgePadding);
|
|
||||||
borderRect.top = 2*labelOffset;
|
|
||||||
|
|
||||||
fCollapseRect = borderRect;
|
|
||||||
fCollapseRect.right = fCollapseRect.left + kExpandSize;
|
|
||||||
fCollapseRect.bottom = fCollapseRect.top + kExpandSize;
|
|
||||||
fCollapseRect.OffsetTo(kEdgePadding * 2, kEdgePadding * 1.5);
|
|
||||||
|
|
||||||
fCloseRect = borderRect;
|
|
||||||
fCloseRect.right -= kEdgePadding * 2;
|
|
||||||
fCloseRect.top += kEdgePadding * 1.5;
|
|
||||||
fCloseRect.left = fCloseRect.right - kCloseSize;
|
|
||||||
fCloseRect.bottom = fCloseRect.top + kCloseSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <Box.h>
|
#include <GroupView.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
class BGroupView;
|
class BGroupView;
|
||||||
@@ -20,13 +20,13 @@ class NotificationView;
|
|||||||
|
|
||||||
typedef std::vector<NotificationView*> infoview_t;
|
typedef std::vector<NotificationView*> infoview_t;
|
||||||
|
|
||||||
class AppGroupView : public BBox {
|
class AppGroupView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
AppGroupView(NotificationWindow* win, const char* label);
|
AppGroupView(NotificationWindow* win, const char* label);
|
||||||
~AppGroupView();
|
|
||||||
|
|
||||||
virtual void MouseDown(BPoint point);
|
virtual void MouseDown(BPoint point);
|
||||||
virtual void MessageReceived(BMessage* msg);
|
virtual void MessageReceived(BMessage* msg);
|
||||||
|
void Draw(BRect updateRect);
|
||||||
|
|
||||||
bool HasChildren();
|
bool HasChildren();
|
||||||
|
|
||||||
@@ -37,7 +37,6 @@ private:
|
|||||||
|
|
||||||
BString fLabel;
|
BString fLabel;
|
||||||
NotificationWindow* fParent;
|
NotificationWindow* fParent;
|
||||||
BGroupView* fView;
|
|
||||||
infoview_t fInfo;
|
infoview_t fInfo;
|
||||||
bool fCollapsed;
|
bool fCollapsed;
|
||||||
BRect fCloseRect;
|
BRect fCloseRect;
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ property_info message_prop_list[] = {
|
|||||||
NotificationView::NotificationView(NotificationWindow* win,
|
NotificationView::NotificationView(NotificationWindow* win,
|
||||||
BNotification* notification, bigtime_t timeout)
|
BNotification* notification, bigtime_t timeout)
|
||||||
:
|
:
|
||||||
BView("NotificationView", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE
|
BView("NotificationView", B_WILL_DRAW),
|
||||||
| B_FRAME_EVENTS),
|
|
||||||
fParent(win),
|
fParent(win),
|
||||||
fNotification(notification),
|
fNotification(notification),
|
||||||
fTimeout(timeout),
|
fTimeout(timeout),
|
||||||
@@ -65,8 +64,6 @@ NotificationView::NotificationView(NotificationWindow* win,
|
|||||||
BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
|
BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
|
||||||
SetLayout(layout);
|
SetLayout(layout);
|
||||||
|
|
||||||
SetText();
|
|
||||||
|
|
||||||
switch (fNotification->Type()) {
|
switch (fNotification->Type()) {
|
||||||
case B_IMPORTANT_NOTIFICATION:
|
case B_IMPORTANT_NOTIFICATION:
|
||||||
SetViewColor(255, 255, 255);
|
SetViewColor(255, 255, 255);
|
||||||
@@ -87,15 +84,15 @@ NotificationView::NotificationView(NotificationWindow* win,
|
|||||||
label << (int)(fNotification->Progress() * 100) << " %";
|
label << (int)(fNotification->Progress() * 100) << " %";
|
||||||
progress->SetTrailingText(label);
|
progress->SetTrailingText(label);
|
||||||
|
|
||||||
BGroupLayoutBuilder b(layout);
|
layout->AddView(progress);
|
||||||
b.AddGlue()
|
|
||||||
.Add(progress);
|
|
||||||
}
|
}
|
||||||
// fall through
|
// fall through
|
||||||
default:
|
default:
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -284,8 +281,8 @@ NotificationView::Draw(BRect updateRect)
|
|||||||
PopState();
|
PopState();
|
||||||
|
|
||||||
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||||
BPoint left(Bounds().left, Bounds().bottom - 1);
|
BPoint left(Bounds().left, Bounds().top);
|
||||||
BPoint right(Bounds().right, Bounds().bottom - 1);
|
BPoint right(Bounds().right, Bounds().top);
|
||||||
StrokeLine(left, right);
|
StrokeLine(left, right);
|
||||||
|
|
||||||
Sync();
|
Sync();
|
||||||
@@ -367,17 +364,19 @@ NotificationView::MouseDown(BPoint point)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
BSize
|
BSize
|
||||||
NotificationView::MinSize()
|
NotificationView::MinSize()
|
||||||
{
|
{
|
||||||
return BLayoutUtils::ComposeSize(ExplicitMinSize(), _CalculateSize());
|
// return BLayoutUtils::ComposeSize(ExplicitMinSize(), _CalculateSize());
|
||||||
|
return _CalculateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BSize
|
BSize
|
||||||
NotificationView::MaxSize()
|
NotificationView::MaxSize()
|
||||||
{
|
{
|
||||||
return BLayoutUtils::ComposeSize(ExplicitMaxSize(), _CalculateSize());
|
return _CalculateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -387,6 +386,7 @@ NotificationView::PreferredSize()
|
|||||||
return BLayoutUtils::ComposeSize(ExplicitPreferredSize(),
|
return BLayoutUtils::ComposeSize(ExplicitPreferredSize(),
|
||||||
_CalculateSize());
|
_CalculateSize());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
BHandler*
|
BHandler*
|
||||||
@@ -524,6 +524,8 @@ NotificationView::SetText(float newMaxWidth)
|
|||||||
// enough.
|
// enough.
|
||||||
static_cast<BGroupLayout*>(GetLayout())->SetInsets(kIconStripeWidth + 8,
|
static_cast<BGroupLayout*>(GetLayout())->SetInsets(kIconStripeWidth + 8,
|
||||||
fHeight, 8, 8);
|
fHeight, 8, 8);
|
||||||
|
|
||||||
|
_CalculateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -539,16 +541,19 @@ NotificationView::_CalculateSize()
|
|||||||
{
|
{
|
||||||
BSize size;
|
BSize size;
|
||||||
|
|
||||||
// Parent width, minus the edge padding, minus the pensize
|
size.width = 300;
|
||||||
size.width = B_SIZE_UNLIMITED;
|
|
||||||
size.height = fHeight;
|
size.height = fHeight;
|
||||||
|
|
||||||
if (fNotification->Type() == B_PROGRESS_NOTIFICATION) {
|
if (fNotification->Type() == B_PROGRESS_NOTIFICATION) {
|
||||||
font_height fh;
|
font_height fh;
|
||||||
be_plain_font->GetHeight(&fh);
|
be_plain_font->GetHeight(&fh);
|
||||||
float fontHeight = fh.ascent + fh.descent + fh.leading;
|
float fontHeight = fh.ascent + fh.descent + fh.leading;
|
||||||
size.height += (kSmallPadding * 2) + (kEdgePadding * 1) + fontHeight;
|
size.height += 9 + (kSmallPadding * 2) + (kEdgePadding * 1)
|
||||||
|
+ fontHeight * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetExplicitMinSize(size);
|
||||||
|
SetExplicitMaxSize(size);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ public:
|
|||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void MouseDown(BPoint point);
|
virtual void MouseDown(BPoint point);
|
||||||
|
|
||||||
|
/*
|
||||||
virtual BSize MinSize();
|
virtual BSize MinSize();
|
||||||
virtual BSize MaxSize();
|
virtual BSize MaxSize();
|
||||||
virtual BSize PreferredSize();
|
virtual BSize PreferredSize();
|
||||||
|
*/
|
||||||
|
|
||||||
virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index,
|
virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index,
|
||||||
BMessage* specifier, int32 form,
|
BMessage* specifier, int32 form,
|
||||||
|
|||||||
@@ -64,11 +64,12 @@ NotificationWindow::NotificationWindow()
|
|||||||
{
|
{
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL, 0));
|
SetLayout(new BGroupLayout(B_VERTICAL, 0));
|
||||||
|
|
||||||
Hide();
|
|
||||||
Show();
|
|
||||||
|
|
||||||
_LoadSettings(true);
|
_LoadSettings(true);
|
||||||
_LoadAppFilters(true);
|
_LoadAppFilters(true);
|
||||||
|
|
||||||
|
// Start the message loop
|
||||||
|
Hide();
|
||||||
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -189,6 +190,7 @@ NotificationWindow::MessageReceived(BMessage* message)
|
|||||||
group->AddInfo(view);
|
group->AddInfo(view);
|
||||||
|
|
||||||
_ResizeAll();
|
_ResizeAll();
|
||||||
|
SetPosition();
|
||||||
|
|
||||||
reply.AddInt32("error", B_OK);
|
reply.AddInt32("error", B_OK);
|
||||||
} else
|
} else
|
||||||
@@ -213,6 +215,7 @@ NotificationWindow::MessageReceived(BMessage* message)
|
|||||||
fViews.erase(it);
|
fViews.erase(it);
|
||||||
|
|
||||||
_ResizeAll();
|
_ResizeAll();
|
||||||
|
SetPosition();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -317,45 +320,31 @@ NotificationWindow::_ResizeAll()
|
|||||||
if (IsHidden())
|
if (IsHidden())
|
||||||
Show();
|
Show();
|
||||||
|
|
||||||
float width = 0;
|
|
||||||
float height = 0;
|
|
||||||
|
|
||||||
for (aIt = fAppViews.begin(); aIt != fAppViews.end(); aIt++) {
|
for (aIt = fAppViews.begin(); aIt != fAppViews.end(); aIt++) {
|
||||||
AppGroupView* view = aIt->second;
|
AppGroupView* view = aIt->second;
|
||||||
float w = -1;
|
|
||||||
float h = -1;
|
|
||||||
|
|
||||||
if (!view->HasChildren()) {
|
if (!view->HasChildren()) {
|
||||||
if (!view->IsHidden())
|
if (!view->IsHidden())
|
||||||
view->Hide();
|
view->Hide();
|
||||||
} else {
|
} else {
|
||||||
view->GetPreferredSize(&w, &h);
|
|
||||||
width = max_c(width, h);
|
|
||||||
|
|
||||||
view->ResizeToPreferred();
|
|
||||||
view->MoveTo(0, height);
|
|
||||||
|
|
||||||
height += h;
|
|
||||||
|
|
||||||
if (view->IsHidden())
|
if (view->IsHidden())
|
||||||
view->Show();
|
view->Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResizeTo(Width(), height);
|
|
||||||
PopupAnimation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NotificationWindow::SetPosition()
|
NotificationWindow::SetPosition()
|
||||||
{
|
{
|
||||||
|
Layout(true);
|
||||||
|
|
||||||
BRect bounds = DecoratorFrame();
|
BRect bounds = DecoratorFrame();
|
||||||
float width = Bounds().Width() + 1;
|
float width = Bounds().Width() + 1;
|
||||||
float height = Bounds().Height() + 1;
|
float height = Bounds().Height() + 1;
|
||||||
|
|
||||||
float leftOffset = Frame().left - bounds.left;
|
float leftOffset = Frame().left - bounds.left;
|
||||||
float topOffset = Frame().top - bounds.top;
|
float topOffset = Frame().top - bounds.top + 1;
|
||||||
float rightOffset = bounds.right - Frame().right;
|
float rightOffset = bounds.right - Frame().right;
|
||||||
float bottomOffset = bounds.bottom - Frame().bottom;
|
float bottomOffset = bounds.bottom - Frame().bottom;
|
||||||
// Size of the borders around the window
|
// Size of the borders around the window
|
||||||
@@ -370,27 +359,27 @@ NotificationWindow::SetPosition()
|
|||||||
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 + topOffset;
|
y = frame.bottom + topOffset;
|
||||||
x = frame.right - width - rightOffset;
|
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
|
||||||
y = frame.top - height - bottomOffset;
|
y = frame.top - height - bottomOffset;
|
||||||
x = frame.right - width - rightOffset;
|
x = frame.right - width + rightOffset;
|
||||||
break;
|
break;
|
||||||
case B_DESKBAR_RIGHT_TOP:
|
case B_DESKBAR_RIGHT_TOP:
|
||||||
x = frame.left - width - rightOffset;
|
x = frame.left - width - rightOffset;
|
||||||
y = frame.top + topOffset;
|
y = frame.top - topOffset;
|
||||||
break;
|
break;
|
||||||
case B_DESKBAR_LEFT_TOP:
|
case B_DESKBAR_LEFT_TOP:
|
||||||
x = frame.right + leftOffset;
|
x = frame.right + leftOffset;
|
||||||
y = frame.top + topOffset;
|
y = frame.top - topOffset;
|
||||||
break;
|
break;
|
||||||
case B_DESKBAR_RIGHT_BOTTOM:
|
case B_DESKBAR_RIGHT_BOTTOM:
|
||||||
y = frame.bottom - height - bottomOffset;
|
y = frame.bottom - height + bottomOffset;
|
||||||
x = frame.left - width - rightOffset;
|
x = frame.left - width - rightOffset;
|
||||||
break;
|
break;
|
||||||
case B_DESKBAR_LEFT_BOTTOM:
|
case B_DESKBAR_LEFT_BOTTOM:
|
||||||
y = frame.bottom - height - bottomOffset;
|
y = frame.bottom - height + bottomOffset;
|
||||||
x = frame.right + leftOffset;
|
x = frame.right + leftOffset;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -400,16 +389,6 @@ NotificationWindow::SetPosition()
|
|||||||
MoveTo(x, y);
|
MoveTo(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
NotificationWindow::PopupAnimation()
|
|
||||||
{
|
|
||||||
SetPosition();
|
|
||||||
|
|
||||||
if (IsHidden())
|
|
||||||
Show();
|
|
||||||
// Activate();// it hides floaters from apps :-(
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NotificationWindow::_LoadSettings(bool startMonitor)
|
NotificationWindow::_LoadSettings(bool startMonitor)
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ private:
|
|||||||
friend class AppGroupView;
|
friend class AppGroupView;
|
||||||
|
|
||||||
void SetPosition();
|
void SetPosition();
|
||||||
void PopupAnimation();
|
|
||||||
void _LoadSettings(bool startMonitor = false);
|
void _LoadSettings(bool startMonitor = false);
|
||||||
void _LoadAppFilters(bool startMonitor = false);
|
void _LoadAppFilters(bool startMonitor = false);
|
||||||
void _SaveAppFilters();
|
void _SaveAppFilters();
|
||||||
|
|||||||
Reference in New Issue
Block a user