mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 16:29:02 +08:00
Internals: Minor ordering/comments of ImGuiWindowTempData.
This commit is contained in:
parent
f56962cb9a
commit
52334ad8df
@ -5859,7 +5859,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->DC.TextWrapPosStack.resize(0);
|
||||
window->DC.CurrentColumns = NULL;
|
||||
window->DC.TreeDepth = 0;
|
||||
window->DC.TreeMayJumpToParentOnPopMask = 0x00;
|
||||
window->DC.TreeJumpToParentOnPopMask = 0x00;
|
||||
window->DC.StateStorage = &window->StateStorage;
|
||||
window->DC.GroupStack.resize(0);
|
||||
window->MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user);
|
||||
|
@ -1310,6 +1310,7 @@ struct ImGuiContext
|
||||
// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered.
|
||||
struct IMGUI_API ImGuiWindowTempData
|
||||
{
|
||||
// Layout
|
||||
ImVec2 CursorPos; // Current emitting position, in absolute coordinates.
|
||||
ImVec2 CursorPosPrevLine;
|
||||
ImVec2 CursorStartPos; // Initial position after Begin(), generally ~ window position + WindowPadding.
|
||||
@ -1318,27 +1319,38 @@ struct IMGUI_API ImGuiWindowTempData
|
||||
ImVec2 PrevLineSize;
|
||||
float CurrLineTextBaseOffset; // Baseline offset (0.0f by default on a new line, generally == style.FramePadding.y when a framed item has been added).
|
||||
float PrevLineTextBaseOffset;
|
||||
int TreeDepth; // Current tree depth.
|
||||
ImU32 TreeMayJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary.
|
||||
ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
|
||||
ImVec1 ColumnsOffset; // 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.
|
||||
ImVec1 GroupOffset;
|
||||
|
||||
// Last item status
|
||||
ImGuiID LastItemId; // ID for last item
|
||||
ImGuiItemStatusFlags LastItemStatusFlags; // Status flags for last item (see ImGuiItemStatusFlags_)
|
||||
ImRect LastItemRect; // Interaction rect for last item
|
||||
ImRect LastItemDisplayRect; // End-user display rect for last item (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect)
|
||||
|
||||
// Keyboard/Gamepad navigation
|
||||
ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
|
||||
int NavLayerCurrentMask; // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping.
|
||||
int NavLayerActiveMask; // Which layer have been written to (result from previous frame)
|
||||
int NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame)
|
||||
bool NavHideHighlightOneFrame;
|
||||
bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f)
|
||||
|
||||
// Miscellaneous
|
||||
bool MenuBarAppending; // FIXME: Remove this
|
||||
ImVec2 MenuBarOffset; // MenuBarOffset.x is sort of equivalent of a per-layer CursorPos.x, saved/restored as we switch to the menu bar. The only situation when MenuBarOffset.y is > 0 if when (SafeAreaPadding.y > FramePadding.y), often used on TVs.
|
||||
int TreeDepth; // Current tree depth.
|
||||
ImU32 TreeJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary.
|
||||
ImVector<ImGuiWindow*> ChildWindows;
|
||||
ImGuiStorage* StateStorage; // Current persistent per-window storage (store e.g. tree node open/close state)
|
||||
ImGuiColumns* CurrentColumns; // Current columns set
|
||||
ImGuiLayoutType LayoutType;
|
||||
ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin()
|
||||
int FocusCounterAll; // Counter for focus/tabbing system. Start at -1 and increase as assigned via FocusableItemRegister() (FIXME-NAV: Needs redesign)
|
||||
int FocusCounterTab; // (same, but only count widgets which you can Tab through)
|
||||
|
||||
// Local parameters stacks
|
||||
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
||||
ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
|
||||
float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
|
||||
@ -1349,29 +1361,31 @@ struct IMGUI_API ImGuiWindowTempData
|
||||
ImVector<ImGuiGroupData>GroupStack;
|
||||
short StackSizesBackup[6]; // Store size of various stacks for asserting
|
||||
|
||||
ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
|
||||
ImVec1 GroupOffset;
|
||||
ImVec1 ColumnsOffset; // 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.
|
||||
ImGuiColumns* CurrentColumns; // Current columns set
|
||||
|
||||
ImGuiWindowTempData()
|
||||
{
|
||||
CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
|
||||
CurrLineSize = PrevLineSize = ImVec2(0.0f, 0.0f);
|
||||
CurrLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
|
||||
TreeDepth = 0;
|
||||
TreeMayJumpToParentOnPopMask = 0x00;
|
||||
Indent = ImVec1(0.0f);
|
||||
ColumnsOffset = ImVec1(0.0f);
|
||||
GroupOffset = ImVec1(0.0f);
|
||||
|
||||
LastItemId = 0;
|
||||
LastItemStatusFlags = 0;
|
||||
LastItemRect = LastItemDisplayRect = ImRect();
|
||||
|
||||
NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
|
||||
NavLayerCurrent = ImGuiNavLayer_Main;
|
||||
NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
|
||||
NavHideHighlightOneFrame = false;
|
||||
NavHasScroll = false;
|
||||
|
||||
MenuBarAppending = false;
|
||||
MenuBarOffset = ImVec2(0.0f, 0.0f);
|
||||
TreeDepth = 0;
|
||||
TreeJumpToParentOnPopMask = 0x00;
|
||||
StateStorage = NULL;
|
||||
CurrentColumns = NULL;
|
||||
LayoutType = ParentLayoutType = ImGuiLayoutType_Vertical;
|
||||
FocusCounterAll = FocusCounterTab = -1;
|
||||
|
||||
@ -1379,11 +1393,6 @@ struct IMGUI_API ImGuiWindowTempData
|
||||
ItemWidth = 0.0f;
|
||||
TextWrapPos = -1.0f;
|
||||
memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
|
||||
|
||||
Indent = ImVec1(0.0f);
|
||||
GroupOffset = ImVec1(0.0f);
|
||||
ColumnsOffset = ImVec1(0.0f);
|
||||
CurrentColumns = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -5269,7 +5269,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
const bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0;
|
||||
bool is_open = TreeNodeBehaviorIsOpen(id, flags);
|
||||
if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
|
||||
window->DC.TreeMayJumpToParentOnPopMask |= (1 << window->DC.TreeDepth);
|
||||
window->DC.TreeJumpToParentOnPopMask |= (1 << window->DC.TreeDepth);
|
||||
|
||||
bool item_add = ItemAdd(interact_bb, id);
|
||||
window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDisplayRect;
|
||||
@ -5442,12 +5442,12 @@ void ImGui::TreePop()
|
||||
|
||||
// Handle Left arrow to move to parent tree node (when ImGuiTreeNodeFlags_NavLeftJumpsBackHere is enabled)
|
||||
if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet())
|
||||
if (g.NavIdIsAlive && (window->DC.TreeMayJumpToParentOnPopMask & tree_depth_mask))
|
||||
if (g.NavIdIsAlive && (window->DC.TreeJumpToParentOnPopMask & tree_depth_mask))
|
||||
{
|
||||
SetNavID(window->IDStack.back(), g.NavLayer);
|
||||
NavMoveRequestCancel();
|
||||
}
|
||||
window->DC.TreeMayJumpToParentOnPopMask &= tree_depth_mask - 1;
|
||||
window->DC.TreeJumpToParentOnPopMask &= tree_depth_mask - 1;
|
||||
|
||||
IM_ASSERT(window->IDStack.Size > 1); // There should always be 1 element in the IDStack (pushed during window creation). If this triggers you called TreePop/PopID too much.
|
||||
PopID();
|
||||
|
Loading…
Reference in New Issue
Block a user