| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 if (cancel_button_ || ok_button_) | 364 if (cancel_button_ || ok_button_) |
| 365 width += style_params_.related_button_hspacing; | 365 width += style_params_.related_button_hspacing; |
| 366 } | 366 } |
| 367 if (width > 0) { | 367 if (width > 0) { |
| 368 width += 2 * style_params_.button_hedge_margin; | 368 width += 2 * style_params_.button_hedge_margin; |
| 369 prefsize.set_width(std::max(prefsize.width(), width)); | 369 prefsize.set_width(std::max(prefsize.width(), width)); |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 prefsize.Enlarge(0, button_height); | 372 prefsize.Enlarge(0, button_height); |
| 373 | 373 |
| 374 if (footnote_view_) { | 374 if (footnote_view_ && footnote_view_->visible()) { |
| 375 gfx::Size footnote_size = footnote_view_->GetPreferredSize(); | 375 const gfx::Size& footnote_size = footnote_view_->GetPreferredSize(); |
| 376 prefsize.Enlarge(0, footnote_size.height()); | 376 prefsize.Enlarge(0, footnote_size.height()); |
| 377 prefsize.set_width(std::max(prefsize.width(), footnote_size.width())); | 377 prefsize.set_width(std::max(prefsize.width(), footnote_size.width())); |
| 378 } | 378 } |
| 379 | 379 |
| 380 return prefsize; | 380 return prefsize; |
| 381 } | 381 } |
| 382 | 382 |
| 383 bool DialogClientView::AcceleratorPressed(const ui::Accelerator& accelerator) { | 383 bool DialogClientView::AcceleratorPressed(const ui::Accelerator& accelerator) { |
| 384 // We only expect Escape key. | 384 // We only expect Escape key. |
| 385 DCHECK(accelerator.key_code() == ui::VKEY_ESCAPE); | 385 DCHECK(accelerator.key_code() == ui::VKEY_ESCAPE); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 return button_height; | 487 return button_height; |
| 488 } | 488 } |
| 489 | 489 |
| 490 int DialogClientView::GetDialogButtonsAreaHeight() const { | 490 int DialogClientView::GetDialogButtonsAreaHeight() const { |
| 491 return !has_dialog_buttons() ? 0 : | 491 return !has_dialog_buttons() ? 0 : |
| 492 GetButtonsHeight() + style_params_.button_content_spacing + | 492 GetButtonsHeight() + style_params_.button_content_spacing + |
| 493 style_params_.button_vedge_margin; | 493 style_params_.button_vedge_margin; |
| 494 } | 494 } |
| 495 | 495 |
| 496 int DialogClientView::GetFootnoteViewHeight() const { | 496 int DialogClientView::GetFootnoteViewHeight() const { |
| 497 return footnote_view_ ? footnote_view_->GetPreferredSize().height() : 0; | 497 return footnote_view_ && footnote_view_->visible() ? |
| 498 footnote_view_->GetPreferredSize().height() : 0; |
| 498 } | 499 } |
| 499 | 500 |
| 500 void DialogClientView::LayoutDialogButtons() { | 501 void DialogClientView::LayoutDialogButtons() { |
| 501 gfx::Rect lb = GetContentsBounds(); | 502 gfx::Rect lb = GetContentsBounds(); |
| 502 gfx::Rect extra_bounds; | 503 gfx::Rect extra_bounds; |
| 503 int bottom_y = lb.bottom() - style_params_.button_vedge_margin; | 504 int bottom_y = lb.bottom() - style_params_.button_vedge_margin - |
| 504 if (footnote_view_) | 505 GetFootnoteViewHeight(); |
| 505 bottom_y -= footnote_view_->GetPreferredSize().height(); | |
| 506 | 506 |
| 507 int button_height = GetButtonsHeight(); | 507 int button_height = GetButtonsHeight(); |
| 508 if (cancel_button_) { | 508 if (cancel_button_) { |
| 509 gfx::Size ps = cancel_button_->GetPreferredSize(); | 509 gfx::Size ps = cancel_button_->GetPreferredSize(); |
| 510 int button_x = lb.right() - ps.width() - style_params_.button_hedge_margin; | 510 int button_x = lb.right() - ps.width() - style_params_.button_hedge_margin; |
| 511 int button_y = bottom_y - ps.height(); | 511 int button_y = bottom_y - ps.height(); |
| 512 cancel_button_->SetBounds(button_x, button_y, ps.width(), ps.height()); | 512 cancel_button_->SetBounds(button_x, button_y, ps.width(), ps.height()); |
| 513 // The extra view bounds are dependent on this button. | 513 // The extra view bounds are dependent on this button. |
| 514 extra_bounds.set_width(std::max(0, cancel_button_->x())); | 514 extra_bounds.set_width(std::max(0, cancel_button_->x())); |
| 515 extra_bounds.set_y(cancel_button_->y()); | 515 extra_bounds.set_y(cancel_button_->y()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 } | 600 } |
| 601 saved_focus_manager_ = focus_manager; | 601 saved_focus_manager_ = focus_manager; |
| 602 // Listen for focus change events so we can update the default button. | 602 // Listen for focus change events so we can update the default button. |
| 603 if (focus_manager) { | 603 if (focus_manager) { |
| 604 focus_manager->AddFocusChangeListener(this); | 604 focus_manager->AddFocusChangeListener(this); |
| 605 listening_to_focus_ = true; | 605 listening_to_focus_ = true; |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 | 608 |
| 609 } // namespace views | 609 } // namespace views |
| OLD | NEW |