diff --git a/3rdparty/SoGLSL b/3rdparty/SoGLSL index f154be6..90d383b 160000 --- a/3rdparty/SoGLSL +++ b/3rdparty/SoGLSL @@ -1 +1 @@ -Subproject commit f154be62a7b61cb09c8c9912ebe5325d78a84f3f +Subproject commit 90d383b7521de1fd0f4dc3665b5a38d08f9a3443 diff --git a/src/Gui/MainFrame.cpp b/src/Gui/MainFrame.cpp index df6be40..b14f79c 100644 --- a/src/Gui/MainFrame.cpp +++ b/src/Gui/MainFrame.cpp @@ -83,6 +83,13 @@ #include +#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) || defined(__WIN64__) || defined(WIN64) || defined(_WIN64) || defined(_MSC_VER) +#include // for quick acces places +#else +#endif + +using namespace std::placeholders; + /////////////////////////////////////////////////////// //// STATIC /////////////////////////////////////////// /////////////////////////////////////////////////////// @@ -131,6 +138,8 @@ bool MainFrame::Init() { HelpManager::Instance()->Init("NOODLESPLATE"); UrlLibrarySystem::Instance()->Init(); + m_CreateDialogPlaces(); + LoadConfigFile("config.xml"); PathSystem::Instance()->Save(); // apply paths who was loaded before in LoadConfigFile @@ -300,6 +309,86 @@ void MainFrame::ShowAboutDialog() { puShowAboutDialog = true; } +void MainFrame::m_CreateDialogPlaces() { + const char* system_group_name = ICON_NDP_STAR " System"; + ImGuiFileDialog::Instance()->AddPlacesGroup(system_group_name, 1, false); + auto system_places_ptr = ImGuiFileDialog::Instance()->GetPlacesGroupPtr(system_group_name); + if (system_places_ptr != nullptr) { +#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) || defined(__WIN64__) || defined(WIN64) || defined(_WIN64) || defined(_MSC_VER) + + ////////////////////////////////////////////////// + //// SYSTEM QUICK ACCESS ///////////////////////// + ////////////////////////////////////////////////// + +#define addKnownFolderAsPlace(knownFolder, folderLabel, folderIcon) \ + { \ + PWSTR path = NULL; \ + HRESULT hr = SHGetKnownFolderPath(knownFolder, 0, NULL, &path); \ + if (SUCCEEDED(hr)) { \ + IGFD::FileStyle style; \ + style.icon = folderIcon; \ + auto place_path = IGFD::Utils::UTF8Encode(path); \ + system_places_ptr->AddPlace(folderLabel, place_path, false, style); \ + } \ + CoTaskMemFree(path); \ + } + addKnownFolderAsPlace(FOLDERID_Desktop, "Desktop", ICON_NDP2_DESKTOP_MAC); + addKnownFolderAsPlace(FOLDERID_Startup, "Startup", ICON_NDP2_HOME); + addKnownFolderAsPlace(FOLDERID_Downloads, "Downloads", ICON_NDP2_DOWNLOADS); + addKnownFolderAsPlace(FOLDERID_Pictures, "Pictures", ICON_NDP_PICTURE_O); + addKnownFolderAsPlace(FOLDERID_Music, "Music", ICON_NDP_MUSIC); + addKnownFolderAsPlace(FOLDERID_Videos, "Videos", ICON_NDP_VIDEO); +#undef addKnownFolderAsPlace + + ////////////////////////////////////////////////// + //// SYSTEM DEVICES ////////////////////////////// + ////////////////////////////////////////////////// + + const DWORD mydrives = 2048; + char lpBuffer[2048]; +#define mini(a, b) (((a) < (b)) ? (a) : (b)) + const DWORD countChars = mini(GetLogicalDriveStringsA(mydrives, lpBuffer), 2047); +#undef mini + if (countChars > 0U && countChars < 2049U) { + std::string var = std::string(lpBuffer, (size_t)countChars); + IGFD::Utils::ReplaceString(var, "\\", ""); + auto arr = IGFD::Utils::SplitStringToVector(var, '\0', false); + wchar_t szVolumeName[2048]; + std::string path; + std::string name; + for (auto& a : arr) { + path = a; + name.clear(); + std::wstring wpath = IGFD::Utils::UTF8Decode(a); + if (GetVolumeInformationW(wpath.c_str(), szVolumeName, 2048, NULL, NULL, NULL, NULL, 0)) { + name = IGFD::Utils::UTF8Encode(szVolumeName); + } + IGFD::FileStyle style; + style.icon = ICON_NDP_DRIVES; + system_places_ptr->AddPlace(path + " " + name, path + IGFD::Utils::GetPathSeparator(), false, style); + } + } +#else +#endif + system_places_ptr = nullptr; + } + + const char* local_group_name = "Local"; + ImGuiFileDialog::Instance()->AddPlacesGroup(local_group_name, 2, false); + auto local_places_ptr = ImGuiFileDialog::Instance()->GetPlacesGroupPtr(local_group_name); + if (local_places_ptr != nullptr) { + IGFD::FileStyle style; + style.icon = ICON_NDP_PICTURE_O; + local_places_ptr->AddPlace("Assets", "assets", false, style); + style.icon = ICON_NDP_FILE_TEXT_O; + local_places_ptr->AddPlace("Scripts", "scripts", false, style); + local_places_ptr = nullptr; + } + + const char* recent_group_name = "Recent"; + ImGuiFileDialog::Instance()->AddPlacesGroup(recent_group_name, 3, false); +} + void MainFrame::DrawSettingsMenu_Global() { if (ImGui::MenuItem("Settings Dialog", "")) { SettingsDlg::Instance()->OpenDialog(); @@ -765,8 +854,12 @@ void MainFrame::DrawMainMenuBar() { } if (ImGui::MenuItem(ICON_NDP2_FOLDER " Open")) { - ImGuiFileDialog::Instance()->OpenDialog("OpenFileDialog", "Open File", ".glsl", puOpenFileDialog.filePath, puOpenFileDialog.filePathName, - 1, nullptr, ImGuiFileDialogFlags_DisableThumbnailMode | ImGuiFileDialogFlags_Modal); + IGFD::FileDialogConfig config; + config.path = puOpenFileDialog.filePath; + config.filePathName = puOpenFileDialog.filePathName; + config.countSelectionMax = 1; + config.flags = ImGuiFileDialogFlags_DisableThumbnailMode | ImGuiFileDialogFlags_Modal; + ImGuiFileDialog::Instance()->OpenDialog("OpenFileDialog", "Open File", ".glsl", config); } if (MainBackend::Instance()->IsLoaded()) { @@ -796,9 +889,12 @@ void MainFrame::DrawMainMenuBar() { if (ImGui::BeginMenu(ICON_NDP2_IMPORT " Import")) { if (ImGui::BeginMenu("From File Type")) { if (ImGui::MenuItem(".json (ShaderToy Backup File)")) { - ImGuiFileDialog::Instance()->OpenDialog("OpenShaderToyBackupJsonFile", "Open ShaderToy Backup File", ".json", - puOpenFileDialog.filePath, puOpenFileDialog.filePathName, 1, nullptr, - ImGuiFileDialogFlags_DisableThumbnailMode | ImGuiFileDialogFlags_Modal); + IGFD::FileDialogConfig config; + config.path = puOpenFileDialog.filePath; + config.filePathName = puOpenFileDialog.filePathName; + config.countSelectionMax = 1; + config.flags = ImGuiFileDialogFlags_DisableThumbnailMode | ImGuiFileDialogFlags_Modal; + ImGuiFileDialog::Instance()->OpenDialog("OpenShaderToyBackupJsonFile", "Open ShaderToy Backup File", ".json", config); } if (ImGui::MenuItem(".xsha (wxShade)")) { @@ -826,12 +922,14 @@ void MainFrame::DrawMainMenuBar() { if (ImGui::BeginMenu(ICON_NDP2_UPLOAD " Export")) { if (ImGui::BeginMenu("Buffer")) { if (ImGui::MenuItem("To Picture File")) { - ImGuiFileDialog::Instance()->OpenDialogWithPane( - "SavePictureDialog", "Save Current Buffer to Picture File", ".png,.tga,.bmp,.hdr", puSavePictureDialog.filePath, - puSavePictureDialog.filePathName, - std::bind(&PictureExportSystem::ExportPictureDialogOptions, PictureExportSystem::Instance(), std::placeholders::_1, - std::placeholders::_2, std::placeholders::_3), - ImGuiFileDialogFlags_Modal); + IGFD::FileDialogConfig config; + config.path = puSavePictureDialog.filePath; + config.filePathName = puSavePictureDialog.filePathName; + config.countSelectionMax = 1; + config.sidePane = std::bind(&PictureExportSystem::ExportPictureDialogOptions, PictureExportSystem::Instance(), _1, _2, _3); + config.flags = ImGuiFileDialogFlags_Modal; + ImGuiFileDialog::Instance()->OpenDialog( + "SavePictureDialog", "Save Current Buffer to Picture File", ".png,.tga,.bmp,.hdr", config); } if (ImGui::BeginMenu("After Each Modif of Code")) { @@ -899,10 +997,13 @@ void MainFrame::DrawMainMenuBar() { auto displayShaderPtr = MainBackend::Instance()->puDisplay_RenderPack.lock(); if (displayShaderPtr && displayShaderPtr->GetShaderKey()) { if (ImGui::MenuItem(ICON_NDP_FLOPPY_O " Save As Template")) { - ImGuiFileDialog::Instance()->OpenDialogWithPane( - "NewFileDialog", "Save As Template", ".glsl", ImGuiFileDialog::Instance()->GetCurrentPath(), - displayShaderPtr->GetShaderKey()->puKey, nullptr, 0, 1, IGFDUserDatas("saveastemplate"), - ImGuiFileDialogFlags_DisableThumbnailMode | ImGuiFileDialogFlags_Modal); + IGFD::FileDialogConfig config; + config.path = ImGuiFileDialog::Instance()->GetCurrentPath(); + config.filePathName = displayShaderPtr->GetShaderKey()->puKey; + config.countSelectionMax = 1; + config.userDatas = IGFDUserDatas("saveastemplate"); + config.flags = ImGuiFileDialogFlags_DisableThumbnailMode | ImGuiFileDialogFlags_Modal; + ImGuiFileDialog::Instance()->OpenDialog("NewFileDialog", "Save As Template", ".glsl", config); } ImGui::Separator(); @@ -1059,11 +1160,14 @@ void MainFrame::DrawMainMenuBar() { void MainFrame::CreateNewShader(std::string vType, const std::string& vFilePathName) { const auto filePathName = FileHelper::Instance()->CorrectSlashTypeForFilePathName(vFilePathName); - puNewFileDialog.tgt_ext = vType; puNewFileDialog.filePathName = filePathName; - ImGuiFileDialog::Instance()->OpenDialog("NewFileDialog", "New File", ".glsl", puNewFileDialog.filePath, puNewFileDialog.filePathName, 1, nullptr, - ImGuiFileDialogFlags_DisableThumbnailMode | ImGuiFileDialogFlags_Modal); + IGFD::FileDialogConfig config; + config.path = puNewFileDialog.filePath; + config.filePathName = puNewFileDialog.filePathName; + config.countSelectionMax = 1; + config.flags = ImGuiFileDialogFlags_DisableThumbnailMode | ImGuiFileDialogFlags_Modal; + ImGuiFileDialog::Instance()->OpenDialog("NewFileDialog", "New File", ".glsl", config); } /////////////////////////////////////////////////////// @@ -1085,7 +1189,7 @@ std::string MainFrame::getXml(const std::string& vOffset, const std::string& vUs str += puForkFileDialog.getXml(vOffset, vUserDatas); str += vOffset + "" + ct::toStr(puShowDebug ? "true" : "false") + "\n"; str += vOffset + "" + ct::toStr(puConsoleGuiVisiblity ? "true" : "false") + "\n"; - str += vOffset + "" + ImGuiFileDialog::Instance()->SerializeBookmarks() + "\n"; + str += vOffset + "" + ImGuiFileDialog::Instance()->SerializePlaces() + "\n"; str += vOffset + "" + ct::toStr(Logger::Instance()->ConsoleVerbose ? "true" : "false") + "\n"; str += vOffset + "" + MainBackend::sCurrentFileLoaded + "\n"; @@ -1142,8 +1246,8 @@ bool MainFrame::setFromXml(tinyxml2::XMLElement* vElem, tinyxml2::XMLElement* vP puFileToLoad = ct::fvariant(strValue).GetS(); if (strName == "debug") puShowDebug = ct::ivariant(strValue).GetB(); - if (strName == "igfd_bookmarks") - ImGuiFileDialog::Instance()->DeserializeBookmarks(strValue); + if (strName == "igfd_places") + ImGuiFileDialog::Instance()->DeserializePlaces(strValue); } LayoutManager::Instance()->setFromXml(vElem, vParent, vUserDatas); diff --git a/src/Gui/MainFrame.h b/src/Gui/MainFrame.h index 0d08c1e..e0d6e07 100644 --- a/src/Gui/MainFrame.h +++ b/src/Gui/MainFrame.h @@ -154,6 +154,7 @@ class MainFrame : public conf::ConfigAbstract void OpenImportBar(std::string vUrl = ""); private: // imgui + void m_CreateDialogPlaces(); void DrawSettingsMenu_Global(); // Settings menu Global bool DrawImportBar(); bool DrawErrorDialog(); diff --git a/src/Headers/CustomImGuiFileDialogConfig.h b/src/Headers/CustomImGuiFileDialogConfig.h index b9bf8df..75a36ff 100644 --- a/src/Headers/CustomImGuiFileDialogConfig.h +++ b/src/Headers/CustomImGuiFileDialogConfig.h @@ -59,7 +59,7 @@ #define DisplayMode_ThumbailsGrid_ButtonString ICON_NDP_FILE_GRID_THUMBNAILS //#define DisplayMode_ThumbailsGrid_ButtonHelp "Thumbnails Grid" -#define USE_EXPLORATION_BY_KEYS +//#define USE_EXPLORATION_BY_KEYS // this mapping by default is for GLFW but you can use another // Up key for explore to the top #define IGFD_KEY_UP ImGuiKey_UpArrow//GLFW_KEY_UP @@ -121,10 +121,20 @@ #define tableHeaderFileSizeString " Size" #define tableHeaderFileDateTimeString " Date" -#define USE_BOOKMARK -//#define bookmarkPaneWith 150.0f -//#define IMGUI_TOGGLE_BUTTON ToggleButton -#define bookmarksButtonString ICON_NDP_BOOKMARK -//#define bookmarksButtonHelpString "bookmark" -#define addBookmarkButtonString ICON_NDP_ADD -#define removeBookmarkButtonString ICON_NDP_REMOVE +#define USE_PLACES_FEATURE +// #define placesPaneWith 150.0f +// #define IMGUI_TOGGLE_BUTTON ToggleButton +#define placesButtonString ICON_NDP_BOOKMARK +// #define placesButtonHelpString "Places" +#define addPlaceButtonString ICON_NDP_ADD +#define removePlaceButtonString ICON_NDP_REMOVE + +// a group for bookmarks will be added by default, but you can also create it yourself and many more +#define USE_PLACES_BOOKMARKS +// #define PLACE_BOOKMARKS_NAME "Bookmarks" +// #define PLACE_BOOKMARKS_DISPLAY_ORDER 0 // to the first + +// a group for system devices (returned by IFileSystem), but you can also add yours +// #define USE_PLACES_DEVICES +// #define PLACE_DEVICES_NAME "Devices" +// #define PLACE_DEVICES_DISPLAY_ORDER 10 // to the end diff --git a/src/Headers/NoodlesPlateBuild.h b/src/Headers/NoodlesPlateBuild.h index 5f2b360..e17964a 100644 --- a/src/Headers/NoodlesPlateBuild.h +++ b/src/Headers/NoodlesPlateBuild.h @@ -1,7 +1,7 @@ #pragma once #define NoodlesPlate_Prefix "NoodlesPlate" -#define NoodlesPlate_BuildNumber 696 +#define NoodlesPlate_BuildNumber 708 #define NoodlesPlate_MinorNumber 7 #define NoodlesPlate_MajorNumber 0 -#define NoodlesPlate_BuildId "0.7.696" +#define NoodlesPlate_BuildId "0.7.708" diff --git a/src/Systems/PathSystem.cpp b/src/Systems/PathSystem.cpp index d96f0c1..150f046 100644 --- a/src/Systems/PathSystem.cpp +++ b/src/Systems/PathSystem.cpp @@ -55,9 +55,12 @@ std::string PathField::GetPath() void PathField::Draw(const char* vButtonLabel) { - if (ImGui::ContrastedButton(vButtonLabel, nullptr, nullptr, 250.0f)) - { - ImGuiFileDialog::Instance()->OpenDialog(vButtonLabel, "Select path", nullptr, m_Original_Path, 1, nullptr, ImGuiFileDialogFlags_Modal); + if (ImGui::ContrastedButton(vButtonLabel, nullptr, nullptr, 250.0f)) { + IGFD::FileDialogConfig config; + config.path = m_Original_Path; + config.countSelectionMax = 1; + config.flags = ImGuiFileDialogFlags_Modal; + ImGuiFileDialog::Instance()->OpenDialog(vButtonLabel, "Select path", nullptr, config); } ImGui::SameLine(); diff --git a/src/Systems/TemplateSystem.cpp b/src/Systems/TemplateSystem.cpp index 90c7394..39b05ed 100644 --- a/src/Systems/TemplateSystem.cpp +++ b/src/Systems/TemplateSystem.cpp @@ -30,6 +30,8 @@ #include #include +using namespace std::placeholders; + //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// @@ -253,11 +255,16 @@ bool TemplateSystem::DrawMenu() void TemplateSystem::CopyFromTemplate(TemplateFile vTemplateFile) { - puSelectedFileToCopy = vTemplateFile; - ImGuiFileDialog::Instance()->OpenDialogWithPane("NewFileDialog", "New File from template", ".glsl", - ImGuiFileDialog::Instance()->GetCurrentPath(), puSelectedFileToCopy.main, - std::bind(&TemplateSystem::SetNameOfBuffers, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), - 350, 1, IGFDUserDatas("createfromtemplate"), ImGuiFileDialogFlags_DisableThumbnailMode | ImGuiFileDialogFlags_Modal); + puSelectedFileToCopy = vTemplateFile; + IGFD::FileDialogConfig config; + config.path = ImGuiFileDialog::Instance()->GetCurrentPath(); + config.filePathName = puSelectedFileToCopy.main; + config.countSelectionMax = 1; + config.sidePane = std::bind(&TemplateSystem::SetNameOfBuffers, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); + config.sidePaneWidth = 350.0f; + config.userDatas = IGFDUserDatas("createfromtemplate"); + config.flags = ImGuiFileDialogFlags_DisableThumbnailMode | ImGuiFileDialogFlags_Modal; + ImGuiFileDialog::Instance()->OpenDialog("NewFileDialog", "New File from template", ".glsl", config); } void TemplateSystem::SetNameOfBuffers(const char * /*vFilter*/, IGFDUserDatas /*vUserDatas*/, bool *vCantContinue)