Skip to content

Commit

Permalink
Increased version to 1.0.22. Disabled in-progress file-dialog support…
Browse files Browse the repository at this point in the history
…. Look for ENABLE_FILE_DIALOG_SUPPORT to re-enable.
  • Loading branch information
bluescan committed Jun 27, 2021
1 parent 897bfe5 commit dd818f5
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 36 deletions.
6 changes: 6 additions & 0 deletions Src/Dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ void Viewer::ShowCheatSheetPopup(bool* popen)
ImGui::Text("Ctrl-M"); ImGui::SameLine(); ImGui::SetCursorPosX(col); ImGui::Text("Save Multi-Frame Image");
ImGui::Text("N"); ImGui::SameLine(); ImGui::SetCursorPosX(col); ImGui::Text("Toggle Nav Bar");
ImGui::Text("S"); ImGui::SameLine(); ImGui::SetCursorPosX(col); ImGui::Text("Toggle Slideshow Counddown");

#ifdef ENABLE_FILE_DIALOG_SUPPORT
ImGui::Text("Ctrl-O"); ImGui::SameLine(); ImGui::SetCursorPosX(col); ImGui::Text("Open File...");
ImGui::Text("Alt-O"); ImGui::SameLine(); ImGui::SetCursorPosX(col); ImGui::Text("Open Dir...");
#endif

ImGui::Text("Ctrl-S"); ImGui::SameLine(); ImGui::SetCursorPosX(col); ImGui::Text("Save As...");
ImGui::Text("Alt-S"); ImGui::SameLine(); ImGui::SetCursorPosX(col); ImGui::Text("Save All...");
ImGui::Text("B"); ImGui::SameLine(); ImGui::SetCursorPosX(col); ImGui::Text("Basic Mode");
Expand Down
16 changes: 8 additions & 8 deletions Src/FileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ FileDialog::DialogResult FileDialog::DoPopup()
tString selDir = GetSelectedDir();
tPrintf("Selected Dir: %s\n", selDir.Chars());

// if (Mode == DialogMode::OpenDir)
// if (Mode == DialogMode::OpenDir)
{
tList<tStringItem> foundDirs;
tSystem::tFindDirs(foundDirs, selDir);
Expand All @@ -234,7 +234,7 @@ FileDialog::DialogResult FileDialog::DoPopup()
SelectedNode->Contents.Append(dirName);
}
}
// else if (Mode == DialogMode::OpenFile)
// else if (Mode == DialogMode::OpenFile)
{
tList<tStringItem> foundFiles;
tSystem::tFindFiles(foundFiles, selDir);
Expand All @@ -261,14 +261,14 @@ FileDialog::DialogResult FileDialog::DoPopup()

ImGui::TableNextColumn();
ImGui::Selectable("2022-11-23 2:45am", &selected);
//ImGui::Text("2022-11-23 2:45am");
// ImGui::Text("2022-11-23 2:45am");
ImGui::TableNextColumn();
ImGui::Selectable("123456 Bytes", &selected);
// ImGui::Text("123456 Bytes");
// if (ImGui::Selectable(item->Chars(), false))
// {
// // Select it.
// }
// ImGui::Text("123456 Bytes");
// if (ImGui::Selectable(item->Chars(), false))
// {
// Select it.
// }
}
ImGui::EndTable();
}
Expand Down
15 changes: 10 additions & 5 deletions Src/FileDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ class FileDialog;
class TreeNode
{
public:
TreeNode() : Name(), Parent(nullptr) { }
TreeNode(const tString& name, FileDialog* dialog, TreeNode* parent = nullptr)
: Name(name), Dialog(dialog), Parent(parent) { }
// void AppendChild(const tString& name) { Children.Append(new TreeNode(name, this)); }
void AppendChild(TreeNode* treeNode) { Children.Append(treeNode); }
TreeNode() :
Name(), Parent(nullptr) { }
TreeNode(const tString& name, FileDialog* dialog, TreeNode* parent = nullptr) :
Name(name), Dialog(dialog), Parent(parent) { }

// void AppendChild(const tString& name) { Children.Append(new TreeNode(name, this)); }
void AppendChild(TreeNode* treeNode)
{
Children.Append(treeNode);
}

tString Name;
FileDialog* Dialog;
Expand Down
22 changes: 6 additions & 16 deletions Src/OpenSaveDialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ using namespace tStd;
using namespace tSystem;
using namespace tMath;
using namespace tImage;
#ifdef ENABLE_FILE_DIALOG_SUPPORT
using namespace tInterface;
#endif


namespace Viewer
Expand All @@ -37,22 +39,9 @@ namespace Viewer
}


