| OLD | NEW |
| 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_BUTTON_IMAGE_BUTTON_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
| 6 #define UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "ui/base/layout.h" | 12 #include "ui/base/layout.h" |
| 12 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
| 13 #include "ui/views/controls/button/custom_button.h" | 14 #include "ui/views/controls/button/custom_button.h" |
| 14 | 15 |
| 15 namespace views { | 16 namespace views { |
| 16 | 17 |
| 17 class Painter; | 18 class Painter; |
| 18 | 19 |
| 19 // An image button. | 20 // An image button. |
| 20 | 21 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 49 | 50 |
| 50 // Set the background details. | 51 // Set the background details. |
| 51 void SetBackground(SkColor color, | 52 void SetBackground(SkColor color, |
| 52 const gfx::ImageSkia* image, | 53 const gfx::ImageSkia* image, |
| 53 const gfx::ImageSkia* mask); | 54 const gfx::ImageSkia* mask); |
| 54 | 55 |
| 55 // Sets how the image is laid out within the button's bounds. | 56 // Sets how the image is laid out within the button's bounds. |
| 56 void SetImageAlignment(HorizontalAlignment h_align, | 57 void SetImageAlignment(HorizontalAlignment h_align, |
| 57 VerticalAlignment v_align); | 58 VerticalAlignment v_align); |
| 58 | 59 |
| 59 void SetFocusPainter(scoped_ptr<Painter> focus_painter); | 60 void SetFocusPainter(std::unique_ptr<Painter> focus_painter); |
| 60 | 61 |
| 61 // The minimum size of the contents (not including the border). The contents | 62 // The minimum size of the contents (not including the border). The contents |
| 62 // will be at least this size, but may be larger if the image itself is | 63 // will be at least this size, but may be larger if the image itself is |
| 63 // larger. | 64 // larger. |
| 64 const gfx::Size& minimum_image_size() const { return minimum_image_size_; } | 65 const gfx::Size& minimum_image_size() const { return minimum_image_size_; } |
| 65 void SetMinimumImageSize(const gfx::Size& size); | 66 void SetMinimumImageSize(const gfx::Size& size); |
| 66 | 67 |
| 67 // Whether we should draw our images resources horizontally flipped. | 68 // Whether we should draw our images resources horizontally flipped. |
| 68 void SetDrawImageMirrored(bool mirrored) { | 69 void SetDrawImageMirrored(bool mirrored) { |
| 69 draw_image_mirrored_ = mirrored; | 70 draw_image_mirrored_ = mirrored; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 HorizontalAlignment h_alignment_; | 107 HorizontalAlignment h_alignment_; |
| 107 VerticalAlignment v_alignment_; | 108 VerticalAlignment v_alignment_; |
| 108 gfx::Size minimum_image_size_; | 109 gfx::Size minimum_image_size_; |
| 109 | 110 |
| 110 // Whether we draw our resources horizontally flipped. This can happen in the | 111 // Whether we draw our resources horizontally flipped. This can happen in the |
| 111 // linux titlebar, where image resources were designed to be flipped so a | 112 // linux titlebar, where image resources were designed to be flipped so a |
| 112 // small curved corner in the close button designed to fit into the frame | 113 // small curved corner in the close button designed to fit into the frame |
| 113 // resources. | 114 // resources. |
| 114 bool draw_image_mirrored_; | 115 bool draw_image_mirrored_; |
| 115 | 116 |
| 116 scoped_ptr<Painter> focus_painter_; | 117 std::unique_ptr<Painter> focus_painter_; |
| 117 | 118 |
| 118 DISALLOW_COPY_AND_ASSIGN(ImageButton); | 119 DISALLOW_COPY_AND_ASSIGN(ImageButton); |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 //////////////////////////////////////////////////////////////////////////////// | 122 //////////////////////////////////////////////////////////////////////////////// |
| 122 // | 123 // |
| 123 // ToggleImageButton | 124 // ToggleImageButton |
| 124 // | 125 // |
| 125 // A toggle-able ImageButton. It swaps out its graphics when toggled. | 126 // A toggle-able ImageButton. It swaps out its graphics when toggled. |
| 126 // | 127 // |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // The parent class's tooltip_text_ is displayed when not toggled, and | 163 // The parent class's tooltip_text_ is displayed when not toggled, and |
| 163 // this one is shown when toggled. | 164 // this one is shown when toggled. |
| 164 base::string16 toggled_tooltip_text_; | 165 base::string16 toggled_tooltip_text_; |
| 165 | 166 |
| 166 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); | 167 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); |
| 167 }; | 168 }; |
| 168 | 169 |
| 169 } // namespace views | 170 } // namespace views |
| 170 | 171 |
| 171 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 172 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
| OLD | NEW |