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 "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/gfx/image/image_skia.h" | 10 #include "ui/gfx/image/image_skia.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 // Sets preferred size, so it could be correctly positioned in layout even if | 58 // Sets preferred size, so it could be correctly positioned in layout even if |
59 // it is NULL. | 59 // it is NULL. |
60 void SetPreferredSize(const gfx::Size& preferred_size) { | 60 void SetPreferredSize(const gfx::Size& preferred_size) { |
61 preferred_size_ = preferred_size; | 61 preferred_size_ = preferred_size; |
62 } | 62 } |
63 | 63 |
64 protected: | 64 protected: |
65 // Returns the image to paint. This is invoked from paint and returns a value | 65 // Returns the image to paint. This is invoked from paint and returns a value |
66 // from images. | 66 // from images. |
67 // |scale_factor| is the scale factor at which the view is painted and the | 67 virtual gfx::ImageSkia GetImageToPaint(); |
68 // scale factor which should be used when mutating ImageSkias. | |
69 virtual gfx::ImageSkia GetImageToPaint(ui::ScaleFactor scale_factor); | |
70 | 68 |
71 // Updates button background for |scale_factor|. | 69 // Updates button background for |scale_factor|. |
72 void UpdateButtonBackground(ui::ScaleFactor scale_factor); | 70 void UpdateButtonBackground(ui::ScaleFactor scale_factor); |
73 | 71 |
74 // The images used to render the different states of this button. | 72 // The images used to render the different states of this button. |
75 gfx::ImageSkia images_[BS_COUNT]; | 73 gfx::ImageSkia images_[BS_COUNT]; |
76 | 74 |
77 // Information necessary to generate background image. | 75 gfx::ImageSkia background_image_; |
78 struct BackgroundImageGenerationInfo { | |
79 BackgroundImageGenerationInfo(); | |
80 ~BackgroundImageGenerationInfo(); | |
81 | |
82 SkColor src_color_; | |
83 gfx::ImageSkia src_image_; | |
84 gfx::ImageSkia src_mask_; | |
85 gfx::ImageSkia result_; | |
86 }; | |
87 BackgroundImageGenerationInfo background_image_; | |
88 | 76 |
89 // Image to draw on top of normal / hot / pushed image. Usually empty. | 77 // Image to draw on top of normal / hot / pushed image. Usually empty. |
90 gfx::ImageSkia overlay_image_; | 78 gfx::ImageSkia overlay_image_; |
91 | 79 |
92 private: | 80 private: |
93 FRIEND_TEST_ALL_PREFIXES(ImageButtonTest, Basics); | 81 FRIEND_TEST_ALL_PREFIXES(ImageButtonTest, Basics); |
94 | 82 |
95 // Image alignment. | 83 // Image alignment. |
96 HorizontalAlignment h_alignment_; | 84 HorizontalAlignment h_alignment_; |
97 VerticalAlignment v_alignment_; | 85 VerticalAlignment v_alignment_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // The parent class's tooltip_text_ is displayed when not toggled, and | 131 // The parent class's tooltip_text_ is displayed when not toggled, and |
144 // this one is shown when toggled. | 132 // this one is shown when toggled. |
145 string16 toggled_tooltip_text_; | 133 string16 toggled_tooltip_text_; |
146 | 134 |
147 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); | 135 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); |
148 }; | 136 }; |
149 | 137 |
150 } // namespace views | 138 } // namespace views |
151 | 139 |
152 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 140 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
OLD | NEW |