diff options
author | crupest <crupest@outlook.com> | 2018-09-22 00:17:53 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-09-22 00:17:53 +0800 |
commit | e01800206050a0ed88cc4f4456fa3590021ab66f (patch) | |
tree | aaa6118d614ead6cd1865e4b2d160cade91d8057 /CruUI/main.cpp | |
parent | 89f7277d47cd37f25a141ec2ebc13c4f6fceabd5 (diff) | |
download | cru-e01800206050a0ed88cc4f4456fa3590021ab66f.tar.gz cru-e01800206050a0ed88cc4f4456fa3590021ab66f.tar.bz2 cru-e01800206050a0ed88cc4f4456fa3590021ab66f.zip |
Add button.
Diffstat (limited to 'CruUI/main.cpp')
-rw-r--r-- | CruUI/main.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/CruUI/main.cpp b/CruUI/main.cpp index 65e63af9..9cd566ab 100644 --- a/CruUI/main.cpp +++ b/CruUI/main.cpp @@ -3,6 +3,7 @@ #include "ui/controls/linear_layout.h" #include "ui/controls/text_block.h" #include "ui/controls/toggle_button.h" +#include "ui/controls/button.h" using cru::String; @@ -14,6 +15,7 @@ using cru::ui::LayoutLength; using cru::ui::controls::LinearLayout; using cru::ui::controls::TextBlock; using cru::ui::controls::ToggleButton; +using cru::ui::controls::Button; int APIENTRY wWinMain( @@ -82,20 +84,28 @@ int APIENTRY wWinMain( layout->AddChild(TextBlock::Create(L"Layout is clicked!")); }); - const auto inner_layout = LinearLayout::Create(LinearLayout::Orientation::Horizontal); - inner_layout->GetLayoutParams()->width.alignment = Alignment::End; + { + const auto inner_layout = LinearLayout::Create(LinearLayout::Orientation::Horizontal); + inner_layout->GetLayoutParams()->width.alignment = Alignment::End; - layout->AddChild(inner_layout); + layout->AddChild(inner_layout); - inner_layout->AddChild(TextBlock::Create(L"Toggle debug border")); + 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()); - }); + 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); + inner_layout->AddChild(toggle_button); + } + + { + const auto button = Button::Create(); + button->AddChild(TextBlock::Create(L"button")); + layout->AddChild(button); + } auto&& create_text_block = [](const String& text, const LayoutLength& width = LayoutLength::Content(), const LayoutLength& height = LayoutLength::Content()) { |