Skip to content

Commit

Permalink
Columns: Refactor: Moved ColumnsSet[] to window out of DC as they are…
Browse files Browse the repository at this point in the history
… persistent data for most + fix for pre C++11 compilers. (#125, #1499)
  • Loading branch information
ocornut committed Dec 13, 2017
1 parent b016215 commit 4ae5c7e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10935,12 +10935,12 @@ void ImGui::PushColumnClipRect(int column_index)

static ImGuiColumnsSet* FindOrAddColumnsSet(ImGuiWindow* window, ImGuiID id)
{
for (int n = 0; n < window->DC.ColumnsSets.Size; n++)
if (window->DC.ColumnsSets[n].ID == id)
return &window->DC.ColumnsSets[n];
for (int n = 0; n < window->ColumnsStorage.Size; n++)
if (window->ColumnsStorage[n].ID == id)
return &window->ColumnsStorage[n];

window->DC.ColumnsSets.push_back(ImGuiColumnsSet());
ImGuiColumnsSet* columns = &window->DC.ColumnsSets.back();
window->ColumnsStorage.push_back(ImGuiColumnsSet());
ImGuiColumnsSet* columns = &window->ColumnsStorage.back();
columns->ID = id;
return columns;
}
Expand Down
20 changes: 10 additions & 10 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ enum ImGuiColumnsFlags_
ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers
ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns
ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window
ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4, // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove.
ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4 // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove.
};

enum ImGuiSelectableFlagsPrivate_
Expand Down Expand Up @@ -403,19 +403,19 @@ struct ImGuiMouseCursorData
// Storage for current popup stack
struct ImGuiPopupRef
{
ImGuiID PopupId; // Set on OpenPopup()
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
ImGuiWindow* ParentWindow; // Set on OpenPopup()
ImGuiID ParentMenuSet; // Set on OpenPopup()
ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup
ImGuiID PopupId; // Set on OpenPopup()
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
ImGuiWindow* ParentWindow; // Set on OpenPopup()
ImGuiID ParentMenuSet; // Set on OpenPopup()
ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup

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; }
};

struct ImGuiColumnData
{
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
ImRect ClipRect;
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
ImRect ClipRect;

ImGuiColumnData() { OffsetNorm = 0.0f; }
};
Expand Down Expand Up @@ -701,8 +701,7 @@ 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.
ImGuiColumnsSet* ColumnsSet;
ImVector<ImGuiColumnsSet> ColumnsSets;
ImGuiColumnsSet* ColumnsSet; // Current columns set

ImGuiDrawContext()
{
Expand Down Expand Up @@ -784,6 +783,7 @@ struct IMGUI_API ImGuiWindow
float ItemWidthDefault;
ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
ImGuiStorage StateStorage;
ImVector<ImGuiColumnsSet> ColumnsStorage;
float FontWindowScale; // Scale multiplier per-window
ImDrawList* DrawList;
ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
Expand Down

0 comments on commit 4ae5c7e

Please sign in to comment.