Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
C++
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102#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 <memory>
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<UI::Widget> TitleScreen::CreateRoot() { auto root = std::make_unique<UI::StackLayout>(UI::Orientation::Vertical, 24.0f); root->AddChild(CreateHeader()); auto recentLabel = std::make_unique<UI::Label>("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<UI::Widget> TitleScreen::CreateHeader() { auto panel = std::make_unique<UI::Panel>(); 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::StackLayout>(UI::Orientation::Horizontal, 16.0f); layout->SetVerticalAlignment(UI::VerticalAlignment::Center); layout->AddChild(std::make_unique<UI::Image>(logoTexture, UI::Size(240.0f, 80.0f))); auto version = std::make_unique<UI::Button>("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<UI::Widget>(); spacer->SetHorizontalAlignment(UI::HorizontalAlignment::Stretch); spacer->SetMaxSize(UI::Size(1000000.0f, 1000000.0f)); layout->AddChild(std::move(spacer)); layout->AddChild(std::make_unique<UI::IconActionButton>(ICON_MS_CREATE, "Create New")); layout->AddChild(std::make_unique<UI::IconActionButton>(ICON_MS_PHOTO_LIBRARY, "My Gallery", []() { ScreenLayer::OpenScreen(std::make_unique<ProjectsScreen>()); })); layout->AddChild(std::make_unique<UI::IconActionButton>(ICON_MS_SETTINGS, "Settings")); panel->AddChild(std::move(layout)); return panel;}
std::unique_ptr<UI::Widget> TitleScreen::CreateRecentProjects() { const auto artworks = ArtworkManagementContext::GetLatest(20); auto layout = std::make_unique<UI::VirtualizingStackLayout>( 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<UI::ArtworkCard>(artworks[index], false); } ); auto scrollable = std::make_unique<UI::ScrollArea>(UI::OverflowFlags::Horizontal); scrollable->SetPadding(UI::Thickness(32.0f, 0.0f)); scrollable->AddChild(std::move(layout)); return scrollable;}
std::unique_ptr<UI::Widget> TitleScreen::CreateFooter() { auto footer = std::make_unique<UI::Label>("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;}