| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/window/dialog_client_view.h" | 5 #include "ui/views/window/dialog_client_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/base/material_design/material_design_controller.h" | 10 #include "ui/base/material_design/material_design_controller.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(ButtonRowContainer); | 71 DISALLOW_COPY_AND_ASSIGN(ButtonRowContainer); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 /////////////////////////////////////////////////////////////////////////////// | 74 /////////////////////////////////////////////////////////////////////////////// |
| 75 // DialogClientView, public: | 75 // DialogClientView, public: |
| 76 | 76 |
| 77 DialogClientView::DialogClientView(Widget* owner, View* contents_view) | 77 DialogClientView::DialogClientView(Widget* owner, View* contents_view) |
| 78 : ClientView(owner, contents_view), | 78 : ClientView(owner, contents_view), |
| 79 button_row_insets_( | 79 button_row_insets_( |
| 80 LayoutProvider::Get()->GetInsetsMetric(INSETS_DIALOG_BUTTON)) { | 80 LayoutProvider::Get()->GetInsetsMetric(INSETS_DIALOG_BUTTON_ROW)) { |
| 81 // Doing this now ensures this accelerator will have lower priority than | 81 // Doing this now ensures this accelerator will have lower priority than |
| 82 // one set by the contents view. | 82 // one set by the contents view. |
| 83 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | 83 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
| 84 button_row_container_ = new ButtonRowContainer(this); | 84 button_row_container_ = new ButtonRowContainer(this); |
| 85 AddChildView(button_row_container_); | 85 AddChildView(button_row_container_); |
| 86 } | 86 } |
| 87 | 87 |
| 88 DialogClientView::~DialogClientView() {} | 88 DialogClientView::~DialogClientView() {} |
| 89 | 89 |
| 90 void DialogClientView::AcceptWindow() { | 90 void DialogClientView::AcceptWindow() { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 if (extra_view_ && !views[0]) | 340 if (extra_view_ && !views[0]) |
| 341 AddChildView(extra_view_); | 341 AddChildView(extra_view_); |
| 342 | 342 |
| 343 if (std::count(views.begin(), views.end(), nullptr) == kNumButtons) | 343 if (std::count(views.begin(), views.end(), nullptr) == kNumButtons) |
| 344 return; | 344 return; |
| 345 | 345 |
| 346 gfx::Insets insets = button_row_insets_; | 346 gfx::Insets insets = button_row_insets_; |
| 347 LayoutProvider* const layout_provider = LayoutProvider::Get(); | 347 LayoutProvider* const layout_provider = LayoutProvider::Get(); |
| 348 // Support dialogs that clear |button_row_insets_| to do their own layout. | 348 // Support dialogs that clear |button_row_insets_| to do their own layout. |
| 349 // They expect GetDialogRelatedControlVerticalSpacing() in this case. | 349 // They expect GetDialogRelatedControlVerticalSpacing() in this case. |
| 350 // TODO(tapted): Remove this under Harmony. | 350 if (insets.top() == 0 && |
| 351 if (insets.top() == 0) { | 351 !ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 352 const int top = | 352 const int top = |
| 353 layout_provider->GetDistanceMetric(DISTANCE_RELATED_CONTROL_VERTICAL); | 353 layout_provider->GetDistanceMetric(DISTANCE_RELATED_CONTROL_VERTICAL); |
| 354 insets.Set(top, insets.left(), insets.bottom(), insets.right()); | 354 insets.Set(top, insets.left(), insets.bottom(), insets.right()); |
| 355 } | 355 } |
| 356 | 356 |
| 357 // The |resize_percent| constants. There's only one stretchy column (padding | 357 // The |resize_percent| constants. There's only one stretchy column (padding |
| 358 // to the left of ok/cancel buttons). | 358 // to the left of ok/cancel buttons). |
| 359 constexpr float kFixed = 0.f; | 359 constexpr float kFixed = 0.f; |
| 360 constexpr float kStretchy = 1.f; | 360 constexpr float kStretchy = 1.f; |
| 361 | 361 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 427 |
| 428 if (extra_view_) | 428 if (extra_view_) |
| 429 return; | 429 return; |
| 430 | 430 |
| 431 extra_view_ = GetDialogDelegate()->CreateExtraView(); | 431 extra_view_ = GetDialogDelegate()->CreateExtraView(); |
| 432 if (extra_view_) | 432 if (extra_view_) |
| 433 extra_view_->SetGroup(kButtonGroup); | 433 extra_view_->SetGroup(kButtonGroup); |
| 434 } | 434 } |
| 435 | 435 |
| 436 } // namespace views | 436 } // namespace views |
| OLD | NEW |