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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Final feedback addressed Created 3 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/controls/button/md_text_button.cc ('k') | ui/views/layout/grid_layout.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/dialog_example.h" 5 #include "ui/views/examples/dialog_example.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/views/bubble/bubble_dialog_delegate.h" 9 #include "ui/views/bubble/bubble_dialog_delegate.h"
10 #include "ui/views/controls/button/checkbox.h" 10 #include "ui/views/controls/button/checkbox.h"
11 #include "ui/views/controls/button/label_button.h" 11 #include "ui/views/controls/button/label_button.h"
12 #include "ui/views/controls/button/md_text_button.h" 12 #include "ui/views/controls/button/md_text_button.h"
13 #include "ui/views/controls/combobox/combobox.h" 13 #include "ui/views/controls/combobox/combobox.h"
14 #include "ui/views/controls/label.h" 14 #include "ui/views/controls/label.h"
15 #include "ui/views/controls/textfield/textfield.h" 15 #include "ui/views/controls/textfield/textfield.h"
16 #include "ui/views/layout/fill_layout.h" 16 #include "ui/views/layout/fill_layout.h"
17 #include "ui/views/layout/grid_layout.h" 17 #include "ui/views/layout/grid_layout.h"
18 #include "ui/views/layout/layout_constants.h" 18 #include "ui/views/layout/layout_constants.h"
19 #include "ui/views/views_delegate.h" 19 #include "ui/views/layout/layout_provider.h"
20 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
21 #include "ui/views/window/dialog_client_view.h" 21 #include "ui/views/window/dialog_client_view.h"
22 22
23 using base::ASCIIToUTF16; 23 using base::ASCIIToUTF16;
24 24
25 namespace views { 25 namespace views {
26 namespace examples { 26 namespace examples {
27 namespace { 27 namespace {
28 28
29 constexpr int kFieldsColumnId = 0; 29 constexpr int kFieldsColumnId = 0;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 }) {} 125 }) {}
126 126
127 DialogExample::~DialogExample() {} 127 DialogExample::~DialogExample() {}
128 128
129 void DialogExample::CreateExampleView(View* container) { 129 void DialogExample::CreateExampleView(View* container) {
130 // GridLayout |resize_percent| constants. 130 // GridLayout |resize_percent| constants.
131 const float kFixed = 0.f; 131 const float kFixed = 0.f;
132 const float kStretchy = 1.f; 132 const float kStretchy = 1.f;
133 133
134 const int horizontal_spacing = 134 const int horizontal_spacing =
135 ViewsDelegate::GetInstance()->GetDistanceMetric( 135 views::LayoutProvider::Get()->GetDistanceMetric(
136 views::DistanceMetric::RELATED_BUTTON_HORIZONTAL); 136 views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
137 GridLayout* layout = GridLayout::CreatePanel(container); 137 GridLayout* layout = GridLayout::CreatePanel(container);
138 container->SetLayoutManager(layout); 138 container->SetLayoutManager(layout);
139 ColumnSet* column_set = layout->AddColumnSet(kFieldsColumnId); 139 ColumnSet* column_set = layout->AddColumnSet(kFieldsColumnId);
140 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, kFixed, 140 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, kFixed,
141 GridLayout::USE_PREF, 0, 0); 141 GridLayout::USE_PREF, 0, 0);
142 column_set->AddPaddingColumn(kFixed, horizontal_spacing); 142 column_set->AddPaddingColumn(kFixed, horizontal_spacing);
143 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kStretchy, 143 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kStretchy,
144 GridLayout::USE_PREF, 0, 0); 144 GridLayout::USE_PREF, 0, 0);
145 column_set->AddPaddingColumn(kFixed, horizontal_spacing); 145 column_set->AddPaddingColumn(kFixed, horizontal_spacing);
146 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kFixed, 146 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kFixed,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 layout->AddView(show_); 179 layout->AddView(show_);
180 180
181 // Grow the dialog a bit when this example is first selected, so it all fits. 181 // Grow the dialog a bit when this example is first selected, so it all fits.
182 gfx::Size dialog_size = container->GetWidget()->GetRestoredBounds().size(); 182 gfx::Size dialog_size = container->GetWidget()->GetRestoredBounds().size();
183 dialog_size.set_height(dialog_size.height() + 80); 183 dialog_size.set_height(dialog_size.height() + 80);
184 container->GetWidget()->SetSize(dialog_size); 184 container->GetWidget()->SetSize(dialog_size);
185 } 185 }
186 186
187 void DialogExample::StartRowWithLabel(GridLayout* layout, const char* label) { 187 void DialogExample::StartRowWithLabel(GridLayout* layout, const char* label) {
188 const float kFixedVerticalResize = 0.f; 188 const float kFixedVerticalResize = 0.f;
189 layout->StartRowWithPadding( 189 layout->StartRowWithPadding(kFixedVerticalResize, kFieldsColumnId,
190 kFixedVerticalResize, kFieldsColumnId, kFixedVerticalResize, 190 kFixedVerticalResize,
191 ViewsDelegate::GetInstance()->GetDistanceMetric( 191 views::LayoutProvider::Get()->GetDistanceMetric(
192 views::DistanceMetric::RELATED_CONTROL_VERTICAL)); 192 views::DISTANCE_RELATED_CONTROL_VERTICAL));
193 layout->AddView(new Label(base::ASCIIToUTF16(label))); 193 layout->AddView(new Label(base::ASCIIToUTF16(label)));
194 } 194 }
195 195
196 void DialogExample::StartTextfieldRow(GridLayout* layout, 196 void DialogExample::StartTextfieldRow(GridLayout* layout,
197 Textfield** member, 197 Textfield** member,
198 const char* label, 198 const char* label,
199 const char* value) { 199 const char* value) {
200 StartRowWithLabel(layout, label); 200 StartRowWithLabel(layout, label);
201 Textfield* textfield = new Textfield(); 201 Textfield* textfield = new Textfield();
202 layout->AddView(textfield); 202 layout->AddView(textfield);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 #endif 326 #endif
327 show_->SetEnabled(enable); 327 show_->SetEnabled(enable);
328 if (!enable && GetModalType() == ui::MODAL_TYPE_CHILD) 328 if (!enable && GetModalType() == ui::MODAL_TYPE_CHILD)
329 PrintStatus("MODAL_TYPE_CHILD can't be used with non-bubbles."); 329 PrintStatus("MODAL_TYPE_CHILD can't be used with non-bubbles.");
330 if (!enable && GetModalType() == ui::MODAL_TYPE_SYSTEM) 330 if (!enable && GetModalType() == ui::MODAL_TYPE_SYSTEM)
331 PrintStatus("MODAL_TYPE_SYSTEM isn't supported on Mac."); 331 PrintStatus("MODAL_TYPE_SYSTEM isn't supported on Mac.");
332 } 332 }
333 333
334 } // namespace examples 334 } // namespace examples
335 } // namespace views 335 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/md_text_button.cc ('k') | ui/views/layout/grid_layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698