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 "ui/events/keycodes/keyboard_codes.h" | 9 #include "ui/events/keycodes/keyboard_codes.h" |
10 #include "ui/views/controls/button/blue_button.h" | 10 #include "ui/views/controls/button/blue_button.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return true; | 249 return true; |
250 } | 250 } |
251 | 251 |
252 void DialogClientView::ViewHierarchyChanged( | 252 void DialogClientView::ViewHierarchyChanged( |
253 const ViewHierarchyChangedDetails& details) { | 253 const ViewHierarchyChangedDetails& details) { |
254 ClientView::ViewHierarchyChanged(details); | 254 ClientView::ViewHierarchyChanged(details); |
255 if (details.is_add && details.child == this) { | 255 if (details.is_add && details.child == this) { |
256 // The old dialog style needs an explicit background color, while the new | 256 // The old dialog style needs an explicit background color, while the new |
257 // dialog style simply inherits the bubble's frame view color. | 257 // dialog style simply inherits the bubble's frame view color. |
258 const DialogDelegate* dialog = GetDialogDelegate(); | 258 const DialogDelegate* dialog = GetDialogDelegate(); |
259 const bool use_new_style = dialog ? | 259 if (dialog && !dialog->UseNewStyleForThisDialog()) |
260 dialog->UseNewStyleForThisDialog() : DialogDelegate::UseNewStyle(); | |
261 if (!use_new_style) | |
262 set_background(views::Background::CreateSolidBackground(GetNativeTheme()-> | 260 set_background(views::Background::CreateSolidBackground(GetNativeTheme()-> |
263 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground))); | 261 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground))); |
264 | 262 |
265 focus_manager_ = GetFocusManager(); | 263 focus_manager_ = GetFocusManager(); |
266 if (focus_manager_) | 264 if (focus_manager_) |
267 GetFocusManager()->AddFocusChangeListener(this); | 265 GetFocusManager()->AddFocusChangeListener(this); |
268 | 266 |
269 UpdateDialogButtons(); | 267 UpdateDialogButtons(); |
270 CreateExtraView(); | 268 CreateExtraView(); |
271 CreateFootnoteView(); | 269 CreateFootnoteView(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 int DialogClientView::GetButtonsAndExtraViewRowHeight() const { | 391 int DialogClientView::GetButtonsAndExtraViewRowHeight() const { |
394 int extra_view_height = ShouldShow(extra_view_) ? | 392 int extra_view_height = ShouldShow(extra_view_) ? |
395 extra_view_->GetPreferredSize().height() : 0; | 393 extra_view_->GetPreferredSize().height() : 0; |
396 int buttons_height = std::max( | 394 int buttons_height = std::max( |
397 ok_button_ ? ok_button_->GetPreferredSize().height() : 0, | 395 ok_button_ ? ok_button_->GetPreferredSize().height() : 0, |
398 cancel_button_ ? cancel_button_->GetPreferredSize().height() : 0); | 396 cancel_button_ ? cancel_button_->GetPreferredSize().height() : 0); |
399 return std::max(extra_view_height, buttons_height); | 397 return std::max(extra_view_height, buttons_height); |
400 } | 398 } |
401 | 399 |
402 gfx::Insets DialogClientView::GetButtonRowInsets() const { | 400 gfx::Insets DialogClientView::GetButtonRowInsets() const { |
403 if (GetButtonsAndExtraViewRowHeight() == 0) | |
404 return gfx::Insets(); | |
405 | |
406 // NOTE: The insets only apply to the buttons, extra view, and footnote view. | 401 // NOTE: The insets only apply to the buttons, extra view, and footnote view. |
407 return DialogDelegate::UseNewStyle() ? | 402 return GetButtonsAndExtraViewRowHeight() == 0 ? gfx::Insets() : |
408 gfx::Insets(0, kButtonHEdgeMarginNew, | 403 gfx::Insets(0, kButtonHEdgeMarginNew, |
409 kButtonVEdgeMarginNew, kButtonHEdgeMarginNew) : | 404 kButtonVEdgeMarginNew, kButtonHEdgeMarginNew); |
410 gfx::Insets(0, kButtonHEdgeMargin, | |
411 kButtonVEdgeMargin, kButtonHEdgeMargin); | |
412 } | 405 } |
413 | 406 |
414 void DialogClientView::Close() { | 407 void DialogClientView::Close() { |
415 GetWidget()->Close(); | 408 GetWidget()->Close(); |
416 GetDialogDelegate()->OnClosed(); | 409 GetDialogDelegate()->OnClosed(); |
417 } | 410 } |
418 | 411 |
419 } // namespace views | 412 } // namespace views |
OLD | NEW |