| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 if (!button) | 45 if (!button) |
| 46 return; | 46 return; |
| 47 | 47 |
| 48 const gfx::Size size = button->GetPreferredSize(); | 48 const gfx::Size size = button->GetPreferredSize(); |
| 49 row_bounds->set_width(row_bounds->width() - size.width()); | 49 row_bounds->set_width(row_bounds->width() - size.width()); |
| 50 DCHECK_LE(button_height, row_bounds->height()); | 50 DCHECK_LE(button_height, row_bounds->height()); |
| 51 button->SetBounds( | 51 button->SetBounds( |
| 52 row_bounds->right(), | 52 row_bounds->right(), |
| 53 row_bounds->y() + (row_bounds->height() - button_height) / 2, | 53 row_bounds->y() + (row_bounds->height() - button_height) / 2, |
| 54 size.width(), button_height); | 54 size.width(), button_height); |
| 55 row_bounds->set_width(row_bounds->width() - kRelatedButtonHSpacing); | 55 row_bounds->set_width(row_bounds->width() - |
| 56 button->GetLayoutDelegate()->GetLayoutDistance( |
| 57 LayoutDelegate::RELATED_BUTTON_HORIZONTAL_SPACING)); |
| 56 } | 58 } |
| 57 | 59 |
| 58 } // namespace | 60 } // namespace |
| 59 | 61 |
| 60 /////////////////////////////////////////////////////////////////////////////// | 62 /////////////////////////////////////////////////////////////////////////////// |
| 61 // DialogClientView, public: | 63 // DialogClientView, public: |
| 62 | 64 |
| 63 DialogClientView::DialogClientView(Widget* owner, View* contents_view) | 65 DialogClientView::DialogClientView(Widget* owner, View* contents_view) |
| 64 : ClientView(owner, contents_view), | 66 : ClientView(owner, contents_view), |
| 65 button_row_insets_(0, | 67 button_row_insets_(0, |
| 66 kButtonHEdgeMarginNew, | 68 contents_view->GetLayoutDelegate()->GetLayoutDistance( |
| 67 kButtonVEdgeMarginNew, | 69 LayoutDelegate::BUTTON_HEDGE_MARGIN_NEW), |
| 68 kButtonHEdgeMarginNew), | 70 contents_view->GetLayoutDelegate()->GetLayoutDistance( |
| 71 LayoutDelegate::BUTTON_VEDGE_MARGIN_NEW), |
| 72 contents_view->GetLayoutDelegate()->GetLayoutDistance( |
| 73 LayoutDelegate::BUTTON_HEDGE_MARGIN_NEW)), |
| 69 ok_button_(nullptr), | 74 ok_button_(nullptr), |
| 70 cancel_button_(nullptr), | 75 cancel_button_(nullptr), |
| 71 extra_view_(nullptr), | 76 extra_view_(nullptr), |
| 72 delegate_allowed_close_(false) { | 77 delegate_allowed_close_(false) { |
| 78 SetLayoutDelegate(contents_view->GetLayoutDelegate()); |
| 73 // Doing this now ensures this accelerator will have lower priority than | 79 // Doing this now ensures this accelerator will have lower priority than |
| 74 // one set by the contents view. | 80 // one set by the contents view. |
| 75 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | 81 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
| 76 } | 82 } |
| 77 | 83 |
| 78 DialogClientView::~DialogClientView() { | 84 DialogClientView::~DialogClientView() { |
| 79 } | 85 } |
| 80 | 86 |
| 81 void DialogClientView::AcceptWindow() { | 87 void DialogClientView::AcceptWindow() { |
| 82 // Only notify the delegate once. See |delegate_allowed_close_|'s comment. | 88 // Only notify the delegate once. See |delegate_allowed_close_|'s comment. |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 std::remove(child_views.begin(), child_views.end(), nullptr), | 372 std::remove(child_views.begin(), child_views.end(), nullptr), |
| 367 child_views.end()); | 373 child_views.end()); |
| 368 | 374 |
| 369 // Setup focus by reordering views. It is not safe to use SetNextFocusableView | 375 // Setup focus by reordering views. It is not safe to use SetNextFocusableView |
| 370 // since child views may be added externally to this view. | 376 // since child views may be added externally to this view. |
| 371 for (size_t i = 0; i < child_views.size(); i++) | 377 for (size_t i = 0; i < child_views.size(); i++) |
| 372 ReorderChildView(child_views[i], i); | 378 ReorderChildView(child_views[i], i); |
| 373 } | 379 } |
| 374 | 380 |
| 375 } // namespace views | 381 } // namespace views |
| OLD | NEW |