Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: ui/views/controls/throbber.h

Issue 1067593006: Implement material throbber and use it in one place (Autofill card (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 23 matching lines...) Expand all
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 gfx::Size GetPreferredSize() const override; 40 gfx::Size GetPreferredSize() const override;
41 void OnPaint(gfx::Canvas* canvas) override; 41 void OnPaint(gfx::Canvas* canvas) override;
42 42
43 protected: 43 protected:
44 const base::Time& start_time() { return start_time_; }
sky 2015/04/21 20:17:38 It's my understanding we return times by value and
Evan Stade 2015/04/21 22:04:02 Done
45
44 // Specifies whether the throbber is currently animating or not 46 // Specifies whether the throbber is currently animating or not
45 bool running_; 47 bool running_;
sky 2015/04/21 20:17:38 Style guide says no protected members.
Evan Stade 2015/04/21 22:04:02 fixed
46 48
47 private: 49 private:
48 void Run(); 50 void Run();
49 51
50 bool paint_while_stopped_; 52 bool paint_while_stopped_;
51 int frame_count_; // How many frames we have. 53 int frame_count_; // How many frames we have.
52 base::Time start_time_; // Time when Start was called. 54 base::Time start_time_; // Time when Start was called.
53 const gfx::ImageSkia* frames_; // Frames images. 55 const gfx::ImageSkia* frames_; // Frames images.
54 base::TimeDelta frame_time_; // How long one frame is displayed. 56 base::TimeDelta frame_time_; // How long one frame is displayed.
55 base::RepeatingTimer<Throbber> timer_; // Used to schedule Run calls. 57 base::RepeatingTimer<Throbber> timer_; // Used to schedule Run calls.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 }; 97 };
96 98
97 // A CheckmarkThrobber is a special variant of throbber that has three states: 99 // A CheckmarkThrobber is a special variant of throbber that has three states:
98 // 1. not yet completed (which paints nothing) 100 // 1. not yet completed (which paints nothing)
99 // 2. working (which paints the throbber animation) 101 // 2. working (which paints the throbber animation)
100 // 3. completed (which paints a checkmark) 102 // 3. completed (which paints a checkmark)
101 // 103 //
102 class VIEWS_EXPORT CheckmarkThrobber : public Throbber { 104 class VIEWS_EXPORT CheckmarkThrobber : public Throbber {
103 public: 105 public:
104 CheckmarkThrobber(); 106 CheckmarkThrobber();
107 ~CheckmarkThrobber() override;
105 108
106 // If checked is true, the throbber stops spinning and displays a checkmark. 109 // If checked is true, the throbber stops spinning and displays a checkmark.
107 // If checked is false, the throbber stops spinning and displays nothing. 110 // If checked is false, the throbber stops spinning and displays nothing.
108 void SetChecked(bool checked); 111 void SetChecked(bool checked);
109 112
110 // Overridden from Throbber: 113 // Overridden from Throbber:
111 void OnPaint(gfx::Canvas* canvas) override; 114 void OnPaint(gfx::Canvas* canvas) override;
112 115
113 private: 116 private:
114 static const int kFrameTimeMs = 30; 117 static const int kFrameTimeMs = 30;
115 118
116 // Whether or not we should display a checkmark. 119 // Whether or not we should display a checkmark.
117 bool checked_; 120 bool checked_;
118 121
119 // The checkmark image. 122 // The checkmark image.
120 const gfx::ImageSkia* checkmark_; 123 const gfx::ImageSkia* checkmark_;
121 124
122 DISALLOW_COPY_AND_ASSIGN(CheckmarkThrobber); 125 DISALLOW_COPY_AND_ASSIGN(CheckmarkThrobber);
123 }; 126 };
124 127
128 // A throbber that follows material design guidelines. This is a specialization
129 // of CheckmarkThrobber for now, but should probably replace Throbber
130 // eventually.
131 class VIEWS_EXPORT MaterialThrobber : public CheckmarkThrobber {
sky 2015/04/21 20:17:38 Do we need both CheckmarkThrobber and MaterialThro
Evan Stade 2015/04/21 22:04:02 Good point. I was going to roll all three into Thr
132 public:
133 MaterialThrobber();
134 ~MaterialThrobber() override;
135
136 void set_preferred_diameter(int diameter) { preferred_diameter_ = diameter; }
sky 2015/04/21 20:17:38 It's unclear exactly what diameter in this context
Evan Stade 2015/04/21 22:04:02 But size sounds like a gfx::Size. I chose diameter
137
138 // View implementation.
139 gfx::Size GetPreferredSize() const override;
140 int GetHeightForWidth(int w) const override;
141 void OnPaint(gfx::Canvas* canvas) override;
142
143 private:
144 // The preferred width and height for this view. Zero indicates the size is
145 // set by the parent class (i.e. matches the size of the pre-material
146 // sprites).
147 int preferred_diameter_;
148
149 DISALLOW_COPY_AND_ASSIGN(MaterialThrobber);
150 };
151
125 } // namespace views 152 } // namespace views
126 153
127 #endif // UI_VIEWS_CONTROLS_THROBBER_H_ 154 #endif // UI_VIEWS_CONTROLS_THROBBER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/card_unmask_prompt_views.cc ('k') | ui/views/controls/throbber.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698