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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void Layout() override; | 128 void Layout() override; |
129 const char* GetClassName() const override; | 129 const char* GetClassName() const override; |
130 View* GetTooltipHandlerForPoint(const gfx::Point& point) override; | 130 View* GetTooltipHandlerForPoint(const gfx::Point& point) override; |
131 bool CanProcessEventsWithinSubtree() const override; | 131 bool CanProcessEventsWithinSubtree() const override; |
132 void GetAccessibleState(ui::AXViewState* state) override; | 132 void GetAccessibleState(ui::AXViewState* state) override; |
133 bool GetTooltipText(const gfx::Point& p, | 133 bool GetTooltipText(const gfx::Point& p, |
134 base::string16* tooltip) const override; | 134 base::string16* tooltip) const override; |
135 void OnEnabledChanged() override; | 135 void OnEnabledChanged() override; |
136 | 136 |
137 protected: | 137 protected: |
138 void PaintText(gfx::Canvas* canvas); | 138 // Paints the display text to |canvas|. It also draws the focus rectangle if |
| 139 // necessary. Returns the bounds of the focus rectangle (or an empty rectangle |
| 140 // if this is not focusable). |
| 141 gfx::Rect PaintText(gfx::Canvas* canvas); |
139 | 142 |
140 SkColor disabled_color() const { return actual_disabled_color_; } | 143 SkColor disabled_color() const { return actual_disabled_color_; } |
141 | 144 |
142 // View: | 145 // View: |
143 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 146 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
144 void VisibilityChanged(View* starting_from, bool is_visible) override; | 147 void VisibilityChanged(View* starting_from, bool is_visible) override; |
145 void OnPaint(gfx::Canvas* canvas) override; | 148 void OnPaint(gfx::Canvas* canvas) override; |
146 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | 149 void OnDeviceScaleFactorChanged(float device_scale_factor) override; |
147 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 150 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
148 | 151 |
149 private: | 152 private: |
150 FRIEND_TEST_ALL_PREFIXES(LabelTest, ResetRenderTextData); | 153 FRIEND_TEST_ALL_PREFIXES(LabelTest, ResetRenderTextData); |
151 FRIEND_TEST_ALL_PREFIXES(LabelTest, MultilineSupportedRenderText); | 154 FRIEND_TEST_ALL_PREFIXES(LabelTest, MultilineSupportedRenderText); |
152 FRIEND_TEST_ALL_PREFIXES(LabelTest, TextChangeWithoutLayout); | 155 FRIEND_TEST_ALL_PREFIXES(LabelTest, TextChangeWithoutLayout); |
| 156 FRIEND_TEST_ALL_PREFIXES(LabelFocusTest, FocusBounds); |
153 | 157 |
154 void Init(const base::string16& text, const gfx::FontList& font_list); | 158 void Init(const base::string16& text, const gfx::FontList& font_list); |
155 | 159 |
156 void ResetLayout(); | 160 void ResetLayout(); |
157 | 161 |
158 // Create a single RenderText instance to actually be painted. | 162 // Create a single RenderText instance to actually be painted. |
159 scoped_ptr<gfx::RenderText> CreateRenderText( | 163 scoped_ptr<gfx::RenderText> CreateRenderText( |
160 const base::string16& text, | 164 const base::string16& text, |
161 gfx::HorizontalAlignment alignment, | 165 gfx::HorizontalAlignment alignment, |
162 gfx::DirectionalityMode directionality, | 166 gfx::DirectionalityMode directionality, |
(...skipping 48 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 |