| 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/system/audio/tray_audio.h" | 5 #include "ash/system/audio/tray_audio.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/display/display_manager.h" |
| 10 #include "ash/metrics/user_metrics_recorder.h" | 11 #include "ash/metrics/user_metrics_recorder.h" |
| 11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 12 #include "ash/system/audio/tray_audio_delegate.h" | 13 #include "ash/system/audio/tray_audio_delegate.h" |
| 13 #include "ash/system/audio/volume_view.h" | 14 #include "ash/system/audio/volume_view.h" |
| 14 #include "ash/system/tray/actionable_view.h" | 15 #include "ash/system/tray/actionable_view.h" |
| 15 #include "ash/system/tray/fixed_sized_scroll_view.h" | 16 #include "ash/system/tray/fixed_sized_scroll_view.h" |
| 16 #include "ash/system/tray/hover_highlight_view.h" | 17 #include "ash/system/tray/hover_highlight_view.h" |
| 17 #include "ash/system/tray/system_tray.h" | 18 #include "ash/system/tray/system_tray.h" |
| 18 #include "ash/system/tray/system_tray_delegate.h" | 19 #include "ash/system/tray/system_tray_delegate.h" |
| 19 #include "ash/system/tray/system_tray_notifier.h" | 20 #include "ash/system/tray/system_tray_notifier.h" |
| 20 #include "ash/system/tray/tray_constants.h" | 21 #include "ash/system/tray/tray_constants.h" |
| 21 #include "ash/volume_control_delegate.h" | 22 #include "ash/volume_control_delegate.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 23 #include "grit/ash_resources.h" | 24 #include "grit/ash_resources.h" |
| 24 #include "third_party/skia/include/core/SkCanvas.h" | 25 #include "third_party/skia/include/core/SkCanvas.h" |
| 25 #include "third_party/skia/include/core/SkPaint.h" | 26 #include "third_party/skia/include/core/SkPaint.h" |
| 26 #include "third_party/skia/include/core/SkRect.h" | 27 #include "third_party/skia/include/core/SkRect.h" |
| 27 #include "third_party/skia/include/effects/SkGradientShader.h" | 28 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 28 #include "ui/gfx/canvas.h" | 29 #include "ui/gfx/canvas.h" |
| 30 #include "ui/gfx/display.h" |
| 29 #include "ui/gfx/font_list.h" | 31 #include "ui/gfx/font_list.h" |
| 30 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
| 31 #include "ui/gfx/image/image_skia_operations.h" | 33 #include "ui/gfx/image/image_skia_operations.h" |
| 32 #include "ui/views/controls/button/image_button.h" | 34 #include "ui/views/controls/button/image_button.h" |
| 33 #include "ui/views/controls/image_view.h" | 35 #include "ui/views/controls/image_view.h" |
| 34 #include "ui/views/controls/label.h" | 36 #include "ui/views/controls/label.h" |
| 35 #include "ui/views/controls/slider.h" | 37 #include "ui/views/controls/slider.h" |
| 36 #include "ui/views/layout/box_layout.h" | 38 #include "ui/views/layout/box_layout.h" |
| 37 #include "ui/views/view.h" | 39 #include "ui/views/view.h" |
| 38 | 40 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); | 122 PopupDetailedView(kTrayPopupAutoCloseDelayInSeconds, false); |
| 121 } | 123 } |
| 122 } | 124 } |
| 123 | 125 |
| 124 void TrayAudio::OnAudioNodesChanged() { | 126 void TrayAudio::OnAudioNodesChanged() { |
| 125 Update(); | 127 Update(); |
| 126 } | 128 } |
| 127 | 129 |
| 128 void TrayAudio::OnActiveOutputNodeChanged() { | 130 void TrayAudio::OnActiveOutputNodeChanged() { |
| 129 Update(); | 131 Update(); |
| 132 // Swap left/right channel if it is in Yoga mode. |
| 133 const DisplayInfo& display_info = |
| 134 Shell::GetInstance()->display_manager()->GetDisplayInfo( |
| 135 gfx::Display::InternalDisplayId()); |
| 136 audio_delegate_->SwapLeftRight(display_info.rotation() == |
| 137 gfx::Display::ROTATE_180); |
| 130 } | 138 } |
| 131 | 139 |
| 132 void TrayAudio::OnActiveInputNodeChanged() { | 140 void TrayAudio::OnActiveInputNodeChanged() { |
| 133 Update(); | 141 Update(); |
| 134 } | 142 } |
| 135 | 143 |
| 136 void TrayAudio::Update() { | 144 void TrayAudio::Update() { |
| 137 if (tray_view()) | 145 if (tray_view()) |
| 138 tray_view()->SetVisible(GetInitialVisibility()); | 146 tray_view()->SetVisible(GetInitialVisibility()); |
| 139 if (volume_view_) { | 147 if (volume_view_) { |
| 140 volume_view_->SetVolumeLevel( | 148 volume_view_->SetVolumeLevel( |
| 141 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f); | 149 static_cast<float>(audio_delegate_->GetOutputVolumeLevel()) / 100.0f); |
| 142 volume_view_->Update(); | 150 volume_view_->Update(); |
| 143 } | 151 } |
| 144 } | 152 } |
| 145 | 153 |
| 146 } // namespace ash | 154 } // namespace ash |
| OLD | NEW |