Merge branch 'master' into docking

# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
This commit is contained in:
ocornut 2024-07-30 16:57:42 +02:00
commit 139e99ca37
9 changed files with 139 additions and 116 deletions

View File

@ -36,9 +36,11 @@ HOW TO UPDATE?
- Please report any issue! - Please report any issue!
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.91.0 WIP (In Progress) VERSION 1.91.0 (Released 2024-07-30)
----------------------------------------------------------------------- -----------------------------------------------------------------------
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.91.0
Breaking changes: Breaking changes:
- IO, IME: renamed platform IME hook and added explicit context for consistency and future-proofness. - IO, IME: renamed platform IME hook and added explicit context for consistency and future-proofness.
@ -46,7 +48,7 @@ Breaking changes:
- new: io.PlatformSetImeDataFn(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data); - new: io.PlatformSetImeDataFn(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
It is expected that for a vast majority of users this is automatically set by core It is expected that for a vast majority of users this is automatically set by core
library and/or platform backend so it won't have any effect. library and/or platform backend so it won't have any effect.
- Obsoleted GetContentRegionMax(), GetWindowContentRegionMin() and GetWindowContentRegionMax(). - Obsoleted GetContentRegionMax(), GetWindowContentRegionMin() and GetWindowContentRegionMax(). (#7838)
You should never need those functions! You can do everything in less a confusing manner by only You should never need those functions! You can do everything in less a confusing manner by only
using GetCursorScreenPos() and GetContentRegionAvail(). Also always consider that if you are using using GetCursorScreenPos() and GetContentRegionAvail(). Also always consider that if you are using
GetWindowPos() and GetCursorPos() you may also be making things unnecessarily complicated. GetWindowPos() and GetCursorPos() you may also be making things unnecessarily complicated.
@ -69,32 +71,24 @@ Breaking changes:
- Commented out obsolete ImGuiModFlags_XXX values (renamed to ImGuiMod_XXX in 1.89). (#4921, #456) - Commented out obsolete ImGuiModFlags_XXX values (renamed to ImGuiMod_XXX in 1.89). (#4921, #456)
- ImGuiModFlags_Ctrl -> ImGuiMod_Ctrl, ImGuiModFlags_Shift -> ImGuiMod_Shift etc. - ImGuiModFlags_Ctrl -> ImGuiMod_Ctrl, ImGuiModFlags_Shift -> ImGuiMod_Shift etc.
- Backends: GLFW+Emscripten: Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to - Backends: GLFW+Emscripten: Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to
ImGui_ImplGlfw_InstallEmscriptenCallbacks(), with additional GLFWWindow* parameter. (#7647) [@ypujante] ImGui_ImplGlfw_InstallEmscriptenCallbacks(), with an additional GLFWWindow* parameter. (#7647) [@ypujante]
Other changes: Other changes:
- Added TextLink(), TextLinkOpenURL() hyperlink widgets. (#7660) - Added TextLink(), TextLinkOpenURL() hyperlink widgets. (#7660)
- IO: added io.PlatformOpenInShellFn handler to open a link/folder/file in OS shell. (#7660) - IO: added io.PlatformOpenInShellFn handler to open a link/folder/file in OS shell. (#7660)
Default to use ShellExecute() under Windows, and system("") under Mac/Linux/etc. Added IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS to disable default Windows/Linux/Mac implementations.
Added IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS to disable default implementation. - IO: added io.ConfigNavSwapGamepadButtons to swap Activate/Cancel (A<>B) buttons, to match the
- IO: added io.ConfigNavSwapGamepadButtons to swap Activate/Cancel (A<>B) buttons, to match tye
typical "Nintendo/Japanese consoles" button layout when using Gamepad navigation. (#787, #5723) typical "Nintendo/Japanese consoles" button layout when using Gamepad navigation. (#787, #5723)
- Added PushItemFlag()/PopItemFlags(), ImGuiItemFlags to modify shared item flags: - Added PushItemFlag()/PopItemFlags(), ImGuiItemFlags to modify shared item flags:
- Added ImGuiItemFlags_NoTabStop to disable tabbing through items. - Added ImGuiItemFlags_NoTabStop to disable tabbing through items.
- Added ImGuiItemFlags_NoNav to disable any navigation and focus of items. (#787) - Added ImGuiItemFlags_NoNav to disable any navigation and focus of items. (#787)
- Added ImGuiItemFlags_NoNavDefaultFocus to disable item being default focus. (#787) - Added ImGuiItemFlags_NoNavDefaultFocus to disable item being default focus. (#787)
- Added ImGuiItemFlags_ButtonRepeat to enable repeat on any button-like behavior. - Added ImGuiItemFlags_ButtonRepeat to enable repeat on any button-like behavior.
- Added ImGuiItemFlags_AutoClosePopups to disable menu items/selection auto closing parent popups. - Added ImGuiItemFlags_AutoClosePopups to disable menu items/selection auto closing parent popups.
Disabling this was previously possible for Selectable() via a direct flag but not for MenuItem(). Disabling this was previously possible for Selectable() via a direct flag but not for MenuItem().
(#1379, #1468, #2200, #4936, #5216, #7302, #7573) (#1379, #1468, #2200, #4936, #5216, #7302, #7573)
- This was mostly all previously in imgui_internal.h. - This was mostly all previously in imgui_internal.h.
- Inputs: added SetItemKeyOwner(ImGuiKey key) in public API. This is a simplified version of a more
complete set of function available in imgui_internal.h. One common use-case for this is to allow
your items to disable standard inputs behaviors such as Tab or Alt handling, Mouse Wheel scrolling,
etc. (#456, #2637, #2620, #2891, #3370, #3724, #4828, #5108, #5242, #5641)
// Hovering or activating the button will disable mouse wheel default behavior to scroll
InvisibleButton(...);
SetItemKeyOwner(ImGuiKey_MouseWheelY);
- Multi-Select: added multi-select API and demos. (#1861, #6518) - Multi-Select: added multi-select API and demos. (#1861, #6518)
- This system implements standard multi-selection idioms (CTRL+mouse click, CTRL+keyboard moves, - This system implements standard multi-selection idioms (CTRL+mouse click, CTRL+keyboard moves,
SHIFT+mouse click, SHIFT+keyboard moves, etc.) with support for clipper (not submitting non-visible SHIFT+mouse click, SHIFT+keyboard moves, etc.) with support for clipper (not submitting non-visible
@ -103,15 +97,16 @@ Other changes:
This is designed to allow all kinds of selection storage you may use in your application This is designed to allow all kinds of selection storage you may use in your application
(e.g. set/map/hash, intrusive selection, interval trees, up to you). (e.g. set/map/hash, intrusive selection, interval trees, up to you).
- The supported widgets are Selectable(), Checkbox(). TreeNode() is also technically supported but... - The supported widgets are Selectable(), Checkbox(). TreeNode() is also technically supported but...
using this correctly is more complicated (you need some sort of linear/random access to your tree, using this correctly is more complicated. You need some sort of linear/random access to your tree,
which is suited to advanced trees setups already implementing filters and clipper. which is suited to advanced trees setups already implementing filters and clipper.
We will work toward simplifying and demoing this later. We will work toward simplifying our existing demo for trees.
- A helper ImGuiSelectionBasicStorage is provided to facilitate getting started in a typical app. - A helper ImGuiSelectionBasicStorage is provided to facilitate getting started in a typical app
(likely to suit a majority of users).
- Documentation: - Documentation:
- Wiki page https://github.com/ocornut/imgui/wiki/Multi-Select for API overview. - Wiki page https://github.com/ocornut/imgui/wiki/Multi-Select for API overview.
- Demo code + headers are well commented. - Demo code + headers are well commented.
- Added BeginMultiSelect(), EndMultiSelect(), SetNextItemSelectionUserData(). - Added BeginMultiSelect(), EndMultiSelect(), SetNextItemSelectionUserData().
- Added IsItemToggledSelection() for use if you need latest selection update during currnet iteration. - Added IsItemToggledSelection() for use if you need latest selection update during current iteration.
- Added ImGuiMultiSelectIO and ImGuiSelectionRequest structures: - Added ImGuiMultiSelectIO and ImGuiSelectionRequest structures:
- BeginMultiSelect() and EndMultiSelect() return a ImGuiMultiSelectIO structure, which - BeginMultiSelect() and EndMultiSelect() return a ImGuiMultiSelectIO structure, which
is mostly an array of ImGuiSelectionRequest actions (clear, select all, set range, etc.) is mostly an array of ImGuiSelectionRequest actions (clear, select all, set range, etc.)
@ -142,12 +137,23 @@ Other changes:
- Multi-Select (with clipper) - Multi-Select (with clipper)
- Multi-Select (with deletion) - Multi-Select (with deletion)
- Multi-Select (dual list box) (#6648) - Multi-Select (dual list box) (#6648)
- Multi-Select (in a table)
- Multi-Select (checkboxes) - Multi-Select (checkboxes)
- Multi-Select (multiple scopes) - Multi-Select (multiple scopes)
- Multi-Select (tiled assert browser)
- Multi-Select (trees) (#1861)
- Multi-Select (advanced) - Multi-Select (advanced)
- Inputs: added SetItemKeyOwner(ImGuiKey key) in public API.
This is a simplified version of a more complete set of function available in imgui_internal.h.
One common use-case for this is to allow your widgets to disable standard inputs behaviors such
as Tab or Alt handling, Mouse Wheel scrolling, etc.
(#456, #2637, #2620, #2891, #3370, #3724, #4828, #5108, #5242, #5641)
// Hovering or activating the button will disable mouse wheel default behavior to scroll
InvisibleButton(...);
SetItemKeyOwner(ImGuiKey_MouseWheelY);
- Nav: fixed clicking window decorations (e.g. resize borders) from losing focused item when - Nav: fixed clicking window decorations (e.g. resize borders) from losing focused item when
within a child window using ImGuiChildFlags_NavFlattened. within a child window using ImGuiChildFlags_NavFlattened.
- InputText: added '\' and '/' as word seperator. (#7824, #7704) [@reduf] - InputText: added '\' and '/' as word separator. (#7824, #7704) [@reduf]
- TreeNode: added SetNextItemStorageID() to specify/override the identifier used for persisting - TreeNode: added SetNextItemStorageID() to specify/override the identifier used for persisting
open/close storage. Useful if needing to often read/write from storage without manipulating open/close storage. Useful if needing to often read/write from storage without manipulating
the ID stack. (#7553, #6990, #3823, #1131) the ID stack. (#7553, #6990, #3823, #1131)
@ -155,35 +161,37 @@ Other changes:
the hovered state. (#7820) [@rerilier] the hovered state. (#7820) [@rerilier]
- Clipper: added SeekCursorForItem() function. When using ImGuiListClipper::Begin(INT_MAX) you can - Clipper: added SeekCursorForItem() function. When using ImGuiListClipper::Begin(INT_MAX) you can
can use the clipper without knowing the amount of items beforehand. (#1311) can use the clipper without knowing the amount of items beforehand. (#1311)
In this situation, call ImGuiListClipper::SeekCursorForItem(items_count) as the end of your iteration In this situation, call ImGuiListClipper::SeekCursorForItem(items_count) at the end of your iteration
loop to position the layout cursor correctly. This is done automatically if provided a count to Begin(). loop to position the layout cursor correctly. This is done automatically if provided a count to Begin().
- Groups, Tables: fixed EndGroup() failing to correctly capture current table occupied size. (#7543) - Groups, Tables: fixed EndGroup() failing to correctly capture current table occupied size. (#7543)
- TabBar, Style: added style.TabBarOverlineSize / ImGuiStyleVar_TabBarOverlineSize to manipulate - Style, TabBar: added style.TabBarOverlineSize / ImGuiStyleVar_TabBarOverlineSize to manipulate
thickness of the horizontal line over selectable tabs. [@DctrNoob] thickness of the horizontal line over selected tabs. [@DctrNoob]
- Misc: added GetID(int) variant for consistency. (#7111)
- Style: close button and collapse/window-menu button hover highlight made rectangular instead of round. - Style: close button and collapse/window-menu button hover highlight made rectangular instead of round.
- Debug Tools: Added IMGUI_DEBUG_LOG(), ImGui::DebugLog() in public API. (#5855) - Misc: added GetID(int) variant for consistency. (#7111)
Debug log entries add a imgui frame counter prefix + are redirected to ShowDebugLogWindow() and - Debug Tools:
other configurable locations. Always call IMGUI_DEBUG_LOG() for maximum stripping in caller code. - Debug Log: Added IMGUI_DEBUG_LOG(), ImGui::DebugLog() in public API. (#5855)
- Debug Tools: Debug Log: Added "Configure Outputs.." button. (#5855) Printed entries include imgui frame counter prefix + are redirected to ShowDebugLogWindow() and
- Debug Tools: Debug Log: Fixed incorrect checkbox layout when partially clipped. other configurable locations. Always call IMGUI_DEBUG_LOG() for maximum stripping in caller code.
- Demo: Reworked "Property Editor" demo in a manner that more ressemble the tree data and - Debug Log: Added "Configure Outputs.." button. (#5855)
- Debug Log: Fixed incorrect checkbox layout when partially clipped.
- Demo: Reworked "Property Editor" demo in a manner that more resemble the tree data and
struct description data that a real application would want to use. struct description data that a real application would want to use.
- Backends: Win32: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN. - Backends:
(#7768, #4858, #2622) [@Aemony] - Backends: Win32: Fixed ImGuiMod_Super being mapped to VK_APPS instead of (VK_LWIN || VK_RWIN).
- Backends: SDL3: Update for API changes: SDL_GetGamepads() memory ownership change. (#7807) (#7768, #4858, #2622) [@Aemony]
- Backends: SDL3: Update for API changes: SDL_GetClipboardText() memory ownership change. (#7801) - Backends: SDL3: Update for API changes: SDL_GetGamepads() memory ownership change. (#7807)
- Backends: SDL3: Update for API changes: SDLK_x renames and SDLK_KP_x removals (#7761, #7762) - Backends: SDL3: Update for API changes: SDL_GetClipboardText() memory ownership change. (#7801)
- Backends: SDL3: Update for API changes: SDL_GetProperty() change to SDL_GetPointerProperty(). (#7794) [@wermipls] - Backends: SDL3: Update for API changes: SDLK_x renames and SDLK_KP_x removals (#7761, #7762)
- Backends: SDL2,SDL3,OSX: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() rename. - Backends: SDL3: Update for API changes: SDL_GetProperty() change to SDL_GetPointerProperty(). (#7794) [@wermipls]
- Backends: GLFW,SDL2: Added io.PlatformOpenInShellFn handler for web/Emscripten versions. (#7660) - Backends: SDL2,SDL3,OSX: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() rename.
[@ypujante, @ocornut] - Backends: GLFW,SDL2: Added io.PlatformOpenInShellFn handler for web/Emscripten versions. (#7660)
- Backends; GLFW+Emscripten: Added support for GLFW3 contrib port which fixes many of the things [@ypujante, @ocornut]
not supported by the embedded GLFW: gamepad support, mouse cursor shapes, copy to clipboard, - Backends; GLFW+Emscripten: Added support for GLFW3 contrib port which fixes many of the things
workaround for Super/Meta key, different ways of resizing, multi-window (glfw/canvas) support. not supported by the embedded GLFW: gamepad support, mouse cursor shapes, copy to clipboard,
(#7647) [@ypujante] workaround for Super/Meta key, different ways of resizing, multi-window (glfw/canvas) support.
- Backends: GLFW+Emscripten: Fixed Emscripten warning when using mouse wheel on some setups (#7647) [@ypujante]
"Unable to preventDefault inside passive event listener". (#7647, #7600) [@ypujante] - Backends: GLFW+Emscripten: Fixed Emscripten warning when using mouse wheel on some setups
"Unable to preventDefault inside passive event listener". (#7647, #7600) [@ypujante]
Docking+Viewports Branch: Docking+Viewports Branch:

View File

@ -11,7 +11,7 @@
android:name="imgui.example.android.MainActivity" android:name="imgui.example.android.MainActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|keyboardHidden|screenSize" android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="false"> android:exported="true">
<meta-data android:name="android.app.lib_name" <meta-data android:name="android.app.lib_name"
android:value="ImGuiExample" /> android:value="ImGuiExample" />

View File

@ -1,4 +1,4 @@
// dear imgui, v1.91.0 WIP // dear imgui, v1.91.0
// (main code and documentation) // (main code and documentation)
// Help: // Help:
@ -438,7 +438,7 @@ CODE
- likewise io.MousePos and GetMousePos() will use OS coordinates. - likewise io.MousePos and GetMousePos() will use OS coordinates.
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos. If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
- 2024/07/25 (1.91.0) - obsoleted GetContentRegionMax(), GetWindowContentRegionMin() and GetWindowContentRegionMax(). - 2024/07/25 (1.91.0) - obsoleted GetContentRegionMax(), GetWindowContentRegionMin() and GetWindowContentRegionMax(). (see #7838 on GitHub for more info)
you should never need those functions. you can do everything with GetCursorScreenPos() and GetContentRegionAvail() in a more simple way. you should never need those functions. you can do everything with GetCursorScreenPos() and GetContentRegionAvail() in a more simple way.
- instead of: GetWindowContentRegionMax().x - GetCursorPos().x - instead of: GetWindowContentRegionMax().x - GetCursorPos().x
- you can use: GetContentRegionAvail().x - you can use: GetContentRegionAvail().x
@ -3123,7 +3123,8 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
bool affected_by_floating_point_precision = ImIsFloatAboveGuaranteedIntegerPrecision(clipper->StartPosY) || ImIsFloatAboveGuaranteedIntegerPrecision(window->DC.CursorPos.y); bool affected_by_floating_point_precision = ImIsFloatAboveGuaranteedIntegerPrecision(clipper->StartPosY) || ImIsFloatAboveGuaranteedIntegerPrecision(window->DC.CursorPos.y);
if (affected_by_floating_point_precision) if (affected_by_floating_point_precision)
clipper->ItemsHeight = window->DC.PrevLineSize.y + g.Style.ItemSpacing.y; // FIXME: Technically wouldn't allow multi-line entries. clipper->ItemsHeight = window->DC.PrevLineSize.y + g.Style.ItemSpacing.y; // FIXME: Technically wouldn't allow multi-line entries.
if (clipper->ItemsHeight == 0.0f && clipper->ItemsCount == INT_MAX) // Accept that no item have been submitted if in indeterminate mode.
return false;
IM_ASSERT(clipper->ItemsHeight > 0.0f && "Unable to calculate item height! First item hasn't moved the cursor vertically!"); IM_ASSERT(clipper->ItemsHeight > 0.0f && "Unable to calculate item height! First item hasn't moved the cursor vertically!");
calc_clipping = true; // If item height had to be calculated, calculate clipping afterwards. calc_clipping = true; // If item height had to be calculated, calculate clipping afterwards.
} }
@ -20795,7 +20796,12 @@ void ImGui::ShowMetricsWindow(bool* p_open)
for (int n = buf_size - 1; n >= 0; n--) for (int n = buf_size - 1; n >= 0; n--)
{ {
ImGuiDebugAllocEntry* entry = &info->LastEntriesBuf[(info->LastEntriesIdx - n + buf_size) % buf_size]; ImGuiDebugAllocEntry* entry = &info->LastEntriesBuf[(info->LastEntriesIdx - n + buf_size) % buf_size];
BulletText("Frame %06d: %+3d ( %2d malloc, %2d free )%s", entry->FrameCount, entry->AllocCount - entry->FreeCount, entry->AllocCount, entry->FreeCount, (n == 0) ? " (most recent)" : ""); BulletText("Frame %06d: %+3d ( %2d alloc, %2d free )", entry->FrameCount, entry->AllocCount - entry->FreeCount, entry->AllocCount, entry->FreeCount);
if (n == 0)
{
SameLine();
Text("<- %d frames ago", g.FrameCount - entry->FrameCount);
}
} }
TreePop(); TreePop();
} }

22
imgui.h
View File

@ -1,4 +1,4 @@
// dear imgui, v1.91.0 WIP // dear imgui, v1.91.0
// (headers) // (headers)
// Help: // Help:
@ -27,8 +27,8 @@
// Library Version // Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.91.0 WIP" #define IMGUI_VERSION "1.91.0"
#define IMGUI_VERSION_NUM 19099 #define IMGUI_VERSION_NUM 19100
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch #define IMGUI_HAS_VIEWPORT // Viewport WIP branch
#define IMGUI_HAS_DOCK // Docking WIP branch #define IMGUI_HAS_DOCK // Docking WIP branch
@ -489,7 +489,7 @@ namespace ImGui
IMGUI_API void SetCursorPos(const ImVec2& local_pos); // [window-local] " IMGUI_API void SetCursorPos(const ImVec2& local_pos); // [window-local] "
IMGUI_API void SetCursorPosX(float local_x); // [window-local] " IMGUI_API void SetCursorPosX(float local_x); // [window-local] "
IMGUI_API void SetCursorPosY(float local_y); // [window-local] " IMGUI_API void SetCursorPosY(float local_y); // [window-local] "
IMGUI_API ImVec2 GetCursorStartPos(); // [window-local] initial cursor position, in window-local coordinates IMGUI_API ImVec2 GetCursorStartPos(); // [window-local] initial cursor position, in window-local coordinates. Call GetCursorScreenPos() after Begin() to get the absolute coordinates version.
// Other layout functions // Other layout functions
IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator. IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
@ -678,12 +678,12 @@ namespace ImGui
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper. IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
// Multi-selection system for Selectable(), Checkbox() functions* // Multi-selection system for Selectable(), Checkbox(), TreeNode() functions [BETA]
// - This enables standard multi-selection/range-selection idioms (CTRL+Mouse/Keyboard, SHIFT+Mouse/Keyboard, etc.) in a way that also allow a clipper to be used. // - This enables standard multi-selection/range-selection idioms (CTRL+Mouse/Keyboard, SHIFT+Mouse/Keyboard, etc.) in a way that also allow a clipper to be used.
// - ImGuiSelectionUserData is often used to store your item index within the current view (but may store something else). // - ImGuiSelectionUserData is often used to store your item index within the current view (but may store something else).
// - Read comments near ImGuiMultiSelectIO for instructions/details and see 'Demo->Widgets->Selection State & Multi-Select' for demo. // - Read comments near ImGuiMultiSelectIO for instructions/details and see 'Demo->Widgets->Selection State & Multi-Select' for demo.
// - (*) TreeNode() is technically supported but... using this correctly is more complicate: you need some sort of linear/random access to your tree, // - TreeNode() is technically supported but... using this correctly is more complicated. You need some sort of linear/random access to your tree,
// which is suited to advanced trees setups already implementing filters and clipper. We will work toward simplifying and demoing this. // which is suited to advanced trees setups already implementing filters and clipper. We will work simplifying the current demo.
// - 'selection_size' and 'items_count' parameters are optional and used by a few features. If they are costly for you to compute, you may avoid them. // - 'selection_size' and 'items_count' parameters are optional and used by a few features. If they are costly for you to compute, you may avoid them.
IMGUI_API ImGuiMultiSelectIO* BeginMultiSelect(ImGuiMultiSelectFlags flags, int selection_size = -1, int items_count = -1); IMGUI_API ImGuiMultiSelectIO* BeginMultiSelect(ImGuiMultiSelectFlags flags, int selection_size = -1, int items_count = -1);
IMGUI_API ImGuiMultiSelectIO* EndMultiSelect(); IMGUI_API ImGuiMultiSelectIO* EndMultiSelect();
@ -2898,10 +2898,10 @@ enum ImGuiMultiSelectFlags_
ImGuiMultiSelectFlags_SingleSelect = 1 << 0, // Disable selecting more than one item. This is available to allow single-selection code to share same code/logic if desired. It essentially disables the main purpose of BeginMultiSelect() tho! ImGuiMultiSelectFlags_SingleSelect = 1 << 0, // Disable selecting more than one item. This is available to allow single-selection code to share same code/logic if desired. It essentially disables the main purpose of BeginMultiSelect() tho!
ImGuiMultiSelectFlags_NoSelectAll = 1 << 1, // Disable CTRL+A shortcut to select all. ImGuiMultiSelectFlags_NoSelectAll = 1 << 1, // Disable CTRL+A shortcut to select all.
ImGuiMultiSelectFlags_NoRangeSelect = 1 << 2, // Disable Shift+selection mouse/keyboard support (useful for unordered 2D selection). With BoxSelect is also ensure contiguous SetRange requests are not combined into one. This allows not handling interpolation in SetRange requests. ImGuiMultiSelectFlags_NoRangeSelect = 1 << 2, // Disable Shift+selection mouse/keyboard support (useful for unordered 2D selection). With BoxSelect is also ensure contiguous SetRange requests are not combined into one. This allows not handling interpolation in SetRange requests.
ImGuiMultiSelectFlags_NoAutoSelect = 1 << 3, // Disable selecting items when navigating (useful for e.g. supporting range-select in a list of checkboxes) ImGuiMultiSelectFlags_NoAutoSelect = 1 << 3, // Disable selecting items when navigating (useful for e.g. supporting range-select in a list of checkboxes).
ImGuiMultiSelectFlags_NoAutoClear = 1 << 4, // Disable clearing selection when navigating or selecting another one (generally used with ImGuiMultiSelectFlags_NoAutoSelect. useful for e.g. supporting range-select in a list of checkboxes) ImGuiMultiSelectFlags_NoAutoClear = 1 << 4, // Disable clearing selection when navigating or selecting another one (generally used with ImGuiMultiSelectFlags_NoAutoSelect. useful for e.g. supporting range-select in a list of checkboxes).
ImGuiMultiSelectFlags_NoAutoClearOnReselect = 1 << 5, // Disable clearing selection when clicking/selecting an already selected item ImGuiMultiSelectFlags_NoAutoClearOnReselect = 1 << 5, // Disable clearing selection when clicking/selecting an already selected item.
ImGuiMultiSelectFlags_BoxSelect1d = 1 << 6, // Enable box-selection with same width and same x pos items (e.g. only full row Selectable()). Box-selection works better with little bit of spacing between items hit-box in order to be able to aim at empty space. ImGuiMultiSelectFlags_BoxSelect1d = 1 << 6, // Enable box-selection with same width and same x pos items (e.g. full row Selectable()). Box-selection works better with little bit of spacing between items hit-box in order to be able to aim at empty space.
ImGuiMultiSelectFlags_BoxSelect2d = 1 << 7, // Enable box-selection with varying width or varying x pos items support (e.g. different width labels, or 2D layout/grid). This is slower: alters clipping logic so that e.g. horizontal movements will update selection of normally clipped items. ImGuiMultiSelectFlags_BoxSelect2d = 1 << 7, // Enable box-selection with varying width or varying x pos items support (e.g. different width labels, or 2D layout/grid). This is slower: alters clipping logic so that e.g. horizontal movements will update selection of normally clipped items.
ImGuiMultiSelectFlags_BoxSelectNoScroll = 1 << 8, // Disable scrolling when box-selecting near edges of scope. ImGuiMultiSelectFlags_BoxSelectNoScroll = 1 << 8, // Disable scrolling when box-selecting near edges of scope.
ImGuiMultiSelectFlags_ClearOnEscape = 1 << 9, // Clear selection when pressing Escape while scope is focused. ImGuiMultiSelectFlags_ClearOnEscape = 1 << 9, // Clear selection when pressing Escape while scope is focused.

View File

@ -1,4 +1,4 @@
// dear imgui, v1.91.0 WIP // dear imgui, v1.91.0
// (demo code) // (demo code)
// Help: // Help:
@ -200,6 +200,7 @@ Index of this file:
#if !defined(IMGUI_DISABLE_DEMO_WINDOWS) #if !defined(IMGUI_DISABLE_DEMO_WINDOWS)
// Forward Declarations // Forward Declarations
struct ImGuiDemoWindowData;
static void ShowExampleAppMainMenuBar(); static void ShowExampleAppMainMenuBar();
static void ShowExampleAppAssetsBrowser(bool* p_open); static void ShowExampleAppAssetsBrowser(bool* p_open);
static void ShowExampleAppConsole(bool* p_open); static void ShowExampleAppConsole(bool* p_open);
@ -208,7 +209,7 @@ static void ShowExampleAppDockSpace(bool* p_open);
static void ShowExampleAppDocuments(bool* p_open); static void ShowExampleAppDocuments(bool* p_open);
static void ShowExampleAppLog(bool* p_open); static void ShowExampleAppLog(bool* p_open);
static void ShowExampleAppLayout(bool* p_open); static void ShowExampleAppLayout(bool* p_open);
static void ShowExampleAppPropertyEditor(bool* p_open); static void ShowExampleAppPropertyEditor(bool* p_open, ImGuiDemoWindowData* demo_data);
static void ShowExampleAppSimpleOverlay(bool* p_open); static void ShowExampleAppSimpleOverlay(bool* p_open);
static void ShowExampleAppAutoResize(bool* p_open); static void ShowExampleAppAutoResize(bool* p_open);
static void ShowExampleAppConstrainedResize(bool* p_open); static void ShowExampleAppConstrainedResize(bool* p_open);
@ -219,10 +220,9 @@ static void ShowExampleMenuFile();
// We split the contents of the big ShowDemoWindow() function into smaller functions // We split the contents of the big ShowDemoWindow() function into smaller functions
// (because the link time of very large functions tends to grow non-linearly) // (because the link time of very large functions tends to grow non-linearly)
struct DemoWindowData; static void ShowDemoWindowMenuBar(ImGuiDemoWindowData* demo_data);
static void ShowDemoWindowMenuBar(DemoWindowData* demo_data); static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data);
static void ShowDemoWindowWidgets(DemoWindowData* demo_data); static void ShowDemoWindowMultiSelect(ImGuiDemoWindowData* demo_data);
static void ShowDemoWindowMultiSelect(DemoWindowData* demo_data);
static void ShowDemoWindowLayout(); static void ShowDemoWindowLayout();
static void ShowDemoWindowPopups(); static void ShowDemoWindowPopups();
static void ShowDemoWindowTables(); static void ShowDemoWindowTables();
@ -321,13 +321,14 @@ static ExampleTreeNode* ExampleTree_CreateNode(const char* name, int uid, Exampl
// (this allocates _many_ more times than most other code in either Dear ImGui or others demo) // (this allocates _many_ more times than most other code in either Dear ImGui or others demo)
static ExampleTreeNode* ExampleTree_CreateDemoTree() static ExampleTreeNode* ExampleTree_CreateDemoTree()
{ {
static const char* root_names[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" }; static const char* root_names[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pear", "Pineapple", "Strawberry", "Watermelon" };
char name_buf[32]; char name_buf[32];
int uid = 0; int uid = 0;
ExampleTreeNode* node_L0 = ExampleTree_CreateNode("<ROOT>", ++uid, NULL); ExampleTreeNode* node_L0 = ExampleTree_CreateNode("<ROOT>", ++uid, NULL);
for (int idx_L0 = 0; idx_L0 < IM_ARRAYSIZE(root_names) * 2; idx_L0++) const int root_items_multiplier = 2;
for (int idx_L0 = 0; idx_L0 < IM_ARRAYSIZE(root_names) * root_items_multiplier; idx_L0++)
{ {
snprintf(name_buf, 32, "%s %d", root_names[idx_L0 / 2], idx_L0 % 2); snprintf(name_buf, 32, "%s %d", root_names[idx_L0 / root_items_multiplier], idx_L0 % root_items_multiplier);
ExampleTreeNode* node_L1 = ExampleTree_CreateNode(name_buf, ++uid, node_L0); ExampleTreeNode* node_L1 = ExampleTree_CreateNode(name_buf, ++uid, node_L0);
const int number_of_childs = (int)strlen(node_L1->Name); const int number_of_childs = (int)strlen(node_L1->Name);
for (int idx_L1 = 0; idx_L1 < number_of_childs; idx_L1++) for (int idx_L1 = 0; idx_L1 < number_of_childs; idx_L1++)
@ -350,7 +351,8 @@ static ExampleTreeNode* ExampleTree_CreateDemoTree()
// [SECTION] Demo Window / ShowDemoWindow() // [SECTION] Demo Window / ShowDemoWindow()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
struct DemoWindowData // Data to be shared accross different functions of the demo.
struct ImGuiDemoWindowData
{ {
// Examples Apps (accessible from the "Examples" menu) // Examples Apps (accessible from the "Examples" menu)
bool ShowMainMenuBar = false; bool ShowMainMenuBar = false;
@ -375,6 +377,9 @@ struct DemoWindowData
bool ShowIDStackTool = false; bool ShowIDStackTool = false;
bool ShowStyleEditor = false; bool ShowStyleEditor = false;
bool ShowAbout = false; bool ShowAbout = false;
// Other data
ExampleTreeNode* DemoTree = NULL;
}; };
// Demonstrate most Dear ImGui features (this is big function!) // Demonstrate most Dear ImGui features (this is big function!)
@ -390,33 +395,33 @@ void ImGui::ShowDemoWindow(bool* p_open)
IMGUI_CHECKVERSION(); IMGUI_CHECKVERSION();
// Stored data // Stored data
static DemoWindowData demo; static ImGuiDemoWindowData demo_data;
// Examples Apps (accessible from the "Examples" menu) // Examples Apps (accessible from the "Examples" menu)
if (demo.ShowMainMenuBar) { ShowExampleAppMainMenuBar(); } if (demo_data.ShowMainMenuBar) { ShowExampleAppMainMenuBar(); }
if (demo.ShowAppDockSpace) { ShowExampleAppDockSpace(&demo.ShowAppDockSpace); } // Important: Process the Docking app first, as explicit DockSpace() nodes needs to be submitted early (read comments near the DockSpace function) if (demo_data.ShowAppDockSpace) { ShowExampleAppDockSpace(&demo_data.ShowAppDockSpace); } // Important: Process the Docking app first, as explicit DockSpace() nodes needs to be submitted early (read comments near the DockSpace function)
if (demo.ShowAppDocuments) { ShowExampleAppDocuments(&demo.ShowAppDocuments); } // ...Process the Document app next, as it may also use a DockSpace() if (demo_data.ShowAppDocuments) { ShowExampleAppDocuments(&demo_data.ShowAppDocuments); } // ...process the Document app next, as it may also use a DockSpace()
if (demo.ShowAppAssetsBrowser) { ShowExampleAppAssetsBrowser(&demo.ShowAppAssetsBrowser); } if (demo_data.ShowAppAssetsBrowser) { ShowExampleAppAssetsBrowser(&demo_data.ShowAppAssetsBrowser); }
if (demo.ShowAppConsole) { ShowExampleAppConsole(&demo.ShowAppConsole); } if (demo_data.ShowAppConsole) { ShowExampleAppConsole(&demo_data.ShowAppConsole); }
if (demo.ShowAppCustomRendering) { ShowExampleAppCustomRendering(&demo.ShowAppCustomRendering); } if (demo_data.ShowAppCustomRendering) { ShowExampleAppCustomRendering(&demo_data.ShowAppCustomRendering); }
if (demo.ShowAppLog) { ShowExampleAppLog(&demo.ShowAppLog); } if (demo_data.ShowAppLog) { ShowExampleAppLog(&demo_data.ShowAppLog); }
if (demo.ShowAppLayout) { ShowExampleAppLayout(&demo.ShowAppLayout); } if (demo_data.ShowAppLayout) { ShowExampleAppLayout(&demo_data.ShowAppLayout); }
if (demo.ShowAppPropertyEditor) { ShowExampleAppPropertyEditor(&demo.ShowAppPropertyEditor); } if (demo_data.ShowAppPropertyEditor) { ShowExampleAppPropertyEditor(&demo_data.ShowAppPropertyEditor, &demo_data); }
if (demo.ShowAppSimpleOverlay) { ShowExampleAppSimpleOverlay(&demo.ShowAppSimpleOverlay); } if (demo_data.ShowAppSimpleOverlay) { ShowExampleAppSimpleOverlay(&demo_data.ShowAppSimpleOverlay); }
if (demo.ShowAppAutoResize) { ShowExampleAppAutoResize(&demo.ShowAppAutoResize); } if (demo_data.ShowAppAutoResize) { ShowExampleAppAutoResize(&demo_data.ShowAppAutoResize); }
if (demo.ShowAppConstrainedResize) { ShowExampleAppConstrainedResize(&demo.ShowAppConstrainedResize); } if (demo_data.ShowAppConstrainedResize) { ShowExampleAppConstrainedResize(&demo_data.ShowAppConstrainedResize); }
if (demo.ShowAppFullscreen) { ShowExampleAppFullscreen(&demo.ShowAppFullscreen); } if (demo_data.ShowAppFullscreen) { ShowExampleAppFullscreen(&demo_data.ShowAppFullscreen); }
if (demo.ShowAppLongText) { ShowExampleAppLongText(&demo.ShowAppLongText); } if (demo_data.ShowAppLongText) { ShowExampleAppLongText(&demo_data.ShowAppLongText); }
if (demo.ShowAppWindowTitles) { ShowExampleAppWindowTitles(&demo.ShowAppWindowTitles); } if (demo_data.ShowAppWindowTitles) { ShowExampleAppWindowTitles(&demo_data.ShowAppWindowTitles); }
// Dear ImGui Tools (accessible from the "Tools" menu) // Dear ImGui Tools (accessible from the "Tools" menu)
if (demo.ShowMetrics) { ImGui::ShowMetricsWindow(&demo.ShowMetrics); } if (demo_data.ShowMetrics) { ImGui::ShowMetricsWindow(&demo_data.ShowMetrics); }
if (demo.ShowDebugLog) { ImGui::ShowDebugLogWindow(&demo.ShowDebugLog); } if (demo_data.ShowDebugLog) { ImGui::ShowDebugLogWindow(&demo_data.ShowDebugLog); }
if (demo.ShowIDStackTool) { ImGui::ShowIDStackToolWindow(&demo.ShowIDStackTool); } if (demo_data.ShowIDStackTool) { ImGui::ShowIDStackToolWindow(&demo_data.ShowIDStackTool); }
if (demo.ShowAbout) { ImGui::ShowAboutWindow(&demo.ShowAbout); } if (demo_data.ShowAbout) { ImGui::ShowAboutWindow(&demo_data.ShowAbout); }
if (demo.ShowStyleEditor) if (demo_data.ShowStyleEditor)
{ {
ImGui::Begin("Dear ImGui Style Editor", &demo.ShowStyleEditor); ImGui::Begin("Dear ImGui Style Editor", &demo_data.ShowStyleEditor);
ImGui::ShowStyleEditor(); ImGui::ShowStyleEditor();
ImGui::End(); ImGui::End();
} }
@ -468,7 +473,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
//ImGui::PushItemWidth(-ImGui::GetWindowWidth() * 0.35f); // e.g. Use 2/3 of the space for widgets and 1/3 for labels (right align) //ImGui::PushItemWidth(-ImGui::GetWindowWidth() * 0.35f); // e.g. Use 2/3 of the space for widgets and 1/3 for labels (right align)
// Menu Bar // Menu Bar
ShowDemoWindowMenuBar(&demo); ShowDemoWindowMenuBar(&demo_data);
ImGui::Text("dear imgui says hello! (%s) (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM); ImGui::Text("dear imgui says hello! (%s) (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM);
ImGui::Spacing(); ImGui::Spacing();
@ -631,7 +636,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
IMGUI_DEMO_MARKER("Configuration/Style"); IMGUI_DEMO_MARKER("Configuration/Style");
if (ImGui::TreeNode("Style")) if (ImGui::TreeNode("Style"))
{ {
ImGui::Checkbox("Style Editor", &demo.ShowStyleEditor); ImGui::Checkbox("Style Editor", &demo_data.ShowStyleEditor);
ImGui::SameLine(); ImGui::SameLine();
HelpMarker("The same contents can be accessed in 'Tools->Style Editor' or by calling the ShowStyleEditor() function."); HelpMarker("The same contents can be accessed in 'Tools->Style Editor' or by calling the ShowStyleEditor() function.");
ImGui::TreePop(); ImGui::TreePop();
@ -680,7 +685,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
} }
// All demo contents // All demo contents
ShowDemoWindowWidgets(&demo); ShowDemoWindowWidgets(&demo_data);
ShowDemoWindowLayout(); ShowDemoWindowLayout();
ShowDemoWindowPopups(); ShowDemoWindowPopups();
ShowDemoWindowTables(); ShowDemoWindowTables();
@ -695,7 +700,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
// [SECTION] ShowDemoWindowMenuBar() // [SECTION] ShowDemoWindowMenuBar()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void ShowDemoWindowMenuBar(DemoWindowData* demo_data) static void ShowDemoWindowMenuBar(ImGuiDemoWindowData* demo_data)
{ {
IMGUI_DEMO_MARKER("Menu"); IMGUI_DEMO_MARKER("Menu");
if (ImGui::BeginMenuBar()) if (ImGui::BeginMenuBar())
@ -761,7 +766,7 @@ static void ShowDemoWindowMenuBar(DemoWindowData* demo_data)
// [SECTION] ShowDemoWindowWidgets() // [SECTION] ShowDemoWindowWidgets()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void ShowDemoWindowWidgets(DemoWindowData* demo_data) static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
{ {
IMGUI_DEMO_MARKER("Widgets"); IMGUI_DEMO_MARKER("Widgets");
//ImGui::SetNextItemOpen(true, ImGuiCond_Once); //ImGui::SetNextItemOpen(true, ImGuiCond_Once);
@ -3173,7 +3178,7 @@ struct ExampleDualListBox
// Also read: https://github.com/ocornut/imgui/wiki/Multi-Select // Also read: https://github.com/ocornut/imgui/wiki/Multi-Select
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void ShowDemoWindowMultiSelect(DemoWindowData* demo_data) static void ShowDemoWindowMultiSelect(ImGuiDemoWindowData* demo_data)
{ {
IMGUI_DEMO_MARKER("Widgets/Selection State & Multi-Select"); IMGUI_DEMO_MARKER("Widgets/Selection State & Multi-Select");
if (ImGui::TreeNode("Selection State & Multi-Select")) if (ImGui::TreeNode("Selection State & Multi-Select"))
@ -3655,11 +3660,13 @@ static void ShowDemoWindowMultiSelect(DemoWindowData* demo_data)
}; // ExampleTreeFuncs }; // ExampleTreeFuncs
static ImGuiSelectionBasicStorage selection; static ImGuiSelectionBasicStorage selection;
static ExampleTreeNode* tree = ExampleTree_CreateDemoTree(); // Create tree once if (demo_data->DemoTree == NULL)
demo_data->DemoTree = ExampleTree_CreateDemoTree(); // Create tree once
ImGui::Text("Selection size: %d", selection.Size); ImGui::Text("Selection size: %d", selection.Size);
if (ImGui::BeginChild("##Tree", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY)) if (ImGui::BeginChild("##Tree", ImVec2(-FLT_MIN, ImGui::GetFontSize() * 20), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY))
{ {
ExampleTreeNode* tree = demo_data->DemoTree;
ImGuiMultiSelectFlags ms_flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect2d; ImGuiMultiSelectFlags ms_flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect2d;
ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(ms_flags, selection.Size, -1); ImGuiMultiSelectIO* ms_io = ImGui::BeginMultiSelect(ms_flags, selection.Size, -1);
ExampleTreeFuncs::ApplySelectionRequests(ms_io, tree, &selection); ExampleTreeFuncs::ApplySelectionRequests(ms_io, tree, &selection);
@ -3689,7 +3696,7 @@ static void ShowDemoWindowMultiSelect(DemoWindowData* demo_data)
static bool use_deletion = true; static bool use_deletion = true;
static bool use_drag_drop = true; static bool use_drag_drop = true;
static bool show_in_table = false; static bool show_in_table = false;
static bool show_color_button = false; static bool show_color_button = true;
static ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect1d; static ImGuiMultiSelectFlags flags = ImGuiMultiSelectFlags_ClearOnEscape | ImGuiMultiSelectFlags_BoxSelect1d;
static WidgetType widget_type = WidgetType_Selectable; static WidgetType widget_type = WidgetType_Selectable;
@ -4672,8 +4679,8 @@ static void ShowDemoWindowLayout()
ImGui::TreePop(); ImGui::TreePop();
} }
IMGUI_DEMO_MARKER("Layout/Clipping"); IMGUI_DEMO_MARKER("Layout/Text Clipping");
if (ImGui::TreeNode("Clipping")) if (ImGui::TreeNode("Text Clipping"))
{ {
static ImVec2 size(100.0f, 100.0f); static ImVec2 size(100.0f, 100.0f);
static ImVec2 offset(30.0f, 30.0f); static ImVec2 offset(30.0f, 30.0f);
@ -8967,6 +8974,7 @@ struct ExampleAppPropertyEditor
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::PushID(field_desc.Name); ImGui::PushID(field_desc.Name);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted(field_desc.Name); ImGui::TextUnformatted(field_desc.Name);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
void* field_ptr = (void*)(((unsigned char*)node) + field_desc.Offset); void* field_ptr = (void*)(((unsigned char*)node) + field_desc.Offset);
@ -9032,7 +9040,7 @@ struct ExampleAppPropertyEditor
}; };
// Demonstrate creating a simple property editor. // Demonstrate creating a simple property editor.
static void ShowExampleAppPropertyEditor(bool* p_open) static void ShowExampleAppPropertyEditor(bool* p_open, ImGuiDemoWindowData* demo_data)
{ {
ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver); ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Example: Property editor", p_open)) if (!ImGui::Begin("Example: Property editor", p_open))
@ -9043,8 +9051,9 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
IMGUI_DEMO_MARKER("Examples/Property Editor"); IMGUI_DEMO_MARKER("Examples/Property Editor");
static ExampleAppPropertyEditor property_editor; static ExampleAppPropertyEditor property_editor;
static ExampleTreeNode* tree_data = ExampleTree_CreateDemoTree(); if (demo_data->DemoTree == NULL)
property_editor.Draw(tree_data); demo_data->DemoTree = ExampleTree_CreateDemoTree();
property_editor.Draw(demo_data->DemoTree);
ImGui::End(); ImGui::End();
} }

View File

@ -1,4 +1,4 @@
// dear imgui, v1.91.0 WIP // dear imgui, v1.91.0
// (drawing and font code) // (drawing and font code)
/* /*

View File

@ -1,4 +1,4 @@
// dear imgui, v1.91.0 WIP // dear imgui, v1.91.0
// (internal structures/api) // (internal structures/api)
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility. // You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.

View File

@ -1,4 +1,4 @@
// dear imgui, v1.91.0 WIP // dear imgui, v1.91.0
// (tables and columns code) // (tables and columns code)
/* /*

View File

@ -1,4 +1,4 @@
// dear imgui, v1.91.0 WIP // dear imgui, v1.91.0
// (widgets code) // (widgets code)
/* /*