|
@@ -918,9 +918,9 @@ static ImRect GetViewportRect();
|
|
|
|
|
|
// Settings
|
|
// Settings
|
|
static void WindowSettingsHandler_ClearAll(ImGuiContext*, ImGuiSettingsHandler*);
|
|
static void WindowSettingsHandler_ClearAll(ImGuiContext*, ImGuiSettingsHandler*);
|
|
-static void WindowSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*);
|
|
|
|
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
|
|
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
|
|
static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
|
|
static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
|
|
|
|
+static void WindowSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*);
|
|
static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf);
|
|
static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf);
|
|
|
|
|
|
// Platform Dependents default implementation for IO functions
|
|
// Platform Dependents default implementation for IO functions
|
|
@@ -3945,9 +3945,9 @@ void ImGui::Initialize(ImGuiContext* context)
|
|
ini_handler.TypeName = "Window";
|
|
ini_handler.TypeName = "Window";
|
|
ini_handler.TypeHash = ImHashStr("Window");
|
|
ini_handler.TypeHash = ImHashStr("Window");
|
|
ini_handler.ClearAllFn = WindowSettingsHandler_ClearAll;
|
|
ini_handler.ClearAllFn = WindowSettingsHandler_ClearAll;
|
|
- ini_handler.ApplyAllFn = WindowSettingsHandler_ApplyAll;
|
|
|
|
ini_handler.ReadOpenFn = WindowSettingsHandler_ReadOpen;
|
|
ini_handler.ReadOpenFn = WindowSettingsHandler_ReadOpen;
|
|
ini_handler.ReadLineFn = WindowSettingsHandler_ReadLine;
|
|
ini_handler.ReadLineFn = WindowSettingsHandler_ReadLine;
|
|
|
|
+ ini_handler.ApplyAllFn = WindowSettingsHandler_ApplyAll;
|
|
ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll;
|
|
ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll;
|
|
g.SettingsHandlers.push_back(ini_handler);
|
|
g.SettingsHandlers.push_back(ini_handler);
|
|
}
|
|
}
|
|
@@ -9784,6 +9784,12 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
|
memcpy(buf, ini_data, ini_size);
|
|
memcpy(buf, ini_data, ini_size);
|
|
buf_end[0] = 0;
|
|
buf_end[0] = 0;
|
|
|
|
|
|
|
|
+ // Call pre-read handlers
|
|
|
|
+ // Some types will clear their data (e.g. dock information) some types will allow merge/override (window)
|
|
|
|
+ for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
|
|
|
+ if (g.SettingsHandlers[handler_n].ReadInitFn)
|
|
|
|
+ g.SettingsHandlers[handler_n].ReadInitFn(&g, &g.SettingsHandlers[handler_n]);
|
|
|
|
+
|
|
void* entry_data = NULL;
|
|
void* entry_data = NULL;
|
|
ImGuiSettingsHandler* entry_handler = NULL;
|
|
ImGuiSettingsHandler* entry_handler = NULL;
|
|
|
|
|
|
@@ -9872,24 +9878,12 @@ static void WindowSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandl
|
|
g.SettingsWindows.clear();
|
|
g.SettingsWindows.clear();
|
|
}
|
|
}
|
|
|
|
|
|
-// Apply to existing windows (if any)
|
|
|
|
-static void WindowSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
|
|
|
-{
|
|
|
|
- ImGuiContext& g = *ctx;
|
|
|
|
- for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
|
|
|
|
- if (settings->WantApply)
|
|
|
|
- {
|
|
|
|
- if (ImGuiWindow* window = ImGui::FindWindowByID(settings->ID))
|
|
|
|
- ApplyWindowSettings(window, settings);
|
|
|
|
- settings->WantApply = false;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
|
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
|
{
|
|
{
|
|
- ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name));
|
|
|
|
- if (!settings)
|
|
|
|
- settings = ImGui::CreateNewWindowSettings(name);
|
|
|
|
|
|
+ ImGuiWindowSettings* settings = ImGui::FindOrCreateWindowSettings(name);
|
|
|
|
+ ImGuiID id = settings->ID;
|
|
|
|
+ *settings = ImGuiWindowSettings(); // Clear existing if recycling previous entry
|
|
|
|
+ settings->ID = id;
|
|
settings->WantApply = true;
|
|
settings->WantApply = true;
|
|
return (void*)settings;
|
|
return (void*)settings;
|
|
}
|
|
}
|
|
@@ -9904,6 +9898,19 @@ static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*,
|
|
else if (sscanf(line, "Collapsed=%d", &i) == 1) settings->Collapsed = (i != 0);
|
|
else if (sscanf(line, "Collapsed=%d", &i) == 1) settings->Collapsed = (i != 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Apply to existing windows (if any)
|
|
|
|
+static void WindowSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
|
|
|
+{
|
|
|
|
+ ImGuiContext& g = *ctx;
|
|
|
|
+ for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
|
|
|
|
+ if (settings->WantApply)
|
|
|
|
+ {
|
|
|
|
+ if (ImGuiWindow* window = ImGui::FindWindowByID(settings->ID))
|
|
|
|
+ ApplyWindowSettings(window, settings);
|
|
|
|
+ settings->WantApply = false;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
|
|
static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
|
|
{
|
|
{
|
|
// Gather data from windows that were active during this session
|
|
// Gather data from windows that were active during this session
|