Updated ImGui.
This commit is contained in:
parent
5d83b6fa4c
commit
f094ca0d38
43
3rdparty/ocornut-imgui/imgui.cpp
vendored
43
3rdparty/ocornut-imgui/imgui.cpp
vendored
@ -689,9 +689,9 @@ static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>& out_sort
|
|||||||
|
|
||||||
static ImGuiIniData* FindWindowSettings(const char* name);
|
static ImGuiIniData* FindWindowSettings(const char* name);
|
||||||
static ImGuiIniData* AddWindowSettings(const char* name);
|
static ImGuiIniData* AddWindowSettings(const char* name);
|
||||||
static void LoadSettings();
|
static void LoadIniSettingsFromDisk(const char* ini_filename);
|
||||||
static void SaveSettings();
|
static void SaveIniSettingsToDisk(const char* ini_filename);
|
||||||
static void MarkSettingsDirty();
|
static void MarkIniSettingsDirty();
|
||||||
|
|
||||||
static void PushColumnClipRect(int column_index = -1);
|
static void PushColumnClipRect(int column_index = -1);
|
||||||
static ImRect GetVisibleRect();
|
static ImRect GetVisibleRect();
|
||||||
@ -2140,7 +2140,7 @@ void ImGui::NewFrame()
|
|||||||
IM_PLACEMENT_NEW(g.LogClipboard) ImGuiTextBuffer();
|
IM_PLACEMENT_NEW(g.LogClipboard) ImGuiTextBuffer();
|
||||||
|
|
||||||
IM_ASSERT(g.Settings.empty());
|
IM_ASSERT(g.Settings.empty());
|
||||||
LoadSettings();
|
LoadIniSettingsFromDisk(g.IO.IniFilename);
|
||||||
g.Initialized = true;
|
g.Initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2225,8 +2225,8 @@ void ImGui::NewFrame()
|
|||||||
if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoMove))
|
if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||||
{
|
{
|
||||||
g.MovedWindow->PosFloat += g.IO.MouseDelta;
|
g.MovedWindow->PosFloat += g.IO.MouseDelta;
|
||||||
if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoSavedSettings))
|
if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoSavedSettings) && (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f))
|
||||||
MarkSettingsDirty();
|
MarkIniSettingsDirty();
|
||||||
}
|
}
|
||||||
FocusWindow(g.MovedWindow);
|
FocusWindow(g.MovedWindow);
|
||||||
}
|
}
|
||||||
@ -2248,7 +2248,7 @@ void ImGui::NewFrame()
|
|||||||
{
|
{
|
||||||
g.SettingsDirtyTimer -= g.IO.DeltaTime;
|
g.SettingsDirtyTimer -= g.IO.DeltaTime;
|
||||||
if (g.SettingsDirtyTimer <= 0.0f)
|
if (g.SettingsDirtyTimer <= 0.0f)
|
||||||
SaveSettings();
|
SaveIniSettingsToDisk(g.IO.IniFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the window we are hovering. Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow
|
// Find the window we are hovering. Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow
|
||||||
@ -2375,7 +2375,7 @@ void ImGui::Shutdown()
|
|||||||
if (!g.Initialized)
|
if (!g.Initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SaveSettings();
|
SaveIniSettingsToDisk(g.IO.IniFilename);
|
||||||
|
|
||||||
for (int i = 0; i < g.Windows.Size; i++)
|
for (int i = 0; i < g.Windows.Size; i++)
|
||||||
{
|
{
|
||||||
@ -2455,15 +2455,14 @@ static ImGuiIniData* AddWindowSettings(const char* name)
|
|||||||
|
|
||||||
// Zero-tolerance, poor-man .ini parsing
|
// Zero-tolerance, poor-man .ini parsing
|
||||||
// FIXME: Write something less rubbish
|
// FIXME: Write something less rubbish
|
||||||
static void LoadSettings()
|
static void LoadIniSettingsFromDisk(const char* ini_filename)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const char* filename = g.IO.IniFilename;
|
if (!ini_filename)
|
||||||
if (!filename)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int file_size;
|
int file_size;
|
||||||
char* file_data = (char*)ImLoadFileToMemory(filename, "rb", &file_size, 1);
|
char* file_data = (char*)ImLoadFileToMemory(ini_filename, "rb", &file_size, 1);
|
||||||
if (!file_data)
|
if (!file_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -2501,11 +2500,11 @@ static void LoadSettings()
|
|||||||
ImGui::MemFree(file_data);
|
ImGui::MemFree(file_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SaveSettings()
|
static void SaveIniSettingsToDisk(const char* ini_filename)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const char* filename = g.IO.IniFilename;
|
g.SettingsDirtyTimer = 0.0f;
|
||||||
if (!filename)
|
if (!ini_filename)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Gather data from windows that were active during this session
|
// Gather data from windows that were active during this session
|
||||||
@ -2522,7 +2521,7 @@ static void SaveSettings()
|
|||||||
|
|
||||||
// Write .ini file
|
// Write .ini file
|
||||||
// If a window wasn't opened in this session we preserve its settings
|
// If a window wasn't opened in this session we preserve its settings
|
||||||
FILE* f = ImFileOpen(filename, "wt");
|
FILE* f = ImFileOpen(ini_filename, "wt");
|
||||||
if (!f)
|
if (!f)
|
||||||
return;
|
return;
|
||||||
for (int i = 0; i != g.Settings.Size; i++)
|
for (int i = 0; i != g.Settings.Size; i++)
|
||||||
@ -2543,7 +2542,7 @@ static void SaveSettings()
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MarkSettingsDirty()
|
static void MarkIniSettingsDirty()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (g.SettingsDirtyTimer <= 0.0f)
|
if (g.SettingsDirtyTimer <= 0.0f)
|
||||||
@ -4015,7 +4014,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|||||||
{
|
{
|
||||||
window->Collapsed = !window->Collapsed;
|
window->Collapsed = !window->Collapsed;
|
||||||
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
||||||
MarkSettingsDirty();
|
MarkIniSettingsDirty();
|
||||||
FocusWindow(window);
|
FocusWindow(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4090,7 +4089,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|||||||
if (window->AutoFitFramesY > 0)
|
if (window->AutoFitFramesY > 0)
|
||||||
window->SizeFull.y = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.y, size_auto_fit.y) : size_auto_fit.y;
|
window->SizeFull.y = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.y, size_auto_fit.y) : size_auto_fit.y;
|
||||||
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
||||||
MarkSettingsDirty();
|
MarkIniSettingsDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4219,7 +4218,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|||||||
// Manual auto-fit when double-clicking
|
// Manual auto-fit when double-clicking
|
||||||
ApplySizeFullWithConstraint(window, size_auto_fit);
|
ApplySizeFullWithConstraint(window, size_auto_fit);
|
||||||
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
||||||
MarkSettingsDirty();
|
MarkIniSettingsDirty();
|
||||||
SetActiveID(0);
|
SetActiveID(0);
|
||||||
}
|
}
|
||||||
else if (held)
|
else if (held)
|
||||||
@ -4227,7 +4226,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|||||||
// We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position
|
// We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position
|
||||||
ApplySizeFullWithConstraint(window, (g.IO.MousePos - g.ActiveIdClickOffset + resize_rect.GetSize()) - window->Pos);
|
ApplySizeFullWithConstraint(window, (g.IO.MousePos - g.ActiveIdClickOffset + resize_rect.GetSize()) - window->Pos);
|
||||||
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
||||||
MarkSettingsDirty();
|
MarkIniSettingsDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
window->Size = window->SizeFull;
|
window->Size = window->SizeFull;
|
||||||
@ -6522,7 +6521,7 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
|
|||||||
if (g.IO.MouseDown[0])
|
if (g.IO.MouseDown[0])
|
||||||
{
|
{
|
||||||
const float mouse_abs_pos = is_horizontal ? g.IO.MousePos.x : g.IO.MousePos.y;
|
const float mouse_abs_pos = is_horizontal ? g.IO.MousePos.x : g.IO.MousePos.y;
|
||||||
float clicked_t = ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f);
|
float clicked_t = (slider_usable_sz > 0.0f) ? ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f) : 0.0f;
|
||||||
if (!is_horizontal)
|
if (!is_horizontal)
|
||||||
clicked_t = 1.0f - clicked_t;
|
clicked_t = 1.0f - clicked_t;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user