| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 : kRelatedButtonHSpacing; | 61 : kRelatedButtonHSpacing; |
| 62 row_bounds->set_width(row_bounds->width() - spacing); | 62 row_bounds->set_width(row_bounds->width() - spacing); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 /////////////////////////////////////////////////////////////////////////////// | 67 /////////////////////////////////////////////////////////////////////////////// |
| 68 // DialogClientView, public: | 68 // DialogClientView, public: |
| 69 | 69 |
| 70 DialogClientView::DialogClientView(Widget* owner, View* contents_view) | 70 DialogClientView::DialogClientView(Widget* owner, View* contents_view) |
| 71 : ClientView(owner, contents_view), | 71 : ClientView(owner, contents_view) { |
| 72 ok_button_(nullptr), | |
| 73 cancel_button_(nullptr), | |
| 74 extra_view_(nullptr), | |
| 75 delegate_allowed_close_(false) { | |
| 76 button_row_insets_ = | 72 button_row_insets_ = |
| 77 ViewsDelegate::GetInstance() | 73 ViewsDelegate::GetInstance() |
| 78 ? ViewsDelegate::GetInstance()->GetDialogButtonInsets() | 74 ? ViewsDelegate::GetInstance()->GetDialogButtonInsets() |
| 79 : gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew, | 75 : gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew, |
| 80 kButtonHEdgeMarginNew); | 76 kButtonHEdgeMarginNew); |
| 81 // Doing this now ensures this accelerator will have lower priority than | 77 // Doing this now ensures this accelerator will have lower priority than |
| 82 // one set by the contents view. | 78 // one set by the contents view. |
| 83 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | 79 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
| 84 | 80 |
| 85 if (ViewsDelegate::GetInstance()) | 81 if (ViewsDelegate::GetInstance()) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 const gfx::Insets insets = GetButtonRowInsets(); | 181 const gfx::Insets insets = GetButtonRowInsets(); |
| 186 size.Enlarge(insets.width(), insets.height()); | 182 size.Enlarge(insets.width(), insets.height()); |
| 187 } | 183 } |
| 188 | 184 |
| 189 // Increase the size as needed to fit the contents view. | 185 // Increase the size as needed to fit the contents view. |
| 190 // NOTE: The contents view is not inset on the top or side client view edges. | 186 // NOTE: The contents view is not inset on the top or side client view edges. |
| 191 gfx::Size contents_size = contents_view()->GetPreferredSize(); | 187 gfx::Size contents_size = contents_view()->GetPreferredSize(); |
| 192 size.Enlarge(0, contents_size.height()); | 188 size.Enlarge(0, contents_size.height()); |
| 193 size.set_width(std::max(size.width(), contents_size.width())); | 189 size.set_width(std::max(size.width(), contents_size.width())); |
| 194 | 190 |
| 191 size.SetToMax(minimum_size_); |
| 192 |
| 195 return size; | 193 return size; |
| 196 } | 194 } |
| 197 | 195 |
| 198 void DialogClientView::Layout() { | 196 void DialogClientView::Layout() { |
| 199 gfx::Rect bounds = GetContentsBounds(); | 197 gfx::Rect bounds = GetContentsBounds(); |
| 200 | 198 |
| 201 // Layout the row containing the buttons and the extra view. | 199 // Layout the row containing the buttons and the extra view. |
| 202 if (has_dialog_buttons() || ShouldShow(extra_view_)) { | 200 if (has_dialog_buttons() || ShouldShow(extra_view_)) { |
| 203 bounds.Inset(GetButtonRowInsets()); | 201 bounds.Inset(GetButtonRowInsets()); |
| 204 const int height = GetButtonsAndExtraViewRowHeight(); | 202 const int height = GetButtonsAndExtraViewRowHeight(); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 std::remove(child_views.begin(), child_views.end(), nullptr), | 402 std::remove(child_views.begin(), child_views.end(), nullptr), |
| 405 child_views.end()); | 403 child_views.end()); |
| 406 | 404 |
| 407 // Setup focus by reordering views. It is not safe to use SetNextFocusableView | 405 // Setup focus by reordering views. It is not safe to use SetNextFocusableView |
| 408 // since child views may be added externally to this view. | 406 // since child views may be added externally to this view. |
| 409 for (size_t i = 0; i < child_views.size(); i++) | 407 for (size_t i = 0; i < child_views.size(); i++) |
| 410 ReorderChildView(child_views[i], i); | 408 ReorderChildView(child_views[i], i); |
| 411 } | 409 } |
| 412 | 410 |
| 413 } // namespace views | 411 } // namespace views |
| OLD | NEW |