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& min_size); |
msw
2014/07/23 19:20:16
nit: |max_size|
noms (inactive)
2014/07/24 14:20:25
Done.
| |
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 |button_size_| and marks |button_size_valid_| as false. | |
148 void ResetCachedSize(); | |
sky
2014/07/23 22:42:36
Is it possible to override ChildPreferredSizeChang
noms (inactive)
2014/07/24 14:20:26
Hmm, but shouldn't actions on the LabelButton also
sky
2014/07/24 15:38:05
Yes, sorry, you may need a mix of the two. But it
| |
149 | |
147 // The image and label shown in the button. | 150 // The image and label shown in the button. |
148 ImageView* image_; | 151 ImageView* image_; |
149 Label* label_; | 152 Label* label_; |
150 | 153 |
151 // The cached font lists in the normal and bold style. | 154 // The cached font lists in the normal and bold style. |
152 gfx::FontList cached_normal_font_list_; | 155 gfx::FontList cached_normal_font_list_; |
153 gfx::FontList cached_bold_font_list_; | 156 gfx::FontList cached_bold_font_list_; |
154 | 157 |
155 // The images and colors for each button state. | 158 // The images and colors for each button state. |
156 gfx::ImageSkia button_state_images_[STATE_COUNT]; | 159 gfx::ImageSkia button_state_images_[STATE_COUNT]; |
157 SkColor button_state_colors_[STATE_COUNT]; | 160 SkColor button_state_colors_[STATE_COUNT]; |
158 | 161 |
159 // Used to track whether SetTextColor() has been invoked. | 162 // Used to track whether SetTextColor() has been invoked. |
160 bool explicitly_set_colors_[STATE_COUNT]; | 163 bool explicitly_set_colors_[STATE_COUNT]; |
161 | 164 |
162 // |min_size_| increases monotonically with the preferred size. | 165 // |min_size_| increases monotonically with the preferred size. |
163 mutable gfx::Size min_size_; | 166 mutable gfx::Size min_size_; |
164 // |max_size_| may be set to clamp the preferred size. | 167 // |max_size_| may be set to clamp the preferred size. |
165 gfx::Size max_size_; | 168 gfx::Size max_size_; |
166 | 169 |
170 // Cache the last computed preferred size. | |
171 mutable gfx::Size button_size_; | |
sky
2014/07/23 22:42:36
Can you name this better. It's the preferred size.
noms (inactive)
2014/07/24 14:20:26
Done.
| |
172 mutable bool button_size_valid_; | |
173 | |
167 // Flag indicating default handling of the return key via an accelerator. | 174 // 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 | 175 // Whether or not the button appears or behaves as the default button in its |
169 // current context; | 176 // current context; |
170 bool is_default_; | 177 bool is_default_; |
171 | 178 |
172 // The button's overall style. | 179 // The button's overall style. |
173 ButtonStyle style_; | 180 ButtonStyle style_; |
174 | 181 |
175 // True if current border was set by UpdateThemedBorder. Defaults to true. | 182 // True if current border was set by UpdateThemedBorder. Defaults to true. |
176 bool border_is_themed_border_; | 183 bool border_is_themed_border_; |
177 | 184 |
178 scoped_ptr<Painter> focus_painter_; | 185 scoped_ptr<Painter> focus_painter_; |
179 | 186 |
180 DISALLOW_COPY_AND_ASSIGN(LabelButton); | 187 DISALLOW_COPY_AND_ASSIGN(LabelButton); |
181 }; | 188 }; |
182 | 189 |
183 } // namespace views | 190 } // namespace views |
184 | 191 |
185 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ | 192 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
OLD | NEW |