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

Unified Diff: ui/views/examples/label_example.cc

Issue 2541313002: RenderTextHarfBuzz: Add support for multi line text selection. (Closed)
Patch Set: Fix test. Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/examples/label_example.h ('k') | ui/views/selection_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/examples/label_example.cc
diff --git a/ui/views/examples/label_example.cc b/ui/views/examples/label_example.cc
index 4255e71679c88747698b89989ab2573d26977be9..b285bb8e52186a65412ad585a57d1edda9646e57 100644
--- a/ui/views/examples/label_example.cc
+++ b/ui/views/examples/label_example.cc
@@ -115,8 +115,10 @@ void LabelExample::CreateExampleView(View* container) {
label->SetBorder(CreateSolidBorder(20, SK_ColorRED));
container->AddChildView(label);
- label = new Label(ASCIIToUTF16("A label supporting text selection."));
+ label = new Label(
+ ASCIIToUTF16("A multiline label...\n\n...which supports text selection"));
label->SetSelectable(true);
+ label->SetMultiLine(true);
container->AddChildView(label);
AddCustomLabel(container);
@@ -132,6 +134,8 @@ void LabelExample::ButtonPressed(Button* button, const ui::Event& event) {
shadows.push_back(gfx::ShadowValue(gfx::Vector2d(2, 2), 0, SK_ColorGRAY));
}
custom_label_->SetShadows(shadows);
+ } else if (button == selectable_) {
+ custom_label_->SetSelectable(selectable_->checked());
}
custom_label_->parent()->parent()->Layout();
custom_label_->SchedulePaint();
@@ -186,6 +190,8 @@ void LabelExample::AddCustomLabel(View* container) {
0, GridLayout::USE_PREF, 0, 0);
column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
0, GridLayout::USE_PREF, 0, 0);
+ column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
+ GridLayout::USE_PREF, 0, 0);
layout->StartRow(0, 1);
multiline_ = new Checkbox(base::ASCIIToUTF16("Multiline"));
multiline_->set_listener(this);
@@ -193,6 +199,9 @@ void LabelExample::AddCustomLabel(View* container) {
shadows_ = new Checkbox(base::ASCIIToUTF16("Shadows"));
shadows_->set_listener(this);
layout->AddView(shadows_);
+ selectable_ = new Checkbox(base::ASCIIToUTF16("Selectable"));
+ selectable_->set_listener(this);
+ layout->AddView(selectable_);
layout->AddPaddingRow(0, 8);
column_set = layout->AddColumnSet(2);
@@ -205,6 +214,10 @@ void LabelExample::AddCustomLabel(View* container) {
custom_label_->SetText(textfield_->text());
layout->AddView(custom_label_);
+ // Disable the text selection checkbox if |custom_label_| does not support
+ // text selection.
+ selectable_->SetEnabled(custom_label_->IsSelectionSupported());
+
container->AddChildView(control_container);
}
« no previous file with comments | « ui/views/examples/label_example.h ('k') | ui/views/selection_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698