implot
implot copied to clipboard
Persist legend location and flags
Hi!
Thanks for this great library. I have a question: How do I persist the location and inside/outside flag of the legend so that if the app is closed and opened again the legend is still at the same position. Is there a method to query the state of the legend? Or something like SetupLegend(ImPlotLocation *location, ImPlotLegendFlags *flags) with references which modifies the current location and flags when the user configures the legend. Then location and flags could be saved on exit and loaded on start of the app.
I'm not an expert but I'd imagine you could persist the state by dumping a json
/txt
/yml
or some other file in the filesystem right before the app is closed. And then you can read from this file when the app is launched again and update the state of the legend as per the contents of the file.
This file could be stored in the installation/build directory.
Isn't there an mechanism in ImGUI to use the imgui.ini
that it writes anyway?
Not quite familiar with imgui.ini
myself. However, dumping a simple file for your own custom use-case could be beneficial in terms of avoiding any dependency on imgui.ini
's behavior.
Not quite familiar with
imgui.ini
myself. However, dumping a simple file for your own custom use-case could be beneficial in terms of avoiding any dependency onimgui.ini
's behavior.
Wouldn't this just result in thousands of files for the user to manage if each and every plugin went that way? Also this sounds quite a bit like NIH when there's already a facility to save state for ImGUI.
So far I haven't found out how to get the current values of the location and the inside/outise flag, so I'm not able to store it to some custom file. I think it is also not stored automatically. That's why we would need a SetupLegend() with user provided state or some other mechanism to extract the current state.