diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-25 22:56:14 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-25 22:56:14 +0000 |
commit | 82ea9c699e624955fefa774fbf495a1eb5583fd9 (patch) | |
tree | 876659c27589b5b398b07bb530850b032b39ccff /ash/system | |
parent | 64f85cf5e3fccefb52b4e2398f58450cf9ea7e1b (diff) | |
download | chromium_src-82ea9c699e624955fefa774fbf495a1eb5583fd9.zip chromium_src-82ea9c699e624955fefa774fbf495a1eb5583fd9.tar.gz chromium_src-82ea9c699e624955fefa774fbf495a1eb5583fd9.tar.bz2 |
ash: Animate tray-background on hover.
BUG=120046
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9854008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128841 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system')
-rw-r--r-- | ash/system/tray/system_tray.cc | 26 | ||||
-rw-r--r-- | ash/system/tray/system_tray.h | 6 |
2 files changed, 16 insertions, 16 deletions
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index d06d9478..c10436f 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -429,10 +429,11 @@ SystemTray::SystemTray() user_observer_(NULL), bubble_(NULL), popup_(NULL), - mouse_in_tray_(false), background_(new internal::SystemTrayBackground), - ALLOW_THIS_IN_INITIALIZER_LIST( - background_animator_(this, 0, kTrayBackgroundAlpha)) { + ALLOW_THIS_IN_INITIALIZER_LIST(hide_background_animator_(this, + 0, kTrayBackgroundAlpha)), + ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(this, + 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) { container_ = new views::View; container_->SetLayoutManager(new views::BoxLayout( views::BoxLayout::kHorizontal, 0, 0, kTrayPaddingBetweenItems)); @@ -446,8 +447,10 @@ SystemTray::SystemTray() SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); AddChildView(container_); - // Initially we want to paint the background. + // Initially we want to paint the background, but without the hover effect. SetPaintsBackground(true, internal::BackgroundAnimator::CHANGE_IMMEDIATE); + hover_background_animator_.SetPaintsBackground(false, + internal::BackgroundAnimator::CHANGE_IMMEDIATE); } SystemTray::~SystemTray() { @@ -534,7 +537,7 @@ void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) { void SystemTray::SetPaintsBackground( bool value, internal::BackgroundAnimator::ChangeType change_type) { - background_animator_.SetPaintsBackground(value, change_type); + hide_background_animator_.SetPaintsBackground(value, change_type); } void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, @@ -588,13 +591,13 @@ bool SystemTray::OnMousePressed(const views::MouseEvent& event) { } void SystemTray::OnMouseEntered(const views::MouseEvent& event) { - mouse_in_tray_ = true; - UpdateBackground(background_animator_.alpha()); + hover_background_animator_.SetPaintsBackground(true, + internal::BackgroundAnimator::CHANGE_ANIMATE); } void SystemTray::OnMouseExited(const views::MouseEvent& event) { - mouse_in_tray_ = false; - UpdateBackground(background_animator_.alpha()); + hover_background_animator_.SetPaintsBackground(false, + internal::BackgroundAnimator::CHANGE_ANIMATE); } void SystemTray::AboutToRequestFocusFromTabTraversal(bool reverse) { @@ -623,9 +626,8 @@ void SystemTray::OnWidgetVisibilityChanged(views::Widget* widget, } void SystemTray::UpdateBackground(int alpha) { - if (mouse_in_tray_) - alpha += kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha; - background_->set_alpha(alpha); + background_->set_alpha(hide_background_animator_.alpha() + + hover_background_animator_.alpha()); SchedulePaint(); } diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h index 98492c8..1279f22 100644 --- a/ash/system/tray/system_tray.h +++ b/ash/system/tray/system_tray.h @@ -163,13 +163,11 @@ class ASH_EXPORT SystemTray : public views::View, internal::SystemTrayBubble* bubble_; views::Widget* popup_; - // Is the mouse in the tray? - bool mouse_in_tray_; - // Owned by the view it's installed on. internal::SystemTrayBackground* background_; - internal::BackgroundAnimator background_animator_; + internal::BackgroundAnimator hide_background_animator_; + internal::BackgroundAnimator hover_background_animator_; DISALLOW_COPY_AND_ASSIGN(SystemTray); }; |