| OLD | NEW |
| 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/button/text_button.h" | 5 #include "views/controls/button/text_button.h" |
| 6 | 6 |
| 7 #include "app/gfx/chrome_canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 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 "views/controls/button/button.h" | 11 #include "views/controls/button/button.h" |
| 12 #include "views/event.h" | 12 #include "views/event.h" |
| 13 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 | 16 |
| 17 // Padding between the icon and text. | 17 // Padding between the icon and text. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 TextButtonBorder::~TextButtonBorder() { | 61 TextButtonBorder::~TextButtonBorder() { |
| 62 } | 62 } |
| 63 | 63 |
| 64 //////////////////////////////////////////////////////////////////////////////// | 64 //////////////////////////////////////////////////////////////////////////////// |
| 65 // | 65 // |
| 66 // TextButtonBackground - painting | 66 // TextButtonBackground - painting |
| 67 // | 67 // |
| 68 //////////////////////////////////////////////////////////////////////////////// | 68 //////////////////////////////////////////////////////////////////////////////// |
| 69 | 69 |
| 70 void TextButtonBorder::Paint(const View& view, ChromeCanvas* canvas) const { | 70 void TextButtonBorder::Paint(const View& view, gfx::Canvas* canvas) const { |
| 71 const TextButton* mb = static_cast<const TextButton*>(&view); | 71 const TextButton* mb = static_cast<const TextButton*>(&view); |
| 72 int state = mb->state(); | 72 int state = mb->state(); |
| 73 | 73 |
| 74 // TextButton takes care of deciding when to call Paint. | 74 // TextButton takes care of deciding when to call Paint. |
| 75 const MBBImageSet* set = &hot_set_; | 75 const MBBImageSet* set = &hot_set_; |
| 76 if (state == TextButton::BS_PUSHED) | 76 if (state == TextButton::BS_PUSHED) |
| 77 set = &pushed_set_; | 77 set = &pushed_set_; |
| 78 | 78 |
| 79 if (set) { | 79 if (set) { |
| 80 gfx::Rect bounds = view.bounds(); | 80 gfx::Rect bounds = view.bounds(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 | 176 |
| 177 void TextButton::SetIcon(const SkBitmap& icon) { | 177 void TextButton::SetIcon(const SkBitmap& icon) { |
| 178 icon_ = icon; | 178 icon_ = icon; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void TextButton::ClearMaxTextSize() { | 181 void TextButton::ClearMaxTextSize() { |
| 182 max_text_size_ = text_size_; | 182 max_text_size_ = text_size_; |
| 183 } | 183 } |
| 184 | 184 |
| 185 void TextButton::Paint(ChromeCanvas* canvas, bool for_drag) { | 185 void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) { |
| 186 if (!for_drag) { | 186 if (!for_drag) { |
| 187 PaintBackground(canvas); | 187 PaintBackground(canvas); |
| 188 | 188 |
| 189 if (hover_animation_->IsAnimating()) { | 189 if (hover_animation_->IsAnimating()) { |
| 190 // Draw the hover bitmap into an offscreen buffer, then blend it | 190 // Draw the hover bitmap into an offscreen buffer, then blend it |
| 191 // back into the current canvas. | 191 // back into the current canvas. |
| 192 canvas->saveLayerAlpha(NULL, | 192 canvas->saveLayerAlpha(NULL, |
| 193 static_cast<int>(hover_animation_->GetCurrentValue() * 255), | 193 static_cast<int>(hover_animation_->GetCurrentValue() * 255), |
| 194 SkCanvas::kARGB_NoClipLayer_SaveFlag); | 194 SkCanvas::kARGB_NoClipLayer_SaveFlag); |
| 195 canvas->drawARGB(0, 255, 255, 255, SkPorterDuff::kClear_Mode); | 195 canvas->drawARGB(0, 255, 255, 255, SkPorterDuff::kClear_Mode); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 return; | 311 return; |
| 312 CustomButton::SetEnabled(enabled); | 312 CustomButton::SetEnabled(enabled); |
| 313 color_ = enabled ? kEnabledColor : kDisabledColor; | 313 color_ = enabled ? kEnabledColor : kDisabledColor; |
| 314 SchedulePaint(); | 314 SchedulePaint(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 bool TextButton::OnMousePressed(const MouseEvent& e) { | 317 bool TextButton::OnMousePressed(const MouseEvent& e) { |
| 318 return true; | 318 return true; |
| 319 } | 319 } |
| 320 | 320 |
| 321 void TextButton::Paint(ChromeCanvas* canvas) { | 321 void TextButton::Paint(gfx::Canvas* canvas) { |
| 322 Paint(canvas, false); | 322 Paint(canvas, false); |
| 323 } | 323 } |
| 324 | 324 |
| 325 } // namespace views | 325 } // namespace views |
| OLD | NEW |