Zachary Hall
c5265450d9
The open dialog now fills the window The theme selector now has a background again.
53 lines
No EOL
1.4 KiB
C++
53 lines
No EOL
1.4 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include <vector>
|
|
#include <filesystem>
|
|
#include <optional>
|
|
#ifdef PORTALS
|
|
#include <libportal/portal.h>
|
|
#include <libportal/filechooser.h>
|
|
#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<ImVec2> window_pos;
|
|
ImVec2 window_size;
|
|
bool open = false;
|
|
bool save;
|
|
ImGui::FileBrowser fallback;
|
|
path pwd;
|
|
string filter_name;
|
|
vector<string> filters;
|
|
string title;
|
|
optional<path> selected;
|
|
public:
|
|
void SetTitle(string title);
|
|
void SetTypeFilters(string name, vector<string> 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();
|
|
}; |