Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Unified Diff: ui/views/window/dialog_client_view.cc

Issue 1717453003: Introduce BubbleDialogDelegateView, which extends DialogDelegateView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: relative ps Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/window/dialog_client_view.cc
diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc
index 5f069efeb02c523fd6f00b722cdef1ab5d8dce24..0e56fd7f18ec5b263660eead6618772d22659344 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -54,10 +54,13 @@ void LayoutButton(LabelButton* button, gfx::Rect* row_bounds) {
DialogClientView::DialogClientView(Widget* owner, View* contents_view)
: ClientView(owner, contents_view),
+ button_row_insets_(0,
+ kButtonHEdgeMarginNew,
+ kButtonVEdgeMarginNew,
+ kButtonHEdgeMarginNew),
ok_button_(NULL),
cancel_button_(NULL),
extra_view_(NULL),
- footnote_view_(NULL),
delegate_allowed_close_(false) {}
DialogClientView::~DialogClientView() {
@@ -81,13 +84,10 @@ void DialogClientView::CancelWindow() {
void DialogClientView::UpdateDialogButtons() {
const int buttons = GetDialogDelegate()->GetDialogButtons();
- ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE);
if (buttons & ui::DIALOG_BUTTON_OK) {
if (!ok_button_) {
ok_button_ = CreateDialogButton(ui::DIALOG_BUTTON_OK);
- if (!(buttons & ui::DIALOG_BUTTON_CANCEL))
- ok_button_->AddAccelerator(escape);
AddChildView(ok_button_);
}
@@ -100,7 +100,6 @@ void DialogClientView::UpdateDialogButtons() {
if (buttons & ui::DIALOG_BUTTON_CANCEL) {
if (!cancel_button_) {
cancel_button_ = CreateDialogButton(ui::DIALOG_BUTTON_CANCEL);
- cancel_button_->AddAccelerator(escape);
AddChildView(cancel_button_);
}
@@ -109,12 +108,6 @@ void DialogClientView::UpdateDialogButtons() {
delete cancel_button_;
cancel_button_ = NULL;
}
-
- // Use the escape key to close the window if there are no dialog buttons.
- if (!has_dialog_buttons())
- AddAccelerator(escape);
- else
- ResetAccelerators();
}
///////////////////////////////////////////////////////////////////////////////
@@ -167,31 +160,12 @@ gfx::Size DialogClientView::GetPreferredSize() const {
size.Enlarge(0, contents_size.height());
size.set_width(std::max(size.width(), contents_size.width()));
- // Increase the size as needed to fit the footnote view.
- if (ShouldShow(footnote_view_)) {
- gfx::Size footnote_size = footnote_view_->GetPreferredSize();
- if (!footnote_size.IsEmpty())
- size.set_width(std::max(size.width(), footnote_size.width()));
-
- int footnote_height = footnote_view_->GetHeightForWidth(size.width());
- size.Enlarge(0, footnote_height);
- }
-
return size;
}
void DialogClientView::Layout() {
gfx::Rect bounds = GetContentsBounds();
- // Layout the footnote view.
- if (ShouldShow(footnote_view_)) {
- const int height = footnote_view_->GetHeightForWidth(bounds.width());
- footnote_view_->SetBounds(bounds.x(), bounds.bottom() - height,
- bounds.width(), height);
- if (height != 0)
- bounds.Inset(0, 0, 0, height);
- }
-
// Layout the row containing the buttons and the extra view.
if (has_dialog_buttons() || ShouldShow(extra_view_)) {
bounds.Inset(GetButtonRowInsets());
@@ -242,7 +216,8 @@ void DialogClientView::ViewHierarchyChanged(
if (details.is_add && details.child == this) {
UpdateDialogButtons();
CreateExtraView();
- CreateFootnoteView();
+ // Use the escape key to close the window.
+ AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
} else if (!details.is_add && details.child != this) {
if (details.child == ok_button_)
ok_button_ = nullptr;
@@ -250,8 +225,6 @@ void DialogClientView::ViewHierarchyChanged(
cancel_button_ = nullptr;
else if (details.child == extra_view_)
extra_view_ = nullptr;
- else if (details.child == footnote_view_)
- footnote_view_ = nullptr;
}
SetupFocusChain();
@@ -292,7 +265,6 @@ DialogClientView::DialogClientView(View* contents_view)
ok_button_(NULL),
cancel_button_(NULL),
extra_view_(NULL),
- footnote_view_(NULL),
delegate_allowed_close_(false) {}
DialogDelegate* DialogClientView::GetDialogDelegate() const {
@@ -310,17 +282,8 @@ void DialogClientView::CreateExtraView() {
}
}
-void DialogClientView::CreateFootnoteView() {
- if (footnote_view_)
- return;
-
- footnote_view_ = GetDialogDelegate()->CreateFootnoteView();
- if (footnote_view_)
- AddChildView(footnote_view_);
-}
-
void DialogClientView::ChildPreferredSizeChanged(View* child) {
- if (child == footnote_view_ || child == extra_view_)
+ if (child == extra_view_)
Layout();
}
@@ -368,14 +331,10 @@ int DialogClientView::GetButtonsAndExtraViewRowHeight() const {
}
gfx::Insets DialogClientView::GetButtonRowInsets() const {
- // NOTE: The insets only apply to the buttons, extra view, and footnote view.
- return GetButtonsAndExtraViewRowHeight() == 0 ? gfx::Insets() :
- gfx::Insets(0, kButtonHEdgeMarginNew,
- kButtonVEdgeMarginNew, kButtonHEdgeMarginNew);
+ return GetButtonsAndExtraViewRowHeight() == 0 ? gfx::Insets()
+ : button_row_insets_;
}
-
-
void DialogClientView::SetupFocusChain() {
// Create a vector of child views in the order of intended focus.
std::vector<View*> child_views;
@@ -388,7 +347,6 @@ void DialogClientView::SetupFocusChain() {
child_views.push_back(cancel_button_);
child_views.push_back(ok_button_);
}
- child_views.push_back(footnote_view_);
// Remove all null views from the vector.
child_views.erase(

Powered by Google App Engine
This is Rietveld 408576698