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

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

Issue 1539583003: Convert Pass()→std::move() in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
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/examples_window.h" 5 #include "ui/views/examples/examples_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility>
9 10
10 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "ui/base/models/combobox_model.h" 13 #include "ui/base/models/combobox_model.h"
13 #include "ui/base/ui_base_paths.h" 14 #include "ui/base/ui_base_paths.h"
14 #include "ui/views/background.h" 15 #include "ui/views/background.h"
15 #include "ui/views/controls/combobox/combobox.h" 16 #include "ui/views/controls/combobox/combobox.h"
16 #include "ui/views/controls/label.h" 17 #include "ui/views/controls/label.h"
17 #include "ui/views/examples/bubble_example.h" 18 #include "ui/views/examples/bubble_example.h"
18 #include "ui/views/examples/button_example.h" 19 #include "ui/views/examples/button_example.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 examples->push_back(new SingleSplitViewExample); 69 examples->push_back(new SingleSplitViewExample);
69 examples->push_back(new SliderExample); 70 examples->push_back(new SliderExample);
70 examples->push_back(new TabbedPaneExample); 71 examples->push_back(new TabbedPaneExample);
71 examples->push_back(new TableExample); 72 examples->push_back(new TableExample);
72 examples->push_back(new TextExample); 73 examples->push_back(new TextExample);
73 examples->push_back(new TextfieldExample); 74 examples->push_back(new TextfieldExample);
74 examples->push_back(new ThrobberExample); 75 examples->push_back(new ThrobberExample);
75 examples->push_back(new TreeViewExample); 76 examples->push_back(new TreeViewExample);
76 examples->push_back(new VectorExample); 77 examples->push_back(new VectorExample);
77 examples->push_back(new WidgetExample); 78 examples->push_back(new WidgetExample);
78 return examples.Pass(); 79 return examples;
79 } 80 }
80 81
81 struct ExampleTitleCompare { 82 struct ExampleTitleCompare {
82 bool operator() (ExampleBase* a, ExampleBase* b) { 83 bool operator() (ExampleBase* a, ExampleBase* b) {
83 return a->example_title() < b->example_title(); 84 return a->example_title() < b->example_title();
84 } 85 }
85 }; 86 };
86 87
87 ScopedExamples GetExamplesToShow(ScopedExamples extra) { 88 ScopedExamples GetExamplesToShow(ScopedExamples extra) {
88 ScopedExamples examples(CreateExamples()); 89 ScopedExamples examples(CreateExamples());
89 if (extra.get()) { 90 if (extra.get()) {
90 examples->insert(examples->end(), extra->begin(), extra->end()); 91 examples->insert(examples->end(), extra->begin(), extra->end());
91 extra->weak_clear(); 92 extra->weak_clear();
92 } 93 }
93 std::sort(examples->begin(), examples->end(), ExampleTitleCompare()); 94 std::sort(examples->begin(), examples->end(), ExampleTitleCompare());
94 return examples.Pass(); 95 return examples;
95 } 96 }
96 97
97 } // namespace 98 } // namespace
98 99
99 // Model for the examples that are being added via AddExample(). 100 // Model for the examples that are being added via AddExample().
100 class ComboboxModelExampleList : public ui::ComboboxModel { 101 class ComboboxModelExampleList : public ui::ComboboxModel {
101 public: 102 public:
102 ComboboxModelExampleList() {} 103 ComboboxModelExampleList() {}
103 ~ComboboxModelExampleList() override {} 104 ~ComboboxModelExampleList() override {}
104 105
(...skipping 20 matching lines...) Expand all
125 class ExamplesWindowContents : public WidgetDelegateView, 126 class ExamplesWindowContents : public WidgetDelegateView,
126 public ComboboxListener { 127 public ComboboxListener {
127 public: 128 public:
128 ExamplesWindowContents(Operation operation, ScopedExamples examples) 129 ExamplesWindowContents(Operation operation, ScopedExamples examples)
129 : combobox_(new Combobox(&combobox_model_)), 130 : combobox_(new Combobox(&combobox_model_)),
130 example_shown_(new View), 131 example_shown_(new View),
131 status_label_(new Label), 132 status_label_(new Label),
132 operation_(operation) { 133 operation_(operation) {
133 instance_ = this; 134 instance_ = this;
134 combobox_->set_listener(this); 135 combobox_->set_listener(this);
135 combobox_model_.SetExamples(examples.Pass()); 136 combobox_model_.SetExamples(std::move(examples));
136 combobox_->ModelChanged(); 137 combobox_->ModelChanged();
137 138
138 set_background(Background::CreateStandardPanelBackground()); 139 set_background(Background::CreateStandardPanelBackground());
139 GridLayout* layout = new GridLayout(this); 140 GridLayout* layout = new GridLayout(this);
140 SetLayoutManager(layout); 141 SetLayoutManager(layout);
141 ColumnSet* column_set = layout->AddColumnSet(0); 142 ColumnSet* column_set = layout->AddColumnSet(0);
142 column_set->AddPaddingColumn(0, 5); 143 column_set->AddPaddingColumn(0, 5);
143 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 144 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
144 GridLayout::USE_PREF, 0, 0); 145 GridLayout::USE_PREF, 0, 0);
145 column_set->AddPaddingColumn(0, 5); 146 column_set->AddPaddingColumn(0, 5);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 213
213 // static 214 // static
214 ExamplesWindowContents* ExamplesWindowContents::instance_ = NULL; 215 ExamplesWindowContents* ExamplesWindowContents::instance_ = NULL;
215 216
216 void ShowExamplesWindow(Operation operation, 217 void ShowExamplesWindow(Operation operation,
217 gfx::NativeWindow window_context, 218 gfx::NativeWindow window_context,
218 ScopedExamples extra_examples) { 219 ScopedExamples extra_examples) {
219 if (ExamplesWindowContents::instance()) { 220 if (ExamplesWindowContents::instance()) {
220 ExamplesWindowContents::instance()->GetWidget()->Activate(); 221 ExamplesWindowContents::instance()->GetWidget()->Activate();
221 } else { 222 } else {
222 ScopedExamples examples(GetExamplesToShow(extra_examples.Pass())); 223 ScopedExamples examples(GetExamplesToShow(std::move(extra_examples)));
223 Widget* widget = new Widget; 224 Widget* widget = new Widget;
224 Widget::InitParams params; 225 Widget::InitParams params;
225 params.delegate = new ExamplesWindowContents(operation, examples.Pass()); 226 params.delegate =
227 new ExamplesWindowContents(operation, std::move(examples));
226 params.context = window_context; 228 params.context = window_context;
227 widget->Init(params); 229 widget->Init(params);
228 widget->Show(); 230 widget->Show();
229 } 231 }
230 } 232 }
231 233
232 void LogStatus(const std::string& string) { 234 void LogStatus(const std::string& string) {
233 ExamplesWindowContents::instance()->SetStatus(string); 235 ExamplesWindowContents::instance()->SetStatus(string);
234 } 236 }
235 237
236 } // namespace examples 238 } // namespace examples
237 } // namespace views 239 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/tooltip_controller.cc ('k') | ui/views/examples/examples_window_with_content.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698