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> | 8 #include <memory> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 ALIGN_BOTTOM | 37 ALIGN_BOTTOM |
38 }; | 38 }; |
39 | 39 |
40 explicit ImageButton(ButtonListener* listener); | 40 explicit ImageButton(ButtonListener* listener); |
41 ~ImageButton() override; | 41 ~ImageButton() override; |
42 | 42 |
43 // Returns the image for a given |state|. | 43 // Returns the image for a given |state|. |
44 virtual const gfx::ImageSkia& GetImage(ButtonState state) const; | 44 virtual const gfx::ImageSkia& GetImage(ButtonState state) const; |
45 | 45 |
46 // Set the image the button should use for the provided state. | 46 // Set the image the button should use for the provided state. |
47 void SetImage(ButtonState state, const gfx::ImageSkia* image); | 47 virtual void SetImage(ButtonState state, const gfx::ImageSkia* image); |
48 | |
49 // As above, but takes a const ref. TODO(estade): all callers should be | |
50 // updated to use this version, and then the implementations can be | |
51 // consolidated. | |
52 virtual void SetImage(ButtonState state, const gfx::ImageSkia& image); | |
53 | 48 |
54 // Set the background details. | 49 // Set the background details. |
55 void SetBackground(SkColor color, | 50 void SetBackground(SkColor color, |
56 const gfx::ImageSkia* image, | 51 const gfx::ImageSkia* image, |
57 const gfx::ImageSkia* mask); | 52 const gfx::ImageSkia* mask); |
58 | 53 |
59 // Sets how the image is laid out within the button's bounds. | 54 // Sets how the image is laid out within the button's bounds. |
60 void SetImageAlignment(HorizontalAlignment h_align, | 55 void SetImageAlignment(HorizontalAlignment h_align, |
61 VerticalAlignment v_align); | 56 VerticalAlignment v_align); |
62 | 57 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Like ImageButton::SetImage(), but to set the graphics used for the | 135 // Like ImageButton::SetImage(), but to set the graphics used for the |
141 // "has been toggled" state. Must be called for each button state | 136 // "has been toggled" state. Must be called for each button state |
142 // before the button is toggled. | 137 // before the button is toggled. |
143 void SetToggledImage(ButtonState state, const gfx::ImageSkia* image); | 138 void SetToggledImage(ButtonState state, const gfx::ImageSkia* image); |
144 | 139 |
145 // Set the tooltip text displayed when the button is toggled. | 140 // Set the tooltip text displayed when the button is toggled. |
146 void SetToggledTooltipText(const base::string16& tooltip); | 141 void SetToggledTooltipText(const base::string16& tooltip); |
147 | 142 |
148 // Overridden from ImageButton: | 143 // Overridden from ImageButton: |
149 const gfx::ImageSkia& GetImage(ButtonState state) const override; | 144 const gfx::ImageSkia& GetImage(ButtonState state) const override; |
150 void SetImage(ButtonState state, const gfx::ImageSkia& image) override; | 145 void SetImage(ButtonState state, const gfx::ImageSkia* image) override; |
151 | 146 |
152 // Overridden from View: | 147 // Overridden from View: |
153 bool GetTooltipText(const gfx::Point& p, | 148 bool GetTooltipText(const gfx::Point& p, |
154 base::string16* tooltip) const override; | 149 base::string16* tooltip) const override; |
155 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 150 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
156 | 151 |
157 private: | 152 private: |
158 // The parent class's images_ member is used for the current images, | 153 // The parent class's images_ member is used for the current images, |
159 // and this array is used to hold the alternative images. | 154 // and this array is used to hold the alternative images. |
160 // We swap between the two when toggling. | 155 // We swap between the two when toggling. |
161 gfx::ImageSkia alternate_images_[STATE_COUNT]; | 156 gfx::ImageSkia alternate_images_[STATE_COUNT]; |
162 | 157 |
163 // True if the button is currently toggled. | 158 // True if the button is currently toggled. |
164 bool toggled_; | 159 bool toggled_; |
165 | 160 |
166 // The parent class's tooltip_text_ is displayed when not toggled, and | 161 // The parent class's tooltip_text_ is displayed when not toggled, and |
167 // this one is shown when toggled. | 162 // this one is shown when toggled. |
168 base::string16 toggled_tooltip_text_; | 163 base::string16 toggled_tooltip_text_; |
169 | 164 |
170 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); | 165 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); |
171 }; | 166 }; |
172 | 167 |
173 } // namespace views | 168 } // namespace views |
174 | 169 |
175 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 170 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
OLD | NEW |