diff options
author | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-24 00:32:58 +0000 |
---|---|---|
committer | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-24 00:32:58 +0000 |
commit | 672ca8c92a76d9a4dfdf1bb9c017bef416157fab (patch) | |
tree | e07b1bbabf0a9fe4bff4e6085aa1134c8aff63e8 /ash/system/audio | |
parent | 672dcd2fc7d0b1b2389e080b8a4dec6898e4bb45 (diff) | |
download | chromium_src-672ca8c92a76d9a4dfdf1bb9c017bef416157fab.zip chromium_src-672ca8c92a76d9a4dfdf1bb9c017bef416157fab.tar.gz chromium_src-672ca8c92a76d9a4dfdf1bb9c017bef416157fab.tar.bz2 |
Implement new volume mute button.
Add a new TrayBarButtonWithTitle class which can be used for both audio and brightness UI for toggle audio/brightness state.
Clip the extra empty space around left/right bar images so that the bar image would not have too much empty space around itself.
The new audio/brightness slider will be implemented in another cl.
BUG=122832
TEST=The new mute segment should show up and work on uber tray bubble.
TBR=oshima@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10808080
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148002 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system/audio')
-rw-r--r-- | ash/system/audio/tray_volume.cc | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/ash/system/audio/tray_volume.cc b/ash/system/audio/tray_volume.cc index 5b9d3a3..17f121d 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); |