[wpigui] Add support for imgui config flags

This commit is contained in:
Peter Johnson
2022-06-01 21:27:00 -07:00
parent 873e72df8c
commit b873e208b4
2 changed files with 8 additions and 3 deletions

View File

@@ -115,7 +115,8 @@ void gui::DestroyContext() {
gContext = nullptr;
}
bool gui::Initialize(const char* title, int width, int height) {
bool gui::Initialize(const char* title, int width, int height,
ImGuiConfigFlags configFlags) {
gContext->title = title;
gContext->width = width;
gContext->height = height;
@@ -138,6 +139,7 @@ bool gui::Initialize(const char* title, int width, int height) {
ImGui::CreateContext();
ImPlot::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= configFlags;
// Hook ini handler to save settings
ImGuiSettingsHandler iniHandler;
@@ -297,9 +299,10 @@ void gui::Main() {
PlatformRenderFrame();
gContext->isPlatformRendering = false;
auto& io = ImGui::GetIO();
// custom saving
if (gContext->saveSettings) {
auto& io = ImGui::GetIO();
if (io.WantSaveIniSettings) {
gContext->saveSettings(false);
io.WantSaveIniSettings = false; // reset flag

View File

@@ -30,8 +30,10 @@ void DestroyContext();
* @param title main application window title
* @param width main application window width
* @param height main application window height
* @param configFlags ImGui configuration flags
*/
bool Initialize(const char* title, int width, int height);
bool Initialize(const char* title, int width, int height,
ImGuiConfigFlags configFlags = ImGuiConfigFlags_None);
/**
* Runs main GUI loop. On some OS'es this must be called from the main thread.