diff options
| author | 杨宇千 <crupest@outlook.com> | 2018-11-07 21:17:30 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-07 21:17:30 +0800 |
| commit | 634dab6ad2c9e4675beacfb77ac02b2d43cab132 (patch) | |
| tree | b44d8cd6f8f4ffbbb6451d42ba9a6b4d98828aec /src/main.cpp | |
| parent | df0d6e1e282c75d4d8154011715f0b74547b35db (diff) | |
| parent | 6f76a0ad3df99ea0d99623347d019536cc07e920 (diff) | |
| download | cru-634dab6ad2c9e4675beacfb77ac02b2d43cab132.tar.gz cru-634dab6ad2c9e4675beacfb77ac02b2d43cab132.tar.bz2 cru-634dab6ad2c9e4675beacfb77ac02b2d43cab132.zip | |
Merge pull request #1 from crupest/minmax-layout
Min max layout support.
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index ab641075..f2e65dd2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -84,7 +84,7 @@ int APIENTRY wWinMain( }); */ - /* + //test 2 const auto layout = CreateWithLayout<LinearLayout>(LayoutSideParams::Exactly(500), LayoutSideParams::Content()); @@ -101,18 +101,20 @@ int APIENTRY wWinMain( inner_layout->AddChild(TextBlock::Create(L"Toggle debug border")); const auto toggle_button = ToggleButton::Create(); +#ifdef CRU_DEBUG_LAYOUT toggle_button->toggle_event.AddHandler([&window](cru::ui::events::ToggleEventArgs& args) { window.SetDebugLayout(args.GetNewState()); }); - +#endif inner_layout->AddChild(toggle_button); layout->AddChild(inner_layout); } { const auto button = Button::Create(); - button->AddChild(MarginContainer::Create(Thickness(20, 5), { TextBlock::Create(L"button") })); + button->GetLayoutParams()->padding = Thickness(20, 5); + button->AddChild(TextBlock::Create(L"button")); layout->AddChild(button); } @@ -128,6 +130,13 @@ int APIENTRY wWinMain( } { + const auto text_box = TextBox::Create(); + text_box->GetLayoutParams()->width.min = 50.0f; + text_box->GetLayoutParams()->width.max = 100.0f; + layout->AddChild(text_box); + } + + { const auto text_block = CreateWithLayout<TextBlock>(LayoutSideParams::Stretch(), LayoutSideParams::Stretch(), L"This is a very very very very very long sentence!!!"); text_block->SetSelectable(true); layout->AddChild(text_block); @@ -138,7 +147,6 @@ int APIENTRY wWinMain( window.AddChild(layout); - */ /* window.AddChild( @@ -149,6 +157,7 @@ int APIENTRY wWinMain( )); */ + /* test 3 const auto linear_layout = CreateWithLayout<LinearLayout>(Thickness(50, 50), Thickness(50, 50), LinearLayout::Orientation::Vertical, ControlList{ Button::Create({ TextBlock::Create(L"Button") @@ -159,6 +168,7 @@ int APIENTRY wWinMain( linear_layout->SetBordered(true); window.AddChild(linear_layout); + */ window.Show(); |