/*
void Viewer::OpenFileModal()
{
ifd::FileDialog::Instance().Open
(
"OpenFileModal", "Open Image",
"Image file "
"(*.png;*.apng;*.dds;*.exr;*.gif;*.hdr;*.ico;*.jpg;*.jpeg;*.bmp;*.tga;*.tif;*.tiff)"
"{.png,.apng,.dds,.exr,.gif,.hdr,.ico,.jpg,.jpeg,.bmp,.tga,.tif,.tiff,.webp},.*",
false,
ImagesDir.Chars()
);
}
*/
// Once we have the file dialog working, use ENABLE_FILE_DIALOG_SUPPORT to enable it.
// We will want to have the following types supported:
#ifdef ENABLE_FILE_DIALOG_SUPPORT
FileDialog OpenFileDialog(FileDialog::DialogMode::OpenFile);
FileDialog OpenDirDialog(FileDialog::DialogMode::OpenDir);
FileDialog SaveFileDialog(FileDialog::DialogMode::SaveFile);
Expand Down Expand Up @@ -92,6 +81,7 @@ void Viewer::DoOpenDirModal(bool openDirPressed)
SetWindowTitle();
}
}
#endif // ENABLE_FILE_DIALOG_SUPPORT


tString Viewer::DoSubFolder()
Expand Down
3 changes: 3 additions & 0 deletions Src/OpenSaveDialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@

namespace Viewer
{
// #define ENABLE_FILE_DIALOG_SUPPORT
#ifdef ENABLE_FILE_DIALOG_SUPPORT
void DoOpenFileModal(bool openFilePressed);
void DoOpenDirModal(bool openDirPressed);
#endif

void DoSaveAsModal(bool saveAsPressed);
void DoSaveAllModal(bool saveAllPressed);
Expand Down
25 changes: 19 additions & 6 deletions Src/TacentView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ namespace Viewer
bool WindowIconified = false;
bool ShowCheatSheet = false;
bool ShowAbout = false;

#ifdef ENABLE_FILE_DIALOG_SUPPORT
bool Request_OpenFileModal = false;
bool Request_OpenDirModal = false;
#endif

bool Request_SaveAsModal = false;
bool Request_SaveAllModal = false;
bool Request_ResizeImageModal = false;
Expand Down Expand Up @@ -1338,10 +1342,11 @@ void Viewer::Update(GLFWwindow* window, double dt, bool dopoll)
//
// File Menu.
//
#ifdef ENABLE_FILE_DIALOG_SUPPORT
bool openFilePressed = Request_OpenFileModal; Request_OpenFileModal = false;
// bool openFilePressed = false; Request_OpenFileModal = false;
bool openDirPressed = Request_OpenDirModal; Request_OpenDirModal = false;
// bool openDirPressed = false; Request_OpenDirModal = false;
#endif

bool saveAsPressed = Request_SaveAsModal; Request_SaveAsModal = false;
bool saveAllPressed = Request_SaveAllModal; Request_SaveAllModal = false;
bool saveContactSheetPressed = Request_ContactSheetModal; Request_ContactSheetModal = false;
Expand All @@ -1351,11 +1356,13 @@ void Viewer::Update(GLFWwindow* window, double dt, bool dopoll)
// Show file menu items...
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, tVector2(4,3));

// if (ImGui::MenuItem("Open File...", "Ctrl-O"))
// openFilePressed = true;
#ifdef ENABLE_FILE_DIALOG_SUPPORT
if (ImGui::MenuItem("Open File...", "Ctrl-O"))
openFilePressed = true;

// if (ImGui::MenuItem("Open Dir...", "Alt-O"))
// openDirPressed = true;
if (ImGui::MenuItem("Open Dir...", "Alt-O"))
openDirPressed = true;
#endif

if (ImGui::MenuItem("Save As...", "Ctrl-S") && CurrImage)
saveAsPressed = true;
Expand All @@ -1378,8 +1385,12 @@ void Viewer::Update(GLFWwindow* window, double dt, bool dopoll)
}

ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, tVector2(4,3));

#ifdef ENABLE_FILE_DIALOG_SUPPORT
DoOpenFileModal(openFilePressed);
DoOpenDirModal(openDirPressed);
#endif

DoSaveAsModal(saveAsPressed);
DoSaveAllModal(saveAllPressed);
DoContactSheetModal(saveContactSheetPressed);
Expand Down Expand Up @@ -2247,12 +2258,14 @@ void Viewer::KeyCallback(GLFWwindow* window, int key, int scancode, int action,
Request_RotateImageModal = true;
break;

#ifdef ENABLE_FILE_DIALOG_SUPPORT
case GLFW_KEY_O:
if (modifiers == GLFW_MOD_ALT)
Request_OpenDirModal = true;
else if (modifiers == GLFW_MOD_CONTROL)
Request_OpenFileModal = true;
break;
#endif

case GLFW_KEY_S: // SaveAs and SaveAll.
if (!modifiers)
Expand Down
2 changes: 1 addition & 1 deletion Src/Version.cmake.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#define set(verStr) namespace ViewerVersion { extern int Major, Minor, Revision; struct Parser { Parser(const char*); }; static Parser parser(#verStr); }

set("VIEWER_VERSION" "1.0.21")
set("VIEWER_VERSION" "1.0.22")

#undef set

0 comments on commit dd818f5

Please sign in to comment.