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

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

Issue 17756003: Colors in views::StyledLabel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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
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/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "ui/base/text/text_elider.h" 10 #include "ui/base/text/text_elider.h"
11 #include "ui/gfx/color_utils.h"
12 #include "ui/native_theme/native_theme.h"
11 #include "ui/views/controls/label.h" 13 #include "ui/views/controls/label.h"
12 #include "ui/views/controls/link.h" 14 #include "ui/views/controls/link.h"
13 #include "ui/views/controls/styled_label_listener.h" 15 #include "ui/views/controls/styled_label_listener.h"
14 16
15 namespace views { 17 namespace views {
16 18
17 namespace { 19 namespace {
18 20
19 // Calculates the height of a line of text. Currently returns the height of 21 // Calculates the height of a line of text. Currently returns the height of
20 // a label. 22 // a label.
(...skipping 14 matching lines...) Expand all
35 result.reset(link); 37 result.reset(link);
36 } else { 38 } else {
37 Label* label = new Label(text); 39 Label* label = new Label(text);
38 // Give the label a focus border so that its preferred size matches 40 // Give the label a focus border so that its preferred size matches
39 // links' preferred sizes 41 // links' preferred sizes
40 label->SetHasFocusBorder(true); 42 label->SetHasFocusBorder(true);
41 43
42 result.reset(label); 44 result.reset(label);
43 } 45 }
44 46
47 result->SetEnabledColor(style_info.color);
48
45 if (!style_info.tooltip.empty()) 49 if (!style_info.tooltip.empty())
46 result->SetTooltipText(style_info.tooltip); 50 result->SetTooltipText(style_info.tooltip);
47 if (style_info.font_style != gfx::Font::NORMAL) 51 if (style_info.font_style != gfx::Font::NORMAL)
48 result->SetFont(result->font().DeriveFont(0, style_info.font_style)); 52 result->SetFont(result->font().DeriveFont(0, style_info.font_style));
49 53
50 return scoped_ptr<View>(result.release()); 54 return scoped_ptr<View>(result.release());
51 } 55 }
52 56
53 } // namespace 57 } // namespace
54 58
55 59
56 StyledLabel::RangeStyleInfo::RangeStyleInfo() 60 StyledLabel::RangeStyleInfo::RangeStyleInfo()
57 : font_style(gfx::Font::NORMAL), 61 : font_style(gfx::Font::NORMAL),
62 color(ui::NativeTheme::instance()->GetSystemColor(
63 ui::NativeTheme::kColorId_LabelEnabledColor)),
58 disable_line_wrapping(false), 64 disable_line_wrapping(false),
59 is_link(false) { 65 is_link(false) {
60 } 66 }
61 67
62 StyledLabel::RangeStyleInfo::~RangeStyleInfo() {} 68 StyledLabel::RangeStyleInfo::~RangeStyleInfo() {}
63 69
64 // static 70 // static
65 StyledLabel::RangeStyleInfo StyledLabel::RangeStyleInfo::CreateForLink() { 71 StyledLabel::RangeStyleInfo StyledLabel::RangeStyleInfo::CreateForLink() {
66 RangeStyleInfo result; 72 RangeStyleInfo result;
67 result.disable_line_wrapping = true; 73 result.disable_line_wrapping = true;
68 result.is_link = true; 74 result.is_link = true;
69 result.font_style = gfx::Font::UNDERLINE; 75 result.font_style = gfx::Font::UNDERLINE;
76 #if defined(OS_WIN)
77 result.color = color_utils::GetSysSkColor(COLOR_HOTLIGHT);
78 #else
79 // TODO(fdoray): source from theme provider.
80 result.color = SkColorSetRGB(0, 51, 153);
Roger Tawa OOO till Jul 10th 2013/06/26 15:16:29 When will this get fixed? When you finish the GTK
fdoray 2013/06/26 17:06:38 This is how the default link color is obtained for
Roger Tawa OOO till Jul 10th 2013/06/27 13:34:32 Might want to ask Ben what his plans are. Adding
81 #endif
70 return result; 82 return result;
71 } 83 }
72 84
73 bool StyledLabel::StyleRange::operator<( 85 bool StyledLabel::StyleRange::operator<(
74 const StyledLabel::StyleRange& other) const { 86 const StyledLabel::StyleRange& other) const {
75 // Intentionally reversed so the priority queue is sorted by smallest first. 87 // Intentionally reversed so the priority queue is sorted by smallest first.
76 return range.start() > other.range.start(); 88 return range.start() > other.range.start();
77 } 89 }
78 90
79 StyledLabel::StyledLabel(const string16& text, StyledLabelListener* listener) 91 StyledLabel::StyledLabel(const string16& text, StyledLabelListener* listener)
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 251 }
240 x += view_size.width() - 2 * overlap; 252 x += view_size.width() - 2 * overlap;
241 253
242 remaining_string = remaining_string.substr(chunk.size()); 254 remaining_string = remaining_string.substr(chunk.size());
243 } 255 }
244 256
245 return (line + 1) * line_height + GetInsets().height(); 257 return (line + 1) * line_height + GetInsets().height();
246 } 258 }
247 259
248 } // namespace views 260 } // namespace views
OLDNEW
« chrome/browser/chromeos/ui/echo_dialog_view.cc ('K') | « ui/views/controls/styled_label.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698