mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-09 23:54:20 +00:00
Shuffle a few internal context fields to reduce padding.
This commit is contained in:
parent
a1632c6116
commit
8019d39545
3 changed files with 27 additions and 26 deletions
23
imgui.cpp
23
imgui.cpp
|
|
@ -4043,6 +4043,13 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
||||||
InputTextState.Ctx = this;
|
InputTextState.Ctx = this;
|
||||||
|
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
WithinFrameScope = WithinFrameScopeWithImplicitWindow = false;
|
||||||
|
TestEngineHookItems = false;
|
||||||
|
FrameCount = 0;
|
||||||
|
FrameCountEnded = FrameCountRendered = -1;
|
||||||
|
Time = 0.0f;
|
||||||
|
memset(ContextName, 0, sizeof(ContextName));
|
||||||
|
|
||||||
Font = NULL;
|
Font = NULL;
|
||||||
FontBaked = NULL;
|
FontBaked = NULL;
|
||||||
FontSize = FontSizeBase = FontBakedScale = CurrentDpiScale = 0.0f;
|
FontSize = FontSizeBase = FontBakedScale = CurrentDpiScale = 0.0f;
|
||||||
|
|
@ -4050,15 +4057,8 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
||||||
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
|
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
|
||||||
if (shared_font_atlas == NULL)
|
if (shared_font_atlas == NULL)
|
||||||
IO.Fonts->OwnerContext = this;
|
IO.Fonts->OwnerContext = this;
|
||||||
Time = 0.0f;
|
|
||||||
FrameCount = 0;
|
|
||||||
FrameCountEnded = FrameCountRendered = -1;
|
|
||||||
WithinEndChildID = 0;
|
WithinEndChildID = 0;
|
||||||
WithinFrameScope = WithinFrameScopeWithImplicitWindow = false;
|
|
||||||
GcCompactAll = false;
|
|
||||||
TestEngineHookItems = false;
|
|
||||||
TestEngine = NULL;
|
TestEngine = NULL;
|
||||||
memset(ContextName, 0, sizeof(ContextName));
|
|
||||||
|
|
||||||
InputEventsNextMouseSource = ImGuiMouseSource_Mouse;
|
InputEventsNextMouseSource = ImGuiMouseSource_Mouse;
|
||||||
InputEventsNextEventId = 1;
|
InputEventsNextEventId = 1;
|
||||||
|
|
@ -4093,10 +4093,10 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
||||||
ActiveIdHasBeenEditedThisFrame = false;
|
ActiveIdHasBeenEditedThisFrame = false;
|
||||||
ActiveIdFromShortcut = false;
|
ActiveIdFromShortcut = false;
|
||||||
ActiveIdClickOffset = ImVec2(-1, -1);
|
ActiveIdClickOffset = ImVec2(-1, -1);
|
||||||
ActiveIdWindow = NULL;
|
|
||||||
ActiveIdSource = ImGuiInputSource_None;
|
ActiveIdSource = ImGuiInputSource_None;
|
||||||
ActiveIdDisabledId = 0;
|
ActiveIdWindow = NULL;
|
||||||
ActiveIdMouseButton = -1;
|
ActiveIdMouseButton = -1;
|
||||||
|
ActiveIdDisabledId = 0;
|
||||||
ActiveIdPreviousFrame = 0;
|
ActiveIdPreviousFrame = 0;
|
||||||
memset(&DeactivatedItemData, 0, sizeof(DeactivatedItemData));
|
memset(&DeactivatedItemData, 0, sizeof(DeactivatedItemData));
|
||||||
memset(&ActiveIdValueOnActivation, 0, sizeof(ActiveIdValueOnActivation));
|
memset(&ActiveIdValueOnActivation, 0, sizeof(ActiveIdValueOnActivation));
|
||||||
|
|
@ -4111,6 +4111,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
||||||
CurrentFocusScopeId = 0;
|
CurrentFocusScopeId = 0;
|
||||||
CurrentItemFlags = ImGuiItemFlags_None;
|
CurrentItemFlags = ImGuiItemFlags_None;
|
||||||
DebugShowGroupRects = false;
|
DebugShowGroupRects = false;
|
||||||
|
GcCompactAll = false;
|
||||||
|
|
||||||
NavCursorVisible = false;
|
NavCursorVisible = false;
|
||||||
NavHighlightItemUnderNav = false;
|
NavHighlightItemUnderNav = false;
|
||||||
|
|
@ -4219,12 +4220,12 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
||||||
memset(LocalizationTable, 0, sizeof(LocalizationTable));
|
memset(LocalizationTable, 0, sizeof(LocalizationTable));
|
||||||
|
|
||||||
LogEnabled = false;
|
LogEnabled = false;
|
||||||
|
LogLineFirstItem = false;
|
||||||
LogFlags = ImGuiLogFlags_None;
|
LogFlags = ImGuiLogFlags_None;
|
||||||
LogWindow = NULL;
|
LogWindow = NULL;
|
||||||
LogNextPrefix = LogNextSuffix = NULL;
|
LogNextPrefix = LogNextSuffix = NULL;
|
||||||
LogFile = NULL;
|
LogFile = NULL;
|
||||||
LogLinePosY = FLT_MAX;
|
LogLinePosY = FLT_MAX;
|
||||||
LogLineFirstItem = false;
|
|
||||||
LogDepthRef = 0;
|
LogDepthRef = 0;
|
||||||
LogDepthToExpand = LogDepthToExpandDefault = 2;
|
LogDepthToExpand = LogDepthToExpandDefault = 2;
|
||||||
|
|
||||||
|
|
@ -4457,8 +4458,8 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* ctx, const char* name) : DrawListInst(NUL
|
||||||
MoveId = GetID("#MOVE");
|
MoveId = GetID("#MOVE");
|
||||||
ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
|
ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
|
||||||
ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f);
|
ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f);
|
||||||
AutoFitFramesX = AutoFitFramesY = -1;
|
|
||||||
AutoPosLastDirection = ImGuiDir_None;
|
AutoPosLastDirection = ImGuiDir_None;
|
||||||
|
AutoFitFramesX = AutoFitFramesY = -1;
|
||||||
SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = 0;
|
SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = 0;
|
||||||
SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX);
|
SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX);
|
||||||
LastFrameActive = -1;
|
LastFrameActive = -1;
|
||||||
|
|
|
||||||
|
|
@ -2164,6 +2164,14 @@ struct ImGuiContextHook
|
||||||
struct ImGuiContext
|
struct ImGuiContext
|
||||||
{
|
{
|
||||||
bool Initialized;
|
bool Initialized;
|
||||||
|
bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame()
|
||||||
|
bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed
|
||||||
|
bool TestEngineHookItems; // Will call test engine hooks: ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log()
|
||||||
|
int FrameCount;
|
||||||
|
int FrameCountEnded;
|
||||||
|
int FrameCountRendered;
|
||||||
|
double Time;
|
||||||
|
char ContextName[16]; // Storage for a context name (to facilitate debugging multi-context setups)
|
||||||
ImGuiIO IO;
|
ImGuiIO IO;
|
||||||
ImGuiPlatformIO PlatformIO;
|
ImGuiPlatformIO PlatformIO;
|
||||||
ImGuiStyle Style;
|
ImGuiStyle Style;
|
||||||
|
|
@ -2176,17 +2184,8 @@ struct ImGuiContext
|
||||||
float FontRasterizerDensity; // Current font density. Used by all calls to GetFontBaked().
|
float FontRasterizerDensity; // Current font density. Used by all calls to GetFontBaked().
|
||||||
float CurrentDpiScale; // Current window/viewport DpiScale == CurrentViewport->DpiScale
|
float CurrentDpiScale; // Current window/viewport DpiScale == CurrentViewport->DpiScale
|
||||||
ImDrawListSharedData DrawListSharedData;
|
ImDrawListSharedData DrawListSharedData;
|
||||||
double Time;
|
|
||||||
int FrameCount;
|
|
||||||
int FrameCountEnded;
|
|
||||||
int FrameCountRendered;
|
|
||||||
ImGuiID WithinEndChildID; // Set within EndChild()
|
ImGuiID WithinEndChildID; // Set within EndChild()
|
||||||
bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame()
|
|
||||||
bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed
|
|
||||||
bool GcCompactAll; // Request full GC
|
|
||||||
bool TestEngineHookItems; // Will call test engine hooks: ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log()
|
|
||||||
void* TestEngine; // Test engine user data
|
void* TestEngine; // Test engine user data
|
||||||
char ContextName[16]; // Storage for a context name (to facilitate debugging multi-context setups)
|
|
||||||
|
|
||||||
// Inputs
|
// Inputs
|
||||||
ImVector<ImGuiInputEvent> InputEventsQueue; // Input events which will be trickled/written into IO structure.
|
ImVector<ImGuiInputEvent> InputEventsQueue; // Input events which will be trickled/written into IO structure.
|
||||||
|
|
@ -2237,11 +2236,11 @@ struct ImGuiContext
|
||||||
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
|
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
|
||||||
bool ActiveIdHasBeenEditedThisFrame;
|
bool ActiveIdHasBeenEditedThisFrame;
|
||||||
bool ActiveIdFromShortcut;
|
bool ActiveIdFromShortcut;
|
||||||
|
ImS8 ActiveIdMouseButton;
|
||||||
ImGuiID ActiveIdDisabledId; // When clicking a disabled item we set ActiveId=window->MoveId to avoid interference with widget code. Actual item ID is stored here.
|
ImGuiID ActiveIdDisabledId; // When clicking a disabled item we set ActiveId=window->MoveId to avoid interference with widget code. Actual item ID is stored here.
|
||||||
int ActiveIdMouseButton : 8;
|
|
||||||
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;
|
|
||||||
ImGuiInputSource ActiveIdSource; // Activating source: ImGuiInputSource_Mouse OR ImGuiInputSource_Keyboard OR ImGuiInputSource_Gamepad
|
ImGuiInputSource ActiveIdSource; // Activating source: ImGuiInputSource_Mouse OR ImGuiInputSource_Keyboard OR ImGuiInputSource_Gamepad
|
||||||
|
ImGuiWindow* ActiveIdWindow;
|
||||||
ImGuiID ActiveIdPreviousFrame;
|
ImGuiID ActiveIdPreviousFrame;
|
||||||
ImGuiDeactivatedItemData DeactivatedItemData;
|
ImGuiDeactivatedItemData DeactivatedItemData;
|
||||||
ImGuiDataTypeStorage ActiveIdValueOnActivation; // Backup of initial value at the time of activation. ONLY SET BY SPECIFIC WIDGETS: DragXXX and SliderXXX.
|
ImGuiDataTypeStorage ActiveIdValueOnActivation; // Backup of initial value at the time of activation. ONLY SET BY SPECIFIC WIDGETS: DragXXX and SliderXXX.
|
||||||
|
|
@ -2271,6 +2270,7 @@ struct ImGuiContext
|
||||||
ImGuiLastItemData LastItemData; // Storage for last submitted item (setup by ItemAdd)
|
ImGuiLastItemData LastItemData; // Storage for last submitted item (setup by ItemAdd)
|
||||||
ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions
|
ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions
|
||||||
bool DebugShowGroupRects;
|
bool DebugShowGroupRects;
|
||||||
|
bool GcCompactAll; // Request full GC
|
||||||
|
|
||||||
// Shared stacks
|
// Shared stacks
|
||||||
ImGuiCol DebugFlashStyleColorIdx; // (Keep close to ColorStack to share cache line)
|
ImGuiCol DebugFlashStyleColorIdx; // (Keep close to ColorStack to share cache line)
|
||||||
|
|
@ -2481,6 +2481,7 @@ struct ImGuiContext
|
||||||
|
|
||||||
// Capture/Logging
|
// Capture/Logging
|
||||||
bool LogEnabled; // Currently capturing
|
bool LogEnabled; // Currently capturing
|
||||||
|
bool LogLineFirstItem;
|
||||||
ImGuiLogFlags LogFlags; // Capture flags/type
|
ImGuiLogFlags LogFlags; // Capture flags/type
|
||||||
ImGuiWindow* LogWindow;
|
ImGuiWindow* LogWindow;
|
||||||
ImFileHandle LogFile; // If != NULL log to stdout/ file
|
ImFileHandle LogFile; // If != NULL log to stdout/ file
|
||||||
|
|
@ -2488,7 +2489,6 @@ struct ImGuiContext
|
||||||
const char* LogNextPrefix; // See comment in LogSetNextTextDecoration(): doesn't copy underlying data, use carefully!
|
const char* LogNextPrefix; // See comment in LogSetNextTextDecoration(): doesn't copy underlying data, use carefully!
|
||||||
const char* LogNextSuffix;
|
const char* LogNextSuffix;
|
||||||
float LogLinePosY;
|
float LogLinePosY;
|
||||||
bool LogLineFirstItem;
|
|
||||||
int LogDepthRef;
|
int LogDepthRef;
|
||||||
int LogDepthToExpand;
|
int LogDepthToExpand;
|
||||||
int LogDepthToExpandDefault; // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call.
|
int LogDepthToExpandDefault; // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call.
|
||||||
|
|
@ -2655,9 +2655,9 @@ struct IMGUI_API ImGuiWindow
|
||||||
short BeginOrderWithinParent; // Begin() order within immediate parent window, if we are a child window. Otherwise 0.
|
short BeginOrderWithinParent; // Begin() order within immediate parent window, if we are a child window. Otherwise 0.
|
||||||
short BeginOrderWithinContext; // Begin() order within entire imgui context. This is mostly used for debugging submission order related issues.
|
short BeginOrderWithinContext; // Begin() order within entire imgui context. This is mostly used for debugging submission order related issues.
|
||||||
short FocusOrder; // Order within WindowsFocusOrder[], altered when windows are focused.
|
short FocusOrder; // Order within WindowsFocusOrder[], altered when windows are focused.
|
||||||
|
ImGuiDir AutoPosLastDirection;
|
||||||
ImS8 AutoFitFramesX, AutoFitFramesY;
|
ImS8 AutoFitFramesX, AutoFitFramesY;
|
||||||
bool AutoFitOnlyGrows;
|
bool AutoFitOnlyGrows;
|
||||||
ImGuiDir AutoPosLastDirection;
|
|
||||||
ImS8 HiddenFramesCanSkipItems; // Hide the window for N frames
|
ImS8 HiddenFramesCanSkipItems; // Hide the window for N frames
|
||||||
ImS8 HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size
|
ImS8 HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size
|
||||||
ImS8 HiddenFramesForRenderOnly; // Hide the window until frame N at Render() time only
|
ImS8 HiddenFramesForRenderOnly; // Hide the window until frame N at Render() time only
|
||||||
|
|
|
||||||
|
|
@ -619,7 +619,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||||
if (flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere))
|
if (flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere))
|
||||||
{
|
{
|
||||||
SetActiveID(id, window);
|
SetActiveID(id, window);
|
||||||
g.ActiveIdMouseButton = mouse_button_clicked;
|
g.ActiveIdMouseButton = (ImS8)mouse_button_clicked;
|
||||||
if (!(flags & ImGuiButtonFlags_NoNavFocus))
|
if (!(flags & ImGuiButtonFlags_NoNavFocus))
|
||||||
{
|
{
|
||||||
SetFocusID(id, window);
|
SetFocusID(id, window);
|
||||||
|
|
@ -637,7 +637,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||||
ClearActiveID();
|
ClearActiveID();
|
||||||
else
|
else
|
||||||
SetActiveID(id, window); // Hold on ID
|
SetActiveID(id, window); // Hold on ID
|
||||||
g.ActiveIdMouseButton = mouse_button_clicked;
|
g.ActiveIdMouseButton = (ImS8)mouse_button_clicked;
|
||||||
if (!(flags & ImGuiButtonFlags_NoNavFocus))
|
if (!(flags & ImGuiButtonFlags_NoNavFocus))
|
||||||
{
|
{
|
||||||
SetFocusID(id, window);
|
SetFocusID(id, window);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue