Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectable tree node #431

Closed
ghost opened this issue Dec 10, 2015 · 2 comments
Closed

Selectable tree node #431

ghost opened this issue Dec 10, 2015 · 2 comments
Labels

Comments

@ghost
Copy link

ghost commented Dec 10, 2015

Hi,

I need a tree with selectable nodes. The current tree does not allow this. I have try using "Selectable+Indent" as leaf and normal tree node for inner nodes but:

  • only the selectable are "selectable"
  • the selectables (even with Indent) are not well aligned with the tree node.

So, I think to create my own TreeNode like widget, here is my current code:

bool SelectableTreeNode(const char* label, bool isSelected, bool hasChildren)
{
    // Selection
    if (isSelected)
    {
        ImU32 col = ImColor(ImGui::GetStyle().Colors[ImGuiCol_HeaderHovered]);
        /*x += os.x;
        y += os.y;
        ImGui::RenderFrame(ImVec2(x, y), ImVec2(x + itemFullWidth, y + itemFullHeight), col, true, 3.f);
        x -= os.x;
        y -= os.y;*/
    }

    ImGui::PushID(label);
    const bool opened = ImGui::CollapsingHeader(label, "", false);
    ImGui::PopID();

    if (opened)
        ImGui::TreePush(label);

    return opened;
}

But how can I :

  • know the area of the treenode (see RenderFrame)
  • Hide the Triangle/Arrow based on the "hasChildren" parameter

Any idea ?

@ocornut
Copy link
Owner

ocornut commented Dec 10, 2015

Could you move this to #190 ?
Thanks

@ocornut
Copy link
Owner

ocornut commented Dec 10, 2015

Moved to #190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant