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

Side by Side Diff: ash/system/audio/tray_volume.cc

Issue 10408036: Modify the volume visuals: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Introduce auto-unmute in audio_handler Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/audio/audio_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/audio/tray_volume.h" 5 #include "ash/system/audio/tray_volume.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/system/tray/tray_constants.h" 9 #include "ash/system/tray/tray_constants.h"
10 #include "ash/system/tray/tray_views.h" 10 #include "ash/system/tray/tray_views.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 99 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
100 kTrayPopupPaddingHorizontal, 0, kTrayPopupPaddingBetweenItems)); 100 kTrayPopupPaddingHorizontal, 0, kTrayPopupPaddingBetweenItems));
101 101
102 icon_ = new VolumeButton(this); 102 icon_ = new VolumeButton(this);
103 AddChildView(icon_); 103 AddChildView(icon_);
104 104
105 ash::SystemTrayDelegate* delegate = 105 ash::SystemTrayDelegate* delegate =
106 ash::Shell::GetInstance()->tray_delegate(); 106 ash::Shell::GetInstance()->tray_delegate();
107 slider_ = new views::Slider(this, views::Slider::HORIZONTAL); 107 slider_ = new views::Slider(this, views::Slider::HORIZONTAL);
108 slider_->set_focus_border_color(kFocusBorderColor); 108 slider_->set_focus_border_color(kFocusBorderColor);
109 slider_->SetValue(delegate->GetVolumeLevel()); 109 slider_->SetValue(
110 delegate->IsAudioMuted() ? 0.0 : delegate->GetVolumeLevel());
Daniel Erat 2012/05/21 17:45:43 nit: remove extra space after ":" (you have two)
Jun Mukai 2012/05/21 17:56:07 Done.
110 slider_->SetAccessibleName( 111 slider_->SetAccessibleName(
111 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( 112 ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
112 IDS_ASH_STATUS_TRAY_VOLUME)); 113 IDS_ASH_STATUS_TRAY_VOLUME));
113 AddChildView(slider_); 114 AddChildView(slider_);
114 } 115 }
115 116
116 virtual ~VolumeView() {} 117 virtual ~VolumeView() {}
117 118
118 void SetVolumeLevel(float percent) { 119 void SetVolumeLevel(float percent) {
119 // The change in volume will be reflected via accessibility system events, 120 // The change in volume will be reflected via accessibility system events,
(...skipping 21 matching lines...) Expand all
141 ash::SystemTrayDelegate* delegate = 142 ash::SystemTrayDelegate* delegate =
142 ash::Shell::GetInstance()->tray_delegate(); 143 ash::Shell::GetInstance()->tray_delegate();
143 delegate->SetAudioMuted(!delegate->IsAudioMuted()); 144 delegate->SetAudioMuted(!delegate->IsAudioMuted());
144 } 145 }
145 146
146 // Overridden from views:SliderListener. 147 // Overridden from views:SliderListener.
147 virtual void SliderValueChanged(views::Slider* sender, 148 virtual void SliderValueChanged(views::Slider* sender,
148 float value, 149 float value,
149 float old_value, 150 float old_value,
150 views::SliderChangeReason reason) OVERRIDE { 151 views::SliderChangeReason reason) OVERRIDE {
151 if (reason == views::VALUE_CHANGED_BY_USER) 152 if (reason == views::VALUE_CHANGED_BY_USER) {
152 ash::Shell::GetInstance()->tray_delegate()->SetVolumeLevel(value); 153 ash::SystemTrayDelegate* delegate =
154 ash::Shell::GetInstance()->tray_delegate();
155 delegate->SetVolumeLevel(value);
156 }
153 icon_->Update(); 157 icon_->Update();
154 } 158 }
155 159
156 VolumeButton* icon_; 160 VolumeButton* icon_;
157 views::Slider* slider_; 161 views::Slider* slider_;
158 162
159 DISALLOW_COPY_AND_ASSIGN(VolumeView); 163 DISALLOW_COPY_AND_ASSIGN(VolumeView);
160 }; 164 };
161 165
162 } // namespace tray 166 } // namespace tray
163 167
164 TrayVolume::TrayVolume() 168 TrayVolume::TrayVolume()
165 : TrayImageItem(IDR_AURA_UBER_TRAY_VOLUME_MUTE), 169 : TrayImageItem(IDR_AURA_UBER_TRAY_VOLUME_MUTE),
166 volume_view_(NULL), 170 volume_view_(NULL),
167 is_default_view_(false) { 171 is_default_view_(false) {
168 } 172 }
169 173
170 TrayVolume::~TrayVolume() { 174 TrayVolume::~TrayVolume() {
171 } 175 }
172 176
173 bool TrayVolume::GetInitialVisibility() { 177 bool TrayVolume::GetInitialVisibility() {
174 return ash::Shell::GetInstance()->tray_delegate()->IsAudioMuted(); 178 ash::SystemTrayDelegate* delegate =
179 ash::Shell::GetInstance()->tray_delegate();
180 return delegate->GetVolumeLevel() == 0.0 || delegate->IsAudioMuted();
175 } 181 }
176 182
177 views::View* TrayVolume::CreateDefaultView(user::LoginStatus status) { 183 views::View* TrayVolume::CreateDefaultView(user::LoginStatus status) {
178 volume_view_ = new tray::VolumeView; 184 volume_view_ = new tray::VolumeView;
179 is_default_view_ = true; 185 is_default_view_ = true;
180 return volume_view_; 186 return volume_view_;
181 } 187 }
182 188
183 views::View* TrayVolume::CreateDetailedView(user::LoginStatus status) { 189 views::View* TrayVolume::CreateDetailedView(user::LoginStatus status) {
184 volume_view_ = new tray::VolumeView; 190 volume_view_ = new tray::VolumeView;
185 is_default_view_ = false; 191 is_default_view_ = false;
186 return volume_view_; 192 return volume_view_;
187 } 193 }
188 194
189 void TrayVolume::DestroyDefaultView() { 195 void TrayVolume::DestroyDefaultView() {
190 if (is_default_view_) 196 if (is_default_view_)
191 volume_view_ = NULL; 197 volume_view_ = NULL;
192 } 198 }
193 199
194 void TrayVolume::DestroyDetailedView() { 200 void TrayVolume::DestroyDetailedView() {
195 if (!is_default_view_) 201 if (!is_default_view_)
196 volume_view_ = NULL; 202 volume_view_ = NULL;
197 } 203 }
198 204
199 void TrayVolume::OnVolumeChanged(float percent) { 205 void TrayVolume::OnVolumeChanged(float percent) {
200 if (tray_view()) 206 if (tray_view())
201 tray_view()->SetVisible(GetInitialVisibility()); 207 tray_view()->SetVisible(GetInitialVisibility());
202 208
203 if (volume_view_) { 209 if (volume_view_) {
210 if (ash::Shell::GetInstance()->tray_delegate()->IsAudioMuted())
211 percent = 0.0;
204 volume_view_->SetVolumeLevel(percent); 212 volume_view_->SetVolumeLevel(percent);
205 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); 213 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds);
206 return; 214 return;
207 } 215 }
208 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); 216 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false);
209 } 217 }
210 218
211 } // namespace internal 219 } // namespace internal
212 } // namespace ash 220 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/audio/audio_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698