diff options
author | crupest <crupest@outlook.com> | 2022-05-15 14:15:31 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-05-15 14:15:31 +0800 |
commit | 34a64e6ffefaab007578932ddbab931a25f1d56e (patch) | |
tree | 541fdb8279e829a129df62288d09916bf23c9200 /demos/ScrollView | |
parent | 8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6 (diff) | |
download | cru-34a64e6ffefaab007578932ddbab931a25f1d56e.tar.gz cru-34a64e6ffefaab007578932ddbab931a25f1d56e.tar.bz2 cru-34a64e6ffefaab007578932ddbab931a25f1d56e.zip |
...
Diffstat (limited to 'demos/ScrollView')
-rw-r--r-- | demos/ScrollView/CMakeLists.txt | 12 | ||||
-rw-r--r-- | demos/ScrollView/main.cpp | 87 |
2 files changed, 99 insertions, 0 deletions
diff --git a/demos/ScrollView/CMakeLists.txt b/demos/ScrollView/CMakeLists.txt new file mode 100644 index 00000000..8b34f5d8 --- /dev/null +++ b/demos/ScrollView/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable(CruDemoScrollView main.cpp) + +if(APPLE) + set_target_properties(CruDemoScrollView PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_GUI_IDENTIFIER life.crupest.cru.demo-scroll-view + MACOSX_BUNDLE_BUNDLE_NAME demo-scroll-view + ) +endif() + +target_add_resources(CruDemoScrollView cru/ui) +target_link_libraries(CruDemoScrollView PRIVATE CruDemoBase CruUi) diff --git a/demos/ScrollView/main.cpp b/demos/ScrollView/main.cpp new file mode 100644 index 00000000..b049a408 --- /dev/null +++ b/demos/ScrollView/main.cpp @@ -0,0 +1,87 @@ +#include "cru/platform/bootstrap/Bootstrap.h" +#include "cru/platform/gui/UiApplication.h" +#include "cru/platform/gui/Window.h" +#include "cru/ui/controls/ScrollView.h" +#include "cru/ui/controls/TextBlock.h" +#include "cru/ui/controls/Window.h" + +using cru::platform::gui::IUiApplication; +using cru::ui::controls::ScrollView; +using cru::ui::controls::TextBlock; +using cru::ui::controls::Window; + +int main() { + std::unique_ptr<IUiApplication> application( + cru::platform::bootstrap::CreateUiApplication()); + + Window window; + ScrollView scroll_view; + window.AddChild(&scroll_view); + + TextBlock text_block( + uR"([Verse 1] +The snow glows white on the mountain tonight +Not a footprint to be seen +A kingdom of isolation +And it looks like I'm the queen +The wind is howling like this swirling storm inside +Couldn't keep it in, Heaven knows I tried + +[Pre-Chorus] +Don't let them in, don't let them see +Be the good girl you always have to be +Conceal, don't feel, don't let them know +Well, now they know + +[Chorus] +Let it go, let it go +Can't hold it back anymore +Let it go, let it go +Turn away and slam the door +I don't care what they're going to say +Let the storm rage on +The cold never bothered me anyway + +[Verse 2] +It's funny how some distance +Makes everything seem small +And the fears that once controlled me +Can't get to me at all + +[Pre-Chorus] +It's time to see what I can do +To test the limits and break through +No right, no wrong, no rules for me +I'm free + +[Chorus] +Let it go, let it go +I'm one with the wind and sky +Let it go, let it go +You'll never see me cry +Here I stand, and here I'll stay +Let the storm rage on... + +[Bridge] +My power flurries through the air into the ground +My soul is spiraling in frozen fractals all around +And one thought crystallizes like an icy blast: +I'm never going back, the past is in the past! + +[Chorus] +Let it go, let it go +And I'll rise like the break of dawn +Let it go, let it go +That perfect girl is gone +Here I stand in the light of day +Let the storm rage on! +The cold never bothered me anyway)", + true); + + scroll_view.SetChild(&text_block); + + window.GetWindowHost()->GetNativeWindow()->SetVisibility( + cru::platform::gui::WindowVisibilityType::Show); + + return application->Run(); +} |