mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 16:29:02 +08:00
Internal: Settings: amend 0b86513
revert to use FindWindowSettingsByID().
Namely for docking system.
This commit is contained in:
parent
082b20e46b
commit
f0ac68ad35
13
imgui.cpp
13
imgui.cpp
@ -12467,8 +12467,9 @@ void ImGui::LogButtons()
|
|||||||
// - SaveIniSettingsToMemory()
|
// - SaveIniSettingsToMemory()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// - CreateNewWindowSettings() [Internal]
|
// - CreateNewWindowSettings() [Internal]
|
||||||
// - FindWindowSettingsByName() [Internal]
|
// - FindWindowSettingsByID() [Internal]
|
||||||
// - FindWindowSettingsByWindow() [Internal]
|
// - FindWindowSettingsByWindow() [Internal]
|
||||||
|
// - ClearWindowSettings() [Internal]
|
||||||
// - WindowSettingsHandler_***() [Internal]
|
// - WindowSettingsHandler_***() [Internal]
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -12686,11 +12687,11 @@ ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name)
|
|||||||
return settings;
|
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.
|
// 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;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiID id = ImHashStr(name);
|
|
||||||
for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
|
for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
|
||||||
if (settings->ID == id)
|
if (settings->ID == id)
|
||||||
return settings;
|
return settings;
|
||||||
@ -12703,7 +12704,7 @@ ImGuiWindowSettings* ImGui::FindWindowSettingsByWindow(ImGuiWindow* window)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (window->SettingsOffset != -1)
|
if (window->SettingsOffset != -1)
|
||||||
return g.SettingsWindows.ptr_from_offset(window->SettingsOffset);
|
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.
|
// 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;
|
window->Flags |= ImGuiWindowFlags_NoSavedSettings;
|
||||||
InitOrLoadWindowSettings(window, NULL);
|
InitOrLoadWindowSettings(window, NULL);
|
||||||
}
|
}
|
||||||
if (ImGuiWindowSettings* settings = window ? FindWindowSettingsByWindow(window) : FindWindowSettingsByName(name))
|
if (ImGuiWindowSettings* settings = window ? FindWindowSettingsByWindow(window) : FindWindowSettingsByID(ImHashStr(name)))
|
||||||
settings->WantDelete = true;
|
settings->WantDelete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12731,7 +12732,7 @@ static void WindowSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandl
|
|||||||
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
||||||
{
|
{
|
||||||
ImGuiID id = ImHashStr(name);
|
ImGuiID id = ImHashStr(name);
|
||||||
ImGuiWindowSettings* settings = ImGui::FindWindowSettingsByName(name);
|
ImGuiWindowSettings* settings = ImGui::FindWindowSettingsByID(id);
|
||||||
if (settings)
|
if (settings)
|
||||||
*settings = ImGuiWindowSettings(); // Clear existing if recycling previous entry
|
*settings = ImGuiWindowSettings(); // Clear existing if recycling previous entry
|
||||||
else
|
else
|
||||||
|
@ -2770,7 +2770,7 @@ namespace ImGui
|
|||||||
|
|
||||||
// Settings - Windows
|
// Settings - Windows
|
||||||
IMGUI_API ImGuiWindowSettings* CreateNewWindowSettings(const char* name);
|
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 ImGuiWindowSettings* FindWindowSettingsByWindow(ImGuiWindow* window);
|
||||||
IMGUI_API void ClearWindowSettings(const char* name);
|
IMGUI_API void ClearWindowSettings(const char* name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user