| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 void DialogExample::ResizeDialog() { | 239 void DialogExample::ResizeDialog() { |
| 240 DCHECK(last_dialog_); | 240 DCHECK(last_dialog_); |
| 241 Widget* widget = last_dialog_->GetWidget(); | 241 Widget* widget = last_dialog_->GetWidget(); |
| 242 gfx::Rect preferred_bounds(widget->GetRestoredBounds()); | 242 gfx::Rect preferred_bounds(widget->GetRestoredBounds()); |
| 243 preferred_bounds.set_size(widget->non_client_view()->GetPreferredSize()); | 243 preferred_bounds.set_size(widget->non_client_view()->GetPreferredSize()); |
| 244 | 244 |
| 245 // Q: Do we need NonClientFrameView::GetWindowBoundsForClientBounds() here? | 245 // Q: Do we need NonClientFrameView::GetWindowBoundsForClientBounds() here? |
| 246 // A: When DialogCientView properly feeds back sizes, we do not. | 246 // A: When DialogCientView properly feeds back sizes, we do not. |
| 247 widget->SetBoundsConstrained(preferred_bounds); | 247 widget->SetBoundsConstrained(preferred_bounds); |
| 248 |
| 249 // For user-resizable dialogs, ensure the window manager enforces any new |
| 250 // minimum size. |
| 251 widget->OnSizeConstraintsChanged(); |
| 248 } | 252 } |
| 249 | 253 |
| 250 void DialogExample::ButtonPressed(Button* sender, const ui::Event& event) { | 254 void DialogExample::ButtonPressed(Button* sender, const ui::Event& event) { |
| 251 if (sender == show_) { | 255 if (sender == show_) { |
| 252 if (bubble_->checked()) { | 256 if (bubble_->checked()) { |
| 253 Bubble* bubble = new Bubble(this, sender); | 257 Bubble* bubble = new Bubble(this, sender); |
| 254 last_dialog_ = bubble; | 258 last_dialog_ = bubble; |
| 255 BubbleDialogDelegateView::CreateBubble(bubble); | 259 BubbleDialogDelegateView::CreateBubble(bubble); |
| 256 } else { | 260 } else { |
| 257 Dialog* dialog = new Dialog(this); | 261 Dialog* dialog = new Dialog(this); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 #endif | 324 #endif |
| 321 show_->SetEnabled(enable); | 325 show_->SetEnabled(enable); |
| 322 if (!enable && GetModalType() == ui::MODAL_TYPE_CHILD) | 326 if (!enable && GetModalType() == ui::MODAL_TYPE_CHILD) |
| 323 PrintStatus("MODAL_TYPE_CHILD can't be used with non-bubbles."); | 327 PrintStatus("MODAL_TYPE_CHILD can't be used with non-bubbles."); |
| 324 if (!enable && GetModalType() == ui::MODAL_TYPE_SYSTEM) | 328 if (!enable && GetModalType() == ui::MODAL_TYPE_SYSTEM) |
| 325 PrintStatus("MODAL_TYPE_SYSTEM isn't supported on Mac."); | 329 PrintStatus("MODAL_TYPE_SYSTEM isn't supported on Mac."); |
| 326 } | 330 } |
| 327 | 331 |
| 328 } // namespace examples | 332 } // namespace examples |
| 329 } // namespace views | 333 } // namespace views |
| OLD | NEW |