Save imgui.ini to %APPDATA%\UsdLayerManager\ instead of CWD
Sets io.IniFilename to %APPDATA%\UsdLayerManager\imgui.ini right after CreateContext so ImGui never touches the working directory for layout persistence. The directory is created on first run via create_directories. m_iniFilePath on ImGuiContext holds the string so the pointer stays valid for the lifetime of the context. Also removes imgui.ini from version control and adds it to .gitignore. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -72,3 +72,6 @@ desktop.ini
|
|||||||
# Temporary files
|
# Temporary files
|
||||||
*.tmp
|
*.tmp
|
||||||
*.temp
|
*.temp
|
||||||
|
|
||||||
|
# ImGui layout (saved to %APPDATA%\UsdLayerManager at runtime)
|
||||||
|
imgui.ini
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
[Window][WindowOverViewport_11111111]
|
|
||||||
Pos=0,22
|
|
||||||
Size=1920,1093
|
|
||||||
Collapsed=0
|
|
||||||
|
|
||||||
[Window][Debug##Default]
|
|
||||||
Pos=60,60
|
|
||||||
Size=400,400
|
|
||||||
Collapsed=0
|
|
||||||
|
|
||||||
[Window][Scene Hierarchy]
|
|
||||||
Pos=0,22
|
|
||||||
Size=285,655
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000001,0
|
|
||||||
|
|
||||||
[Window][Layer Panel]
|
|
||||||
Pos=60,60
|
|
||||||
Size=121,48
|
|
||||||
Collapsed=0
|
|
||||||
|
|
||||||
[Window][Viewport]
|
|
||||||
Pos=287,22
|
|
||||||
Size=1286,1003
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000007,0
|
|
||||||
|
|
||||||
[Window][Property Panel]
|
|
||||||
Pos=1575,22
|
|
||||||
Size=345,1093
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000006,0
|
|
||||||
|
|
||||||
[Window][Stage Info]
|
|
||||||
Pos=0,22
|
|
||||||
Size=285,655
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000001,1
|
|
||||||
|
|
||||||
[Window][Stage Editor]
|
|
||||||
Pos=0,679
|
|
||||||
Size=285,436
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000002,0
|
|
||||||
|
|
||||||
[Window][Timeline]
|
|
||||||
Pos=287,1027
|
|
||||||
Size=1286,88
|
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000008,0
|
|
||||||
|
|
||||||
[Docking][Data]
|
|
||||||
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,22 Size=1920,1093 Split=X
|
|
||||||
DockNode ID=0x00000005 Parent=0x08BD597D SizeRef=1573,637 Split=X
|
|
||||||
DockNode ID=0x00000003 Parent=0x00000005 SizeRef=285,637 Split=Y Selected=0xB8729153
|
|
||||||
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=289,381 Selected=0xB8729153
|
|
||||||
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=289,254 Selected=0xBE78FE5F
|
|
||||||
DockNode ID=0x00000004 Parent=0x00000005 SizeRef=1286,637 Split=Y Selected=0xC450F867
|
|
||||||
DockNode ID=0x00000007 Parent=0x00000004 SizeRef=850,547 CentralNode=1 Selected=0xC450F867
|
|
||||||
DockNode ID=0x00000008 Parent=0x00000004 SizeRef=850,88 Selected=0x4F89F0DC
|
|
||||||
DockNode ID=0x00000006 Parent=0x08BD597D SizeRef=345,637 Selected=0xFA2314A6
|
|
||||||
|
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <imgui_impl_win32.h>
|
#include <imgui_impl_win32.h>
|
||||||
#include <imgui_impl_opengl3.h>
|
#include <imgui_impl_opengl3.h>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
// Forward declare message handler from imgui_impl_win32.cpp
|
// Forward declare message handler from imgui_impl_win32.cpp
|
||||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
@@ -94,6 +95,15 @@ bool ImGuiContext::Initialize(const std::string& windowTitle, int width, int hei
|
|||||||
// ImGui window is focused, which would block all viewport hotkeys (F, A, etc.).
|
// ImGui window is focused, which would block all viewport hotkeys (F, A, etc.).
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||||
|
|
||||||
|
// Store imgui.ini in %APPDATA%\UsdLayerManager\ so it doesn't litter the CWD.
|
||||||
|
if (const char* appData = getenv("APPDATA")) {
|
||||||
|
std::filesystem::path iniDir =
|
||||||
|
std::filesystem::path(appData) / "UsdLayerManager";
|
||||||
|
std::filesystem::create_directories(iniDir);
|
||||||
|
m_iniFilePath = (iniDir / "imgui.ini").string();
|
||||||
|
io.IniFilename = m_iniFilePath.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// Load Inter font.
|
// Load Inter font.
|
||||||
// The build directory copies the font as Inter.ttc; the install step renames
|
// The build directory copies the font as Inter.ttc; the install step renames
|
||||||
// it to Inter.ttf. Try .ttf first (install layout), fall back to .ttc (build).
|
// it to Inter.ttf. Try .ttf first (install layout), fall back to .ttc (build).
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ private:
|
|||||||
bool m_shouldClose;
|
bool m_shouldClose;
|
||||||
int m_width;
|
int m_width;
|
||||||
int m_height;
|
int m_height;
|
||||||
|
std::string m_iniFilePath; // persists for the lifetime of the ImGui context
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace UsdLayerManager
|
} // namespace UsdLayerManager
|
||||||
|
|||||||
Reference in New Issue
Block a user