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

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

Issue 9703078: ash: Highlight the items in the uber-tray popup when hovering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 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/settings/tray_settings.cc ('k') | ash/system/tray/tray_empty.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 879a00ba12690c2de941c021a1f283269fd67b8c..3dc143c364e2e9a6abde7f281228077fdf443e49 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -25,6 +25,7 @@
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/label.h"
+#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/view.h"
@@ -47,11 +48,56 @@ const int kShadowHeight = 3;
const SkColor kDarkColor = SkColorSetRGB(120, 120, 120);
const SkColor kLightColor = SkColorSetRGB(240, 240, 240);
const SkColor kBackgroundColor = SK_ColorWHITE;
+const SkColor kHoverBackgroundColor = SkColorSetRGB(0xfb, 0xfc, 0xfb);
const SkColor kShadowColor = SkColorSetARGB(25, 0, 0, 0);
const SkColor kTrayBackgroundColor = SkColorSetARGB(100, 0, 0, 0);
const SkColor kTrayBackgroundHover = SkColorSetARGB(150, 0, 0, 0);
+// A view with some special behaviour for tray items:
+// - changes background color on hover.
+// - TODO: accessibility
+class TrayItemContainer : public views::View {
+ public:
+ explicit TrayItemContainer(views::View* view) : hover_(false) {
+ set_notify_enter_exit_on_child(true);
+ set_border(view->border() ? views::Border::CreateEmptyBorder(0, 0, 0, 0) :
+ NULL);
+ SetLayoutManager(new views::FillLayout);
+ AddChildView(view);
+ }
+
+ virtual ~TrayItemContainer() {}
+
+ private:
+ // Overridden from views::View.
+ virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE {
+ hover_ = true;
+ SchedulePaint();
+ }
+
+ virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE {
+ hover_ = false;
+ SchedulePaint();
+ }
+
+ virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE {
+ views::View* view = child_at(0);
+ if (!view->background()) {
+ canvas->FillRect(gfx::Rect(size()),
+ hover_ ? kHoverBackgroundColor : kBackgroundColor);
+ } else {
+ canvas->FillRect(gfx::Rect(view->x() + kShadowOffset, view->y(),
+ view->width() - kShadowOffset, kShadowHeight),
+ kShadowColor);
+ }
+ }
+
+ bool hover_;
+
+ DISALLOW_COPY_AND_ASSIGN(TrayItemContainer);
+};
+
class SystemTrayBubbleBackground : public views::Background {
public:
explicit SystemTrayBubbleBackground(views::View* owner)
@@ -67,14 +113,6 @@ class SystemTrayBubbleBackground : public views::Background {
for (int i = 0; i < owner_->child_count(); i++) {
views::View* v = owner_->child_at(i);
- if (!v->background()) {
- canvas->FillRect(v->bounds(), kBackgroundColor);
- } else if (last_view) {
- canvas->FillRect(gfx::Rect(v->x() + kShadowOffset, v->y(),
- v->width() - kShadowOffset, kShadowHeight),
- kShadowColor);
- }
-
if (!v->border()) {
canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1),
gfx::Point(v->x() + v->width() + 1, v->y() - 1),
@@ -247,7 +285,7 @@ class SystemTrayBubble : public views::BubbleDelegateView {
views::View* view = detailed_ ? (*it)->CreateDetailedView(login_status) :
(*it)->CreateDefaultView(login_status);
if (view)
- AddChildView(view);
+ AddChildView(new TrayItemContainer(view));
}
}
« no previous file with comments | « ash/system/settings/tray_settings.cc ('k') | ash/system/tray/tray_empty.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698