summaryrefslogtreecommitdiffstats
path: root/ash/system/tray
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 00:22:01 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 00:22:01 +0000
commitb2976afb1147c2b71eb8b7fe08bad0d30a59c615 (patch)
treef1f678bf6f59561d286db75f01f5d9a830449502 /ash/system/tray
parent4b4ed5882820d2293ec5d30d8eb7518ac5b360ed (diff)
downloadchromium_src-b2976afb1147c2b71eb8b7fe08bad0d30a59c615.zip
chromium_src-b2976afb1147c2b71eb8b7fe08bad0d30a59c615.tar.gz
chromium_src-b2976afb1147c2b71eb8b7fe08bad0d30a59c615.tar.bz2
Changes the background color of status area.
As is described in crbug.com/235992, the new status area will be: - as-is dark background, hover changes color gradually - when click, the background changes to blue color - the color and behavior should be shared among web notification and tray - the height should be same. This CL doesn't change the user icon layout. It will be done in another CL. BUG=235992 R=derat@chromium.org, stevenjb@chromium.org Review URL: https://codereview.chromium.org/14198020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197529 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system/tray')
-rw-r--r--ash/system/tray/system_tray.cc3
-rw-r--r--ash/system/tray/tray_background_view.cc58
-rw-r--r--ash/system/tray/tray_background_view.h5
3 files changed, 56 insertions, 10 deletions
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index ce3a81a..2fc3411 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -334,6 +334,7 @@ bool SystemTray::HasSystemBubbleType(SystemTrayBubble::BubbleType type) {
void SystemTray::DestroySystemBubble() {
system_bubble_.reset();
detailed_item_ = NULL;
+ SetBubbleVisible(false);
}
void SystemTray::DestroyNotificationBubble() {
@@ -412,6 +413,7 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
SystemTrayBubble* bubble = new SystemTrayBubble(this, items, bubble_type);
system_bubble_.reset(new internal::SystemBubbleWrapper(bubble));
system_bubble_->InitView(this, tray_container(), &init_params);
+ SetBubbleVisible(true);
}
// Save height of default view for creating detailed views directly.
if (!detailed)
@@ -475,6 +477,7 @@ void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
UpdateAfterShelfAlignmentChange(alignment);
// Destroy any existing bubble so that it is rebuilt correctly.
system_bubble_.reset();
+ SetBubbleVisible(false);
// Rebuild any notification bubble.
if (notification_bubble_) {
notification_bubble_.reset();
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index 6a67a9e..3f51d62a 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -27,8 +27,9 @@
namespace {
-const SkColor kTrayBackgroundAlpha = 100;
-const SkColor kTrayBackgroundHoverAlpha = 150;
+const int kTrayBackgroundAlpha = 100;
+const int kTrayBackgroundHoverAlpha = 150;
+const SkColor kTrayBackgroundPressedColor = SkColorSetRGB(66, 129, 244);
// Adjust the size of TrayContainer with additional padding.
const int kTrayContainerVerticalPaddingBottomAlignment = 1;
@@ -71,10 +72,15 @@ class TrayBackgroundView::TrayWidgetObserver : public views::WidgetObserver {
class TrayBackground : public views::Background {
public:
- TrayBackground() : alpha_(kTrayBackgroundAlpha) {}
+ TrayBackground() {
+ set_alpha(kTrayBackgroundAlpha);
+ }
+
virtual ~TrayBackground() {}
- void set_alpha(int alpha) { alpha_ = alpha; }
+ SkColor color() { return color_; }
+ void set_color(SkColor color) { color_ = color; }
+ void set_alpha(int alpha) { color_ = SkColorSetARGB(alpha, 0, 0, 0); }
private:
// Overridden from views::Background.
@@ -82,7 +88,7 @@ class TrayBackground : public views::Background {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kFill_Style);
- paint.setColor(SkColorSetARGB(alpha_, 0, 0, 0));
+ paint.setColor(color_);
SkPath path;
gfx::Rect bounds(view->GetLocalBounds());
SkScalar radius = SkIntToScalar(kTrayRoundedBorderRadius);
@@ -90,7 +96,7 @@ class TrayBackground : public views::Background {
canvas->DrawPath(path, paint);
}
- int alpha_;
+ SkColor color_;
DISALLOW_COPY_AND_ASSIGN(TrayBackground);
};
@@ -169,6 +175,8 @@ TrayBackgroundView::TrayBackgroundView(
hide_background_animator_(this, 0, kTrayBackgroundAlpha),
hover_background_animator_(
this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha),
+ hovered_(false),
+ pressed_(false),
widget_observer_(new TrayWidgetObserver(this)) {
set_notify_enter_exit_on_child(true);
@@ -193,11 +201,23 @@ void TrayBackgroundView::Initialize() {
}
void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) {
+ hovered_ = true;
+ if (!background_)
+ return;
+ if (pressed_)
+ return;
+
hover_background_animator_.SetPaintsBackground(true,
internal::BackgroundAnimator::CHANGE_ANIMATE);
}
void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) {
+ hovered_ = false;
+ if (!background_)
+ return;
+ if (pressed_)
+ return;
+
hover_background_animator_.SetPaintsBackground(false,
internal::BackgroundAnimator::CHANGE_ANIMATE);
}
@@ -231,10 +251,13 @@ bool TrayBackgroundView::PerformAction(const ui::Event& event) {
}
void TrayBackgroundView::UpdateBackground(int alpha) {
- if (background_) {
- background_->set_alpha(hide_background_animator_.alpha() +
- hover_background_animator_.alpha());
- }
+ if (!background_)
+ return;
+ if (pressed_)
+ return;
+
+ background_->set_alpha(hide_background_animator_.alpha() +
+ hover_background_animator_.alpha());
SchedulePaint();
}
@@ -378,6 +401,21 @@ TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const {
return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM;
}
+void TrayBackgroundView::SetBubbleVisible(bool visible) {
+ pressed_ = visible;
+ if (!background_)
+ return;
+
+ // Do not change gradually, changing color between grey and blue is weird.
+ if (pressed_)
+ background_->set_color(kTrayBackgroundPressedColor);
+ else if (hovered_)
+ background_->set_alpha(kTrayBackgroundHoverAlpha);
+ else
+ background_->set_alpha(kTrayBackgroundAlpha);
+ SchedulePaint();
+}
+
void TrayBackgroundView::UpdateBubbleViewArrow(
views::TrayBubbleView* bubble_view) {
aura::RootWindow* root_window =
diff --git a/ash/system/tray/tray_background_view.h b/ash/system/tray/tray_background_view.h
index 07db9f1..15597ba 100644
--- a/ash/system/tray/tray_background_view.h
+++ b/ash/system/tray/tray_background_view.h
@@ -121,6 +121,9 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
// Returns the bubble anchor alignment based on |shelf_alignment_|.
views::TrayBubbleView::AnchorAlignment GetAnchorAlignment() const;
+ // Updates the view visual based on the visibility of the bubble.
+ void SetBubbleVisible(bool visible);
+
StatusAreaWidget* status_area_widget() {
return status_area_widget_;
}
@@ -157,6 +160,8 @@ class ASH_EXPORT TrayBackgroundView : public ActionableView,
internal::BackgroundAnimator hide_background_animator_;
internal::BackgroundAnimator hover_background_animator_;
+ bool hovered_;
+ bool pressed_;
scoped_ptr<TrayWidgetObserver> widget_observer_;
scoped_ptr<TrayEventFilter> tray_event_filter_;