#include "TitleScreen.h" #include "MaterialIcons.h" #include "../Texture.h" #include "../Version.h" #include "../Widgets/IconActionButton.h" #include "../Widgets/Image.h" #include "../Widgets/Label.h" #include "../Widgets/Panel.h" #include "../Widgets/ArtworkCard.h" #include "../ManagementContext/ArtworkManagementContext.h" #include "../Widgets/ScrollArea.h" #include "../UserInterface/Layout/StackLayout.h" #include "../UserInterface/Layout/VirtualizingStackLayout.h" #include "../AppLayers/ScreenLayer.h" #include "ProjectsScreen.h" #include "UserInterface/Engine/Geometry.h" #include "Widgets/Button.h" #include TitleScreen::TitleScreen() : Screen(nullptr), logoTexture(new Texture("logoFull.png")) { rootWidget = CreateRoot(); dirtyManager.SetRootWidget(rootWidget.get()); inputRouter.SetRootWidget(rootWidget.get()); } TitleScreen::~TitleScreen() { rootWidget.reset(); delete logoTexture; } std::unique_ptr TitleScreen::CreateRoot() { auto root = std::make_unique(UI::Orientation::Vertical, 24.0f); root->AddChild(CreateHeader()); auto recentLabel = std::make_unique("Recently Edited"); recentLabel->SetTextColor(UI::Color(0.0f, 0.0f, 0.0f, 1.0f)); recentLabel->SetPadding(UI::Thickness(32.0f, 0.0f)); root->AddChild(std::move(recentLabel)); root->AddChild(CreateRecentProjects()); root->AddChild(CreateFooter()); return root; } #include "../SystemInfo.h" std::unique_ptr TitleScreen::CreateHeader() { auto panel = std::make_unique(); panel->SetBgColor(UI::Color(0, 0, 0, 1.0f)); panel->SetVerticalAlignment(UI::VerticalAlignment::Center); panel->SetPadding(UI::Thickness(32.0f, 16.0f)); auto layout = std::make_unique(UI::Orientation::Horizontal, 16.0f); layout->SetVerticalAlignment(UI::VerticalAlignment::Center); layout->AddChild(std::make_unique(logoTexture, UI::Size(240.0f, 80.0f))); auto version = std::make_unique("ver." + SEMVER_STRING, []() { SystemInformation::Show(); }); version->SetVerticalAlignment(UI::VerticalAlignment::Bottom); version->SetMargin(UI::Thickness(0, 0, 0, 15.0f)); version->SetPadding(UI::Thickness(0,0)); version->SetNormalColor(UI::Color(0, 0, 0, 0.0f)); version->SetHoverColor(UI::Color(0, 0, 0, 0.0f)); version->SetActiveColor(UI::Color(0, 0, 0, 0.0f)); // since systeminfo is currently blocking,having pressed show up at all times when open is not prefereable, remove once using panel modal layout->AddChild(std::move(version)); auto spacer = std::make_unique(); spacer->SetHorizontalAlignment(UI::HorizontalAlignment::Stretch); spacer->SetMaxSize(UI::Size(1000000.0f, 1000000.0f)); layout->AddChild(std::move(spacer)); layout->AddChild(std::make_unique(ICON_MS_CREATE, "Create New")); layout->AddChild(std::make_unique(ICON_MS_PHOTO_LIBRARY, "My Gallery", []() { ScreenLayer::OpenScreen(std::make_unique()); })); layout->AddChild(std::make_unique(ICON_MS_SETTINGS, "Settings")); panel->AddChild(std::move(layout)); return panel; } std::unique_ptr TitleScreen::CreateRecentProjects() { const auto artworks = ArtworkManagementContext::GetLatest(20); auto layout = std::make_unique( artworks.size(), 10.0f, 240.0f, [artworks](std::size_t index) { return UI::ArtworkCard::GetSizeForArtwork(artworks[index], false); }, [artworks](std::size_t index) { return std::make_unique(artworks[index], false); } ); auto scrollable = std::make_unique(UI::OverflowFlags::Horizontal); scrollable->SetPadding(UI::Thickness(32.0f, 0.0f)); scrollable->AddChild(std::move(layout)); return scrollable; } std::unique_ptr TitleScreen::CreateFooter() { auto footer = std::make_unique("Made with <3 by HatLink & Contributors"); footer->SetTextColor(UI::Color(0.0f, 0.0f, 0.0f, 1.0f)); footer->SetPadding(UI::Thickness(32.0f, 0.0f)); return footer; }