Implemented view change and trash in file selector, and moved more file IO to SDL file IO

This commit is contained in:
Yousef Khadadeh 2026-04-23 20:56:11 +03:00
parent b81b33660e
commit 9ea5a1eae9
15 changed files with 585 additions and 203 deletions

View file

@ -1,5 +1,7 @@
#pragma once
#include "Screen.hpp"
#include "nlohmann/json.hpp"
class FileSelectScreen : public Screen {
public:
@ -7,25 +9,76 @@ class FileSelectScreen : public Screen {
virtual void gui_layout_run() override;
virtual void draw(SkCanvas* canvas) override;
virtual void input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile) override;
struct TrashInfo {
struct TrashFile {
SDL_Time trashTime;
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(TrashFile, trashTime)
};
std::unordered_map<std::string, TrashFile> files;
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(TrashInfo, files)
};
~FileSelectScreen();
private:
std::filesystem::path savePath;
std::filesystem::path trashPath;
std::filesystem::path trashInfoPath;
struct FileInfo {
std::string fileName;
SDL_Time lastModifyTime;
std::string lastModifyDate;
bool selected = false;
};
const std::vector<FileInfo>& get_file_list(const std::string& folder);
std::optional<std::vector<FileInfo>> fileListOptional;
void update_file_list(std::vector<FileInfo>& fL, const std::filesystem::path& savePath, bool trashUpdate);
TrashInfo trashInfo;
std::vector<FileInfo> fileList;
void main_display();
void main_menu();
void file_view();
bool main_menu_fills_screen();
void file_view();
void file_view_edit();
void menu_black_box();
void title_bar(std::string_view title);
void edit_action_bar();
void edit_title_bar();
void title_bar();
void text_transparent_option_button(const char* id, const char* text, const std::function<void()>& onClick);
void icon_text_transparent_option_selected_button(const char* id, const std::string& svgPath, const char* text, bool isSelected, const std::function<void()>& onClick);
void edit_action_bar_button(const char* id, const std::string& svgPath, const char* text, const std::function<void()>& onClick);
enum class TrashMoveType {
NONE,
MOVE_TO_TRASH,
MOVE_OUT_OF_TRASH
};
void move_selected_files(const std::filesystem::path& fromPath, const std::filesystem::path& toPath, TrashMoveType trashMoveType);
void delete_selected_files_in_trash();
enum class FileViewType {
LARGE_GRID,
MEDIUM_GRID,
SMALL_GRID
} fileViewType = FileViewType::LARGE_GRID;
enum class MoreOptionsMenu {
CLOSED,
MAIN,
VIEW
} moreOptionsMenu = MoreOptionsMenu::CLOSED;
enum class SelectedMenu {
FILES,
TRASH,
SETTINGS
} selectedMenu = SelectedMenu::FILES;
void start_edit_mode();
size_t numberOfSelectedEntries;
bool editMode = false;
bool mainMenuOpen = false;
};