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

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

Issue 1870573003: Full Keyboard Access: Second Approach (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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/examples/button_example.cc ('k') | ui/views/examples/widget_example.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/tree_view_example.h" 5 #include "ui/views/examples/tree_view_example.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/views/controls/button/label_button.h" 8 #include "ui/views/controls/button/label_button.h"
9 #include "ui/views/controls/menu/menu_model_adapter.h" 9 #include "ui/views/controls/menu/menu_model_adapter.h"
10 #include "ui/views/controls/menu/menu_runner.h" 10 #include "ui/views/controls/menu/menu_runner.h"
11 #include "ui/views/controls/tree/tree_view.h" 11 #include "ui/views/controls/tree/tree_view.h"
12 #include "ui/views/layout/grid_layout.h" 12 #include "ui/views/layout/grid_layout.h"
13 #include "ui/views/style/platform_style.h"
13 14
14 using base::ASCIIToUTF16; 15 using base::ASCIIToUTF16;
15 16
16 namespace views { 17 namespace views {
17 namespace examples { 18 namespace examples {
18 19
19 TreeViewExample::TreeViewExample() 20 TreeViewExample::TreeViewExample()
20 : ExampleBase("Tree View"), 21 : ExampleBase("Tree View"),
21 tree_view_(NULL), 22 tree_view_(NULL),
22 model_(new NodeType(ASCIIToUTF16("root"), 1)) { 23 model_(new NodeType(ASCIIToUTF16("root"), 1)) {
(...skipping 17 matching lines...) Expand all
40 model_.GetRoot()->Add(sheep_node, 0); 41 model_.GetRoot()->Add(sheep_node, 0);
41 sheep_node->Add(new NodeType(ASCIIToUTF16("Sheep 1"), 1), 0); 42 sheep_node->Add(new NodeType(ASCIIToUTF16("Sheep 1"), 1), 0);
42 sheep_node->Add(new NodeType(ASCIIToUTF16("Sheep 2"), 1), 1); 43 sheep_node->Add(new NodeType(ASCIIToUTF16("Sheep 2"), 1), 1);
43 44
44 tree_view_ = new TreeView(); 45 tree_view_ = new TreeView();
45 tree_view_->set_context_menu_controller(this); 46 tree_view_->set_context_menu_controller(this);
46 tree_view_->SetRootShown(false); 47 tree_view_->SetRootShown(false);
47 tree_view_->SetModel(&model_); 48 tree_view_->SetModel(&model_);
48 tree_view_->SetController(this); 49 tree_view_->SetController(this);
49 add_ = new LabelButton(this, ASCIIToUTF16("Add")); 50 add_ = new LabelButton(this, ASCIIToUTF16("Add"));
50 add_->SetFocusable(true); 51 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::BUTTON, add_);
51 remove_ = new LabelButton(this, ASCIIToUTF16("Remove")); 52 remove_ = new LabelButton(this, ASCIIToUTF16("Remove"));
52 remove_->SetFocusable(true); 53 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::BUTTON, remove_);
53 change_title_ = new LabelButton(this, ASCIIToUTF16("Change Title")); 54 change_title_ = new LabelButton(this, ASCIIToUTF16("Change Title"));
54 change_title_->SetFocusable(true); 55 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::BUTTON, change_title_);
55 56
56 GridLayout* layout = new GridLayout(container); 57 GridLayout* layout = new GridLayout(container);
57 container->SetLayoutManager(layout); 58 container->SetLayoutManager(layout);
58 59
59 const int tree_view_column = 0; 60 const int tree_view_column = 0;
60 ColumnSet* column_set = layout->AddColumnSet(tree_view_column); 61 ColumnSet* column_set = layout->AddColumnSet(tree_view_column);
61 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 62 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL,
62 1.0f, GridLayout::USE_PREF, 0, 0); 63 1.0f, GridLayout::USE_PREF, 0, 0);
63 layout->StartRow(1 /* expand */, tree_view_column); 64 layout->StartRow(1 /* expand */, tree_view_column);
64 layout->AddView(tree_view_->CreateParentIfNecessary()); 65 layout->AddView(tree_view_->CreateParentIfNecessary());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 case ID_ADD: 170 case ID_ADD:
170 AddNewNode(); 171 AddNewNode();
171 break; 172 break;
172 default: 173 default:
173 NOTREACHED(); 174 NOTREACHED();
174 } 175 }
175 } 176 }
176 177
177 } // namespace examples 178 } // namespace examples
178 } // namespace views 179 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/button_example.cc ('k') | ui/views/examples/widget_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698