diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index 9266c3aa4c..450476f80a 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -31,7 +31,8 @@ AppGroupView::AppGroupView(NotificationWindow* win, const char* label) BGroupView("appGroup", B_VERTICAL, 0), fLabel(label), fParent(win), - fCollapsed(false) + fCollapsed(false), + fCloseClicked(false) { SetFlags(Flags() | B_WILL_DRAW); @@ -78,14 +79,7 @@ AppGroupView::Draw(BRect updateRect) SetPenSize(kPenSize); // Draw the dismiss widget - 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.RightTop(), closeCross.LeftBottom()); + _DrawCloseButton(updateRect); // Draw the label SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); @@ -100,6 +94,39 @@ AppGroupView::Draw(BRect updateRect) } +void +AppGroupView::_DrawCloseButton(const BRect& updateRect) +{ + PushState(); + BRect closeRect = Bounds(); + + closeRect.InsetBy(7, 7); + closeRect.left = closeRect.right - kCloseSize; + closeRect.bottom = closeRect.top + kCloseSize; + + rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + float tint = B_DARKEN_2_TINT; + + if (fCloseClicked) { + BRect buttonRect(closeRect.InsetByCopy(-4, -4)); + be_control_look->DrawButtonFrame(this, buttonRect, updateRect, + base, base, + BControlLook::B_ACTIVATED | BControlLook::B_BLEND_FRAME); + be_control_look->DrawButtonBackground(this, buttonRect, updateRect, + base, BControlLook::B_ACTIVATED); + tint *= 1.2; + closeRect.OffsetBy(1, 1); + } + + base = tint_color(base, tint); + SetHighColor(base); + SetPenSize(2); + StrokeLine(closeRect.LeftTop(), closeRect.RightBottom()); + StrokeLine(closeRect.LeftBottom(), closeRect.RightTop()); + PopState(); +} + + void AppGroupView::MouseDown(BPoint point) { diff --git a/src/servers/notification/AppGroupView.h b/src/servers/notification/AppGroupView.h index 0c1406d56d..10f9e60cc2 100644 --- a/src/servers/notification/AppGroupView.h +++ b/src/servers/notification/AppGroupView.h @@ -35,12 +35,15 @@ public: const BString& Group() const; private: + void _DrawCloseButton(const BRect& updateRect); + BString fLabel; NotificationWindow* fParent; infoview_t fInfo; bool fCollapsed; BRect fCloseRect; BRect fCollapseRect; + bool fCloseClicked; }; #endif // _APP_GROUP_VIEW_H diff --git a/src/servers/notification/NotificationView.cpp b/src/servers/notification/NotificationView.cpp index 3bfff101bd..f5a2994fe2 100644 --- a/src/servers/notification/NotificationView.cpp +++ b/src/servers/notification/NotificationView.cpp @@ -18,6 +18,7 @@ #include +#include #include #include #include @@ -58,7 +59,8 @@ NotificationView::NotificationView(NotificationWindow* win, fNotification(notification), fTimeout(timeout), fRunner(NULL), - fBitmap(NULL) + fBitmap(NULL), + fCloseClicked(false) { if (fNotification->Icon() != NULL) fBitmap = new BBitmap(fNotification->Icon()); @@ -271,19 +273,7 @@ NotificationView::Draw(BRect updateRect) rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR); detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT); - // Draw the close widget - BRect closeRect = Bounds(); - closeRect.InsetBy(2 * kEdgePadding, 2 * kEdgePadding); - closeRect.left = closeRect.right - kCloseSize; - closeRect.bottom = closeRect.top + kCloseSize; - - PushState(); - SetHighColor(detailCol); - StrokeRoundRect(closeRect, kSmallPadding, kSmallPadding); - BRect closeCross = closeRect.InsetByCopy(kSmallPadding, kSmallPadding); - StrokeLine(closeCross.LeftTop(), closeCross.RightBottom()); - StrokeLine(closeCross.LeftBottom(), closeCross.RightTop()); - PopState(); + _DrawCloseButton(updateRect); SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); BPoint left(Bounds().left, Bounds().top); @@ -294,6 +284,39 @@ NotificationView::Draw(BRect updateRect) } +void +NotificationView::_DrawCloseButton(const BRect& updateRect) +{ + PushState(); + BRect closeRect = Bounds(); + + closeRect.InsetBy(3 * kEdgePadding, 3 * kEdgePadding); + closeRect.left = closeRect.right - kCloseSize; + closeRect.bottom = closeRect.top + kCloseSize; + + rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + float tint = B_DARKEN_2_TINT; + + if (fCloseClicked) { + BRect buttonRect(closeRect.InsetByCopy(-4, -4)); + be_control_look->DrawButtonFrame(this, buttonRect, updateRect, + base, base, + BControlLook::B_ACTIVATED | BControlLook::B_BLEND_FRAME); + be_control_look->DrawButtonBackground(this, buttonRect, updateRect, + base, BControlLook::B_ACTIVATED); + tint *= 1.2; + closeRect.OffsetBy(1, 1); + } + + base = tint_color(base, tint); + SetHighColor(base); + SetPenSize(2); + StrokeLine(closeRect.LeftTop(), closeRect.RightBottom()); + StrokeLine(closeRect.LeftBottom(), closeRect.RightTop()); + PopState(); +} + + void NotificationView::MouseDown(BPoint point) { @@ -355,6 +378,8 @@ NotificationView::MouseDown(BPoint point) be_roster->Launch(fNotification->OnClickApp(), &messages); else be_roster->Launch(fNotification->OnClickFile(), &messages); + } else { + fCloseClicked = true; } // Remove the info view after a click diff --git a/src/servers/notification/NotificationView.h b/src/servers/notification/NotificationView.h index 37ed61c7da..4653c66df9 100644 --- a/src/servers/notification/NotificationView.h +++ b/src/servers/notification/NotificationView.h @@ -52,6 +52,7 @@ public: private: void _CalculateSize(); + void _DrawCloseButton(const BRect& updateRect); struct LineInfo { BFont font; @@ -68,10 +69,9 @@ private: BMessageRunner* fRunner; BBitmap* fBitmap; - LineInfoList fLines; - float fHeight; + bool fCloseClicked; }; #endif // _NOTIFICATION_VIEW_H diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp index 5a901469b8..be8e670c1d 100644 --- a/src/servers/notification/NotificationWindow.cpp +++ b/src/servers/notification/NotificationWindow.cpp @@ -48,7 +48,7 @@ property_info main_prop_list[] = { }; -const float kCloseSize = 8; +const float kCloseSize = 6; const float kExpandSize = 8; const float kPenSize = 1; const float kEdgePadding = 2;