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

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

Issue 2934503002: Remove references to ui/views/layout/layout_constants.h (Closed)
Patch Set: Created 3 years, 6 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 | « chrome/browser/ui/views/uninstall_view.cc ('k') | ui/views/layout/layout_provider.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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 base::ASCIIToUTF16("Fake Modeless (non-bubbles)"), 124 base::ASCIIToUTF16("Fake Modeless (non-bubbles)"),
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 views::LayoutProvider* provider = views::LayoutProvider::Get();
134 const int horizontal_spacing = 135 const int horizontal_spacing =
135 views::LayoutProvider::Get()->GetDistanceMetric( 136 provider->GetDistanceMetric(views::DISTANCE_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 18 matching lines...) Expand all
165 layout->AddView(mode_); 165 layout->AddView(mode_);
166 166
167 StartRowWithLabel(layout, "Bubble"); 167 StartRowWithLabel(layout, "Bubble");
168 AddCheckbox(layout, &bubble_); 168 AddCheckbox(layout, &bubble_);
169 AddCheckbox(layout, &persistent_bubble_); 169 AddCheckbox(layout, &persistent_bubble_);
170 persistent_bubble_->SetText(base::ASCIIToUTF16("Persistent")); 170 persistent_bubble_->SetText(base::ASCIIToUTF16("Persistent"));
171 171
172 column_set = layout->AddColumnSet(kButtonsColumnId); 172 column_set = layout->AddColumnSet(kButtonsColumnId);
173 column_set->AddColumn(GridLayout::CENTER, GridLayout::CENTER, kStretchy, 173 column_set->AddColumn(GridLayout::CENTER, GridLayout::CENTER, kStretchy,
174 GridLayout::USE_PREF, 0, 0); 174 GridLayout::USE_PREF, 0, 0);
175 layout->StartRowWithPadding(kFixed, kButtonsColumnId, kFixed, 175 layout->StartRowWithPadding(
176 kUnrelatedControlVerticalSpacing); 176 kFixed, kButtonsColumnId, kFixed,
177 provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL));
177 show_ = 178 show_ =
178 MdTextButton::CreateSecondaryUiButton(this, base::ASCIIToUTF16("Show")); 179 MdTextButton::CreateSecondaryUiButton(this, base::ASCIIToUTF16("Show"));
179 layout->AddView(show_); 180 layout->AddView(show_);
180 181
181 // Grow the dialog a bit when this example is first selected, so it all fits. 182 // Grow the dialog a bit when this example is first selected, so it all fits.
182 gfx::Size dialog_size = container->GetWidget()->GetRestoredBounds().size(); 183 gfx::Size dialog_size = container->GetWidget()->GetRestoredBounds().size();
183 dialog_size.set_height(dialog_size.height() + 80); 184 dialog_size.set_height(dialog_size.height() + 80);
184 container->GetWidget()->SetSize(dialog_size); 185 container->GetWidget()->SetSize(dialog_size);
185 } 186 }
186 187
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 #endif 327 #endif
327 show_->SetEnabled(enable); 328 show_->SetEnabled(enable);
328 if (!enable && GetModalType() == ui::MODAL_TYPE_CHILD) 329 if (!enable && GetModalType() == ui::MODAL_TYPE_CHILD)
329 PrintStatus("MODAL_TYPE_CHILD can't be used with non-bubbles."); 330 PrintStatus("MODAL_TYPE_CHILD can't be used with non-bubbles.");
330 if (!enable && GetModalType() == ui::MODAL_TYPE_SYSTEM) 331 if (!enable && GetModalType() == ui::MODAL_TYPE_SYSTEM)
331 PrintStatus("MODAL_TYPE_SYSTEM isn't supported on Mac."); 332 PrintStatus("MODAL_TYPE_SYSTEM isn't supported on Mac.");
332 } 333 }
333 334
334 } // namespace examples 335 } // namespace examples
335 } // namespace views 336 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/uninstall_view.cc ('k') | ui/views/layout/layout_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698