diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-23 19:22:42 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-23 19:22:42 +0000 |
commit | e924968c0e87e63b1a32fcde9f2b952c090f0379 (patch) | |
tree | 8dc58b87fa18290ef93292a2d97553602afffdcd | |
parent | d84bf2dfe1b6fcf9cdf68d4a560428a033324af0 (diff) | |
download | chromium_src-e924968c0e87e63b1a32fcde9f2b952c090f0379.zip chromium_src-e924968c0e87e63b1a32fcde9f2b952c090f0379.tar.gz chromium_src-e924968c0e87e63b1a32fcde9f2b952c090f0379.tar.bz2 |
ash: Improve uber tray bubble lifetimes.
This makes us extend the lifetime of an already-shown
detailed view (e.g. volume or brightness) when the key that
shows it is pressed again. It also fixes an issue where
there was a delay after one view was hidden before another
could be shown.
BUG=119624,119745
TEST=manual
Review URL: https://chromiumcodereview.appspot.com/9808072
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128551 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/system/audio/tray_volume.cc | 2 | ||||
-rw-r--r-- | ash/system/brightness/tray_brightness.cc | 10 | ||||
-rw-r--r-- | ash/system/tray/system_tray.cc | 20 | ||||
-rw-r--r-- | ash/system/tray/system_tray.h | 4 | ||||
-rw-r--r-- | ash/system/tray/system_tray_item.cc | 4 | ||||
-rw-r--r-- | ash/system/tray/system_tray_item.h | 5 |
6 files changed, 34 insertions, 11 deletions
diff --git a/ash/system/audio/tray_volume.cc b/ash/system/audio/tray_volume.cc index e58806b..b54a994 100644 --- a/ash/system/audio/tray_volume.cc +++ b/ash/system/audio/tray_volume.cc @@ -197,9 +197,9 @@ void TrayVolume::DestroyDetailedView() { void TrayVolume::OnVolumeChanged(float percent) { if (volume_view_.get()) { volume_view_->SetVolumeLevel(percent); + SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); return; } - PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); } diff --git a/ash/system/brightness/tray_brightness.cc b/ash/system/brightness/tray_brightness.cc index 6df363a..88d08c8 100644 --- a/ash/system/brightness/tray_brightness.cc +++ b/ash/system/brightness/tray_brightness.cc @@ -121,13 +121,15 @@ void TrayBrightness::DestroyDetailedView() { } void TrayBrightness::OnBrightnessChanged(float percent, bool user_initiated) { - if (brightness_view_.get()) { + if (brightness_view_.get()) brightness_view_->SetBrightnessLevel(percent); - return; - } if (!user_initiated) return; - PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); + + if (brightness_view_.get()) + SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); + else + PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); } } // namespace internal diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index 7ecef7a..cc66c45 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -301,6 +301,7 @@ class SystemTrayBubble : public views::BubbleDelegateView { } } + bool detailed() const { return detailed_; } void set_can_activate(bool activate) { can_activate_ = activate; } void StartAutoCloseTimer(int seconds) { @@ -471,7 +472,7 @@ void SystemTray::RemoveTrayItem(SystemTrayItem* item) { void SystemTray::ShowDefaultView() { if (popup_) { popup_->RemoveObserver(this); - popup_->Close(); + popup_->CloseNow(); } popup_ = NULL; bubble_ = NULL; @@ -484,7 +485,7 @@ void SystemTray::ShowDetailedView(SystemTrayItem* item, bool activate) { if (popup_) { popup_->RemoveObserver(this); - popup_->Close(); + popup_->CloseNow(); } popup_ = NULL; bubble_ = NULL; @@ -495,6 +496,11 @@ void SystemTray::ShowDetailedView(SystemTrayItem* item, bubble_->StartAutoCloseTimer(close_delay); } +void SystemTray::SetDetailedViewCloseDelay(int close_delay) { + if (bubble_ && bubble_->detailed()) + bubble_->StartAutoCloseTimer(close_delay); +} + void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) { if (popup_) popup_->CloseNow(); @@ -553,20 +559,22 @@ void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, bool SystemTray::OnKeyPressed(const views::KeyEvent& event) { if (event.key_code() == ui::VKEY_SPACE || event.key_code() == ui::VKEY_RETURN) { - if (popup_) + if (popup_ && bubble_ && !bubble_->detailed()) popup_->Hide(); else - ShowItems(items_.get(), false, true); + ShowDefaultView(); return true; } return false; } bool SystemTray::OnMousePressed(const views::MouseEvent& event) { - if (popup_) + // If we're already showing the default view, hide it; otherwise, show it + // (and hide any popup that's currently shown). + if (popup_ && bubble_ && !bubble_->detailed()) popup_->Hide(); else - ShowItems(items_.get(), false, true); + ShowDefaultView(); return true; } diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h index ce72c92..5287404 100644 --- a/ash/system/tray/system_tray.h +++ b/ash/system/tray/system_tray.h @@ -59,6 +59,10 @@ class ASH_EXPORT SystemTray : public views::View, int close_delay_in_seconds, bool activate); + // Continue showing the existing detailed view, if any, for |close_delay| + // seconds. + void SetDetailedViewCloseDelay(int close_delay); + // Updates the items when the login status of the system changes. void UpdateAfterLoginStatusChange(user::LoginStatus login_status); diff --git a/ash/system/tray/system_tray_item.cc b/ash/system/tray/system_tray_item.cc index ad705e4..242013e 100644 --- a/ash/system/tray/system_tray_item.cc +++ b/ash/system/tray/system_tray_item.cc @@ -20,4 +20,8 @@ void SystemTrayItem::PopupDetailedView(int for_seconds, bool activate) { Shell::GetInstance()->tray()->ShowDetailedView(this, for_seconds, activate); } +void SystemTrayItem::SetDetailedViewCloseDelay(int for_seconds) { + Shell::GetInstance()->tray()->SetDetailedViewCloseDelay(for_seconds); +} + } // namespace ash diff --git a/ash/system/tray/system_tray_item.h b/ash/system/tray/system_tray_item.h index 23c6ff3..9fd438a 100644 --- a/ash/system/tray/system_tray_item.h +++ b/ash/system/tray/system_tray_item.h @@ -47,6 +47,11 @@ class ASH_EXPORT SystemTrayItem { // time. void PopupDetailedView(int for_seconds, bool activate); + // Continue showing the currently-shown detailed view, if any, for + // |for_seconds| seconds. The caller is responsible for checking that the + // currently-shown view is for this item. + void SetDetailedViewCloseDelay(int for_seconds); + private: DISALLOW_COPY_AND_ASSIGN(SystemTrayItem); |