#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
#endif
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
// Tab stop handling (previously was using internal ItemFocusable() api)
// FIXME-NAV: We would now want to move this above the clipping test, but this would require being able to scroll and currently this would mean an extra frame. (#4079, #343)
if(flags&ImGuiItemAddFlags_Focusable)
ItemFocusable(window,id);
// We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them)
//if (!g.IO.NavActive) // [2017/10/06] Removed this possibly redundant test but I am not sure of all the side-effects yet. Some of the feature here will need to work regardless of using a _NoNavInputs flag.
// FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRectScreen + scoring from a rect wrapped according to current wrapping policy)
// *Fallback* manual-scroll with Nav directional keys when window has no navigable item
ImGuiWindow*window=g.NavWindow;
constfloatscroll_speed=IM_ROUND(window->CalcFontSize()*100*io.DeltaTime);// We need round the scrolling speed because sub-pixel scroll isn't reliably supported.
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
IMGUI_APIvoidPushStyleVar(ImGuiStyleVaridx,floatval);// modify a style float variable. always use this if you modify the style after NewFrame().
IMGUI_APIvoidPushStyleVar(ImGuiStyleVaridx,constImVec2&val);// modify a style ImVec2 variable. always use this if you modify the style after NewFrame().
IMGUI_APIvoidPopStyleVar(intcount=1);
IMGUI_APIvoidPushAllowKeyboardFocus(boolallow_keyboard_focus);// allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
IMGUI_APIvoidPushAllowKeyboardFocus(boolallow_keyboard_focus);// == tab stop enable. Allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
IMGUI_APIvoidPopAllowKeyboardFocus();
IMGUI_APIvoidPushButtonRepeat(boolrepeat);// in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame.
IMGUI_APIvoidPopButtonRepeat();
@ -998,10 +1002,7 @@ enum ImGuiInputTextFlags_
ImGuiInputTextFlags_NoUndoRedo=1<<16,// Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID().
ImGuiInputTextFlags_CallbackResize=1<<18,// Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this)
ImGuiInputTextFlags_CallbackEdit=1<<19,// Callback on any edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
// [Internal]
ImGuiInputTextFlags_Multiline=1<<20,// For internal use by InputTextMultiline()
ImGuiInputTextFlags_NoMarkEdited=1<<21// For internal use by functions using InputText() before reformatting data
ImGuiInputTextFlags_CallbackEdit=1<<19// Callback on any edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
// Obsolete names (will be removed soon)
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
@ -3074,6 +3075,10 @@ enum ImDrawCornerFlags_
#pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
#pragma warning (pop)
#endif
// Include imgui_user.h at the end of imgui.h (convenient for user to only explicitly include vanilla imgui.h)
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
#pragma warning (disable: 4127) // condition expression is constant
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
#pragma warning (disable: 6255) // [Static Analyzer] _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead.
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer)
#endif
// Clang/GCC warnings with -Weverything
@ -105,6 +108,9 @@ namespace IMGUI_STB_NAMESPACE
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable: 4456) // declaration of 'xx' hides previous local declaration
#pragma warning (disable: 6385) // (stb_truetype) Reading invalid data from 'buffer': the readable size is '_Old_3`kernel_width' bytes, but '3' bytes may be read.
#pragma warning (disable: 28182) // (stb_rectpack) Dereferencing NULL pointer. 'cur' contains the same NULL value as 'cur->next' did.
#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
#pragma warning (disable: 26812) // The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer)
#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
#endif
// Clang/GCC warnings with -Weverything
@ -111,7 +114,7 @@ struct ImGuiGroupData; // Stacked storage data for BeginGroup()/End
structImGuiInputTextState;// Internal state of the currently focused/edited text input box
structImGuiLastItemDataBackup;// Backup and restore IsItemHovered() internal data
structImGuiMenuColumns;// Simple column measurement, currently used for MenuItem() only
structImGuiNavMoveResult;// Result of a gamepad/keyboard directional navigation move query result
structImGuiNavItemData;// Result of a gamepad/keyboard directional navigation move query result
structImGuiMetricsConfig;// Storage for ShowMetricsWindow() and DebugNodeXXX() functions
structImGuiNextWindowData;// Storage for SetNextWindow** functions
structImGuiNextItemData;// Storage for SetNextItem** functions
@ -135,6 +138,7 @@ struct ImGuiWindowSettings; // Storage for a window .ini settings (we ke
typedefintImGuiDataAuthority;// -> enum ImGuiDataAuthority_ // Enum: for storing the source authority (dock node vs window) of a field
typedefintImGuiLayoutType;// -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
typedefintImGuiItemFlags;// -> enum ImGuiItemFlags_ // Flags: for PushItemFlag()
typedefintImGuiItemAddFlags;// -> enum ImGuiItemAddFlags_ // Flags: for ItemAdd()
typedefintImGuiItemStatusFlags;// -> enum ImGuiItemStatusFlags_ // Flags: for DC.LastItemStatusFlags
typedefintImGuiOldColumnFlags;// -> enum ImGuiOldColumnFlags_ // Flags: for BeginColumns()
typedefintImGuiNavHighlightFlags;// -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
ImGuiItemFlags_SelectableDontClosePopup=1<<5,// false // MenuItem/Selectable() automatically closes current Popup window
ImGuiItemFlags_MixedValue=1<<6,// false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
ImGuiItemFlags_ReadOnly=1<<7,// false // [ALPHA] Allow hovering interactions but underlying value is not changed.
ImGuiItemFlags_Default_=0
ImGuiItemFlags_ReadOnly=1<<7// false // [ALPHA] Allow hovering interactions but underlying value is not changed.
};
// Flags for ItemAdd()
// FIXME-NAV: _Focusable is _ALMOST_ what you would expect to be called '_TabStop' but because SetKeyboardFocusHere() works on items with no TabStop we distinguish Focusable from TabStop.
enumImGuiItemAddFlags_
{
ImGuiItemAddFlags_None=0,
ImGuiItemAddFlags_Focusable=1<<0// FIXME-NAV: In current/legacy scheme, Focusable+TabStop support are opt-in by widgets. We will transition it toward being opt-out, so this flag is expected to eventually disappear.
};
// Storage for LastItem data
enumImGuiItemStatusFlags_
{
ImGuiItemStatusFlags_None=0,
ImGuiItemStatusFlags_HoveredRect=1<<0,
ImGuiItemStatusFlags_HasDisplayRect=1<<1,// LastItemDisplayRect is valid
ImGuiItemStatusFlags_HoveredRect=1<<0,// Mouse position is within item rectangle (does NOT mean that the window is in correct z-order and can be hovered!, this is only one part of the most-common IsItemHovered test)
ImGuiItemStatusFlags_HasDisplayRect=1<<1,// window->DC.LastItemDisplayRect is valid
ImGuiItemStatusFlags_Edited=1<<2,// Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
ImGuiItemStatusFlags_ToggledSelection=1<<3,// Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected" because reporting the change allows us to handle clipping with less issues.
ImGuiItemStatusFlags_ToggledSelection=1<<3,// Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected", only state changes, in order to easily handle clipping with less issues.
ImGuiItemStatusFlags_ToggledOpen=1<<4,// Set when TreeNode() reports toggling their open state.
ImGuiItemStatusFlags_HasDeactivated=1<<5,// Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag.
ImGuiItemStatusFlags_Deactivated=1<<6,// Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
ImGuiItemStatusFlags_HoveredWindow=1<<7// Override the HoveredWindow test to allow cross-window hover testing.
ImGuiItemStatusFlags_HoveredWindow=1<<7,// Override the HoveredWindow test to allow cross-window hover testing.
ImGuiItemStatusFlags_FocusedByCode=1<<8,// Set when the Focusable item just got focused from code.
ImGuiItemStatusFlags_FocusedByTabbing=1<<9,// Set when the Focusable item just got focused by Tabbing.
ImGuiIDHoveredId;// Hovered widget, filled during the frame
ImGuiIDHoveredIdPreviousFrame;
boolHoveredIdAllowOverlap;
@ -1596,9 +1627,9 @@ struct ImGuiContext
ImGuiKeyModFlagsNavMoveRequestKeyMods;
ImGuiDirNavMoveDir,NavMoveDirLast;// Direction of the move request (left/right/up/down), direction of the previous move request
ImGuiDirNavMoveClipDir;// FIXME-NAV: Describe the purpose of this better. Might want to rename?
ImGuiNavMoveResultNavMoveResultLocal;// Best move request candidate within NavWindow
ImGuiNavMoveResultNavMoveResultLocalVisibleSet;// Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag)
ImGuiNavMoveResultNavMoveResultOther;// Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
ImGuiNavItemData NavMoveResultLocal;// Best move request candidate within NavWindow
ImGuiNavItemData NavMoveResultLocalVisibleSet;// Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag)
ImGuiNavItemData NavMoveResultOther;// Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
ImGuiWindow*NavWrapRequestWindow;// Window which requested trying nav wrap-around.
// 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.
// If you have old/custom copy-and-pasted widgets that used FocusableItemRegister():
// (Old) IMGUI_VERSION_NUM < 18209: using 'ItemAdd(....)' and 'bool focused = FocusableItemRegister(...)'
// (New) IMGUI_VERSION_NUM >= 18209: using 'ItemAdd(..., ImGuiItemAddFlags_Focusable)' and 'bool focused = (GetItemStatusFlags() & ImGuiItemStatusFlags_Focused) != 0'
// Widget code are simplified as there's no need to call FocusableItemUnregister() while managing the transition from regular widget to TempInputText()
inlineboolFocusableItemRegister(ImGuiWindow*window,ImGuiIDid){IM_ASSERT(0);IM_UNUSED(window);IM_UNUSED(id);returnfalse;}// -> pass ImGuiItemAddFlags_Focusable flag to ItemAdd()
IMGUI_APIvoidLogBegin(ImGuiLogTypetype,intauto_open_depth);// -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name.
IMGUI_APIvoidLogToBuffer(intauto_open_depth=-1);// Start logging/capturing to internal buffer
IMGUI_APIvoidActivateItem(ImGuiIDid);// Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again.
#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
#endif
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
#endif
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
// We don't bother handling support for legacy operators since they are a little too crappy. Instead we will later implement a proper expression evaluator in the future.
sscanf(buf,format,p_data);
if(sscanf(buf,format,p_data)<1)
returnfalse;
}
else
{
// Small types need a 32-bit buffer to receive the result from scanf()
// Experimental: simple click (without moving) turns Drag into an InputText
// FIXME: Currently polling ImGuiConfigFlags_IsTouchScreen, may either poll an hypothetical ImGuiBackendFlags_HasKeyboard and/or an explicit drag settings.
IM_ASSERT((flags==1||(flags&ImGuiSliderFlags_InvalidMask_)==0)&&"Invalid ImGuiSliderFlags flag! Has the 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead.");
draw_window->DC.NavLayerActiveMaskNext |=(1<<draw_window->DC.NavLayerCurrent);// This is to ensure that EndChild() will display a navigation highlight so we can "enter" into it.
draw_window->DC.NavLayersActiveMaskNext |=(1<<draw_window->DC.NavLayerCurrent);// This is to ensure that EndChild() will display a navigation highlight so we can "enter" into it.
draw_window->DC.CursorPos+=style.FramePadding;
inner_size.x-=draw_window->ScrollbarSizes.x;
}
else
{
// Support for internal ImGuiInputTextFlags_MergedItem flag, which could be redesigned as an ItemFlags if needed (with test performed in ItemAdd)
// To do so we claim focus back, restore NavId and then process the movement request for yet another frame.
// This involve a one-frame delay which isn't very problematic in this situation. We could remove it by scoring in advance for multiple window (probably not worth the hassle/cost)