| 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 "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 143 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 144 void VisibilityChanged(View* starting_from, bool is_visible) override; | 144 void VisibilityChanged(View* starting_from, bool is_visible) override; |
| 145 void OnPaint(gfx::Canvas* canvas) override; | 145 void OnPaint(gfx::Canvas* canvas) override; |
| 146 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 146 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
| 147 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 147 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 FRIEND_TEST_ALL_PREFIXES(LabelTest, ResetRenderTextData); | 150 FRIEND_TEST_ALL_PREFIXES(LabelTest, ResetRenderTextData); |
| 151 FRIEND_TEST_ALL_PREFIXES(LabelTest, MultilineSupportedRenderText); | 151 FRIEND_TEST_ALL_PREFIXES(LabelTest, MultilineSupportedRenderText); |
| 152 FRIEND_TEST_ALL_PREFIXES(LabelTest, TextChangeWithoutLayout); | 152 FRIEND_TEST_ALL_PREFIXES(LabelTest, TextChangeWithoutLayout); |
| 153 FRIEND_TEST_ALL_PREFIXES(LabelFocusTest, FocusBounds); |
| 154 FRIEND_TEST_ALL_PREFIXES(LabelFocusTest, EmptyLabel); |
| 153 | 155 |
| 154 void Init(const base::string16& text, const gfx::FontList& font_list); | 156 void Init(const base::string16& text, const gfx::FontList& font_list); |
| 155 | 157 |
| 156 void ResetLayout(); | 158 void ResetLayout(); |
| 157 | 159 |
| 158 // Create a single RenderText instance to actually be painted. | 160 // Create a single RenderText instance to actually be painted. |
| 159 scoped_ptr<gfx::RenderText> CreateRenderText( | 161 scoped_ptr<gfx::RenderText> CreateRenderText( |
| 160 const base::string16& text, | 162 const base::string16& text, |
| 161 gfx::HorizontalAlignment alignment, | 163 gfx::HorizontalAlignment alignment, |
| 162 gfx::DirectionalityMode directionality, | 164 gfx::DirectionalityMode directionality, |
| 163 gfx::ElideBehavior elide_behavior); | 165 gfx::ElideBehavior elide_behavior); |
| 164 | 166 |
| 165 // Set up |lines_| to actually be painted. | 167 // Set up |lines_| to actually be painted. |
| 166 void MaybeBuildRenderTextLines(); | 168 void MaybeBuildRenderTextLines(); |
| 167 | 169 |
| 170 gfx::Rect GetFocusBounds(); |
| 171 |
| 168 // Get the text broken into lines as needed to fit the given |width|. | 172 // Get the text broken into lines as needed to fit the given |width|. |
| 169 std::vector<base::string16> GetLinesForWidth(int width) const; | 173 std::vector<base::string16> GetLinesForWidth(int width) const; |
| 170 | 174 |
| 171 // Get the natural text size, unelided and only wrapped on newlines. | 175 // Get the natural text size, unelided and only wrapped on newlines. |
| 172 gfx::Size GetTextSize() const; | 176 gfx::Size GetTextSize() const; |
| 173 | 177 |
| 174 void RecalculateColors(); | 178 void RecalculateColors(); |
| 175 | 179 |
| 176 // Updates any colors that have not been explicitly set from the theme. | 180 // Updates any colors that have not been explicitly set from the theme. |
| 177 void UpdateColorsFromTheme(const ui::NativeTheme* theme); | 181 void UpdateColorsFromTheme(const ui::NativeTheme* theme); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // TODO(vadimt): Remove is_first_paint_text_ before crbug.com/431326 is | 215 // TODO(vadimt): Remove is_first_paint_text_ before crbug.com/431326 is |
| 212 // closed. | 216 // closed. |
| 213 bool is_first_paint_text_; | 217 bool is_first_paint_text_; |
| 214 | 218 |
| 215 DISALLOW_COPY_AND_ASSIGN(Label); | 219 DISALLOW_COPY_AND_ASSIGN(Label); |
| 216 }; | 220 }; |
| 217 | 221 |
| 218 } // namespace views | 222 } // namespace views |
| 219 | 223 |
| 220 #endif // UI_VIEWS_CONTROLS_LABEL_H_ | 224 #endif // UI_VIEWS_CONTROLS_LABEL_H_ |
| OLD | NEW |