| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_STYLED_LABEL_H_ | 5 #ifndef UI_VIEWS_CONTROLS_STYLED_LABEL_H_ |
| 6 #define UI_VIEWS_CONTROLS_STYLED_LABEL_H_ | 6 #define UI_VIEWS_CONTROLS_STYLED_LABEL_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 SkColor displayed_on_background_color() const { | 80 SkColor displayed_on_background_color() const { |
| 81 return displayed_on_background_color_; | 81 return displayed_on_background_color_; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void set_auto_color_readability_enabled(bool auto_color_readability) { | 84 void set_auto_color_readability_enabled(bool auto_color_readability) { |
| 85 auto_color_readability_enabled_ = auto_color_readability; | 85 auto_color_readability_enabled_ = auto_color_readability; |
| 86 } | 86 } |
| 87 | 87 |
| 88 // View implementation: | 88 // View implementation: |
| 89 virtual gfx::Insets GetInsets() const OVERRIDE; | 89 virtual gfx::Insets GetInsets() const OVERRIDE; |
| 90 virtual int GetHeightForWidth(int w) OVERRIDE; | 90 virtual int GetHeightForWidth(int w) const OVERRIDE; |
| 91 virtual void Layout() OVERRIDE; | 91 virtual void Layout() OVERRIDE; |
| 92 virtual void PreferredSizeChanged() OVERRIDE; | 92 virtual void PreferredSizeChanged() OVERRIDE; |
| 93 | 93 |
| 94 // LinkListener implementation: | 94 // LinkListener implementation: |
| 95 virtual void LinkClicked(Link* source, int event_flags) OVERRIDE; | 95 virtual void LinkClicked(Link* source, int event_flags) OVERRIDE; |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 struct StyleRange { | 98 struct StyleRange { |
| 99 StyleRange(const gfx::Range& range, | 99 StyleRange(const gfx::Range& range, |
| 100 const RangeStyleInfo& style_info) | 100 const RangeStyleInfo& style_info) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 131 | 131 |
| 132 // The ranges that should be linkified, sorted by start position. | 132 // The ranges that should be linkified, sorted by start position. |
| 133 StyleRanges style_ranges_; | 133 StyleRanges style_ranges_; |
| 134 | 134 |
| 135 // A mapping from a view to the range it corresponds to in |text_|. Only views | 135 // A mapping from a view to the range it corresponds to in |text_|. Only views |
| 136 // that correspond to ranges with is_link style set will be added to the map. | 136 // that correspond to ranges with is_link style set will be added to the map. |
| 137 std::map<View*, gfx::Range> link_targets_; | 137 std::map<View*, gfx::Range> link_targets_; |
| 138 | 138 |
| 139 // This variable saves the result of the last GetHeightForWidth call in order | 139 // This variable saves the result of the last GetHeightForWidth call in order |
| 140 // to avoid repeated calculation. | 140 // to avoid repeated calculation. |
| 141 gfx::Size calculated_size_; | 141 mutable gfx::Size calculated_size_; |
| 142 | 142 |
| 143 // Background color on which the label is drawn, for auto color readability. | 143 // Background color on which the label is drawn, for auto color readability. |
| 144 SkColor displayed_on_background_color_; | 144 SkColor displayed_on_background_color_; |
| 145 bool displayed_on_background_color_set_; | 145 bool displayed_on_background_color_set_; |
| 146 | 146 |
| 147 // Controls whether the text is automatically re-colored to be readable on the | 147 // Controls whether the text is automatically re-colored to be readable on the |
| 148 // background. | 148 // background. |
| 149 bool auto_color_readability_enabled_; | 149 bool auto_color_readability_enabled_; |
| 150 | 150 |
| 151 DISALLOW_COPY_AND_ASSIGN(StyledLabel); | 151 DISALLOW_COPY_AND_ASSIGN(StyledLabel); |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 } // namespace views | 154 } // namespace views |
| 155 | 155 |
| 156 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ | 156 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ |
| OLD | NEW |