1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 01:20:55 +01:00

Internals: Forward declaring and commenting internal structures. Renamed ImGuiDrawContext to ImGuiWindowTempData, but kept .DC member name for backward compatibility purpose

This commit is contained in:
omar 2018-05-16 18:34:12 +02:00
parent 86f8cdbd98
commit ede5059e69
2 changed files with 32 additions and 22 deletions

View File

@ -4087,7 +4087,7 @@ void ImGui::EndFrame()
} }
// Hide implicit "Debug" window if it hasn't been used // Hide implicit "Debug" window if it hasn't been used
IM_ASSERT(g.CurrentWindowStack.Size == 1); // Mismatched Begin()/End() calls IM_ASSERT(g.CurrentWindowStack.Size == 1); // Mismatched Begin()/End() calls, did you forget to call end on g.CurrentWindow->Name?
if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed) if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed)
g.CurrentWindow->Active = false; g.CurrentWindow->Active = false;
End(); End();
@ -11220,7 +11220,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
return false; return false;
} }
// We use NoHoldingActiveID on menus so that use can click and hold on menu and drag to browse child entries // We use NoHoldingActiveID on menus so user can click and _hold_ on a menu then drag to browse child entries
ImGuiButtonFlags button_flags = 0; ImGuiButtonFlags button_flags = 0;
if (flags & ImGuiSelectableFlags_NoHoldingActiveID) button_flags |= ImGuiButtonFlags_NoHoldingActiveID; if (flags & ImGuiSelectableFlags_NoHoldingActiveID) button_flags |= ImGuiButtonFlags_NoHoldingActiveID;
if (flags & ImGuiSelectableFlags_PressedOnClick) button_flags |= ImGuiButtonFlags_PressedOnClick; if (flags & ImGuiSelectableFlags_PressedOnClick) button_flags |= ImGuiButtonFlags_PressedOnClick;

View File

@ -33,16 +33,25 @@
// Forward Declarations // Forward Declarations
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct ImRect; struct ImRect; // An axis-aligned rectangle (2 points)
struct ImGuiColMod; struct ImDrawDataBuilder; // Helper to build a ImDrawData instance
struct ImGuiStyleMod; struct ImDrawListSharedData; // Data shared between all ImDrawList instances
struct ImGuiGroupData; struct ImGuiColMod; // Stacked color modifier, backup of modified data so we can restore it
struct ImGuiMenuColumns; struct ImGuiColumnData; // Storage data for a single column
struct ImGuiDrawContext; struct ImGuiColumnsSet; // Storage data for a columns set
struct ImGuiTextEditState; struct ImGuiContext; // Main imgui context
struct ImGuiPopupRef; struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
struct ImGuiWindow; struct ImGuiItemHoveredDataBackup; // Backup and restore IsItemHovered() internal data
struct ImGuiWindowSettings; struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
struct ImGuiNavMoveResult; // Result of a directional navigation move query result
struct ImGuiNextWindowData; // Storage for SetNexWindow** functions
struct ImGuiPopupRef; // Storage for current popup stack
struct ImGuiSettingsHandler;
struct ImGuiStyleMod; // Stacked style modifier, backup of modified data so we can restore it
struct ImGuiTextEditState; // Internal state of the currently focused/edited text input box
struct ImGuiWindow; // Storage for one window
struct ImGuiWindowTempData; // Temporary storage for one, that's the data which in theory we could ditch at the end of the frame
struct ImGuiWindowSettings; // Storage for window settings stored in .ini file (we keep one of those even if the actual window wasn't instanced during this session)
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_
@ -372,7 +381,7 @@ struct ImGuiStyleMod
ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; } ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
}; };
// Stacked data for BeginGroup()/EndGroup() // Stacked storage data for BeginGroup()/EndGroup()
struct ImGuiGroupData struct ImGuiGroupData
{ {
ImVec2 BackupCursorPos; ImVec2 BackupCursorPos;
@ -386,7 +395,7 @@ struct ImGuiGroupData
bool AdvanceCursor; bool AdvanceCursor;
}; };
// Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper. // Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper.
struct IMGUI_API ImGuiMenuColumns struct IMGUI_API ImGuiMenuColumns
{ {
int Count; int Count;
@ -424,7 +433,7 @@ struct IMGUI_API ImGuiTextEditState
void OnKeyPressed(int key); void OnKeyPressed(int key);
}; };
// Data saved in imgui.ini file // Windows data saved in imgui.ini file
struct ImGuiWindowSettings struct ImGuiWindowSettings
{ {
char* Name; char* Name;
@ -501,6 +510,7 @@ struct ImGuiColumnsSet
} }
}; };
// Data shared between all ImDrawList instances
struct IMGUI_API ImDrawListSharedData struct IMGUI_API ImDrawListSharedData
{ {
ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas
@ -579,7 +589,7 @@ struct ImGuiNextWindowData
} }
}; };
// Main state for ImGui // Main imgui context
struct ImGuiContext struct ImGuiContext
{ {
bool Initialized; bool Initialized;
@ -832,9 +842,9 @@ enum ImGuiItemFlags_
ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus
}; };
// Transient per-window data, reset at the beginning of the frame // Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow.
// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered. // FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered.
struct IMGUI_API ImGuiDrawContext struct IMGUI_API ImGuiWindowTempData
{ {
ImVec2 CursorPos; ImVec2 CursorPos;
ImVec2 CursorPosPrevLine; ImVec2 CursorPosPrevLine;
@ -879,7 +889,7 @@ struct IMGUI_API ImGuiDrawContext
float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API. float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
ImGuiColumnsSet* ColumnsSet; // Current columns set ImGuiColumnsSet* ColumnsSet; // Current columns set
ImGuiDrawContext() ImGuiWindowTempData()
{ {
CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f); CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
CurrentLineHeight = PrevLineHeight = 0.0f; CurrentLineHeight = PrevLineHeight = 0.0f;
@ -911,7 +921,7 @@ struct IMGUI_API ImGuiDrawContext
} }
}; };
// Windows data // Storage for one window
struct IMGUI_API ImGuiWindow struct IMGUI_API ImGuiWindow
{ {
char* Name; char* Name;
@ -956,7 +966,7 @@ struct IMGUI_API ImGuiWindow
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size) ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right. ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right.
ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame ImGuiWindowTempData DC; // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name.
ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
ImRect ClipRect; // Current clipping rectangle. = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2. ImRect ClipRect; // Current clipping rectangle. = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
ImRect OuterRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window. ImRect OuterRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window.