Skip to content

Commit

Permalink
Update hello_imgui (add dock_space_id_from_name)
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Mar 17, 2023
1 parent dc8ccda commit ba114f1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
13 changes: 10 additions & 3 deletions bindings/imgui_bundle/hello_imgui.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,8 @@ class DockableWindow:
* `label`: _string_. Title of the window.
* `dockSpaceName`: _DockSpaceName (aka string)_. Id of the dock space where this window
should initialy be placed
* `GuiFunction`: _VoidFuntion_. Any function that will render this window's Gui.
should initially be placed
* `GuiFunction`: _VoidFunction_. Any function that will render this window's Gui.
* `isVisible`: _bool, default=true_. Flag that indicates whether this window is visible or not.
* `canBeClosed`: _bool, default=true_. Flag that indicates whether the user can close this window.
* `callBeginEnd`: _bool, default=true_. Flag that indicates whether ImGui::Begin and ImGui::End
Expand Down Expand Up @@ -1334,7 +1334,10 @@ class DockableWindow:
#
# * `DockableWindow * dockableWindowOfName(const std::string & name)`: returns a pointer to a dockable window
# * `None focusDockableWindow(const std::string& name)`: will focus a dockable window
#
# * `optional<ImGuiID> dockSpaceIdFromName(const std::string& dockSpaceName)`: may return the ImGuiID corresponding
# to the dockspace with this name.
# **Warning**: this will work reliably only if layoutCondition = DockingLayoutCondition::ApplicationStart. In other
# cases, the ID may be cached by ImGui himself at the first run, and HelloImGui will *not* know it on subsequent runs!
#@@md
#

Expand Down Expand Up @@ -1365,6 +1368,10 @@ class DockingParams:
# void focusDockableWindow(const std::string& windowName); /* original C++ signature */
def focus_dockable_window(self, window_name: str) -> None:
pass

# std::optional<ImGuiID> dockSpaceIdFromName(const std::string& dockSpaceName); /* original C++ signature */
def dock_space_id_from_name(self, dock_space_name: str) -> Optional[ImGuiID]:
pass
# DockingParams(std::vector<DockingSplit> dockingSplits = std::vector<DockingSplit>(), std::vector<DockableWindow> dockableWindows = std::vector<DockableWindow>(), DockingLayoutCondition layoutCondition = DockingLayoutCondition::FirstUseEver, bool layoutReset = false); /* original C++ signature */
def __init__(
self,
Expand Down
12 changes: 9 additions & 3 deletions external/hello_imgui/bindings/hello_imgui_amalgamation.h
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,7 @@ struct RunnerCallbacks
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <vector>
#include <utility>
#include <optional>
#include <stdio.h>

namespace HelloImGui
Expand Down Expand Up @@ -1980,8 +1981,8 @@ _Members:_
* `label`: _string_. Title of the window.
* `dockSpaceName`: _DockSpaceName (aka string)_. Id of the dock space where this window
should initialy be placed
* `GuiFunction`: _VoidFuntion_. Any function that will render this window's Gui.
should initially be placed
* `GuiFunction`: _VoidFunction_. Any function that will render this window's Gui.
* `isVisible`: _bool, default=true_. Flag that indicates whether this window is visible or not.
* `canBeClosed`: _bool, default=true_. Flag that indicates whether the user can close this window.
* `callBeginEnd`: _bool, default=true_. Flag that indicates whether ImGui::Begin and ImGui::End
Expand Down Expand Up @@ -2054,7 +2055,10 @@ struct DockableWindow
* `DockableWindow * dockableWindowOfName(const std::string & name)`: returns a pointer to a dockable window
* `void focusDockableWindow(const std::string& name)`: will focus a dockable window
* `optional<ImGuiID> dockSpaceIdFromName(const std::string& dockSpaceName)`: may return the ImGuiID corresponding
to the dockspace with this name.
**Warning**: this will work reliably only if layoutCondition = DockingLayoutCondition::ApplicationStart. In other
cases, the ID may be cached by ImGui himself at the first run, and HelloImGui will *not* know it on subsequent runs!
@@md
*/

Expand All @@ -2076,6 +2080,8 @@ struct DockingParams

DockableWindow * dockableWindowOfName(const std::string & name);
void focusDockableWindow(const std::string& windowName);

std::optional<ImGuiID> dockSpaceIdFromName(const std::string& dockSpaceName);
};
} // namespace HelloImGui

