Settings: Internals: Renamed ImGuiSettingsWindow to ImGuiWindowSettings.

docking
omar 7 years ago
parent 4a43632163
commit 963259d128

@ -643,8 +643,8 @@ static void AddDrawListToRenderList(ImVector<ImDrawList*>& out_rende
static void AddWindowToRenderList(ImVector<ImDrawList*>& out_render_list, ImGuiWindow* window); static void AddWindowToRenderList(ImVector<ImDrawList*>& out_render_list, ImGuiWindow* window);
static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>& out_sorted_windows, ImGuiWindow* window); static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>& out_sorted_windows, ImGuiWindow* window);
static ImGuiSettingsWindow* FindWindowSettings(const char* name); static ImGuiWindowSettings* FindWindowSettings(const char* name);
static ImGuiSettingsWindow* AddWindowSettings(const char* name); static ImGuiWindowSettings* AddWindowSettings(const char* name);
static void LoadIniSettingsFromDisk(const char* ini_filename); static void LoadIniSettingsFromDisk(const char* ini_filename);
static void LoadIniSettingsFromMemory(const char* buf); static void LoadIniSettingsFromMemory(const char* buf);
@ -2473,7 +2473,7 @@ void ImGui::NewFrame()
static void* SettingsHandlerWindow_ReadOpenEntry(ImGuiContext&, const char* name) static void* SettingsHandlerWindow_ReadOpenEntry(ImGuiContext&, const char* name)
{ {
ImGuiSettingsWindow* settings = FindWindowSettings(name); ImGuiWindowSettings* settings = FindWindowSettings(name);
if (!settings) if (!settings)
settings = AddWindowSettings(name); settings = AddWindowSettings(name);
return (void*)settings; return (void*)settings;
@ -2481,7 +2481,7 @@ static void* SettingsHandlerWindow_ReadOpenEntry(ImGuiContext&, const char* name
static void SettingsHandlerWindow_ReadLine(ImGuiContext&, void* entry, const char* line) static void SettingsHandlerWindow_ReadLine(ImGuiContext&, void* entry, const char* line)
{ {
ImGuiSettingsWindow* settings = (ImGuiSettingsWindow*)entry; ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry;
float x, y; float x, y;
int i; int i;
if (sscanf(line, "Pos=%f,%f", &x, &y) == 2) settings->Pos = ImVec2(x, y); if (sscanf(line, "Pos=%f,%f", &x, &y) == 2) settings->Pos = ImVec2(x, y);
@ -2497,7 +2497,7 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext& g, ImGuiTextBuffer* buf
ImGuiWindow* window = g.Windows[i]; ImGuiWindow* window = g.Windows[i];
if (window->Flags & ImGuiWindowFlags_NoSavedSettings) if (window->Flags & ImGuiWindowFlags_NoSavedSettings)
continue; continue;
ImGuiSettingsWindow* settings = FindWindowSettings(window->Name); ImGuiWindowSettings* settings = FindWindowSettings(window->Name);
if (!settings) // This will only return NULL in the rare instance where the window was first created with ImGuiWindowFlags_NoSavedSettings then had the flag disabled later on. We don't bind settings in this case (bug #1000). if (!settings) // This will only return NULL in the rare instance where the window was first created with ImGuiWindowFlags_NoSavedSettings then had the flag disabled later on. We don't bind settings in this case (bug #1000).
continue; continue;
settings->Pos = window->Pos; settings->Pos = window->Pos;
@ -2510,7 +2510,7 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext& g, ImGuiTextBuffer* buf
buf->reserve(buf->size() + g.SettingsWindows.Size * 96); // ballpark reserve buf->reserve(buf->size() + g.SettingsWindows.Size * 96); // ballpark reserve
for (int i = 0; i != g.SettingsWindows.Size; i++) for (int i = 0; i != g.SettingsWindows.Size; i++)
{ {
const ImGuiSettingsWindow* settings = &g.SettingsWindows[i]; const ImGuiWindowSettings* settings = &g.SettingsWindows[i];
if (settings->Pos.x == FLT_MAX) if (settings->Pos.x == FLT_MAX)
continue; continue;
const char* name = settings->Name; const char* name = settings->Name;
@ -2609,24 +2609,24 @@ void ImGui::Shutdown()
g.Initialized = false; g.Initialized = false;
} }
static ImGuiSettingsWindow* FindWindowSettings(const char* name) static ImGuiWindowSettings* FindWindowSettings(const char* name)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiID id = ImHash(name, 0); ImGuiID id = ImHash(name, 0);
for (int i = 0; i != g.SettingsWindows.Size; i++) for (int i = 0; i != g.SettingsWindows.Size; i++)
{ {
ImGuiSettingsWindow* ini = &g.SettingsWindows[i]; ImGuiWindowSettings* ini = &g.SettingsWindows[i];
if (ini->Id == id) if (ini->Id == id)
return ini; return ini;
} }
return NULL; return NULL;
} }
static ImGuiSettingsWindow* AddWindowSettings(const char* name) static ImGuiWindowSettings* AddWindowSettings(const char* name)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
g.SettingsWindows.resize(g.SettingsWindows.Size + 1); g.SettingsWindows.resize(g.SettingsWindows.Size + 1);
ImGuiSettingsWindow* settings = &g.SettingsWindows.back(); ImGuiWindowSettings* settings = &g.SettingsWindows.back();
settings->Name = ImStrdup(name); settings->Name = ImStrdup(name);
settings->Id = ImHash(name, 0); settings->Id = ImHash(name, 0);
settings->Collapsed = false; settings->Collapsed = false;
@ -4078,7 +4078,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
window->PosFloat = ImVec2(60, 60); window->PosFloat = ImVec2(60, 60);
window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y); window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);
ImGuiSettingsWindow* settings = FindWindowSettings(name); ImGuiWindowSettings* settings = FindWindowSettings(name);
if (!settings) if (!settings)
settings = AddWindowSettings(name); settings = AddWindowSettings(name);
else else

@ -38,10 +38,10 @@ struct ImGuiGroupData;
struct ImGuiSimpleColumns; struct ImGuiSimpleColumns;
struct ImGuiDrawContext; struct ImGuiDrawContext;
struct ImGuiTextEditState; struct ImGuiTextEditState;
struct ImGuiSettingsWindow;
struct ImGuiMouseCursorData; struct ImGuiMouseCursorData;
struct ImGuiPopupRef; struct ImGuiPopupRef;
struct ImGuiWindow; struct ImGuiWindow;
struct ImGuiWindowSettings;
typedef int ImGuiLayoutType; // enum: horizontal or vertical // enum ImGuiLayoutType_ typedef int ImGuiLayoutType; // enum: horizontal or vertical // enum ImGuiLayoutType_
typedef int ImGuiButtonFlags; // flags: for ButtonEx(), ButtonBehavior() // enum ImGuiButtonFlags_ typedef int ImGuiButtonFlags; // flags: for ButtonEx(), ButtonBehavior() // enum ImGuiButtonFlags_
@ -371,7 +371,7 @@ struct IMGUI_API ImGuiTextEditState
}; };
// Data saved in imgui.ini file // Data saved in imgui.ini file
struct ImGuiSettingsWindow struct ImGuiWindowSettings
{ {
char* Name; char* Name;
ImGuiID Id; ImGuiID Id;
@ -379,7 +379,7 @@ struct ImGuiSettingsWindow
ImVec2 Size; ImVec2 Size;
bool Collapsed; bool Collapsed;
ImGuiSettingsWindow() { Name = NULL; Id = 0; Pos = Size = ImVec2(0,0); Collapsed = false; } ImGuiWindowSettings() { Name = NULL; Id = 0; Pos = Size = ImVec2(0,0); Collapsed = false; }
}; };
struct ImGuiSettingsHandler struct ImGuiSettingsHandler
@ -500,7 +500,7 @@ struct ImGuiContext
// Settings // Settings
float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
ImVector<ImGuiSettingsWindow> SettingsWindows; // .ini settings for ImGuiWindow ImVector<ImGuiWindowSettings> SettingsWindows; // .ini settings for ImGuiWindow
ImVector<ImGuiSettingsHandler> SettingsHandlers; // List of .ini settings handlers ImVector<ImGuiSettingsHandler> SettingsHandlers; // List of .ini settings handlers
// Logging // Logging

Loading…
Cancel
Save