Chromium Code Reviews| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 set_min_size(gfx::Size()) to clear the monotonically increasing size. |
| 69 void set_min_size(const gfx::Size& min_size) { min_size_ = min_size; } | 69 void set_min_size(const gfx::Size& min_size) { |
|
msw
2014/07/21 16:28:26
Rename these (SetMinSize, SetMaxSize) and define t
noms (inactive)
2014/07/21 17:18:51
Done.
| |
| 70 void set_max_size(const gfx::Size& max_size) { max_size_ = max_size; } | 70 min_size_ = min_size; |
| 71 ResetCachedSize(); | |
| 72 } | |
| 73 void set_max_size(const gfx::Size& max_size) { | |
| 74 max_size_ = max_size; | |
| 75 ResetCachedSize(); | |
| 76 } | |
| 71 | 77 |
| 72 // Get or set the option to handle the return key; false by default. | 78 // Get or set the option to handle the return key; false by default. |
| 73 bool is_default() const { return is_default_; } | 79 bool is_default() const { return is_default_; } |
| 74 void SetIsDefault(bool is_default); | 80 void SetIsDefault(bool is_default); |
| 75 | 81 |
| 76 // Get or set the button's overall style; the default is |STYLE_TEXTBUTTON|. | 82 // Get or set the button's overall style; the default is |STYLE_TEXTBUTTON|. |
| 77 ButtonStyle style() const { return style_; } | 83 ButtonStyle style() const { return style_; } |
| 78 void SetStyle(ButtonStyle style); | 84 void SetStyle(ButtonStyle style); |
| 79 | 85 |
| 80 void SetFocusPainter(scoped_ptr<Painter> focus_painter); | 86 void SetFocusPainter(scoped_ptr<Painter> focus_painter); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 // NativeThemeDelegate: | 143 // NativeThemeDelegate: |
| 138 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; | 144 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; |
| 139 virtual ui::NativeTheme::State GetThemeState( | 145 virtual ui::NativeTheme::State GetThemeState( |
| 140 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | 146 ui::NativeTheme::ExtraParams* params) const OVERRIDE; |
| 141 virtual const gfx::Animation* GetThemeAnimation() const OVERRIDE; | 147 virtual const gfx::Animation* GetThemeAnimation() const OVERRIDE; |
| 142 virtual ui::NativeTheme::State GetBackgroundThemeState( | 148 virtual ui::NativeTheme::State GetBackgroundThemeState( |
| 143 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | 149 ui::NativeTheme::ExtraParams* params) const OVERRIDE; |
| 144 virtual ui::NativeTheme::State GetForegroundThemeState( | 150 virtual ui::NativeTheme::State GetForegroundThemeState( |
| 145 ui::NativeTheme::ExtraParams* params) const OVERRIDE; | 151 ui::NativeTheme::ExtraParams* params) const OVERRIDE; |
| 146 | 152 |
| 153 // Resets |button_size_| and marks |button_size_valid_| as false. | |
| 154 void ResetCachedSize(); | |
| 155 | |
| 147 // The image and label shown in the button. | 156 // The image and label shown in the button. |
| 148 ImageView* image_; | 157 ImageView* image_; |
| 149 Label* label_; | 158 Label* label_; |
| 150 | 159 |
| 151 // The cached font lists in the normal and bold style. | 160 // The cached font lists in the normal and bold style. |
| 152 gfx::FontList cached_normal_font_list_; | 161 gfx::FontList cached_normal_font_list_; |
| 153 gfx::FontList cached_bold_font_list_; | 162 gfx::FontList cached_bold_font_list_; |
| 154 | 163 |
| 155 // The images and colors for each button state. | 164 // The images and colors for each button state. |
| 156 gfx::ImageSkia button_state_images_[STATE_COUNT]; | 165 gfx::ImageSkia button_state_images_[STATE_COUNT]; |
| 157 SkColor button_state_colors_[STATE_COUNT]; | 166 SkColor button_state_colors_[STATE_COUNT]; |
| 158 | 167 |
| 159 // Used to track whether SetTextColor() has been invoked. | 168 // Used to track whether SetTextColor() has been invoked. |
| 160 bool explicitly_set_colors_[STATE_COUNT]; | 169 bool explicitly_set_colors_[STATE_COUNT]; |
| 161 | 170 |
| 162 // |min_size_| increases monotonically with the preferred size. | 171 // |min_size_| increases monotonically with the preferred size. |
| 163 mutable gfx::Size min_size_; | 172 mutable gfx::Size min_size_; |
| 164 // |max_size_| may be set to clamp the preferred size. | 173 // |max_size_| may be set to clamp the preferred size. |
| 165 gfx::Size max_size_; | 174 gfx::Size max_size_; |
| 166 | 175 |
| 176 // Cache the last computed preferred size. | |
| 177 mutable gfx::Size button_size_; | |
| 178 mutable bool button_size_valid_; | |
| 179 | |
| 167 // Flag indicating default handling of the return key via an accelerator. | 180 // 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 | 181 // Whether or not the button appears or behaves as the default button in its |
| 169 // current context; | 182 // current context; |
| 170 bool is_default_; | 183 bool is_default_; |
| 171 | 184 |
| 172 // The button's overall style. | 185 // The button's overall style. |
| 173 ButtonStyle style_; | 186 ButtonStyle style_; |
| 174 | 187 |
| 175 // True if current border was set by UpdateThemedBorder. Defaults to true. | 188 // True if current border was set by UpdateThemedBorder. Defaults to true. |
| 176 bool border_is_themed_border_; | 189 bool border_is_themed_border_; |
| 177 | 190 |
| 178 scoped_ptr<Painter> focus_painter_; | 191 scoped_ptr<Painter> focus_painter_; |
| 179 | 192 |
| 180 DISALLOW_COPY_AND_ASSIGN(LabelButton); | 193 DISALLOW_COPY_AND_ASSIGN(LabelButton); |
| 181 }; | 194 }; |
| 182 | 195 |
| 183 } // namespace views | 196 } // namespace views |
| 184 | 197 |
| 185 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ | 198 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ |
| OLD | NEW |