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

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

Issue 1577973002: Merge to m48: Fix volume slider to emit value changed events and do not focus system tray it\ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2564
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | ash/system/tray/system_tray.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/volume_view.h" 5 #include "ash/system/audio/volume_view.h"
6 6
7 #include "ash/ash_constants.h" 7 #include "ash/ash_constants.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/audio/tray_audio.h" 9 #include "ash/system/audio/tray_audio.h"
10 #include "ash/system/audio/tray_audio_delegate.h" 10 #include "ash/system/audio/tray_audio_delegate.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 Layout(); 168 Layout();
169 } 169 }
170 170
171 void VolumeView::SetVolumeLevel(float percent) { 171 void VolumeView::SetVolumeLevel(float percent) {
172 // Slider's value is in finer granularity than audio volume level(0.01), 172 // Slider's value is in finer granularity than audio volume level(0.01),
173 // there will be a small discrepancy between slider's value and volume level 173 // there will be a small discrepancy between slider's value and volume level
174 // on audio side. To avoid the jittering in slider UI, do not set change 174 // on audio side. To avoid the jittering in slider UI, do not set change
175 // slider value if the change is less than 1%. 175 // slider value if the change is less than 1%.
176 if (std::abs(percent-slider_->value()) < 0.01) 176 if (std::abs(percent-slider_->value()) < 0.01)
177 return; 177 return;
178 // The change in volume will be reflected via accessibility system events,
179 // so we prevent the UI event from being sent here.
180 slider_->set_enable_accessibility_events(false);
181 slider_->SetValue(percent); 178 slider_->SetValue(percent);
182 // It is possible that the volume was (un)muted, but the actual volume level 179 // It is possible that the volume was (un)muted, but the actual volume level
183 // did not change. In that case, setting the value of the slider won't 180 // did not change. In that case, setting the value of the slider won't
184 // trigger an update. So explicitly trigger an update. 181 // trigger an update. So explicitly trigger an update.
185 Update(); 182 Update();
186 slider_->set_enable_accessibility_events(true); 183 slider_->set_enable_accessibility_events(true);
187 } 184 }
188 185
189 void VolumeView::UpdateDeviceTypeAndMore() { 186 void VolumeView::UpdateDeviceTypeAndMore() {
190 bool show_more = is_default_view_ && TrayAudio::ShowAudioDeviceMenu() && 187 bool show_more = is_default_view_ && TrayAudio::ShowAudioDeviceMenu() &&
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 273
277 void VolumeView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 274 void VolumeView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
278 // Separator's prefered size is based on set bounds. When an empty bounds is 275 // Separator's prefered size is based on set bounds. When an empty bounds is
279 // set on first layout this causes BoxLayout to ignore the separator. Reset 276 // set on first layout this causes BoxLayout to ignore the separator. Reset
280 // its height on each bounds change so that it is laid out properly. 277 // its height on each bounds change so that it is laid out properly.
281 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height())); 278 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height()));
282 } 279 }
283 280
284 } // namespace tray 281 } // namespace tray
285 } // namespace ash 282 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/system_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698