-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
More general ini file support? #437
Comments
Yes I suppose it would be desirable, I was considering it could be a separate library (not sure if that's right or not). If you want to develop the idea and draft an API or how it would work, I haven't really thought about it yet. I believe it would have huge ramification. Note that it could also be applied to ImGui own storage for e.g. whether a tree node is opened or not. though the current design for those is that we have a set of hash->value and it's not really designed to persist, so dumping out the hash->value map would work but that would be anonymous and impossible to "clean". So better off with a more high-level design involving setting a state of whether tree state are saved, e.g. PushTreeStatePersistent(true); and the tree calls may use the persistence API providing more info that just hashes. |
Maybe it would be just enough to have an api modelled after the events, exactly like hovered or active items are used? In that case, every widget would have to load/save their own variables, as opposed to have an automated solution. // pseudocode
ImGui::Begin("color picker");
static float color[4];
ColorPicker4(color);
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("I am a tooltip");
ImGui::EndTooltip();
}
if (ImGui::IsItemLoading()) {
ImGui::Load("main.window4.color", color);
}
if (ImGui::IsItemSaving()) {
ImGui::Save("main.window4.color", color);
}
ImGui::End(); |
If you want to get rid of the manual tagging and provide some smart nesting support, then add push/pop states if (ImGui::IsItemLoading()) {
ImGui::BeginLoad("color"); // supposedly inside main -> window4 context already
ImGui::Load(color);
ImGui::EndLoad();
} |
Any update on this? I think you wouldn't even need a separate Load/Save function, you could just do something like this: ImGui::BeginConfig("SomeSection");
ImGui::Config("SomeKey", &SomeBool);
ImGui::EndConfig(); On |
This could totally work as separate library, calling it say, |
Fair enough. What about window close state? That is generally what I would intend to use it for. |
This idea is still up in the air (someone mentioned it to me recently) and unimplemented, but in the meanwhile here's a little update:
|
+1 |
The ini file support appears to only store pos, size and collapsed values for the windows. It would be convenient to be able to use the ini files to store other settings as well.
In my case I was looking to add the information on whether the window should be open or not, but the interface could be even more general (some kind of registry).
The text was updated successfully, but these errors were encountered: