2026-04-12 17:31:32 +03:00
|
|
|
#include "FileSelectScreen.hpp"
|
2026-04-17 19:32:49 +03:00
|
|
|
#include "../MainProgram.hpp"
|
|
|
|
|
#include "../GUIHolder.hpp"
|
|
|
|
|
#include "../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
|
2026-04-21 18:38:24 +03:00
|
|
|
#include "../GUIStuff/ElementHelpers/ButtonHelpers.hpp"
|
2026-04-23 21:49:13 +03:00
|
|
|
#include "../GUIStuff/ElementHelpers/ScrollAreaHelpers.hpp"
|
2026-04-18 20:51:45 +03:00
|
|
|
#include "Helpers/ConvertVec.hpp"
|
|
|
|
|
#include "../GUIStuff/Elements/GridScrollArea.hpp"
|
2026-04-19 17:44:48 +03:00
|
|
|
#include "../GUIStuff/Elements/ImageDisplay.hpp"
|
2026-04-22 17:40:58 +03:00
|
|
|
#include "../GUIStuff/Elements/LayoutElement.hpp"
|
2026-04-23 20:56:11 +03:00
|
|
|
#include "../GUIStuff/Elements/SVGIcon.hpp"
|
2026-04-25 19:01:19 +03:00
|
|
|
#include "../GUIStuff/Elements/TextParagraph.hpp"
|
2026-04-26 18:20:37 +03:00
|
|
|
#include "../GUIStuff/ElementHelpers/LayoutHelpers.hpp"
|
2026-04-23 20:56:11 +03:00
|
|
|
#include "../GUIStuff/Elements/PositionAdjustingPopupMenu.hpp"
|
2026-04-19 17:44:48 +03:00
|
|
|
#include "../World.hpp"
|
2026-04-20 18:56:39 +03:00
|
|
|
#include "Helpers/StringHelpers.hpp"
|
2026-04-26 13:21:05 +03:00
|
|
|
#include "PhoneDrawingProgramScreen.hpp"
|
2026-04-23 20:56:11 +03:00
|
|
|
#include <SDL3/SDL_time.h>
|
2026-04-20 20:16:15 +03:00
|
|
|
#include <SDL3/SDL_timer.h>
|
2026-04-17 19:32:49 +03:00
|
|
|
|
2026-04-22 17:40:58 +03:00
|
|
|
#define MAIN_MENU_SIZE 300
|
|
|
|
|
|
|
|
|
|
using namespace GUIStuff;
|
|
|
|
|
using namespace ElementHelpers;
|
|
|
|
|
|
2026-04-23 20:56:11 +03:00
|
|
|
FileSelectScreen::FileSelectScreen(MainProgram& m): Screen(m) {
|
|
|
|
|
savePath = main.conf.configPath / "saves";
|
|
|
|
|
trashPath = main.conf.configPath / "trash";
|
|
|
|
|
trashInfoPath = main.conf.configPath / "trashInfo.json";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
nlohmann::json j(nlohmann::json::parse(read_file_to_string(trashInfoPath)));
|
|
|
|
|
j.get_to(trashInfo);
|
|
|
|
|
}
|
|
|
|
|
catch(...) {}
|
|
|
|
|
|
|
|
|
|
update_file_list(fileList, savePath, false);
|
|
|
|
|
|
|
|
|
|
// Update trash list once to get trash info up to date
|
|
|
|
|
std::vector<FileInfo> trashListTemp;
|
|
|
|
|
update_file_list(trashListTemp, trashPath, true);
|
|
|
|
|
}
|
2026-04-17 19:32:49 +03:00
|
|
|
|
|
|
|
|
void FileSelectScreen::gui_layout_run() {
|
2026-04-23 20:56:11 +03:00
|
|
|
main_display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileSelectScreen::update_file_list(std::vector<FileInfo>& fL, const std::filesystem::path& savePath, bool trashUpdate) {
|
|
|
|
|
constexpr SDL_Time NS_IN_DAY = SDL_SECONDS_TO_NS(24 * 3600);
|
|
|
|
|
|
|
|
|
|
SDL_Time currentTime;
|
|
|
|
|
SDL_GetCurrentTime(¤tTime);
|
|
|
|
|
|
|
|
|
|
SDL_Time afterThirtyDays = currentTime + NS_IN_DAY * 30;
|
|
|
|
|
|
|
|
|
|
fL.clear();
|
|
|
|
|
int globCount;
|
|
|
|
|
char** filesInPath = SDL_GlobDirectory(savePath.string().c_str(), "*", 0, &globCount);
|
|
|
|
|
if(filesInPath) {
|
|
|
|
|
for(int i = 0; i < globCount; i++) {
|
|
|
|
|
std::filesystem::path p = filesInPath[i];
|
|
|
|
|
std::string fExt = p.extension().string();
|
|
|
|
|
if(fExt == "." + World::FILE_EXTENSION) {
|
|
|
|
|
std::filesystem::path fullPath = savePath / filesInPath[i];
|
|
|
|
|
FileInfo fileInfoToAdd;
|
|
|
|
|
fileInfoToAdd.fileName = p.stem().string();
|
|
|
|
|
|
|
|
|
|
if(trashUpdate) {
|
|
|
|
|
auto it = trashInfo.files.find(fileInfoToAdd.fileName);
|
|
|
|
|
if(it == trashInfo.files.end()) {
|
|
|
|
|
trashInfo.files[fileInfoToAdd.fileName].trashTime = currentTime;
|
|
|
|
|
fileInfoToAdd.lastModifyTime = currentTime;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fileInfoToAdd.lastModifyTime = it->second.trashTime;
|
|
|
|
|
|
|
|
|
|
if(fileInfoToAdd.lastModifyTime >= afterThirtyDays) {
|
|
|
|
|
// Remove file and thumbnail
|
|
|
|
|
SDL_RemovePath(fullPath.string().c_str());
|
|
|
|
|
SDL_RemovePath((savePath / fileInfoToAdd.fileName / ".jpg").string().c_str());
|
|
|
|
|
trashInfo.files.erase(it);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t daysToDeletion = (afterThirtyDays - fileInfoToAdd.lastModifyTime) / NS_IN_DAY;
|
|
|
|
|
|
|
|
|
|
if(daysToDeletion == 0)
|
|
|
|
|
fileInfoToAdd.lastModifyDate = "Today";
|
|
|
|
|
else if(daysToDeletion == 1)
|
|
|
|
|
fileInfoToAdd.lastModifyDate = "Tomorrow";
|
|
|
|
|
else
|
|
|
|
|
fileInfoToAdd.lastModifyDate = std::to_string(daysToDeletion) + " days";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
SDL_PathInfo pathInfo;
|
|
|
|
|
if(SDL_GetPathInfo(fullPath.string().c_str(), &pathInfo)) {
|
|
|
|
|
SDL_DateTime pathDt;
|
|
|
|
|
fileInfoToAdd.lastModifyTime = pathInfo.modify_time;
|
|
|
|
|
if(SDL_TimeToDateTime(pathInfo.modify_time, &pathDt, true)) {
|
|
|
|
|
fileInfoToAdd.lastModifyDate = sdl_time_to_nice_access_time(pathDt, main.conf.dateFormat, main.conf.timeFormat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fL.emplace_back(fileInfoToAdd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
SDL_CreateDirectory(savePath.string().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileSelectScreen::main_display() {
|
2026-04-18 20:51:45 +03:00
|
|
|
auto& gui = main.g.gui;
|
2026-04-17 19:32:49 +03:00
|
|
|
CLAY_AUTO_ID({
|
2026-04-18 20:51:45 +03:00
|
|
|
.layout = {
|
2026-04-21 18:38:24 +03:00
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
2026-04-22 17:40:58 +03:00
|
|
|
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
2026-04-18 20:51:45 +03:00
|
|
|
},
|
2026-04-17 19:32:49 +03:00
|
|
|
}) {
|
2026-04-24 11:07:15 +03:00
|
|
|
mainMenuOpenAnim = gui.float_animation("main menu animation", {
|
|
|
|
|
.duration = 0.1f,
|
|
|
|
|
.easing = BezierEasing(0.36f, 0.0f, 0.64f, 1.0f)
|
|
|
|
|
});
|
|
|
|
|
actionBarOpenAnim = gui.float_animation("action bar animation", {
|
|
|
|
|
.duration = 0.1f,
|
|
|
|
|
.easing = BezierEasing(0.36f, 0.0f, 0.64f, 1.0f)
|
|
|
|
|
});
|
|
|
|
|
main_menu();
|
|
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
2026-04-26 18:20:37 +03:00
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
2026-04-24 11:07:15 +03:00
|
|
|
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP },
|
|
|
|
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
|
|
|
|
},
|
|
|
|
|
}) {
|
2026-04-22 17:40:58 +03:00
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
2026-04-24 11:07:15 +03:00
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
2026-04-22 17:40:58 +03:00
|
|
|
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP },
|
|
|
|
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
|
|
|
|
},
|
|
|
|
|
}) {
|
2026-04-24 11:07:15 +03:00
|
|
|
if(editMode) {
|
|
|
|
|
numberOfSelectedEntries = std::count_if(fileList.begin(), fileList.end(), [] (const FileInfo& f) { return f.selected; });
|
|
|
|
|
if(numberOfSelectedEntries == 0)
|
|
|
|
|
actionBarOpenAnim->animation_trigger_reverse();
|
2026-04-23 20:56:11 +03:00
|
|
|
else
|
2026-04-24 11:07:15 +03:00
|
|
|
actionBarOpenAnim->animation_trigger();
|
|
|
|
|
edit_title_bar();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
actionBarOpenAnim->animation_trigger_reverse();
|
|
|
|
|
title_bar();
|
|
|
|
|
}
|
2026-04-27 00:42:25 +03:00
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
|
|
|
|
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
|
|
|
|
},
|
|
|
|
|
}) {
|
|
|
|
|
window_gap_side_bar(gui, "main display left fill", WindowFillSideBarConfig::Direction::LEFT);
|
2026-04-26 18:20:37 +03:00
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
|
|
|
|
.padding = CLAY_PADDING_ALL(gui.io.theme->padding1),
|
|
|
|
|
.childGap = gui.io.theme->childGap1,
|
|
|
|
|
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP },
|
|
|
|
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
|
|
|
|
},
|
|
|
|
|
}) {
|
|
|
|
|
switch(selectedMenu) {
|
|
|
|
|
case SelectedMenu::FILES:
|
|
|
|
|
file_view();
|
|
|
|
|
if(!editMode)
|
|
|
|
|
create_file_button();
|
|
|
|
|
break;
|
|
|
|
|
case SelectedMenu::TRASH:
|
|
|
|
|
file_view();
|
|
|
|
|
break;
|
|
|
|
|
case SelectedMenu::SETTINGS:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-27 00:42:25 +03:00
|
|
|
window_gap_side_bar(gui, "main display right fill", WindowFillSideBarConfig::Direction::RIGHT);
|
|
|
|
|
}
|
|
|
|
|
window_gap_side_bar(gui, "main display bottom fill", WindowFillSideBarConfig::Direction::BOTTOM);
|
2026-04-24 11:07:15 +03:00
|
|
|
menu_black_box();
|
2026-04-22 17:40:58 +03:00
|
|
|
}
|
2026-04-24 11:07:15 +03:00
|
|
|
edit_action_bar();
|
2026-04-22 17:40:58 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-26 13:21:05 +03:00
|
|
|
void FileSelectScreen::create_file_button() {
|
|
|
|
|
auto& gui = main.g.gui;
|
|
|
|
|
gui.set_z_index(gui.get_z_index() + 2, [&] {
|
|
|
|
|
gui.element<LayoutElement>("create file button floating area", [&](LayoutElement*, const Clay_ElementId& lId) {
|
|
|
|
|
CLAY(lId, {
|
|
|
|
|
.layout = {.sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)}},
|
|
|
|
|
.floating = {
|
|
|
|
|
.offset = {-5, -5},
|
|
|
|
|
.zIndex = gui.get_z_index(),
|
|
|
|
|
.attachPoints = {
|
|
|
|
|
.element = CLAY_ATTACH_POINT_RIGHT_BOTTOM,
|
|
|
|
|
.parent = CLAY_ATTACH_POINT_RIGHT_BOTTOM
|
|
|
|
|
},
|
2026-04-27 00:42:25 +03:00
|
|
|
.attachTo = CLAY_ATTACH_TO_PARENT
|
2026-04-26 13:21:05 +03:00
|
|
|
}
|
|
|
|
|
}) {
|
|
|
|
|
svg_icon_button(gui, "add button", "data/icons/plus.svg", {
|
|
|
|
|
.onClick = [&] {
|
|
|
|
|
main.create_new_tab({
|
|
|
|
|
.isClient = false
|
|
|
|
|
});
|
|
|
|
|
main.screen = std::make_unique<PhoneDrawingProgramScreen>(main);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-23 20:56:11 +03:00
|
|
|
void FileSelectScreen::edit_action_bar_button(const char* id, const std::string& svgPath, const char* text, const std::function<void()>& onClick) {
|
|
|
|
|
auto& gui = main.g.gui;
|
|
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {.sizing = {.width = CLAY_SIZING_FIXED(70), .height = CLAY_SIZING_GROW(0)}}
|
|
|
|
|
}) {
|
|
|
|
|
gui.element<SelectableButton>(id, SelectableButton::Data{
|
|
|
|
|
.drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
|
|
|
|
|
.onClick = onClick,
|
|
|
|
|
.innerContent = [&](const SelectableButton::InnerContentCallbackParameters&) {
|
|
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)},
|
|
|
|
|
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP },
|
|
|
|
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
|
|
|
|
}
|
|
|
|
|
}) {
|
|
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {.sizing = {.width = CLAY_SIZING_FIXED(20), .height = CLAY_SIZING_FIXED(20)}}
|
|
|
|
|
}) {
|
|
|
|
|
gui.element<SVGIcon>("icon", svgPath, false);
|
|
|
|
|
}
|
|
|
|
|
text_label(gui, text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileSelectScreen::move_selected_files(const std::filesystem::path& fromPath, const std::filesystem::path& toPath, TrashMoveType trashMoveType) {
|
|
|
|
|
SDL_Time currentTime;
|
|
|
|
|
SDL_GetCurrentTime(¤tTime);
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> toFolderListNames;
|
|
|
|
|
|
|
|
|
|
int globCount;
|
|
|
|
|
char** filesInPath = SDL_GlobDirectory(toPath.c_str(), "*", 0, &globCount);
|
|
|
|
|
if(filesInPath) {
|
|
|
|
|
for(int i = 0; i < globCount; i++) {
|
|
|
|
|
std::filesystem::path p(filesInPath[i]);
|
|
|
|
|
toFolderListNames.emplace_back(p.filename().stem());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
SDL_CreateDirectory(toPath.string().c_str());
|
|
|
|
|
|
|
|
|
|
for(const FileInfo& f : fileList) {
|
|
|
|
|
if(f.selected) {
|
|
|
|
|
std::string newFileName = ensure_string_unique(toFolderListNames, f.fileName);
|
|
|
|
|
std::filesystem::path filePath = fromPath / (f.fileName + "." + World::FILE_EXTENSION);
|
|
|
|
|
std::filesystem::path thumbnailPath = fromPath / (f.fileName + ".jpg");
|
|
|
|
|
std::filesystem::path newFilePath = toPath / (newFileName + "." + World::FILE_EXTENSION);
|
|
|
|
|
std::filesystem::path newThumbnailPath = toPath / (newFileName + ".jpg");
|
|
|
|
|
SDL_RenamePath(filePath.string().c_str(), newFilePath.string().c_str());
|
|
|
|
|
SDL_RenamePath(thumbnailPath.string().c_str(), newThumbnailPath.string().c_str());
|
|
|
|
|
switch(trashMoveType) {
|
|
|
|
|
case TrashMoveType::NONE:
|
|
|
|
|
break;
|
|
|
|
|
case TrashMoveType::MOVE_TO_TRASH:
|
|
|
|
|
trashInfo.files[newFileName] = TrashInfo::TrashFile{
|
|
|
|
|
.trashTime = currentTime
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case TrashMoveType::MOVE_OUT_OF_TRASH:
|
|
|
|
|
trashInfo.files.erase(f.fileName);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-23 22:22:43 +03:00
|
|
|
void FileSelectScreen::duplicate_selected_files(const std::filesystem::path& inPath) {
|
|
|
|
|
std::vector<std::string> toFolderListNames;
|
|
|
|
|
|
|
|
|
|
int globCount;
|
|
|
|
|
char** filesInPath = SDL_GlobDirectory(inPath.c_str(), "*", 0, &globCount);
|
|
|
|
|
if(filesInPath) {
|
|
|
|
|
for(int i = 0; i < globCount; i++) {
|
|
|
|
|
std::filesystem::path p(filesInPath[i]);
|
|
|
|
|
toFolderListNames.emplace_back(p.filename().stem());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
SDL_CreateDirectory(inPath.string().c_str());
|
|
|
|
|
|
|
|
|
|
for(const FileInfo& f : fileList) {
|
|
|
|
|
if(f.selected) {
|
|
|
|
|
std::string newFileName = ensure_string_unique(toFolderListNames, f.fileName);
|
|
|
|
|
std::filesystem::path filePath = inPath / (f.fileName + World::DOT_FILE_EXTENSION);
|
|
|
|
|
std::filesystem::path thumbnailPath = inPath / (f.fileName + ".jpg");
|
|
|
|
|
std::filesystem::path newFilePath = inPath / (newFileName + "." + World::FILE_EXTENSION);
|
|
|
|
|
std::filesystem::path newThumbnailPath = inPath / (newFileName + ".jpg");
|
|
|
|
|
SDL_CopyFile(filePath.string().c_str(), newFilePath.string().c_str());
|
|
|
|
|
SDL_CopyFile(thumbnailPath.string().c_str(), newThumbnailPath.string().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-23 20:56:11 +03:00
|
|
|
void FileSelectScreen::delete_selected_files_in_trash() {
|
|
|
|
|
for(const FileInfo& f : fileList) {
|
|
|
|
|
if(f.selected) {
|
|
|
|
|
std::filesystem::path filePath = trashPath / (f.fileName + World::DOT_FILE_EXTENSION);
|
|
|
|
|
std::filesystem::path thumbnailPath = trashPath / (f.fileName + ".jpg");
|
|
|
|
|
SDL_RemovePath(filePath.string().c_str());
|
|
|
|
|
SDL_RemovePath(thumbnailPath.string().c_str());
|
|
|
|
|
trashInfo.files.erase(f.fileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileSelectScreen::edit_action_bar() {
|
|
|
|
|
auto& gui = main.g.gui;
|
2026-04-24 11:07:15 +03:00
|
|
|
if(actionBarOpenAnim->get_val()) {
|
|
|
|
|
gui.element<LayoutElement>("edit action bar", [&](LayoutElement*, const Clay_ElementId& lId) {
|
|
|
|
|
CLAY(lId, {
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(50 * actionBarOpenAnim->get_val())},
|
|
|
|
|
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
|
|
|
|
|
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
|
|
|
|
},
|
|
|
|
|
.backgroundColor = convert_vec4<Clay_Color>(gui.io.theme->backColor1),
|
|
|
|
|
}) {
|
|
|
|
|
if(actionBarOpenAnim->is_at_end()) {
|
|
|
|
|
if(selectedMenu == SelectedMenu::FILES) {
|
|
|
|
|
edit_action_bar_button("trash", "data/icons/trash.svg", "Trash", [&] {
|
|
|
|
|
move_selected_files(savePath, trashPath, TrashMoveType::MOVE_TO_TRASH);
|
|
|
|
|
update_file_list(fileList, savePath, false);
|
|
|
|
|
editMode = false;
|
|
|
|
|
});
|
|
|
|
|
edit_action_bar_button("duplicate", "data/icons/RemixIcon/file-copy-line.svg", "Duplicate", [&] {
|
|
|
|
|
duplicate_selected_files(savePath);
|
|
|
|
|
update_file_list(fileList, savePath, false);
|
|
|
|
|
editMode = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if(selectedMenu == SelectedMenu::TRASH) {
|
|
|
|
|
edit_action_bar_button("restore", "data/icons/RemixIcon/refresh-line.svg", "Restore", [&] {
|
|
|
|
|
move_selected_files(trashPath, savePath, TrashMoveType::MOVE_OUT_OF_TRASH);
|
|
|
|
|
update_file_list(fileList, trashPath, true);
|
|
|
|
|
editMode = false;
|
|
|
|
|
});
|
|
|
|
|
edit_action_bar_button("delete", "data/icons/trash.svg", "Delete", [&] {
|
|
|
|
|
delete_selected_files_in_trash();
|
|
|
|
|
update_file_list(fileList, trashPath, true);
|
|
|
|
|
editMode = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-23 20:56:11 +03:00
|
|
|
}
|
2026-04-24 11:07:15 +03:00
|
|
|
});
|
|
|
|
|
}
|
2026-04-23 20:56:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileSelectScreen::edit_title_bar() {
|
2026-04-22 17:40:58 +03:00
|
|
|
auto& gui = main.g.gui;
|
2026-04-27 00:42:25 +03:00
|
|
|
window_fill_side_bar(gui, "edit top toolbar", {
|
|
|
|
|
.dir = WindowFillSideBarConfig::Direction::TOP,
|
|
|
|
|
.backgroundColor = gui.io.theme->backColor0
|
|
|
|
|
}, [&] {
|
|
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)},
|
|
|
|
|
.childGap = gui.io.theme->childGap1,
|
|
|
|
|
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER },
|
|
|
|
|
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
2026-04-23 20:56:11 +03:00
|
|
|
}
|
2026-04-27 00:42:25 +03:00
|
|
|
}) {
|
|
|
|
|
svg_icon_button(gui, "close edit mode button", "data/icons/close.svg", {
|
|
|
|
|
.drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
|
|
|
|
|
.onClick = [&] {
|
|
|
|
|
editMode = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
mutable_text_label(gui, "select files label", (numberOfSelectedEntries == 0) ? "Select files" : (std::to_string(numberOfSelectedEntries) + " selected"));
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-04-23 20:56:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileSelectScreen::title_bar() {
|
|
|
|
|
auto& gui = main.g.gui;
|
2026-04-26 18:20:37 +03:00
|
|
|
window_fill_side_bar(gui, "top toolbar", {
|
|
|
|
|
.dir = WindowFillSideBarConfig::Direction::TOP,
|
|
|
|
|
.backgroundColor = gui.io.theme->backColor0
|
|
|
|
|
}, [&] {
|
2026-04-23 20:56:11 +03:00
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
2026-04-26 18:20:37 +03:00
|
|
|
.childGap = gui.io.theme->childGap1,
|
|
|
|
|
.childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER},
|
|
|
|
|
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
2026-04-23 20:56:11 +03:00
|
|
|
}
|
2026-04-26 18:20:37 +03:00
|
|
|
}) {
|
|
|
|
|
svg_icon_button(gui, "main settings button", "data/icons/menu.svg", {
|
2026-04-23 20:56:11 +03:00
|
|
|
.drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
|
|
|
|
|
.onClick = [&] {
|
2026-04-26 18:20:37 +03:00
|
|
|
mainMenuOpenAnim->animation_trigger();
|
2026-04-23 20:56:11 +03:00
|
|
|
}
|
|
|
|
|
});
|
2026-04-26 18:20:37 +03:00
|
|
|
switch(selectedMenu) {
|
|
|
|
|
case SelectedMenu::FILES:
|
|
|
|
|
mutable_text_label(gui, "main screen header text", "Files");
|
|
|
|
|
break;
|
|
|
|
|
case SelectedMenu::TRASH:
|
|
|
|
|
mutable_text_label(gui, "main screen header text", "Trash");
|
|
|
|
|
break;
|
|
|
|
|
case SelectedMenu::SETTINGS:
|
|
|
|
|
mutable_text_label(gui, "main screen header text", "Settings");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
|
|
|
|
}
|
|
|
|
|
}) {}
|
|
|
|
|
if(selectedMenu == SelectedMenu::FILES || selectedMenu == SelectedMenu::TRASH) {
|
|
|
|
|
SelectableButton* moreButton = svg_icon_button(gui, "more settings button", "data/icons/RemixIcon/more-2-fill.svg", {
|
|
|
|
|
.drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
|
|
|
|
|
.onClick = [&] {
|
|
|
|
|
moreOptionsMenu = MoreOptionsMenu::MAIN;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if(moreButton->get_bb().has_value() && moreOptionsMenu != MoreOptionsMenu::CLOSED) {
|
|
|
|
|
gui.set_z_index(gui.get_z_index() + 10, [&] {
|
|
|
|
|
gui.element<PositionAdjustingPopupMenu>("more options popup", moreButton->get_bb().value().top_right(), [&] {
|
|
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = {.width = CLAY_SIZING_FIT(200), .height = CLAY_SIZING_FIT(0)},
|
|
|
|
|
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
|
|
|
|
},
|
|
|
|
|
.backgroundColor = convert_vec4<Clay_Color>(gui.io.theme->backColor1),
|
|
|
|
|
.cornerRadius = CLAY_CORNER_RADIUS(4)
|
|
|
|
|
}) {
|
|
|
|
|
if(moreOptionsMenu == MoreOptionsMenu::MAIN) {
|
|
|
|
|
text_transparent_option_button("Edit", "Edit", [&] {
|
|
|
|
|
moreOptionsMenu = MoreOptionsMenu::CLOSED;
|
|
|
|
|
start_edit_mode();
|
|
|
|
|
});
|
|
|
|
|
text_transparent_option_button("View", "View", [&] {
|
|
|
|
|
moreOptionsMenu = MoreOptionsMenu::VIEW;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if(moreOptionsMenu == MoreOptionsMenu::VIEW) {
|
|
|
|
|
text_transparent_option_button("Large Grid", "Large Grid", [&] {
|
|
|
|
|
fileViewType = FileViewType::LARGE_GRID;
|
|
|
|
|
moreOptionsMenu = MoreOptionsMenu::CLOSED;
|
|
|
|
|
});
|
|
|
|
|
text_transparent_option_button("Medium Grid", "Medium Grid", [&] {
|
|
|
|
|
fileViewType = FileViewType::MEDIUM_GRID;
|
|
|
|
|
moreOptionsMenu = MoreOptionsMenu::CLOSED;
|
|
|
|
|
});
|
|
|
|
|
text_transparent_option_button("Small Grid", "Small Grid", [&] {
|
|
|
|
|
fileViewType = FileViewType::SMALL_GRID;
|
|
|
|
|
moreOptionsMenu = MoreOptionsMenu::CLOSED;
|
|
|
|
|
});
|
|
|
|
|
text_transparent_option_button("List", "List", [&] {
|
|
|
|
|
fileViewType = FileViewType::LIST;
|
|
|
|
|
moreOptionsMenu = MoreOptionsMenu::CLOSED;
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-04-23 20:56:11 +03:00
|
|
|
}
|
2026-04-26 18:20:37 +03:00
|
|
|
}, LayoutElement::Callbacks{
|
|
|
|
|
.mouseButton = [&](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& m) {
|
|
|
|
|
if(!l->mouseHovering && m.down) {
|
2026-04-23 20:56:11 +03:00
|
|
|
moreOptionsMenu = MoreOptionsMenu::CLOSED;
|
2026-04-26 18:20:37 +03:00
|
|
|
main.g.gui.set_to_layout();
|
|
|
|
|
}
|
2026-04-23 20:56:11 +03:00
|
|
|
}
|
2026-04-26 18:20:37 +03:00
|
|
|
});
|
2026-04-23 20:56:11 +03:00
|
|
|
});
|
2026-04-26 18:20:37 +03:00
|
|
|
}
|
2026-04-23 20:56:11 +03:00
|
|
|
}
|
|
|
|
|
}
|
2026-04-26 18:20:37 +03:00
|
|
|
});
|
2026-04-22 17:40:58 +03:00
|
|
|
}
|
|
|
|
|
|
2026-04-23 20:56:11 +03:00
|
|
|
void FileSelectScreen::text_transparent_option_button(const char* id, const char* text, const std::function<void()>& onClick) {
|
|
|
|
|
auto& gui = main.g.gui;
|
|
|
|
|
text_button(gui, id, text, {
|
|
|
|
|
.drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
|
|
|
|
|
.wide = true,
|
|
|
|
|
.centered = false,
|
|
|
|
|
.onClick = onClick
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileSelectScreen::icon_text_transparent_option_selected_button(const char* id, const std::string& svgPath, const char* text, bool isSelected, const std::function<void()>& onClick) {
|
|
|
|
|
auto& gui = main.g.gui;
|
|
|
|
|
text_button_with_icon(gui, id, svgPath, text, {
|
|
|
|
|
.drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
|
|
|
|
|
.isSelected = isSelected,
|
|
|
|
|
.wide = true,
|
|
|
|
|
.centered = false,
|
|
|
|
|
.onClick = onClick
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 17:40:58 +03:00
|
|
|
void FileSelectScreen::main_menu() {
|
2026-04-24 11:07:15 +03:00
|
|
|
if(!mainMenuOpenAnim->is_at_start()) {
|
|
|
|
|
auto& gui = main.g.gui;
|
2026-04-26 18:20:37 +03:00
|
|
|
window_fill_side_bar(gui, "main menu popup", {
|
|
|
|
|
.dir = WindowFillSideBarConfig::Direction::LEFT,
|
|
|
|
|
.backgroundColor = gui.io.theme->backColor0
|
|
|
|
|
}, [&] {
|
|
|
|
|
gui.element<LayoutElement>("inner main menu element", [&] (LayoutElement*, const Clay_ElementId& lId) {
|
|
|
|
|
CLAY(lId, {
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = {.width = CLAY_SIZING_FIXED(300.0f * mainMenuOpenAnim->get_val()), .height = CLAY_SIZING_GROW(0)},
|
|
|
|
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
|
|
|
|
},
|
|
|
|
|
}) {
|
|
|
|
|
if(mainMenuOpenAnim->is_at_end()) {
|
|
|
|
|
icon_text_transparent_option_selected_button("Files", "data/icons/folder.svg", "Files", selectedMenu == SelectedMenu::FILES, [&] {
|
|
|
|
|
selectedMenu = SelectedMenu::FILES;
|
|
|
|
|
update_file_list(fileList, savePath, false);
|
|
|
|
|
mainMenuOpenAnim->animation_trigger_reverse();
|
|
|
|
|
});
|
|
|
|
|
icon_text_transparent_option_selected_button("Trash", "data/icons/trash.svg", "Trash", selectedMenu == SelectedMenu::TRASH, [&] {
|
|
|
|
|
selectedMenu = SelectedMenu::TRASH;
|
|
|
|
|
update_file_list(fileList, trashPath, true);
|
|
|
|
|
mainMenuOpenAnim->animation_trigger_reverse();
|
|
|
|
|
});
|
|
|
|
|
icon_text_transparent_option_selected_button("Settings", "data/icons/RemixIcon/settings-3-line.svg", "Settings", selectedMenu == SelectedMenu::SETTINGS, [&] {
|
|
|
|
|
selectedMenu = SelectedMenu::SETTINGS;
|
|
|
|
|
mainMenuOpenAnim->animation_trigger_reverse();
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-04-24 11:07:15 +03:00
|
|
|
}
|
2026-04-26 18:20:37 +03:00
|
|
|
});
|
2026-04-24 11:07:15 +03:00
|
|
|
});
|
|
|
|
|
}
|
2026-04-22 17:40:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileSelectScreen::file_view() {
|
|
|
|
|
auto& gui = main.g.gui;
|
2026-04-23 20:56:11 +03:00
|
|
|
std::filesystem::path folderPath = (selectedMenu == SelectedMenu::TRASH) ? trashPath : savePath;
|
|
|
|
|
|
2026-04-23 21:49:13 +03:00
|
|
|
auto fileButton = [&] (size_t i, bool isList, const Vector2f& iconSize) {
|
|
|
|
|
std::filesystem::path filePath = folderPath / (fileList[i].fileName + "." + World::FILE_EXTENSION);
|
|
|
|
|
gui.element<SelectableButton>("file button", SelectableButton::Data{
|
|
|
|
|
.isSelected = editMode && fileList[i].selected,
|
|
|
|
|
.onClick = [&, filePath, i] {
|
|
|
|
|
if(editMode)
|
|
|
|
|
fileList[i].selected = !fileList[i].selected;
|
|
|
|
|
else {
|
|
|
|
|
CustomEvents::emit_event<CustomEvents::OpenInfiniPaintFileEvent>({
|
|
|
|
|
.isClient = false,
|
|
|
|
|
.filePathSource = filePath
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
.innerContent = [&](const SelectableButton::InnerContentCallbackParameters& c){
|
|
|
|
|
if(isList) {
|
|
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
|
|
|
|
.padding = CLAY_PADDING_ALL(gui.io.theme->padding1),
|
|
|
|
|
.childGap = 6,
|
|
|
|
|
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER },
|
|
|
|
|
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
|
|
|
|
}
|
|
|
|
|
}) {
|
|
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = { .sizing = {.width = CLAY_SIZING_FIXED(iconSize.x()), .height = CLAY_SIZING_FIXED(iconSize.y()) }},
|
|
|
|
|
}) {
|
|
|
|
|
gui.element<ImageDisplay>("ico", ImageDisplay::Data{
|
|
|
|
|
.imgPath = folderPath / (fileList[i].fileName + ".jpg"),
|
|
|
|
|
.radius = 20
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
2026-04-25 19:01:19 +03:00
|
|
|
.sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)},
|
2026-04-23 21:49:13 +03:00
|
|
|
.childGap = 6,
|
|
|
|
|
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER },
|
|
|
|
|
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
|
|
|
|
}
|
|
|
|
|
}) {
|
|
|
|
|
text_label(gui, fileList[i].fileName);
|
|
|
|
|
text_label_light(gui, fileList[i].lastModifyDate);
|
|
|
|
|
}
|
2026-04-23 20:56:11 +03:00
|
|
|
}
|
2026-04-23 21:49:13 +03:00
|
|
|
}
|
|
|
|
|
else {
|
2026-04-22 17:40:58 +03:00
|
|
|
CLAY_AUTO_ID({
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
|
|
|
|
.padding = CLAY_PADDING_ALL(gui.io.theme->padding1),
|
|
|
|
|
.childGap = 6,
|
|
|
|
|
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
|
|
|
|
|
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
|
|
|
|
}
|
|
|
|
|
}) {
|
|
|
|
|
CLAY_AUTO_ID({
|
2026-04-23 20:56:11 +03:00
|
|
|
.layout = { .sizing = {.width = CLAY_SIZING_FIXED(iconSize.x()), .height = CLAY_SIZING_FIXED(iconSize.y()) }},
|
2026-04-22 17:40:58 +03:00
|
|
|
}) {
|
|
|
|
|
gui.element<ImageDisplay>("ico", ImageDisplay::Data{
|
2026-04-23 20:56:11 +03:00
|
|
|
.imgPath = folderPath / (fileList[i].fileName + ".jpg"),
|
2026-04-22 17:40:58 +03:00
|
|
|
.radius = 20
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-04-25 19:01:19 +03:00
|
|
|
gui.element<LayoutElement>("file name layout elem", [&](LayoutElement* l, const Clay_ElementId& lId) {
|
|
|
|
|
CLAY(lId, {
|
|
|
|
|
.layout = {
|
|
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)},
|
|
|
|
|
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP },
|
|
|
|
|
},
|
|
|
|
|
}) {
|
|
|
|
|
if(l->get_bb()) {
|
|
|
|
|
RichText::TextData fileNameText;
|
|
|
|
|
fileNameText.paragraphs.emplace_back(fileList[i].fileName);
|
|
|
|
|
gui.element<TextParagraph>("file name", TextParagraph::Data{
|
|
|
|
|
.text = fileNameText,
|
|
|
|
|
.maxGrowX = l->get_bb().value().width(),
|
|
|
|
|
.maxGrowY = 0.0f
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-04-22 17:40:58 +03:00
|
|
|
text_label_light(gui, fileList[i].lastModifyDate);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-23 21:49:13 +03:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if(fileViewType == FileViewType::LIST) {
|
|
|
|
|
scroll_area_many_entries(gui, "File selector list", ScrollBarManyEntriesOptions{
|
|
|
|
|
.entryHeight = 150.0f,
|
|
|
|
|
.entryCount = fileList.size(),
|
|
|
|
|
.clipHorizontal = true,
|
2026-04-25 19:01:19 +03:00
|
|
|
.xElementSize = CLAY_SIZING_FIT(0),
|
2026-04-23 21:49:13 +03:00
|
|
|
.elementContent = [&](size_t i) {
|
|
|
|
|
fileButton(i, true, Vector2f{100.0f, 100.0f});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Vector2f entrySize{0.0f, 0.0f};
|
|
|
|
|
Vector2f iconSize{0.0f, 0.0f};
|
|
|
|
|
switch(fileViewType) {
|
|
|
|
|
case FileViewType::LARGE_GRID:
|
|
|
|
|
entrySize = {200.0f, 220.0f};
|
|
|
|
|
iconSize = {150.0f, 150.0f};
|
|
|
|
|
break;
|
|
|
|
|
case FileViewType::MEDIUM_GRID:
|
|
|
|
|
entrySize = {170.0f, 190.0f};
|
|
|
|
|
iconSize = {120.0f, 120.0f};
|
|
|
|
|
break;
|
|
|
|
|
case FileViewType::SMALL_GRID:
|
|
|
|
|
entrySize = {140.0f, 160.0f};
|
|
|
|
|
iconSize = {90.0f, 90.0f};
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2026-04-22 17:40:58 +03:00
|
|
|
}
|
2026-04-23 21:49:13 +03:00
|
|
|
gui.element<GridScrollArea>("File selector grid", GridScrollArea::Options{
|
|
|
|
|
.entryWidth = entrySize.x(),
|
|
|
|
|
.childAlignmentX = CLAY_ALIGN_X_LEFT,
|
|
|
|
|
.entryHeight = entrySize.y(),
|
|
|
|
|
.entryCount = fileList.size(),
|
|
|
|
|
.elementContent = [&](size_t i) {
|
|
|
|
|
fileButton(i, false, iconSize);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-04-22 17:40:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileSelectScreen::menu_black_box() {
|
|
|
|
|
auto& gui = main.g.gui;
|
2026-04-24 11:07:15 +03:00
|
|
|
if(!mainMenuOpenAnim->is_at_start()) {
|
2026-04-22 17:40:58 +03:00
|
|
|
gui.set_z_index(gui.get_z_index() + 1, [&] {
|
|
|
|
|
gui.element<LayoutElement>("file list disable fill", [&] (LayoutElement* l, const Clay_ElementId& lId) {
|
|
|
|
|
CLAY(lId, {
|
2026-04-18 20:51:45 +03:00
|
|
|
.layout = {
|
2026-04-22 17:40:58 +03:00
|
|
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
|
|
|
|
},
|
2026-04-24 11:07:15 +03:00
|
|
|
.backgroundColor = {0.0f, 0.0f, 0.0f, 0.6f * mainMenuOpenAnim->get_val()},
|
2026-04-22 17:40:58 +03:00
|
|
|
.floating = {
|
|
|
|
|
.zIndex = gui.get_z_index(),
|
|
|
|
|
.attachPoints = {
|
|
|
|
|
.element = CLAY_ATTACH_POINT_LEFT_TOP,
|
|
|
|
|
.parent = CLAY_ATTACH_POINT_LEFT_TOP
|
|
|
|
|
},
|
|
|
|
|
.attachTo = CLAY_ATTACH_TO_PARENT
|
2026-04-18 20:51:45 +03:00
|
|
|
}
|
|
|
|
|
}) {
|
2026-04-22 17:40:58 +03:00
|
|
|
}
|
|
|
|
|
}, LayoutElement::Callbacks{
|
|
|
|
|
.mouseButton = [&] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& m) {
|
|
|
|
|
if(m.down && m.button == InputManager::MouseButton::LEFT && l->mouseHovering) {
|
2026-04-24 11:07:15 +03:00
|
|
|
mainMenuOpenAnim->animation_trigger_reverse();
|
2026-04-22 17:40:58 +03:00
|
|
|
gui.set_to_layout();
|
2026-04-19 17:44:48 +03:00
|
|
|
}
|
2026-04-18 20:51:45 +03:00
|
|
|
}
|
2026-04-22 17:40:58 +03:00
|
|
|
});
|
2026-04-18 20:51:45 +03:00
|
|
|
});
|
2026-04-17 19:32:49 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-23 20:56:11 +03:00
|
|
|
void FileSelectScreen::start_edit_mode() {
|
|
|
|
|
for(auto& f : fileList)
|
|
|
|
|
f.selected = false;
|
|
|
|
|
editMode = true;
|
2026-04-19 17:44:48 +03:00
|
|
|
}
|
|
|
|
|
|
2026-04-22 21:40:01 +03:00
|
|
|
void FileSelectScreen::input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile) {
|
|
|
|
|
main.create_new_tab(openFile);
|
2026-04-26 13:21:05 +03:00
|
|
|
main.screen = std::make_unique<PhoneDrawingProgramScreen>(main);
|
2026-04-22 21:40:01 +03:00
|
|
|
}
|
|
|
|
|
|
2026-04-17 19:32:49 +03:00
|
|
|
void FileSelectScreen::draw(SkCanvas* canvas) {
|
2026-04-24 01:28:38 +03:00
|
|
|
canvas->clear(main.g.gui.io.theme->backColor0);
|
2026-04-17 19:32:49 +03:00
|
|
|
}
|
2026-04-23 20:56:11 +03:00
|
|
|
|
|
|
|
|
FileSelectScreen::~FileSelectScreen() {
|
|
|
|
|
nlohmann::json j;
|
|
|
|
|
nlohmann::to_json(j, trashInfo);
|
|
|
|
|
std::string saveJson = nlohmann::to_string(j);
|
|
|
|
|
SDL_SaveFile(trashInfoPath.string().c_str(), saveJson.c_str(), saveJson.size());
|
|
|
|
|
}
|