imgui-node-editor icon indicating copy to clipboard operation
imgui-node-editor copied to clipboard

Using tables API

Open MultiPain opened this issue 3 years ago • 7 comments

Here there is problem with tables: nodes_tables The "edge" position depends on window size AND position nodes_tables2 How can I fix this?

MultiPain avatar Jul 18 '22 07:07 MultiPain

A minimal code example would be somewhat helpful to anyone wanting to debug this.

gnif avatar Jul 21 '22 07:07 gnif

@gnif ok, here it is:

void Draw()
{
    static bool firstFrame = true; 
    static ImGuiTableFlags flags = ImGuiTableFlags_PadOuterX | ImGuiTableFlags_NoHostExtendX | ImGuiTableFlags_Borders;
    static float nodeWidth = 128.0f;

    int uniqueId = 1;

    ImGui::SetNextWindowPos(ImVec2(94.0f, 164.0f), ImGuiCond_Once);
    ImGui::SetNextWindowSize(ImVec2(344.0f, 178.0f), ImGuiCond_Once);

    NodeEditor::Begin("My editor");

    NodeEditor::BeginNode(uniqueId++);

    if (ImGui::BeginTable("Node", 2, flags))
    {
        float columnWidth = nodeWidth * 0.5f;
        ImGui::TableSetupColumn("Inputs", ImGuiTableColumnFlags_WidthFixed, columnWidth);
        ImGui::TableSetupColumn("Outputs", ImGuiTableColumnFlags_WidthFixed, columnWidth);

        ImGui::TableNextRow();
        ImGui::TableNextColumn();
        ImGui::TextUnformatted("Hello");
        ImGui::TableNextColumn();
        ImGui::TextUnformatted("World!");

        ImGui::TableNextRow();
        ImGui::TableNextColumn();
        ImGui::TextUnformatted("Hello");
        ImGui::TableNextColumn();
        ImGui::TextUnformatted("World!");

    }
    ImGui::EndTable();

    NodeEditor::EndNode();

    NodeEditor::End();

    if (firstFrame)
    {
        firstFrame = false;
        NodeEditor::SetNodePosition(uniqueId - 1, ImVec2(352.0f, -192.0f));
        NodeEditor::NavigateToContent();
    }
}

Try to change window size and position.

MultiPain avatar Jul 21 '22 11:07 MultiPain

I think it is so much easier to create a layot with tables rather than with stack layout.

P.S. accedetically closed, sorry

MultiPain avatar Jul 21 '22 11:07 MultiPain

Tables are much younger that stack layouts and node editor. I need to investigate how to address this issue.

thedmd avatar Aug 12 '22 21:08 thedmd

Tables are much younger that stack layouts and node editor. I need to investigate how to address this issue.

After playing around with stack layout, I finally managed to put things together :) image

MultiPain avatar Aug 13 '22 07:08 MultiPain

It seems this bug is still present. is there workaround to have actual tables inside nodes? 2023-06-16T16-08-41

pozemka avatar Jun 16 '23 13:06 pozemka

A fixed table size will work correctly, but you don't manually define the table size, this bug occurs :(

TheZoc avatar Jun 22 '23 09:06 TheZoc