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

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

Issue 2375843003: views: add Harmony dialog width support (Closed)
Patch Set: Created 4 years, 3 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
« ui/views/window/dialog_delegate.h ('K') | « ui/views/window/dialog_delegate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/window/dialog_delegate.cc
diff --git a/ui/views/window/dialog_delegate.cc b/ui/views/window/dialog_delegate.cc
index 81f636723102cb125094045070ea489f5d154ff3..6b62012e6a254ff95775baad657f24d8d28cd49d 100644
--- a/ui/views/window/dialog_delegate.cc
+++ b/ui/views/window/dialog_delegate.cc
@@ -10,6 +10,7 @@
#include "build/build_config.h"
#include "ui/accessibility/ax_view_state.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/color_palette.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/bubble/bubble_border.h"
@@ -128,6 +129,10 @@ void DialogDelegate::UpdateButton(LabelButton* button, ui::DialogButton type) {
button->SetIsDefault(is_default);
}
+DialogDelegate::DialogWidth DialogDelegate::GetDefaultDialogWidth() const {
+ return DIALOG_WIDTH_DEFAULT;
+}
+
int DialogDelegate::GetDialogButtons() const {
return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
}
@@ -268,4 +273,18 @@ void DialogDelegateView::ViewHierarchyChanged(
NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
}
+gfx::Size DialogDelegateView::GetPreferredSize() const {
+ int height = View::GetPreferredSize().height();
Evan Stade 2016/09/28 16:14:37 you should get the width in the switch statement b
Elly Fong-Jones 2016/09/28 18:44:09 Done.
+ DialogDelegate::DialogWidth width = DialogDelegate::DIALOG_WIDTH_DEFAULT;
+ if (ui::MaterialDesignController::IsSecondaryUiMaterial())
+ width = GetDefaultDialogWidth();
+ switch (width) {
+ case DialogDelegate::DIALOG_WIDTH_SMALL: return gfx::Size(320, height);
+ case DialogDelegate::DIALOG_WIDTH_MEDIUM: return gfx::Size(448, height);
+ case DialogDelegate::DIALOG_WIDTH_LARGE: return gfx::Size(512, height);
+ default: return View::GetPreferredSize();
Evan Stade 2016/09/28 16:14:37 don't we want to enforce small/medium/large? If we
Evan Stade 2016/09/28 16:14:37 nit: better not to have a default --- explicitly l
Elly Fong-Jones 2016/09/28 18:44:09 We do, but we can't right now, until every DialogD
Elly Fong-Jones 2016/09/28 18:44:09 Done.
Evan Stade 2016/09/28 21:12:38 if every dialogdelegate is going to need to explic
+ }
+ return gfx::Size();
+}
+
} // namespace views
« ui/views/window/dialog_delegate.h ('K') | « ui/views/window/dialog_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698