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_LABEL_H_ | 5 #ifndef UI_VIEWS_CONTROLS_LABEL_H_ |
| 6 #define UI_VIEWS_CONTROLS_LABEL_H_ | 6 #define UI_VIEWS_CONTROLS_LABEL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 // Get or set the distance in pixels between baselines of multi-line text. | 125 // Get or set the distance in pixels between baselines of multi-line text. |
| 126 // Default is 0, indicating the distance between lines should be the standard | 126 // Default is 0, indicating the distance between lines should be the standard |
| 127 // one for the label's text, font list, and platform. | 127 // one for the label's text, font list, and platform. |
| 128 int line_height() const { return line_height_; } | 128 int line_height() const { return line_height_; } |
| 129 void SetLineHeight(int height); | 129 void SetLineHeight(int height); |
| 130 | 130 |
| 131 // Get or set if the label text can wrap on multiple lines; default is false. | 131 // Get or set if the label text can wrap on multiple lines; default is false. |
| 132 bool is_multi_line() const { return is_multi_line_; } | 132 bool is_multi_line() const { return is_multi_line_; } |
| 133 void SetMultiLine(bool multi_line); | 133 void SetMultiLine(bool multi_line); |
| 134 | 134 |
| 135 // Get or set if the label text should be obscured before rendering (e.g. | |
| 136 // should "Password!" display as "*********"); default is false. | |
| 137 bool is_obscured() const { return is_obscured_; } | |
| 138 void SetObscured(bool obscured); | |
| 139 | |
| 140 // Get the label text as displayed to the user, respecting the 'obscured' | |
|
msw
2014/04/03 01:38:48
nit: drop the word "label" for a one-line comment.
Mike West
2014/04/03 08:17:25
Done.
| |
| 141 // flag. | |
| 142 const base::string16& display_text() const; | |
|
msw
2014/04/03 01:38:48
nit: non-inlined functions should have CamelCaseNa
Mike West
2014/04/03 08:17:25
Done.
| |
| 143 | |
| 135 // Sets whether the label text can be split on words. | 144 // Sets whether the label text can be split on words. |
| 136 // Default is false. This only works when is_multi_line is true. | 145 // Default is false. This only works when is_multi_line is true. |
| 137 void SetAllowCharacterBreak(bool allow_character_break); | 146 void SetAllowCharacterBreak(bool allow_character_break); |
| 138 | 147 |
| 139 // Sets whether the label text should be elided in the middle or end (if | 148 // Sets whether the label text should be elided in the middle or end (if |
| 140 // necessary). The default is to elide at the end. | 149 // necessary). The default is to elide at the end. |
| 141 // NOTE: Eliding in the middle is not supported for multi-line strings. | 150 // NOTE: Eliding in the middle is not supported for multi-line strings. |
| 142 void SetElideBehavior(ElideBehavior elide_behavior); | 151 void SetElideBehavior(ElideBehavior elide_behavior); |
| 143 | 152 |
| 144 // Sets the tooltip text. Default behavior for a label (single-line) is to | 153 // Sets the tooltip text. Default behavior for a label (single-line) is to |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 // Updates any colors that have not been explicitly set from the theme. | 241 // Updates any colors that have not been explicitly set from the theme. |
| 233 void UpdateColorsFromTheme(const ui::NativeTheme* theme); | 242 void UpdateColorsFromTheme(const ui::NativeTheme* theme); |
| 234 | 243 |
| 235 // Resets |cached_heights_| and |cached_heights_cursor_| and mark | 244 // Resets |cached_heights_| and |cached_heights_cursor_| and mark |
| 236 // |text_size_valid_| as false. | 245 // |text_size_valid_| as false. |
| 237 void ResetCachedSize(); | 246 void ResetCachedSize(); |
| 238 | 247 |
| 239 bool ShouldShowDefaultTooltip() const; | 248 bool ShouldShowDefaultTooltip() const; |
| 240 | 249 |
| 241 base::string16 text_; | 250 base::string16 text_; |
| 251 base::string16 obscured_text_; | |
|
msw
2014/04/03 01:38:48
nit: Call this |layout_text| to be consistent with
Mike West
2014/04/03 08:17:25
Done.
| |
| 242 gfx::FontList font_list_; | 252 gfx::FontList font_list_; |
| 243 SkColor requested_enabled_color_; | 253 SkColor requested_enabled_color_; |
| 244 SkColor actual_enabled_color_; | 254 SkColor actual_enabled_color_; |
| 245 SkColor requested_disabled_color_; | 255 SkColor requested_disabled_color_; |
| 246 SkColor actual_disabled_color_; | 256 SkColor actual_disabled_color_; |
| 247 SkColor background_color_; | 257 SkColor background_color_; |
| 248 | 258 |
| 249 // Set to true once the corresponding setter is invoked. | 259 // Set to true once the corresponding setter is invoked. |
| 250 bool enabled_color_set_; | 260 bool enabled_color_set_; |
| 251 bool disabled_color_set_; | 261 bool disabled_color_set_; |
| 252 bool background_color_set_; | 262 bool background_color_set_; |
| 253 | 263 |
| 254 bool auto_color_readability_; | 264 bool auto_color_readability_; |
| 255 mutable gfx::Size text_size_; | 265 mutable gfx::Size text_size_; |
| 256 mutable bool text_size_valid_; | 266 mutable bool text_size_valid_; |
| 257 int line_height_; | 267 int line_height_; |
| 258 bool is_multi_line_; | 268 bool is_multi_line_; |
| 269 bool is_obscured_; | |
| 259 bool allow_character_break_; | 270 bool allow_character_break_; |
| 260 ElideBehavior elide_behavior_; | 271 ElideBehavior elide_behavior_; |
| 261 gfx::HorizontalAlignment horizontal_alignment_; | 272 gfx::HorizontalAlignment horizontal_alignment_; |
| 262 base::string16 tooltip_text_; | 273 base::string16 tooltip_text_; |
| 263 // Whether to collapse the label when it's not visible. | 274 // Whether to collapse the label when it's not visible. |
| 264 bool collapse_when_hidden_; | 275 bool collapse_when_hidden_; |
| 265 // The following member variable is used to control whether the | 276 // The following member variable is used to control whether the |
| 266 // directionality is auto-detected based on first strong directionality | 277 // directionality is auto-detected based on first strong directionality |
| 267 // character or is determined by chrome UI's locale. | 278 // character or is determined by chrome UI's locale. |
| 268 DirectionalityMode directionality_mode_; | 279 DirectionalityMode directionality_mode_; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 280 // The cached heights to avoid recalculation in GetHeightForWidth(). | 291 // The cached heights to avoid recalculation in GetHeightForWidth(). |
| 281 std::vector<gfx::Size> cached_heights_; | 292 std::vector<gfx::Size> cached_heights_; |
| 282 int cached_heights_cursor_; | 293 int cached_heights_cursor_; |
| 283 | 294 |
| 284 DISALLOW_COPY_AND_ASSIGN(Label); | 295 DISALLOW_COPY_AND_ASSIGN(Label); |
| 285 }; | 296 }; |
| 286 | 297 |
| 287 } // namespace views | 298 } // namespace views |
| 288 | 299 |
| 289 #endif // UI_VIEWS_CONTROLS_LABEL_H_ | 300 #endif // UI_VIEWS_CONTROLS_LABEL_H_ |
| OLD | NEW |