Closed moebiussurfing closed 3 years ago
I'm not really familiar with the Helpers, but it looks like you can't use them without ofxImGui::BeginWindow()
.
Does this happen with the original addon too, or just with this fork ?
I think your issue might be related to ofxImGui::BeginWindow()
calling ImGui::Begin()
with the ImGuiWindowFlags_NoSavedSettings
flag --> disabling saving for those windows. So it would be better to make that flag optional in BeginWindow
? If the flag is explicitly set, there's probably a reason for the helpers to set it.
Does this happen with the original addon too, or just with this fork ?
on the original repo works fine.
Very strange because nothing really changes in the helpers code, compared to jvcleave/master.
It crashes because windowOpen.usedNames
is empty, causing windowOpen.usedNames.top()
to fail, and only BeginWindow() sets it, so it's meant to be used together.
Imo, your use case is a hack anyways, or am I wrong ?
Maybe you could add/write write an ofxImGui::PushWindow(string);
(and pop
) function based on ofxImGui::BeginWindow()
, without the ImGui::Begin();
call, to enable using the helpers within an existing imgui window.
Very strange because nothing really changes in the helpers code, compared to jvcleave/master. Imo, your use case is a hack anyways, or am I wrong ?
I don't mean about your changes. This happened always also on the official repo. My case is not a hack, I think... It's the normal use in OF when your are using ofParameters helpers. If you want to use the ofParameter helpers you need to use this ofxImGui begin/end window and settings methods... The last time I checked this into ofxImGui, I felt that all this getUniqueName methods and ofxImGui::Settings do not where useful and annoying, or maybe I didn't understood why they were there. (Maybe to remember the layout/trees opened/expanded-or-not states thinking on the ini layout store/recall? I don't know.)
btw, the problem that I was mentioning above was, that: when using this (required to use ofParameters) ofxImGui::begin/end/windows/settings, the app stops handing the imgui.ini layout settings on startup the app again.
Sorry, I'm still not sure to understand the real issue...
ofxImGui::beginWindow
, that function seems to handle its own window-size-and-position, therefore force-disabling imgui.ini use for that imgui window (by setting ImGuiWindowFlags_NoSavedSettings
).ofxImGui::beginWindow
is needed for using the helpers gui, so it's an "expected" crash if you use helpers without that call.In the example, using the lines below, the imgui.ini settings are kept, but then they are overridden; commenting these lines produces the behaviour you expect, I think.
static bool bCollapse = false;
if (ofxImGui::BeginWindow("Helpers", mainSettings, ImGuiWindowFlags_None, &bCollapse))
In the example, using the lines below, the imgui.ini settings are kept, but then they are overridden; commenting these lines produces the behaviour you expect, I think.
static bool bCollapse = false; if (ofxImGui::BeginWindow("Helpers", mainSettings, ImGuiWindowFlags_None, &bCollapse))
Thanks a lot @Daandelange , Finally I tried this (commenting the 3 lines) and it works: the layout it's being restored fine when reopening the app.
So, to enable the .ini handling: The example-helpers must change this:
//this->gui.setup();
this->gui.setup(nullptr, true, ImGuiConfigFlags_None, true, true);
and
//if (ofxImGui::BeginWindow("Helpers", mainSettings, false))
static bool bCollapse = false;
if (ofxImGui::BeginWindow("Helpers", mainSettings, ImGuiWindowFlags_None, &bCollapse))
This behavior does not happen on the official ofxImGui. The same untouched example-helpers project works fine like this out of the box: https://imgur.com/a/lHjCchq
PS: Do you think maybe you can add another method with these lines commented? Maybe it's a good idea to have very minimal version, without all the mainSettings/SetNextWindowPos/SetNextWindowSize... stuff maybe we don't need it at all. We only need to allow ofParameters and it's better to handle the more ImGui raw/native code, plugins... etc. What do you think?
PS2: From now I'll check a complex example with docking and multi instance and I'll report back.
PS3: Sorry about insist on this, but for me it's very annoying if the layout is not recalled, bc then you should need to do the layout hard coded...
Thanks again for all this work.
hey @Daandelange , I am not sure, correct me if I am losing something, but it looks like the old API breaks something:
Personally, I really need the layout imgui.ini restoring, docking, and ofParameter helpers. To do this I add this to the setup call:
gui.setup(nullptr, true, ImGuiConfigFlags_DockingEnable, true, true);
Related to the project
ofxImGui\example-helpers
: The imgui.ini recall is not working when using:To make it work I need to stop using the ofxImGui helpers like this:
BUT, the problem is that we can not use OF helpers outside an ofxImGui::BeginWindow / ofxImGui::EndWindow(mainSettings); methods...
On the example-helpers you can see that it crashes when using the ImGui::Begin()/End()
So this means that: if I want to enable the layout ini recall, I must stop using the OF helpers.