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

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

Issue 2541313002: RenderTextHarfBuzz: Add support for multi line text selection. (Closed)
Patch Set: -- 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
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..0b6b344c3663237c289319208d8381dc1cbb1712 100644
--- a/ui/views/examples/label_example.cc
+++ b/ui/views/examples/label_example.cc
@@ -132,6 +132,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 == text_selection_) {
+ custom_label_->SetSelectable(text_selection_->checked());
}
custom_label_->parent()->parent()->Layout();
custom_label_->SchedulePaint();
@@ -186,6 +188,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 +197,9 @@ void LabelExample::AddCustomLabel(View* container) {
shadows_ = new Checkbox(base::ASCIIToUTF16("Shadows"));
shadows_->set_listener(this);
layout->AddView(shadows_);
+ text_selection_ = new Checkbox(base::ASCIIToUTF16("Text selection"));
+ text_selection_->set_listener(this);
+ layout->AddView(text_selection_);
layout->AddPaddingRow(0, 8);
column_set = layout->AddColumnSet(2);
@@ -205,6 +212,13 @@ 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.
+ if (custom_label_->SetSelectable(true))
+ text_selection_->SetChecked(true);
+ else
+ text_selection_->SetEnabled(false);
+
container->AddChildView(control_container);
}

Powered by Google App Engine
This is Rietveld 408576698