From 500c906b1b26ab4acd1eb9feb9c5bd359c9e2922 Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Sun, 16 Oct 2022 09:09:33 +0200 Subject: [PATCH 1/2] Compatibility for mac: home is at /Users --- ImFileDialog.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ImFileDialog.cpp b/ImFileDialog.cpp index 53832d9..bf969fc 100644 --- a/ImFileDialog.cpp +++ b/ImFileDialog.cpp @@ -413,8 +413,11 @@ namespace ifd { uid = geteuid(); pw = getpwuid(uid); if (pw) { +#ifdef __APPLE__ + std::string homePath = "/Users/" + std::string(pw->pw_name); +#else std::string homePath = "/home/" + std::string(pw->pw_name); - +#endif if (std::filesystem::exists(homePath, ec)) quickAccess->Children.push_back(new FileTreeNode(homePath)); if (std::filesystem::exists(homePath + "/Desktop", ec)) From 55640cc495cf46d2090c2d1f2428c353b93e904f Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Sun, 16 Oct 2022 09:10:22 +0200 Subject: [PATCH 2/2] Add details/icon/preview buttons + zoom slider * They are presented at the bottom of the window (to the left of Ok/Cancel) * The size of the widget is unchanged * Compatible with small window sizes Note: preview now starts at zoom=3 instead of 5 --- ImFileDialog.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/ImFileDialog.cpp b/ImFileDialog.cpp index bf969fc..cae1873 100644 --- a/ImFileDialog.cpp +++ b/ImFileDialog.cpp @@ -840,7 +840,7 @@ namespace ifd { } void FileDialog::m_refreshIconPreview() { - if (m_zoom >= 5.0f) { + if (m_zoom >= 3.0f) { if (m_previewLoader == nullptr) { m_previewLoaderRunning = true; m_previewLoader = new std::thread(&FileDialog::m_loadPreview, this); @@ -1386,7 +1386,31 @@ namespace ifd { } } - // buttons + // zoom + { + bool changed = false; + int zoom_int = (int)m_zoom; + changed |= ImGui::RadioButton("Details", & zoom_int, 1); + ImGui::SameLine(); + changed |= ImGui::RadioButton("Icons", & zoom_int, 2); + ImGui::SameLine(); + changed |= ImGui::RadioButton("Preview", & zoom_int, 3); + ImGui::SameLine(); + if (zoom_int >= 3) + { + ImGui::SameLine(); + ImGui::SetNextItemWidth(75.f); + changed |= ImGui::SliderInt("##Zoom", &zoom_int, 3, 30, ""); + } + if (changed) + { + m_zoom = (float) zoom_int; + m_refreshIconPreview(); + } + ImGui::SameLine(); + } + + // buttons float ok_cancel_width = GUI_ELEMENT_SIZE * 7; ImGui::SetCursorPosX(ImGui::GetWindowWidth() - ok_cancel_width); if (ImGui::Button(m_type == IFD_DIALOG_SAVE ? "Save" : "Open", ImVec2(ok_cancel_width / 2 - ImGui::GetStyle().ItemSpacing.x, 0.0f))) {