Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: ui/views/controls/styled_label.h

Issue 111023004: Add GetMinimumSize() for Labels and ensure it's zero for empty Links. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/link.cc ('k') | ui/views/controls/styled_label.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 9 #include <map>
9 #include <queue>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
14 #include "ui/gfx/range/range.h" 14 #include "ui/gfx/range/range.h"
15 #include "ui/gfx/size.h" 15 #include "ui/gfx/size.h"
16 #include "ui/views/controls/link_listener.h" 16 #include "ui/views/controls/link_listener.h"
17 #include "ui/views/view.h" 17 #include "ui/views/view.h"
18 18
19 namespace views { 19 namespace views {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 : range(range), 96 : range(range),
97 style_info(style_info) { 97 style_info(style_info) {
98 } 98 }
99 ~StyleRange() {} 99 ~StyleRange() {}
100 100
101 bool operator<(const StyleRange& other) const; 101 bool operator<(const StyleRange& other) const;
102 102
103 gfx::Range range; 103 gfx::Range range;
104 RangeStyleInfo style_info; 104 RangeStyleInfo style_info;
105 }; 105 };
106 typedef std::list<StyleRange> StyleRanges;
106 107
107 // Calculates how to layout child views, creates them and sets their size 108 // Calculates how to layout child views, creates them and sets their size
108 // and position. |width| is the horizontal space, in pixels, that the view 109 // and position. |width| is the horizontal space, in pixels, that the view
109 // has to work with. If |dry_run| is true, the view hierarchy is not touched. 110 // has to work with. If |dry_run| is true, the view hierarchy is not touched.
110 // The return value is the height in pixels. 111 // The return value is the necessary size.
111 int CalculateAndDoLayout(int width, bool dry_run); 112 gfx::Size CalculateAndDoLayout(int width, bool dry_run);
112 113
113 // The text to display. 114 // The text to display.
114 string16 text_; 115 string16 text_;
115 116
116 // The default style to use for any part of the text that isn't within 117 // The default style to use for any part of the text that isn't within
117 // a range in |style_ranges_|. 118 // a range in |style_ranges_|.
118 RangeStyleInfo default_style_info_; 119 RangeStyleInfo default_style_info_;
119 120
120 // The listener that will be informed of link clicks. 121 // The listener that will be informed of link clicks.
121 StyledLabelListener* listener_; 122 StyledLabelListener* listener_;
122 123
123 // The ranges that should be linkified, sorted by start position. 124 // The ranges that should be linkified, sorted by start position.
124 std::priority_queue<StyleRange> style_ranges_; 125 StyleRanges style_ranges_;
125 126
126 // A mapping from a view to the range it corresponds to in |text_|. Only views 127 // A mapping from a view to the range it corresponds to in |text_|. Only views
127 // that correspond to ranges with is_link style set will be added to the map. 128 // that correspond to ranges with is_link style set will be added to the map.
128 std::map<View*, gfx::Range> link_targets_; 129 std::map<View*, gfx::Range> link_targets_;
129 130
130 // This variable saves the result of the last GetHeightForWidth call in order 131 // This variable saves the result of the last GetHeightForWidth call in order
131 // to avoid repeated calculation. 132 // to avoid repeated calculation.
132 gfx::Size calculated_size_; 133 gfx::Size calculated_size_;
133 134
134 // Background color on which the label is drawn, for auto color readability. 135 // Background color on which the label is drawn, for auto color readability.
135 SkColor displayed_on_background_color_; 136 SkColor displayed_on_background_color_;
136 bool displayed_on_background_color_set_; 137 bool displayed_on_background_color_set_;
137 138
138 // Controls whether the text is automatically re-colored to be readable on the 139 // Controls whether the text is automatically re-colored to be readable on the
139 // background. 140 // background.
140 bool auto_color_readability_enabled_; 141 bool auto_color_readability_enabled_;
141 142
142 DISALLOW_COPY_AND_ASSIGN(StyledLabel); 143 DISALLOW_COPY_AND_ASSIGN(StyledLabel);
143 }; 144 };
144 145
145 } // namespace views 146 } // namespace views
146 147
147 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_ 148 #endif // UI_VIEWS_CONTROLS_STYLED_LABEL_H_
OLDNEW
« no previous file with comments | « ui/views/controls/link.cc ('k') | ui/views/controls/styled_label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698