1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-24 07:40:22 +01:00

Internal: Settings: amend 0b86513 revert to use FindWindowSettingsByID().

Namely for docking system.
This commit is contained in:
ocornut 2023-02-10 17:01:14 +01:00
parent 082b20e46b
commit f0ac68ad35
2 changed files with 8 additions and 7 deletions

View File

@ -12467,8 +12467,9 @@ void ImGui::LogButtons()
// - SaveIniSettingsToMemory()
//-----------------------------------------------------------------------------
// - CreateNewWindowSettings() [Internal]
// - FindWindowSettingsByName() [Internal]
// - FindWindowSettingsByID() [Internal]
// - FindWindowSettingsByWindow() [Internal]
// - ClearWindowSettings() [Internal]
// - WindowSettingsHandler_***() [Internal]
//-----------------------------------------------------------------------------
@ -12686,11 +12687,11 @@ ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name)
return settings;
}
// We don't provide a FindWindowSettingsByName() because Docking system doesn't always hold on names.
// This is called once per window .ini entry + once per newly instantiated window.
ImGuiWindowSettings* ImGui::FindWindowSettingsByName(const char* name)
ImGuiWindowSettings* ImGui::FindWindowSettingsByID(ImGuiID id)
{
ImGuiContext& g = *GImGui;
ImGuiID id = ImHashStr(name);
for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
if (settings->ID == id)
return settings;
@ -12703,7 +12704,7 @@ ImGuiWindowSettings* ImGui::FindWindowSettingsByWindow(ImGuiWindow* window)
ImGuiContext& g = *GImGui;
if (window->SettingsOffset != -1)
return g.SettingsWindows.ptr_from_offset(window->SettingsOffset);
return FindWindowSettingsByName(window->Name); // Actual search executed once, so at this point we don't mind the redundant hashing.
return FindWindowSettingsByID(window->ID);
}
// This will revert window to its initial state, including enabling the ImGuiCond_FirstUseEver/ImGuiCond_Once conditions once more.
@ -12716,7 +12717,7 @@ void ImGui::ClearWindowSettings(const char* name)
window->Flags |= ImGuiWindowFlags_NoSavedSettings;
InitOrLoadWindowSettings(window, NULL);
}
if (ImGuiWindowSettings* settings = window ? FindWindowSettingsByWindow(window) : FindWindowSettingsByName(name))
if (ImGuiWindowSettings* settings = window ? FindWindowSettingsByWindow(window) : FindWindowSettingsByID(ImHashStr(name)))
settings->WantDelete = true;
}
@ -12731,7 +12732,7 @@ static void WindowSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandl
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
{
ImGuiID id = ImHashStr(name);
ImGuiWindowSettings* settings = ImGui::FindWindowSettingsByName(name);
ImGuiWindowSettings* settings = ImGui::FindWindowSettingsByID(id);
if (settings)
*settings = ImGuiWindowSettings(); // Clear existing if recycling previous entry
else

View File

@ -2770,7 +2770,7 @@ namespace ImGui
// Settings - Windows
IMGUI_API ImGuiWindowSettings* CreateNewWindowSettings(const char* name);
IMGUI_API ImGuiWindowSettings* FindWindowSettingsByName(const char* name);
IMGUI_API ImGuiWindowSettings* FindWindowSettingsByID(ImGuiID id);
IMGUI_API ImGuiWindowSettings* FindWindowSettingsByWindow(ImGuiWindow* window);
IMGUI_API void ClearWindowSettings(const char* name);