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 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_AUDIO_VOLUME_VIEW_H_ | 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_AUDIO_VOLUME_VIEW_H_ |
6 #define ASH_COMMON_SYSTEM_CHROMEOS_AUDIO_VOLUME_VIEW_H_ | 6 #define ASH_COMMON_SYSTEM_CHROMEOS_AUDIO_VOLUME_VIEW_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "ui/views/controls/button/button.h" | 9 #include "ui/views/controls/button/button.h" |
10 #include "ui/views/controls/slider.h" | 10 #include "ui/views/controls/slider.h" |
11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 class CustomButton; | 14 class CustomButton; |
15 class ImageView; | 15 class ImageView; |
16 } | 16 } |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 class SystemTrayItem; | 19 class SystemTrayItem; |
20 class TriView; | 20 class TriView; |
21 | 21 |
22 namespace system { | |
23 class TrayAudioDelegate; | |
24 } | |
25 | |
26 namespace tray { | 22 namespace tray { |
27 class VolumeButton; | 23 class VolumeButton; |
28 | 24 |
29 class VolumeView : public views::View, | 25 class VolumeView : public views::View, |
30 public views::SliderListener, | 26 public views::SliderListener, |
31 public views::ButtonListener { | 27 public views::ButtonListener { |
32 public: | 28 public: |
33 VolumeView(SystemTrayItem* owner, | 29 VolumeView(SystemTrayItem* owner, bool is_default_view); |
34 system::TrayAudioDelegate* audio_delegate, | |
35 bool is_default_view); | |
36 | 30 |
37 ~VolumeView() override; | 31 ~VolumeView() override; |
38 | 32 |
39 void Update(); | 33 void Update(); |
40 | 34 |
41 // Sets volume level on slider_, |percent| is ranged from [0.00] to [1.00]. | 35 // Sets volume level on slider_, |percent| is ranged from [0.00] to [1.00]. |
42 void SetVolumeLevel(float percent); | 36 void SetVolumeLevel(float percent); |
43 | 37 |
44 private: | 38 private: |
45 // Updates device_type_ icon and more_ button. | 39 // Updates device_type_ icon and more_ button. |
46 void UpdateDeviceTypeAndMore(); | 40 void UpdateDeviceTypeAndMore(); |
47 void HandleVolumeUp(int percent); | 41 void HandleVolumeUp(int percent); |
48 void HandleVolumeDown(int percent); | 42 void HandleVolumeDown(int percent); |
49 | 43 |
50 // SliderListener: | 44 // SliderListener: |
51 void SliderValueChanged(views::Slider* sender, | 45 void SliderValueChanged(views::Slider* sender, |
52 float value, | 46 float value, |
53 float old_value, | 47 float old_value, |
54 views::SliderChangeReason reason) override; | 48 views::SliderChangeReason reason) override; |
55 | 49 |
56 // views::ButtonListener: | 50 // views::ButtonListener: |
57 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 51 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
58 | 52 |
59 SystemTrayItem* owner_; | 53 SystemTrayItem* owner_; |
60 // The only immediate child view of |this|. All other view elements are added | 54 // The only immediate child view of |this|. All other view elements are added |
61 // to the |tri_view_| to handle layout. | 55 // to the |tri_view_| to handle layout. |
62 TriView* tri_view_; | 56 TriView* tri_view_; |
63 system::TrayAudioDelegate* audio_delegate_; | |
64 views::CustomButton* more_button_; | 57 views::CustomButton* more_button_; |
65 VolumeButton* icon_; | 58 VolumeButton* icon_; |
66 views::Slider* slider_; | 59 views::Slider* slider_; |
67 views::ImageView* device_type_; | 60 views::ImageView* device_type_; |
68 bool is_default_view_; | 61 bool is_default_view_; |
69 | 62 |
70 DISALLOW_COPY_AND_ASSIGN(VolumeView); | 63 DISALLOW_COPY_AND_ASSIGN(VolumeView); |
71 }; | 64 }; |
72 | 65 |
73 } // namespace tray | 66 } // namespace tray |
74 } // namespace ash | 67 } // namespace ash |
75 | 68 |
76 #endif // ASH_COMMON_SYSTEM_CHROMEOS_AUDIO_VOLUME_VIEW_H_ | 69 #endif // ASH_COMMON_SYSTEM_CHROMEOS_AUDIO_VOLUME_VIEW_H_ |
OLD | NEW |