OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_CHROMEOS_SETTING_LEVEL_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTING_LEVEL_BUBBLE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SETTING_LEVEL_BUBBLE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SETTING_LEVEL_BUBBLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "app/animation_delegate.h" | 9 #include "app/animation_delegate.h" |
10 #include "app/slide_animation.h" | 10 #include "app/slide_animation.h" |
11 #include "base/timer.h" | 11 #include "base/timer.h" |
12 #include "chrome/browser/views/info_bubble.h" | 12 #include "chrome/browser/views/info_bubble.h" |
13 | 13 |
14 class SkBitmap; | 14 class SkBitmap; |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 | 17 |
18 class SettingLevelBubbleView; | 18 class SettingLevelBubbleView; |
19 | 19 |
20 // Singleton class controlling a bubble displaying a level-based setting like | 20 // Singleton class controlling a bubble displaying a level-based setting like |
21 // volume or brightness. | 21 // volume or brightness. |
22 class SettingLevelBubble : public InfoBubbleDelegate, | 22 class SettingLevelBubble : public InfoBubbleDelegate, |
23 public AnimationDelegate { | 23 public AnimationDelegate { |
24 public: | 24 public: |
25 void ShowBubble(int percent); | 25 void ShowBubble(int percent); |
26 | 26 |
27 protected: | 27 protected: |
28 explicit SettingLevelBubble(SkBitmap* icon); | 28 explicit SettingLevelBubble(SkBitmap* increase_icon, |
| 29 SkBitmap* decrease_icon, |
| 30 SkBitmap* zero_icon); |
29 virtual ~SettingLevelBubble() {} | 31 virtual ~SettingLevelBubble() {} |
30 | 32 |
31 private: | 33 private: |
32 void OnTimeout(); | 34 void OnTimeout(); |
33 | 35 |
34 // Overridden from InfoBubbleDelegate. | 36 // Overridden from InfoBubbleDelegate. |
35 virtual void InfoBubbleClosing(InfoBubble* info_bubble, | 37 virtual void InfoBubbleClosing(InfoBubble* info_bubble, |
36 bool closed_by_escape); | 38 bool closed_by_escape); |
37 virtual bool CloseOnEscape() { return true; } | 39 virtual bool CloseOnEscape() { return true; } |
38 virtual bool FadeInOnShow() { return false; } | 40 virtual bool FadeInOnShow() { return false; } |
39 | 41 |
40 // Overridden from AnimationDelegate. | 42 // Overridden from AnimationDelegate. |
41 virtual void AnimationEnded(const Animation* animation); | 43 virtual void AnimationEnded(const Animation* animation); |
42 virtual void AnimationProgressed(const Animation* animation); | 44 virtual void AnimationProgressed(const Animation* animation); |
43 | 45 |
44 // Previous and current percentages, or -1 if not yet shown. | 46 // Previous and current percentages, or -1 if not yet shown. |
45 int previous_percent_; | 47 int previous_percent_; |
46 int current_percent_; | 48 int current_percent_; |
47 | 49 |
48 // Icon displayed in the bubble. Not owned by us. | 50 // Icons displayed in the bubble when increasing or decreasing the level or |
49 SkBitmap* icon_; | 51 // setting it to zero. Not owned by us. |
| 52 SkBitmap* increase_icon_; |
| 53 SkBitmap* decrease_icon_; |
| 54 SkBitmap* zero_icon_; |
50 | 55 |
51 // Currently shown bubble or NULL. | 56 // Currently shown bubble or NULL. |
52 InfoBubble* bubble_; | 57 InfoBubble* bubble_; |
53 | 58 |
54 // Its contents view, owned by InfoBubble. | 59 // Its contents view, owned by InfoBubble. |
55 SettingLevelBubbleView* view_; | 60 SettingLevelBubbleView* view_; |
56 | 61 |
57 SlideAnimation animation_; | 62 SlideAnimation animation_; |
58 base::OneShotTimer<SettingLevelBubble> timeout_timer_; | 63 base::OneShotTimer<SettingLevelBubble> timeout_timer_; |
59 | 64 |
60 DISALLOW_COPY_AND_ASSIGN(SettingLevelBubble); | 65 DISALLOW_COPY_AND_ASSIGN(SettingLevelBubble); |
61 }; | 66 }; |
62 | 67 |
63 } // namespace chromeos | 68 } // namespace chromeos |
64 | 69 |
65 #endif // CHROME_BROWSER_CHROMEOS_SETTING_LEVEL_BUBBLE_H_ | 70 #endif // CHROME_BROWSER_CHROMEOS_SETTING_LEVEL_BUBBLE_H_ |
OLD | NEW |