Commit fe28550d authored by sadrul@chromium.org's avatar sadrul@chromium.org

ash: Highlight the items in the uber-tray popup when hovering.

Since the items are already highlighted, remove underlining on hover for
'Settings' entry.

BUG=118328
TEST=none

Review URL: https://chromiumcodereview.appspot.com/9703078

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126971 0039d316-1c4b-4281-b951-d872f2087c98
parent 7fc22cb9
......@@ -45,20 +45,6 @@ class SettingsView : public views::View {
return true;
}
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE {
gfx::Font font = label_->font();
label_->SetFont(font.DeriveFont(0,
font.GetStyle() | gfx::Font::UNDERLINED));
SchedulePaint();
}
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE {
gfx::Font font = label_->font();
label_->SetFont(font.DeriveFont(0,
font.GetStyle() & ~gfx::Font::UNDERLINED));
SchedulePaint();
}
private:
views::Label* label_;
......
......@@ -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));
}
}
......
......@@ -19,14 +19,15 @@ views::View* TrayEmpty::CreateTrayView(user::LoginStatus status) {
}
views::View* TrayEmpty::CreateDefaultView(user::LoginStatus status) {
views::View* view = new views::View;
if (status == user::LOGGED_IN_NONE)
return NULL;
views::View* view = new views::View;
view->set_background(views::Background::CreateSolidBackground(
SkColorSetARGB(0, 0, 0, 0)));
view->set_border(views::Border::CreateEmptyBorder(10, 0, 0, 0));
view->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
0, 0, 0));
return view;
}
......
......@@ -104,6 +104,7 @@ class UserView : public views::View,
CHECK(status != ash::user::LOGGED_IN_NONE);
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
0, 0, 0));
set_background(views::Background::CreateSolidBackground(SK_ColorWHITE));
if (status != ash::user::LOGGED_IN_GUEST)
AddUserInfo();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment