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

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: 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 | no next file » | 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());
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 if (delegate->IsAudioMuted() && value > 0.0)
157 delegate->SetAudioMuted(false);
sadrul 2012/05/19 02:10:54 I don't think this is the right place for this cha
Daniel Erat 2012/05/19 05:38:34 Sorry, I gave conflicting feedback in the review f
Jun Mukai 2012/05/21 17:05:38 Still not sure which is better, but is there any r
Jun Mukai 2012/05/21 17:19:38 Note that same thing was introduced to volume_cont
158 }
153 icon_->Update(); 159 icon_->Update();
154 } 160 }
155 161
156 VolumeButton* icon_; 162 VolumeButton* icon_;
157 views::Slider* slider_; 163 views::Slider* slider_;
158 164
159 DISALLOW_COPY_AND_ASSIGN(VolumeView); 165 DISALLOW_COPY_AND_ASSIGN(VolumeView);
160 }; 166 };
161 167
162 } // namespace tray 168 } // namespace tray
163 169
164 TrayVolume::TrayVolume() 170 TrayVolume::TrayVolume()
165 : TrayImageItem(IDR_AURA_UBER_TRAY_VOLUME_MUTE), 171 : TrayImageItem(IDR_AURA_UBER_TRAY_VOLUME_MUTE),
166 volume_view_(NULL), 172 volume_view_(NULL),
167 is_default_view_(false) { 173 is_default_view_(false) {
168 } 174 }
169 175
170 TrayVolume::~TrayVolume() { 176 TrayVolume::~TrayVolume() {
171 } 177 }
172 178
173 bool TrayVolume::GetInitialVisibility() { 179 bool TrayVolume::GetInitialVisibility() {
174 return ash::Shell::GetInstance()->tray_delegate()->IsAudioMuted(); 180 ash::SystemTrayDelegate* delegate =
181 ash::Shell::GetInstance()->tray_delegate();
182 return delegate->GetVolumeLevel() == 0.0 || delegate->IsAudioMuted();
175 } 183 }
176 184
177 views::View* TrayVolume::CreateDefaultView(user::LoginStatus status) { 185 views::View* TrayVolume::CreateDefaultView(user::LoginStatus status) {
178 volume_view_ = new tray::VolumeView; 186 volume_view_ = new tray::VolumeView;
179 is_default_view_ = true; 187 is_default_view_ = true;
180 return volume_view_; 188 return volume_view_;
181 } 189 }
182 190
183 views::View* TrayVolume::CreateDetailedView(user::LoginStatus status) { 191 views::View* TrayVolume::CreateDetailedView(user::LoginStatus status) {
184 volume_view_ = new tray::VolumeView; 192 volume_view_ = new tray::VolumeView;
185 is_default_view_ = false; 193 is_default_view_ = false;
186 return volume_view_; 194 return volume_view_;
187 } 195 }
188 196
189 void TrayVolume::DestroyDefaultView() { 197 void TrayVolume::DestroyDefaultView() {
190 if (is_default_view_) 198 if (is_default_view_)
191 volume_view_ = NULL; 199 volume_view_ = NULL;
192 } 200 }
193 201
194 void TrayVolume::DestroyDetailedView() { 202 void TrayVolume::DestroyDetailedView() {
195 if (!is_default_view_) 203 if (!is_default_view_)
196 volume_view_ = NULL; 204 volume_view_ = NULL;
197 } 205 }
198 206
199 void TrayVolume::OnVolumeChanged(float percent) { 207 void TrayVolume::OnVolumeChanged(float percent) {
200 if (tray_view()) 208 if (tray_view())
201 tray_view()->SetVisible(GetInitialVisibility()); 209 tray_view()->SetVisible(GetInitialVisibility());
202 210
203 if (volume_view_) { 211 if (volume_view_) {
212 if (ash::Shell::GetInstance()->tray_delegate()->IsAudioMuted())
213 percent = 0.0;
204 volume_view_->SetVolumeLevel(percent); 214 volume_view_->SetVolumeLevel(percent);
205 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds); 215 SetDetailedViewCloseDelay(kTrayPopupAutoCloseDelayInSeconds);
206 return; 216 return;
207 } 217 }
208 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); 218 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false);
209 } 219 }
210 220
211 } // namespace internal 221 } // namespace internal
212 } // namespace ash 222 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698