mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 05:27:01 +00:00
Internal: Minor tidying/reordering of sections within ImGuiContext / window DC.
This commit is contained in:
parent
7355c84701
commit
0b485f12d7
12
imgui.cpp
12
imgui.cpp
@ -6786,7 +6786,7 @@ void ImGui::BeginGroup()
|
|||||||
group_data.BackupCurrentLineTextBaseOffset = window->DC.CurrentLineTextBaseOffset;
|
group_data.BackupCurrentLineTextBaseOffset = window->DC.CurrentLineTextBaseOffset;
|
||||||
group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive;
|
group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive;
|
||||||
group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive;
|
group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive;
|
||||||
group_data.AdvanceCursor = true;
|
group_data.EmitItem = true;
|
||||||
|
|
||||||
window->DC.GroupOffset.x = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffset.x;
|
window->DC.GroupOffset.x = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffset.x;
|
||||||
window->DC.Indent = window->DC.GroupOffset;
|
window->DC.Indent = window->DC.GroupOffset;
|
||||||
@ -6804,8 +6804,7 @@ void ImGui::EndGroup()
|
|||||||
|
|
||||||
ImGuiGroupData& group_data = window->DC.GroupStack.back();
|
ImGuiGroupData& group_data = window->DC.GroupStack.back();
|
||||||
|
|
||||||
ImRect group_bb(group_data.BackupCursorPos, window->DC.CursorMaxPos);
|
ImRect group_bb(group_data.BackupCursorPos, ImMax(window->DC.CursorMaxPos, group_data.BackupCursorPos));
|
||||||
group_bb.Max = ImMax(group_bb.Min, group_bb.Max);
|
|
||||||
|
|
||||||
window->DC.CursorPos = group_data.BackupCursorPos;
|
window->DC.CursorPos = group_data.BackupCursorPos;
|
||||||
window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos);
|
window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos);
|
||||||
@ -6816,12 +6815,15 @@ void ImGui::EndGroup()
|
|||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return
|
g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return
|
||||||
|
|
||||||
if (group_data.AdvanceCursor)
|
if (!group_data.EmitItem)
|
||||||
{
|
{
|
||||||
|
window->DC.GroupStack.pop_back();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrentLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
|
window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrentLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
|
||||||
ItemSize(group_bb.GetSize(), 0.0f);
|
ItemSize(group_bb.GetSize(), 0.0f);
|
||||||
ItemAdd(group_bb, 0);
|
ItemAdd(group_bb, 0);
|
||||||
}
|
|
||||||
|
|
||||||
// If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group.
|
// If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group.
|
||||||
// It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets.
|
// It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets.
|
||||||
|
@ -575,7 +575,7 @@ struct ImGuiGroupData
|
|||||||
float BackupCurrentLineTextBaseOffset;
|
float BackupCurrentLineTextBaseOffset;
|
||||||
ImGuiID BackupActiveIdIsAlive;
|
ImGuiID BackupActiveIdIsAlive;
|
||||||
bool BackupActiveIdPreviousFrameIsAlive;
|
bool BackupActiveIdPreviousFrameIsAlive;
|
||||||
bool AdvanceCursor;
|
bool EmitItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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.
|
||||||
@ -818,11 +818,12 @@ struct ImGuiContext
|
|||||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
||||||
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
||||||
ImDrawListSharedData DrawListSharedData;
|
ImDrawListSharedData DrawListSharedData;
|
||||||
|
|
||||||
double Time;
|
double Time;
|
||||||
int FrameCount;
|
int FrameCount;
|
||||||
int FrameCountEnded;
|
int FrameCountEnded;
|
||||||
int FrameCountRendered;
|
int FrameCountRendered;
|
||||||
|
|
||||||
|
// Windows state
|
||||||
ImVector<ImGuiWindow*> Windows; // Windows, sorted in display order, back to front
|
ImVector<ImGuiWindow*> Windows; // Windows, sorted in display order, back to front
|
||||||
ImVector<ImGuiWindow*> WindowsFocusOrder; // Windows, sorted in focus order, back to front
|
ImVector<ImGuiWindow*> WindowsFocusOrder; // Windows, sorted in focus order, back to front
|
||||||
ImVector<ImGuiWindow*> WindowsSortBuffer;
|
ImVector<ImGuiWindow*> WindowsSortBuffer;
|
||||||
@ -832,39 +833,45 @@ struct ImGuiContext
|
|||||||
ImGuiWindow* CurrentWindow; // Being drawn into
|
ImGuiWindow* CurrentWindow; // Being drawn into
|
||||||
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
|
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
|
||||||
ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
|
ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
|
||||||
|
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
|
||||||
|
|
||||||
|
// Item/widgets state and tracking information
|
||||||
ImGuiID HoveredId; // Hovered widget
|
ImGuiID HoveredId; // Hovered widget
|
||||||
bool HoveredIdAllowOverlap;
|
bool HoveredIdAllowOverlap;
|
||||||
ImGuiID HoveredIdPreviousFrame;
|
ImGuiID HoveredIdPreviousFrame;
|
||||||
float HoveredIdTimer; // Measure contiguous hovering time
|
float HoveredIdTimer; // Measure contiguous hovering time
|
||||||
float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active
|
float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active
|
||||||
ImGuiID ActiveId; // Active widget
|
ImGuiID ActiveId; // Active widget
|
||||||
ImGuiID ActiveIdPreviousFrame;
|
|
||||||
ImGuiID ActiveIdIsAlive; // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame)
|
ImGuiID ActiveIdIsAlive; // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame)
|
||||||
float ActiveIdTimer;
|
float ActiveIdTimer;
|
||||||
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
||||||
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
||||||
bool ActiveIdHasBeenPressed; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
|
bool ActiveIdHasBeenPressed; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
|
||||||
bool ActiveIdHasBeenEdited; // Was the value associated to the widget Edited over the course of the Active state.
|
bool ActiveIdHasBeenEdited; // Was the value associated to the widget Edited over the course of the Active state.
|
||||||
bool ActiveIdPreviousFrameIsAlive;
|
|
||||||
bool ActiveIdPreviousFrameHasBeenEdited;
|
|
||||||
int ActiveIdAllowNavDirFlags; // Active widget allows using directional navigation (e.g. can activate a button and move away from it)
|
int ActiveIdAllowNavDirFlags; // Active widget allows using directional navigation (e.g. can activate a button and move away from it)
|
||||||
int ActiveIdBlockNavInputFlags;
|
int ActiveIdBlockNavInputFlags;
|
||||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||||
ImGuiWindow* ActiveIdWindow;
|
ImGuiWindow* ActiveIdWindow;
|
||||||
ImGuiWindow* ActiveIdPreviousFrameWindow;
|
|
||||||
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
||||||
|
ImGuiID ActiveIdPreviousFrame;
|
||||||
|
bool ActiveIdPreviousFrameIsAlive;
|
||||||
|
bool ActiveIdPreviousFrameHasBeenEdited;
|
||||||
|
ImGuiWindow* ActiveIdPreviousFrameWindow;
|
||||||
|
|
||||||
ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
|
ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
|
||||||
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
|
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
|
||||||
ImVec2 LastValidMousePos;
|
|
||||||
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
|
// Next window/item data
|
||||||
|
ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions
|
||||||
|
bool NextTreeNodeOpenVal; // Storage for SetNextTreeNode** functions
|
||||||
|
ImGuiCond NextTreeNodeOpenCond;
|
||||||
|
|
||||||
|
// Shared stacks
|
||||||
ImVector<ImGuiColorMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
|
ImVector<ImGuiColorMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
|
||||||
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
|
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
|
||||||
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
|
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
|
||||||
ImVector<ImGuiPopupData>OpenPopupStack; // Which popups are open (persistent)
|
ImVector<ImGuiPopupData>OpenPopupStack; // Which popups are open (persistent)
|
||||||
ImVector<ImGuiPopupData>BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
|
ImVector<ImGuiPopupData>BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
|
||||||
ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions
|
|
||||||
bool NextTreeNodeOpenVal; // Storage for SetNextTreeNode** functions
|
|
||||||
ImGuiCond NextTreeNodeOpenCond;
|
|
||||||
|
|
||||||
// Navigation data (for gamepad/keyboard)
|
// Navigation data (for gamepad/keyboard)
|
||||||
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusWindow'
|
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusWindow'
|
||||||
@ -948,6 +955,7 @@ struct ImGuiContext
|
|||||||
ImVector<ImGuiTabBarSortItem> TabSortByWidthBuffer;
|
ImVector<ImGuiTabBarSortItem> TabSortByWidthBuffer;
|
||||||
|
|
||||||
// Widget state
|
// Widget state
|
||||||
|
ImVec2 LastValidMousePos;
|
||||||
ImGuiInputTextState InputTextState;
|
ImGuiInputTextState InputTextState;
|
||||||
ImFont InputTextPasswordFont;
|
ImFont InputTextPasswordFont;
|
||||||
ImGuiID TempInputTextId; // Temporary text input when CTRL+clicking on a slider, etc.
|
ImGuiID TempInputTextId; // Temporary text input when CTRL+clicking on a slider, etc.
|
||||||
@ -1003,37 +1011,41 @@ struct ImGuiContext
|
|||||||
FontSize = FontBaseSize = 0.0f;
|
FontSize = FontBaseSize = 0.0f;
|
||||||
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
|
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
|
||||||
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
|
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
|
||||||
|
|
||||||
Time = 0.0f;
|
Time = 0.0f;
|
||||||
FrameCount = 0;
|
FrameCount = 0;
|
||||||
FrameCountEnded = FrameCountRendered = -1;
|
FrameCountEnded = FrameCountRendered = -1;
|
||||||
|
|
||||||
WindowsActiveCount = 0;
|
WindowsActiveCount = 0;
|
||||||
CurrentWindow = NULL;
|
CurrentWindow = NULL;
|
||||||
HoveredWindow = NULL;
|
HoveredWindow = NULL;
|
||||||
HoveredRootWindow = NULL;
|
HoveredRootWindow = NULL;
|
||||||
|
MovingWindow = NULL;
|
||||||
|
|
||||||
HoveredId = 0;
|
HoveredId = 0;
|
||||||
HoveredIdAllowOverlap = false;
|
HoveredIdAllowOverlap = false;
|
||||||
HoveredIdPreviousFrame = 0;
|
HoveredIdPreviousFrame = 0;
|
||||||
HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
|
HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
|
||||||
ActiveId = 0;
|
ActiveId = 0;
|
||||||
ActiveIdPreviousFrame = 0;
|
|
||||||
ActiveIdIsAlive = 0;
|
ActiveIdIsAlive = 0;
|
||||||
ActiveIdTimer = 0.0f;
|
ActiveIdTimer = 0.0f;
|
||||||
ActiveIdIsJustActivated = false;
|
ActiveIdIsJustActivated = false;
|
||||||
ActiveIdAllowOverlap = false;
|
ActiveIdAllowOverlap = false;
|
||||||
ActiveIdHasBeenPressed = false;
|
ActiveIdHasBeenPressed = false;
|
||||||
ActiveIdHasBeenEdited = false;
|
ActiveIdHasBeenEdited = false;
|
||||||
ActiveIdPreviousFrameIsAlive = false;
|
|
||||||
ActiveIdPreviousFrameHasBeenEdited = false;
|
|
||||||
ActiveIdAllowNavDirFlags = 0x00;
|
ActiveIdAllowNavDirFlags = 0x00;
|
||||||
ActiveIdBlockNavInputFlags = 0x00;
|
ActiveIdBlockNavInputFlags = 0x00;
|
||||||
ActiveIdClickOffset = ImVec2(-1,-1);
|
ActiveIdClickOffset = ImVec2(-1,-1);
|
||||||
ActiveIdWindow = ActiveIdPreviousFrameWindow = NULL;
|
ActiveIdWindow = NULL;
|
||||||
ActiveIdSource = ImGuiInputSource_None;
|
ActiveIdSource = ImGuiInputSource_None;
|
||||||
|
|
||||||
|
ActiveIdPreviousFrame = 0;
|
||||||
|
ActiveIdPreviousFrameIsAlive = false;
|
||||||
|
ActiveIdPreviousFrameHasBeenEdited = false;
|
||||||
|
ActiveIdPreviousFrameWindow = NULL;
|
||||||
|
|
||||||
LastActiveId = 0;
|
LastActiveId = 0;
|
||||||
LastActiveIdTimer = 0.0f;
|
LastActiveIdTimer = 0.0f;
|
||||||
LastValidMousePos = ImVec2(0.0f, 0.0f);
|
|
||||||
MovingWindow = NULL;
|
|
||||||
NextTreeNodeOpenVal = false;
|
NextTreeNodeOpenVal = false;
|
||||||
NextTreeNodeOpenCond = 0;
|
NextTreeNodeOpenCond = 0;
|
||||||
|
|
||||||
@ -1087,6 +1099,7 @@ struct ImGuiContext
|
|||||||
|
|
||||||
CurrentTabBar = NULL;
|
CurrentTabBar = NULL;
|
||||||
|
|
||||||
|
LastValidMousePos = ImVec2(0.0f, 0.0f);
|
||||||
TempInputTextId = 0;
|
TempInputTextId = 0;
|
||||||
ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
|
ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
|
||||||
DragCurrentAccumDirty = false;
|
DragCurrentAccumDirty = false;
|
||||||
|
@ -5903,7 +5903,7 @@ void ImGui::EndMenuBar()
|
|||||||
PopClipRect();
|
PopClipRect();
|
||||||
PopID();
|
PopID();
|
||||||
window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->MenuBarRect().Min.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos.
|
window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->MenuBarRect().Min.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos.
|
||||||
window->DC.GroupStack.back().AdvanceCursor = false;
|
window->DC.GroupStack.back().EmitItem = false;
|
||||||
EndGroup(); // Restore position on layer 0
|
EndGroup(); // Restore position on layer 0
|
||||||
window->DC.LayoutType = ImGuiLayoutType_Vertical;
|
window->DC.LayoutType = ImGuiLayoutType_Vertical;
|
||||||
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
|
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
|
||||||
|
Loading…
Reference in New Issue
Block a user