OLD | NEW |
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 Loading... |
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 const int horizontal_spacing = | 134 const int horizontal_spacing = ViewsDelegate::GetInstance()->GetSpacingMetric( |
135 ViewsDelegate::GetInstance()->GetDialogRelatedButtonHorizontalSpacing(); | 135 views::SpacingMetric::RELATED_HORIZONTAL_BUTTON); |
136 GridLayout* layout = GridLayout::CreatePanel(container); | 136 GridLayout* layout = GridLayout::CreatePanel(container); |
137 container->SetLayoutManager(layout); | 137 container->SetLayoutManager(layout); |
138 ColumnSet* column_set = layout->AddColumnSet(kFieldsColumnId); | 138 ColumnSet* column_set = layout->AddColumnSet(kFieldsColumnId); |
139 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, kFixed, | 139 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, kFixed, |
140 GridLayout::USE_PREF, 0, 0); | 140 GridLayout::USE_PREF, 0, 0); |
141 column_set->AddPaddingColumn(kFixed, horizontal_spacing); | 141 column_set->AddPaddingColumn(kFixed, horizontal_spacing); |
142 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kStretchy, | 142 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kStretchy, |
143 GridLayout::USE_PREF, 0, 0); | 143 GridLayout::USE_PREF, 0, 0); |
144 column_set->AddPaddingColumn(kFixed, horizontal_spacing); | 144 column_set->AddPaddingColumn(kFixed, horizontal_spacing); |
145 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kFixed, | 145 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kFixed, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Grow the dialog a bit when this example is first selected, so it all fits. | 180 // Grow the dialog a bit when this example is first selected, so it all fits. |
181 gfx::Size dialog_size = container->GetWidget()->GetRestoredBounds().size(); | 181 gfx::Size dialog_size = container->GetWidget()->GetRestoredBounds().size(); |
182 dialog_size.set_height(dialog_size.height() + 80); | 182 dialog_size.set_height(dialog_size.height() + 80); |
183 container->GetWidget()->SetSize(dialog_size); | 183 container->GetWidget()->SetSize(dialog_size); |
184 } | 184 } |
185 | 185 |
186 void DialogExample::StartRowWithLabel(GridLayout* layout, const char* label) { | 186 void DialogExample::StartRowWithLabel(GridLayout* layout, const char* label) { |
187 const float kFixedVerticalResize = 0.f; | 187 const float kFixedVerticalResize = 0.f; |
188 layout->StartRowWithPadding( | 188 layout->StartRowWithPadding( |
189 kFixedVerticalResize, kFieldsColumnId, kFixedVerticalResize, | 189 kFixedVerticalResize, kFieldsColumnId, kFixedVerticalResize, |
190 ViewsDelegate::GetInstance()->GetDialogRelatedControlVerticalSpacing()); | 190 ViewsDelegate::GetInstance()->GetSpacingMetric( |
| 191 views::SpacingMetric::RELATED_VERTICAL_CONTROL)); |
191 layout->AddView(new Label(base::ASCIIToUTF16(label))); | 192 layout->AddView(new Label(base::ASCIIToUTF16(label))); |
192 } | 193 } |
193 | 194 |
194 void DialogExample::StartTextfieldRow(GridLayout* layout, | 195 void DialogExample::StartTextfieldRow(GridLayout* layout, |
195 Textfield** member, | 196 Textfield** member, |
196 const char* label, | 197 const char* label, |
197 const char* value) { | 198 const char* value) { |
198 StartRowWithLabel(layout, label); | 199 StartRowWithLabel(layout, label); |
199 Textfield* textfield = new Textfield(); | 200 Textfield* textfield = new Textfield(); |
200 layout->AddView(textfield); | 201 layout->AddView(textfield); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 #endif | 321 #endif |
321 show_->SetEnabled(enable); | 322 show_->SetEnabled(enable); |
322 if (!enable && GetModalType() == ui::MODAL_TYPE_CHILD) | 323 if (!enable && GetModalType() == ui::MODAL_TYPE_CHILD) |
323 PrintStatus("MODAL_TYPE_CHILD can't be used with non-bubbles."); | 324 PrintStatus("MODAL_TYPE_CHILD can't be used with non-bubbles."); |
324 if (!enable && GetModalType() == ui::MODAL_TYPE_SYSTEM) | 325 if (!enable && GetModalType() == ui::MODAL_TYPE_SYSTEM) |
325 PrintStatus("MODAL_TYPE_SYSTEM isn't supported on Mac."); | 326 PrintStatus("MODAL_TYPE_SYSTEM isn't supported on Mac."); |
326 } | 327 } |
327 | 328 |
328 } // namespace examples | 329 } // namespace examples |
329 } // namespace views | 330 } // namespace views |
OLD | NEW |