mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Columns: Refactor: Moved columns data into their own data structure. Minimum changes now to ease diffing. (#125, #1499)
This commit is contained in:
@ -331,14 +331,6 @@ struct ImGuiGroupData
|
||||
bool AdvanceCursor;
|
||||
};
|
||||
|
||||
// Per column data for Columns()
|
||||
struct ImGuiColumnData
|
||||
{
|
||||
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
|
||||
ImRect ClipRect;
|
||||
//float IndentX;
|
||||
};
|
||||
|
||||
// Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper.
|
||||
struct IMGUI_API ImGuiSimpleColumns
|
||||
{
|
||||
@ -420,6 +412,42 @@ struct ImGuiPopupRef
|
||||
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
|
||||
};
|
||||
|
||||
// Per column data for Columns()
|
||||
struct ImGuiColumnData
|
||||
{
|
||||
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
|
||||
ImRect ClipRect;
|
||||
};
|
||||
|
||||
struct ImGuiColumnsSet
|
||||
{
|
||||
int ColumnsCurrent;
|
||||
int ColumnsCount;
|
||||
float ColumnsMinX;
|
||||
float ColumnsMaxX;
|
||||
float ColumnsStartPosY;
|
||||
float ColumnsStartMaxPosX; // Backup of CursorMaxPos
|
||||
float ColumnsCellMinY;
|
||||
float ColumnsCellMaxY;
|
||||
ImGuiColumnsFlags ColumnsFlags;
|
||||
ImGuiID ColumnsSetId;
|
||||
ImVector<ImGuiColumnData> ColumnsData;
|
||||
|
||||
ImGuiColumnsSet() { Clear(); }
|
||||
void Clear()
|
||||
{
|
||||
ColumnsCurrent = 0;
|
||||
ColumnsCount = 1;
|
||||
ColumnsMinX = ColumnsMaxX = 0.0f;
|
||||
ColumnsStartPosY = 0.0f;
|
||||
ColumnsStartMaxPosX = 0.0f;
|
||||
ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
|
||||
ColumnsFlags = 0;
|
||||
ColumnsSetId = 0;
|
||||
ColumnsData.clear();
|
||||
}
|
||||
};
|
||||
|
||||
// Main state for ImGui
|
||||
struct ImGuiContext
|
||||
{
|
||||
@ -674,17 +702,8 @@ struct IMGUI_API ImGuiDrawContext
|
||||
float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
|
||||
float GroupOffsetX;
|
||||
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.
|
||||
int ColumnsCurrent;
|
||||
int ColumnsCount;
|
||||
float ColumnsMinX;
|
||||
float ColumnsMaxX;
|
||||
float ColumnsStartPosY;
|
||||
float ColumnsStartMaxPosX; // Backup of CursorMaxPos
|
||||
float ColumnsCellMinY;
|
||||
float ColumnsCellMaxY;
|
||||
ImGuiColumnsFlags ColumnsFlags;
|
||||
ImGuiID ColumnsSetId;
|
||||
ImVector<ImGuiColumnData> ColumnsData;
|
||||
ImGuiColumnsSet* ColumnsSet;
|
||||
ImVector<ImGuiColumnsSet> ColumnsSets;
|
||||
|
||||
ImGuiDrawContext()
|
||||
{
|
||||
@ -708,14 +727,7 @@ struct IMGUI_API ImGuiDrawContext
|
||||
IndentX = 0.0f;
|
||||
GroupOffsetX = 0.0f;
|
||||
ColumnsOffsetX = 0.0f;
|
||||
ColumnsCurrent = 0;
|
||||
ColumnsCount = 1;
|
||||
ColumnsMinX = ColumnsMaxX = 0.0f;
|
||||
ColumnsStartPosY = 0.0f;
|
||||
ColumnsStartMaxPosX = 0.0f;
|
||||
ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
|
||||
ColumnsFlags = 0;
|
||||
ColumnsSetId = 0;
|
||||
ColumnsSet = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
@ -877,8 +889,8 @@ namespace ImGui
|
||||
IMGUI_API bool IsDragDropPayloadBeingAccepted();
|
||||
|
||||
// FIXME-WIP: New Columns API
|
||||
IMGUI_API void BeginColumns(const char* id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
|
||||
IMGUI_API void EndColumns(); // close columns
|
||||
IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
|
||||
IMGUI_API void EndColumns(); // close columns
|
||||
IMGUI_API void PushColumnClipRect(int column_index = -1);
|
||||
|
||||
// NB: All position are in absolute pixels coordinates (never using window coordinates internally)
|
||||
|
Reference in New Issue
Block a user