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/base/layout.h" | 10 #include "ui/base/layout.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void SetBackground(SkColor color, | 50 void SetBackground(SkColor color, |
51 const gfx::ImageSkia* image, | 51 const gfx::ImageSkia* image, |
52 const gfx::ImageSkia* mask); | 52 const gfx::ImageSkia* mask); |
53 | 53 |
54 // 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. |
55 void SetImageAlignment(HorizontalAlignment h_align, | 55 void SetImageAlignment(HorizontalAlignment h_align, |
56 VerticalAlignment v_align); | 56 VerticalAlignment v_align); |
57 | 57 |
58 void SetFocusPainter(scoped_ptr<Painter> focus_painter); | 58 void SetFocusPainter(scoped_ptr<Painter> focus_painter); |
59 | 59 |
60 // Sets preferred size, so it could be correctly positioned in layout even if | 60 // The minimum size of the contents (not including the border). The contents |
61 // it is NULL. | 61 // will be at least this size, but may be larger if the image itself is |
62 void SetPreferredSize(const gfx::Size& preferred_size) { | 62 // larger. |
63 preferred_size_ = preferred_size; | 63 const gfx::Size& minimum_image_size() const { return minimum_image_size_; } |
64 } | 64 void SetMinimumImageSize(const gfx::Size& size); |
65 | 65 |
66 // Whether we should draw our images resources horizontally flipped. | 66 // Whether we should draw our images resources horizontally flipped. |
67 void SetDrawImageMirrored(bool mirrored) { | 67 void SetDrawImageMirrored(bool mirrored) { |
68 draw_image_mirrored_ = mirrored; | 68 draw_image_mirrored_ = mirrored; |
69 } | 69 } |
70 | 70 |
71 // Overridden from View: | 71 // Overridden from View: |
72 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 72 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
73 virtual const char* GetClassName() const OVERRIDE; | 73 virtual const char* GetClassName() const OVERRIDE; |
74 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 74 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
(...skipping 22 matching lines...) Expand all Loading... |
97 FRIEND_TEST_ALL_PREFIXES(ImageButtonTest, ImagePositionWithBorder); | 97 FRIEND_TEST_ALL_PREFIXES(ImageButtonTest, ImagePositionWithBorder); |
98 FRIEND_TEST_ALL_PREFIXES(ImageButtonTest, LeftAlignedMirrored); | 98 FRIEND_TEST_ALL_PREFIXES(ImageButtonTest, LeftAlignedMirrored); |
99 FRIEND_TEST_ALL_PREFIXES(ImageButtonTest, RightAlignedMirrored); | 99 FRIEND_TEST_ALL_PREFIXES(ImageButtonTest, RightAlignedMirrored); |
100 | 100 |
101 // Returns the correct position of the image for painting. | 101 // Returns the correct position of the image for painting. |
102 gfx::Point ComputeImagePaintPosition(const gfx::ImageSkia& image); | 102 gfx::Point ComputeImagePaintPosition(const gfx::ImageSkia& image); |
103 | 103 |
104 // Image alignment. | 104 // Image alignment. |
105 HorizontalAlignment h_alignment_; | 105 HorizontalAlignment h_alignment_; |
106 VerticalAlignment v_alignment_; | 106 VerticalAlignment v_alignment_; |
107 gfx::Size preferred_size_; | 107 gfx::Size minimum_image_size_; |
108 | 108 |
109 // Whether we draw our resources horizontally flipped. This can happen in the | 109 // Whether we draw our resources horizontally flipped. This can happen in the |
110 // linux titlebar, where image resources were designed to be flipped so a | 110 // linux titlebar, where image resources were designed to be flipped so a |
111 // small curved corner in the close button designed to fit into the frame | 111 // small curved corner in the close button designed to fit into the frame |
112 // resources. | 112 // resources. |
113 bool draw_image_mirrored_; | 113 bool draw_image_mirrored_; |
114 | 114 |
115 scoped_ptr<Painter> focus_painter_; | 115 scoped_ptr<Painter> focus_painter_; |
116 | 116 |
117 DISALLOW_COPY_AND_ASSIGN(ImageButton); | 117 DISALLOW_COPY_AND_ASSIGN(ImageButton); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // The parent class's tooltip_text_ is displayed when not toggled, and | 162 // The parent class's tooltip_text_ is displayed when not toggled, and |
163 // this one is shown when toggled. | 163 // this one is shown when toggled. |
164 base::string16 toggled_tooltip_text_; | 164 base::string16 toggled_tooltip_text_; |
165 | 165 |
166 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); | 166 DISALLOW_COPY_AND_ASSIGN(ToggleImageButton); |
167 }; | 167 }; |
168 | 168 |
169 } // namespace views | 169 } // namespace views |
170 | 170 |
171 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ | 171 #endif // UI_VIEWS_CONTROLS_BUTTON_IMAGE_BUTTON_H_ |
OLD | NEW |