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

Unified Diff: ash/system/audio/tray_volume.cc

Issue 10808080: Implement new volume mute button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 8 years, 5 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/ash_strings.grd ('k') | ash/system/tray/tray_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/audio/tray_volume.cc
diff --git a/ash/system/audio/tray_volume.cc b/ash/system/audio/tray_volume.cc
index 5b9d3a38541c2785474f7b26fc330f31393f64fd..17f121d69b4837b5532f6c4c70335517be726e54 100644
--- a/ash/system/audio/tray_volume.cc
+++ b/ash/system/audio/tray_volume.cc
@@ -91,6 +91,26 @@ class VolumeButton : public views::ToggleImageButton {
DISALLOW_COPY_AND_ASSIGN(VolumeButton);
};
+class MuteButton : public ash::internal::TrayBarButtonWithTitle {
+ public:
+ explicit MuteButton(views::ButtonListener* listener)
+ : TrayBarButtonWithTitle(listener,
+ IDS_ASH_STATUS_TRAY_VOLUME_MUTE,
+ kTrayBarButtonWidth) {
+ Update();
+ }
+ virtual ~MuteButton() {}
+
+ void Update() {
+ ash::SystemTrayDelegate* delegate =
+ ash::Shell::GetInstance()->tray_delegate();
+ UpdateButton(delegate->IsAudioMuted());
+ SchedulePaint();
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(MuteButton);
+};
+
class VolumeView : public views::View,
public views::ButtonListener,
public views::SliderListener {
@@ -102,6 +122,9 @@ class VolumeView : public views::View,
icon_ = new VolumeButton(this);
AddChildView(icon_);
+ mute_ = new MuteButton(this);
+ AddChildView(mute_);
+
ash::SystemTrayDelegate* delegate =
ash::Shell::GetInstance()->tray_delegate();
slider_ = new views::Slider(this, views::Slider::HORIZONTAL);
@@ -125,6 +148,7 @@ class VolumeView : public views::View,
// did not change. In that case, setting the value of the slider won't
// trigger an update. So explicitly trigger an update.
icon_->Update();
+ mute_->Update();
slider_->set_enable_accessibility_events(true);
}
@@ -138,7 +162,7 @@ class VolumeView : public views::View,
// Overridden from views::ButtonListener.
virtual void ButtonPressed(views::Button* sender,
const views::Event& event) OVERRIDE {
- CHECK(sender == icon_);
+ CHECK(sender == icon_ || sender == mute_);
ash::SystemTrayDelegate* delegate =
ash::Shell::GetInstance()->tray_delegate();
delegate->SetAudioMuted(!delegate->IsAudioMuted());
@@ -158,6 +182,7 @@ class VolumeView : public views::View,
}
VolumeButton* icon_;
+ MuteButton* mute_;
views::Slider* slider_;
DISALLOW_COPY_AND_ASSIGN(VolumeView);
« no previous file with comments | « ash/ash_strings.grd ('k') | ash/system/tray/tray_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698