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

Side by Side Diff: ui/views/examples/textfield_example.cc

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a lost comment and modify a render text unittest to not test black because of test env font con… Created 4 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
« no previous file with comments | « ui/views/examples/text_example.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/views/examples/textfield_example.h" 5 #include "ui/views/examples/textfield_example.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 name_->AppendText(ASCIIToUTF16("[append]")); 116 name_->AppendText(ASCIIToUTF16("[append]"));
117 password_->AppendText(ASCIIToUTF16("[append]")); 117 password_->AppendText(ASCIIToUTF16("[append]"));
118 read_only_->AppendText(ASCIIToUTF16("[append]")); 118 read_only_->AppendText(ASCIIToUTF16("[append]"));
119 } else if (sender == set_) { 119 } else if (sender == set_) {
120 name_->SetText(ASCIIToUTF16("[set]")); 120 name_->SetText(ASCIIToUTF16("[set]"));
121 password_->SetText(ASCIIToUTF16("[set]")); 121 password_->SetText(ASCIIToUTF16("[set]"));
122 read_only_->SetText(ASCIIToUTF16("[set]")); 122 read_only_->SetText(ASCIIToUTF16("[set]"));
123 } else if (sender == set_style_) { 123 } else if (sender == set_style_) {
124 if (!name_->text().empty()) { 124 if (!name_->text().empty()) {
125 name_->SetColor(SK_ColorGREEN); 125 name_->SetColor(SK_ColorGREEN);
126 name_->SetStyle(gfx::BOLD, true);
127 126
128 if (name_->text().length() >= 5) { 127 if (name_->text().length() >= 5) {
129 size_t fifth = name_->text().length() / 5; 128 size_t fifth = name_->text().length() / 5;
130 const gfx::Range big_range(1 * fifth, 4 * fifth); 129 const gfx::Range big_range(1 * fifth, 4 * fifth);
131 name_->ApplyStyle(gfx::BOLD, false, big_range);
132 name_->ApplyStyle(gfx::UNDERLINE, true, big_range); 130 name_->ApplyStyle(gfx::UNDERLINE, true, big_range);
133 name_->ApplyColor(SK_ColorBLUE, big_range); 131 name_->ApplyColor(SK_ColorBLUE, big_range);
134 132
135 const gfx::Range small_range(2 * fifth, 3 * fifth); 133 const gfx::Range small_range(2 * fifth, 3 * fifth);
136 name_->ApplyStyle(gfx::ITALIC, true, small_range); 134 name_->ApplyStyle(gfx::ITALIC, true, small_range);
137 name_->ApplyStyle(gfx::UNDERLINE, false, small_range); 135 name_->ApplyStyle(gfx::UNDERLINE, false, small_range);
138 name_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, small_range); 136 name_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, small_range);
139 name_->ApplyColor(SK_ColorRED, small_range); 137 name_->ApplyColor(SK_ColorRED, small_range);
140 } 138 }
141 } 139 }
142 } 140 }
143 } 141 }
144 142
145 } // namespace examples 143 } // namespace examples
146 } // namespace views 144 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/text_example.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698