diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-19 21:01:27 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-19 21:01:27 +0000 |
commit | 131952c3605d1ad328ae73f71c06ca0ea1615c2c (patch) | |
tree | abfd5367826764e155af7a72b5ae416ad50fbdcb /ui/views/examples/widget_example.cc | |
parent | 01ae53417b7c0a698e48861f251167f0b6b4c872 (diff) | |
download | chromium_src-131952c3605d1ad328ae73f71c06ca0ea1615c2c.zip chromium_src-131952c3605d1ad328ae73f71c06ca0ea1615c2c.tar.gz chromium_src-131952c3605d1ad328ae73f71c06ca0ea1615c2c.tar.bz2 |
Fix DialogClientView layout, buttons, accelerators; etc.
Rename Get[Extra|Footnote]View to Create*; only call once per dialog.
Clamp 'extra view' size and align left in the button row.
Simplify 'extra view' users: remove containers/layout, init on demand.
Remove unused GetSizeExtraViewHeightToButtons / IsDialogButtonVisible / GetFootnoteViewHeight.
Remove non-functional PaintSizeBox code and broken |size_box_bounds_|.
Move meaningful StyleParams distinctions to GetInsets().
(temporarily regresses new dialog style resizing and button spacing)
Get default button text in DialogDelegateView::GetDialogButtonLabel.
Return superclass GetDialogButtonLabel in OVERRIDES, not string16().
Simplify FocusChangeListener add/remove for default button wrangling.
Add TreeView return key accelerator handling to commit pending edits.
Remove AreAcceleratorsEnabled (was for committing tree view, edits)
Fix [Dialog|Widget]Example's init; add extra/footnote views.
TODO(followup): Restore dialog resizing via frame view hit testing.
TODO(followup): Fix new dialog button spacing via layout constants.
BUG=166075
TEST=No observable dialog appearance/behavior changes (except minor button spacing change for experimental --enable-new-dialog-style)
R=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/12259021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183286 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/examples/widget_example.cc')
-rw-r--r-- | ui/views/examples/widget_example.cc | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/ui/views/examples/widget_example.cc b/ui/views/examples/widget_example.cc index a4c221b..c91e1e8 100644 --- a/ui/views/examples/widget_example.cc +++ b/ui/views/examples/widget_example.cc @@ -6,6 +6,7 @@ #include "base/utf_string_conversions.h" #include "ui/views/controls/button/text_button.h" +#include "ui/views/controls/label.h" #include "ui/views/layout/box_layout.h" #include "ui/views/view.h" #include "ui/views/widget/widget.h" @@ -18,13 +19,34 @@ namespace { class DialogExample : public DialogDelegateView { public: + DialogExample(); + virtual ~DialogExample(); virtual string16 GetWindowTitle() const OVERRIDE; + virtual View* CreateExtraView() OVERRIDE; + virtual View* CreateFootnoteView() OVERRIDE; }; +DialogExample::DialogExample() { + set_background(Background::CreateSolidBackground(SK_ColorGRAY)); + SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 10, 10, 10)); + AddChildView(new Label(ASCIIToUTF16("Dialog contents label!"))); +} + +DialogExample::~DialogExample() { +} + string16 DialogExample::GetWindowTitle() const { return ASCIIToUTF16("Dialog Widget Example"); } +View* DialogExample::CreateExtraView() { + return new NativeTextButton(NULL, ASCIIToUTF16("Extra button!")); +} + +View* DialogExample::CreateFootnoteView() { + return new Label(ASCIIToUTF16("Footnote label!")); +} + } // namespace WidgetExample::WidgetExample() : ExampleBase("Widget") { @@ -34,7 +56,7 @@ WidgetExample::~WidgetExample() { } void WidgetExample::CreateExampleView(View* container) { - container->SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, 0, 0, 2)); + container->SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, 0, 0, 10)); BuildButton(container, "Popup widget", POPUP); BuildButton(container, "Dialog widget", DIALOG); #if defined(OS_LINUX) @@ -79,11 +101,8 @@ void WidgetExample::ButtonPressed(Button* sender, const ui::Event& event) { ShowWidget(sender, Widget::InitParams(Widget::InitParams::TYPE_POPUP)); break; case DIALOG: { - Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); - params.delegate = new DialogExample(); - params.remove_standard_frame = true; - params.transparent = true; - ShowWidget(sender, params); + DialogDelegateView::CreateDialogWidget(new DialogExample(), NULL, + sender->GetWidget()->GetNativeView())->Show(); break; } case CHILD: |