Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117#include "ProjectsLayer.h"#include "../ManagementContext/StyleManagmentContext.h"#include "../UserData.h"#include <filesystem>#include <imgui.h>#include "../Version.h"#include "../App.h"
void ProjectsAppLayer::OnActivate() { isActive = true; RefreshProjects();}
void ProjectsAppLayer::RefreshProjects() { projects.clear(); if (!std::filesystem::exists(UserData::GetProjectsDir())) { return; } for (auto& project : std::filesystem::directory_iterator(UserData::GetProjectsDir())) { if (project.is_directory() || project.path().extension() != ".grdn") { continue; } projects.push_back(project.path().filename().string()); }}void ProjectsAppLayer::OnDeactivate() { isActive = false;}void ProjectsAppLayer::OnRender() { const ImGuiViewport* viewport = ImGui::GetMainViewport(); ImGui::SetNextWindowPos(viewport->WorkPos, ImGuiCond_Always, ImVec2(0.0f, 0.0f)); ImGui::SetNextWindowSize(viewport->WorkSize, ImGuiCond_Always); StyleManagmentContext::Push(PROJECTSWINDOW); ImGui::Begin("Projects", nullptr, ImGuiWindowFlags_None | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar); ImGui::Text("My Gallery"); ImGui::SameLine(); ImGui::TextDisabled("Note: this screen will be drastically overhauled eventually, the purpouse of this version is to provide a functional interface"); ImGui::Separator(); ImGui::BeginListBox("##ProjectsList", ImVec2(-FLT_MIN, -220.0f)); bool wantToEdit = false; for (const auto& project : projects) { if (ImGui::Selectable(project.c_str(), selectedProject == project)) { selectedProject = project; } if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { wantToEdit = true; } } if (projects.empty()) { ImGui::TextDisabled("No projects found. Create one below! (will be saved in ~/.local/share/Gradien/Projects/)"); } ImGui::EndListBox(); ImGui::BeginDisabled(selectedProject == ""); if (ImGui::Button("Edit") || wantToEdit) { App::CurrentArtwork = new Artwork(UserData::GetProjectsDir() + "/" + selectedProject); App::CurrentArtwork->LoadProject(); } ImGui::SameLine(); if (ImGui::Button("Rename")) { } ImGui::SameLine(); if (ImGui::Button("Delete")) { } ImGui::EndDisabled(); ImGui::SameLine(); if (ImGui::Button("Refresh")) { RefreshProjects(); } ImGui::Separator(); static int canvasWidth = 1280; static int canvasHeight = 720; const int minDim = 1; const int maxDim = 4096; const int extendedDim = 16384; static bool extended = false; ImGui::Text("New Project"); ImGui::PushItemWidth(-FLT_MIN); if (ImGui::GetMainViewport()->WorkSize.x > 640) { int v[] = {canvasWidth, canvasHeight}; ImGui::TextDisabled("Width, Height:"); ImGui::SliderInt2("##WidthHeight", v, minDim, extended ? extendedDim : maxDim, "%dpx"); canvasWidth = v[0]; canvasHeight = v[1]; } else { ImGui::SliderInt("##Width", &canvasWidth, minDim, extended ? extendedDim : maxDim,"Width: %dpx"); ImGui::SliderInt("##Height", &canvasHeight, minDim, extended ? extendedDim : maxDim, "Height: %dpx"); } ImGui::Checkbox("Extend Dimensions (may impact performance and makes selection more difficult)", &extended); ImGui::PopItemWidth(); if (ImGui::Button("Create")) { time_t timestamp = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); char filename[64]; strftime(filename, 64, "untitled_%Y-%m-%d_%H-%M-%S.grdn", localtime(×tamp)); std::string filepath = UserData::GetProjectsDir() + "/" + filename; App::CurrentArtwork = Artwork::NewArtwork(canvasWidth, canvasHeight, filepath); App::CurrentArtwork->LoadProject(); RefreshProjects(); } ImGui::SameLine(); ImGui::BeginDisabled(); if (ImGui::Button("Import from Storage")) { } ImGui::SameLine(); if (ImGui::Button("Import from Clipboard")) { } ImGui::EndDisabled(); ImGui::Separator(); ImGui::Text("%s", VERSION_STRING.c_str()); ImGui::SameLine(); ImGui::TextLinkOpenURL("Source Code", "https://tangled.org/hatlink.bsky.social/gradien"); ImGui::SameLine(); ImGui::TextLinkOpenURL("Feedback", "https://userinput.app/#/s/did:plc:iif6bnwns5ikitrpwvlz2eo5/3mnsgs3pk2h2z"); ImGui::SameLine(); ImGui::TextDisabled("Made with <3 by HatLink & Contributors"); ImGui::End(); StyleManagmentContext::Pop();}