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

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

Issue 12317109: Add a dialog for getting user consent in the echo redeem flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 months 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
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 #include "ui/views/controls/styled_label.h" 5 #include "ui/views/controls/styled_label.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "ui/base/text/text_elider.h" 10 #include "ui/base/text/text_elider.h"
(...skipping 28 matching lines...) Expand all
39 39
40 void StyledLabel::AddLink(const ui::Range& range) { 40 void StyledLabel::AddLink(const ui::Range& range) {
41 DCHECK(!range.is_reversed()); 41 DCHECK(!range.is_reversed());
42 DCHECK(!range.is_empty()); 42 DCHECK(!range.is_empty());
43 DCHECK(ui::Range(0, text_.size()).Contains(range)); 43 DCHECK(ui::Range(0, text_.size()).Contains(range));
44 link_ranges_.push(LinkRange(range)); 44 link_ranges_.push(LinkRange(range));
45 calculated_size_ = gfx::Size(); 45 calculated_size_ = gfx::Size();
46 InvalidateLayout(); 46 InvalidateLayout();
47 } 47 }
48 48
49 void StyledLabel::SizeToFit(int width) {
sky 2013/03/18 19:32:39 I'm not a fan of this method, it's too easy to use
tbarzic 2013/03/18 20:40:03 ok, removed
50 SetBounds(x(), y(), width, GetHeightForWidth(width));
51 InvalidateLayout();
52 }
53
49 gfx::Insets StyledLabel::GetInsets() const { 54 gfx::Insets StyledLabel::GetInsets() const {
50 gfx::Insets insets = View::GetInsets(); 55 gfx::Insets insets = View::GetInsets();
51 const gfx::Insets focus_border_padding(1, 1, 1, 1); 56 const gfx::Insets focus_border_padding(1, 1, 1, 1);
52 insets += focus_border_padding; 57 insets += focus_border_padding;
53 return insets; 58 return insets;
54 } 59 }
55 60
61 gfx::Size StyledLabel::GetPreferredSize() {
62 return gfx::Size(width(), GetHeightForWidth(width()));
sky 2013/03/18 19:32:39 This isn't right. If you need the preferred size f
tbarzic 2013/03/18 20:40:03 Done.
63 }
64
56 int StyledLabel::GetHeightForWidth(int w) { 65 int StyledLabel::GetHeightForWidth(int w) {
57 if (w != calculated_size_.width()) 66 if (w != calculated_size_.width())
58 calculated_size_ = gfx::Size(w, CalculateAndDoLayout(w, true)); 67 calculated_size_ = gfx::Size(w, CalculateAndDoLayout(w, true));
59 68
60 return calculated_size_.height(); 69 return calculated_size_.height();
61 } 70 }
62 71
63 void StyledLabel::Layout() { 72 void StyledLabel::Layout() {
64 CalculateAndDoLayout(GetLocalBounds().width(), false); 73 CalculateAndDoLayout(GetLocalBounds().width(), false);
65 } 74 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 173 }
165 x += view_size.width() - 2 * overlap; 174 x += view_size.width() - 2 * overlap;
166 175
167 remaining_string = remaining_string.substr(chunk.size()); 176 remaining_string = remaining_string.substr(chunk.size());
168 } 177 }
169 178
170 return (line + 1) * line_height + GetInsets().height(); 179 return (line + 1) * line_height + GetInsets().height();
171 } 180 }
172 181
173 } // namespace views 182 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698