| 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 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |