Chromium Code Reviews| 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.h" | 10 #include "base/time.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 Throbber(int frame_time_ms, bool paint_while_stopped, gfx::ImageSkia* frames); | 29 Throbber(int frame_time_ms, bool paint_while_stopped, gfx::ImageSkia* frames); |
| 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 void set_interactive(bool interactive) { interactive_ = interactive; } | |
| 40 | |
| 39 // Overridden from View: | 41 // Overridden from View: |
| 40 virtual gfx::Size GetPreferredSize() OVERRIDE; | 42 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 43 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 44 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; | |
|
sadrul
2013/02/05 02:31:42
You can do this by overriding HasHitTestMask too.
| |
| 42 | 45 |
| 43 protected: | 46 protected: |
| 44 // Specifies whether the throbber is currently animating or not | 47 // Specifies whether the throbber is currently animating or not |
| 45 bool running_; | 48 bool running_; |
| 46 | 49 |
| 47 private: | 50 private: |
| 48 void Run(); | 51 void Run(); |
| 49 | 52 |
| 50 bool paint_while_stopped_; | 53 bool paint_while_stopped_; |
| 51 int frame_count_; // How many frames we have. | 54 int frame_count_; // How many frames we have. |
| 52 base::Time start_time_; // Time when Start was called. | 55 base::Time start_time_; // Time when Start was called. |
| 53 const gfx::ImageSkia* frames_; // Frames images. | 56 const gfx::ImageSkia* frames_; // Frames images. |
| 54 base::TimeDelta frame_time_; // How long one frame is displayed. | 57 base::TimeDelta frame_time_; // How long one frame is displayed. |
| 55 base::RepeatingTimer<Throbber> timer_; // Used to schedule Run calls. | 58 base::RepeatingTimer<Throbber> timer_; // Used to schedule Run calls. |
| 56 | 59 |
| 60 // A flag controlling hit test handling for interactivity. | |
| 61 bool interactive_; | |
| 62 | |
| 57 DISALLOW_COPY_AND_ASSIGN(Throbber); | 63 DISALLOW_COPY_AND_ASSIGN(Throbber); |
| 58 }; | 64 }; |
| 59 | 65 |
| 60 // A SmoothedThrobber is a throbber that is representing potentially short | 66 // A SmoothedThrobber is a throbber that is representing potentially short |
| 61 // and nonoverlapping bursts of work. SmoothedThrobber ignores small | 67 // and nonoverlapping bursts of work. SmoothedThrobber ignores small |
| 62 // pauses in the work stops and starts, and only starts its throbber after | 68 // pauses in the work stops and starts, and only starts its throbber after |
| 63 // a small amount of work time has passed. | 69 // a small amount of work time has passed. |
| 64 class VIEWS_EXPORT SmoothedThrobber : public Throbber { | 70 class VIEWS_EXPORT SmoothedThrobber : public Throbber { |
| 65 public: | 71 public: |
| 66 explicit SmoothedThrobber(int frame_delay_ms); | 72 explicit SmoothedThrobber(int frame_delay_ms); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 | 124 |
| 119 // The checkmark image. | 125 // The checkmark image. |
| 120 const gfx::ImageSkia* checkmark_; | 126 const gfx::ImageSkia* checkmark_; |
| 121 | 127 |
| 122 DISALLOW_COPY_AND_ASSIGN(CheckmarkThrobber); | 128 DISALLOW_COPY_AND_ASSIGN(CheckmarkThrobber); |
| 123 }; | 129 }; |
| 124 | 130 |
| 125 } // namespace views | 131 } // namespace views |
| 126 | 132 |
| 127 #endif // UI_VIEWS_CONTROLS_THROBBER_H_ | 133 #endif // UI_VIEWS_CONTROLS_THROBBER_H_ |
| OLD | NEW |