Expand Down
4 changes: 3 additions & 1 deletion external/hello_imgui/bindings/pybind_hello_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ void py_init_module_hello_imgui(py::module& m)

auto pyClassDockableWindow =
py::class_<HelloImGui::DockableWindow>
(m, "DockableWindow", "*\n@@md#DockableWindow\n\n**DockableWindow** is a struct that represents a window that can be docked.\n\n_Members:_\n\n* `label`: _string_. Title of the window.\n* `dockSpaceName`: _DockSpaceName (aka string)_. Id of the dock space where this window\n should initialy be placed\n* `GuiFunction`: _VoidFuntion_. Any function that will render this window's Gui.\n* `isVisible`: _bool, default=true_. Flag that indicates whether this window is visible or not.\n* `canBeClosed`: _bool, default=true_. Flag that indicates whether the user can close this window.\n* `callBeginEnd`: _bool, default=true_. Flag that indicates whether ImGui::Begin and ImGui::End\n calls should be added automatically (with the given \"label\"). Set to False if you want to call\n ImGui::Begin/End yourself\n* `includeInViewMenu`: _bool, default=true_. Flag that indicates whether this window should be mentioned\n in the view menu.\n* `imGuiWindowFlags`: _ImGuiWindowFlags, default=0_. Window flags, see enum ImGuiWindowFlags_\n* `windowSize`: _ImVec2, default=(0., 0.) (i.e let the app decide)_. Window size (unused if docked)\n* `windowSizeCondition`: _ImGuiCond, default=ImGuiCond_FirstUseEver_. When to apply the window size.\n* `windowPos`: _ImVec2, default=(0., 0.) (i.e let the app decide)_. Window position (unused if docked)\n* `windowPosCondition`: _ImGuiCond, default=ImGuiCond_FirstUseEver_. When to apply the window position.\n* `focusWindowAtNextFrame`: _bool, default = false_. If set to True this window will be focused at the next frame.\n\n@@md\n*")
(m, "DockableWindow", "*\n@@md#DockableWindow\n\n**DockableWindow** is a struct that represents a window that can be docked.\n\n_Members:_\n\n* `label`: _string_. Title of the window.\n* `dockSpaceName`: _DockSpaceName (aka string)_. Id of the dock space where this window\n should initially be placed\n* `GuiFunction`: _VoidFunction_. Any function that will render this window's Gui.\n* `isVisible`: _bool, default=true_. Flag that indicates whether this window is visible or not.\n* `canBeClosed`: _bool, default=true_. Flag that indicates whether the user can close this window.\n* `callBeginEnd`: _bool, default=true_. Flag that indicates whether ImGui::Begin and ImGui::End\n calls should be added automatically (with the given \"label\"). Set to False if you want to call\n ImGui::Begin/End yourself\n* `includeInViewMenu`: _bool, default=true_. Flag that indicates whether this window should be mentioned\n in the view menu.\n* `imGuiWindowFlags`: _ImGuiWindowFlags, default=0_. Window flags, see enum ImGuiWindowFlags_\n* `windowSize`: _ImVec2, default=(0., 0.) (i.e let the app decide)_. Window size (unused if docked)\n* `windowSizeCondition`: _ImGuiCond, default=ImGuiCond_FirstUseEver_. When to apply the window size.\n* `windowPos`: _ImVec2, default=(0., 0.) (i.e let the app decide)_. Window position (unused if docked)\n* `windowPosCondition`: _ImGuiCond, default=ImGuiCond_FirstUseEver_. When to apply the window position.\n* `focusWindowAtNextFrame`: _bool, default = false_. If set to True this window will be focused at the next frame.\n\n@@md\n*")
.def(py::init<const std::string &, const DockSpaceName &, const VoidFunction, bool, bool>(),
py::arg("label_") = "", py::arg("dock_space_name_") = "", py::arg("gui_function_") = HelloImGui::EmptyVoidFunction(), py::arg("is_visible_") = true, py::arg("can_be_closed_") = true)
.def_readwrite("label", &DockableWindow::label, "")
Expand Down Expand Up @@ -508,6 +508,8 @@ void py_init_module_hello_imgui(py::module& m)
pybind11::return_value_policy::reference)
.def("focus_dockable_window",
&DockingParams::focusDockableWindow, py::arg("window_name"))
.def("dock_space_id_from_name",
&DockingParams::dockSpaceIdFromName, py::arg("dock_space_name"))
;


Expand Down

0 comments on commit ba114f1

Please sign in to comment.