| Index: ui/views/examples/textfield_example.cc
|
| diff --git a/ui/views/examples/textfield_example.cc b/ui/views/examples/textfield_example.cc
|
| index ffcf464e9e57fef5e9a80acd16fd8238b9556fbe..11ca35e505c8d404834b9dceda66db0aaa042ac4 100644
|
| --- a/ui/views/examples/textfield_example.cc
|
| +++ b/ui/views/examples/textfield_example.cc
|
| @@ -8,6 +8,7 @@
|
|
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "ui/events/event.h"
|
| +#include "ui/gfx/color_palette.h"
|
| #include "ui/gfx/range/range.h"
|
| #include "ui/gfx/render_text.h"
|
| #include "ui/views/controls/button/label_button.h"
|
| @@ -46,6 +47,8 @@ void TextfieldExample::CreateExampleView(View* container) {
|
| read_only_->SetReadOnly(true);
|
| read_only_->SetText(ASCIIToUTF16("read only"));
|
| show_password_ = new LabelButton(this, ASCIIToUTF16("Show password"));
|
| + set_background_ =
|
| + new LabelButton(this, ASCIIToUTF16("Set non-default background"));
|
| clear_all_ = new LabelButton(this, ASCIIToUTF16("Clear All"));
|
| append_ = new LabelButton(this, ASCIIToUTF16("Append"));
|
| set_ = new LabelButton(this, ASCIIToUTF16("Set"));
|
| @@ -61,25 +64,23 @@ void TextfieldExample::CreateExampleView(View* container) {
|
| 0.2f, GridLayout::USE_PREF, 0, 0);
|
| column_set->AddColumn(GridLayout::FILL, GridLayout::FILL,
|
| 0.8f, GridLayout::USE_PREF, 0, 0);
|
| - layout->StartRow(0, 0);
|
| - layout->AddView(new Label(ASCIIToUTF16("Name:")));
|
| - layout->AddView(name_);
|
| - layout->StartRow(0, 0);
|
| - layout->AddView(new Label(ASCIIToUTF16("Password:")));
|
| - layout->AddView(password_);
|
| - layout->StartRow(0, 0);
|
| - layout->AddView(new Label(ASCIIToUTF16("Read Only:")));
|
| - layout->AddView(read_only_);
|
| - layout->StartRow(0, 0);
|
| - layout->AddView(show_password_);
|
| - layout->StartRow(0, 0);
|
| - layout->AddView(clear_all_);
|
| - layout->StartRow(0, 0);
|
| - layout->AddView(append_);
|
| - layout->StartRow(0, 0);
|
| - layout->AddView(set_);
|
| - layout->StartRow(0, 0);
|
| - layout->AddView(set_style_);
|
| +
|
| + auto MakeRow = [layout](View* view1, View* view2) {
|
| + layout->StartRowWithPadding(0, 0, 0, 5);
|
| + layout->AddView(view1);
|
| + if (view2)
|
| + layout->AddView(view2);
|
| + };
|
| + MakeRow(new Label(ASCIIToUTF16("Name:")), name_);
|
| + MakeRow(new Label(ASCIIToUTF16("Password:")), password_);
|
| + MakeRow(new Label(ASCIIToUTF16("Read Only:")), read_only_);
|
| + MakeRow(new Label(ASCIIToUTF16("Name:")), nullptr);
|
| + MakeRow(show_password_, nullptr);
|
| + MakeRow(set_background_, nullptr);
|
| + MakeRow(clear_all_, nullptr);
|
| + MakeRow(append_, nullptr);
|
| + MakeRow(set_, nullptr);
|
| + MakeRow(set_style_, nullptr);
|
| }
|
|
|
| void TextfieldExample::ContentsChanged(Textfield* sender,
|
| @@ -107,6 +108,8 @@ bool TextfieldExample::HandleMouseEvent(Textfield* sender,
|
| void TextfieldExample::ButtonPressed(Button* sender, const ui::Event& event) {
|
| if (sender == show_password_) {
|
| PrintStatus("Password [%s]", UTF16ToUTF8(password_->text()).c_str());
|
| + } else if (sender == set_background_) {
|
| + password_->SetBackgroundColor(gfx::kGoogleRed300);
|
| } else if (sender == clear_all_) {
|
| base::string16 empty;
|
| name_->SetText(empty);
|
|
|