Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2316)

Unified Diff: ash/system/tray/system_tray.cc

Issue 9594011: ash uber tray: Make the tray background rounded. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/wm/shelf_layout_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/system_tray.cc
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 8862e810bf58963f6255245ee3b19f9d1f46fb3c..ccf1f21caefd40a58af5bdcfa30a8434e279d3c5 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -19,6 +19,7 @@
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkPath.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/skia_util.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/label.h"
@@ -41,6 +42,9 @@ const SkColor kLightColor = SkColorSetRGB(240, 240, 240);
const SkColor kBackgroundColor = SK_ColorWHITE;
const SkColor kShadowColor = SkColorSetARGB(25, 0, 0, 0);
+const SkColor kTrayBackgroundColor = SkColorSetARGB(100, 0, 0, 0);
+const SkColor kTrayBackgroundHover = SkColorSetARGB(150, 0, 0, 0);
+
class SystemTrayBubbleBackground : public views::Background {
public:
explicit SystemTrayBubbleBackground(views::View* owner)
@@ -229,6 +233,32 @@ class SystemTrayBubble : public views::BubbleDelegateView {
DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble);
};
+class SystemTrayBackground : public views::Background {
+ public:
+ SystemTrayBackground() : hovering_(false) {}
+ virtual ~SystemTrayBackground() {}
+
+ void set_hovering(bool hover) { hovering_ = hover; }
+
+ private:
+ // Overridden from views::Background.
+ virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(hovering_ ? kTrayBackgroundHover : kTrayBackgroundColor);
+ SkPath path;
+ gfx::Rect bounds(view->GetContentsBounds());
+ SkScalar radius = SkIntToScalar(4);
+ path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius);
+ canvas->GetSkCanvas()->drawPath(path, paint);
+ }
+
+ bool hovering_;
+
+ DISALLOW_COPY_AND_ASSIGN(SystemTrayBackground);
+};
+
} // namespace internal
SystemTray::SystemTray()
@@ -237,8 +267,8 @@ SystemTray::SystemTray()
popup_(NULL) {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
5, 0, 3));
- set_background(views::Background::CreateSolidBackground(
- SkColorSetARGB(127, 0, 0, 0)));
+ set_background(new SystemTrayBackground);
+ set_notify_enter_exit_on_child(true);
}
SystemTray::~SystemTray() {
@@ -320,6 +350,16 @@ bool SystemTray::OnMousePressed(const views::MouseEvent& event) {
return true;
}
+void SystemTray::OnMouseEntered(const views::MouseEvent& event) {
+ static_cast<SystemTrayBackground*>(background())->set_hovering(true);
+ SchedulePaint();
+}
+
+void SystemTray::OnMouseExited(const views::MouseEvent& event) {
+ static_cast<SystemTrayBackground*>(background())->set_hovering(false);
+ SchedulePaint();
+}
+
void SystemTray::OnWidgetClosing(views::Widget* widget) {
CHECK_EQ(popup_, widget);
popup_ = NULL;
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/wm/shelf_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698