GUI for tools

Started by
9 comments, last by ocornut 8 years, 3 months ago

Thanks for your answer and feel free to move this discussion over to the github if you don't want to hijack this topic.

I'm not entirely sure why you aren't using TreeNode(), your code seems to attempt to replicate a behavior similar to that but with a slightly unusual construct. But it may just be because I don't understand the exact needs.

Based on your snippet it looks like you could use TreeNode(), a typical simple use pattern would be:


// Identify by pointer (obj)
// Display name + size as in the tree label
if (ImGui::TreeNode(obj, "%s (%d)", obj->Name, obj->Size))
{
   UserCode(obj);
   ImGui::TreePop();
}

One of my tool looks like that:

(Colored button + TreeNode() + SameLine() before adding the extra 2 checkboxs and the drag showing "100" for my alpha settings.)

71fb6f88-b8c3-11e5-9d13-59b31b926f1c.PNG

Or a more property tree in imgui_demo.cpp - ShowExampleAppPropertyEditor()

39d14cd2-ab5c-11e5-89f5-31740e8b932e.png

If you are really desirous of implementing a custom version of TreeNode() you can copy the MyTreeNode() code from here and adjust layout:

https://github.com/ocornut/imgui/issues/282#issuecomment-136011369

Arguably TreeNode() is missing a setting to adjust with precision the difference between hit-test behavior vs visual highlight behavior, this can be customized by copying the example code above, but ideally we should add those options in the stock library. The two screenshots above don't use any custom stuff.

Hope it helps. Sorry again for somehow hijacking this thread.

This topic is closed to new replies.

Advertisement