#pragma once #include "config.h" #include #include #include #include #ifdef PORTALS #include #include #endif #include "imgui.h" #include "imfilebrowser.h" using std::string; using std::vector; using std::optional; using namespace std::filesystem; class FileBrowser { #ifdef PORTALS XdpPortal *portal; GVariant *variant = NULL; GVariantType *type = NULL; GVariantType *inner_filter_type = NULL; GMainLoop *main_loop; GMainContext *main_context; static void FileBrowserOpenCallback(GObject *src, GAsyncResult *res, gpointer data); static void FileBrowserSaveCallback(GObject *src, GAsyncResult *res, gpointer data); #endif optional window_pos; ImVec2 window_size; bool open = false; bool save; ImGui::FileBrowser fallback; path pwd; string filter_name; vector filters; string title; optional selected; public: void SetTitle(string title); void SetTypeFilters(string name, vector filters); void SetPwd(path path); bool HasSelected(); path GetSelected(); void SetWindowSize(int width, int height); void SetWindowPos(int x, int y); void Display(); void Open(); void ClearSelected(); bool IsOpened(); FileBrowser(bool save, ImGuiFileBrowserFlags extra_fallback_flags = 0); ~FileBrowser(); };