Use Web+ tabs close button

Fixes #9566
This commit is contained in:
Adrien Destugues - PulkoMandy 2012-11-05 19:21:06 +01:00
parent a0e690928b
commit 82a674605b
5 changed files with 81 additions and 26 deletions

View File

@ -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)
{

View File

@ -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

View File

@ -18,6 +18,7 @@
#include <Bitmap.h>
#include <ControlLook.h>
#include <GroupLayout.h>
#include <LayoutUtils.h>
#include <MessageRunner.h>
@ -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

View File

@ -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

View File

@ -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;