@@ -31,7 +31,8 @@ AppGroupView::AppGroupView(NotificationWindow* win, const char* label)
|
|||||||
BGroupView("appGroup", B_VERTICAL, 0),
|
BGroupView("appGroup", B_VERTICAL, 0),
|
||||||
fLabel(label),
|
fLabel(label),
|
||||||
fParent(win),
|
fParent(win),
|
||||||
fCollapsed(false)
|
fCollapsed(false),
|
||||||
|
fCloseClicked(false)
|
||||||
{
|
{
|
||||||
SetFlags(Flags() | B_WILL_DRAW);
|
SetFlags(Flags() | B_WILL_DRAW);
|
||||||
|
|
||||||
@@ -78,14 +79,7 @@ AppGroupView::Draw(BRect updateRect)
|
|||||||
SetPenSize(kPenSize);
|
SetPenSize(kPenSize);
|
||||||
|
|
||||||
// Draw the dismiss widget
|
// Draw the dismiss widget
|
||||||
BRect closeCross = fCloseRect;
|
_DrawCloseButton(updateRect);
|
||||||
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());
|
|
||||||
|
|
||||||
// Draw the label
|
// Draw the label
|
||||||
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
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
|
void
|
||||||
AppGroupView::MouseDown(BPoint point)
|
AppGroupView::MouseDown(BPoint point)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,12 +35,15 @@ public:
|
|||||||
const BString& Group() const;
|
const BString& Group() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _DrawCloseButton(const BRect& updateRect);
|
||||||
|
|
||||||
BString fLabel;
|
BString fLabel;
|
||||||
NotificationWindow* fParent;
|
NotificationWindow* fParent;
|
||||||
infoview_t fInfo;
|
infoview_t fInfo;
|
||||||
bool fCollapsed;
|
bool fCollapsed;
|
||||||
BRect fCloseRect;
|
BRect fCloseRect;
|
||||||
BRect fCollapseRect;
|
BRect fCollapseRect;
|
||||||
|
bool fCloseClicked;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _APP_GROUP_VIEW_H
|
#endif // _APP_GROUP_VIEW_H
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
#include <LayoutUtils.h>
|
#include <LayoutUtils.h>
|
||||||
#include <MessageRunner.h>
|
#include <MessageRunner.h>
|
||||||
@@ -58,7 +59,8 @@ NotificationView::NotificationView(NotificationWindow* win,
|
|||||||
fNotification(notification),
|
fNotification(notification),
|
||||||
fTimeout(timeout),
|
fTimeout(timeout),
|
||||||
fRunner(NULL),
|
fRunner(NULL),
|
||||||
fBitmap(NULL)
|
fBitmap(NULL),
|
||||||
|
fCloseClicked(false)
|
||||||
{
|
{
|
||||||
if (fNotification->Icon() != NULL)
|
if (fNotification->Icon() != NULL)
|
||||||
fBitmap = new BBitmap(fNotification->Icon());
|
fBitmap = new BBitmap(fNotification->Icon());
|
||||||
@@ -271,19 +273,7 @@ NotificationView::Draw(BRect updateRect)
|
|||||||
rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR);
|
rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR);
|
||||||
detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);
|
detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);
|
||||||
|
|
||||||
// Draw the close widget
|
_DrawCloseButton(updateRect);
|
||||||
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();
|
|
||||||
|
|
||||||
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
|
||||||
BPoint left(Bounds().left, Bounds().top);
|
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
|
void
|
||||||
NotificationView::MouseDown(BPoint point)
|
NotificationView::MouseDown(BPoint point)
|
||||||
{
|
{
|
||||||
@@ -355,6 +378,8 @@ NotificationView::MouseDown(BPoint point)
|
|||||||
be_roster->Launch(fNotification->OnClickApp(), &messages);
|
be_roster->Launch(fNotification->OnClickApp(), &messages);
|
||||||
else
|
else
|
||||||
be_roster->Launch(fNotification->OnClickFile(), &messages);
|
be_roster->Launch(fNotification->OnClickFile(), &messages);
|
||||||
|
} else {
|
||||||
|
fCloseClicked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the info view after a click
|
// Remove the info view after a click
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void _CalculateSize();
|
void _CalculateSize();
|
||||||
|
void _DrawCloseButton(const BRect& updateRect);
|
||||||
|
|
||||||
struct LineInfo {
|
struct LineInfo {
|
||||||
BFont font;
|
BFont font;
|
||||||
@@ -68,10 +69,9 @@ private:
|
|||||||
BMessageRunner* fRunner;
|
BMessageRunner* fRunner;
|
||||||
|
|
||||||
BBitmap* fBitmap;
|
BBitmap* fBitmap;
|
||||||
|
|
||||||
LineInfoList fLines;
|
LineInfoList fLines;
|
||||||
|
|
||||||
float fHeight;
|
float fHeight;
|
||||||
|
bool fCloseClicked;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _NOTIFICATION_VIEW_H
|
#endif // _NOTIFICATION_VIEW_H
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ property_info main_prop_list[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const float kCloseSize = 8;
|
const float kCloseSize = 6;
|
||||||
const float kExpandSize = 8;
|
const float kExpandSize = 8;
|
||||||
const float kPenSize = 1;
|
const float kPenSize = 1;
|
||||||
const float kEdgePadding = 2;
|
const float kEdgePadding = 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user