| OLD | NEW |
| 1 // Copyright (c) 2011 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 #include "ui/views/controls/button/image_button.h" | 5 #include "ui/views/controls/button/image_button.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "ui/base/animation/throb_animation.h" | 8 #include "ui/base/animation/throb_animation.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/skbitmap_operations.h" | 10 #include "ui/gfx/skbitmap_operations.h" |
| 11 | 11 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 //////////////////////////////////////////////////////////////////////////////// | 58 //////////////////////////////////////////////////////////////////////////////// |
| 59 // ImageButton, View overrides: | 59 // ImageButton, View overrides: |
| 60 | 60 |
| 61 gfx::Size ImageButton::GetPreferredSize() { | 61 gfx::Size ImageButton::GetPreferredSize() { |
| 62 if (!images_[BS_NORMAL].isNull()) | 62 if (!images_[BS_NORMAL].isNull()) |
| 63 return gfx::Size(images_[BS_NORMAL].width(), images_[BS_NORMAL].height()); | 63 return gfx::Size(images_[BS_NORMAL].width(), images_[BS_NORMAL].height()); |
| 64 return preferred_size_; | 64 return preferred_size_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ImageButton::OnPaint(gfx::Canvas* canvas) { | 67 void ImageButton::OnPaint(gfx::CanvasSkia* canvas) { |
| 68 // Call the base class first to paint any background/borders. | 68 // Call the base class first to paint any background/borders. |
| 69 View::OnPaint(canvas); | 69 View::OnPaint(canvas); |
| 70 | 70 |
| 71 SkBitmap img = GetImageToPaint(); | 71 SkBitmap img = GetImageToPaint(); |
| 72 | 72 |
| 73 if (!img.isNull()) { | 73 if (!img.isNull()) { |
| 74 int x = 0, y = 0; | 74 int x = 0, y = 0; |
| 75 | 75 |
| 76 if (h_alignment_ == ALIGN_CENTER) | 76 if (h_alignment_ == ALIGN_CENTER) |
| 77 x = (width() - img.width()) / 2; | 77 x = (width() - img.width()) / 2; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 bool ToggleImageButton::GetTooltipText(const gfx::Point& p, | 165 bool ToggleImageButton::GetTooltipText(const gfx::Point& p, |
| 166 string16* tooltip) const { | 166 string16* tooltip) const { |
| 167 if (!toggled_ || toggled_tooltip_text_.empty()) | 167 if (!toggled_ || toggled_tooltip_text_.empty()) |
| 168 return Button::GetTooltipText(p, tooltip); | 168 return Button::GetTooltipText(p, tooltip); |
| 169 | 169 |
| 170 *tooltip = toggled_tooltip_text_; | 170 *tooltip = toggled_tooltip_text_; |
| 171 return true; | 171 return true; |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace views | 174 } // namespace views |
| OLD | NEW |