diff options
author | crupest <crupest@outlook.com> | 2018-09-20 22:50:37 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-09-20 22:50:37 +0800 |
commit | 5f7d3268e3d2ea84a1afc97c209b703bf4092c76 (patch) | |
tree | 8cab3c7457420b55376e5825f0cdfefd47551c00 /CruUI/main.cpp | |
parent | 6cd7b4e168fdda6bf83187cda9269cad5f9ee0ed (diff) | |
download | cru-5f7d3268e3d2ea84a1afc97c209b703bf4092c76.tar.gz cru-5f7d3268e3d2ea84a1afc97c209b703bf4092c76.tar.bz2 cru-5f7d3268e3d2ea84a1afc97c209b703bf4092c76.zip |
Improve linear layout.
Diffstat (limited to 'CruUI/main.cpp')
-rw-r--r-- | CruUI/main.cpp | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/CruUI/main.cpp b/CruUI/main.cpp index e8dc60d6..6c96c833 100644 --- a/CruUI/main.cpp +++ b/CruUI/main.cpp @@ -81,7 +81,20 @@ int APIENTRY wWinMain( layout->AddChild(TextBlock::Create(L"Layout is clicked!")); }); - layout->AddChild(ToggleButton::Create()); + const auto inner_layout = LinearLayout::Create(LinearLayout::Orientation::Horizontal); + LinearLayout::SetAlignment(inner_layout, cru::ui::Alignment::End); + + layout->AddChild(inner_layout); + + inner_layout->AddChild(TextBlock::Create(L"Toggle debug border")); + + const auto toggle_button = ToggleButton::Create(); + toggle_button->toggle_event.AddHandler([&window](cru::ui::events::ToggleEventArgs& args) + { + window.SetDebugDrawControlBorder(args.GetNewState()); + }); + + inner_layout->AddChild(toggle_button); auto&& create_text_block = [](const String& text, const MeasureLength& width = MeasureLength::Content(), const MeasureLength& height = MeasureLength::Content()) { @@ -91,16 +104,24 @@ int APIENTRY wWinMain( return text_block; }; - const auto text_block = create_text_block(L"Hello World!!!", MeasureLength::Exactly(200), MeasureLength::Exactly(50)); + { + const auto text_block = create_text_block(L"Hello World!!!", MeasureLength::Exactly(200), MeasureLength::Exactly(80)); + + text_block->mouse_click_event.AddHandler([layout](cru::ui::events::MouseButtonEventArgs& args) + { + layout->AddChild(TextBlock::Create(L"Hello world is clicked!")); + }); + + layout->AddChild(text_block); + layout->AddChild(create_text_block(L"This is a very very very very very long sentence!!!", MeasureLength::Stretch(), MeasureLength::Stretch())); + } - text_block->mouse_click_event.AddHandler([layout](cru::ui::events::MouseButtonEventArgs& args) { - layout->AddChild(TextBlock::Create(L"Hello world is clicked!")); - }); + const auto text_block = TextBlock::Create(L"This is a little short sentence!!!"); + LinearLayout::SetAlignment(text_block, cru::ui::Alignment::Start); + layout->AddChild(text_block); + } - layout->AddChild(text_block); - layout->AddChild(create_text_block(L"This is a very very very very very long sentence!!!", MeasureLength::Stretch(), MeasureLength::Stretch())); - layout->AddChild(TextBlock::Create(L"This is a little short sentence!!!")); layout->AddChild(create_text_block(L"By crupest!!!", MeasureLength::Stretch(), MeasureLength::Stretch())); |