|
@@ -88,7 +88,6 @@ struct ImGuiTabItem; // Storage for a tab item (within a tab bar)
|
|
|
struct ImGuiWindow; // Storage for one window
|
|
struct ImGuiWindow; // Storage for one window
|
|
|
struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame)
|
|
struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame)
|
|
|
struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)
|
|
struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)
|
|
|
-template<typename T> struct ImPool; // Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID
|
|
|
|
|
|
|
|
|
|
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
|
|
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
|
|
|
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
|
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
|
@@ -145,6 +144,7 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
|
|
|
// - Helpers: Maths
|
|
// - Helpers: Maths
|
|
|
// - Helper: ImBoolVector
|
|
// - Helper: ImBoolVector
|
|
|
// - Helper: ImPool<>
|
|
// - Helper: ImPool<>
|
|
|
|
|
+// - Helper: ImChunkStream<>
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Macros
|
|
// Macros
|
|
@@ -307,23 +307,45 @@ typedef int ImPoolIdx;
|
|
|
template<typename T>
|
|
template<typename T>
|
|
|
struct IMGUI_API ImPool
|
|
struct IMGUI_API ImPool
|
|
|
{
|
|
{
|
|
|
- ImVector<T> Data; // Contiguous data
|
|
|
|
|
|
|
+ ImVector<T> Buf; // Contiguous data
|
|
|
ImGuiStorage Map; // ID->Index
|
|
ImGuiStorage Map; // ID->Index
|
|
|
ImPoolIdx FreeIdx; // Next free idx to use
|
|
ImPoolIdx FreeIdx; // Next free idx to use
|
|
|
|
|
|
|
|
ImPool() { FreeIdx = 0; }
|
|
ImPool() { FreeIdx = 0; }
|
|
|
~ImPool() { Clear(); }
|
|
~ImPool() { Clear(); }
|
|
|
- T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Data[idx] : NULL; }
|
|
|
|
|
- T* GetByIndex(ImPoolIdx n) { return &Data[n]; }
|
|
|
|
|
- ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Data.Data && p < Data.Data + Data.Size); return (ImPoolIdx)(p - Data.Data); }
|
|
|
|
|
- T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Data[*p_idx]; *p_idx = FreeIdx; return Add(); }
|
|
|
|
|
- bool Contains(const T* p) const { return (p >= Data.Data && p < Data.Data + Data.Size); }
|
|
|
|
|
- void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Data[idx].~T(); } Map.Clear(); Data.clear(); FreeIdx = 0; }
|
|
|
|
|
- T* Add() { int idx = FreeIdx; if (idx == Data.Size) { Data.resize(Data.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Data[idx]; } IM_PLACEMENT_NEW(&Data[idx]) T(); return &Data[idx]; }
|
|
|
|
|
|
|
+ T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Buf[idx] : NULL; }
|
|
|
|
|
+ T* GetByIndex(ImPoolIdx n) { return &Buf[n]; }
|
|
|
|
|
+ ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); }
|
|
|
|
|
+ T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); }
|
|
|
|
|
+ bool Contains(const T* p) const { return (p >= Buf.Data && p < Buf.Data + Buf.Size); }
|
|
|
|
|
+ void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = 0; }
|
|
|
|
|
+ T* Add() { int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); return &Buf[idx]; }
|
|
|
void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
|
|
void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
|
|
|
- void Remove(ImGuiID key, ImPoolIdx idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
|
|
|
|
|
- void Reserve(int capacity) { Data.reserve(capacity); Map.Data.reserve(capacity); }
|
|
|
|
|
- int GetSize() const { return Data.Size; }
|
|
|
|
|
|
|
+ void Remove(ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
|
|
|
|
|
+ void Reserve(int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); }
|
|
|
|
|
+ int GetSize() const { return Buf.Size; }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// Helper: ImChunkStream<>
|
|
|
|
|
+// Build and iterate a contiguous stream of variable-sized structures.
|
|
|
|
|
+// This is used by Settings to store persistent data while reducing allocation count.
|
|
|
|
|
+// We store the chunk size first, and align the final size on 4 bytes boundaries (this what the '(X + 3) & ~3' statement is for)
|
|
|
|
|
+// The tedious/zealous amount of casting is to avoid -Wcast-align warnings.
|
|
|
|
|
+template<typename T>
|
|
|
|
|
+struct IMGUI_API ImChunkStream
|
|
|
|
|
+{
|
|
|
|
|
+ ImVector<char> Buf;
|
|
|
|
|
+
|
|
|
|
|
+ void clear() { Buf.clear(); }
|
|
|
|
|
+ bool empty() const { return Buf.Size == 0; }
|
|
|
|
|
+ int size() const { return Buf.Size; }
|
|
|
|
|
+ T* alloc_chunk(size_t sz) { size_t HDR_SZ = 4; sz = ((HDR_SZ + sz) + 3u) & ~3u; int off = Buf.Size; Buf.resize(off + (int)sz); ((int*)(void*)(Buf.Data + off))[0] = (int)sz; return (T*)(void*)(Buf.Data + off + (int)HDR_SZ); }
|
|
|
|
|
+ T* begin() { size_t HDR_SZ = 4; if (!Buf.Data) return NULL; return (T*)(void*)(Buf.Data + HDR_SZ); }
|
|
|
|
|
+ T* next_chunk(T* p) { size_t HDR_SZ = 4; IM_ASSERT(p >= begin() && p < end()); p = (T*)(void*)((char*)(void*)p + chunk_size(p)); if (p == (T*)(void*)((char*)end() + HDR_SZ)) return (T*)0; IM_ASSERT(p < end()); return p; }
|
|
|
|
|
+ int chunk_size(const T* p) { return ((const int*)p)[-1]; }
|
|
|
|
|
+ T* end() { return (T*)(void*)(Buf.Data + Buf.Size); }
|
|
|
|
|
+ int offset_from_ptr(const T* p) { IM_ASSERT(p >= begin() && p < end()); const ptrdiff_t off = (const char*)p - Buf.Data; return (int)off; }
|
|
|
|
|
+ T* ptr_from_offset(int off) { IM_ASSERT(off >= 4 && off < Buf.Size); return (T*)(void*)(Buf.Data + off); }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
@@ -343,7 +365,7 @@ enum ImGuiButtonFlags_
|
|
|
ImGuiButtonFlags_DontClosePopups = 1 << 7, // disable automatically closing parent popup on press // [UNUSED]
|
|
ImGuiButtonFlags_DontClosePopups = 1 << 7, // disable automatically closing parent popup on press // [UNUSED]
|
|
|
ImGuiButtonFlags_Disabled = 1 << 8, // disable interactions
|
|
ImGuiButtonFlags_Disabled = 1 << 8, // disable interactions
|
|
|
ImGuiButtonFlags_AlignTextBaseLine = 1 << 9, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
|
|
ImGuiButtonFlags_AlignTextBaseLine = 1 << 9, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
|
|
|
- ImGuiButtonFlags_NoKeyModifiers = 1 << 10, // disable interaction if a key modifier is held
|
|
|
|
|
|
|
+ ImGuiButtonFlags_NoKeyModifiers = 1 << 10, // disable mouse interaction if a key modifier is held
|
|
|
ImGuiButtonFlags_NoHoldingActiveID = 1 << 11, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
|
ImGuiButtonFlags_NoHoldingActiveID = 1 << 11, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
|
|
ImGuiButtonFlags_PressedOnDragDropHold = 1 << 12, // press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
|
|
ImGuiButtonFlags_PressedOnDragDropHold = 1 << 12, // press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
|
|
|
ImGuiButtonFlags_NoNavFocus = 1 << 13, // don't override navigation focus when activated
|
|
ImGuiButtonFlags_NoNavFocus = 1 << 13, // don't override navigation focus when activated
|
|
@@ -422,8 +444,9 @@ enum ImGuiItemStatusFlags_
|
|
|
ImGuiItemStatusFlags_HasDisplayRect = 1 << 1,
|
|
ImGuiItemStatusFlags_HasDisplayRect = 1 << 1,
|
|
|
ImGuiItemStatusFlags_Edited = 1 << 2, // Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
|
|
ImGuiItemStatusFlags_Edited = 1 << 2, // Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
|
|
|
ImGuiItemStatusFlags_ToggledSelection = 1 << 3, // Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected" because reporting the change allows us to handle clipping with less issues.
|
|
ImGuiItemStatusFlags_ToggledSelection = 1 << 3, // Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected" because reporting the change allows us to handle clipping with less issues.
|
|
|
- ImGuiItemStatusFlags_HasDeactivated = 1 << 4, // Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag.
|
|
|
|
|
- ImGuiItemStatusFlags_Deactivated = 1 << 5 // Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
|
|
|
|
|
|
|
+ ImGuiItemStatusFlags_ToggledOpen = 1 << 4, // Set when TreeNode() reports toggling their open state.
|
|
|
|
|
+ ImGuiItemStatusFlags_HasDeactivated = 1 << 5, // Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag.
|
|
|
|
|
+ ImGuiItemStatusFlags_Deactivated = 1 << 6 // Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
|
|
|
|
|
|
|
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
|
|
, // [imgui_tests only]
|
|
, // [imgui_tests only]
|
|
@@ -681,15 +704,16 @@ struct IMGUI_API ImGuiInputTextState
|
|
|
|
|
|
|
|
// Windows data saved in imgui.ini file
|
|
// Windows data saved in imgui.ini file
|
|
|
// Because we never destroy or rename ImGuiWindowSettings, we can store the names in a separate buffer easily.
|
|
// Because we never destroy or rename ImGuiWindowSettings, we can store the names in a separate buffer easily.
|
|
|
|
|
+// (this is designed to be stored in a ImChunkStream buffer, with the variable-length Name following our structure)
|
|
|
struct ImGuiWindowSettings
|
|
struct ImGuiWindowSettings
|
|
|
{
|
|
{
|
|
|
- int NameOffset; // Offset into SettingsWindowNames[]
|
|
|
|
|
ImGuiID ID;
|
|
ImGuiID ID;
|
|
|
ImVec2ih Pos;
|
|
ImVec2ih Pos;
|
|
|
ImVec2ih Size;
|
|
ImVec2ih Size;
|
|
|
bool Collapsed;
|
|
bool Collapsed;
|
|
|
|
|
|
|
|
- ImGuiWindowSettings() { NameOffset = -1; ID = 0; Pos = Size = ImVec2ih(0, 0); Collapsed = false; }
|
|
|
|
|
|
|
+ ImGuiWindowSettings() { ID = 0; Pos = Size = ImVec2ih(0, 0); Collapsed = false; }
|
|
|
|
|
+ char* GetName() { return (char*)(this + 1); }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
struct ImGuiSettingsHandler
|
|
struct ImGuiSettingsHandler
|
|
@@ -1053,12 +1077,11 @@ struct ImGuiContext
|
|
|
ImVec2 PlatformImeLastPos;
|
|
ImVec2 PlatformImeLastPos;
|
|
|
|
|
|
|
|
// Settings
|
|
// Settings
|
|
|
- bool SettingsLoaded;
|
|
|
|
|
- float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero
|
|
|
|
|
- ImGuiTextBuffer SettingsIniData; // In memory .ini settings
|
|
|
|
|
- ImVector<ImGuiSettingsHandler> SettingsHandlers; // List of .ini settings handlers
|
|
|
|
|
- ImVector<ImGuiWindowSettings> SettingsWindows; // ImGuiWindow .ini settings entries (parsed from the last loaded .ini file and maintained on saving)
|
|
|
|
|
- ImGuiTextBuffer SettingsWindowsNames; // Names for SettingsWindows
|
|
|
|
|
|
|
+ bool SettingsLoaded;
|
|
|
|
|
+ float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero
|
|
|
|
|
+ ImGuiTextBuffer SettingsIniData; // In memory .ini settings
|
|
|
|
|
+ ImVector<ImGuiSettingsHandler> SettingsHandlers; // List of .ini settings handlers
|
|
|
|
|
+ ImChunkStream<ImGuiWindowSettings> SettingsWindows; // ImGuiWindow .ini settings entries
|
|
|
|
|
|
|
|
// Logging
|
|
// Logging
|
|
|
bool LogEnabled;
|
|
bool LogEnabled;
|
|
@@ -1369,7 +1392,7 @@ struct IMGUI_API ImGuiWindow
|
|
|
ImGuiStorage StateStorage;
|
|
ImGuiStorage StateStorage;
|
|
|
ImVector<ImGuiColumns> ColumnsStorage;
|
|
ImVector<ImGuiColumns> ColumnsStorage;
|
|
|
float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale()
|
|
float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale()
|
|
|
- int SettingsIdx; // Index into SettingsWindow[] (indices are always valid as we only grow the array from the back)
|
|
|
|
|
|
|
+ int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back)
|
|
|
|
|
|
|
|
ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
|
|
ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
|
|
|
ImDrawList DrawListInst;
|
|
ImDrawList DrawListInst;
|