Skip to content

Commit

Permalink
Adding dialog support
Browse files Browse the repository at this point in the history
  • Loading branch information
kecho committed Dec 21, 2023
1 parent f77817c commit bd6283f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Build/Tundra/units.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ local LibIncludes = {
Config = "win64-*-*"
},
ImguiDir,
ImGuiFileDialogDir,
ImplotDir,
LibJpgDir,
LibPngDir,
Expand Down Expand Up @@ -330,7 +331,7 @@ local CoalPyModuleIncludes = {
}

local CoalPyModuleDeps = {
render = { imguiLib, implotLib, spirvreflect, tinyobjloader, cjson },
render = { imguiLib, ImGuiFileDialog, implotLib, spirvreflect, tinyobjloader, cjson },
texture = { zlibLib, libpngLib, libjpegLib }
}

Expand Down
21 changes: 21 additions & 0 deletions Source/pymodules/gpu/ImguiBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <functional>
#include <imgui_internal.h> //for docking API
#include <misc/cpp/imgui_stdlib.h>
#include <ImGuiFileDialog.h>

namespace coalpy
{
Expand Down Expand Up @@ -1357,6 +1358,26 @@ PyObject* setColorEditOptions(PyObject* self, PyObject* vargs, PyObject* kwds)
Py_RETURN_NONE;
}

PyObject* openDialog(PyObject* self, PyObject* vargs, PyObject* kwds)
{
CHECK_IMGUI
static char* argnames[] = { "key", "title", "filter", "path", nullptr };
char* key, * title, * filter, * path;
if (!PyArg_ParseTupleAndKeywords(vargs, kwds, "ssss", argnames, &key, &title, &filter, &path))
return nullptr;

std::string keyStr = key, titleStr = title, pathStr = path;
ImGuiFileDialog::Instance()->OpenDialog(keyStr, titleStr, filter, pathStr);

if (ImGuiFileDialog::Instance()->Display(keyStr))
{
ImGuiFileDialog::Instance()->Close();
}


Py_RETURN_NONE;
}


}//methods

Expand Down
13 changes: 13 additions & 0 deletions Source/pymodules/gpu/bindings/Imgui.inl
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,19 @@ COALPY_FN(set_color_edit_options, setColorEditOptions, R"(
flags : see coalpy.gpu.ImGuiColorEditFlags
)")

COALPY_FN(open_dialog, openDialog, R"(
Open a file dialog
Parameters:
key (str): key of dialog
title (str): title of dialog
filter (str): file filter, i.e ".cpp.h.hpp"
path (str): path of dialog
Returns (tuple):
(filePathName, filePath, response(bool))
)")


//Imgui focus flags enums
COALPY_ENUM_BEGIN(ImGuiFocusedFlags, "ImGUI Focused flags")
Expand Down

0 comments on commit bd6283f

Please sign in to comment.