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

Side by Side Diff: views/controls/button/text_button.cc

Issue 1961001: Refactors animation to allow for cleaner subclassing. I'm doing this (Closed)
Patch Set: Incorporated review feedback Created 10 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
« no previous file with comments | « views/controls/button/image_button.cc ('k') | no next file » | 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) 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 #include "views/controls/button/text_button.h" 5 #include "views/controls/button/text_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/throb_animation.h" 9 #include "app/throb_animation.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
11 #include "gfx/canvas.h" 11 #include "gfx/canvas.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 234 }
235 235
236 void TextButton::SetShowHighlighted(bool show_highlighted) { 236 void TextButton::SetShowHighlighted(bool show_highlighted) {
237 show_highlighted_ = show_highlighted; 237 show_highlighted_ = show_highlighted;
238 } 238 }
239 239
240 void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) { 240 void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) {
241 if (!for_drag) { 241 if (!for_drag) {
242 PaintBackground(canvas); 242 PaintBackground(canvas);
243 243
244 if (show_highlighted_ && hover_animation_->IsAnimating()) { 244 if (show_highlighted_ && hover_animation_->is_animating()) {
245 // Draw the hover bitmap into an offscreen buffer, then blend it 245 // Draw the hover bitmap into an offscreen buffer, then blend it
246 // back into the current canvas. 246 // back into the current canvas.
247 canvas->saveLayerAlpha(NULL, 247 canvas->saveLayerAlpha(NULL,
248 static_cast<int>(hover_animation_->GetCurrentValue() * 255), 248 static_cast<int>(hover_animation_->GetCurrentValue() * 255),
249 SkCanvas::kARGB_NoClipLayer_SaveFlag); 249 SkCanvas::kARGB_NoClipLayer_SaveFlag);
250 canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); 250 canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
251 PaintBorder(canvas); 251 PaintBorder(canvas);
252 canvas->restore(); 252 canvas->restore();
253 } else if ((show_highlighted_ && 253 } else if ((show_highlighted_ &&
254 (state_ == BS_HOT || state_ == BS_PUSHED)) || 254 (state_ == BS_HOT || state_ == BS_PUSHED)) ||
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 bool TextButton::OnMousePressed(const MouseEvent& e) { 399 bool TextButton::OnMousePressed(const MouseEvent& e) {
400 RequestFocus(); 400 RequestFocus();
401 return true; 401 return true;
402 } 402 }
403 403
404 void TextButton::Paint(gfx::Canvas* canvas) { 404 void TextButton::Paint(gfx::Canvas* canvas) {
405 Paint(canvas, false); 405 Paint(canvas, false);
406 } 406 }
407 407
408 } // namespace views 408 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/button/image_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698