• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef ASH_SYSTEM_AUDIO_VOLUME_VIEW_H_
6 #define ASH_SYSTEM_AUDIO_VOLUME_VIEW_H_
7 
8 #include "ash/system/tray/actionable_view.h"
9 #include "ui/gfx/font.h"
10 #include "ui/views/controls/button/button.h"
11 #include "ui/views/controls/slider.h"
12 
13 namespace views {
14 class View;
15 class ImageView;
16 }
17 
18 namespace ash {
19 class HoverHighlightView;
20 class SystemTrayItem;
21 
22 namespace system {
23 class TrayAudioDelegate;
24 }
25 
26 namespace tray {
27 class BarSeparator;
28 class VolumeButton;
29 class VolumeSlider;
30 
31 class VolumeView : public ActionableView,
32                    public views::ButtonListener,
33                    public views::SliderListener {
34  public:
35   VolumeView(SystemTrayItem* owner,
36              system::TrayAudioDelegate* audio_delegate,
37              bool is_default_view);
38 
39   virtual ~VolumeView();
40 
41   void Update();
42 
43   // Sets volume level on slider_, |percent| is ranged from [0.00] to [1.00].
44   void SetVolumeLevel(float percent);
45 
46  private:
47   // Updates bar_, device_type_ icon, and more_ buttons.
48   void UpdateDeviceTypeAndMore();
49   void HandleVolumeUp(float percent);
50   void HandleVolumeDown(float percent);
51 
52   // Overridden from views::View.
53   virtual void Layout() OVERRIDE;
54 
55   // Overridden from views::ButtonListener.
56   virtual void ButtonPressed(views::Button* sender,
57                              const ui::Event& event) OVERRIDE;
58 
59   // Overridden from views::SliderListener.
60   virtual void SliderValueChanged(views::Slider* sender,
61                                   float value,
62                                   float old_value,
63                                   views::SliderChangeReason reason) OVERRIDE;
64 
65   // Overriden from ActionableView.
66   virtual bool PerformAction(const ui::Event& event) OVERRIDE;
67 
68   SystemTrayItem* owner_;
69   system::TrayAudioDelegate* audio_delegate_;
70   VolumeButton* icon_;
71   VolumeSlider* slider_;
72   BarSeparator* bar_;
73   views::ImageView* device_type_;
74   views::ImageView* more_;
75   bool is_default_view_;
76 
77   DISALLOW_COPY_AND_ASSIGN(VolumeView);
78 };
79 
80 }  // namespace tray
81 }  // namespace ash
82 
83 #endif  // ASH_SYSTEM_AUDIO_VOLUME_VIEW_H_
84 
85