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..a0d9e6adc6914bebe678e17d68c0255cc46ae603 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: |
+ // Overrridden from views::Background. |
Ben Goodger (Google)
2012/03/05 22:54:37
2 rs
sadrul
2012/03/05 22:58:43
Done.
|
+ 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; |