Open thomasgeissl opened 3 years ago
Hello Thomas,
I've never really used the ImHelpers part of this addon, and I've limited knowledge on this part. (They seem to heavily rely on GetUniqueName
).
Moebius is doing some modifications with them; @moebiussurfing, I remember you saying something similar by mail ? (something like switching to ImGui::PushID(i++);
instead of GetUniqueName()
)
hey @thomasgeissl ,
can you try this branch? https://github.com/Daandelange/ofxImGui/tree/ofParameters-Helpers-Test today I made some changes trying to figure out how to solve these crashes...
I am using the group helper it like the original repo:
.h
ofxImGui::Settings mainSettings = ofxImGui::Settings();
.cpp
//setup
gui.setup(nullptr, true, ImGuiConfigFlags_DockingEnable, true, false);//this do not matters
//draw
ofxImGui::AddGroup(params_1, mainSettings);
ofxImGui::AddGroup(params_2, mainSettings);
ofxImGui::AddGroup(params_3, mainSettings);
I made modifications to collapse the group/tree by default.
Should be better to allow passing the window/tree flags with the group, then we can customize better the window props...
but is crashing sometimes... You can see on the commented zones my frustrated attempts...
I think we don't need this mess of settings maybe but I am not sure. Something like this could be nice:
void ofxImGui::AddGroup(ofParameterGroup& group, ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_None)
I encourage you to use this fork that @Daandelange is working on, I am using two "instances" of ImGui, I mean some panels coming from an addon, another from the ofApp, and all working fine.
there's a fork with a simpler params helpers approach that could be inspiration: https://github.com/yumataesu/ofxImGui_v3/blob/master/src/Helper.h
Just re-checked the helpers code a bit, and your changes to it. The Helpers feel quite obsolete indeed, and could be stripped / refactored, I think (saying this without having any experience with them). It could be great to have a more exhaustive example of the Helpers to address these questions and test them.
What feels obsolete to me :
getUniqueName
: could be replaced with pushID()
and popID()
or something similar. This is bound to windowOpen
, which doesn't look to be used for other stuff. Except that it's a public variable, so people could be using it (= slightly breaking). ofxImGui::Settings::Settings
seem to be a bit more complicated, it seems to serve as a state machine for improving the default imgui behaviour, combined with custom layout helpers. Removing this will probably break the layout of existing projects, probably best not changing it too much. (?)Note : Remember, as useful as they are, usage of the Handler functions remain optional. If you need too specific layouts, you better write your own alternatives.
Yamataesu's helper functions seem way more minimal and thus quite different from the original code. He stripped the whole ofxImGui::Settings
part, so that could give an example of how ofxImGui would look like without the original layout tricks.
@thomasgeissl To get back to your initial question, I've commited a slightly different version of your code, so the new name gets added to the list of taken names. I don't know if it's due to your use case that the stack is empty, but better add a crash protection anyways !
thanks.
if I find time, I will have a deeper look. I think I did not pass settings to the function. I think your fix will still crash, if usedNames is emtpy then top() will be null.
You're right. Usednames is pushed()/poped() in begin()
/end()
in tree
and window
. So outside of a window, it's supposedly empty.
So maybe creating a "top-level"/"default" stack for windowless zones as a quick fix ? (will probably never get popped()
unless cleanly implemented)
Or as discussed above, switch away from getUniqueName()
.
If you have some time, yes please. :) For now, the quick fix is pushed, still untested. On long-term, IMO, the 2nd option is better, but needs a deeper insight for confirmation.
I agree with what you are proposing. I think I should have some time next week. Thanks for your work on updating the addon.
ofxImGui::Settings::Settings
seem to be a bit more complicated, it seems to serve as a state machine for improving the default imgui behaviour, combined with custom layout helpers. Removing this will probably break the layout of existing projects, probably best not changing it too much. (?) On the other side, it feels like most of its features are handled (or handleable) by native ImGui functions, but I don't know how exactly how much. What's the Helpers' "layout engine" doing compared to native Imgui behaviour ?Yamataesu's helper functions seem way more minimal and thus quite different from the original code. He stripped the whole ofxImGui::Settings part, so that could give an example of how ofxImGui would look like without the original layout tricks.
Hey @Daandelange ,
The more observable layout behavior when using helpers is that: when you add a container ofParameterGroup, with other nested groups with more params etc etc, the official repo makes something like:
But the layout states (collapsing, closed windows..) are not being handled with .ini ImGui workflow. (Only handles the position and windows, docking sizes).
So in my case I ended using additional extra params bools in OF that I need to handle by myself, declaring, serializing on exit, deserializing on starting, etc. But unfortunately I am not being able to restore the collapsing states. I must change this workflow to let do this easy directly by ImGui.
Personally, what I would like to have is to make my custom extra layout helpers as you said above; something like flag some widgets to be drawn with the desired style. (Besides the argument to add the flags when adding single ungrouped widgets/parameters)
For example:
(maybe a pair/struct/map with the parameter name and an enum with _STYLE_CHECKBOX, STYLE_SLIDER, STYLESTEPPER...etc. And then when populating all the group params, to check if the name is on the queue and then apply the queued style. )
EDITED
Ok, I see, thanks for these details; so it's about the layout and not directly related to GetUniqueName
.
Your other points sound like new ideas/features and could become a new issue. (?)
imgui.ini
(header collapse, open tabs, etc.)https://github.com/ocornut/imgui/issues/437#issuecomment-380403870
.AddGroup()
has to guess from an AbstractParameter
. Maybe an AddGroup(g, appearance_flags_list[] )
will do instead of making pairs.
And another one, GetUniqueName was crashing, as usedNames is empty initially. I don't really know what's going on, need to double check with a working brain. Here is a quick fix, but there are probably things missing. Probably this is also the case in Jason's original code. Or maybe related to how I create my UI.
Any Ideas?