Merge branch 'master' into docking

This commit is contained in:
ocornut 2023-03-21 16:51:19 +01:00
commit ad44f5831a
6 changed files with 798 additions and 69 deletions

View File

@ -106,6 +106,15 @@ Breaking Changes:
Other changes:
- InputText: Fixed a tricky edge case, ensuring value is always written back on the
frame where IsItemDeactivated() returns true, in order to allow usage without user
retaining underlying data. While we don't really want to encourage user not retaining
underlying data, in the absence of a "late commit" behavior/flag we understand it may
be desirable to take advantage of this trick. (#4714)
- Drag, Sliders: Fixed parsing of text input when '+' or '#' format flags are used
in the format string. (#6259) [@idbrii]
- IO: Fixed support for calling io.AddXXXX functions fron inactive context (wrongly
advertised as supported in 1.89.4). (#6199, #6256, #5856) [@cfillion]
- Backends: OpenGL3: Fixed GL loader crash when GL_VERSION returns NULL. (#6154, #4445, #3530)
- Examples: Windows: Added 'misc/debuggers/imgui.natstepfilter' file to all Visual Studio projects,
now that VS 2022 17.6 Preview 2 support adding Debug Step Filter spec files into projects.
@ -4496,7 +4505,664 @@ Other Changes:
- Other fixes, comments, tweaks.
-----------------------------------------------------------------------
VERSION 1.38 (2015-04-20)
-----------------------------------------------------------------------
For older version, see https://github.com/ocornut/imgui/releases
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.38
Breaking Changes:
- Renamed IsClipped() to IsRectClipped(). Kept inline redirection function (will obsolete).
- Renamed ImDrawList::AddArc() to ImDrawList::AddArcFast().
Other Changes:
- Added DragFloat(), DragInt() widget, click and drag to adjust value with given step.
Hold SHIFT/ALT to speed-up/slow-down. Double-click or CTRL+click to input text.
Passing min >= max makes the widget unbounded.
- Added DragFloat2(), DragFloat3(), DragFloat4(), DragInt2(), DragInt3(), DragInt4() helper variants.
- Added ShowMetricsWindow() which is mainly useful to debug ImGui internals. Added IO.MetricsRenderVertices counter.
- Added ResetMouseDragDelta() for iterative dragging operations.
- Added ImFontAtlas::AddFontFromCompressedTTF() helper + binary_to_compressed_c.cpp tool to compress a file and create a .c array from it.
- Added PushId() GetId() variants that takes string range to avoid user making unnecessary copies.
- Added IsItemVisible().
- Fixed IsRectClipped() incorrectly returning false when log is enabled.
- Slider: visual fix in the unlikely that style.GrabMinSize is larger than a slider.
- SliderFloat: removed support for unbound slider (using FLT_MAX), caused various inconsistency. Use InputFloat()/DragFloat().
- ColorEdit4: hide components prefix if there's no space for them.
- Combo: adding frame padding inside the combo box.
- Columns: mouse dragging uses absolute mouse coordinates.Fixed dragging left-most column of an auto-resizable window. #125
- Selectable: render highlight into AutoFitPadding region but do not extend it, fixing visual gap.
- Focus: Allow SetWindowFocus(NULL) to remove focus.
- Focus: Clicking on void (outside an ImGui windows) loses keyboard-focus so application can use TAB.
- Popup: Fixed hovering over a popup's child (popups disable hovering on other windows but not their childs) #197
- Fixed active widget not releasing its active state while being clipped.
- Fixed user-facing version of IsItemHovered() ignoring overlapping windows.
- Fixed label vertical alignment for InputInt2(), InputInt3(), InputInt4().
- Fixed new collapsed auto-resizing window with saved .ini settings not calculating their initial width #176
- Fixed Begin() returning true on collapsed windows that had loaded settings #176
- Fixed style.DisplaySafeAreaPadding handling from being applied on window prior to them auto-fitting.
- ShowTestWindow(): added examples for DragFloat, DragInt and only custom label embedded in format strings.
- ShowTestWindow(): fixed "manipulating titles" example not doing the right thing, broken in ff35d24
- Examples: OpenGL/GLFW: Fixed modifier key state setting in GLFW callbacks.
- Examples: OpenGL/GLFW: Added glBindTexture(0) in OpenGL fixed pipeline examples. Save restore current program and texture in the OpenGL3 example.
- Examples: DirectX11: Removed unnecessary vertices conversion and CUSTOMVERTEX types.
- Comments, fixes, tweaks.
-----------------------------------------------------------------------
VERSION 1.37 (2015-03-26)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.37
Other Changes:
- Added a more convenient three parameters version of Begin() which covers the common uses better.
- Added mouse cursor types handling (resize, move, text input cursors, etc.) that user can query with GetMouseCursor(). Added demo and instructions in ShowTestWindow().
- Added embedded mouse cursor data for MouseDrawCursor software cursor rendering, for consoles/tablets/etc. (#155).
- Added first version of BeginPopup/EndPopup() helper API to create popup menus. Popups automatically lock their position to the mouse cursor when first appearing. They close automatically when clicking outside, and inhibit hovering items from other windows when active (to allow for clicking outside). (#126)
- Added thickness parameter to ImDrawList::AddLine().
- Added ImDrawList::PushClipRectFullScreen() helper.
- Added style.DisplaySafeAreaPadding which was previously hard-coded (useful if you can't see the edges of your display, e.g. TV screens).
- Added CalcItemRectClosestPoint() helper.
- Added GetMouseDragDelta(), IsMouseDragging() helpers, given a mouse button and an optional "unlock" threshold. Added io.MouseDragThreshold setting. (#167)
- IsItemHovered() return false if another widget is active, aka we can't use what we are hovering now.
- Added IsItemHoveredRect() if old behavior of IsItemHovered() is needed (e.g. for implementing the drop side of a drag'n drop operation).
- IsItemhovered() include space taken by label and behave consistently for all widgets (#145)
- Auto-filling child window feed their content size to parent (#170)
- InputText() removed the odd ~ characters when clipping.
- InputText() update its width in case of resize initiated programmatically while the widget is active.
- InputText() last active preserve scrolling position. Reset scroll if widget size becomes bigger than contents.
- Selectable(): not specifying a width defaults to using max of label width and remaining width.
- Selectable(const char*, bool) version has bool defaulting to false.
- Selectable(): fixed misusage of GetContentRegionMax().x leaking into auto-fitting.
- Windows starting Collapsed runs initial auto-fit to retrieve a width for their title bar (#175)
- Fixed new window from having an incorrect content size on their first frame, if queried by user. Fixed SetWindowPos/SetNextWindowPos having a side-effect size computation (#175)
- InputFloat(): fixed label alignment if total widget width forcefully bigger than space available.
- Auto contents size aware of enforced vertical scrollbar if window is larger than display size.
- Fixed new windows auto-fitting bigger than their .ini saved size. This was a bug but it may be a desirable effect sometimes, may reconsider it.
- Fixed negative clipping rectangle when collapsing windows that could affect manual submission to ImDrawList and end-user rendering function if unhandled (#177)
- Fixed bounding measurement of empty groups (fix #162)
- Fixed assignment order in Begin() making auto-fit size effectively lag by one frame. Also disabling "clamp into view" while windows are auto-fitting so that auto-fitting window in corners don't get pushed away.
- Fixed MouseClickedPos not updated on double-click update (#167)
- Fixed MouseDrawCursor feature submitting an empty trailing command in the draw list. Fixed unmerged draw calls for software mouse cursor.
- Fixed double-clicking on resize grip keeping the grip active if mouse button is kept held.
- Bounding box tests exclude higher bound, so touching items (zero spacing) don't report double hover when cursor is on edge.
- Setting io.LogFilename to NULL disable default LogToFile() (part of #175)
- Tweak stb_textedit integration to be lenient if another piece of code are leaking their STB_TEXTEDIT definitions/symbols.
- Shutdown() freeing a few extra vectors so they don't have to freed by destruction (#169)
- Examples: OpenGL2/3 examples automatically hide the OS mouse cursor if software cursor rendering is used.
- ShowTestWindow: Added Widgets Alignment demo under Layout section
- ShowTestWindow: Added simple dragging widget example.
- ShowTestWindow: Graph has checkbox under the label, also demo using BeginGroup/EndGroup().
- ShowTestWindow: Using SetNextWindowSize() in examples to encourage its use.
- Fixes, tweaks, comments.
-----------------------------------------------------------------------
VERSION 1.36 (2015-03-18)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.36
Other Changes:
- Added ImGui::GetVersion(), IMGUI_VERSION (#127)
- Added BeginGroup()/EndGroup() layout tools (#160).
- Added Indent() / Unindent().
- Added InputInt2(), InputInt3(), InputInt4() for completeness.
- Added GetItemRectSize().
- Added VSliderFloat(), VSliderInt(), vertical sliders.
- Added IsRootWindowFocused(), IsRootWindowOrAnyChildFocused().
- Added io.KeyAlt + support in examples apps, in prevision for future usage of Alt modifier (was missing).
- Added ImGuiStyleVar_GrabMinSize enum value for PushStyleVar().
- Various fixes related to vertical alignment of text after widget of varied sizes. Allow for multiple blocks of multiple lines text on the same "line". Added demos.
- Explicit size passed to Plot*(), Button() includes the frame padding.
- Style: Changed default Border and Column border colors to be most subtle.
- Renamed style.TreeNodeSpacing to style.IndentSpacing, ImGuiStyleVar_TreeNodeSpacing to ImGuiStyleVar_IndentSpacing.
- Renamed GetWindowIsFocused() to IsWindowFocused(), kept inline redirection with old name (will obsolete).
- Renamed GetItemRectMin()/GetItemRectMax() to GetItemRectMin()/GetItemRectMax(), kept inline redirection with old name (will obsolete).
- Sliders: Fast-path when power=1.0f, also makes code easier to read.
- Sliders: Fixed parsing of decimal precision back from format string when using %%.
- Sliders: Fixed hovering bounding test excluding padding between outer frame and grab (there was a few pixels dead-zone).
- Separator() logs itself as text when passing through text log.
- Optimisation: TreeNodeV() early out if SkipItems is set without formatting.
- Moved various static buffers into state. Increase the formatted string buffer from 1K to 3K.
- Examples: Example console keeps focus on input box at all times.
- Examples: Updated to GLFW 3.1. Moved to examples/libs/ folder.
- Examples: Added 64-bit projects for MSVC.
- Examples: Increase warning level from /W3 to /W4 for MSVC.
- Examples: DirectX9: fixed duplicate creation of vertex buffer.
- Renamed internal type ImGuiAabb to ImRect. Changed mentions of 'box' or 'aabb' to say 'rect'.
- Tweaks, minor fixes and comments.
-----------------------------------------------------------------------
VERSION 1.35 (2015-03-09)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.35
Other Changes:
- Examples: refactored all examples application to make it easier to isolate and grab the code you need for OpenGL 2/3, DirectX 9/11, and toward a more sensible format for samples.
- Scrollbar grab have a minimum size (style.GrabSizeMin), always visible even with huge scroll amount. (#150).
- Scrollbar: Clicking inside the grab box doesn't modify scroll value. Subsequent movement always relative.
- Added "###" labelling syntax to pass a label that isn't part of the hashed ID (#107), e.g. ("%d###static_id",rand()).
- Added GetColumnIndex(), GetColumnsCount() (#154)
- Added GetScrollPosY(), GetScrollMaxY().
- Fixed the Chinese/Japanese glyph ranges; include missing punctuations (#156)
- Fixed Combo() and ListBox() labels not included in declared size, for use with SameLine(), etc. (fix #149, #151).
- Fixed ListBoxHeader() incorrect handling of SkipItems early out when window is collapsed.
- Fixed using IsItemHovered() after EndChild() (#151)
- Fixed malformed UTF-8 decoding errors leading to infinite loops (#158)
- InputText() handles buffer limit correctly for multi-byte UTF-8 characters, won't insert an incomplete UTF-8 character when reaching buffer limit (fix #158)
- Handle double-width space (0x3000) in various places the same as single-width spaces, for Chinese/Japanese users.
- Collapse triangle uses text color (not border color).
- Fixed font fallback glyph width.
- Renamed style.ScrollBarWidth to style.ScrollbarWidth to be consistent with other casing.
- Windows: setup a default handler for ImeSetInputScreenPosFn so the IME dialog (for Japanese/Chinese, etc.) is positioned correctly as you input text.
- Windows: default clipboard handlers for Windows handle UTF-8.
- Examples: Fixed DirectX 9/11 examples applications handling of Microsoft IME.
- Examples: Allow DirectX 9/11 examples applications to resize the window.
- ShowTestWindow: Fixed "undo" button of custom rendering applet.
- ShowTestWindow: Added "Manipulating Window Title" example.
-----------------------------------------------------------------------
VERSION 1.34 (2015-03-02)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.34
Other Changes:
- Added Bullet() helper - equivalent to BulletText(""), SameLine().
- Added SetWindowFocus(), SetWindowFocus(const char*), SetNextWindowFocus() (#146)
- Added SetWindowPos(), SetWindowSize(), SetWindowCollaposed() given a window name.
- Added SetNextTreeNodeOpened() with optional condition flag in replacement of OpenNextNode() and consistent with other API.
- Renamed ImGuiSetCondition_* to ImGuiSetCond_* and ImGuiCondition_FirstUseThisSession to ImGuiCond_Once.
- Added missing definition for ImGui::GetWindowCollapsed().
- Fixed GetGlyphRangesJapanese() actually missing katakana ranges and a few useful extensions.
- Fixed clicking on a widget in a child window not focusing the parent window (#147).
- Fixed clicking on empty space of child window not setting keyboard focus for the child window (#147).
- Fixed IsItemHovered() behaving differently on Combo() (#145)
- Fixed ColumnOffsets storage not honoring SetStateStorage() (not very useful but consistent).
- Examples: Removed dependency on Glew for OpenGL examples. Removed Glew binaries for Windows.
- Examples: Fixed link warning for OpenGL windows examples.
- Comments, tweaks.
-----------------------------------------------------------------------
VERSION 1.33b (2015-02-23)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.33b
Other Changes:
- Fixed resizing columns.
-----------------------------------------------------------------------
VERSION 1.33 (2015-02-22)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.33
Other Changes:
- InputText: having a InputText widget active doesn't steal mouse inputs from clicking on a button before losing focus (relate to #134)
- InputText: cursor/selection/undo stack persist when using other widgets and getting back to same (#134).
- InputText: fix effective buffer size being smaller than necessary by 1 byte (so if you give 3 bytes you can input 2 ascii chars + zero terminator, which is correct).
- Added IsAnyItemActive().
- Child window explicitly inherit collapse state from parent (so if user keeps submitting items even thought Begin has returned 'false' the child items will be clipped faster).
- BeginChild() return a bool the same way Begin() does. if true you can skip submitting content.
- Removed extraneous (1,1) padding on child window (pointed out in #125)
- Columns: doesn't bail out when SkipItems is set (fix #136)
- Columns: Separator() within column correctly vertical offset all cells (pointed out in #125)
- GetColumnOffset() / SetColumnOffset() handles padding values more correctly so matching columns can be lined up between a parent and a child window (cf. #125)
- Fix ImFont::BuildLookupTable() potential dangling pointer dereference (fix #131)
- Fix hovering of child window extending past their parent not taking account of parent clipping rectangle (fix #137)
- Sliders: value text is clipped inside the frame when resizing sliders to be small.
- ImGuITextFilter::Draw() use regular width call rather than computing its own arbitrary width.
- ImGuiTextFilter: can take a default filter string during construction.
-----------------------------------------------------------------------
VERSION 1.32 (2015-02-11)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.32
Other Changes:
- Added Selectable() building block for various list boxes, combo boxes, etc.
- Added ListBox() (#129).
- Added ListBoxHeader(), ListBoxFooter() for customized list traversal and creating multi-selection boxes.
- Fixed title bar text clipping issue (fix #128).
- InputText: added ImGuiInputTextFlags_CallbackCharFilter system for filtering/replacement (#130). Callback now passed an "EventFlag" parameter.
- InputText: Added ImGuiInputTextFlags_CharsUppercase and ImGuiInputTextFlags_CharsNoBlank stock filters.
- PushItemWidth() can take negative value to right-align items.
- Optimisation: Columns offsets cached to avoid unnecessary binary search.
- Optimisation: Optimized CalcTextSize() function by about 25% (they are often the bottleneck when submitting thousands of clipped items).
- Added ImGuiCol_ChildWindowBg, ImGuiStyleVar_ChildWindowRounding for completeness and flexibility.
- Added BeginChild() variant that takes an ImGuiID.
- Tweak default ImGuiCol_HeaderActive color to be less bright.
- Calculate framerate for the user (IO.Framerate), as a purely luxurious feature and to reduce sample code size a little.
-----------------------------------------------------------------------
VERSION 1.31 (2015-02-08)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.31
Other Changes:
- Added ImGuiWindowFlags_NoCollapse flag.
- Added a way to replace the internal state pointer so that we can optionally share it between modules (e.g. multiple DLLs).
- Added tint_col parameter to ImageButton().
- Added CalcListClipping() helper to perform faster/coarse clipping on user side (when manipulating lists with thousands of items).
- Added GetCursorPosX() / GetCursorPosY() shortcuts.
- Renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing().
- Combo box always appears above other child windows of a same parent.
- Combo/Label: label is properly clipped inside the frame (#23).
- Added cpu-side text clipping functions which are used in some instances to avoid extra draw calls.
- InputText: Filtering private Unicode range 0xE000-0xF8FF.
- Fixed holding button over scrollbar creating a small feedback loop with calculation of contents size.
- Calling SetCursorPos() automatically extends the contents size.
- Track ownership of mouse clicks. Avoid requesting IO.WantCaptureMouse if initial click was outside of ImGui.
- Removed the dependency on realloc().
- Other fixes, tweaks and comments.
-----------------------------------------------------------------------
VERSION 1.30 (2015-02-01)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.30
Breaking Changes:
- Big update! Initialisation had to be changed. You don't need to load PNG data anymore. The new system gives you uncompressed texture data.
- This sequence:
const void* png_data;
unsigned int png_size;
ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size);
// <Copy to GPU>
- Became:
unsigned char* pixels;
int width, height;
// io.Fonts->AddFontFromFileTTF("myfontfile.ttf", 24.0f); // Optionally load another font
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
// <Copy to GPU>
io.Fonts->TexID = (your_texture_identifier);
- PixelCenterOffset has been removed and isn't a necessary setting anymore. Offset your projection matrix by 0.5 if you have rendering problems.
Other Changes:
- Loading TTF files with stb_truetype.h.
- We still embed a compressed pixel-perfect TTF version of ProggyClean for convenience.
- Runtime font rendering is a little faster than previously.
- You can load multiple fonts with multiple size inside the font atlas. Rendering with multiple fonts are still merged into a single draw call whenever possible.
- The system handles UTF-8 and provide ranges to easily load e.g. characters for Japanese display.
- Added PushFont() / PopFont().
- Added Image() and ImageButton() to display your own texture data.
- Added callback system in command-list. This can be used if you want to do your own rendering (e.g. render a 3D scene) inside ImGui widgets.
- Added IsItemActive() to tell if last widget is being held / modified (as opposed to just being hovered). Useful for custom dragging behaviors.
- Style: Added FrameRounding setting for a more rounded look (default to 0 for now).
- Window: Fixed using multiple Begin/End pair on the same wnidow.
- Window: Fixed style.WindowMinSize not being honored properly.
- Window: Added SetCursorScreenPos() helper (WindowPos+CursorPos = ScreenPos).
- ColorEdit3: clicking on color square change the edition. The toggle button is hidden by default.
- Clipboard: Fixed logging to clipboard on architectures where va_list are passed by reference to vsnprintf.
- Clipboard: Improve memory reserve policy for Clipboard / ImGuiTextBuffer.
- Tooltip: Always auto-resize.
- Tooltip: Fixed TooltigBg color not being honored properly.
- Tooltip: Allow SetNextWindowPos() to be used on tooltips.
- Added io.DisplayVisibleMin / io.DisplayVisibleMax to ease integration of virtual / scrolling display.
- Added Set/GetVoidPtr in ImGuiStorage.
- Added ColorConvertHSVtoRGB, ColorConvertRGBtoHSV, ColorConvertFloat4ToU32 helpers.
- Added ImColor() inline helper to easily convert colors to packed 4x1 byte or 4x1 float formats.
- Added io.MouseDrawCursor option to draw a mouse cursor for now (on systems that don't have one)
- Examples: Added custom drawing app example for using ImDrawList api.
- Lots of others fixes, tweaks and comments!
-----------------------------------------------------------------------
VERSION 1.20 (2015-01-07)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.20
- Fixed InputInt() InputFloat() label not declaring their width, breaking usage of SameLine().
- Fixed hovering of combo boxes that extend beyond the parent window limits.
- Fixed text input of Unicode character in the 128-255 range.
- Fixed clipboard pasting into an InputText box not filtering the characters according to contents semantic.
- Dragging outside area of a widget while it is active doesn't trigger hover on other widgets.
- Activating widget bring parent window to front if not already.
- Checkbox and Radio buttons activate on click-release to be consistent with other widgets and most UI.
- InputText() nows consume input characters immediately so they cannot be reused if ImGui::Update is called again with a call to ImGui::Render(). (fixes #105)
- Examples: Console: added support for History callbacks + some cleanup.
- Various small optimisations.
- Cleanup and other fixes.
-----------------------------------------------------------------------
VERSION 1.19 (2014-12-30)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.19
- Tightening default style a little.
- Added ImGuiStyleVar_WindowRounding enum for PushStyleVar() API.
- Added SliderInt2(), SliderInt3(), SliderInt4() for consistency.
- Widgets more consistently handle empty labels (starting with ## mark) for their size calculation.
- Fixed crashing with zero sized frame-buffer.
- Fixed ImGui::Combo() not registering its size properly when clipped out of screen.
- Renamed second parameter to Begin() to 'bool* p_opened' to be a little more self-explanatory. Added more comments on the use of Begin().
- Logging: Added LogText() to pass text straight to the log output (tty/clipboard/file) without rendering it.
- Logging: Added LogFinish() to stop logging at an arbitrary point.
- Logging: Log depth padding relative to start depth.
- Logging: Tree nodes and headers looking better when logged to text.
- Logging: Log outputs \r\n under Windows to play it nicely with \n unaware tools such as Notepad.
- Style editor: added a button to output colors to clipboard/tty.
- OpenGL3 example: fix growing of VBO.
- Cleanup and other minor fixes.
-----------------------------------------------------------------------
VERSION 1.18 (2014-12-11)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.18
- Added ImGuiWindowFlags_NoScrollWithMouse, disable mouse wheel scrolling on a window.
- Added ImGuiWindowFlags_NoSavedSettings, disable loading/saving window state to .ini file.
- Added SetNextWindowPos(), SetNextWindowSize(), SetNextWindowCollapsed() API along with SetWindowPos(), SetWindowSize(), SetWindowCollapsed(). All functions include an optional second parameter to easily set current value vs session default value vs persistent default value.
- Removed rarely useful SetNewWindowDefaultPos() in favor of new API.
- Fixed hovering of lower-right resize grip when it is above a child window.
- Fixed InputInt() writing to output when it doesn't need to.
- Added IMGUI_INCLUDE_IMGUI_USER_H define to include user file at the bottom of imgui.h without modifying the vanilla distribution.
- ImGuiStorage helper can store float + added helpers to get pointer to stored data.
- Setup Travis CI integration. Builds the OpenGL examples on Linux with GCC and Clang.
- Examples: Added a "Fixed overlay" example in ShowTestWindow().
- Examples: Re-added OpenGL 3 programmable-pipeline example (along with the existing fixed pipeline example).
- Examples: OpenGL examples can now resize the application window.
- Other minor fixes and comments.
-----------------------------------------------------------------------
VERSION 1.17 (2014-12-03)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.17
- Added ImGuiWindowFlags_AlwaysAutoResize + example app.
- Calling ImGui::SetWindowSize(0,0) force an autofit without zero-sizing first.
- ImGui::InputText() support for completion/history/custom callback + added fancy completion example in the console demo app.
- Not word-wrapping on apostrophes.
- Increased visibility of check box and radio button with smaller size.
- Smooth mouse scrolling on OSX (uses floating point scroll/wheel input).
- New version of IMGUI_ONCE_UPON_A_FRAME helper macro that works with all compilers.
- Moved IO.Font*** options to inside the IO.Font-> structure.. Added IO.FontGlobalScale setting (in addition to Font->Scale per individual font).
- Fixed more Clang -Weverything warnings.
- Examples: Added DirectX11 example application.
- Examples: Created single .sln solution for all example projects.
- Examples: Fixed DirectX9 example window initially showing an hourglass cursor.
- Examples: Removed Microsoft IME handler in examples, too niche/confusing. Moved equivalent code to imgui.cpp instruction block.
-----------------------------------------------------------------------
VERSION 1.16b (2014-11-21)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.16b
- Fix broken PopStyleVar() crashing.
-----------------------------------------------------------------------
VERSION 1.16 (2014-11-21)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.16
- General fixing of Columns API to allow filling a cell with multiple widgets before switching to the next column.
- Added documentation INDEX to top of imgui.cpp.
- Fixed unaligned memory access for Emscripten compatibility.
- Various pedantic warning fixes (now testing with Clang).
- Added extra asserts to catch incorrect usage.
- PushStyleColor() / PushStyleVar() can be used outside the scope of a window (namely to change variables that are used within the Begin() call).
- PushTextWrapPos() defaults to 0.0 (right-end of current drawing region).
- Fixed compatibility with std::vector if user decide to #define ImVector.
- MouseWheel input is now normalized.
- Added IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT compile-time option to redefine the vertex layout.
- Style editor: colors listed inside a scrolling region.
- Examples: tweaks and fixes.
-----------------------------------------------------------------------
VERSION 1.15 (2014-11-07)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.15
- Renamed IsHovered() to IsItemHovered().
- Added word-wrapping API: TextWrapped(), PushTextWrapPos(), PopTextWrapPos().
- Added IsItemFocused() to tell if last widget is being focused for keyboard input.
- Added overloads of ImGui::PlotLines() and ImGui::PlotHistogram() taking a function pointer to get values.
- Added SetWindowSize().
- Added GetContentRegionMax() supporting columns. Some bug fixes with using columns.
- Added PushStyleVar(),PopStyleVar() helpers to modify style from user code.
- Added dummy IMGUI_API definition in front of all entry-points for silly DLL action.
- Allowing BeginChild() allows to specify negative sizes to specify "use remaining minus xx".
- Windows with the NoResize flag can still use auto-fitting.
- Added a simple example console into the demo window.
- Comments and fixes.
-----------------------------------------------------------------------
VERSION 1.14 (2014-10-25)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.14
- Comments and fixes.
- Added SetKeyboardFocusHere() to set input focus from code.
- Added GetWindowFont(), GetWindowFontSize() for users of the low-level ImDrawList API.
- Added a UserData void *pointer so that the callback functions can access user state "Just in case a project has adverse reactions to adding globals or statics in their own code."
- Renamed IMGUI_INCLUDE_IMGUI_USER_CPP to IMGUI_INCLUDE_IMGUI_USER_INL
----------------------------------------------------------------------
VERSION 1.13 (2014-09-30)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.13
- Added support for UTF-8 for international text display and text edition/input (if the font supports it).
- Added sample "M+ font" by Coji Morishita in extra_fonts/ to display Japanese text.
- Added IO.ImeSetInputScreenPosFn callback for positioning OS IME input.
- Added IO.FontFallbackGlyph (default to '?').
- OpenGL example: added commented code to load custom font from file-system.
- OpenGL example: shared makefile for Linux and MacOSX.
----------------------------------------------------------------------
VERSION 1.12 (2014-09-24)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.12
- Added IO.FontBaseScale value for easy scaling of all windows.
- Added IsMouseHoveringWindow(), IsMouseHoveringAnyWindow(), IsPosHoveringAnyWindow() helpers.
- Added va_list variations of all functions taking ellipsis (...) parameters.
- Added section in documentation to explicitly document cases of API breaking changes (e.g. renamed IM_MALLOC below).
- Moved IM_MALLOC / IM_FREE defines. to IO structure members that can be set at runtime (also allowing precompiled ImGui to cover more use cases).
- Fixed OpenGL samples for Retina display.
- Comments and minor fixes.
----------------------------------------------------------------------
VERSION 1.11 (2014-09-10)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.11
- Added more comments in the code.
- Made radio buttons render ascii when logged into tty/file/clipboard.
- Added ImGuiInputTextFlags_EnterReturnsTrue flag to InputText() and variants.
- Added #define IMGUI_INCLUDE_IMGUI_USER_CPP to optionally include imgui_user.cpp from the end of imgui.cpp
- Fixed file-descriptor leak if ImBitmapFont::LoadFromFile() calls to fseek/ftell fails.
----------------------------------------------------------------------
VERSION 1.10 (2014-08-31)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.10
- User can override memory allocators by #define-ing IM_MALLOC, IM_FREE, IM_REALLOC,
- Added SetCursorPosX(), SetCursorPosY() shortcuts.
- Checkbox() returns true when pressed.
- Added optional external fonts data in extra_fonts/ for reference.
- Removed the need to setup IO.FontHeight when using a custom font.
- Added comments on external fonts usage.
----------------------------------------------------------------------
VERSION 1.09 (2014-08-28)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.09
Breaking Changes:
- The behaviour of PixelCenterOffset changed! You may need to change your value if you had set it to non-default in your code and/or offset your projection matrix by 0.5 pixels. It is likely that the default PixelCenterOffset value of 0.0 is now suitable unless your rendering uses some form of multisampling.
Other Changes:
- Various minor render tweaks and fixes. Better support for renderers using multisampling.
- Moved IMGUI_FONT_TEX_UV_FOR_WHITE #define to a variable in the IO structure so font can be changed at runtime.
- Minor other fixes, tweaks, comments.
----------------------------------------------------------------------
VERSION 1.08 (2014-08-25)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.09
- Fixed ImGuiTextFilter trimming of leading/trailing blanks.
- Fixed file descriptor leak on LoadSettings() failure.
- Fix type conversion compiler warnings.
- Added basic sizes edition in the style editor.
- Added CalcTextSize(), GetCursorScreenPos() functions.
- Disable client state in OpenGL example after rendering.
- Converted all Tabs to Spaces in sources.
----------------------------------------------------------------------
VERSION 1.07 (2014-08-18)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.07
- Added InputFloat4(), SliderFloat4() helpers.
- Added global Alpha in ImGuiStyle structure. When Alpha=0.0, ImGui skips most of logic and all rendering processing.
- Fix clipping of title bar text.
- Fix to allow the user to call NewFrame() multiple times without calling Render().
- Reduce inner window clipping to take account for the extend of CollapsingHeader() - share same clipping rectangle.
- Fix for child windows with inverted clip rectangles (when scrolled and out of screen, Etc.).
- Minor fixes, tweaks, comments.
----------------------------------------------------------------------
VERSION 1.06 (2014-08-15)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.06
- Added BeginTooltip()/EndTooltip() helpers to create tooltips with custom contents.
- Added TextColored() helper.
- Added a 'stride' parameter to PlotLines() / PlotHistogram().
- Fixed PlotLines() / PlotHistogram() from occasionally wrapping back to the most-left value.
- TreeNode() / CollapsingHeader() ignore clicks when CTRL or SHIFT are held.
- Slowed down mouse wheel scrolling inside combo boxes.
- Minor tweaks.
- Fixed trailing '\n' in text strings reporting extra line height.
- Fixed tooltip position needlessly leaking into .ini file.
- Fixed invalid .ini file data persistently being saved back into the file.
----------------------------------------------------------------------
VERSION 1.05 (2014-08-14)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.05
- Added default clipboard functions for Windows + "private" clipboard on other systems (user can still override).
- Fixed logarithmic sliders and HSV conversions on Mac/Linux.
- Tidying up example applications so it looks easier to just grab code.
- Added GetItemBoxMin(), GetItemBoxMax().
- Tweaks, more consistent #define names.
- Fix for doing multiple Begin()/End() during the same frame.
----------------------------------------------------------------------
VERSION 1.04 (2014-08-13)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.04
- Fixes (v1.03 introduced a bug with combo box & scissoring bug OpenGL sample).
- Added ImGui::InputFloat2() and ImGui::SliderFloat2() functions.
----------------------------------------------------------------------
VERSION 1.03 (2014-08-13)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.03
- OpenGL example now use the fixed function-pipeline + cleanups, down by 150 lines.
- Added quick & dirty Makefiles for MacOSX and Linux.
- Simplified the DrawList system, ImDrawCmd include the clipping rectangle + some optimisations.
- Fixed warnings for more stringent compilation settings.
----------------------------------------------------------------------
VERSION 1.02 (2014-08-12)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.02
- Comments.
- Portability fixes.
- Fixing and tidying up sample applications.
- Checkboxes and radio buttons can be clicked on their labels as well as their icon.
- Checkboxes and radio buttons display in a different color when hovered.
----------------------------------------------------------------------
VERSION 1.01 (2014-08-11)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.01
- Added PixelCenterOffset for OpenGL/DirectX compatibility.
- Commented and tweaked samples.
- Added Git ignore list.
----------------------------------------------------------------------
VERSION 1.00 (2014-08-10)
-----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.00
- Initial release.

View File

@ -1385,9 +1385,9 @@ void ImGuiIO::ClearInputKeys()
MouseWheel = MouseWheelH = 0.0f;
}
static ImGuiInputEvent* FindLatestInputEvent(ImGuiInputEventType type, int arg = -1)
static ImGuiInputEvent* FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventType type, int arg = -1)
{
ImGuiContext& g = *GImGui;
ImGuiContext& g = *ctx;
for (int n = g.InputEventsQueue.Size - 1; n >= 0; n--)
{
ImGuiInputEvent* e = &g.InputEventsQueue[n];
@ -1406,6 +1406,8 @@ static ImGuiInputEvent* FindLatestInputEvent(ImGuiInputEventType type, int arg =
// - ImGuiKey key: Translated key (as in, generally ImGuiKey_A matches the key end-user would use to emit an 'A' character)
// - bool down: Is the key down? use false to signify a key release.
// - float analog_value: 0.0f..1.0f
// IMPORTANT: THIS FUNCTION AND OTHER "ADD" GRABS THE CONTEXT FROM OUR INSTANCE.
// WE NEED TO ENSURE THAT ALL FUNCTION CALLS ARE FULLFILLING THIS, WHICH IS WHY GetKeyData() HAS AN EXPLICIT CONTEXT.
void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
{
//if (e->Down) { IMGUI_DEBUG_LOG_IO("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); }
@ -1414,7 +1416,7 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
return;
ImGuiContext& g = *Ctx;
IM_ASSERT(ImGui::IsNamedKeyOrModKey(key)); // Backend needs to pass a valid ImGuiKey_ constant. 0..511 values are legacy native key codes which are not accepted by this API.
IM_ASSERT(!ImGui::IsAliasKey(key)); // Backend cannot submit ImGuiKey_MouseXXX values they are automatically inferred from AddMouseXXX() events.
IM_ASSERT(ImGui::IsAliasKey(key) == false); // Backend cannot submit ImGuiKey_MouseXXX values they are automatically inferred from AddMouseXXX() events.
IM_ASSERT(key != ImGuiMod_Shortcut); // We could easily support the translation here but it seems saner to not accept it (TestEngine perform a translation itself)
// Verify that backend isn't mixing up using new io.AddKeyEvent() api and old io.KeysDown[] + io.KeyMap[] data.
@ -1429,8 +1431,8 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
BackendUsingLegacyNavInputArray = false;
// Filter duplicate (in particular: key mods and gamepad analog values are commonly spammed)
const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_Key, (int)key);
const ImGuiKeyData* key_data = ImGui::GetKeyData(key);
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Key, (int)key);
const ImGuiKeyData* key_data = ImGui::GetKeyData(&g, key);
const bool latest_key_down = latest_event ? latest_event->Key.Down : key_data->Down;
const float latest_key_analog = latest_event ? latest_event->Key.AnalogValue : key_data->AnalogValue;
if (latest_key_down == down && latest_key_analog == analog_value)
@ -1496,7 +1498,7 @@ void ImGuiIO::AddMousePosEvent(float x, float y)
ImVec2 pos((x > -FLT_MAX) ? ImFloorSigned(x) : x, (y > -FLT_MAX) ? ImFloorSigned(y) : y);
// Filter duplicate
const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_MousePos);
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MousePos);
const ImVec2 latest_pos = latest_event ? ImVec2(latest_event->MousePos.PosX, latest_event->MousePos.PosY) : g.IO.MousePos;
if (latest_pos.x == pos.x && latest_pos.y == pos.y)
return;
@ -1518,7 +1520,7 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
return;
// Filter duplicate
const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_MouseButton, (int)mouse_button);
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MouseButton, (int)mouse_button);
const bool latest_button_down = latest_event ? latest_event->MouseButton.Down : g.IO.MouseDown[mouse_button];
if (latest_button_down == down)
return;
@ -1551,14 +1553,14 @@ void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)
void ImGuiIO::AddMouseViewportEvent(ImGuiID viewport_id)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
IM_ASSERT(Ctx != NULL);
ImGuiContext& g = *Ctx;
IM_ASSERT(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport);
if (!AppAcceptingEvents)
return;
// Filter duplicate
const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_MouseViewport);
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_MouseViewport);
const ImGuiID latest_viewport_id = latest_event ? latest_event->MouseViewport.HoveredViewportID : g.IO.MouseHoveredViewport;
if (latest_viewport_id == viewport_id)
return;
@ -1576,7 +1578,7 @@ void ImGuiIO::AddFocusEvent(bool focused)
ImGuiContext& g = *Ctx;
// Filter duplicate
const ImGuiInputEvent* latest_event = FindLatestInputEvent(ImGuiInputEventType_Focus);
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Focus);
const bool latest_focused = latest_event ? latest_event->AppFocused.Focused : !g.IO.AppFocusLost;
if (latest_focused == focused)
return;
@ -3666,6 +3668,7 @@ void ImGui::Shutdown()
g.ClipboardHandlerData.clear();
g.MenusIdSubmittedThisFrame.clear();
g.InputTextState.ClearFreeMemory();
g.InputTextDeactivatedState.ClearFreeMemory();
g.SettingsWindows.clear();
g.SettingsHandlers.clear();
@ -3844,8 +3847,11 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
// Clear previous active id
if (g.ActiveId != 0)
{
// While most behaved code would make an effort to not steal active id during window move/drag operations,
// we at least need to be resilient to it. Cancelling the move is rather aggressive and users of 'master' branch
// we at least need to be resilient to it. Canceling the move is rather aggressive and users of 'master' branch
// may prefer the weird ill-defined half working situation ('docking' did assert), so may need to rework that.
if (g.MovingWindow != NULL && g.ActiveId == g.MovingWindow->MoveId)
{
@ -3853,6 +3859,13 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
g.MovingWindow = NULL;
}
// This could be written in a more general way (e.g associate a hook to ActiveId),
// but since this is currently quite an exception we'll leave it as is.
// One common scenario leading to this is: pressing Key ->NavMoveRequestApplyResult() -> ClearActiveId()
if (g.InputTextState.ID == g.ActiveId)
InputTextDeactivateHook(g.ActiveId);
}
// Set active id
g.ActiveIdIsJustActivated = (g.ActiveId != id);
if (g.ActiveIdIsJustActivated)
@ -3876,7 +3889,8 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
if (id)
{
g.ActiveIdIsAlive = id;
g.ActiveIdSource = (g.NavActivateId == id || g.NavJustMovedToId == id) ? (ImGuiInputSource)ImGuiInputSource_Nav : ImGuiInputSource_Mouse;
g.ActiveIdSource = (g.NavActivateId == id || g.NavJustMovedToId == id) ? g.NavInputSource : ImGuiInputSource_Mouse;
IM_ASSERT(g.ActiveIdSource != ImGuiInputSource_None);
}
// Clear declaration of inputs claimed by the widget
@ -3924,11 +3938,17 @@ void ImGui::MarkItemEdited(ImGuiID id)
// This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit().
// ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need to fill the data.
ImGuiContext& g = *GImGui;
IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive);
IM_UNUSED(id); // Avoid unused variable warnings when asserts are compiled out.
//IM_ASSERT(g.CurrentWindow->DC.LastItemId == id);
if (g.ActiveId == id || g.ActiveId == 0)
{
g.ActiveIdHasBeenEditedThisFrame = true;
g.ActiveIdHasBeenEditedBefore = true;
}
// We accept a MarkItemEdited() on drag and drop targets (see https://github.com/ocornut/imgui/issues/1875#issuecomment-978243343)
// We accept 'ActiveIdPreviousFrame == id' for InputText() returning an edit after it has been taken ActiveId away (#4714)
IM_ASSERT(g.DragDropActive || g.ActiveId == id || g.ActiveId == 0 || g.ActiveIdPreviousFrame == id);
//IM_ASSERT(g.CurrentWindow->DC.LastItemId == id);
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_Edited;
}
@ -5542,7 +5562,7 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
FocusWindow(child_window);
NavInitWindow(child_window, false);
SetActiveID(id + 1, child_window); // Steal ActiveId with another arbitrary id so that key-press won't activate child item
g.ActiveIdSource = ImGuiInputSource_Nav;
g.ActiveIdSource = g.NavInputSource;
}
return ret;
}
@ -8307,13 +8327,13 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
// - Shortcut() [Internal]
//-----------------------------------------------------------------------------
ImGuiKeyData* ImGui::GetKeyData(ImGuiKey key)
ImGuiKeyData* ImGui::GetKeyData(ImGuiContext* ctx, ImGuiKey key)
{
ImGuiContext& g = *GImGui;
ImGuiContext& g = *ctx;
// Special storage location for mods
if (key & ImGuiMod_Mask_)
key = ConvertSingleModFlagToKey(key);
key = ConvertSingleModFlagToKey(ctx, key);
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
IM_ASSERT(key >= ImGuiKey_LegacyNativeKey_BEGIN && key < ImGuiKey_NamedKey_END);
@ -8362,22 +8382,22 @@ IM_STATIC_ASSERT(ImGuiKey_NamedKey_COUNT == IM_ARRAYSIZE(GKeyNames));
const char* ImGui::GetKeyName(ImGuiKey key)
{
ImGuiContext& g = *GImGui;
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
IM_ASSERT((IsNamedKey(key) || key == ImGuiKey_None) && "Support for user key indices was dropped in favor of ImGuiKey. Please update backend and user code.");
#else
if (IsLegacyKey(key))
{
ImGuiIO& io = GetIO();
if (io.KeyMap[key] == -1)
if (g.IO.KeyMap[key] == -1)
return "N/A";
IM_ASSERT(IsNamedKey((ImGuiKey)io.KeyMap[key]));
key = (ImGuiKey)io.KeyMap[key];
IM_ASSERT(IsNamedKey((ImGuiKey)g.IO.KeyMap[key]));
key = (ImGuiKey)g.IO.KeyMap[key];
}
#endif
if (key == ImGuiKey_None)
return "None";
if (key & ImGuiMod_Mask_)
key = ConvertSingleModFlagToKey(key);
key = ConvertSingleModFlagToKey(&g, key);
if (!IsNamedKey(key))
return "Unknown";
@ -8472,7 +8492,7 @@ static void ImGui::UpdateKeyRoutingTable(ImGuiKeyRoutingTable* rt)
// Apply routing to owner if there's no owner already (RoutingCurr == None at this point)
if (routing_entry->Mods == g.IO.KeyMods)
{
ImGuiKeyOwnerData* owner_data = ImGui::GetKeyOwnerData(key);
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
if (owner_data->OwnerCurr == ImGuiKeyOwner_None)
owner_data->OwnerCurr = routing_entry->RoutingCurr;
}
@ -8509,7 +8529,7 @@ ImGuiKeyRoutingData* ImGui::GetShortcutRoutingData(ImGuiKeyChord key_chord)
ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
ImGuiKey mods = (ImGuiKey)(key_chord & ImGuiMod_Mask_);
if (key == ImGuiKey_None)
key = ConvertSingleModFlagToKey(mods);
key = ConvertSingleModFlagToKey(&g, mods);
IM_ASSERT(IsNamedKey(key));
// Get (in the majority of case, the linked list will have one element so this should be 2 reads.
@ -9242,7 +9262,7 @@ void ImGui::SetNextFrameWantCaptureMouse(bool want_capture_mouse)
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
static const char* GetInputSourceName(ImGuiInputSource source)
{
const char* input_source_names[] = { "None", "Mouse", "Keyboard", "Gamepad", "Nav", "Clipboard" };
const char* input_source_names[] = { "None", "Mouse", "Keyboard", "Gamepad", "Clipboard" };
IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT && source >= 0 && source < ImGuiInputSource_COUNT);
return input_source_names[source];
}
@ -9389,7 +9409,7 @@ ImGuiID ImGui::GetKeyOwner(ImGuiKey key)
return ImGuiKeyOwner_None;
ImGuiContext& g = *GImGui;
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key);
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
ImGuiID owner_id = owner_data->OwnerCurr;
if (g.ActiveIdUsingAllKeyboardKeys && owner_id != g.ActiveId && owner_id != ImGuiKeyOwner_Any)
@ -9413,7 +9433,7 @@ bool ImGui::TestKeyOwner(ImGuiKey key, ImGuiID owner_id)
if (key >= ImGuiKey_Keyboard_BEGIN && key < ImGuiKey_Keyboard_END)
return false;
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key);
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
if (owner_id == ImGuiKeyOwner_Any)
return (owner_data->LockThisFrame == false);
@ -9441,7 +9461,8 @@ void ImGui::SetKeyOwner(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags)
IM_ASSERT(IsNamedKeyOrModKey(key) && (owner_id != ImGuiKeyOwner_Any || (flags & (ImGuiInputFlags_LockThisFrame | ImGuiInputFlags_LockUntilRelease)))); // Can only use _Any with _LockXXX flags (to eat a key away without an ID to retrieve it)
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetKeyOwner) == 0); // Passing flags not supported by this function!
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key);
ImGuiContext& g = *GImGui;
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
owner_data->OwnerCurr = owner_data->OwnerNext = owner_id;
// We cannot lock by default as it would likely break lots of legacy code.
@ -9490,7 +9511,7 @@ bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags
// Special storage location for mods
ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
if (key == ImGuiKey_None)
key = ConvertSingleModFlagToKey(mods);
key = ConvertSingleModFlagToKey(&g, mods);
if (!IsKeyPressed(key, owner_id, (flags & (ImGuiInputFlags_Repeat | (ImGuiInputFlags)ImGuiInputFlags_RepeatRateMask_))))
return false;
@ -9941,7 +9962,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
// return false;
const bool is_rect_visible = bb.Overlaps(window->ClipRect);
if (!is_rect_visible)
if (id == 0 || (id != g.ActiveId && id != g.NavId))
if (id == 0 || (id != g.ActiveId && id != g.ActiveIdPreviousFrame && id != g.NavId))
if (!g.LogEnabled)
return false;
@ -11232,7 +11253,7 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
if (g.LastItemData.ID == id)
window->NavRectRel[nav_layer] = WindowRectAbsToRel(window, g.LastItemData.NavRect);
if (g.ActiveIdSource == ImGuiInputSource_Nav)
if (g.ActiveIdSource == ImGuiInputSource_Keyboard || g.ActiveIdSource == ImGuiInputSource_Gamepad)
g.NavDisableMouseHover = true;
else
g.NavDisableHighlight = true;
@ -19290,7 +19311,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
{
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
{
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key);
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
if (owner_data->OwnerCurr == ImGuiKeyOwner_None)
continue;
Text("%s: 0x%08X%s", GetKeyName(key), owner_data->OwnerCurr,

View File

@ -23,7 +23,7 @@
// Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
#define IMGUI_VERSION "1.89.5 WIP"
#define IMGUI_VERSION_NUM 18941
#define IMGUI_VERSION_NUM 18943
#define IMGUI_HAS_TABLE
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
#define IMGUI_HAS_DOCK // Docking WIP branch

View File

@ -5786,8 +5786,6 @@ static void ShowDemoWindowColumns()
ImGui::TreePop();
}
namespace ImGui { extern ImGuiKeyData* GetKeyData(ImGuiKey key); }
static void ShowDemoWindowInputs()
{
IMGUI_DEMO_MARKER("Inputs & Focus");
@ -5822,7 +5820,7 @@ static void ShowDemoWindowInputs()
struct funcs { static bool IsLegacyNativeDupe(ImGuiKey key) { return key < 512 && ImGui::GetIO().KeyMap[key] != -1; } }; // Hide Native<>ImGuiKey duplicates when both exists in the array
ImGuiKey start_key = (ImGuiKey)0;
#endif
ImGui::Text("Keys down:"); for (ImGuiKey key = start_key; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1)) { if (funcs::IsLegacyNativeDupe(key) || !ImGui::IsKeyDown(key)) continue; ImGui::SameLine(); ImGui::Text((key < ImGuiKey_NamedKey_BEGIN) ? "\"%s\"" : "\"%s\" %d", ImGui::GetKeyName(key), key); ImGui::SameLine(); ImGui::Text("(%.02f)", ImGui::GetKeyData(key)->DownDuration); }
ImGui::Text("Keys down:"); for (ImGuiKey key = start_key; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1)) { if (funcs::IsLegacyNativeDupe(key) || !ImGui::IsKeyDown(key)) continue; ImGui::SameLine(); ImGui::Text((key < ImGuiKey_NamedKey_BEGIN) ? "\"%s\"" : "\"%s\" %d", ImGui::GetKeyName(key), key); }
ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.

View File

@ -134,6 +134,7 @@ struct ImGuiDockNode; // Docking system node (hold a list of Windo
struct ImGuiDockNodeSettings; // Storage for a dock node in .ini file (we preserve those even if the associated dock node isn't active during the session)
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
struct ImGuiInputTextDeactivateData;// Short term storage to backup text of a deactivating InputText() while another is stealing active id
struct ImGuiLastItemData; // Status storage for last submitted items
struct ImGuiLocEntry; // A localization entry.
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
@ -1058,6 +1059,15 @@ struct IMGUI_API ImGuiMenuColumns
void CalcNextTotalWidth(bool update_offsets);
};
// Internal temporary state for deactivating InputText() instances.
struct IMGUI_API ImGuiInputTextDeactivatedState
{
ImGuiID ID; // widget id owning the text state (which just got deactivated)
ImVector<char> TextA; // text buffer
ImGuiInputTextDeactivatedState() { memset(this, 0, sizeof(*this)); }
void ClearFreeMemory() { ID = 0; TextA.clear(); }
};
// Internal state of the currently focused/edited text input box
// For a given item ID, access with ImGui::GetInputTextState()
struct IMGUI_API ImGuiInputTextState
@ -1277,7 +1287,6 @@ enum ImGuiInputSource
ImGuiInputSource_Keyboard,
ImGuiInputSource_Gamepad,
ImGuiInputSource_Clipboard, // Currently only used by InputText()
ImGuiInputSource_Nav, // Stored in g.ActiveIdSource only
ImGuiInputSource_COUNT
};
@ -1968,7 +1977,7 @@ struct ImGuiContext
bool ActiveIdHasBeenEditedThisFrame;
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
ImGuiWindow* ActiveIdWindow;
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
ImGuiInputSource ActiveIdSource; // Activating source: ImGuiInputSource_Mouse OR ImGuiInputSource_Keyboard OR ImGuiInputSource_Gamepad
int ActiveIdMouseButton;
ImGuiID ActiveIdPreviousFrame;
bool ActiveIdPreviousFrameIsAlive;
@ -2031,7 +2040,7 @@ struct ImGuiContext
ImGuiKeyChord NavJustMovedToKeyMods;
ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame.
ImGuiActivateFlags NavNextActivateFlags;
ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard.
ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS CAN ONLY BE ImGuiInputSource_Keyboard or ImGuiInputSource_Mouse
ImGuiNavLayer NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later.
bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRectRel is valid
bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default)
@ -2125,6 +2134,7 @@ struct ImGuiContext
// Widget state
ImVec2 MouseLastValidPos;
ImGuiInputTextState InputTextState;
ImGuiInputTextDeactivatedState InputTextDeactivatedState;
ImFont InputTextPasswordFont;
ImGuiID TempInputId; // Temporary text input when CTRL+clicking on a slider, etc.
ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets
@ -2283,7 +2293,7 @@ struct ImGuiContext
NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
NavActivateFlags = NavNextActivateFlags = ImGuiActivateFlags_None;
NavJustMovedToKeyMods = ImGuiMod_None;
NavInputSource = ImGuiInputSource_None;
NavInputSource = ImGuiInputSource_Keyboard;
NavLayer = ImGuiNavLayer_Main;
NavIdIsAlive = false;
NavMousePosDirty = false;
@ -3125,9 +3135,9 @@ namespace ImGui
inline bool IsMouseKey(ImGuiKey key) { return key >= ImGuiKey_Mouse_BEGIN && key < ImGuiKey_Mouse_END; }
inline bool IsAliasKey(ImGuiKey key) { return key >= ImGuiKey_Aliases_BEGIN && key < ImGuiKey_Aliases_END; }
inline ImGuiKeyChord ConvertShortcutMod(ImGuiKeyChord key_chord) { ImGuiContext& g = *GImGui; IM_ASSERT_PARANOID(key_chord & ImGuiMod_Shortcut); return (key_chord & ~ImGuiMod_Shortcut) | (g.IO.ConfigMacOSXBehaviors ? ImGuiMod_Super : ImGuiMod_Ctrl); }
inline ImGuiKey ConvertSingleModFlagToKey(ImGuiKey key)
inline ImGuiKey ConvertSingleModFlagToKey(ImGuiContext* ctx, ImGuiKey key)
{
ImGuiContext& g = *GImGui;
ImGuiContext& g = *ctx;
if (key == ImGuiMod_Ctrl) return ImGuiKey_ReservedForModCtrl;
if (key == ImGuiMod_Shift) return ImGuiKey_ReservedForModShift;
if (key == ImGuiMod_Alt) return ImGuiKey_ReservedForModAlt;
@ -3136,7 +3146,8 @@ namespace ImGui
return key;
}
IMGUI_API ImGuiKeyData* GetKeyData(ImGuiKey key);
IMGUI_API ImGuiKeyData* GetKeyData(ImGuiContext* ctx, ImGuiKey key);
inline ImGuiKeyData* GetKeyData(ImGuiKey key) { ImGuiContext& g = *GImGui; return GetKeyData(&g, key); }
IMGUI_API void GetKeyChordName(ImGuiKeyChord key_chord, char* out_buf, int out_buf_size);
inline ImGuiKey MouseButtonToKey(ImGuiMouseButton button) { IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT); return (ImGuiKey)(ImGuiKey_MouseLeft + button); }
IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
@ -3162,7 +3173,7 @@ namespace ImGui
IMGUI_API void SetKeyOwner(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags = 0);
IMGUI_API void SetItemKeyOwner(ImGuiKey key, ImGuiInputFlags flags = 0); // Set key owner to last item if it is hovered or active. Equivalent to 'if (IsItemHovered() || IsItemActive()) { SetKeyOwner(key, GetItemID());'.
IMGUI_API bool TestKeyOwner(ImGuiKey key, ImGuiID owner_id); // Test that key is either not owned, either owned by 'owner_id'
inline ImGuiKeyOwnerData* GetKeyOwnerData(ImGuiKey key) { if (key & ImGuiMod_Mask_) key = ConvertSingleModFlagToKey(key); IM_ASSERT(IsNamedKey(key)); return &GImGui->KeysOwnerData[key - ImGuiKey_NamedKey_BEGIN]; }
inline ImGuiKeyOwnerData* GetKeyOwnerData(ImGuiContext* ctx, ImGuiKey key) { if (key & ImGuiMod_Mask_) key = ConvertSingleModFlagToKey(ctx, key); IM_ASSERT(IsNamedKey(key)); return &ctx->KeysOwnerData[key - ImGuiKey_NamedKey_BEGIN]; }
// [EXPERIMENTAL] High-Level: Input Access functions w/ support for Key/Input Ownership
// - Important: legacy IsKeyPressed(ImGuiKey, bool repeat=true) _DEFAULTS_ to repeat, new IsKeyPressed() requires _EXPLICIT_ ImGuiInputFlags_Repeat flag.
@ -3429,6 +3440,7 @@ namespace ImGui
// InputText
IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
IMGUI_API void InputTextDeactivateHook(ImGuiID id);
IMGUI_API bool TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags);
IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min = NULL, const void* p_clamp_max = NULL);
inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputId == id); }

View File

@ -622,7 +622,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
// Set active id so it can be queried by user via IsItemActive(), equivalent of holding the mouse button.
pressed = true;
SetActiveID(id, window);
g.ActiveIdSource = ImGuiInputSource_Nav;
g.ActiveIdSource = g.NavInputSource;
if (!(flags & ImGuiButtonFlags_NoNavFocus))
SetFocusID(id, window);
}
@ -660,7 +660,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
if (!(flags & ImGuiButtonFlags_NoNavFocus))
g.NavDisableHighlight = true;
}
else if (g.ActiveIdSource == ImGuiInputSource_Nav)
else if (g.ActiveIdSource == ImGuiInputSource_Keyboard || g.ActiveIdSource == ImGuiInputSource_Gamepad)
{
// When activated using Nav, we hold on the ActiveID until activation button is released
if (g.NavActivateDownId != id)
@ -2251,7 +2251,7 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
if (g.IO.KeyShift)
adjust_delta *= 10.0f;
}
else if (g.ActiveIdSource == ImGuiInputSource_Nav)
else if (g.ActiveIdSource == ImGuiInputSource_Keyboard || g.ActiveIdSource == ImGuiInputSource_Gamepad)
{
const int decimal_precision = is_floating_point ? ImParseFormatPrecision(format, 3) : 0;
const bool tweak_slow = IsKeyDown((g.NavInputSource == ImGuiInputSource_Gamepad) ? ImGuiKey_NavGamepadTweakSlow : ImGuiKey_NavKeyboardTweakSlow);
@ -2358,7 +2358,7 @@ bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v
// Those are the things we can do easily outside the DragBehaviorT<> template, saves code generation.
if (g.ActiveIdSource == ImGuiInputSource_Mouse && !g.IO.MouseDown[0])
ClearActiveID();
else if (g.ActiveIdSource == ImGuiInputSource_Nav && g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated)
else if ((g.ActiveIdSource == ImGuiInputSource_Keyboard || g.ActiveIdSource == ImGuiInputSource_Gamepad) && g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated)
ClearActiveID();
}
if (g.ActiveId != id)
@ -2827,7 +2827,7 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
set_new_value = true;
}
}
else if (g.ActiveIdSource == ImGuiInputSource_Nav)
else if (g.ActiveIdSource == ImGuiInputSource_Keyboard || g.ActiveIdSource == ImGuiInputSource_Gamepad)
{
if (g.ActiveIdIsJustActivated)
{
@ -3306,7 +3306,7 @@ void ImParseFormatSanitizeForPrinting(const char* fmt_in, char* fmt_out, size_t
*fmt_out = 0; // Zero-terminate
}
// - For scanning we need to remove all width and precision fields "%3.7f" -> "%f". BUT don't strip types like "%I64d" which includes digits. ! "%07I64d" -> "%I64d"
// - For scanning we need to remove all width and precision fields and flags "%+3.7f" -> "%f". BUT don't strip types like "%I64d" which includes digits. ! "%07I64d" -> "%I64d"
const char* ImParseFormatSanitizeForScanning(const char* fmt_in, char* fmt_out, size_t fmt_out_size)
{
const char* fmt_end = ImParseFormatFindEnd(fmt_in);
@ -3317,7 +3317,7 @@ const char* ImParseFormatSanitizeForScanning(const char* fmt_in, char* fmt_out,
while (fmt_in < fmt_end)
{
char c = *fmt_in++;
if (!has_type && ((c >= '0' && c <= '9') || c == '.'))
if (!has_type && ((c >= '0' && c <= '9') || c == '.' || c == '+' || c == '#'))
continue;
has_type |= ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); // Stop skipping digits
if (c != '\'' && c != '$' && c != '_') // Custom flags provided by stb_sprintf.h. POSIX 2008 also supports '.
@ -3456,7 +3456,12 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
flags |= ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
bool value_changed = false;
if (p_step != NULL)
if (p_step == NULL)
{
if (InputText(label, buf, IM_ARRAYSIZE(buf), flags))
value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
}
else
{
const float button_size = GetFrameHeight();
@ -3499,11 +3504,6 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
PopID();
EndGroup();
}
else
{
if (InputText(label, buf, IM_ARRAYSIZE(buf), flags))
value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
}
if (value_changed)
MarkItemEdited(g.LastItemData.ID);
@ -4005,6 +4005,21 @@ static void InputTextReconcileUndoStateAfterUserCallback(ImGuiInputTextState* st
p[i] = ImStb::STB_TEXTEDIT_GETCHAR(state, first_diff + i);
}
// As InputText() retain textual data and we currently provide a path for user to not retain it (via local variables)
// we need some form of hook to reapply data back to user buffer on deactivation frame. (#4714)
// It would be more desirable that we discourage users from taking advantage of the "user not retaining data" trick,
// but that more likely be attractive when we do have _NoLiveEdit flag available.
void ImGui::InputTextDeactivateHook(ImGuiID id)
{
ImGuiContext& g = *GImGui;
ImGuiInputTextState* state = &g.InputTextState;
if (id == 0 || state->ID != id)
return;
g.InputTextDeactivatedState.ID = state->ID;
g.InputTextDeactivatedState.TextA.resize(state->CurLenA + 1);
memcpy(g.InputTextDeactivatedState.TextA.Data, state->TextA.Data, state->CurLenA + 1);
}
// Edit a string of text
// - buf_size account for the zero-terminator, so a buf_size of 6 can hold "Hello" but not "Hello!".
// This is so we can easily call InputText() on static arrays using ARRAYSIZE() and to match
@ -4110,7 +4125,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
float scroll_y = is_multiline ? draw_window->Scroll.y : FLT_MAX;
const bool init_changed_specs = (state != NULL && state->Stb.single_line != !is_multiline);
const bool init_changed_specs = (state != NULL && state->Stb.single_line != !is_multiline); // state != NULL means its our state.
const bool init_make_active = (user_clicked || user_scroll_finish || input_requested_by_nav || input_requested_by_tabbing);
const bool init_state = (init_make_active || user_scroll_active);
if ((init_state && g.ActiveId != id) || init_changed_specs)
@ -4119,6 +4134,9 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
state = &g.InputTextState;
state->CursorAnimReset();
// Backup state of deactivating item so they'll have a chance to do a write to output buffer on the same frame they report IsItemDeactivatedAfterEdit (#4714)
InputTextDeactivateHook(state->ID);
// Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar)
// From the moment we focused we are ignoring the content of 'buf' (unless we are in read-only mode)
const int buf_len = (int)strlen(buf);
@ -4531,6 +4549,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// Push records into the undo stack so we can CTRL+Z the revert operation itself
apply_new_text = state->InitialTextA.Data;
apply_new_text_length = state->InitialTextA.Size - 1;
value_changed = true;
ImVector<ImWchar> w_text;
if (apply_new_text_length > 0)
{
@ -4644,10 +4663,24 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
{
apply_new_text = state->TextA.Data;
apply_new_text_length = state->CurLenA;
value_changed = true;
}
}
}
// Handle reapplying final data on deactivation (see InputTextDeactivateHook() for details)
if (g.InputTextDeactivatedState.ID == id)
{
if (g.ActiveId != id && IsItemDeactivatedAfterEdit() && !is_readonly)
{
apply_new_text = g.InputTextDeactivatedState.TextA.Data;
apply_new_text_length = g.InputTextDeactivatedState.TextA.Size - 1;
value_changed |= (strcmp(g.InputTextDeactivatedState.TextA.Data, buf) != 0);
//IMGUI_DEBUG_LOG("InputText(): apply Deactivated data for 0x%08X: \"%.*s\".\n", id, apply_new_text_length, apply_new_text);
}
g.InputTextDeactivatedState.ID = 0;
}
// Copy result to user buffer. This can currently only happen when (g.ActiveId == id)
if (apply_new_text != NULL)
{
@ -4675,7 +4708,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// If the underlying buffer resize was denied or not carried to the next frame, apply_new_text_length+1 may be >= buf_size.
ImStrncpy(buf, apply_new_text, ImMin(apply_new_text_length + 1, buf_size));
value_changed = true;
}
// Release active ID at the end of the function (so e.g. pressing Return still does a final application of the value)