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 #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 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "base/gtest_prod_util.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
10 #include "ui/views/controls/button/custom_button.h" | 11 #include "ui/views/controls/button/custom_button.h" |
11 | 12 |
12 namespace views { | 13 namespace views { |
13 | 14 |
14 // An image button. | 15 // An image button. |
15 | 16 |
16 // Note that this type of button is not focusable by default and will not be | 17 // Note that this type of button is not focusable by default and will not be |
17 // part of the focus chain. Call set_focusable(true) to make it part of the | 18 // part of the focus chain. Call set_focusable(true) to make it part of the |
18 // focus chain. | 19 // focus chain. |
19 | 20 |
20 class VIEWS_EXPORT ImageButton : public CustomButton { | 21 class VIEWS_EXPORT ImageButton : public CustomButton { |
21 public: | 22 public: |
22 explicit ImageButton(ButtonListener* listener); | 23 explicit ImageButton(ButtonListener* listener); |
23 virtual ~ImageButton(); | 24 virtual ~ImageButton(); |
24 | 25 |
25 // Set the image the button should use for the provided state. | 26 // Set the image the button should use for the provided state. |
26 virtual void SetImage(ButtonState state, const SkBitmap* image); | 27 virtual void SetImage(ButtonState state, const SkBitmap* image); |
27 | 28 |
28 // Set the background details. | 29 // Set the background details. |
29 void SetBackground(SkColor color, | 30 void SetBackground(SkColor color, |
30 const SkBitmap* image, | 31 const SkBitmap* image, |
31 const SkBitmap* mask); | 32 const SkBitmap* mask); |
32 | 33 |
| 34 // Set an |image| to draw on top of the normal / hot / pushed image. |
| 35 // Pass NULL for no image. |
| 36 void SetOverlayImage(const SkBitmap* image); |
| 37 |
33 enum HorizontalAlignment { ALIGN_LEFT = 0, | 38 enum HorizontalAlignment { ALIGN_LEFT = 0, |
34 ALIGN_CENTER, | 39 ALIGN_CENTER, |
35 ALIGN_RIGHT, }; | 40 ALIGN_RIGHT, }; |
36 | 41 |
37 enum VerticalAlignment { ALIGN_TOP = 0, | 42 enum VerticalAlignment { ALIGN_TOP = 0, |
38 ALIGN_MIDDLE, | 43 ALIGN_MIDDLE, |
39 ALIGN_BOTTOM }; | 44 ALIGN_BOTTOM }; |
40 | 45 |
41 // Sets how the image is laid out within the button's bounds. | 46 // Sets how the image is laid out within the button's bounds. |
42 void SetImageAlignment(HorizontalAlignment h_align, | 47 void SetImageAlignment(HorizontalAlignment h_align, |
(...skipping 13 matching lines...) Expand all Loading... |
56 // Returns the image to paint. This is invoked from paint and returns a value | 61 // Returns the image to paint. This is invoked from paint and returns a value |
57 // from images. | 62 // from images. |
58 virtual SkBitmap GetImageToPaint(); | 63 virtual SkBitmap GetImageToPaint(); |
59 | 64 |
60 // The images used to render the different states of this button. | 65 // The images used to render the different states of this button. |
61 SkBitmap images_[BS_COUNT]; | 66 SkBitmap images_[BS_COUNT]; |
62 | 67 |
63 // The background image. | 68 // The background image. |
64 SkBitmap background_image_; | 69 SkBitmap background_image_; |
65 | 70 |
| 71 // Image to draw on top of normal / hot / pushed image. Usually empty. |
| 72 SkBitmap overlay_image_; |
| 73 |
66 private: | 74 private: |
| 75 FRIEND_TEST_ALL_PREFIXES(ImageButtonTest, Basics); |
| 76 |
67 // Image alignment. | 77 // Image alignment. |
68 HorizontalAlignment h_alignment_; | 78 HorizontalAlignment h_alignment_; |
69 VerticalAlignment v_alignment_; | 79 VerticalAlignment v_alignment_; |
70 gfx::Size preferred_size_; | 80 gfx::Size preferred_size_; |
71 | 81 |
72 DISALLOW_COPY_AND_ASSIGN(ImageButton); | 82 DISALLOW_COPY_AND_ASSIGN(ImageButton); |
73 }; | 83 }; |
74 | 84 |
75 //////////////////////////////////////////////////////////////////////////////// | 85 //////////////////////////////////////////////////////////////////////////////// |
76 // | 86 // |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // The parent class's tooltip_text_ is displayed when not toggled, and | 124 // The parent class's tooltip_text_ is displayed when not toggled, and |
115 // this one is shown when toggled. | 125 // this one is shown when toggled. |
116 string16 toggled_tooltip_text_; | 126 string16 toggled_tooltip_text_; |
117 | 127 |
118 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); | 128 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); |
119 }; | 129 }; |
120 | 130 |
121 } // namespace views | 131 } // namespace views |
122 | 132 |
123 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 133 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
OLD | NEW |