Skip to content

How to use (nearly) vanilla imgui with stacklayout (required for blueprint) #327

@dgm3333

Description

@dgm3333

If it's any use this is a way to integrated dmd's stacklayout into imgui with minimal change to the core files.

tested for v1.92.4 WIP

I haven't made this a pull request as it's a clear deviation from dmd and ocornut's intentions with stacklayout and imgui but perhaps it's helpful.

However it's always irritated me that stacklayout is required for blueprint so the node editor can't be used with vanilla imgui withouta fair bit of modification.
These files therefore strip the stacklayout functions out so imgui-node-editor can be used in (mostly) vanilla imgui.

Download then remove the .txt extension for these files (for some reason git won't allow me to upload with .cpp or .h extensions)
These files go in the same folder as imgui.h. Don't forget to add them to the project in visual studio.

imgui_stacklayout.h.txt
imgui_stacklayout.cpp.txt

in imconfig.h file uncomment / update these defines:-
#define IMGUI_DEFINE_MATH_OPERATORS // might not be required (I haven't tested without it but its in my build)
#define IMGUI_INCLUDE_IMGUI_USER_H
#define IMGUI_USER_H_FILENAME "imgui_stacklayout.h" // This enables the stack layout extension

in imgui.h add LayoutAlign just below grabrounding items

ImGuiStyleVar_GrabRounding,             // float     GrabRounding
ImGuiStyleVar_LayoutAlign,              // float     LayoutAlign

float       GrabRounding;               // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
float       LayoutAlign;                // Element alignment inside horizontal and vertical layouts (0.0f - left/top, 1.0f - right/bottom, 0.5f - center).

ditto in imgui.cpp
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, LayoutAlign) }, // ImGuiStyleVar_LayoutAlign

also in imgui.cpp ImGui::ItemSize just after the SkipItems return
...
if (window->SkipItems)
return;

if (ImGui_ItemSize_StackLayoutHorizontal(window, size, text_baseline_y))
	return;

...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions