| OLD | NEW |
| 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/common/system/chromeos/audio/volume_view.h" | 5 #include "ash/common/system/chromeos/audio/volume_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/metrics/user_metrics_action.h" | 10 #include "ash/common/metrics/user_metrics_action.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 Update(); | 249 Update(); |
| 250 slider_->set_enable_accessibility_events(true); | 250 slider_->set_enable_accessibility_events(true); |
| 251 } | 251 } |
| 252 | 252 |
| 253 void VolumeView::UpdateDeviceTypeAndMore() { | 253 void VolumeView::UpdateDeviceTypeAndMore() { |
| 254 bool show_more = is_default_view_ && audio_delegate_->HasAlternativeSources(); | 254 bool show_more = is_default_view_ && audio_delegate_->HasAlternativeSources(); |
| 255 | 255 |
| 256 if (!show_more) | 256 if (!show_more) |
| 257 return; | 257 return; |
| 258 | 258 |
| 259 // Show output device icon if necessary. | 259 bool target_visibility = false; |
| 260 device_type_->SetVisible(false); | |
| 261 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 260 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
| 262 const gfx::VectorIcon& device_icon = | 261 const gfx::VectorIcon& device_icon = |
| 263 audio_delegate_->GetActiveOutputDeviceVectorIcon(); | 262 audio_delegate_->GetActiveOutputDeviceVectorIcon(); |
| 264 if (!device_icon.is_empty()) { | 263 if (!device_icon.is_empty()) { |
| 265 device_type_->SetImage( | 264 device_type_->SetImage( |
| 266 gfx::CreateVectorIcon(device_icon, kMenuIconColor)); | 265 gfx::CreateVectorIcon(device_icon, kMenuIconColor)); |
| 267 device_type_->SetVisible(true); | 266 target_visibility = true; |
| 268 } | 267 } |
| 269 } else { | 268 } else { |
| 270 int device_icon = audio_delegate_->GetActiveOutputDeviceIconId(); | 269 int device_icon = audio_delegate_->GetActiveOutputDeviceIconId(); |
| 271 if (device_icon != system::TrayAudioDelegate::kNoAudioDeviceIcon) { | 270 if (device_icon != system::TrayAudioDelegate::kNoAudioDeviceIcon) { |
| 272 device_type_->SetImage(ui::ResourceBundle::GetSharedInstance() | 271 device_type_->SetImage(ui::ResourceBundle::GetSharedInstance() |
| 273 .GetImageNamed(device_icon) | 272 .GetImageNamed(device_icon) |
| 274 .ToImageSkia()); | 273 .ToImageSkia()); |
| 275 device_type_->SetVisible(true); | 274 target_visibility = true; |
| 276 } | 275 } |
| 277 } | 276 } |
| 277 if (device_type_->visible() != target_visibility) { |
| 278 device_type_->SetVisible(target_visibility); |
| 279 device_type_->InvalidateLayout(); |
| 280 } |
| 278 } | 281 } |
| 279 | 282 |
| 280 void VolumeView::HandleVolumeUp(int level) { | 283 void VolumeView::HandleVolumeUp(int level) { |
| 281 audio_delegate_->SetOutputVolumeLevel(level); | 284 audio_delegate_->SetOutputVolumeLevel(level); |
| 282 if (audio_delegate_->IsOutputAudioMuted() && | 285 if (audio_delegate_->IsOutputAudioMuted() && |
| 283 level > audio_delegate_->GetOutputDefaultVolumeMuteLevel()) { | 286 level > audio_delegate_->GetOutputDefaultVolumeMuteLevel()) { |
| 284 audio_delegate_->SetOutputAudioIsMuted(false); | 287 audio_delegate_->SetOutputAudioIsMuted(false); |
| 285 } | 288 } |
| 286 } | 289 } |
| 287 | 290 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 void VolumeView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 346 void VolumeView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 344 // Separator's prefered size is based on set bounds. When an empty bounds is | 347 // Separator's prefered size is based on set bounds. When an empty bounds is |
| 345 // set on first layout this causes BoxLayout to ignore the separator. Reset | 348 // set on first layout this causes BoxLayout to ignore the separator. Reset |
| 346 // its height on each bounds change so that it is laid out properly. | 349 // its height on each bounds change so that it is laid out properly. |
| 347 if (separator_) | 350 if (separator_) |
| 348 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height())); | 351 separator_->SetSize(gfx::Size(kSeparatorSize, bounds().height())); |
| 349 } | 352 } |
| 350 | 353 |
| 351 } // namespace tray | 354 } // namespace tray |
| 352 } // namespace ash | 355 } // namespace ash |
| OLD | NEW |