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

Side by Side Diff: ui/views/examples/multiline_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/controls/tabbed_pane/tabbed_pane.cc ('k') | ui/views/examples/text_example.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 #include "ui/views/examples/multiline_example.h" 5 #include "ui/views/examples/multiline_example.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 gfx::Range bold_range = ClampRange(gfx::Range(4, 10), range_max); 94 gfx::Range bold_range = ClampRange(gfx::Range(4, 10), range_max);
95 gfx::Range italic_range = ClampRange(gfx::Range(7, 13), range_max); 95 gfx::Range italic_range = ClampRange(gfx::Range(7, 13), range_max);
96 96
97 render_text_->SetText(new_contents); 97 render_text_->SetText(new_contents);
98 render_text_->SetColor(SK_ColorBLACK); 98 render_text_->SetColor(SK_ColorBLACK);
99 render_text_->ApplyColor(0xFFFF0000, color_range); 99 render_text_->ApplyColor(0xFFFF0000, color_range);
100 render_text_->SetStyle(gfx::DIAGONAL_STRIKE, false); 100 render_text_->SetStyle(gfx::DIAGONAL_STRIKE, false);
101 render_text_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, color_range); 101 render_text_->ApplyStyle(gfx::DIAGONAL_STRIKE, true, color_range);
102 render_text_->SetStyle(gfx::UNDERLINE, false); 102 render_text_->SetStyle(gfx::UNDERLINE, false);
103 render_text_->ApplyStyle(gfx::UNDERLINE, true, color_range); 103 render_text_->ApplyStyle(gfx::UNDERLINE, true, color_range);
104 render_text_->ApplyStyle(gfx::BOLD, true, bold_range);
105 render_text_->ApplyStyle(gfx::ITALIC, true, italic_range); 104 render_text_->ApplyStyle(gfx::ITALIC, true, italic_range);
105 render_text_->ApplyWeight(gfx::Font::Weight::BOLD, bold_range);
106 InvalidateLayout(); 106 InvalidateLayout();
107 } 107 }
108 108
109 void SetMaxLines(int max_lines) { 109 void SetMaxLines(int max_lines) {
110 render_text_->SetMaxLines(max_lines); 110 render_text_->SetMaxLines(max_lines);
111 render_text_->SetElideBehavior(max_lines ? gfx::ELIDE_TAIL : gfx::NO_ELIDE); 111 render_text_->SetElideBehavior(max_lines ? gfx::ELIDE_TAIL : gfx::NO_ELIDE);
112 } 112 }
113 113
114 private: 114 private:
115 void OnBoundsChanged(const gfx::Rect& previous_bounds) override { 115 void OnBoundsChanged(const gfx::Rect& previous_bounds) override {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 : base::string16()); 201 : base::string16());
202 } else if (sender == elision_checkbox_) { 202 } else if (sender == elision_checkbox_) {
203 render_text_view_->SetMaxLines(elision_checkbox_->checked() ? 3 : 0); 203 render_text_view_->SetMaxLines(elision_checkbox_->checked() ? 3 : 0);
204 } 204 }
205 container()->Layout(); 205 container()->Layout();
206 container()->SchedulePaint(); 206 container()->SchedulePaint();
207 } 207 }
208 208
209 } // namespace examples 209 } // namespace examples
210 } // namespace views 210 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/tabbed_pane/tabbed_pane.cc ('k') | ui/views/examples/text_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698