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_LABEL_BUTTON_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 void SetFontList(const gfx::FontList& font_list); | 58 void SetFontList(const gfx::FontList& font_list); |
59 | 59 |
60 // Set the elide behavior of this button. | 60 // Set the elide behavior of this button. |
61 void SetElideBehavior(gfx::ElideBehavior elide_behavior); | 61 void SetElideBehavior(gfx::ElideBehavior elide_behavior); |
62 | 62 |
63 // Get or set the horizontal alignment used for the button; reversed in RTL. | 63 // Get or set the horizontal alignment used for the button; reversed in RTL. |
64 // The optional image will lead the text, unless the button is right-aligned. | 64 // The optional image will lead the text, unless the button is right-aligned. |
65 gfx::HorizontalAlignment GetHorizontalAlignment() const; | 65 gfx::HorizontalAlignment GetHorizontalAlignment() const; |
66 void SetHorizontalAlignment(gfx::HorizontalAlignment alignment); | 66 void SetHorizontalAlignment(gfx::HorizontalAlignment alignment); |
67 | 67 |
68 // Call set_min_size(gfx::Size()) to clear the monotonically increasing size. | 68 // Call SetMinSize(gfx::Size()) to clear the monotonically increasing size. |
69 void set_min_size(const gfx::Size& min_size) { min_size_ = min_size; } | 69 void SetMinSize(const gfx::Size& min_size); |
70 void set_max_size(const gfx::Size& max_size) { max_size_ = max_size; } | 70 void SetMaxSize(const gfx::Size& max_size); |
71 | 71 |
72 // Get or set the option to handle the return key; false by default. | 72 // Get or set the option to handle the return key; false by default. |
73 bool is_default() const { return is_default_; } | 73 bool is_default() const { return is_default_; } |
74 void SetIsDefault(bool is_default); | 74 void SetIsDefault(bool is_default); |
75 | 75 |
76 // Get or set the button's overall style; the default is |STYLE_TEXTBUTTON|. | 76 // Get or set the button's overall style; the default is |STYLE_TEXTBUTTON|. |
77 ButtonStyle style() const { return style_; } | 77 ButtonStyle style() const { return style_; } |
78 void SetStyle(ButtonStyle style); | 78 void SetStyle(ButtonStyle style); |
79 | 79 |
80 void SetFocusPainter(scoped_ptr<Painter> focus_painter); | 80 void SetFocusPainter(scoped_ptr<Painter> focus_painter); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // NativeThemeDelegate: | 137 // NativeThemeDelegate: |
138 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; | 138 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; |
139 virtual ui::NativeTheme::State GetThemeState( | 139 virtual ui::NativeTheme::State GetThemeState( |
140 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | 140 ui::NativeTheme::ExtraParams* params) const OVERRIDE; |
141 virtual const gfx::Animation* GetThemeAnimation() const OVERRIDE; | 141 virtual const gfx::Animation* GetThemeAnimation() const OVERRIDE; |
142 virtual ui::NativeTheme::State GetBackgroundThemeState( | 142 virtual ui::NativeTheme::State GetBackgroundThemeState( |
143 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | 143 ui::NativeTheme::ExtraParams* params) const OVERRIDE; |
144 virtual ui::NativeTheme::State GetForegroundThemeState( | 144 virtual ui::NativeTheme::State GetForegroundThemeState( |
145 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | 145 ui::NativeTheme::ExtraParams* params) const OVERRIDE; |
146 | 146 |
| 147 // Resets |cached_preferred_size_| and marks |cached_preferred_size_valid_| |
| 148 // as false. |
| 149 void ResetCachedPreferredSize(); |
| 150 |
147 // The image and label shown in the button. | 151 // The image and label shown in the button. |
148 ImageView* image_; | 152 ImageView* image_; |
149 Label* label_; | 153 Label* label_; |
150 | 154 |
151 // The cached font lists in the normal and bold style. | 155 // The cached font lists in the normal and bold style. |
152 gfx::FontList cached_normal_font_list_; | 156 gfx::FontList cached_normal_font_list_; |
153 gfx::FontList cached_bold_font_list_; | 157 gfx::FontList cached_bold_font_list_; |
154 | 158 |
155 // The images and colors for each button state. | 159 // The images and colors for each button state. |
156 gfx::ImageSkia button_state_images_[STATE_COUNT]; | 160 gfx::ImageSkia button_state_images_[STATE_COUNT]; |
157 SkColor button_state_colors_[STATE_COUNT]; | 161 SkColor button_state_colors_[STATE_COUNT]; |
158 | 162 |
159 // Used to track whether SetTextColor() has been invoked. | 163 // Used to track whether SetTextColor() has been invoked. |
160 bool explicitly_set_colors_[STATE_COUNT]; | 164 bool explicitly_set_colors_[STATE_COUNT]; |
161 | 165 |
162 // |min_size_| increases monotonically with the preferred size. | 166 // |min_size_| increases monotonically with the preferred size. |
163 mutable gfx::Size min_size_; | 167 mutable gfx::Size min_size_; |
164 // |max_size_| may be set to clamp the preferred size. | 168 // |max_size_| may be set to clamp the preferred size. |
165 gfx::Size max_size_; | 169 gfx::Size max_size_; |
166 | 170 |
| 171 // Cache the last computed preferred size. |
| 172 mutable gfx::Size cached_preferred_size_; |
| 173 mutable bool cached_preferred_size_valid_; |
| 174 |
167 // Flag indicating default handling of the return key via an accelerator. | 175 // Flag indicating default handling of the return key via an accelerator. |
168 // Whether or not the button appears or behaves as the default button in its | 176 // Whether or not the button appears or behaves as the default button in its |
169 // current context; | 177 // current context; |
170 bool is_default_; | 178 bool is_default_; |
171 | 179 |
172 // The button's overall style. | 180 // The button's overall style. |
173 ButtonStyle style_; | 181 ButtonStyle style_; |
174 | 182 |
175 // True if current border was set by UpdateThemedBorder. Defaults to true. | 183 // True if current border was set by UpdateThemedBorder. Defaults to true. |
176 bool border_is_themed_border_; | 184 bool border_is_themed_border_; |
177 | 185 |
178 scoped_ptr<Painter> focus_painter_; | 186 scoped_ptr<Painter> focus_painter_; |
179 | 187 |
180 DISALLOW_COPY_AND_ASSIGN(LabelButton); | 188 DISALLOW_COPY_AND_ASSIGN(LabelButton); |
181 }; | 189 }; |
182 | 190 |
183 } // namespace views | 191 } // namespace views |
184 | 192 |
185 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ | 193 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
OLD | NEW |