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

Side by Side Diff: views/controls/throbber.cc

Issue 113443: ChromeCanvas->gfx::Canvas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « views/controls/throbber.h ('k') | views/controls/tree/tree_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "views/controls/throbber.h" 5 #include "views/controls/throbber.h"
6 6
7 #include "app/gfx/chrome_canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "grit/theme_resources.h" 10 #include "grit/theme_resources.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkBitmap.h"
12 12
13 using base::Time; 13 using base::Time;
14 using base::TimeDelta; 14 using base::TimeDelta;
15 15
16 namespace views { 16 namespace views {
17 17
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 void Throbber::Run() { 59 void Throbber::Run() {
60 DCHECK(running_); 60 DCHECK(running_);
61 61
62 SchedulePaint(); 62 SchedulePaint();
63 } 63 }
64 64
65 gfx::Size Throbber::GetPreferredSize() { 65 gfx::Size Throbber::GetPreferredSize() {
66 return gfx::Size(frames_->height(), frames_->height()); 66 return gfx::Size(frames_->height(), frames_->height());
67 } 67 }
68 68
69 void Throbber::Paint(ChromeCanvas* canvas) { 69 void Throbber::Paint(gfx::Canvas* canvas) {
70 if (!running_ && !paint_while_stopped_) 70 if (!running_ && !paint_while_stopped_)
71 return; 71 return;
72 72
73 const TimeDelta elapsed_time = Time::Now() - start_time_; 73 const TimeDelta elapsed_time = Time::Now() - start_time_;
74 const int current_frame = 74 const int current_frame =
75 static_cast<int>(elapsed_time / frame_time_) % frame_count_; 75 static_cast<int>(elapsed_time / frame_time_) % frame_count_;
76 76
77 int image_size = frames_->height(); 77 int image_size = frames_->height();
78 int image_offset = current_frame * image_size; 78 int image_offset = current_frame * image_size;
79 canvas->DrawBitmapInt(*frames_, 79 canvas->DrawBitmapInt(*frames_,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 134
135 void CheckmarkThrobber::SetChecked(bool checked) { 135 void CheckmarkThrobber::SetChecked(bool checked) {
136 bool changed = checked != checked_; 136 bool changed = checked != checked_;
137 if (changed) { 137 if (changed) {
138 checked_ = checked; 138 checked_ = checked;
139 SchedulePaint(); 139 SchedulePaint();
140 } 140 }
141 } 141 }
142 142
143 void CheckmarkThrobber::Paint(ChromeCanvas* canvas) { 143 void CheckmarkThrobber::Paint(gfx::Canvas* canvas) {
144 if (running_) { 144 if (running_) {
145 // Let the throbber throb... 145 // Let the throbber throb...
146 Throbber::Paint(canvas); 146 Throbber::Paint(canvas);
147 return; 147 return;
148 } 148 }
149 // Otherwise we paint our tick mark or nothing depending on our state. 149 // Otherwise we paint our tick mark or nothing depending on our state.
150 if (checked_) { 150 if (checked_) {
151 int checkmark_x = (width() - checkmark_->width()) / 2; 151 int checkmark_x = (width() - checkmark_->width()) / 2;
152 int checkmark_y = (height() - checkmark_->height()) / 2; 152 int checkmark_y = (height() - checkmark_->height()) / 2;
153 canvas->DrawBitmapInt(*checkmark_, checkmark_x, checkmark_y); 153 canvas->DrawBitmapInt(*checkmark_, checkmark_x, checkmark_y);
154 } 154 }
155 } 155 }
156 156
157 // static 157 // static
158 void CheckmarkThrobber::InitClass() { 158 void CheckmarkThrobber::InitClass() {
159 static bool initialized = false; 159 static bool initialized = false;
160 if (!initialized) { 160 if (!initialized) {
161 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 161 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
162 checkmark_ = rb.GetBitmapNamed(IDR_INPUT_GOOD); 162 checkmark_ = rb.GetBitmapNamed(IDR_INPUT_GOOD);
163 initialized = true; 163 initialized = true;
164 } 164 }
165 } 165 }
166 166
167 // static 167 // static
168 SkBitmap* CheckmarkThrobber::checkmark_ = NULL; 168 SkBitmap* CheckmarkThrobber::checkmark_ = NULL;
169 169
170 } // namespace views 170 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/throbber.h ('k') | views/controls/tree/tree_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698