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

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

Issue 2413223003: Views:: Make Labels support text selection. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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/textfield/textfield_unittest.cc ('k') | ui/views/selection_controller.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 (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/label_example.h" 5 #include "ui/views/examples/label_example.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/gfx/geometry/vector2d.h" 10 #include "ui/gfx/geometry/vector2d.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 label->SetText(ASCIIToUTF16("A multi-line label will wrap onto subsequent " 108 label->SetText(ASCIIToUTF16("A multi-line label will wrap onto subsequent "
109 "lines if the text's width exceeds the label's available width, which is " 109 "lines if the text's width exceeds the label's available width, which is "
110 "helpful for extemely long text used to demonstrate line wrapping.")); 110 "helpful for extemely long text used to demonstrate line wrapping."));
111 label->SetMultiLine(true); 111 label->SetMultiLine(true);
112 container->AddChildView(label); 112 container->AddChildView(label);
113 113
114 label = new Label(ASCIIToUTF16("Label with thick border")); 114 label = new Label(ASCIIToUTF16("Label with thick border"));
115 label->SetBorder(CreateSolidBorder(20, SK_ColorRED)); 115 label->SetBorder(CreateSolidBorder(20, SK_ColorRED));
116 container->AddChildView(label); 116 container->AddChildView(label);
117 117
118 label = new Label(ASCIIToUTF16("A label supporting text selection."));
119 label->SetSelectable(true);
120 container->AddChildView(label);
121
118 AddCustomLabel(container); 122 AddCustomLabel(container);
119 } 123 }
120 124
121 void LabelExample::ButtonPressed(Button* button, const ui::Event& event) { 125 void LabelExample::ButtonPressed(Button* button, const ui::Event& event) {
122 if (button == multiline_) { 126 if (button == multiline_) {
123 custom_label_->SetMultiLine(multiline_->checked()); 127 custom_label_->SetMultiLine(multiline_->checked());
124 } else if (button == shadows_) { 128 } else if (button == shadows_) {
125 gfx::ShadowValues shadows; 129 gfx::ShadowValues shadows;
126 if (shadows_->checked()) { 130 if (shadows_->checked()) {
127 shadows.push_back(gfx::ShadowValue(gfx::Vector2d(), 1, SK_ColorRED)); 131 shadows.push_back(gfx::ShadowValue(gfx::Vector2d(), 1, SK_ColorRED));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 example_combobox_models_.push_back(base::WrapUnique(model)); 218 example_combobox_models_.push_back(base::WrapUnique(model));
215 Combobox* combobox = new Combobox(model); 219 Combobox* combobox = new Combobox(model);
216 combobox->SetSelectedIndex(0); 220 combobox->SetSelectedIndex(0);
217 combobox->set_listener(this); 221 combobox->set_listener(this);
218 layout->AddView(combobox); 222 layout->AddView(combobox);
219 return combobox; 223 return combobox;
220 } 224 }
221 225
222 } // namespace examples 226 } // namespace examples
223 } // namespace views 227 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield_unittest.cc ('k') | ui/views/selection_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698