mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-03 05:29:10 +08:00
Merge branch 'viewport' into docking
# Conflicts: # imgui.cpp # imgui_internal.h
This commit is contained in:
commit
0947fa3de0
@ -12,7 +12,7 @@ COMMITS HISTORY: https://github.com/ocornut/imgui/commits/master
|
||||
WHEN TO UPDATE?
|
||||
|
||||
- Keeping your copy of dear imgui updated once in a while is recommended.
|
||||
- It is generally safe to sync to the latest commit in master.
|
||||
- It is generally safe to sync to the latest commit in master.
|
||||
The library is fairly stable and regressions tends to be fixed fast when reported.
|
||||
|
||||
HOW TO UPDATE?
|
||||
@ -23,8 +23,8 @@ HOW TO UPDATE?
|
||||
- If you have a problem with a missing function/symbols, search for its name in the code, there will likely be a comment about it.
|
||||
- If you are dropping this repository in your codebase, please leave the demo and text files in there, they will be useful.
|
||||
- You may diff your previous Changelog with the one you just copied and read that diff.
|
||||
- You may enable `IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in imconfig.h to forcefully disable legacy names and symbols.
|
||||
Doing it every once in a while is a good way to make sure you are not using obsolete symbols. Dear ImGui is in active development,
|
||||
- You may enable `IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in imconfig.h to forcefully disable legacy names and symbols.
|
||||
Doing it every once in a while is a good way to make sure you are not using obsolete symbols. Dear ImGui is in active development,
|
||||
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
||||
- Please report any issue!
|
||||
|
||||
@ -92,11 +92,14 @@ Other changes:
|
||||
|
||||
Other Changes:
|
||||
- Added .editorconfig file for text editors to standardize using spaces. (#2038) [@kudaba]
|
||||
- Fixed range-version of PushID() and GetID() not honoring the ### operator to restart from the seed value.
|
||||
- ImDrawList: Fixed AddCircle(), AddCircleFilled() angle step being off, which was visible when drawing a "circle"
|
||||
with a small number of segments (e.g. an hexagon). (#2287) [@baktery]
|
||||
- ImGuiTextBuffer: Added append() function (unformatted).
|
||||
- ImFontAtlas: Added 0x2000-0x206F general punctuation range to default ChineseFull/ChineseSimplifiedCommon ranges. (#2093)
|
||||
- ImFontAtlas: FreeType: Added support for imgui allocators + custom FreeType only SetAllocatorFunctions. (#2285) [@Vuhdo]
|
||||
- Examples: Win32: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created
|
||||
- ImFontAtlas: FreeType: Fixed using imgui_freetype.cpp in unity builds. (#2302)
|
||||
- Examples: Win32: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created
|
||||
in a different thread or parent. (#1951, #2087, #2156, #2232) [many people]
|
||||
- Examples: Win32: Added support for XInput games (if ImGuiConfigFlags_NavEnableGamepad is enabled).
|
||||
- Examples: Win32: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. (#2264)
|
||||
@ -132,15 +135,15 @@ Other Changes:
|
||||
the parent window of the popup instead of the newly clicked window.
|
||||
- Window: Contents size is preserved while a window collapsed. Fix auto-resizing window losing their size for one frame when uncollapsed.
|
||||
- Window: Contents size is preserved while a window contents is hidden (unless it is hidden for resizing purpose).
|
||||
- Window: Resizing windows from edge is now enabled by default (io.ConfigWindowsResizeFromEdges=true). Note that
|
||||
- Window: Resizing windows from edge is now enabled by default (io.ConfigWindowsResizeFromEdges=true). Note that
|
||||
it only works _if_ the back-end sets ImGuiBackendFlags_HasMouseCursors, which the standard back-ends do.
|
||||
- Window: Added io.ConfigWindowsMoveFromTitleBarOnly option. This is ignored by window with no title bars (often popups).
|
||||
This affects clamping window within the visible area: with this option enabled title bars need to be visible. (#899)
|
||||
- Window: Fixed using SetNextWindowPos() on a child window (which wasn't really documented) position the cursor as expected
|
||||
in the parent window, so there is no mismatch between the layout in parent and the position of the child window.
|
||||
in the parent window, so there is no mismatch between the layout in parent and the position of the child window.
|
||||
- InputFloat: When using ImGuiInputTextFlags_ReadOnly the step buttons are disabled. (#2257)
|
||||
- DragFloat: Fixed broken mouse direction change with power!=1.0. (#2174, #2206) [@Joshhua5]
|
||||
- Nav: Fixed an keyboard issue where holding Activate/Space for longer than two frames on a button would unnecessary
|
||||
- Nav: Fixed an keyboard issue where holding Activate/Space for longer than two frames on a button would unnecessary
|
||||
keep the focus on the parent window, which could steal it from newly appearing windows. (#787)
|
||||
- Nav: Fixed animated window titles from being updated when displayed in the CTRL+Tab list. (#787)
|
||||
- Error recovery: Extraneous/undesired calls to End() are now being caught by an assert in the End() function closer
|
||||
@ -176,7 +179,7 @@ Other Changes:
|
||||
- Fixed a text rendering/clipping bug introduced in 1.66 (on 2018-10-12, commit ede3a3b9) that affect single ImDrawList::AddText()
|
||||
calls with single strings larger than 10k. Text/TextUnformatted() calls were not affected, but e.g. InputText() was. [@pdoane]
|
||||
- When the focused window become inactive don't restore focus to a window with the ImGuiWindowFlags_NoInputs flag. (#2213) [@zzzyap]
|
||||
- Separator: Fixed Separator() outputting an extraneous empty line when captured into clipboard/text/file.
|
||||
- Separator: Fixed Separator() outputting an extraneous empty line when captured into clipboard/text/file.
|
||||
- Demo: Added ShowAboutWindow() call, previously was only accessible from the demo window.
|
||||
- Demo: ShowAboutWindow() now display various Build/Config Information (compiler, os, etc.) that can easily be copied into bug reports.
|
||||
- Fixed build issue with osxcross and macOS. (#2218) [@dos1]
|
||||
@ -195,7 +198,7 @@ Breaking Changes:
|
||||
|
||||
Other Changes:
|
||||
|
||||
- Fixed calling SetNextWindowSize()/SetWindowSize() with non-integer values leading to
|
||||
- Fixed calling SetNextWindowSize()/SetWindowSize() with non-integer values leading to
|
||||
accidental alteration of window position. We now round the provided size. (#2067)
|
||||
- Fixed calling DestroyContext() always saving .ini data with the current context instead
|
||||
of the supplied context pointer. (#2066)
|
||||
@ -204,7 +207,7 @@ Other Changes:
|
||||
- Nav: Fixed an assert in certain circumstance (mostly when using popups) when mouse positions stop being valid. (#2168)
|
||||
- Nav: Fixed explicit directional input not re-highlighting current nav item if there is a single item in the window
|
||||
and highlight has been previously disabled by the mouse. (#787)
|
||||
- DragFloat: Fixed a situation where dragging with value rounding enabled or with a power curve
|
||||
- DragFloat: Fixed a situation where dragging with value rounding enabled or with a power curve
|
||||
erroneously wrapped the value to one of the min/max edge. (#2024, #708, #320, #2075).
|
||||
- DragFloat: Disabled using power curve when one edge is FLT_MAX (broken in 1.61). (#2024)
|
||||
- DragFloat: Disabled setting a default drag speed when one edge is FLT_MAX. (#2024)
|
||||
@ -223,9 +226,9 @@ Other Changes:
|
||||
to the provided string to uniquely identify the child window. This was undoing an intentional change
|
||||
introduced in 1.50 and broken in 1.60. (#1698, #894, #713).
|
||||
- TextUnformatted(): Fixed a case where large-text path would read bytes past the text_end marker depending
|
||||
on the position of new lines in the buffer (it wasn't affecting the output but still not the right thing to do!)
|
||||
- ListBox(): Fixed frame sizing when items_count==1 unnecessarily showing a scrollbar. (#2173) [@luk1337, @ocornut]
|
||||
- ListBox(): Tweaked frame sizing so list boxes will look more consistent when FramePadding is far from ItemSpacing.
|
||||
on the position of new lines in the buffer (it wasn't affecting the output but still not the right thing to do!)
|
||||
- ListBox(): Fixed frame sizing when items_count==1 unnecessarily showing a scrollbar. (#2173) [@luk1337, @ocornut]
|
||||
- ListBox(): Tweaked frame sizing so list boxes will look more consistent when FramePadding is far from ItemSpacing.
|
||||
- RenderText(): Some optimization for very large text buffers, useful for non-optimized builds.
|
||||
- BeginMenu(): Fixed menu popup horizontal offset being off the item in the menu bar when WindowPadding=0.0f.
|
||||
- ArrowButton(): Fixed arrow shape being horizontally misaligned by (FramePadding.y-FramePadding.x) if they are different.
|
||||
@ -283,7 +286,7 @@ Changes:
|
||||
isolate your patches. You can peak at imgui_widgets.cpp from 1.64 to get a sense of what is included in it,
|
||||
then separate your changes into several patches that can more easily be applied to 1.64 on a per-file basis.
|
||||
What I found worked nicely for me, was to open the diff of the old patches in an interactive merge/diff tool,
|
||||
search for the corresponding function in the new code and apply the chunks manually.
|
||||
search for the corresponding function in the new code and apply the chunks manually.
|
||||
- As a reminder, if you have any change to imgui.cpp it is a good habit to discuss them on the github,
|
||||
so a solution applicable on the Master branch can be found. If your company has changes that you cannot
|
||||
disclose you may also contact me privately.
|
||||
@ -299,10 +302,10 @@ Breaking Changes:
|
||||
- Changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecision over time.
|
||||
- Removed per-window ImGuiWindowFlags_ResizeFromAnySide Beta flag in favor `io.ConfigResizeWindowsFromEdges=true` to enable the feature globally. (#1495)
|
||||
The feature is not currently enabled by default because it is not satisfying enough, but will eventually be.
|
||||
- InputText: Renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData for consistency.
|
||||
Kept redirection types (will obsolete).
|
||||
- InputText: Renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData for consistency.
|
||||
Kept redirection types (will obsolete).
|
||||
- InputText: Removed ImGuiTextEditCallbackData::ReadOnly since it is a duplication of (ImGuiTextEditCallbackData::Flags & ImGuiInputTextFlags_ReadOnly).
|
||||
- Renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API.
|
||||
- Renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API.
|
||||
Kept redirection function (will obsolete soonish as IsItemDeactivatedAfterChange() is very recent).
|
||||
- Renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to io.ConfigMacOSXBehaviors for consistency. (#1427, #473)
|
||||
- Removed obsolete redirection functions: CollapsingHeader() variation with 2 bools - marked obsolete in v1.49, May 2016.
|
||||
@ -316,17 +319,17 @@ Other Changes:
|
||||
While it was previously possible, you won't be able to CTRL-TAB out and immediately back in a window with the ImGuiWindow_NoNavFocus flag.
|
||||
- Window: Allow menu and popups windows from ignoring the style.WindowMinSize values so short menus/popups are not padded. (#1909)
|
||||
- Window: Added global io.ConfigResizeWindowsFromEdges option to enable resizing windows from their edges and from the lower-left corner. (#1495)
|
||||
- Window: Collapse button shows hovering highlight + clicking and dragging on it allows to drag the window as well.
|
||||
- Window: Collapse button shows hovering highlight + clicking and dragging on it allows to drag the window as well.
|
||||
- Added IsItemEdited() to query if the last item modified its value (or was pressed). This is equivalent to the bool returned by most widgets.
|
||||
It is useful in some situation e.g. using InputText() with ImGuiInputTextFlags_EnterReturnsTrue. (#2034)
|
||||
- InputText: Added support for buffer size/capacity changes via the ImGuiInputTextFlags_CallbackResize flag. (#2006, #1443, #1008).
|
||||
- InputText: Fixed not tracking the cursor horizontally when modifying the text buffer through a callback.
|
||||
- InputText: Fixed minor off-by-one issue when submitting a buffer size smaller than the initial zero-terminated buffer contents.
|
||||
- InputText: Fixed a few pathological crash cases on single-line InputText widget with multiple millions characters worth of contents.
|
||||
- InputText: Fixed a few pathological crash cases on single-line InputText widget with multiple millions characters worth of contents.
|
||||
Because the current text drawing function reserve for a worst-case amount of vertices and how we handle horizontal clipping,
|
||||
we currently just avoid displaying those single-line widgets when they are over a threshold of 2 millions characters,
|
||||
we currently just avoid displaying those single-line widgets when they are over a threshold of 2 millions characters,
|
||||
until a better solution is found.
|
||||
- Drag and Drop: Fixed an incorrect assert when dropping a source that is submitted after the target (bug introduced with 1.62 changes
|
||||
- Drag and Drop: Fixed an incorrect assert when dropping a source that is submitted after the target (bug introduced with 1.62 changes
|
||||
related to the addition of IsItemDeactivated()). (#1875, #143)
|
||||
- Drag and Drop: Fixed ImGuiDragDropFlags_SourceNoDisableHover to affect hovering state prior to calling IsItemHovered() + fixed description. (#143)
|
||||
- Drag and Drop: Calling BeginTooltip() between a BeginDragSource()/EndDragSource() or BeginDropTarget()/EndDropTarget() uses adjusted tooltip
|
||||
@ -339,11 +342,11 @@ Other Changes:
|
||||
- Misc: Added optional misc/stl/imgui_stl.h wrapper to use with STL types (e.g. InputText with std::string). (#2006, #1443, #1008)
|
||||
[*EDIT* renamed to misc/std/imgui_stdlib.h in 1.66]
|
||||
- Misc: Added IMGUI_VERSION_NUM for easy compile-time testing. (#2025)
|
||||
- Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut]
|
||||
- Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut]
|
||||
- Misc: Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors.
|
||||
- Made assertion more clear when trying to call Begin() outside of the NewFrame()..EndFrame() scope. (#1987)
|
||||
- Fixed assertion when transitioning from an active ID to another within a group, affecting ColorPicker (broken in 1.62). (#2023, #820, #956, #1875).
|
||||
- Fixed PushID() from keeping alive the new ID Stack top value (if a previously active widget shared the ID it would be erroneously kept alive).
|
||||
- Fixed PushID() from keeping alive the new ID Stack top value (if a previously active widget shared the ID it would be erroneously kept alive).
|
||||
- Fixed horizontal mouse wheel not forwarding the request to the parent window if ImGuiWindowFlags_NoScrollWithMouse is set. (#1463, #1380, #1502)
|
||||
- Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276)
|
||||
- ImDrawList: Improved handling for worst-case vertices reservation policy when large amount of text (e.g. 1+ million character strings)
|
||||
@ -362,15 +365,15 @@ Other Changes:
|
||||
- Examples: OSX: Added early raw OSX platform backend. (#1873) [@pagghiu, @itamago, @ocornut]
|
||||
- Examples: Added mac OSX & iOS + Metal example in example_apple_metal/. (#1929, #1873) [@warrenm]
|
||||
- Examples: Added mac OSX + OpenGL2 example in example_apple_opengl2/. (#1873)
|
||||
- Examples: OpenGL3: Added shaders more versions of GLSL. (#1938, #1941, #1900, #1513, #1466, etc.)
|
||||
- Examples: OpenGL3: Tweaked the imgui_impl_opengl3.cpp to work as-is with Emscripten + WebGL 2.0. (#1941). [@o-micron]
|
||||
- Examples: OpenGL3: Added shaders more versions of GLSL. (#1938, #1941, #1900, #1513, #1466, etc.)
|
||||
- Examples: OpenGL3: Tweaked the imgui_impl_opengl3.cpp to work as-is with Emscripten + WebGL 2.0. (#1941). [@o-micron]
|
||||
- Examples: OpenGL3: Made the example app default to GL 3.0 + GLSL 130 (instead of GL 3.2 + GLSL 150) unless on Mac.
|
||||
- Examples: OpenGL3: Added error output when shaders fail to compile/link.
|
||||
- Examples: OpenGL3: Added support for glew and glad OpenGL loaders out of the box. (#2001, #2002) [@jdumas]
|
||||
- Examples: OpenGL2: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications. (#1996)
|
||||
- Examples: DirectX10, DirectX11: Fixed unreleased resources in Init and Shutdown functions. (#1944)
|
||||
- Examples: DirectX11: Querying for IDXGIFactory instead of IDXGIFactory1 to increase compatibility. (#1989) [@matt77hias]
|
||||
- Examples: Vulkan: Fixed handling of VkSurfaceCapabilitiesKHR::maxImageCount = 0 case. Tweaked present mode selections.
|
||||
- Examples: Vulkan: Fixed handling of VkSurfaceCapabilitiesKHR::maxImageCount = 0 case. Tweaked present mode selections.
|
||||
- Examples: Win32, Glfw, SDL: Added support for the ImGuiMouseCursor_Hand cursor.
|
||||
|
||||
|
||||
@ -380,8 +383,8 @@ Other Changes:
|
||||
|
||||
Breaking Changes:
|
||||
|
||||
- TreeNodeEx(): The helper ImGuiTreeNodeFlags_CollapsingHeader flag now include ImGuiTreeNodeFlags_NoTreePushOnOpen. The flag was already set by CollapsingHeader().
|
||||
The only difference is if you were using TreeNodeEx() manually with ImGuiTreeNodeFlags_CollapsingHeader and without ImGuiTreeNodeFlags_NoTreePushOnOpen.
|
||||
- TreeNodeEx(): The helper ImGuiTreeNodeFlags_CollapsingHeader flag now include ImGuiTreeNodeFlags_NoTreePushOnOpen. The flag was already set by CollapsingHeader().
|
||||
The only difference is if you were using TreeNodeEx() manually with ImGuiTreeNodeFlags_CollapsingHeader and without ImGuiTreeNodeFlags_NoTreePushOnOpen.
|
||||
In this case you can remove the ImGuiTreeNodeFlags_NoTreePushOnOpen flag from your call (ImGuiTreeNodeFlags_CollapsingHeader & ~ImGuiTreeNodeFlags_NoTreePushOnOpen). (#1864)
|
||||
This also apply if you were using internal's TreeNodeBehavior() with the ImGuiTreeNodeFlags_CollapsingHeader flag directly.
|
||||
- ImFontAtlas: Renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish new smaller variants and discourage using the full set. (#1859)
|
||||
@ -398,23 +401,23 @@ Other Changes:
|
||||
before: imgui_impl_sdl_gl3.cpp --> after: imgui_impl_sdl2.cpp + imgui_impl_opengl2.cpp
|
||||
before: imgui_impl_sdl_gl3.cpp --> after: imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp etc.
|
||||
- The idea is what we can now easily combine and maintain back-ends and reduce code redundancy. Individual files are smaller and more reusable.
|
||||
Integration of imgui into a new/custom engine may also be easier as there is less overlap between "windowing / inputs" and "rendering" code,
|
||||
Integration of imgui into a new/custom engine may also be easier as there is less overlap between "windowing / inputs" and "rendering" code,
|
||||
so you may study or grab one half of the code and not the other.
|
||||
- This change was motivated by the fact that adding support for the upcoming multi-viewport feature requires more work from the Platform and Renderer
|
||||
back-ends, and the amount of redundancy across files was becoming too difficult to maintain. If you use default back-ends, you'll benefit from an
|
||||
- This change was motivated by the fact that adding support for the upcoming multi-viewport feature requires more work from the Platform and Renderer
|
||||
back-ends, and the amount of redundancy across files was becoming too difficult to maintain. If you use default back-ends, you'll benefit from an
|
||||
easy update path to support multi-viewports later (for future ImGui 1.7x).
|
||||
- This is not strictly a breaking change if you keep your old bindings, but when you'll want to fully update your bindings,
|
||||
expect to have to reshuffle a few things.
|
||||
- This is not strictly a breaking change if you keep your old bindings, but when you'll want to fully update your bindings,
|
||||
expect to have to reshuffle a few things.
|
||||
- Each example still has its own main.cpp which you may refer you to understand how to initialize and glue everything together.
|
||||
- Some frameworks (such as the Allegro, Marmalade) handle both the "platform" and "rendering" part, and your custom engine may as well.
|
||||
- Read examples/README.txt for details.
|
||||
- Added IsItemDeactivated() to query if the last item was active previously and isn't anymore. Useful for Undo/Redo patterns. (#820, #956, #1875)
|
||||
- Added IsItemDeactivatedAfterChange() [*EDIT* renamed to IsItemDeactivatedAfterEdit() in 1.63] if the last item was active previously,
|
||||
is not anymore, and during its active state modified a value. Note that you may still get false positive (e.g. drag value and while
|
||||
- Added IsItemDeactivatedAfterChange() [*EDIT* renamed to IsItemDeactivatedAfterEdit() in 1.63] if the last item was active previously,
|
||||
is not anymore, and during its active state modified a value. Note that you may still get false positive (e.g. drag value and while
|
||||
holding return on the same value). (#820, #956, #1875)
|
||||
- Nav: Added support for PageUp/PageDown (explorer-style: first aim at bottom/top most item, when scroll a page worth of contents). (#787)
|
||||
- Nav: To keep the navigated item in view we also attempt to scroll the parent window as well as the current window. (#787)
|
||||
- ColorEdit3, ColorEdit4, ColorButton: Added ImGuiColorEditFlags_NoDragDrop flag to disable ColorEditX as drag target and ColorButton as drag source. (#1826)
|
||||
- ColorEdit3, ColorEdit4, ColorButton: Added ImGuiColorEditFlags_NoDragDrop flag to disable ColorEditX as drag target and ColorButton as drag source. (#1826)
|
||||
- BeginDragDropSource(): Offset tooltip position so it is off the mouse cursor, but also closer to it than regular tooltips, and not clamped by viewport. (#1739)
|
||||
- BeginDragDropTarget(): Added ImGuiDragDropFlags_AcceptNoPreviewTooltip flag to request hiding the drag source tooltip from the target site. (#143)
|
||||
- BeginCombo(), BeginMainMenuBar(), BeginChildFrame(): Temporary style modification are restored at the end of BeginXXX instead of EndXXX, to not affect tooltips and child windows.
|
||||
@ -426,15 +429,15 @@ Other Changes:
|
||||
- ImFontAtlas: Added GetGlyphRangesChineseSimplifiedCommon() helper that returns a list of ~2500 most common Simplified Chinese characters. (#1859) [@JX-Master, @ocornut]
|
||||
- Examples: OSX: Added imgui_impl_osx.mm binding to be used along with e.g. imgui_impl_opengl2.cpp. (#281, #1870) [@pagghiu, @itamago, @ocornut]
|
||||
- Examples: GLFW: Made it possible to Shutdown/Init the backend again (by reseting the time storage properly). (#1827) [@ice1000]
|
||||
- Examples: Win32: Fixed handling of mouse wheel messages to support sub-unit scrolling messages (typically sent by track-pads). (#1874) [@zx64]
|
||||
- Examples: Win32: Fixed handling of mouse wheel messages to support sub-unit scrolling messages (typically sent by track-pads). (#1874) [@zx64]
|
||||
- Examples: SDL+Vulkan: Added SDL+Vulkan example.
|
||||
- Examples: Allegro5: Added support for ImGuiConfigFlags_NoMouseCursorChange flag. Added clipboard support.
|
||||
- Examples: Allegro5: Added support for ImGuiConfigFlags_NoMouseCursorChange flag. Added clipboard support.
|
||||
- Examples: Allegro5: Unindexing buffers ourselves as Allegro indexed drawing primitives are buggy in the DirectX9 back-end (will be fixed in Allegro 5.2.5+).
|
||||
- Examples: DirectX12: Moved the ID3D12GraphicsCommandList* parameter from ImGui_ImplDX12_NewFrame() to ImGui_ImplDX12_RenderDrawData() which makes a lots more sense. (#301)
|
||||
- Examples: Vulkan: Reordered parameters ImGui_ImplVulkan_RenderDrawData() to be consistent with other bindings, a good occasion since we refactored the code.
|
||||
- Examples: Vulkan: Reordered parameters ImGui_ImplVulkan_RenderDrawData() to be consistent with other bindings, a good occasion since we refactored the code.
|
||||
- Examples: FreeGLUT: Added FreeGLUT bindings. Added FreeGLUT+OpenGL2 example. (#801)
|
||||
- Examples: The functions in imgui_impl_xxx.cpp are prefixed with IMGUI_IMPL_API (which defaults to IMGUI_API) to facilitate some uses. (#1888)
|
||||
- Examples: Fixed bindings to use ImGuiMouseCursor_COUNT instead of old name ImGuiMouseCursor_Count_ so they can compile with IMGUI_DISABLE_OBSOLETE_FUNCTIONS. (#1887)
|
||||
- Examples: Fixed bindings to use ImGuiMouseCursor_COUNT instead of old name ImGuiMouseCursor_Count_ so they can compile with IMGUI_DISABLE_OBSOLETE_FUNCTIONS. (#1887)
|
||||
- Misc: Updated stb_textedit from 1.09 + patches to 1.12 + minor patches.
|
||||
- Internals: PushItemFlag() flags are inherited by BeginChild().
|
||||
|
||||
@ -561,7 +564,7 @@ Breaking Changes:
|
||||
- Renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData.
|
||||
- Removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it should be easy to replicate on your side (you can find the code in 1.53).
|
||||
- [EDITED] Window: BeginChild() with an explicit name doesn't include the hash within the internal window name. (#1698)
|
||||
This change was erroneously introduced, undoing the change done for #894, #713, and not documented properly in the original
|
||||
This change was erroneously introduced, undoing the change done for #894, #713, and not documented properly in the original
|
||||
1.60 release Changelog. It was fixed on 2018-09-28 (1.66) and I wrote this paragraph the same day.
|
||||
|
||||
Other Changes:
|
||||
@ -575,7 +578,7 @@ Other Changes:
|
||||
- See https://github.com/ocornut/imgui/issues/1599 for recommended gamepad mapping or download PNG/PSD at http://goo.gl/9LgVZW
|
||||
- See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. Read imgui.cpp for more details.
|
||||
- To use Keyboard Navigation:
|
||||
- Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
|
||||
- Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
|
||||
- Basic controls: arrows to navigate, Alt to enter menus, Space to activate item, Enter to edit text, Escape to cancel/close, Ctrl-Tab to focus windows, etc.
|
||||
- When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag will be set.
|
||||
For more advanced uses, you may want to read from io.NavActive or io.NavVisible. Read imgui.cpp for more details.
|
||||
|
@ -18,7 +18,7 @@ Dear ImGui is a bloat-free graphical user interface library for C++. It outputs
|
||||
|
||||
Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries.
|
||||
|
||||
Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.
|
||||
Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.
|
||||
|
||||
See [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui), [Quotes](https://github.com/ocornut/imgui/wiki/Quotes) and [Gallery](https://github.com/ocornut/imgui/issues/2265) pages to get an idea of its use cases.
|
||||
|
||||
@ -76,7 +76,7 @@ ImGui::ColorEdit4("Color", my_color);
|
||||
// Plot some values
|
||||
const float my_values[] = { 0.2f, 0.1f, 1.0f, 0.5f, 0.9f, 2.2f };
|
||||
ImGui::PlotLines("Frame Times", my_values, IM_ARRAYSIZE(my_values));
|
||||
|
||||
|
||||
// Display contents in a scrolling region
|
||||
ImGui::TextColored(ImVec4(1,1,0,1), "Important Stuff");
|
||||
ImGui::BeginChild("Scrolling");
|
||||
@ -90,13 +90,13 @@ Result:
|
||||
|
||||
### How it works
|
||||
|
||||
Check out the References section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization and state retention from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.
|
||||
Check out the References section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization and state retention from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces.
|
||||
|
||||
Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate dear imgui with your existing codebase.
|
||||
Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate dear imgui with your existing codebase.
|
||||
|
||||
_A common misunderstanding is to mistake immediate mode gui for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the gui functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._
|
||||
|
||||
Dear ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue (hot code reload) feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game making editor/framework, etc.
|
||||
Dear ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue (hot code reload) feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game making editor/framework, etc.
|
||||
|
||||
Demo Binaries
|
||||
-------------
|
||||
@ -194,7 +194,7 @@ Demo window
|
||||
References
|
||||
----------
|
||||
|
||||
The Immediate Mode GUI paradigm may at first appear unusual to some users. This is mainly because "Retained Mode" GUIs have been so widespread and predominant. The following links can give you a better understanding about how Immediate Mode GUIs works.
|
||||
The Immediate Mode GUI paradigm may at first appear unusual to some users. This is mainly because "Retained Mode" GUIs have been so widespread and predominant. The following links can give you a better understanding about how Immediate Mode GUIs works.
|
||||
- [Johannes 'johno' Norneby's article](http://www.johno.se/book/imgui.html).
|
||||
- [A presentation by Rickard Gustafsson and Johannes Algelind](http://www.cse.chalmers.se/edu/year/2011/course/TDA361/Advanced%20Computer%20Graphics/IMGUI.pdf).
|
||||
- [Jari Komppa's tutorial on building an ImGui library](http://iki.fi/sol/imgui/).
|
||||
@ -216,15 +216,15 @@ Frequently Asked Question (FAQ)
|
||||
|
||||
**Where is the documentation?**
|
||||
|
||||
- The documentation is at the top of imgui.cpp + effectively imgui.h.
|
||||
- Example code is in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function. It covers most features of ImGui so you can read the code and call the function itself to see its output.
|
||||
- Standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder.
|
||||
- The documentation is at the top of imgui.cpp + effectively imgui.h.
|
||||
- Example code is in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function. It covers most features of ImGui so you can read the code and call the function itself to see its output.
|
||||
- Standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder.
|
||||
- We obviously needs better documentation! Consider contributing or becoming a [Patron](http://www.patreon.com/imgui) to promote this effort.
|
||||
- Your programming IDE is your friend, find the type or function declaration to find comments associated to it.
|
||||
- Your programming IDE is your friend, find the type or function declaration to find comments associated to it.
|
||||
|
||||
**Which version should I get?**
|
||||
|
||||
I occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported.
|
||||
I occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported.
|
||||
|
||||
You may also peak at the [Multi-Viewport](https://github.com/ocornut/imgui/issues/1542) and [Docking](https://github.com/ocornut/imgui/issues/2109) branches. Even though they are marked beta, several projects are using them and they are kept in sync with master regularly.
|
||||
|
||||
@ -314,9 +314,9 @@ And all other supporters; THANK YOU!
|
||||
Credits
|
||||
-------
|
||||
|
||||
Developed by [Omar Cornut](http://www.miracleworld.net) and every direct or indirect contributors to the GitHub. The early version of this library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com).
|
||||
Developed by [Omar Cornut](http://www.miracleworld.net) and every direct or indirect contributors to the GitHub. The early version of this library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com).
|
||||
|
||||
I first discovered the IMGUI paradigm at [Q-Games](http://www.q-games.com) where Atman had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating on it.
|
||||
I first discovered the IMGUI paradigm at [Q-Games](http://www.q-games.com) where Atman had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating on it.
|
||||
|
||||
Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license).
|
||||
|
||||
|
@ -25,7 +25,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- window: using SetWindowPos() inside Begin() and moving the window with the mouse reacts a very ugly glitch. We should just defer the SetWindowPos() call.
|
||||
- window: GetWindowSize() returns (0,0) when not calculated? (#1045)
|
||||
- window: investigate better auto-positioning for new windows.
|
||||
- window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate.
|
||||
- window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate.
|
||||
- window/child: the first draw command of a child window could be moved into the current draw command of the parent window (unless child+tooltip?).
|
||||
- window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero.
|
||||
- scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse)
|
||||
@ -60,7 +60,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- widgets: activate by identifier (trigger button, focus given id)
|
||||
- widgets: a way to represent "mixed" values, so e.g. all values replaced with **, including check-boxes, colors, etc. with support for multi-components widgets (e.g. SliderFloat3, make only "Y" mixed)
|
||||
|
||||
- input text: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now and super fragile.
|
||||
- input text: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now and super fragile.
|
||||
- input text: reorganize event handling, allow CharFilter to modify buffers, allow multiple events? (#541)
|
||||
- input text: expose CursorPos in char filter event (#816)
|
||||
- input text: access public fields via a non-callback API e.g. InputTextGetState("xxx") that may return NULL if not active.
|
||||
@ -93,19 +93,19 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding.
|
||||
- layout: BeginGroup() needs a border option. (~#1496)
|
||||
- layout: vertical alignment of mixed height items (e.g. buttons) within a same line (#1284)
|
||||
|
||||
|
||||
- columns: sizing policy (e.g. for each column: fixed size, %, fill, distribute default size among fills) (#513, #125)
|
||||
- columns: add a conditional parameter to SetColumnOffset() (#513, #125)
|
||||
- columns: headers. re-orderable. (#513, #125)
|
||||
- columns: optional sorting modifiers (up/down), sort list so sorting can be done multi-criteria. notify user when sort order changed.
|
||||
- columns: option to alternate background colors on odd/even scanlines.
|
||||
- columns: allow columns to recurse.
|
||||
- columns: allow a same columns set to be interrupted by e.g. CollapsingHeader and resume with columns in sync when moving them.
|
||||
- columns: option to alternate background colors on odd/even scanlines.
|
||||
- columns: allow columns to recurse.
|
||||
- columns: allow a same columns set to be interrupted by e.g. CollapsingHeader and resume with columns in sync when moving them.
|
||||
- columns: separator function or parameter that works within the column (currently Separator() bypass all columns) (#125)
|
||||
- columns: flag to add horizontal separator above/below?
|
||||
- columns/layout: setup minimum line height (equivalent of automatically calling AlignFirstTextHeightToWidgets)
|
||||
|
||||
!- color: the color conversion helpers/types are a mess and needs sorting out.
|
||||
!- color: the color conversion helpers/types are a mess and needs sorting out.
|
||||
- color: (api breaking) ImGui::ColorConvertXXX functions should be loose ImColorConvertXX to match imgui_internals.h
|
||||
|
||||
- plot: full featured plot/graph api w/ scrolling, zooming etc. all bell & whistle. why not!
|
||||
@ -122,7 +122,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- clipper: ability to run without knowing full count in advance.
|
||||
|
||||
- splitter/separator: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
|
||||
|
||||
|
||||
- dock: merge docking branch (#2109)
|
||||
- dock: A~ Unreal style document system (requires low-level controls of dockspace serialization fork/copy/delete). this is mostly working but the DockBuilderXXX api are not exposed/finished.
|
||||
- dock: B: when docking outer, perform size locking on neighbors nodes the same way we do it with splitters, so other nodes are not resized.
|
||||
@ -196,8 +196,8 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
|
||||
- tooltip: tooltip that doesn't fit in entire screen seems to lose their "last preferred direction" and may teleport when moving mouse.
|
||||
- tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
||||
- tooltip: tooltips with delay timers? or general timer policy? (instantaneous vs timed): IsItemHovered() with timer + implicit aabb-id for items with no ID. (#1485)
|
||||
|
||||
- tooltip: tooltips with delay timers? or general timer policy? (instantaneous vs timed): IsItemHovered() with timer + implicit aabb-id for items with no ID. (#1485)
|
||||
|
||||
- menus: calling BeginMenu() twice with a same name doesn't append as Begin() does for regular windows (#1207)
|
||||
- menus: menu bars inside modal windows are acting weird.
|
||||
- status-bar: add a per-window status bar helper similar to what menu-bar does.
|
||||
@ -205,7 +205,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- shortcuts,menus: global-style shortcut api e.g. "Save (CTRL+S)" -> explicit flag for recursing into closed menu
|
||||
- shortcuts: programmatically access shortcuts "Focus("&Save"))
|
||||
- menus: menu-bar: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin)
|
||||
- menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally either 0 either longer.
|
||||
- menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally either 0 either longer.
|
||||
|
||||
- text: selectable text (for copy) as a generic feature (ItemFlags?)
|
||||
- text: proper alignment options in imgui_internal.h
|
||||
@ -265,7 +265,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
!- font: better CalcTextSizeA() API, at least for simple use cases. current one is horrible (perhaps have simple vs extended versions).
|
||||
- font: a CalcTextHeight() helper could run faster than CalcTextSize().y
|
||||
- font: enforce monospace through ImFontConfig (for icons?) + create dual ImFont output from same input, reusing rasterized data but with different glyphs/AdvanceX
|
||||
- font: finish CustomRectRegister() to allow mapping Unicode codepoint to custom texture data
|
||||
- font: finish CustomRectRegister() to allow mapping Unicode codepoint to custom texture data
|
||||
- font: PushFontSize API (#1018)
|
||||
- font: MemoryTTF taking ownership confusing/not obvious, maybe default should be opposite?
|
||||
- font/demo: add tools to show glyphs used by a text blob, display U16 value, list missing glyphs.
|
||||
|
@ -8,7 +8,7 @@ https://discourse.dearimgui.org/c/getting-started
|
||||
|
||||
3. PLEASE MAKE SURE that you have: read the FAQ in imgui.cpp; explored the contents of ShowDemoWindow() including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the link provided in (1).
|
||||
|
||||
4. Delete points 1-4 and PLEASE FILL THE TEMPLATE BELOW before submitting your issue.
|
||||
4. Delete points 1-4 and PLEASE FILL THE TEMPLATE BELOW before submitting your issue.
|
||||
|
||||
----
|
||||
|
||||
@ -19,17 +19,17 @@ _(you may also go to Demo>About Window, and click "Config/Build Information" to
|
||||
Version: XXX
|
||||
Branch: XXX _(master/viewport/docking/etc.)_
|
||||
|
||||
**Back-end/Renderer/Compiler/OS**
|
||||
**Back-end/Renderer/Compiler/OS**
|
||||
|
||||
Back-ends: imgui_impl_XXX.cpp + imgui_impl_XXX.cpp _(or specify if using a custom engine/back-end)_
|
||||
Compiler: XXX _(if the question is related to building or platform specific features)_
|
||||
Operating System: XXX
|
||||
Operating System: XXX
|
||||
|
||||
**My Issue/Question:**
|
||||
**My Issue/Question:**
|
||||
|
||||
XXX _(please provide as much context as possible)_
|
||||
|
||||
**Screenshots/Video**
|
||||
**Screenshots/Video**
|
||||
|
||||
XXX _(you can drag files here)_
|
||||
|
||||
|
@ -26,7 +26,7 @@ This folder contains two things:
|
||||
- Example applications (standalone, ready-to-build) using the aforementioned bindings.
|
||||
They are the in the XXXX_example/ sub-folders.
|
||||
|
||||
You can find binaries of some of those example applications at:
|
||||
You can find binaries of some of those example applications at:
|
||||
http://www.miracleworld.net/imgui/binaries
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ You can find binaries of some of those example applications at:
|
||||
|
||||
- Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
||||
Please read the comments and instruction at the top of each file.
|
||||
|
||||
|
||||
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
|
||||
to your project and use them unmodified. Each imgui_impl_xxxx.cpp comes with its own individual
|
||||
ChangeLog at the top of the .cpp files, so if you want to update them later it will be easier to
|
||||
@ -44,13 +44,13 @@ You can find binaries of some of those example applications at:
|
||||
|
||||
- Dear ImGui has 0 to 1 frame of lag for most behaviors, at 60 FPS your experience should be pleasant.
|
||||
However, consider that OS mouse cursors are typically drawn through a specific hardware accelerated path
|
||||
and will feel smoother than common GPU rendered contents (including Dear ImGui windows).
|
||||
You may experiment with the io.MouseDrawCursor flag to request Dear ImGui to draw a mouse cursor itself,
|
||||
and will feel smoother than common GPU rendered contents (including Dear ImGui windows).
|
||||
You may experiment with the io.MouseDrawCursor flag to request Dear ImGui to draw a mouse cursor itself,
|
||||
to visualize the lag between a hardware cursor and a software cursor. However, rendering a mouse cursor
|
||||
at 60 FPS will feel slow. It might be beneficial to the user experience to switch to a software rendered
|
||||
cursor only when an interactive drag is in progress.
|
||||
cursor only when an interactive drag is in progress.
|
||||
Note that some setup or GPU drivers are likely to be causing extra lag depending on their settings.
|
||||
If you feel that dragging windows feels laggy and you are not sure who to blame: try to build an
|
||||
If you feel that dragging windows feels laggy and you are not sure who to blame: try to build an
|
||||
application drawing a shape directly under the mouse cursor.
|
||||
|
||||
|
||||
@ -72,17 +72,17 @@ Most the example bindings are split in 2 parts:
|
||||
- Some bindings for higher level frameworks carry both "Platform" and "Renderer" parts in one file.
|
||||
This is the case for Allegro 5 (imgui_impl_allegro5.cpp), Marmalade (imgui_impl_marmalade5.cpp).
|
||||
|
||||
- If you use your own engine, you may decide to use some of existing bindings and/or rewrite some using
|
||||
- If you use your own engine, you may decide to use some of existing bindings and/or rewrite some using
|
||||
your own API. As a recommendation, if you are new to Dear ImGui, try using the existing binding as-is
|
||||
first, before moving on to rewrite some of the code. Although it is tempting to rewrite both of the
|
||||
first, before moving on to rewrite some of the code. Although it is tempting to rewrite both of the
|
||||
imgui_impl_xxxx files to fit under your coding style, consider that it is not necessary!
|
||||
In fact, if you are new to Dear ImGui, rewriting them will almost always be harder.
|
||||
|
||||
Example: your engine is built over Windows + DirectX11 but you have your own high-level rendering
|
||||
Example: your engine is built over Windows + DirectX11 but you have your own high-level rendering
|
||||
system layered over DirectX11.
|
||||
Suggestion: step 1: try using imgui_impl_win32.cpp + imgui_impl_dx11.cpp first.
|
||||
Once this work, _if_ you want you can replace the imgui_impl_dx11.cpp code with a custom renderer
|
||||
using your own functions, etc.
|
||||
Suggestion: step 1: try using imgui_impl_win32.cpp + imgui_impl_dx11.cpp first.
|
||||
Once this work, _if_ you want you can replace the imgui_impl_dx11.cpp code with a custom renderer
|
||||
using your own functions, etc.
|
||||
Please consider using the bindings to the lower-level platform/graphics API as-is.
|
||||
|
||||
Example: your engine is multi-platform (consoles, phones, etc.), you have high-level systems everywhere.
|
||||
@ -90,17 +90,17 @@ Most the example bindings are split in 2 parts:
|
||||
This is counter-intuitive, but this will get you running faster! Once you better understand how imgui
|
||||
works and is bound, you can rewrite the code using your own systems.
|
||||
|
||||
- From Dear ImGui 1.XX we added an (optional) feature called "viewport" which allows imgui windows to be
|
||||
seamlessly detached from the main application window. This is achieved using an extra layer to the
|
||||
platform and renderer bindings, which allows imgui to communicate platform-specific requests such as
|
||||
"create an additional OS window", "create a render context", "get the OS position of this window" etc.
|
||||
When using this feature, the coupling with your OS/renderer becomes much tighter than a regular imgui
|
||||
- From Dear ImGui 1.XX we added an (optional) feature called "viewport" which allows imgui windows to be
|
||||
seamlessly detached from the main application window. This is achieved using an extra layer to the
|
||||
platform and renderer bindings, which allows imgui to communicate platform-specific requests such as
|
||||
"create an additional OS window", "create a render context", "get the OS position of this window" etc.
|
||||
When using this feature, the coupling with your OS/renderer becomes much tighter than a regular imgui
|
||||
integration. It is also much more complicated and require more work to integrate correctly.
|
||||
If you are new to imgui and you are trying to integrate it into your application, first try to ignore
|
||||
everything related to Viewport and Platform Windows. You'll be able to come back to it later!
|
||||
Note that if you decide to use unmodified imgui_impl_xxxx.cpp files, you will automatically benefit
|
||||
from improvements and fixes related to viewports and platform windows without extra work on your side.
|
||||
See 'ImGuiPlatformIO' for details.
|
||||
See 'ImGuiPlatformIO' for details.
|
||||
|
||||
|
||||
List of Platforms Bindings in this repository:
|
||||
@ -132,7 +132,7 @@ Third-party framework, graphics API and languages bindings are listed at:
|
||||
https://github.com/ocornut/imgui/wiki/Bindings
|
||||
|
||||
Languages: C, C#, ChaiScript, D, Go, Haxe, Java, Lua, Odin, Pascal, PureBasic, Python, Rust, Swift...
|
||||
Frameworks: Cinder, Cocoa (OSX), Cocos2d-x, Emscripten, SFML, GML/GameMaker Studio, Irrlicht, Ogre,
|
||||
Frameworks: Cinder, Cocoa (OSX), Cocos2d-x, Emscripten, SFML, GML/GameMaker Studio, Irrlicht, Ogre,
|
||||
OpenSceneGraph, openFrameworks, LOVE, NanoRT, Nim Game Lib, Qt3d, SFML, Unreal Engine 4...
|
||||
Miscellaneous: Software Renderer, RemoteImgui, etc.
|
||||
|
||||
@ -142,12 +142,12 @@ Third-party framework, graphics API and languages bindings are listed at:
|
||||
---------------------------------------
|
||||
|
||||
Building:
|
||||
Unfortunately in 2018 it is still tedious to create and maintain portable build files using external
|
||||
libraries (the kind we're using here to create a window and render 3D triangles) without relying on
|
||||
Unfortunately in 2018 it is still tedious to create and maintain portable build files using external
|
||||
libraries (the kind we're using here to create a window and render 3D triangles) without relying on
|
||||
third party software. For most examples here I choose to provide:
|
||||
- Makefiles for Linux/OSX
|
||||
- Batch files for Visual Studio 2008+
|
||||
- A .sln project file for Visual Studio 2010+
|
||||
- A .sln project file for Visual Studio 2010+
|
||||
- Xcode project files for the Apple examples
|
||||
Please let me know if they don't work with your setup!
|
||||
You can probably just import the imgui_impl_xxx.cpp/.h files into your own codebase or compile those
|
||||
@ -157,7 +157,7 @@ Building:
|
||||
example_win32_directx9/
|
||||
DirectX9 example, Windows only.
|
||||
= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx9.cpp
|
||||
|
||||
|
||||
example_win32_directx10/
|
||||
DirectX10 example, Windows only.
|
||||
= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx10.cpp
|
||||
@ -165,7 +165,7 @@ example_win32_directx10/
|
||||
example_win32_directx11/
|
||||
DirectX11 example, Windows only.
|
||||
= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx11.cpp
|
||||
|
||||
|
||||
example_win32_directx12/
|
||||
DirectX12 example, Windows only.
|
||||
= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp
|
||||
@ -195,9 +195,9 @@ example_glfw_opengl2/
|
||||
example_glfw_opengl3/
|
||||
GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (programmable pipeline).
|
||||
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
|
||||
This uses more modern OpenGL calls and custom shaders.
|
||||
This uses more modern OpenGL calls and custom shaders.
|
||||
Prefer using that if you are using modern OpenGL in your application (anything with shaders).
|
||||
|
||||
|
||||
example_glfw_vulkan/
|
||||
GLFW (Win32, Mac, Linux) + Vulkan example.
|
||||
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
|
||||
@ -211,12 +211,12 @@ example_sdl_opengl2/
|
||||
This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter.
|
||||
If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to
|
||||
make things more complicated, will require your code to reset many OpenGL attributes to their initial
|
||||
state, and might confuse your GPU driver. One star, not recommended.
|
||||
state, and might confuse your GPU driver. One star, not recommended.
|
||||
|
||||
example_sdl_opengl3/
|
||||
SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example.
|
||||
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
|
||||
This uses more modern OpenGL calls and custom shaders.
|
||||
This uses more modern OpenGL calls and custom shaders.
|
||||
Prefer using that if you are using modern OpenGL in your application (anything with shaders).
|
||||
|
||||
example_sdl_vulkan/
|
||||
|
206
imgui.cpp
206
imgui.cpp
@ -714,8 +714,8 @@ CODE
|
||||
you to animate labels. For example you may want to include varying information in a window title bar,
|
||||
but windows are uniquely identified by their ID. Use "###" to pass a label that isn't part of ID:
|
||||
|
||||
Button("Hello###ID"); // Label = "Hello", ID = hash of (..., "ID")
|
||||
Button("World###ID"); // Label = "World", ID = hash of (..., "ID") // Same as above, even though the label looks different
|
||||
Button("Hello###ID"); // Label = "Hello", ID = hash of (..., "###ID")
|
||||
Button("World###ID"); // Label = "World", ID = hash of (..., "###ID") // Same as above, even though the label looks different
|
||||
|
||||
sprintf(buf, "My game (%f FPS)###MyGame", fps);
|
||||
Begin(buf); // Variable title, ID = hash of "MyGame"
|
||||
@ -1049,7 +1049,7 @@ static void UpdateManualResize(ImGuiWindow* window, const ImVec2& si
|
||||
static void EndFrameDrawDimmedBackgrounds();
|
||||
|
||||
// Viewports
|
||||
const ImGuiID IMGUI_VIEWPORT_DEFAULT_ID = 0x11111111; // Using an arbitrary constant instead of e.g. ImHash("ViewportDefault", 0); so it's easier to spot in the debugger. The exact value doesn't matter.
|
||||
const ImGuiID IMGUI_VIEWPORT_DEFAULT_ID = 0x11111111; // Using an arbitrary constant instead of e.g. ImHashStr("ViewportDefault", 0); so it's easier to spot in the debugger. The exact value doesn't matter.
|
||||
static ImGuiViewportP* AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& platform_pos, const ImVec2& size, ImGuiViewportFlags flags);
|
||||
static void UpdateViewportsNewFrame();
|
||||
static void UpdateViewportsEndFrame();
|
||||
@ -1477,45 +1477,69 @@ int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args)
|
||||
}
|
||||
#endif // #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
|
||||
|
||||
// Pass data_size == 0 for zero-terminated strings, data_size > 0 for non-string data.
|
||||
// Pay attention that data_size==0 will yield different results than passing strlen(data) because the zero-terminated codepath handles ###.
|
||||
// This should technically be split into two distinct functions (ImHashData/ImHashStr), perhaps once we remove the silly static variable.
|
||||
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
|
||||
ImU32 ImHash(const void* data, int data_size, ImU32 seed)
|
||||
// CRC32 needs a 1KB lookup table (not cache friendly)
|
||||
// Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily:
|
||||
// - avoid an unnecessary branch/memory tap, - keep the ImHashXXX functions usable by static constructors, - make it thread-safe.
|
||||
static const ImU32 GCrc32LookupTable[256] =
|
||||
{
|
||||
static ImU32 crc32_lut[256] = { 0 };
|
||||
if (!crc32_lut[1])
|
||||
{
|
||||
const ImU32 polynomial = 0xEDB88320;
|
||||
for (ImU32 i = 0; i < 256; i++)
|
||||
{
|
||||
ImU32 crc = i;
|
||||
for (ImU32 j = 0; j < 8; j++)
|
||||
crc = (crc >> 1) ^ (ImU32(-int(crc & 1)) & polynomial);
|
||||
crc32_lut[i] = crc;
|
||||
}
|
||||
}
|
||||
0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,
|
||||
0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5,
|
||||
0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C,0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59,
|
||||
0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D,
|
||||
0x76DC4190,0x01DB7106,0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,0x91646C97,0xE6635C01,
|
||||
0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950,0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65,
|
||||
0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9,
|
||||
0x5005713C,0x270241AA,0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,0xB7BD5C3B,0xC0BA6CAD,
|
||||
0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84,0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1,
|
||||
0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5,
|
||||
0xD6D6A3E8,0xA1D1937E,0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,0x316E8EEF,0x4669BE79,
|
||||
0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28,0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D,
|
||||
0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21,
|
||||
0x86D3D2D4,0xF1D4E242,0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,0x616BFFD3,0x166CCF45,
|
||||
0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC,0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9,
|
||||
0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D,
|
||||
};
|
||||
|
||||
// Known size hash
|
||||
// It is ok to call ImHashData on a string with known length but the ### operator won't be supported.
|
||||
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
|
||||
ImU32 ImHashData(const void* data_p, size_t data_size, ImU32 seed)
|
||||
{
|
||||
ImU32 crc = ~seed;
|
||||
const unsigned char* data = (const unsigned char*)data_p;
|
||||
const ImU32* crc32_lut = GCrc32LookupTable;
|
||||
while (data_size-- != 0)
|
||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++];
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
// Zero-terminated string hash, with support for ### to reset back to seed value
|
||||
// We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed.
|
||||
// Because this syntax is rarely used we are optimizing for the common case.
|
||||
// - If we reach ### in the string we discard the hash so far and reset to the seed.
|
||||
// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build)
|
||||
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
|
||||
ImU32 ImHashStr(const char* data, size_t data_size, ImU32 seed)
|
||||
{
|
||||
seed = ~seed;
|
||||
ImU32 crc = seed;
|
||||
const unsigned char* current = (const unsigned char*)data;
|
||||
|
||||
if (data_size > 0)
|
||||
const unsigned char* src = (const unsigned char*)data;
|
||||
const ImU32* crc32_lut = GCrc32LookupTable;
|
||||
if (data_size != 0)
|
||||
{
|
||||
// Known size
|
||||
while (data_size--)
|
||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *current++];
|
||||
while (data_size-- != 0)
|
||||
{
|
||||
unsigned char c = *src++;
|
||||
if (c == '#' && src[0] == '#' && src[1] == '#')
|
||||
crc = seed;
|
||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Zero-terminated string
|
||||
while (unsigned char c = *current++)
|
||||
while (unsigned char c = *src++)
|
||||
{
|
||||
// We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed.
|
||||
// Because this syntax is rarely used we are optimizing for the common case.
|
||||
// - If we reach ### in the string we discard the hash so far and reset to the seed.
|
||||
// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller.
|
||||
if (c == '#' && current[0] == '#' && current[1] == '#')
|
||||
if (c == '#' && src[0] == '#' && src[1] == '#')
|
||||
crc = seed;
|
||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
||||
}
|
||||
@ -2141,6 +2165,32 @@ bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
|
||||
|
||||
char ImGuiTextBuffer::EmptyString[1] = { 0 };
|
||||
|
||||
void ImGuiTextBuffer::append(const char* str, const char* str_end)
|
||||
{
|
||||
int len = str_end ? (int)(str_end - str) : (int)strlen(str);
|
||||
|
||||
// Add zero-terminator the first time
|
||||
const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
|
||||
const int needed_sz = write_off + len;
|
||||
if (write_off + len >= Buf.Capacity)
|
||||
{
|
||||
int new_capacity = Buf.Capacity * 2;
|
||||
Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity);
|
||||
}
|
||||
|
||||
Buf.resize(needed_sz);
|
||||
memcpy(&Buf[write_off - 1], str, (size_t)len);
|
||||
Buf[write_off - 1 + len] = 0;
|
||||
}
|
||||
|
||||
void ImGuiTextBuffer::appendf(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
appendfv(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// Helper: Text buffer for logging/accumulating text
|
||||
void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
|
||||
{
|
||||
@ -2159,8 +2209,8 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
|
||||
const int needed_sz = write_off + len;
|
||||
if (write_off + len >= Buf.Capacity)
|
||||
{
|
||||
int double_capacity = Buf.Capacity * 2;
|
||||
Buf.reserve(needed_sz > double_capacity ? needed_sz : double_capacity);
|
||||
int new_capacity = Buf.Capacity * 2;
|
||||
Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity);
|
||||
}
|
||||
|
||||
Buf.resize(needed_sz);
|
||||
@ -2168,14 +2218,6 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
|
||||
va_end(args_copy);
|
||||
}
|
||||
|
||||
void ImGuiTextBuffer::appendf(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
appendfv(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] ImGuiListClipper
|
||||
// This is currently not as flexible/powerful as it should be, needs some rework (see TODO)
|
||||
@ -2494,7 +2536,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
|
||||
: DrawListInst(&context->DrawListSharedData)
|
||||
{
|
||||
Name = ImStrdup(name);
|
||||
ID = ImHash(name, 0);
|
||||
ID = ImHashStr(name, 0);
|
||||
IDStack.push_back(ID);
|
||||
Flags = FlagsPreviousFrame = ImGuiWindowFlags_None;
|
||||
Viewport = NULL;
|
||||
@ -2575,7 +2617,7 @@ ImGuiWindow::~ImGuiWindow()
|
||||
ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
ImGuiID id = ImHash(str, str_end ? (int)(str_end - str) : 0, seed);
|
||||
ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed);
|
||||
ImGui::KeepAliveID(id);
|
||||
return id;
|
||||
}
|
||||
@ -2583,7 +2625,7 @@ ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
|
||||
ImGuiID ImGuiWindow::GetID(const void* ptr)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
ImGuiID id = ImHash(&ptr, sizeof(void*), seed);
|
||||
ImGuiID id = ImHashData(&ptr, sizeof(void*), seed);
|
||||
ImGui::KeepAliveID(id);
|
||||
return id;
|
||||
}
|
||||
@ -2591,13 +2633,13 @@ ImGuiID ImGuiWindow::GetID(const void* ptr)
|
||||
ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
return ImHash(str, str_end ? (int)(str_end - str) : 0, seed);
|
||||
return ImHashStr(str, str_end ? (str_end - str) : 0, seed);
|
||||
}
|
||||
|
||||
ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
return ImHash(&ptr, sizeof(void*), seed);
|
||||
return ImHashData(&ptr, sizeof(void*), seed);
|
||||
}
|
||||
|
||||
// This is only used in rare/specific situations to manufacture an ID out of nowhere.
|
||||
@ -2605,7 +2647,7 @@ ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
const int r_rel[4] = { (int)(r_abs.Min.x - Pos.x), (int)(r_abs.Min.y - Pos.y), (int)(r_abs.Max.x - Pos.x), (int)(r_abs.Max.y - Pos.y) };
|
||||
ImGuiID id = ImHash(&r_rel, sizeof(r_rel), seed);
|
||||
ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed);
|
||||
ImGui::KeepAliveID(id);
|
||||
return id;
|
||||
}
|
||||
@ -3671,7 +3713,7 @@ void ImGui::Initialize(ImGuiContext* context)
|
||||
// Add .ini handle for ImGuiWindow type
|
||||
ImGuiSettingsHandler ini_handler;
|
||||
ini_handler.TypeName = "Window";
|
||||
ini_handler.TypeHash = ImHash("Window", 0, 0);
|
||||
ini_handler.TypeHash = ImHashStr("Window", 0);
|
||||
ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen;
|
||||
ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine;
|
||||
ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
|
||||
@ -3969,12 +4011,13 @@ void ImGui::EndFrame()
|
||||
IM_ASSERT(g.FrameScopeActive && "Forgot to call ImGui::NewFrame()?");
|
||||
|
||||
// Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
|
||||
if (g.PlatformIO.Platform_SetImeInputPos && ImLengthSqr(g.PlatformImePos - g.PlatformImeLastPos) > 0.0001f && g.PlatformImePosViewport && g.PlatformImePosViewport->PlatformWindowCreated)
|
||||
{
|
||||
g.PlatformIO.Platform_SetImeInputPos(g.PlatformImePosViewport, g.PlatformImePos);
|
||||
g.PlatformImeLastPos = g.PlatformImePos;
|
||||
g.PlatformImePosViewport = NULL;
|
||||
}
|
||||
if (g.PlatformIO.Platform_SetImeInputPos && (g.PlatformImeLastPos.x == FLT_MAX || ImLengthSqr(g.PlatformImePos - g.PlatformImeLastPos) > 0.0001f))
|
||||
if (g.PlatformImePosViewport && g.PlatformImePosViewport->PlatformWindowCreated)
|
||||
{
|
||||
g.PlatformIO.Platform_SetImeInputPos(g.PlatformImePosViewport, g.PlatformImePos);
|
||||
g.PlatformImeLastPos = g.PlatformImePos;
|
||||
g.PlatformImePosViewport = NULL;
|
||||
}
|
||||
|
||||
// Report when there is a mismatch of Begin/BeginChild vs End/EndChild calls. Important: Remember that the Begin/BeginChild API requires you
|
||||
// to always call End/EndChild even if Begin/BeginChild returns false! (this is unfortunately inconsistent with most other Begin* API).
|
||||
@ -4701,7 +4744,7 @@ ImGuiWindow* ImGui::FindWindowByID(ImGuiID id)
|
||||
|
||||
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
||||
{
|
||||
ImGuiID id = ImHash(name, 0);
|
||||
ImGuiID id = ImHashStr(name, 0);
|
||||
return FindWindowByID(id);
|
||||
}
|
||||
|
||||
@ -5403,10 +5446,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
||||
window->Pos = FindBestWindowPosForPopup(window);
|
||||
|
||||
// Late create viewport if we don't fit within our current host viewport.
|
||||
if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned && !window->Viewport->PlatformWindowMinimized)
|
||||
if (!window->Viewport->GetRect().Contains(window->Rect()))
|
||||
{
|
||||
// Late create viewport, based on the assumption that with our calculations, the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport)
|
||||
// This is based on the assumption that the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport)
|
||||
//ImGuiViewport* old_viewport = window->Viewport;
|
||||
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing);
|
||||
|
||||
@ -6959,71 +7003,74 @@ void ImGui::SetItemDefaultFocus()
|
||||
|
||||
void ImGui::SetStateStorage(ImGuiStorage* tree)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
window->DC.StateStorage = tree ? tree : &window->StateStorage;
|
||||
}
|
||||
|
||||
ImGuiStorage* ImGui::GetStateStorage()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->DC.StateStorage;
|
||||
}
|
||||
|
||||
void ImGui::PushID(const char* str_id)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
window->IDStack.push_back(window->GetIDNoKeepAlive(str_id));
|
||||
}
|
||||
|
||||
void ImGui::PushID(const char* str_id_begin, const char* str_id_end)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
window->IDStack.push_back(window->GetIDNoKeepAlive(str_id_begin, str_id_end));
|
||||
}
|
||||
|
||||
void ImGui::PushID(const void* ptr_id)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
window->IDStack.push_back(window->GetIDNoKeepAlive(ptr_id));
|
||||
}
|
||||
|
||||
void ImGui::PushID(int int_id)
|
||||
{
|
||||
const void* ptr_id = (void*)(intptr_t)int_id;
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
window->IDStack.push_back(window->GetIDNoKeepAlive(ptr_id));
|
||||
}
|
||||
|
||||
void ImGui::PopID()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
window->IDStack.pop_back();
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetID(const char* str_id)
|
||||
{
|
||||
return GImGui->CurrentWindow->GetID(str_id);
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->GetID(str_id);
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetID(const char* str_id_begin, const char* str_id_end)
|
||||
{
|
||||
return GImGui->CurrentWindow->GetID(str_id_begin, str_id_end);
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->GetID(str_id_begin, str_id_end);
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetID(const void* ptr_id)
|
||||
{
|
||||
return GImGui->CurrentWindow->GetID(ptr_id);
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->GetID(ptr_id);
|
||||
}
|
||||
|
||||
bool ImGui::IsRectVisible(const ImVec2& size)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;;
|
||||
return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size));
|
||||
}
|
||||
|
||||
bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;;
|
||||
return window->ClipRect.Overlaps(ImRect(rect_min, rect_max));
|
||||
}
|
||||
|
||||
@ -7645,6 +7692,7 @@ void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* view
|
||||
if (g.CurrentViewport == viewport)
|
||||
return;
|
||||
g.CurrentViewport = viewport;
|
||||
//IMGUI_DEBUG_LOG("SetCurrentViewport changed '%s' 0x%08X\n", current_window ? current_window->Name : NULL, viewport ? viewport->ID : 0);
|
||||
|
||||
// Notify platform layer of viewport changes
|
||||
// FIXME-DPI: This is only currently used for experimenting with handling of multiple DPI
|
||||
@ -8158,7 +8206,7 @@ void ImGui::UpdatePlatformWindows()
|
||||
{
|
||||
const char* title_begin = window_for_title->Name;
|
||||
char* title_end = (char*)(intptr_t)FindRenderedTextEnd(title_begin);
|
||||
const ImGuiID title_hash = ImHash(title_begin, (int)(title_end - title_begin));
|
||||
const ImGuiID title_hash = ImHashStr(title_begin, title_end - title_begin);
|
||||
if (viewport->LastNameHash != title_hash)
|
||||
{
|
||||
char title_end_backup_c = *title_end;
|
||||
@ -9748,7 +9796,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
||||
else
|
||||
{
|
||||
window = NULL;
|
||||
source_id = ImHash("#SourceExtern", 0);
|
||||
source_id = ImHashStr("#SourceExtern", 0);
|
||||
source_drag_active = true;
|
||||
}
|
||||
|
||||
@ -10137,7 +10185,7 @@ void ImGui::DockContextInitialize(ImGuiContext* ctx)
|
||||
// Add .ini handle for persistent docking data
|
||||
ImGuiSettingsHandler ini_handler;
|
||||
ini_handler.TypeName = "Docking";
|
||||
ini_handler.TypeHash = ImHash("Docking", 0, 0);
|
||||
ini_handler.TypeHash = ImHashStr("Docking", 0, 0);
|
||||
ini_handler.ReadOpenFn = DockSettingsHandler_ReadOpen;
|
||||
ini_handler.ReadLineFn = DockSettingsHandler_ReadLine;
|
||||
ini_handler.WriteAllFn = DockSettingsHandler_WriteAll;
|
||||
@ -12238,7 +12286,7 @@ ImGuiID ImGui::DockSpaceOverViewport(ImGuiViewport* viewport, ImGuiDockNodeFlags
|
||||
|
||||
void ImGui::DockBuilderDockWindow(const char* window_name, ImGuiID node_id)
|
||||
{
|
||||
ImGuiID window_id = ImHash(window_name, 0);
|
||||
ImGuiID window_id = ImHashStr(window_name, 0);
|
||||
if (ImGuiWindow* window = FindWindowByID(window_id))
|
||||
{
|
||||
// Apply to created window
|
||||
@ -12503,7 +12551,7 @@ void ImGui::DockBuilderCopyDockspace(ImGuiID src_dockspace_id, ImGuiID dst_docks
|
||||
{
|
||||
const char* src_window_name = (*in_window_remap_pairs)[remap_window_n];
|
||||
const char* dst_window_name = (*in_window_remap_pairs)[remap_window_n + 1];
|
||||
ImGuiID src_window_id = ImHash(src_window_name, 0);
|
||||
ImGuiID src_window_id = ImHashStr(src_window_name, 0);
|
||||
src_windows.push_back(src_window_id);
|
||||
|
||||
// Search in the remapping tables
|
||||
@ -13165,7 +13213,7 @@ ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name)
|
||||
g.SettingsWindows.push_back(ImGuiWindowSettings());
|
||||
ImGuiWindowSettings* settings = &g.SettingsWindows.back();
|
||||
settings->Name = ImStrdup(name);
|
||||
settings->ID = ImHash(name, 0);
|
||||
settings->ID = ImHashStr(name, 0);
|
||||
return settings;
|
||||
}
|
||||
|
||||
@ -13180,7 +13228,7 @@ ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id)
|
||||
|
||||
ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name)
|
||||
{
|
||||
if (ImGuiWindowSettings* settings = FindWindowSettings(ImHash(name, 0)))
|
||||
if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name, 0)))
|
||||
return settings;
|
||||
return CreateNewWindowSettings(name);
|
||||
}
|
||||
@ -13198,7 +13246,7 @@ void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
||||
ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiID type_hash = ImHash(type_name, 0, 0);
|
||||
const ImGuiID type_hash = ImHashStr(type_name, 0);
|
||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
||||
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
|
||||
return &g.SettingsHandlers[handler_n];
|
||||
@ -13303,7 +13351,7 @@ const char* ImGui::SaveIniSettingsToMemory(size_t* out_size)
|
||||
|
||||
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
||||
{
|
||||
ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHash(name, 0));
|
||||
ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name, 0));
|
||||
if (!settings)
|
||||
settings = ImGui::CreateNewWindowSettings(name);
|
||||
return (void*)settings;
|
||||
|
10
imgui.h
10
imgui.h
@ -364,13 +364,14 @@ namespace ImGui
|
||||
// ID stack/scopes
|
||||
// - Read the FAQ for more details about how ID are handled in dear imgui. If you are creating widgets in a loop you most
|
||||
// likely want to push a unique identifier (e.g. object pointer, loop index) to uniquely differentiate them.
|
||||
// - The resulting ID are hashes of the entire stack.
|
||||
// - You can also use the "Label##foobar" syntax within widget label to distinguish them from each others.
|
||||
// - In this header file we use the "label"/"name" terminology to denote a string that will be displayed and used as an ID,
|
||||
// whereas "str_id" denote a string that is only used as an ID and not normally displayed.
|
||||
IMGUI_API void PushID(const char* str_id); // push string identifier into the ID stack. IDs == hash of the entire stack!
|
||||
IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end);
|
||||
IMGUI_API void PushID(const void* ptr_id); // push pointer into the ID stack.
|
||||
IMGUI_API void PushID(int int_id); // push integer into the ID stack.
|
||||
IMGUI_API void PushID(const char* str_id); // push string into the ID stack (will hash string).
|
||||
IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); // push string into the ID stack (will hash string).
|
||||
IMGUI_API void PushID(const void* ptr_id); // push pointer into the ID stack (will hash pointer).
|
||||
IMGUI_API void PushID(int int_id); // push integer into the ID stack (will hash integer).
|
||||
IMGUI_API void PopID(); // pop from the ID stack.
|
||||
IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself
|
||||
IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end);
|
||||
@ -1675,6 +1676,7 @@ struct ImGuiTextBuffer
|
||||
void clear() { Buf.clear(); }
|
||||
void reserve(int capacity) { Buf.reserve(capacity); }
|
||||
const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; }
|
||||
IMGUI_API void append(const char* str, const char* str_end = NULL);
|
||||
IMGUI_API void appendf(const char* fmt, ...) IM_FMTARGS(2);
|
||||
IMGUI_API void appendfv(const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
};
|
||||
|
@ -154,7 +154,8 @@ IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const
|
||||
IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
|
||||
|
||||
// Helpers: Misc
|
||||
IMGUI_API ImU32 ImHash(const void* data, int data_size, ImU32 seed = 0); // Pass data_size==0 for zero-terminated strings
|
||||
IMGUI_API ImU32 ImHashData(const void* data, size_t data_size, ImU32 seed = 0);
|
||||
IMGUI_API ImU32 ImHashStr(const char* data, size_t data_size, ImU32 seed = 0);
|
||||
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size = NULL, int padding_bytes = 0);
|
||||
IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
|
||||
static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
|
||||
@ -162,6 +163,9 @@ static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c =
|
||||
static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
|
||||
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
|
||||
#define ImQsort qsort
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
static inline ImU32 ImHash(const void* data, int size, ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68]
|
||||
#endif
|
||||
|
||||
// Helpers: Geometry
|
||||
IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
|
||||
@ -616,7 +620,7 @@ struct ImGuiWindowSettings
|
||||
struct ImGuiSettingsHandler
|
||||
{
|
||||
const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']'
|
||||
ImGuiID TypeHash; // == ImHash(TypeName, 0, 0)
|
||||
ImGuiID TypeHash; // == ImHashStr(TypeName, 0, 0)
|
||||
void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
|
||||
void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
|
||||
void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf'
|
||||
@ -1242,7 +1246,7 @@ struct IMGUI_API ImGuiWindowTempData
|
||||
struct IMGUI_API ImGuiWindow
|
||||
{
|
||||
char* Name;
|
||||
ImGuiID ID; // == ImHash(Name)
|
||||
ImGuiID ID; // == ImHashStr(Name)
|
||||
ImGuiWindowFlags Flags, FlagsPreviousFrame; // See enum ImGuiWindowFlags_
|
||||
ImGuiWindowClass WindowClass; // Advanced users only. Set with SetNextWindowClass()
|
||||
ImGuiViewportP* Viewport; // Always set in Begin(), only inactive windows may have a NULL value here
|
||||
|
@ -6141,7 +6141,7 @@ static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label)
|
||||
{
|
||||
if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
|
||||
{
|
||||
ImGuiID id = ImHash(label, 0);
|
||||
ImGuiID id = ImHashStr(label, 0);
|
||||
KeepAliveID(id);
|
||||
return id;
|
||||
}
|
||||
|
@ -13,6 +13,6 @@ misc/freetype/
|
||||
Benefit from better FreeType rasterization, in particular for small fonts.
|
||||
|
||||
misc/natvis/
|
||||
Natvis file to describe dear imgui types in the Visual Studio debugger.
|
||||
With this, types like ImVector<> will be displayed nicely in the debugger.
|
||||
Natvis file to describe dear imgui types in the Visual Studio debugger.
|
||||
With this, types like ImVector<> will be displayed nicely in the debugger.
|
||||
You can include this file a Visual Studio project file, or install it in Visual Studio folder.
|
||||
|
@ -3,7 +3,7 @@ imgui_stdlib.h + imgui_stdlib.cpp
|
||||
InputText() wrappers for C++ standard library (STL) type: std::string.
|
||||
This is also an example of how you may wrap your own similar types.
|
||||
|
||||
imgui_scoped.h
|
||||
imgui_scoped.h
|
||||
[Experimental, not currently in main repository]
|
||||
Additional header file with some RAII-style wrappers for common ImGui functions.
|
||||
Try by merging: https://github.com/ocornut/imgui/pull/2197
|
||||
|
@ -3,7 +3,7 @@ The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' (by Tristan Grimmer),
|
||||
a 13 pixels high, pixel-perfect font used by default.
|
||||
We embed it font in source code so you can use Dear ImGui without any file system access.
|
||||
|
||||
You may also load external .TTF/.OTF files.
|
||||
You may also load external .TTF/.OTF files.
|
||||
The files in this folder are suggested fonts, provided as a convenience.
|
||||
(Note: .OTF support in imstb_truetype.h currently doesn't appear to load every font)
|
||||
|
||||
@ -45,9 +45,9 @@ If you have other loading/merging/adding fonts, you can post on the Dear ImGui "
|
||||
USING ICONS
|
||||
---------------------------------------
|
||||
|
||||
Using an icon font (such as FontAwesome: http://fontawesome.io or OpenFontIcons. https://github.com/traverseda/OpenFontIcons)
|
||||
Using an icon font (such as FontAwesome: http://fontawesome.io or OpenFontIcons. https://github.com/traverseda/OpenFontIcons)
|
||||
is an easy and practical way to use icons in your Dear ImGui application.
|
||||
A common pattern is to merge the icon font within your main font, so you can embed icons directly from your strings without
|
||||
A common pattern is to merge the icon font within your main font, so you can embed icons directly from your strings without
|
||||
having to change fonts back and forth.
|
||||
|
||||
To refer to the icon UTF-8 codepoints from your C++ code, you may use those headers files created by Juliette Foucaut:
|
||||
@ -77,8 +77,8 @@ Example Usage:
|
||||
ImGui::Text("%s among %d items", ICON_FA_SEARCH, count);
|
||||
ImGui::Button(ICON_FA_SEARCH " Search");
|
||||
// C string _literals_ can be concatenated at compilation time, e.g. "hello" " world"
|
||||
// ICON_FA_SEARCH is defined as a string literal so this is the same as "A" "B" becoming "AB"
|
||||
|
||||
// ICON_FA_SEARCH is defined as a string literal so this is the same as "A" "B" becoming "AB"
|
||||
|
||||
See Links below for other icons fonts and related tools.
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ Load .TTF/.OTF file with:
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImFont* font1 = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
||||
ImFont* font2 = io.Fonts->AddFontFromFileTTF("anotherfont.otf", size_pixels);
|
||||
|
||||
|
||||
// Select font at runtime
|
||||
ImGui::Text("Hello"); // use the default font (which is the first loaded font)
|
||||
ImGui::PushFont(font2);
|
||||
@ -113,13 +113,13 @@ For advanced options create a ImFontConfig structure and pass it to the AddFont
|
||||
|
||||
If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API.
|
||||
The typical result of failing to upload a texture is if every glyphs appears as white rectangles.
|
||||
In particular, using a large range such as GetGlyphRangesChineseSimplifiedCommon() is not recommended unless you
|
||||
In particular, using a large range such as GetGlyphRangesChineseSimplifiedCommon() is not recommended unless you
|
||||
set OversampleH/OversampleV to 1 and use a small font size.
|
||||
Mind the fact that some graphics drivers have texture size limitation.
|
||||
If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours.
|
||||
Some solutions:
|
||||
|
||||
- 1) Reduce glyphs ranges by calculating them from source localization data.
|
||||
- 1) Reduce glyphs ranges by calculating them from source localization data.
|
||||
You can use ImFontGlyphRangesBuilder for this purpose, this will be the biggest win!
|
||||
- 2) You may reduce oversampling, e.g. config.OversampleH = config.OversampleV = 1, this will largely reduce your texture size.
|
||||
- 3) Set io.Fonts.TexDesiredWidth to specify a texture width to minimize texture height (see comment in ImFontAtlas::Build function).
|
||||
@ -144,14 +144,14 @@ Add a fourth parameter to bake specific font ranges only:
|
||||
|
||||
// Basic Latin, Extended Latin
|
||||
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, NULL, io.Fonts->GetGlyphRangesDefault());
|
||||
|
||||
|
||||
// Default + Selection of 2500 Ideographs used by Simplified Chinese
|
||||
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, NULL, io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||
|
||||
|
||||
// Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
|
||||
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||
|
||||
See "BUILDING CUSTOM GLYPH RANGES" section to create your own ranges.
|
||||
See "BUILDING CUSTOM GLYPH RANGES" section to create your own ranges.
|
||||
Offset font vertically by altering the io.Font->DisplayOffset value:
|
||||
|
||||
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
||||
@ -163,8 +163,8 @@ Offset font vertically by altering the io.Font->DisplayOffset value:
|
||||
---------------------------------------
|
||||
|
||||
Dear ImGui uses imstb_truetype.h to rasterize fonts (with optional oversampling).
|
||||
This technique and its implementation are not ideal for fonts rendered at _small sizes_, which may appear a
|
||||
little blurry or hard to read.
|
||||
This technique and its implementation are not ideal for fonts rendered at _small sizes_, which may appear a
|
||||
little blurry or hard to read.
|
||||
|
||||
There is an implementation of the ImFontAtlas builder using FreeType that you can use in the misc/freetype/ folder.
|
||||
|
||||
@ -178,7 +178,7 @@ Also note that correct sRGB space blending will have an important effect on your
|
||||
---------------------------------------
|
||||
|
||||
You can use the ImFontGlyphRangesBuilder helper to create glyph ranges based on text input.
|
||||
For example: for a game where your script is known, if you can feed your entire script to it and only build the characters the game needs.
|
||||
For example: for a game where your script is known, if you can feed your entire script to it and only build the characters the game needs.
|
||||
|
||||
ImVector<ImWchar> ranges;
|
||||
ImFontGlyphRangesBuilder builder;
|
||||
@ -198,11 +198,11 @@ For example: for a game where your script is known, if you can feed your entire
|
||||
Compile and use 'binary_to_compressed_c.cpp' to create a compressed C style array that you can embed in source code.
|
||||
See the documentation in binary_to_compressed_c.cpp for instruction on how to use the tool.
|
||||
You may find a precompiled version binary_to_compressed_c.exe for Windows instead of demo binaries package (see README).
|
||||
The tool optionally used Base85 encoding to reduce the size of _source code_ but the read-only arrays will be about 20% bigger.
|
||||
The tool optionally used Base85 encoding to reduce the size of _source code_ but the read-only arrays will be about 20% bigger.
|
||||
|
||||
Then load the font with:
|
||||
ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels, ...);
|
||||
or:
|
||||
or:
|
||||
ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_base85, size_pixels, ...);
|
||||
|
||||
|
||||
@ -221,7 +221,7 @@ Cousine-Regular.ttf
|
||||
by Steve Matteson
|
||||
Digitized data copyright (c) 2010 Google Corporation.
|
||||
Licensed under the SIL Open Font License, Version 1.1
|
||||
https://fonts.google.com/specimen/Cousine
|
||||
https://fonts.google.com/specimen/Cousine
|
||||
|
||||
DroidSans.ttf
|
||||
|
||||
@ -267,7 +267,7 @@ ICON FONTS
|
||||
|
||||
Kenney Icon Font (Game Controller Icons)
|
||||
https://github.com/nicodinh/kenney-icon-font
|
||||
|
||||
|
||||
IcoMoon - Custom Icon font builder
|
||||
https://icomoon.io/app
|
||||
|
||||
|
@ -244,10 +244,12 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
|
||||
#define STBRP_ASSERT(x) IM_ASSERT(x)
|
||||
#define STBRP_STATIC
|
||||
#define STB_RECT_PACK_IMPLEMENTATION
|
||||
#include "imstb_rectpack.h"
|
||||
#endif
|
||||
|
||||
struct ImFontBuildSrcGlyphFT
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
Natvis file to describe dear imgui types in the Visual Studio debugger.
|
||||
With this, types like ImVector<> will be displayed nicely in the debugger.
|
||||
Natvis file to describe dear imgui types in the Visual Studio debugger.
|
||||
With this, types like ImVector<> will be displayed nicely in the debugger.
|
||||
You can include this file a Visual Studio project file, or install it in Visual Studio folder.
|
||||
|
Loading…
Reference in New Issue
Block a user