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

Unified Diff: ash/common/system/chromeos/audio/volume_view.cc

Issue 2485353002: Fix the volume strength icon to reflect the volume control clicks (Closed)
Patch Set: fix variable type Created 4 years, 1 month 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/common/system/chromeos/audio/volume_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/chromeos/audio/volume_view.cc
diff --git a/ash/common/system/chromeos/audio/volume_view.cc b/ash/common/system/chromeos/audio/volume_view.cc
index 38d050b98627ee8bf140e19c4b6c52997c91cb1a..67577d775facca1c85d5a29363153822aeb70889 100644
--- a/ash/common/system/chromeos/audio/volume_view.cc
+++ b/ash/common/system/chromeos/audio/volume_view.cc
@@ -227,6 +227,9 @@ void VolumeView::Update() {
}
void VolumeView::SetVolumeLevel(float percent) {
+ // Update volume level to the current audio level.
+ Update();
+
// Slider's value is in finer granularity than audio volume level(0.01),
// there will be a small discrepancy between slider's value and volume level
// on audio side. To avoid the jittering in slider UI, do not set change
@@ -268,7 +271,7 @@ void VolumeView::UpdateDeviceTypeAndMore() {
}
}
-void VolumeView::HandleVolumeUp(float level) {
+void VolumeView::HandleVolumeUp(int level) {
audio_delegate_->SetOutputVolumeLevel(level);
if (audio_delegate_->IsOutputAudioMuted() &&
level > audio_delegate_->GetOutputDefaultVolumeMuteLevel()) {
@@ -276,7 +279,7 @@ void VolumeView::HandleVolumeUp(float level) {
}
}
-void VolumeView::HandleVolumeDown(float level) {
+void VolumeView::HandleVolumeDown(int level) {
audio_delegate_->SetOutputVolumeLevel(level);
if (!audio_delegate_->IsOutputAudioMuted() &&
level <= audio_delegate_->GetOutputDefaultVolumeMuteLevel()) {
@@ -306,11 +309,11 @@ void VolumeView::SliderValueChanged(views::Slider* sender,
float old_value,
views::SliderChangeReason reason) {
if (reason == views::VALUE_CHANGED_BY_USER) {
- float new_volume = value * 100.0f;
- float current_volume = audio_delegate_->GetOutputVolumeLevel();
+ int new_volume = value * 100;
James Cook 2016/11/11 22:21:15 Aside: I'm a little surprised that this doesn't ge
yiyix 2016/11/11 22:27:54 Do you think adding a comment here would help the
+ int current_volume = audio_delegate_->GetOutputVolumeLevel();
// Do not call change audio volume if the difference is less than
// 1%, which is beyond cras audio api's granularity for output volume.
- if (std::abs(new_volume - current_volume) < 1.0f)
+ if (std::abs(new_volume - current_volume) < 1)
tdanderson 2016/11/11 19:48:35 if both values are now ints, the only way this can
yiyix 2016/11/11 22:27:54 You are right. Done
return;
WmShell::Get()->RecordUserMetricsAction(
is_default_view_ ? UMA_STATUS_AREA_CHANGED_VOLUME_MENU
« no previous file with comments | « ash/common/system/chromeos/audio/volume_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698