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

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: 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
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..53ea69cbe58820e0b30c27cd3df002c93961e557 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,7 +309,7 @@ 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;
+ int new_volume = value * 100;
float current_volume = audio_delegate_->GetOutputVolumeLevel();
tdanderson 2016/11/11 18:30:24 It looks like TrayAudioDelegate has an integer ret
yiyix 2016/11/11 19:01:24 Sorry, I forget to update this type. There is no r
// Do not call change audio volume if the difference is less than
// 1%, which is beyond cras audio api's granularity for output volume.

Powered by Google App Engine
This is Rietveld 408576698