Chromium Code Reviews| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 const gfx::Insets insets = GetButtonRowInsets(); | 167 const gfx::Insets insets = GetButtonRowInsets(); |
| 168 size.Enlarge(insets.width(), insets.height()); | 168 size.Enlarge(insets.width(), insets.height()); |
| 169 } | 169 } |
| 170 | 170 |
| 171 // Increase the size as needed to fit the contents view. | 171 // Increase the size as needed to fit the contents view. |
| 172 // NOTE: The contents view is not inset on the top or side client view edges. | 172 // NOTE: The contents view is not inset on the top or side client view edges. |
| 173 gfx::Size contents_size = contents_view()->GetPreferredSize(); | 173 gfx::Size contents_size = contents_view()->GetPreferredSize(); |
| 174 size.Enlarge(0, contents_size.height()); | 174 size.Enlarge(0, contents_size.height()); |
| 175 size.set_width(std::max(size.width(), contents_size.width())); | 175 size.set_width(std::max(size.width(), contents_size.width())); |
| 176 | 176 |
| 177 // An explicit width factor overrides automatic sizing. | |
| 178 int width_factor = GetDialogDelegate()->GetWidthFactor(); | |
| 179 if (width_factor != 0) | |
| 180 size = gfx::Size(width_factor * 32, size.height()); | |
|
Evan Stade
2016/10/05 19:52:28
you still need to use GetHeightForWidth
gfx::Size
| |
| 181 | |
| 177 return size; | 182 return size; |
| 178 } | 183 } |
| 179 | 184 |
| 180 void DialogClientView::Layout() { | 185 void DialogClientView::Layout() { |
| 181 gfx::Rect bounds = GetContentsBounds(); | 186 gfx::Rect bounds = GetContentsBounds(); |
| 182 | 187 |
| 183 // Layout the row containing the buttons and the extra view. | 188 // Layout the row containing the buttons and the extra view. |
| 184 if (has_dialog_buttons() || ShouldShow(extra_view_)) { | 189 if (has_dialog_buttons() || ShouldShow(extra_view_)) { |
| 185 bounds.Inset(GetButtonRowInsets()); | 190 bounds.Inset(GetButtonRowInsets()); |
| 186 const int height = GetButtonsAndExtraViewRowHeight(); | 191 const int height = GetButtonsAndExtraViewRowHeight(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 std::remove(child_views.begin(), child_views.end(), nullptr), | 371 std::remove(child_views.begin(), child_views.end(), nullptr), |
| 367 child_views.end()); | 372 child_views.end()); |
| 368 | 373 |
| 369 // Setup focus by reordering views. It is not safe to use SetNextFocusableView | 374 // Setup focus by reordering views. It is not safe to use SetNextFocusableView |
| 370 // since child views may be added externally to this view. | 375 // since child views may be added externally to this view. |
| 371 for (size_t i = 0; i < child_views.size(); i++) | 376 for (size_t i = 0; i < child_views.size(); i++) |
| 372 ReorderChildView(child_views[i], i); | 377 ReorderChildView(child_views[i], i); |
| 373 } | 378 } |
| 374 | 379 |
| 375 } // namespace views | 380 } // namespace views |
| OLD | NEW |