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

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

Issue 2696263002: Refactor ViewsDelegate and MD-ify the icon-to-text spacing for checkbox and radiobutton (Closed)
Patch Set: Used ifdef instead of duplicated code for delegate initialization Created 3 years, 9 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/layout_constants.h » ('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"
(...skipping 114 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()->GetDialogRelatedButtonHorizontalSpacing(); 135 ViewsDelegate::GetInstance()->GetDistanceMetric(
136 views::DistanceMetric::RELATED_BUTTON_HORIZONTAL);
136 GridLayout* layout = GridLayout::CreatePanel(container); 137 GridLayout* layout = GridLayout::CreatePanel(container);
137 container->SetLayoutManager(layout); 138 container->SetLayoutManager(layout);
138 ColumnSet* column_set = layout->AddColumnSet(kFieldsColumnId); 139 ColumnSet* column_set = layout->AddColumnSet(kFieldsColumnId);
139 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, kFixed, 140 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, kFixed,
140 GridLayout::USE_PREF, 0, 0); 141 GridLayout::USE_PREF, 0, 0);
141 column_set->AddPaddingColumn(kFixed, horizontal_spacing); 142 column_set->AddPaddingColumn(kFixed, horizontal_spacing);
142 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kStretchy, 143 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kStretchy,
143 GridLayout::USE_PREF, 0, 0); 144 GridLayout::USE_PREF, 0, 0);
144 column_set->AddPaddingColumn(kFixed, horizontal_spacing); 145 column_set->AddPaddingColumn(kFixed, horizontal_spacing);
145 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kFixed, 146 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kFixed,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // 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.
181 gfx::Size dialog_size = container->GetWidget()->GetRestoredBounds().size(); 182 gfx::Size dialog_size = container->GetWidget()->GetRestoredBounds().size();
182 dialog_size.set_height(dialog_size.height() + 80); 183 dialog_size.set_height(dialog_size.height() + 80);
183 container->GetWidget()->SetSize(dialog_size); 184 container->GetWidget()->SetSize(dialog_size);
184 } 185 }
185 186
186 void DialogExample::StartRowWithLabel(GridLayout* layout, const char* label) { 187 void DialogExample::StartRowWithLabel(GridLayout* layout, const char* label) {
187 const float kFixedVerticalResize = 0.f; 188 const float kFixedVerticalResize = 0.f;
188 layout->StartRowWithPadding( 189 layout->StartRowWithPadding(
189 kFixedVerticalResize, kFieldsColumnId, kFixedVerticalResize, 190 kFixedVerticalResize, kFieldsColumnId, kFixedVerticalResize,
190 ViewsDelegate::GetInstance()->GetDialogRelatedControlVerticalSpacing()); 191 ViewsDelegate::GetInstance()->GetDistanceMetric(
192 views::DistanceMetric::RELATED_CONTROL_VERTICAL));
191 layout->AddView(new Label(base::ASCIIToUTF16(label))); 193 layout->AddView(new Label(base::ASCIIToUTF16(label)));
192 } 194 }
193 195
194 void DialogExample::StartTextfieldRow(GridLayout* layout, 196 void DialogExample::StartTextfieldRow(GridLayout* layout,
195 Textfield** member, 197 Textfield** member,
196 const char* label, 198 const char* label,
197 const char* value) { 199 const char* value) {
198 StartRowWithLabel(layout, label); 200 StartRowWithLabel(layout, label);
199 Textfield* textfield = new Textfield(); 201 Textfield* textfield = new Textfield();
200 layout->AddView(textfield); 202 layout->AddView(textfield);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 #endif 326 #endif
325 show_->SetEnabled(enable); 327 show_->SetEnabled(enable);
326 if (!enable && GetModalType() == ui::MODAL_TYPE_CHILD) 328 if (!enable && GetModalType() == ui::MODAL_TYPE_CHILD)
327 PrintStatus("MODAL_TYPE_CHILD can't be used with non-bubbles."); 329 PrintStatus("MODAL_TYPE_CHILD can't be used with non-bubbles.");
328 if (!enable && GetModalType() == ui::MODAL_TYPE_SYSTEM) 330 if (!enable && GetModalType() == ui::MODAL_TYPE_SYSTEM)
329 PrintStatus("MODAL_TYPE_SYSTEM isn't supported on Mac."); 331 PrintStatus("MODAL_TYPE_SYSTEM isn't supported on Mac.");
330 } 332 }
331 333
332 } // namespace examples 334 } // namespace examples
333 } // namespace views 335 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/md_text_button.cc ('k') | ui/views/layout/layout_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698