OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_VIEWS_CONTROLS_THROBBER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_THROBBER_H_ |
6 #define UI_VIEWS_CONTROLS_THROBBER_H_ | 6 #define UI_VIEWS_CONTROLS_THROBBER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 virtual ~Throbber(); | 30 virtual ~Throbber(); |
31 | 31 |
32 // Start and stop the throbber animation | 32 // Start and stop the throbber animation |
33 virtual void Start(); | 33 virtual void Start(); |
34 virtual void Stop(); | 34 virtual void Stop(); |
35 | 35 |
36 // Set custom throbber frames. Otherwise IDR_THROBBER is loaded. | 36 // Set custom throbber frames. Otherwise IDR_THROBBER is loaded. |
37 void SetFrames(const gfx::ImageSkia* frames); | 37 void SetFrames(const gfx::ImageSkia* frames); |
38 | 38 |
39 // Overridden from View: | 39 // Overridden from View: |
40 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 40 virtual gfx::Size GetPreferredSize() const override; |
41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 41 virtual void OnPaint(gfx::Canvas* canvas) override; |
42 | 42 |
43 protected: | 43 protected: |
44 // Specifies whether the throbber is currently animating or not | 44 // Specifies whether the throbber is currently animating or not |
45 bool running_; | 45 bool running_; |
46 | 46 |
47 private: | 47 private: |
48 void Run(); | 48 void Run(); |
49 | 49 |
50 bool paint_while_stopped_; | 50 bool paint_while_stopped_; |
51 int frame_count_; // How many frames we have. | 51 int frame_count_; // How many frames we have. |
52 base::Time start_time_; // Time when Start was called. | 52 base::Time start_time_; // Time when Start was called. |
53 const gfx::ImageSkia* frames_; // Frames images. | 53 const gfx::ImageSkia* frames_; // Frames images. |
54 base::TimeDelta frame_time_; // How long one frame is displayed. | 54 base::TimeDelta frame_time_; // How long one frame is displayed. |
55 base::RepeatingTimer<Throbber> timer_; // Used to schedule Run calls. | 55 base::RepeatingTimer<Throbber> timer_; // Used to schedule Run calls. |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(Throbber); | 57 DISALLOW_COPY_AND_ASSIGN(Throbber); |
58 }; | 58 }; |
59 | 59 |
60 // A SmoothedThrobber is a throbber that is representing potentially short | 60 // A SmoothedThrobber is a throbber that is representing potentially short |
61 // and nonoverlapping bursts of work. SmoothedThrobber ignores small | 61 // and nonoverlapping bursts of work. SmoothedThrobber ignores small |
62 // pauses in the work stops and starts, and only starts its throbber after | 62 // pauses in the work stops and starts, and only starts its throbber after |
63 // a small amount of work time has passed. | 63 // a small amount of work time has passed. |
64 class VIEWS_EXPORT SmoothedThrobber : public Throbber { | 64 class VIEWS_EXPORT SmoothedThrobber : public Throbber { |
65 public: | 65 public: |
66 explicit SmoothedThrobber(int frame_delay_ms); | 66 explicit SmoothedThrobber(int frame_delay_ms); |
67 SmoothedThrobber(int frame_delay_ms, gfx::ImageSkia* frames); | 67 SmoothedThrobber(int frame_delay_ms, gfx::ImageSkia* frames); |
68 virtual ~SmoothedThrobber(); | 68 virtual ~SmoothedThrobber(); |
69 | 69 |
70 virtual void Start() OVERRIDE; | 70 virtual void Start() override; |
71 virtual void Stop() OVERRIDE; | 71 virtual void Stop() override; |
72 | 72 |
73 void set_start_delay_ms(int value) { start_delay_ms_ = value; } | 73 void set_start_delay_ms(int value) { start_delay_ms_ = value; } |
74 void set_stop_delay_ms(int value) { stop_delay_ms_ = value; } | 74 void set_stop_delay_ms(int value) { stop_delay_ms_ = value; } |
75 | 75 |
76 private: | 76 private: |
77 // Called when the startup-delay timer fires | 77 // Called when the startup-delay timer fires |
78 // This function starts the actual throbbing. | 78 // This function starts the actual throbbing. |
79 void StartDelayOver(); | 79 void StartDelayOver(); |
80 | 80 |
81 // Called when the shutdown-delay timer fires. | 81 // Called when the shutdown-delay timer fires. |
(...skipping 19 matching lines...) Expand all Loading... |
101 // | 101 // |
102 class VIEWS_EXPORT CheckmarkThrobber : public Throbber { | 102 class VIEWS_EXPORT CheckmarkThrobber : public Throbber { |
103 public: | 103 public: |
104 CheckmarkThrobber(); | 104 CheckmarkThrobber(); |
105 | 105 |
106 // If checked is true, the throbber stops spinning and displays a checkmark. | 106 // If checked is true, the throbber stops spinning and displays a checkmark. |
107 // If checked is false, the throbber stops spinning and displays nothing. | 107 // If checked is false, the throbber stops spinning and displays nothing. |
108 void SetChecked(bool checked); | 108 void SetChecked(bool checked); |
109 | 109 |
110 // Overridden from Throbber: | 110 // Overridden from Throbber: |
111 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 111 virtual void OnPaint(gfx::Canvas* canvas) override; |
112 | 112 |
113 private: | 113 private: |
114 static const int kFrameTimeMs = 30; | 114 static const int kFrameTimeMs = 30; |
115 | 115 |
116 // Whether or not we should display a checkmark. | 116 // Whether or not we should display a checkmark. |
117 bool checked_; | 117 bool checked_; |
118 | 118 |
119 // The checkmark image. | 119 // The checkmark image. |
120 const gfx::ImageSkia* checkmark_; | 120 const gfx::ImageSkia* checkmark_; |
121 | 121 |
122 DISALLOW_COPY_AND_ASSIGN(CheckmarkThrobber); | 122 DISALLOW_COPY_AND_ASSIGN(CheckmarkThrobber); |
123 }; | 123 }; |
124 | 124 |
125 } // namespace views | 125 } // namespace views |
126 | 126 |
127 #endif // UI_VIEWS_CONTROLS_THROBBER_H_ | 127 #endif // UI_VIEWS_CONTROLS_THROBBER_H_ |
OLD | NEW |