Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ImguiFileSystemDialog.h
Go to the documentation of this file.
1#pragma once
2
5
7
8#include <Common/primitive_type.h>
9#include <DataIO/FileSystem/Path.h>
10
11#include <cstddef>
12#include <vector>
13#include <string>
14#include <string_view>
15
16namespace ph::editor
17{
18
19class ImguiEditorUIProxy;
20
32
34{
35public:
36 static const char* const OPEN_FILE_TITLE;
37 static const char* const SAVE_FILE_TITLE;
38 static const char* const OPEN_FOLDER_TITLE;
39 static const char* const SAVE_FOLDER_TITLE;
40
41public:
43
48 void openPopup(
49 const char* popupName);
50
56 const char* popupName,
57 ImguiEditorUIProxy editorUI,
58 const ImguiFileSystemDialogParameters& params = {});
59
67 const char* popupName,
68 ImguiEditorUIProxy editorUI,
69 const ImVec2& dialogSize,
70 const ImguiFileSystemDialogParameters& params = {});
71
72 void clearSelection();
73
78 bool dialogClosed();
79
85 Path getSelectedDirectory() const;
86
92 Path getSelectedItem() const;
93
101 Path getSelectedTarget() const;
102
107 std::vector<Path> getSelectedItems() const;
108
113 bool hasSelectedDirectory() const;
114
119 bool hasSelectedItem() const;
120
121private:
122 void buildFileSystemDialogContent(
123 const ImVec2& dialogSize,
124 const ImguiFileSystemDialogParameters& params);
125
126 void buildFileSystemDialogTreeNodeRecursive(
127 FileSystemDirectoryEntry* baseEntry);
128
131 std::string_view getEntryItemNameWithoutDecorations(std::size_t itemIndex) const;
132
133 FileSystemExplorer m_explorer;
134 FileSystemDirectoryEntry* m_browsingEntry;
135 FileSystemDirectoryEntry* m_selectedEntry;
136 bool m_dialogClosedFlag;
137
138 imgui::StringCache m_fsDialogEntryPreviewBuffer;
139 imgui::StringCache m_fsDialogItemPreviewBuffer;
140 bool m_isEditingEntry;
141 bool m_isEditingItem;
142
143 // Cached for display
144 std::string m_fsDialogEntryPathName;
145 std::vector<std::string> m_fsDialogEntryItemNames;
146
147 std::vector<std::string> m_fsDialogRootNames;
148 std::size_t m_fsDialogSelectedRootIdx;
149 std::vector<Path> m_fsDialogEntryItems;
150 std::size_t m_fsDialogSelectedEntryItemIdx;
151 std::size_t m_fsDialogNumSelectedItems;
152 std::vector<uint8> m_fsDialogEntryItemSelection;
153};
154
155}// end namespace ph::editor
Definition ImguiEditorUIProxy.h:16
Definition ImguiFileSystemDialog.h:34
std::vector< Path > getSelectedItems() const
Get all selected items. Call after dialogClosed() for a complete result. If the dialog is not closed,...
Definition ImguiFileSystemDialog.cpp:245
void clearSelection()
Definition ImguiFileSystemDialog.cpp:159
static const char *const OPEN_FILE_TITLE
Definition ImguiFileSystemDialog.h:36
ImguiFileSystemDialog()
Definition ImguiFileSystemDialog.cpp:31
Path getSelectedTarget() const
Get the selected filesystem target. The result can be either the selected directory or a full path to...
Definition ImguiFileSystemDialog.cpp:232
static const char *const SAVE_FILE_TITLE
Definition ImguiFileSystemDialog.h:37
static const char *const SAVE_FOLDER_TITLE
Definition ImguiFileSystemDialog.h:39
bool dialogClosed()
Definition ImguiFileSystemDialog.cpp:174
Path getSelectedDirectory() const
Get the selected directory. Call after dialogClosed() for a complete result. If the dialog is not clo...
Definition ImguiFileSystemDialog.cpp:185
bool hasSelectedDirectory() const
Fast way to check whether a directory has been selected. Call after dialogClosed() for a complete res...
Definition ImguiFileSystemDialog.cpp:278
Path getSelectedItem() const
Get the selected item. Call after dialogClosed() for a complete result. If the dialog is not closed,...
Definition ImguiFileSystemDialog.cpp:208
void buildFileSystemDialogPopupModal(const char *popupName, ImguiEditorUIProxy editorUI, const ImguiFileSystemDialogParameters &params={})
Definition ImguiFileSystemDialog.cpp:78
void openPopup(const char *popupName)
Definition ImguiFileSystemDialog.cpp:53
static const char *const OPEN_FOLDER_TITLE
Definition ImguiFileSystemDialog.h:38
bool hasSelectedItem() const
Fast way to check whether an item has been selected. Call after dialogClosed() for a complete result....
Definition ImguiFileSystemDialog.cpp:289
Definition ph_editor.h:10
Definition ImguiFileSystemDialog.h:22
bool requiresItemSelection
Definition ImguiFileSystemDialog.h:27
bool requiresDirectorySelection
Definition ImguiFileSystemDialog.h:30
bool canSelectDirectory
Definition ImguiFileSystemDialog.h:24
bool canSelectItem
Definition ImguiFileSystemDialog.h:23