Compare commits

...

1462 Commits

Author SHA1 Message Date
ocornut
bbf2cd28b1 WIP Backends: SDLRenderer3: transform vertices manually. 2024-09-04 17:20:30 +02:00
ocornut
8d5c79096f WIP Backends: SDLRenderer3: adding support for multi-viewports. (broken: see 2 FIXMES) 2024-09-04 17:20:30 +02:00
ocornut
f63c95a076 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl3.cpp
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2024-09-04 16:58:44 +02:00
ocornut
6d70c2dc73 Viewports: fixed misuse of inset_max.y, which typically would have broken using BeginViewportSideBar() with ImGuiDir_Down, regression from 1.91.0. (#7940, #7823)
Amend cfd23957f
2024-09-03 20:02:04 +02:00
ocornut
6af9ac29ec Backends: SDL3: following SDL3 reverting their change, result of SDL_GetDisplays() must be freed. (#7809)
Reverts 271910e
2024-09-03 19:13:45 +02:00
ocornut
226e0d579d Fixed duplicate declaration of GetPlatformIO() in header. (#7917) 2024-08-25 15:07:36 +02:00
ocornut
8c4dceba08 Tabs: avoid queuing a refocus when tab is already focused, which would have the side-effect of e.g. closing popup on a mouse release. (#7914) 2024-08-23 19:40:47 +02:00
ocornut
4fc187dc60 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2024-08-23 19:19:22 +02:00
ocornut
947961b7b4 Fixed Clang17 C++26 warning. (#7383)
Unable to repro locally for now.
2024-08-23 15:51:05 +02:00
ocornut
8b37da74db Backends: GLFW: undo accidentally not committing use of Platform_SetClipboardTextFn as I was testing the legacy path (amend 214977e). 2024-08-22 20:28:30 +02:00
ocornut
fed4841bd4 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2024-08-22 20:26:59 +02:00
ocornut
ea01c63e36 Backends: SDL2, SDL3: amend filtering logic for it to work with multi-viewports. (#7853) 2024-08-19 14:46:53 +02:00
ocornut
24b077c7f8 Merge branch 'master' into docking (multi-viewport broken until next commit)
# Conflicts:
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
2024-08-19 14:44:35 +02:00
ocornut
65840c19c4 Backends: SDL2, SDL3, Win32: don't submit monitor with 0 DpiScale (e.g. accessibility virtual monitor?). to prevent assert. (#7902)
I am not too confident on this but I believe pushing this is the fastest way we will get feedback.
2024-08-19 12:19:06 +02:00
RT2
fa65dcf24c Backends: SDL2, SDL3: Replace Win32 hack with SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN hint. (#7896) 2024-08-19 12:15:29 +02:00
Nicolas Noble
fbafc33376 Backends: GLFW: don't submit monitor with 0 DpiScale (e.g. accessibility virtual monitor?). to prevent assert. (#7902) 2024-08-19 11:51:53 +02:00
ocornut
7b6314f47d Viewports: don't call platform_io.Platform_GetWindowWorkAreaInsets() before window creation. (#7823)
Amend a18f020
2024-08-07 16:55:56 +02:00
ocornut
a18f020072 Viewports: added platform_io.Platform_GetWindowWorkAreaInsets() hook. (#7823) 2024-08-01 19:10:22 +02:00
ocornut
d8c98c8c14 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
2024-08-01 19:07:53 +02:00
ocornut
cfd23957fb Viewports: rework viewport's WorkOffset (positive top-left, negative top-right0 into WorkInset (positive everywhere). (#7823) 2024-08-01 19:04:46 +02:00
ocornut
139e99ca37 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
2024-07-30 16:57:42 +02:00
ocornut
6df1a06fc3 Merge branch 'master' into docking 2024-07-29 23:18:54 +02:00
ocornut
e212511047 Backends: Vulkan: ImGui_ImplVulkan_SwapBuffers() still proceeds increasing counts on VK_SUBOPTIMAL_KHR. (#7825, #3881)
Amend 085cff2f
2024-07-29 15:48:54 +02:00
ocornut
5c9825c16d Viewports: update fallback monitor to primary monitor if there's one.
Amend 4b9bc490.
+ metrics: display fallback monitor.
2024-07-29 12:28:42 +02:00
ocornut
3552df562e Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2024-07-25 16:41:56 +02:00
chenqiudu
aa0f6b37bd Backends: OSX: fixed NSAppKitVersion version limit for setWantsBestResolutionOpenGLSurface usage. (#7814) 2024-07-23 15:20:38 +02:00
ocornut
271910e349 Backends: SDL3: Update for API changes: SDL_GetDisplays() memory ownership change. (#7809) 2024-07-22 19:43:59 +02:00
ocornut
3fab2bb7be Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl3.cpp
#	imgui.cpp
2024-07-22 19:41:39 +02:00
ocornut
02cc7d451c Merge branch 'master' into docking
# Conflicts:
#	imgui_demo.cpp
2024-07-19 18:49:25 +02:00
ocornut
fd77815f9f Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
2024-07-18 18:22:26 +02:00
ocornut
0e485a2109 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl3.cpp
#	imgui.cpp
#	imgui_widgets.cpp
2024-07-18 17:56:27 +02:00
ocornut
5ea96c15cd Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_win32.cpp
2024-07-15 11:21:18 +02:00
ocornut
527b2c45af Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl2.cpp
2024-07-02 19:05:36 +02:00
ocornut
3f61da7e8b Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	backends/imgui_impl_sdl3.h
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2024-07-02 17:48:38 +02:00
ocornut
3369cbd277 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl3.cpp
2024-07-01 17:10:12 +02:00
ocornut
3fec562da1 Merged GetBackgroundDrawList()/GetForegroundDrawList() and GetBackgroundDrawList(ImGuiViewport* viewport)/GetForegroundDrawList(ImGuiViewport* viewport) api entry points. 2024-06-28 16:16:51 +02:00
ocornut
138d9d0c21 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl2.cpp
#	backends/imgui_impl_opengl3.cpp
2024-06-28 16:03:49 +02:00
ocornut
a028c2df2a Windows, Menus: Fixed an issue where the size of sub-menu in their own viewport would be erroneously clamped to the size of main viewport. (#7730)
Amend #7287, #7063
2024-06-27 16:05:25 +02:00
ocornut
10a5a857f5 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	backends/imgui_impl_win32.cpp
#	imgui.h
2024-06-26 14:54:01 +02:00
ocornut
7237d3e5c3 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
#	imgui_internal.h
2024-06-21 16:18:22 -07:00
ocornut
66ed89b0ca Docking: mark window payload as not cross-context. 2024-06-20 17:48:54 -07:00
ocornut
e863f89d39 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2024-06-20 17:47:22 -07:00
ocornut
416cfdb99d Backends: Win32: Secondary viewports WndProc handler retrieve/set imgui context from the HWND.
Allowing WndProc dispatch to work in multi-context setups.
2024-06-20 17:44:19 -07:00
ocornut
3acb869a95 Backends: Win32: avoid skipping DefWindowProc() on WM_CLOSE.
Mostly because I don't have a trace of why I did it this way, even in viewport branch history.
2024-06-20 17:42:46 -07:00
ocornut
2ebb4e931d TabBar, Style, Docking: amend 21bda2e for docking branch. 2024-06-18 17:47:22 -07:00
ocornut
3e7f1d42db Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui.h
#	imgui_draw.cpp
2024-06-18 17:45:17 -07:00
bcsanches
64a82d73c9 Backends: SDL3: Update for introduction of SDL_GLContext from void*. (#7701, #7702) 2024-06-18 09:45:24 -07:00
ocornut
6d948ab47e Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2024-06-06 17:52:55 +02:00
ocornut
fdc084f532 Merge branch 'master' into docking 2024-06-03 19:08:37 +02:00
ocornut
222dd775fc Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2024-05-28 17:11:57 +02:00
ocornut
2db79d0868 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2024-05-27 15:47:30 +02:00
ocornut
975beafafd Merge branch 'master' into docking 2024-05-24 17:23:58 +02:00
ocornut
fee0210592 Merge branch 'master' into docking 2024-05-24 16:09:29 +02:00
ocornut
5ecef2f321 Merge branch 'master' into docking
# Conflicts:
#	examples/example_win32_directx10/main.cpp
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx12/main.cpp
#	imgui.cpp
2024-05-23 17:25:02 +02:00
ocornut
36ffdd69d3 Merge remote-tracking branch 'origin/master' into docking 2024-05-21 19:01:06 +02:00
ocornut
9ebab255d2 Docking: *BREAKING* changed signature of DockSpaceOverViewport() to allow passing an explicit dockspace id if desired. (#7611) 2024-05-21 19:00:25 +02:00
ocornut
b39fc84f89 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2024-05-16 19:57:04 +02:00
ocornut
15d8d41f86 Examples: add missing ImGuiConfigFlags_DockingEnable flag in some examples. 2024-05-14 19:01:18 +02:00
ocornut
eabe98f6d5 Merge branch 'master' into docking (incl merge moved CurrentDpiScale field)
# Conflicts:
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
2024-05-14 16:29:06 +02:00
ocornut
e391fe2e66 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui_internal.h
2024-05-08 16:17:32 +02:00
Rory O'Connell
8b2c6dd42f Backends: Vulkan: reworked swap-chain resize handling for secondary viewports to work with typical Linux setups. (#2626, #3390, #3758, #7508, #7513) 2024-05-07 16:14:15 +02:00
cfillion
f5d185238c Viewports: fixed outer-right edge of MenuBar clipping rectangle off by one when window is located on a monitor with negative coordinates. (#6861, #2884) 2024-05-03 17:44:33 +02:00
ocornut
2f2d5070f5 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2024-05-03 16:30:09 +02:00
Sandro Cavazzoni
ebb8d78102 Backends: Vulkan: Create a custom pipeline for secondary viewports. (#6325, #6305, #7398, #3459, #3253, #3522)
Edited from original commit: moved ImGui_ImplVulkan_CreatePipeline() call from ImGui_ImplVulkanH_CreateOrResizeWindow() to ImGui_ImplVulkan_CreateWindow().
2024-04-30 15:37:36 +02:00
ocornut
49e70e60a2 Backends: Vulkan: Stripped misleading leftover of ImGui_ImplVulkanH_Window::Pipeline (#6325, #6305, #7398, #3459, #3253, #3522)
As this is currently unused and misleading. Next commit will add a separate pipeline for secondary viewport.
2024-04-30 15:37:36 +02:00
ocornut
9d6818d0ce Docking: comments, clairfy why we store style override on dragged windows. Clarify why we don't need to store alpha. (#7535, #2771)
Amend ebbb98d51
2024-04-30 14:10:11 +02:00
ocornut
5717f0a33e Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_vulkan.cpp
#	backends/imgui_impl_win32.cpp
2024-04-30 10:42:46 +02:00
ocornut
b555984a94 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	imgui.cpp
2024-04-18 21:18:18 +02:00
ocornut
4cb0fe3c7d Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl3.cpp
#	backends/imgui_impl_sdl3.h
#	docs/CHANGELOG.txt
#	imgui_internal.h
2024-04-16 14:24:13 +02:00
ocornut
c1743eef48 Docking: when io.ConfigDockingWithShift is enabled, fixed help tooltip erroneously reading SetNextWindowXXX() data. (#6709, #4643, #7491) 2024-04-15 11:43:16 +02:00
ocornut
1db579d458 Merge branch 'master' into docking 2024-04-11 16:21:56 +02:00
ocornut
085781f5ca Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2024-03-18 22:52:40 -07:00
ocornut
adcc3217c3 Revert "Docking: Fix C++26 zealous warnings (#7383, #7089)" + Disable warnings
This reverts commit 9d9ca37a84.
2024-03-11 15:07:05 +01:00
ocornut
9d9ca37a84 Docking: Fix C++26 zealous warnings (#7383, #7089) 2024-03-11 14:41:02 +01:00
ocornut
fd75685fb0 Merge branch 'master' into docking 2024-03-05 18:12:11 +01:00
ocornut
77dff5a735 Backends: comments. 2024-02-28 11:06:40 +01:00
ocornut
4e8c43f6b7 Backends: Win32: made it so that an appearing viewport showing up doesn't bring its parent viewport to front. (#7354) 2024-02-27 20:02:26 +01:00
ocornut
1a487165b1 Merge branch 'master' into docking 2024-02-27 18:44:51 +01:00
ocornut
c6aa051629 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2024-02-22 20:01:46 +01:00
ocornut
2b662b1ab9 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2024-02-20 15:33:20 +01:00
ocornut
8048b52498 Backends: GLFW: enable ImGuiBackendFlags_HasMouseHoveredViewport support with GLFW 3.3.x. (#7316) 2024-02-15 14:50:45 +01:00
ocornut
c66a1e7d51 Backends: Vulkan: ImGui_ImplVulkan_CreateWindow() amend merge to take account of PipelineRenderingCreateInfo change. (#7166, #6855, #5446, #5037) 2024-02-14 14:39:26 +01:00
ocornut
d79514c407 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_dx9.cpp
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	backends/imgui_impl_vulkan.cpp
#	imgui.cpp
2024-02-14 14:32:17 +01:00
ocornut
8490a262c4 Debug Tools: Metrics: Improved Monitors and Viewports minimap display. Highlight on hover. (amends) 2024-02-09 17:28:41 +01:00
ocornut
71bcf350bd Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2024-02-09 17:26:45 +01:00
ocornut
30ba3c347c Viewports: Fixed moving accross monitors when io.ConfigWindowsMoveFromTitleBarOnly is set. (#7299, #3071) 2024-02-09 15:43:25 +01:00
ocornut
59c8db69eb Demo: reorder Demo->Configuration section with docking/viewports section. 2024-02-09 15:27:35 +01:00
ocornut
82eeafc196 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
2024-02-07 22:10:33 +01:00
actboy168
54ef4092a9 Backends: OSX: Fixed not submitting Monitors info when viewports are not enabled. (#7257) 2024-01-24 14:51:04 +01:00
ocornut
eb42e164dd Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_vulkan.cpp
2024-01-22 19:01:25 +01:00
ocornut
01b99a974d Backends: Vulkan: Fixed vkAcquireNextImageKHR() validation errors in VulkanSDK 1.3.275 by allocating one extra semaphore than in-flight frames. (#7236) 2024-01-19 14:50:46 +01:00
ocornut
cab7edd135 Merge branch 'master' into docking
# Conflicts:
#	imgui_internal.h
2024-01-17 18:38:03 +01:00
ocornut
80c83a4277 Docking: added ImGuiDockNodeFlags_DockedWindowsInFocusRoute to configure a dock node to automatically set ParentWindowForFocusRoute on its docked windows. (#6798, #2637, #456) 2024-01-16 14:30:43 +01:00
ocornut
cceff4684a Docking: added ImGuiWindowClass::FocusRouteParentWindowId as a public facing version of SetWindowParentWindowForFocusRoute() (#6798, #2637, #456) 2024-01-16 14:30:42 +01:00
ocornut
69b64e2b73 Internals: Docking: revert 32a3c61 in favor of user explicitely calling SetWindowParentWindowForFocusRoute(). (#6798)
The revert doesn't look the same as 32a3c61 as since then we are baking focus roue into NavFocusScopePath().
2024-01-16 11:50:00 +01:00
ocornut
a27f22f0e9 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_vulkan.cpp
#	imgui.cpp
#	imgui_internal.h
2024-01-16 11:43:36 +01:00
ocornut
32a3c61d00 Internals: Shortcut() follow docking chain (until we formalize a more general focus scope stack). (#456) 2024-01-11 19:48:31 +01:00
ocornut
2dc85e6e43 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui_internal.h
2024-01-10 18:34:23 +01:00
ocornut
cf02023565 Internals, Inputs: Fix for ImGuiInputFlags_RepeatUntilXXX logic when #ifdef IMGUI_DISABLE_OBSOLETE_KEYIO is not set.
Amend 8323a06. Eager to get rid of legacy IMGUI_DISABLE_OBSOLETE_KEYIO stuff: technically it's been two years, may give it another one.
2024-01-09 23:05:53 +01:00
ocornut
ebcfcd8da3 Merge branch 'master' into docking 2024-01-09 22:39:06 +01:00
ocornut
8deb1007cd Backends: OSX: Fixed IME position in multi-monitor/multi-viewports setups. (#7028) 2024-01-09 22:36:01 +01:00
ocornut
a683033e49 Backends: OSX: Fixed monitor and window position by correctly transforming Y origin on multi-monitor setups. (#7028, #7101, #6009, #6432) 2024-01-09 22:21:57 +01:00
ocornut
e3d7cd665d Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_vulkan.cpp
2024-01-03 18:33:44 +01:00
David Maas
2523c197bc
Fixed title bar background alpha being used to render viewport-owned windows. (#7184, #7181) 2023-12-31 00:45:25 +01:00
Kai Wang
20e1caec85 Backends: DX12: Changed swapchain scaling mode to DXGI_SCALING_NONE. (#7152, #7153) 2023-12-21 14:18:43 +01:00
ocornut
4aa81116a5 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	imgui.cpp
2023-12-20 23:57:19 +01:00
ocornut
8add6bcb9f Merge remote-tracking branch 'origin/master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2023-12-14 17:21:15 +01:00
ocornut
96b5b1724b Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_vulkan.cpp
#	imgui_internal.h
2023-12-05 12:20:16 +01:00
ocornut
f6253b87d0 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl3.cpp
#	imgui.cpp
2023-11-28 14:39:46 +01:00
Marc Delorme
e07663d9a1 Docking: transform ImGuiContext* ctx = GImGui to ImGuiContext& g = *GImGui for consistency (#5856) 2023-11-28 14:18:52 +01:00
ocornut
ce0d0ac829 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl3.cpp
#	backends/imgui_impl_vulkan.cpp
#	imgui.cpp
2023-11-15 16:08:53 +01:00
Oliver Eriksson
6695006bea Backends: Vulkan: use specified ColorAttachmentFormat when creating a secondary window when enabling UseDynamicRendering. (#6999, #5446, #5037) 2023-11-15 14:53:32 +01:00
ocornut
0941adc931 Backends: SDL3: Updates for recent API changes. (#7000) (w/ multi-viewports version)
# Conflicts:
#	backends/imgui_impl_sdl3.cpp
2023-11-13 16:24:50 +01:00
ocornut
9d950444a2 Backends: Vulkan: Fixes for VK_NO_PROTOTYPES (docking merge + reorder docking only bits)
Amend for 6e7b43b,79a9e2f
2023-11-10 15:40:41 +01:00
ocornut
450f1d7e7b Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_vulkan.cpp
#	imgui.cpp
2023-11-10 14:56:10 +01:00
ocornut
37ea320b96 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2023-11-07 20:20:41 +01:00
ocornut
208b8242bc Docking: Settings: Fix for loss of settings caused by 9298e31 yesterday. (#6982) 2023-11-03 21:14:19 +01:00
ocornut
4cde40dbe1 Undid some of the changes done by c95fbb4 because they are not compatible with docking code.
(Will cherry-pick this from docking to master)
2023-11-02 18:06:38 +01:00
ocornut
9298e310b2 Merge branch 'master' into docking (note: won't build as-is, see next commit)
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2023-11-02 18:05:43 +01:00
Luca Lolli
04e9a2fac1
Backends: SDL3: rename SDL_EVENT_DISPLAY (#6974)
SDL3 display events have been renamed
2023-11-01 13:53:30 +01:00
ocornut
2a6d7b1eaa Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
2023-10-18 19:45:19 +02:00
ocornut
51d1a72e9b Docking: Revised undocking logic to reduce accidental whole-node undocking:
Amend bb2aa5e77.
Revert to normal threshold in StartMouseMovingWindowOrNode().
Added tooltip when hovering the collapse/window menu button.
2023-10-16 15:56:46 +02:00
ocornut
4521dec85d Docking: Fixed DockNodeBeginAmendTabBar() asserting on first call since ef8ff1b 2023-10-16 15:13:44 +02:00
ocornut
83c4336828 Tables: fixed angled headers with frozen columns. 2023-10-12 19:48:29 +02:00
ocornut
f7fc186408 Merge branch 'master' into docking
+ 2 comments
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	backends/imgui_impl_win32.cpp
2023-10-12 19:22:36 +02:00
ocornut
72ebd91567 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	imgui.h
2023-10-05 15:10:45 +02:00
ocornut
9064dbd404 Backends: DX9: Fixed incorrect assert triggering on reopening session with minimized windows. (#3424) 2023-10-02 15:28:22 +02:00
ocornut
d27b4ad366 Backends: GLFW: support for case where secondary viewport WndProc is not the same as main viewport one. (#6889) 2023-10-02 12:09:13 +02:00
ocornut
17bfafda55 Backends: GLFW: moved WndProc hook to bottom of file + rename a field. (#6889)
No functional change in this commit.
2023-10-02 12:09:08 +02:00
ocornut
ff534b0d0a Docking: Fixed a bug where ClassId compare tests (when using SetNextWindowClass) on success would prevent further filter from running. (#6882) 2023-10-02 10:57:22 +02:00
ocornut
f8aed6499f Debug Tools: Rename ShowIdStackToolWindow() -> ShowIDStackToolWindow(). (#4631)
Squashed of 2 master commits.
2023-09-28 20:16:13 +02:00
ocornut
b7c250925f Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2023-09-27 18:21:39 +02:00
ocornut
bb2fb74645 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
2023-09-26 11:42:49 +02:00
ocornut
c418685315 Fixed window inner clipping rectangle off by one when window is located on a monitor with negative coordinates. (#6861, #2884) 2023-09-25 20:45:34 +02:00
ocornut
2c0007731f Docking: fixed calling DockContextCalcDropPosForDocking() with window in node without passing its node. 2023-09-20 17:27:55 +02:00
ocornut
61acb34e32 Docking: Fixed an issue leading to incorrect restoration of selected tab in dock nodes that don't carry the currently focused window. (#2304)
In TestSuite: see "docking_tab_focus_restore".
Remove old code ~ ed3c015f 8bac6d4 8cac70d8
+ Fix potential crash in IMGUI_DEBUG_LOG_DOCKING() path when using amended buttons.
2023-09-20 14:43:47 +02:00
ocornut
3ce6b06feb Merge branch 'master' into docking 2023-09-20 12:53:35 +02:00
ocornut
64b1e448d2 TabBar, Style: added style.TabBarBorderSize and associated ImGuiStyleVar_TabBarBorderSize. (#6820, #4859, #5022, #5239)
Removed ImGuiTabItemFlags_Preview. Will need cherry-picking in master.
2023-09-18 15:28:44 +02:00
ocornut
ac3bc73c13 Docking: Fixed node tab-bar not having a filled value for tab-bar which is required for claiming moue wheel ownership in (unenabled) ImGuiTabBarFlags_FittingPolicyScroll mode.
Amend 5f30191
2023-09-18 14:32:23 +02:00
ocornut
afd0d3fca1 Docking: made ImGuiDockNodeFlags_NoUndocking public. (#2999, #6823, #6780, #3492)
Amend 1612813.
2023-09-18 12:41:18 +02:00
ocornut
72d760ba00 Docking: (Breaking) renamed ImGuiDockNodeFlags_NoDockingInCentralNode -> ImGuiDockNodeFlags_NoDockingOverCentralNode, ImGuiDockNodeFlags_NoSplit -> ImGuiDockNodeFlags_NoDockingSplit.
Shuffled other internal flags and added comments.
2023-09-18 12:27:29 +02:00
ocornut
f693c3d806 Docking: made "ImGuiDockNodeFlags_NoDocking" a combination of all others ImGuiDockNodeFlags_NoDockingXXX flags. (#2999, #6823, #6780, #3492) 2023-09-18 11:27:44 +02:00
ocornut
7e246a7bb9 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2023-09-16 13:51:51 +02:00
ocornut
1612813114 Docking: Internals: added ImGuiDockNodeFlags_NoUndocking. (#2999, #6823, #6780) 2023-09-15 20:44:26 +02:00
ocornut
14f8b76c1a Docking: Comments. Removed misleading shared/local identicators. (#6823, #2999)
NoDocking not marked as saved (it never was). Removed unused ImGuiDockNodeFlags_LocalFlagsMask_.
2023-09-15 20:44:15 +02:00
ocornut
72dbe45adc Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
2023-09-08 18:02:06 +02:00
ocornut
1d8e48c161 Using range-based for where it makes sense. (#4537)
Amend 82d177c
2023-09-04 15:13:12 +02:00
ocornut
a1b60fc1f5 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
2023-09-04 14:59:59 +02:00
ocornut
300464a487 Docking: when io.ConfigDockingWithShift is enabled, staying stationary while moving a window displays an help tooltip to increase affordance. (#6709, #4643)
Hope this doesn't feel spammy?
2023-08-30 17:45:06 +02:00
ocornut
7d6e83efca Docking: Fixed non-root dockspace not having their background rendered properly.
Fix f422e78. Fuller version of 08b3a1a pushed in master.
2023-08-30 15:26:46 +02:00
ocornut
762ec445e6 Docking: Fixed bad bug, dock node host wouldn't merge background. (#6753, #6716)
Fixes f422e78. Didn't crash because g.Windows[] is always larger than g.WindowsFocusOrder[].
2023-08-28 11:25:50 +02:00
ocornut
475453668d Backends: SDL2/SDL3: Fixed bad merge in docking branch (#6735) 2023-08-26 11:45:21 +02:00
ocornut
61d35972e2 CloseButton, CollapseButton: don't include FramePadding into size. Use ItemInnerSpacing.x between title bar buttons. Amend for Docking. (#6749) 2023-08-25 14:29:42 +02:00
ocornut
676497fe05 Merge branch 'master' into docking
ac64b65 on master seemed incorrect.

# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2023-08-25 14:20:51 +02:00
ocornut
1161301386 Backends: amend "Missing features" sections for multi-viewports support. 2023-08-15 13:02:56 +02:00
ocornut
f422e7826f ImDrawData: Fixed an issue where TotalVtxCount/TotalIdxCount does not match the sum of individual ImDrawList's buffer sizes. (#6716)
Amend dbeeeae59
2023-08-14 16:12:15 +02:00
ocornut
63b6300c39 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2023-08-08 14:16:13 +02:00
ocornut
f8704cd085 Merge branch 'master' into docking 2023-08-01 13:11:26 +02:00
ocornut
30594c37d0 Merge branch 'master' into docking 2023-08-01 10:22:21 +02:00
ocornut
f8f805f046 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_dx10.cpp
#	backends/imgui_impl_dx11.cpp
#	backends/imgui_impl_dx12.cpp
#	backends/imgui_impl_dx9.cpp
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_opengl2.cpp
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	backends/imgui_impl_vulkan.cpp
#	backends/imgui_impl_win32.cpp
2023-07-20 23:18:47 +02:00
ocornut
07d1709ca2 Doc: removed "generic" docking/viewport branch section of changelog since this is misleading. Will add formally when we reelase. (#2109, #1542) 2023-07-13 11:45:39 +02:00
ocornut
023e59a5f2 ImDrawData: call _PopUnusedDrawCmd() later. as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch). (#6406, #4879, #1878)
Amend/fix dbeeeae for docking.
+ Build fix when using IMGUI_DISABLE_DEBUG_TOOLS
2023-07-12 18:40:04 +02:00
ocornut
0110f4c8cc Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2023-07-12 18:19:24 +02:00
ocornut
51b348095c Docking, Style: resizing separators use same colors as window borders. (#2522) 2023-07-11 15:17:54 +02:00
ocornut
f4942bca32 Docking: follow to 27c735e to fix rendering of docked-window scrollbar above outer border. (#2522) 2023-07-11 15:01:20 +02:00
ocornut
27c735e3e9 Scrollbar: layout needs to take account of window border size, so a border size will slightly reduce scrollbar size. (#2522)
Rework/revert intent of c1a61d25a.
2023-07-11 15:00:51 +02:00
ocornut
f6feddd1ee Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2023-07-11 12:44:15 +02:00
ocornut
b79751ebad Docking: Added DockingSeparatorSize to style: amends (#3481, #4721, #2522)
Add ImGuiStyleVar_DockingSeparatorSize + misc Docking related comments.
2023-07-11 12:43:50 +02:00
PossiblyAShrub
a5aff5fd3e Docking: Added DockingSeparatorSize to style (#3481, #4721, #2522)
(DockingSplitterSize in current commit, about to be renamed)
2023-07-11 12:37:40 +02:00
ohthesetrees
8566fec661
Backends: SDL3: Changing SDL_WINDOW_SKIP_TASKBAR to SDL_WINDOW_UTILITY for SDL3 (#6573) 2023-07-05 11:01:56 +02:00
ocornut
dc3e531ff2 Merge branch 'master' into docking 2023-07-04 16:22:25 +02:00
sean
ac8573884d Backends: Vulkan: Amends for docking branch. (#5446, #5037) 2023-07-04 15:02:21 +02:00
ocornut
677c7b2258 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_vulkan.cpp
#	docs/CHANGELOG.txt
#	docs/TODO.txt
2023-07-04 14:58:03 +02:00
ocornut
a88e5be7f4 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_widgets.cpp
2023-06-28 14:56:33 +02:00
ocornut
6b01114057 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
2023-06-23 16:04:13 +02:00
ocornut
057fcae30c Docking+Viewports: Fixed extraneous viewport+platform-window recreation. Part 4.
Part 4: store reference viewport id from last visible single window stored in node. So Win1 -> Win1|Win2 can reuse viewport on split.
Refer to "viewport_owner_change_1" and "viewport_owner_change_2" in ImGuiTestSuite.
2023-06-23 16:03:01 +02:00
ocornut
35b41949fb Docking+Viewports: Fixed extraneous viewport+platform-window recreation. Part 3.
Part 3: DockNodeRemoveWindow() clears viewports so it doesn't get bounced back and forth.
Note that in case of called from e.g. dock builder this can happen mid-frame. Clearing Viewport here isn't well exercised yet. If window doesn't get a Begin() in same-frame it'll be hidden.
Refer to "viewport_owner_change_1" and "viewport_owner_change_2" in ImGuiTestSuite.
Amend 6b77668171
2023-06-23 15:55:14 +02:00
ocornut
099e8533e2 Docking+Viewports: Fixed extraneous viewport+platform-window recreation. Part 2.
Part 2: Fixed various transfer cases.
Refer to "viewport_owner_change_1" and "viewport_owner_change_2" in ImGuiTestSuite.
2023-06-23 15:51:43 +02:00
ocornut
66c09fc05b Docking+Viewports: Fixed extraneous viewport+platform-window recreation. Part 1.
Part 1: Add counters. Amend logs.
Refer to "viewport_owner_change_1" and "viewport_owner_change_2" in ImGuiTestSuite.
2023-06-23 15:49:45 +02:00
ocornut
7d81a166f9 Docking: Fixed one-frame flickering on reappearing windows binding to a dock node where a later-submitted window was already bound. 2023-06-23 15:49:45 +02:00
ocornut
e4aeef4b9f Viewports: Closing a viewport via OS/platform means (e.g. OS close button or task-bar menu), mark all windows in this viewport as closed. 2023-06-21 15:34:51 +02:00
ocornut
1450d23b60 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	docs/CHANGELOG.txt
#	imgui.cpp
2023-06-20 15:12:09 +02:00
ocornut
b9db5c566b Backends: Win32: Added support for updating ParentViewportID after viewport creation.
This tends to be desirable for applicaton manipulating this value via ImGuiWindowClass::ParentViewportID.
I thought it would be a simple call to SetParent(), it's only slightly more complicated but added comments about it.
2023-06-15 11:26:27 +02:00
ocornut
ef07ddf087 Debug Tools: Added 'io.ConfigDebugIniSettings' option to save .ini data with extra comments.
Moved from compile-time to runtime flag. Applied docking specific change to this cherry-picked commit.

# Conflicts:
#	docs/CHANGELOG.txt
2023-06-13 11:55:21 +02:00
ocornut
fa5d2656b0 Docking: DockBuilderDockWindow() API calls don't clear docking order if the target node is same as existing one
+ Add more debug log + Display DockOrder in metrics.
2023-06-13 11:37:35 +02:00
ocornut
3f63cee4c1 Docking: Fixed dragging from title-bar empty space (#5181, #2645)
This would need a test in ImGuiTestSuite.
2023-06-12 15:33:20 +02:00
ocornut
0664877998 Merge branch 'master' into docking 2023-06-09 14:02:19 +02:00
Luca Lolli
8fd0a04135
Backends: SDL3: Fix backend in docking/multi-viewports branch. (#6483)
The definition has been renamed to SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED.
Display scale is no longer available in SDL_DisplayMode but can be retrieved using SDL_GetDisplayContentScale.
2023-06-01 11:30:26 +02:00
ocornut
823a1385a2 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdlrenderer.h
#	docs/CHANGELOG.txt
#	imgui.cpp
2023-05-31 14:51:56 +02:00
ocornut
3418d50949 Viewports: Fixes erroneous popup closure on closing a previous popup. (#6462, #6299)
Avoid applying imgui-side focus when focus change is due to a viewport destruction.
2023-05-30 17:09:27 +02:00
S41L0R
f0f3b927e0
Backends: GLFW: Avoid linking with GLFW function for homebrew switch (#6473) 2023-05-30 10:27:21 +02:00
slowriot
6cc967a124
Backends: GLFW: Only enable Vulkan support if not building with Emscripten (#6468) 2023-05-28 18:08:06 +02:00
omar
2e810d575c
Backends: GLFW: Fix breaking typo 19b436f68 (#5683, #6459) 2023-05-26 13:41:45 +02:00
ocornut
19b436f68d Backends: GLFW: Preserve monitor list when there are no monitor. (#5683) 2023-05-25 15:38:35 +02:00
ocornut
54c1ac3e38 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2023-05-22 10:10:29 +02:00
ocornut
e590b5114e Viewports: Fixed loss of imgui-side focus when dragging a secondary viewport back in main viewport. (#6299)
Amend d2291df55, 63370be0e, dcb6335bfe
2023-05-20 14:22:01 +02:00
ocornut
530134d125 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_metal.mm
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl3.cpp
#	imgui.cpp
2023-05-10 12:57:37 +02:00
ocornut
031148dc56 Fixed bad merge. 2023-04-25 16:30:31 +02:00
ocornut
594cc4793a Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2023-04-25 12:21:16 +02:00
ocornut
d2291df551 Viewports: Fixed setting focus from platform decoration from accidentally closing modals (#6299, #6357)
+ Fixed double-assignment static analyzer warning.

# Conflicts:
#	imgui.cpp
2023-04-21 19:22:41 +02:00
ocornut
bba39762dc Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2023-04-21 19:12:11 +02:00
ocornut
ac38c8e6fe IO: removed ImGuiBackendFlags_HasMouseHoveredViewport assert in AddMouseViewportEvent().
In theory shouldn't accept them, but a backend overriding another would be prevented from doing so because of this (test engine).
2023-04-21 18:01:18 +02:00
ocornut
c11128891e Backends: SDL2/SDL3: Update monitor list when receiving a display event. (#6348) 2023-04-21 15:40:14 +02:00
ocornut
adf693c061 Viewports: added void* ImGuiPlatformMonitor::PlatformHandle field (backend-dependant). 2023-04-21 15:31:14 +02:00
ocornut
07e07030a6 Backends: Win32: revert accidental deletion of ImGui_ImplWin32_EnableAlphaCompositing() in a566ecc (#3218)
This was still in docking, but moved back in upper locaton.
# Conflicts:
#	backends/imgui_impl_win32.cpp
2023-04-20 10:41:03 +02:00
ocornut
88ac2ced7c Backends: DX10: Fixed typo in previous commit. 2023-04-19 17:18:04 +02:00
ocornut
f498f084d6 Examples: Amend Win32/Winapi + OpenGL example for multi-viewport. (#3218, #5170 and #6086, #2772, #2600, #2359, #2022, #1553) 2023-04-19 16:48:07 +02:00
Mark Jansen
4bc51c6ff4 Examples: Extend Win32/Winapi + OpenGL example for multi-viewport. (#3218, #5170 and #6086, #2772, #2600, #2359, #2022, #1553) 2023-04-19 16:46:54 +02:00
ocornut
1f2b84a654 Backends: clear viewport specific bits in io.BackendFlags on backend Shutdown(). (#6334)
Amend 055e715
2023-04-19 16:40:18 +02:00
ocornut
4f692ba840 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_metal.mm
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_win32.cpp
#	docs/CHANGELOG.txt
2023-04-19 16:35:50 +02:00
ocornut
0ea3b87bd6 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui_internal.h
2023-04-13 16:24:09 +02:00
ocornut
bed11b35d1 Fix typos and use nullptr in backends. Amend 506f7e0 2023-04-11 16:20:17 +02:00
ocornut
aec062a8a5 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	docs/CHANGELOG.txt
#	examples/example_win32_directx9/main.cpp
#	imgui_internal.h
2023-04-11 16:16:17 +02:00
ocornut
1668693bcf Backends: SDL2/SDL3: Fixed IME text input rectangle position with viewports. (#6071, #1953) 2023-04-06 19:18:15 +02:00
ocornut
ec461c6ccb Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	imgui_demo.cpp
2023-04-06 19:16:08 +02:00
ocornut
63370be0e5 Viewports: fix/amend dcb6335 to (1) avoid refocusing when focus action was actionned from a click within imgui boundaries and (2) restore a null focus as well. (#6299) 2023-04-06 16:29:36 +02:00
ocornut
1f0b46b93c Viewports: moved Platform_GetWindowFocus queries in UpdateViewportsNewFrame(). Added ImGuiViewportFlags_IsFocused status flag. (#1542)
Not sure why queries were in UpdatePlatformWindows().
- initially added there on 2018/04/26 f1ae07e532 (squashed)
- slightly moved in cd51f37fc0 for the purpose of putting less constraint on backend but that check is now done on our side anyhow.
Seems more consistent to do it nxt to other polling in UpdateViewportsNewFrame().
Not using ImGuiViewportFlags_IsFocused yet.
2023-04-06 16:08:53 +02:00
ocornut
ed72fcd12a Viewports: Internal: rename LastFrontMostStampCount -> LastFocusedStampCount. Rename ImGuiViewportFlags_Minimized -> ImGuiViewportFlags_IsMinimized
Effectively it is currently the later, but see comment "Even without focus, we assume the window becomes front-most." in UpdatePlatformWindows().
+ Moved Window field at top since it is most useful.
2023-04-06 15:17:52 +02:00
ocornut
dcb6335bfe Viewports: Setting focus from Platform/OS sets corresponding focus at Dear ImGui level. (#6299) 2023-04-05 20:25:05 +02:00
ocornut
ee5ce36745 Merge branch 'master' into docking, including specific merge for imgui_impl_glfw.cpp for f070497
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	backends/imgui_impl_win32.cpp
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2023-04-04 21:17:47 +02:00
ocornut
4fdafef54f Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl2.cpp
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	docs/CHANGELOG.txt
#	imgui_widgets.cpp
2023-03-29 18:41:41 +02:00
ocornut
bf87fbcbcc Docking: Fixed using GetItemXXX() or IsItemXXX() functions after a DockSpace(). (#6217) 2023-03-22 18:58:32 +01:00
ocornut
ad44f5831a Merge branch 'master' into docking 2023-03-21 17:04:54 +01:00
Bruno Perković
5320a6ebd3 Backends: Made SDL3 backend compatible with commit 698dbd8. (#6255, #6146) 2023-03-21 12:17:54 +01:00
ocornut
6b3435a2db Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_opengl3.cpp
#	docs/CHANGELOG.txt
2023-03-16 12:01:13 +01:00
ocornut
85beda96de Backends: GLFW: Fix Emscripten erroneously enabling multi-viewport support, leading to assert. (#5683) 2023-03-15 14:51:46 +01:00
ocornut
9e30fb0ec1 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	docs/CHANGELOG.txt
#	imgui.cpp
2023-03-14 16:38:22 +01:00
ocornut
9937660b1c Merge branch 'master' into docking
# Conflicts:
#	examples/example_allegro5/main.cpp
#	examples/example_apple_metal/main.mm
#	examples/example_apple_opengl2/main.mm
#	examples/example_glfw_metal/main.mm
#	examples/example_glfw_opengl2/main.cpp
#	examples/example_glfw_opengl3/main.cpp
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_glut_opengl2/main.cpp
#	examples/example_sdl2_directx11/main.cpp
#	examples/example_sdl2_metal/main.mm
#	examples/example_sdl2_opengl2/main.cpp
#	examples/example_sdl2_opengl3/main.cpp
#	examples/example_sdl2_vulkan/main.cpp
#	examples/example_sdl3_opengl3/main.cpp
#	examples/example_win32_directx10/main.cpp
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx12/main.cpp
#	examples/example_win32_directx9/main.cpp
#	imgui.cpp
2023-03-10 18:40:04 +01:00
ocornut
e2cede6542 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2023-03-08 17:41:32 +01:00
ocornut
f5c5a710aa Docking: exposed DockNodeWindowMenuHandler_Default() in imgui_internal.h to facilitate reuse. 2023-03-06 17:08:09 +01:00
ocornut
4078abe14c Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	imgui.cpp
#	imgui.h
2023-03-06 17:03:55 +01:00
ocornut
702626dd8a Docking: storing window menu handler in a function pointer to allow customizing menu (undocumented) 2023-03-06 16:59:57 +01:00
ocornut
e25e4526cd Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_win32.cpp
#	docs/CHANGELOG.txt
2023-02-15 18:18:47 +01:00
ocornut
192196711a Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2023-02-14 16:01:11 +01:00
ocornut
345184330b Internals: Settings: amend ClearWindowSettings() for Docking. 2023-02-10 18:28:45 +01:00
ocornut
ea4565368e Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl2.h
#	backends/imgui_impl_sdl3.cpp
#	backends/imgui_impl_sdl3.h
#	imgui.cpp
2023-02-10 17:05:06 +01:00
ocornut
0d7d877cb5 Backends: SDL3: Update for latest.
Note that resizing secondary viewports seems broken.
2023-02-10 14:45:52 +01:00
ocornut
95412ad3a5 Backends: SDL3: Removed unnecessary #ifdef. 2023-02-07 17:09:51 +01:00
ocornut
a526ff8c30 Backends: SDL3: Added multi-viewports support. (#6146) 2023-02-07 16:30:58 +01:00
ocornut
e4233c6fb6 Merge branch 'master' into docking (doesn't include viewports-related changes for new SDL3 backend)
# Conflicts:
#	backends/imgui_impl_dx10.cpp
#	backends/imgui_impl_dx10.h
#	backends/imgui_impl_dx11.cpp
#	backends/imgui_impl_dx11.h
#	backends/imgui_impl_dx12.cpp
#	backends/imgui_impl_dx12.h
#	backends/imgui_impl_dx9.cpp
#	backends/imgui_impl_dx9.h
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_metal.h
#	backends/imgui_impl_metal.mm
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_opengl3.h
#	backends/imgui_impl_osx.h
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdlrenderer.cpp
#	backends/imgui_impl_sdlrenderer.h
#	backends/imgui_impl_vulkan.cpp
#	backends/imgui_impl_vulkan.h
#	backends/imgui_impl_win32.cpp
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui_widgets.cpp
2023-02-07 16:23:49 +01:00
ocornut
c807192abc Tables: amend f799a29 with a better solution + fix potential overflow (#6140) 2023-02-03 22:50:58 +01:00
ocornut
b0a936e5d4 Merge branch 'master' into docking (incl revert of examples refactor)
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
#	examples/example_glfw_opengl2/main.cpp
#	examples/example_glfw_opengl3/main.cpp
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_sdl_directx11/main.cpp
#	examples/example_sdl_opengl2/main.cpp
#	examples/example_sdl_opengl3/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	examples/example_win32_directx10/main.cpp
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx12/main.cpp
#	examples/example_win32_directx9/main.cpp
2023-02-03 22:38:39 +01:00
ocornut
97a1f761c6 Examples: (Again, but better) made SDL+GL and GLFW+GL examples build with Emscripten. (#2492, #2494, #3699, #3705) 2023-02-03 22:23:23 +01:00
ocornut
5ebb6a2954 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
2023-02-02 19:38:24 +01:00
ocornut
5386ddcd05 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
#	examples/example_emscripten_opengl3/main.cpp
#	examples/example_glfw_opengl2/main.cpp
#	examples/example_glfw_opengl3/main.cpp
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_glut_opengl2/main.cpp
#	examples/example_sdl_directx11/main.cpp
#	examples/example_sdl_opengl2/main.cpp
#	examples/example_sdl_opengl3/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	examples/example_win32_directx10/main.cpp
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx12/main.cpp
#	examples/example_win32_directx9/main.cpp
#	imgui_demo.cpp
2023-02-02 18:31:26 +01:00
ocornut
887abe9578 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
#	imgui_widgets.cpp
2023-02-01 22:18:57 +01:00
ocornut
88dfd85e92 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2023-01-21 00:49:06 +01:00
Cody Tapscott
6342275bbb Backends: GLFW: Handle unsupported glfwGetVideoMode() for Emscripten. (#6096)
This is used to populate the monitor array, which is only a requirement for multi-viewport support (which is not supported by Emscripten anyway).
2023-01-20 17:04:55 +01:00
ocornut
d822c65317 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	docs/CHANGELOG.txt
2023-01-05 15:58:49 +01:00
ocornut
fc3815bfe5 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_vulkan.cpp
2023-01-03 21:06:09 +01:00
ocornut
824baa6a4d Docking: fixed DockSpace() with ImGuiDockNodeFlags_KeepAliveOnly marking current window as written to,. (#6037) 2023-01-03 14:22:07 +01:00
ocornut
42e166089a Backends: Metal: fixed secondary viewport rendering. (#6015, #4821, #2778) 2023-01-03 12:34:47 +01:00
ocornut
6939676372 Docking: fixed DockBuilderCopyDockSpace() crashing when windows not in the remapping list are docked on the left or top side of a split. (#6035) 2023-01-02 17:54:50 +01:00
Mikko Sivulainen
16aaf60697 Backends: OSX: fixed ImGui_ImplOSX_GetWindowSize and ConvertNSRect. (#6009) 2023-01-02 15:38:40 +01:00
ocornut
90de839445 Backends: SDL: fix build on WinRT (#6019, #5974) - version for docking branch
Amend da83253
2023-01-02 15:03:18 +01:00
ocornut
c191faf0ba Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
#	imgui_widgets.cpp
2022-12-08 21:19:01 +01:00
ocornut
d3025cde37 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2022-12-06 22:13:12 +01:00
ocornut
5eda547e6f Merge branch 'master' into docking 2022-12-06 15:10:09 +01:00
ocornut
3ea0fad204 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui.h
2022-12-01 20:22:27 +01:00
ocornut
540909bddf Fixed version string for consistency (#5918) 2022-11-28 14:42:37 +01:00
ocornut
fad8afd62a Docking: amend to allow localizing docking specific user facing string. (#5895) 2022-11-24 21:29:41 +01:00
ocornut
595a428baa Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui_internal.h
2022-11-24 21:27:15 +01:00
ocornut
d2f9c5dfb7 Viewports: moving PlatformWindowCreated field to public structure. (#5882) 2022-11-24 16:39:45 +01:00
ocornut
9964740a47 Viewport: Fixed collapsed windows setting ImGuiViewportFlags_NoRendererClear without making title bar color opaque.
(thanks christopher knorr!)
2022-11-18 19:34:24 +01:00
ocornut
38cfe22b8b Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2022-11-16 17:57:05 +01:00
ocornut
94e850fd6f Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2022-11-15 15:40:54 +01:00
ocornut
d7aca168ee Backends: SDL: Fixed drag'n drop crossing a viewport border losing mouse coordinates. (#5710, #5012)
Amend 51bbc7065
2022-11-10 16:22:34 +01:00
ocornut
a571933f8b Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
2022-11-09 15:59:26 +01:00
ocornut
4d5da74c79 Merge branch 'master' into docking 2022-11-08 20:44:04 +01:00
ocornut
5728f2e15f Fix build with IMGUI_DISABLE_DEBUG_TOOLS 2022-11-04 16:47:04 +01:00
ocornut
849c8052b7 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui_internal.h
2022-11-04 16:26:15 +01:00
cfillion
ced92d9c52 Inputs, Viewports: fix UpdateViewportsNewFrame() running before UpdateInputEvents(), leading to MouseViewport lagging by a frame on transitions. (#5837, #4921)
Will merge the swap in master.
2022-10-31 12:08:23 +01:00
ocornut
375ae5dce4 Merge branch 'master' into docking (incl glfw use of GLFW_VERSION_COMBINED)
Note switched from GLFW_VERSION_REVISION * 10 to GLFW_VERSION_REVISION * 1
2022-10-24 22:58:25 +02:00
ocornut
50c4234aca Docking: Further fixes for highlight of nested nodes. (#5702)
Amend fb0b9c71, 8f43487, 9764adc, 24dfebf
Added more regression tests e.g "docking_focus_nodes_nested"
2022-10-24 20:34:03 +02:00
ocornut
5370b46c4e Docking: Made spacing between dock nodes not a dropping gap. 2022-10-24 20:25:42 +02:00
ocornut
f87e891f18 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2022-10-14 18:50:40 +02:00
ocornut
edf522b58a Merge branch 'master' into docking + amends change to nullptr (#5760)
# Conflicts:
#	backends/imgui_impl_dx10.cpp
#	backends/imgui_impl_dx11.cpp
#	backends/imgui_impl_dx12.cpp
#	backends/imgui_impl_dx9.cpp
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_opengl2.cpp
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_vulkan.cpp
#	backends/imgui_impl_win32.cpp
#	imgui_internal.h
2022-10-11 15:59:23 +02:00
ocornut
cb04326b46 Fixed ImGuiWindowFlags_UnsavedDocument clipping label in docked windows with no close button. [changes for docking] (#5745)
+ TabBar: starts displaying the unsaved document marker with a frame delay to match how close button is processed, otherwise the transition would be noticeable.
2022-10-04 18:08:29 +02:00
ocornut
fb0b9c7160 Docking: Fixed missing highlight when using dock node host window borders. (#5702)
Amend 8f434874, 9764adc7b, 24dfebf45
2022-10-03 14:55:22 +02:00
ocornut
69beaa1d0b Viewports: Fix AddMouseViewportEvent() to honor AppAcceptingEvents, filter duplicate, add to debug log. 2022-09-29 22:03:21 +02:00
ocornut
d91211f9f2 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_win32.cpp
2022-09-29 22:02:23 +02:00
ocornut
11f5be0caf Backends: OpenGL: Add ability to #define IMGUI_IMPL_OPENGL_DEBUG. (#4468, #4825, #4832, #5127, #5655, #5709)
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
2022-09-27 14:40:18 +02:00
ocornut
8f434874c0 Docking: Fixed incorrect focus highlight on docking node when focusing a menu. (#5702) 2022-09-26 15:56:54 +02:00
ocornut
6fd2ee9416 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdl.cpp
#	imgui_demo.cpp
2022-09-26 14:57:34 +02:00
ocornut
1dc7d0e633 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
2022-09-26 11:08:49 +02:00
ocornut
3af9ac320d Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_examples.sln
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
2022-09-17 00:25:42 +02:00
ocornut
64b88da21b Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui.h
2022-09-09 20:48:57 +02:00
ocornut
caf4b7f1e6 Backends: SDL: Fixed building backend under non-OSX Apple targets (e.g. iPhone). (#5665) 2022-09-09 16:45:16 +02:00
ocornut
aceab9a877 Obsoleted using SetCursorPos()/SetCursorScreenPos() to extend parent window/cell boundaries. (#5548)
This incorrect pattern has been mentioned or suggested in: #4510, #3355, #1760, #1490, #4152, #150

# Conflicts:
#	imgui.cpp
2022-09-02 16:38:40 +02:00
ocornut
bc2002ab92 Merge branch 'master' into docking 2022-09-01 20:54:37 +02:00
ocornut
71a0701920 Nav: Fixed regression in e99c4fc preventing CTR+Tab to work without NavEnableKeyboard (#5504, #4023); 2022-08-24 15:49:03 +02:00
ocornut
db798fd5be Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_metal.mm
#	imgui.cpp
#	imgui_internal.h
2022-08-23 18:41:24 +02:00
ocornut
b78738ff23 Internals: Docking: rename HoveredDockNode to DebugHoveredDockNode to clarify that it isn't usable for much other than debugging. 2022-08-22 19:18:06 +02:00
Rokas Kupstys
8cbd391f09 Docking: Add source dock node parameter DockContextCalcDropPosForDocking() to facilitate test engine (un)docking nodes before they are split out to their own window.
Metrics: Display dock_node->Windows in node metrics.
2022-08-08 15:33:19 +02:00
Rokas Kupstys
ff1567e240 Docking: Simplify logic of moving tabs between nodes. Amends 0abe7d. (#5515)
The idea is that in the absence of a tab bar, as new one gets created new tabs will be sorted based on window->DockOrder so this may work but we're not 100% sure.
2022-08-05 12:39:47 +02:00
ocornut
e9f50fb87c Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2022-08-03 22:04:03 +02:00
Rokas Kupstys
f573ebf31a Docking+Viewports: Fix undocking window node causing parent viewport to become unresponsive. (#5503)
Amend 67be485e, Somehow ties to 58f5092c + 0eb45a05 (#4310)
Unsure of exact chain of event but this caused a parent link msimatch between the time of the MouseMoving test in AddUpdateViewport() setting _NoInputs on the wrong parent., and the release clearing _NoInputs on the rght one.
2022-08-03 18:07:08 +02:00
ocornut
b12e056c21 Docking: Fixed amending into an existing tab bar from rendering invisible items. (#5515, amend b16f738d #2700, #2539)
Commit b16f738d left us with a "current" channel 0 which seems inadequate. Undoing that, assuming default is always 1, code filling bg color does a switch. Only DockContextEndFrame() leave it at 0 and it's not particularly necessary.
2022-08-03 17:00:59 +02:00
ocornut
0abe7d1cc5 Docking: Fixed splitting/docking into a node that has buttons amended into tab bar. Windows were not moved correctly. (#5515) 2022-08-03 16:11:39 +02:00
ocornut
e21f462f6f Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2022-08-03 15:29:04 +02:00
ocornut
28a123ca47 Internals: Docking: make DockContextFindNodeByID() more visible (instead of DockBuilderGetNode)
+ using defines for channel changes.
2022-08-03 15:22:19 +02:00
Rokas Kupstys
cb8ead1f71 Docking: Fix docked window contents not rendering when switching with CTRL+Tab.
(regression from 8eb8689).
2022-07-18 15:25:46 -07:00
ocornut
77637fd936 Docking, Nav: Fixed using gamepad/keyboard navigation not being able enter menu layer (#5463, #4792)
Fix 37958ca
2022-07-12 10:51:14 +02:00
ocornut
21fc57f2cf Merge branch 'master' into docking 2022-07-08 16:09:30 +02:00
Stephen H. Gerstacker
ad5aa54166 Backends, Viewport: Metal: Pull format from shared context. (#5403, #5437) 2022-06-30 20:19:27 +02:00
ocornut
5d0deebba4 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2022-06-30 20:17:48 +02:00
Runik
58eb40db76 Backends: GLFW: Fixed leftover static variable preventing from changing or reinitializing backend while application is running. (#4616, #5434) 2022-06-29 15:47:37 +02:00
ocornut
9cd9c2eff9 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui_widgets.cpp
2022-06-21 18:28:33 +02:00
ocornut
9764adc7bb Docking: Amend 24dfebf. Fixed incorrect focus highlight on docking node with nested hierarchies. 2022-06-17 17:11:23 +02:00
ocornut
506717390f Docking, Modal: Fixed a crash when opening popup from a parent which is being docked on the same frame. (#5401)
Ideally we should untangle the purpose of parent_window_in_stack / ParentWindowInBeginStack better.
2022-06-16 18:43:33 +02:00
rokups
101aec95d9 Backends: SDL+GLFW, Examples: SDL+Metal, GLFW+Metal: Fix viewport support with Metal backend.
Fixes #5392 + alignment fixes and removed static_cast<> + Amended with fix.
2022-06-16 13:12:54 +02:00
ocornut
e135cdbc24 Merge branch 'master' into docking + update for IMGUI_DEBUG_LOG calls.
# Conflicts:
#	backends/imgui_impl_dx12.cpp
#	imgui.cpp
#	imgui_internal.h
2022-06-15 15:39:23 +02:00
ocornut
24dfebf455 Docking: Fixed incorrect focus highlight on docking node when focusing empty central node or a child window which was manually injected into a dockspace window. 2022-06-13 20:19:33 +02:00
ocornut
e900ca355e Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_metal.mm
#	imgui.cpp
#	imgui.h
2022-06-10 19:29:17 +02:00
Andrej Redeky
4789c7e485
Misc: Fix custom assertion macro failing to compile imgui.cpp (#5378) 2022-06-05 13:34:10 +02:00
ocornut
7b5a8e4f2b Merge branch 'master' into docking (wanted for #4468, #3381, #2981, #4825, #4832, #5127)
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
2022-05-30 15:26:12 +02:00
Rokas Kupstys
250333d895 Docking: Fix unhiding tab bar regression. (#5325, #5181)
Broken by 90386780
2022-05-19 16:59:39 +02:00
Rokas Kupstys
36055213c5 Docking: Fixed moving window being interrupted when undocing a window with "io.ConfigDockingAlwaysTabBar = true". (#5324)
Regression introduced in 6b7766817
2022-05-19 16:54:54 +02:00
ocornut
6b5a2426d7 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_metal.mm
#	backends/imgui_impl_opengl3.cpp
#	imgui.cpp
2022-05-17 11:59:32 +02:00
omar
2fa60bec27
Examples: Apple+OpenGL: Fix build. 2022-05-09 11:30:52 +02:00
omar
693b4c57fe
Backends: OSX: Implement ImGui_ImplOSX_ShowWindow(). (#5299) 2022-05-09 10:45:56 +02:00
ocornut
d666a1d473 Backends: OSX, Metal: Amend d111133, tidying up, remove unused, misc tweaks. . (#4821, #2778) 2022-05-03 18:14:10 +02:00
stuartcarnie
6868d11669 Backends: OSX, Metal: Added multi-viewports support. (#4821, #2778) 2022-05-03 18:14:07 +02:00
ocornut
414165d23f Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	imgui.cpp
2022-05-03 14:40:17 +02:00
Dima Koltun
ec48681455 Windows: Fixed first-time windows appearing in negative coordinates. (#5215, #3414)
Regression added in 6af92b05b
2022-04-22 20:26:40 +02:00
ocornut
8dd5425182 Merge branch 'master' into docking
# Conflicts:
#	docs/TODO.txt
2022-04-22 19:15:37 +02:00
ocornut
505f19e3b0 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2022-04-05 17:55:53 +02:00
ocornut
377b864bb4 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_dx12.cpp
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2022-03-23 17:21:34 +01:00
ocornut
9b0c26b0b2 Backends: SDL: Fix more dragging issues. SDL_CaptureMouse() is essentially broken. (#5012, #5082)
master got c5f6721 which is combining f337378 and this commit.
2022-03-22 18:09:33 +01:00
Rokas Kupstys
f337378066 Backends: SDL: Fix multi-viewport dragging issue with SDL on some systems. (#5012) 2022-02-28 11:10:39 +01:00
ocornut
8639a2f9f8 Viewports: Fixed translating a host viewport from briefly altering the size of AlwaysAutoResize windows. (#5057) 2022-02-25 16:41:40 +01:00
ocornut
64519c6875 Docking: Fixed floating docked nodes not being clamped into viewport workrect to stay reachable when g.ConfigWindowsMoveFromTitleBarOnly is set and multi-viewports are disabled. (#5044) 2022-02-22 16:21:10 +01:00
ocornut
7b0d58c5e5 Merge branch 'master' into docking 2022-02-22 14:57:17 +01:00
ocornut
9948535118 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui.h
#	imgui_draw.cpp
2022-02-17 18:47:43 +01:00
ocornut
1e14cc5cae Viewports: Fixed main viewport size not matching ImDrawData::DisplaySize for one frame during resize when multi-viewports are disabled. (#4900) 2022-02-10 18:50:28 +01:00
ocornut
aa86800092 Internals: rework RenderMouseCursor() signature so we can use it in docking branch more naturally. (Merged from master+ rework for docking)
# Conflicts:
#	imgui.cpp
#	imgui_draw.cpp
2022-02-08 12:29:44 +01:00
ocornut
1ee252772a Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2022-02-07 18:20:10 +01:00
ocornut
033538731c Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
2022-02-07 16:18:19 +01:00
ocornut
31762a8173 Docking: fixed potential crash if a passthrough dock node is submitted without a child intermediate (currently not possible via API) 2022-02-03 12:04:11 +01:00
ocornut
5017602752 Backends: SDL: Amend 08350e5, multi-viewports mouse tracking works under Linux. (#4960) + Reword tests to help static analysis. 2022-02-03 11:52:03 +01:00
ocornut
37958ca1b5 Docking: Fixed CTRL+TAB back into a docked window not selecting menu layer when no item are on main layer.
Could merge on master.
2022-02-03 00:19:31 +01:00
ocornut
8eb8689391 Docking: Tabs use their own identifier (in order to make window->ID refer to whole window in test engine). Also prevents Tab ID from clashing with "" which was common. 2022-02-02 23:23:13 +01:00
ocornut
c1ab3c406f Docking: Fixed size constraints not working on single window holding on a dock id (still doesn't work on docked windows). 2022-02-02 23:10:14 +01:00
ocornut
d378e4088f Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_draw.cpp
2022-02-01 15:46:42 +01:00
ocornut
08350e53e7 Backends: SDL: no support for ImGuiBackendFlags_HasMouseHoveredViewport under OSX/LInux (#4960) 2022-01-31 11:47:44 +01:00
ocornut
27004aca70 Revert moving ImGuiKeyModFlags to internal.h (amendc906c65)
# Conflicts:
#	imgui.cpp
2022-01-28 15:53:41 +01:00
ocornut
d5f0d45ae4 Merge branch 'master' into docking + remove two _PopUnusedDrawCmd() from docking branch, following 718daa1
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui_internal.h
2022-01-27 17:50:31 +01:00
ocornut
f1a073186c Docking: Fixed a CTRL+TAB crash when aiming at an empty docked window. (#4792) 2022-01-25 17:28:43 +01:00
ocornut
3e0d6ec895 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_vulkan.cpp
#	backends/imgui_impl_vulkan.h
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
#	imgui_internal.h
2022-01-21 12:39:15 +01:00
ocornut
e278277d53 IO: added AddMouseViewportEvent() + used in backends. 2022-01-18 17:24:59 +01:00
ocornut
1338eb31f7 Viewports: Relaxed specs for backend supporting ImGuiBackendFlags_HasMouseHoveredViewport. Backends: SDL: Added support for simplified HasMouseHoveredViewport. (#1542, #4665) 2022-01-18 17:01:55 +01:00
ocornut
007a427e0a Viewports: Fixed active InputText() from preventing viewports to merge. (#4212) 2022-01-18 16:04:25 +01:00
ocornut
8567a4cca3 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
#	imgui_demo.cpp
#	imgui_internal.h
2022-01-17 18:19:20 +01:00
ocornut
ec1e57ed4a Merge "Backends: SDL: Fix for Emscriptem. Amend 98ce013." + Fix bad merge from master of "is_app_focused" property (Amend 0647ba3) 2022-01-13 18:55:58 +01:00
ocornut
e51a0a80ca IO: fix SetKeyEventNativeData() not handling ImGuiKey_None the same way as AddKeyEvent(). (#4905, #4858) 2022-01-13 18:43:58 +01:00
ocornut
0647ba3bad Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_osx.h
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
2022-01-13 18:36:23 +01:00
ocornut
acfc7798fd Rename io.AddKeyModEvent() -> io.AddKeyModsEvent() and updated backends accordingly. (#2625, #4858)
Amend 790132a (breaking)

# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
2022-01-10 17:01:07 +01:00
ocornut
9ce0f35ef3 Backends: OSX: Fixed typo. 2022-01-10 15:48:12 +01:00
ocornut
ef681e7019 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_glfw.h
#	backends/imgui_impl_osx.h
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_sdl.h
#	backends/imgui_impl_win32.cpp
#	backends/imgui_impl_win32.h
#	imgui.cpp
2022-01-10 15:24:21 +01:00
ocornut
704ab1114a Merge branch 'master' into docking. Remove Platform_SetImeInputPos. Remove backend-side IME implementation. Rrevert removal of MouseDragMaxDistanceAbs in 206b9ea. (#2589, #3113)
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
#	imgui_widgets.cpp
2022-01-05 14:30:20 +01:00
ocornut
afb1180d7d Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2022-01-03 21:52:31 +01:00
ocornut
9c8f288d1a Viewports: Fixed a CTRL+TAB crash with viewports enabled (#4023, #787) (amend 1dc3af3, 23ef6c1, 657073a)
+ Expose FindHoveredViewportFromPlatformWindowStack() in imgui_internal.h
2021-12-30 21:46:09 +01:00
ocornut
2aa9959553 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_opengl3.cpp
#	docs/CHANGELOG.txt
2021-12-30 21:42:19 +01:00
ocornut
15b4a064f9 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_win32.cpp
#	examples/example_marmalade/main.cpp
#	imgui.cpp
#	imgui.h
2021-12-22 16:02:04 +01:00
ocornut
06d5f9297d Internals: reduced side-effects of setting window->HiddenFramesForRenderOnly > 0 2021-12-15 16:03:20 +01:00
ocornut
248ed1b01d Internals: UpdateWindowInFocusOrderList: amend a528398 to fix docking. (#3496, #4797) 2021-12-15 14:28:10 +01:00
ocornut
cd36acc88b Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_osx.h
#	backends/imgui_impl_osx.mm
#	imgui.cpp
2021-12-15 12:10:03 +01:00
ocornut
747f7fdbba Docking: prevent docking any window created above a popup/modal. (#4317) 2021-12-09 16:47:11 +01:00
ocornut
f605351307 Added an assertion for the common user mistake of using "" as an identifier at the root level of a window. (#1414, #2562, #2807, #4008, #4158, #4375, #4548, #4657, #4796)
#4158, #4375, #4548, #4657, #4796)
2021-12-09 15:38:44 +01:00
ocornut
e31d116d37 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl2.cpp
#	imgui.cpp
#	imgui_internal.h
2021-12-09 11:52:23 +01:00
ocornut
0647cf434c Nav, Docking: Fix crash on dimming docked window and DockSpaceOverViewport() with PassthruCentralNode.
(amend 1dc3af3, 23ef6c1, 657073a)
2021-12-08 17:05:31 +01:00
ocornut
fc198fe1db Nav, Docking: Fix dimming on docked windows. 2021-12-06 19:50:42 +01:00
ocornut
c1b70e0391 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2021-12-06 19:17:03 +01:00
ocornut
06e4f4e370 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdlrenderer.cpp
#	backends/imgui_impl_sdlrenderer.h
#	imgui.cpp
#	imgui.h
2021-12-03 19:24:42 +01:00
ocornut
1dc3af381a Nav, Docking: reworked modal/ctrl+tab dimming system to be entirely processed at end of the frame, which will simplify things for an upcoming commit.
(Will backport some of this back to master now.)
2021-12-03 19:18:57 +01:00
ocornut
c122c0ef89 Docking: Amend b16f738 fixed dimming of docked window + removed thin highlight around windows (never worked on docked window, not viewports friendly, hard to move to EndFrame) (#2700, #2539, #2522) 2021-12-03 16:15:06 +01:00
ocornut
b16f738d04 Docking: docked windows honor ImGuiCol_WindowBg. Host window in charge of rendering seams. (#2700, #2539 + Docked windows honor display their border properly. (#2522)
Plus: better support for transparent one in nodes
Side effects: DockContextBindNodeToWindow doesn't alter node->IsVisible.
Side effects: ImDrawList:: _ResetForNewFrame() needs to merge, sane (in case of
(Amended, force-pushed)
2021-12-03 14:46:34 +01:00
ocornut
bf80204e63 Docking: internals: extracted rounding corner calculation into reusable CalcRoundingFlagsForRectInRect() function. 2021-12-02 20:22:03 +01:00
ocornut
8733ca49b0 Docking: Fixed single-frame node pos/size inconsistencies when window stop or start being submitted.
Fix 718e15c7d while preserving its intended property. Tested by "docking_window_appearing_layout". (#2109)
2021-12-02 18:46:42 +01:00
ocornut
6afcfe3442 Docking: Fixed incorrectly rounded tab bars for dock node that are not at the top of their dock tree. 2021-12-01 18:27:05 +01:00
ocornut
848d21b6b5 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_sdlrenderer.cpp
#	backends/imgui_impl_sdlrenderer.h
#	imgui.cpp
#	imgui_widgets.cpp
2021-12-01 15:37:40 +01:00
ocornut
1ab3007752 Viewports: Fixed CTRL+TAB highlight outline on docked windows not always fitting in host viewport + moved EndFrameDrawDimmedBackgrounds() call + removed duplicate code in Begin() already in EndFrameDrawDimmedBackgrounds() 2021-12-01 14:42:58 +01:00
Mikko Sivulainen
5f5ba8eb11
Docking: Fix typo (had no side effect) (#4778)
Co-authored-by: Mikko Sivulainen <mikko.sivulainen@supercell.com>
2021-12-01 11:10:37 +01:00
ocornut
719d931304 Docking: Fixed a bug undocking windows docked into a non-visible or _KeepAliveOnly dockspace. (#4757) 2021-11-24 17:49:21 +01:00
ocornut
ea83d040e6 Viewports: fix missing default per-window value for ParentViewportId due to zero-cleared in-window instance (#4756)
Broken by 2080d12b
2021-11-24 16:47:13 +01:00
ocornut
7f38773b73 Fixed crash on right-click without modal, introduced by previous commit a3667f46, (#4729) 2021-11-17 12:46:30 +01:00
ocornut
b50b22d787 Fixed tooltip in own viewport over modal from being incorrectly dimmed. (#4729)
Normally we would aim to ensure that g.Windows[] gets maintained to reflect display layer but it is presently non trivial.
2021-11-16 16:14:21 +01:00
ocornut
2080d12bd9 Viewports: Made it possible to explicitly assign ImGuiWindowClass::ParentViewportId to 0. (#3152, #2871) 2021-11-16 01:10:10 +01:00
ocornut
dc8c3618e8 Merge branch 'master' into docking
# Conflicts:
#	imgui_demo.cpp
2021-11-10 15:26:03 +01:00
ocornut
b17dffffb3 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2021-11-04 20:52:54 +01:00
ocornut
c1d2793580 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2021-11-04 15:26:01 +01:00
ocornut
0b4edf4e94 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_vulkan.cpp
#	imgui.cpp
2021-11-03 11:51:37 +01:00
ocornut
bac748fa95 Backends: Made it possible to shutdown default Platform Backends before the Renderer backends. (#4656) 2021-10-15 17:16:26 +02:00
ocornut
05877c14df Fixed nested BeginDisabled()/EndDisabled() bug in Docking branch due to bad merge. (#4655, #4452, #4453, #4462) 2021-10-15 11:51:01 +02:00
ocornut
9b59455184 Merge branch 'master' into docking
# Conflicts:
#	imgui.h
2021-10-15 11:49:30 +02:00
ocornut
29653273c1 Docking: reinstate io.ConfigDockingWithShift option. (#4643)
This more or less reverts commit 3ed07a8f0b.
2021-10-13 16:47:29 +02:00
ocornut
1b215ecb01 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2021-10-11 19:25:50 +02:00
ocornut
1780579403 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2021-10-06 17:57:11 +02:00
ocornut
835a5344b0 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
#	imgui_internal.h
2021-09-24 15:49:28 +02:00
ocornut
65ad63de84 Added ImGuiFocusedFlags_NoPopupHierarchy and ImGuiHoveredFlags_NoPopupHierarchy (followup #4527)
IsWindowFocused: fix flag usage (amend 6b1e094c) was technically harmless because of light typing.
2021-09-24 15:41:30 +02:00
ocornut
ca097c2c68 Docking: Fixed IsItemHovered() and functions depending on it (e.g. BeginPopupContextItem()) when called after Begin() on a docked window (#3851)
Fix ee643b2a
2021-09-22 14:07:18 +02:00
ocornut
fa0a314f59 Nav: Fixed an issue with losing focus on docked windows when pressing Alt while keyboard navigation is disabled. (#4547, #4439) 2021-09-21 13:16:00 +02:00
ocornut
c58fb46411 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2021-09-14 19:26:27 +02:00
ocornut
e7cc534367 Docking: Improved resizing system so that non-central zone are better at keeping their fixed size. 2021-09-14 17:57:47 +02:00
ocornut
29828d0469 Docking: floating node with a central node hides properly when nothing is docked + rename. 2021-09-14 17:56:09 +02:00
ocornut
8dfb52245b Docking: bits. 2021-09-13 20:40:30 +02:00
ocornut
5d95e7eef9 Viewports: extracted DestroyViewport() out of UpdateViewportsNewFrame() function. 2021-09-11 14:06:43 +02:00
ocornut
92a39f78b9 Fixed IsWindowFocused/IsWindowHovered with _ChildWindows for not following through popup parents (amend 6b1e094c, fix #4527) 2021-09-11 14:06:10 +02:00
ocornut
79d39b190b Viewports: fix window with viewport ini data immediately merged into a host viewport from leaving a temporary viewport alive for a frame (would leak into backend). 2021-09-10 15:05:17 +02:00
ocornut
6b77668171 Viewports: Fixed a crash while a window owning its viewport disappear while being dragged.
t would manifest when e.g. reconfiguring dock nodes while dragging.
2021-09-09 21:05:40 +02:00
ocornut
9a49c1ddbd Viewports: fixed unnecessary creation of temporary viewports when multiple docked windows got reassigned to a new node (created mid-frame) which already has a HostWindow 2021-09-09 20:51:53 +02:00
ocornut
6b1e094cfb Fixed _ChildWindows from leaking docking hierarchy. Added ImGuiFocusedFlags_DockHierarchy and ImGuiHoveredFlags_DockHierarchy. 2021-09-08 19:10:25 +02:00
ocornut
cfb837203c Internals: refactored IsWindowHovered()/IsWindowFocused() to make their logic more similar + change underlying value of ImGuiHoveredFlags_AllowWhenBlockedByPopup + comment out docking only flags. 2021-09-08 16:45:24 +02:00
ocornut
40caab4748 Fixed bad merge of Changelog in docking branch 2021-09-07 18:21:47 +02:00
ocornut
fa9fc05ac6 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2021-09-07 18:20:12 +02:00
ocornut
53589092b2 Docking: warning fix for when IM_ASSERT() is empty 2021-08-31 13:49:11 +02:00
ocornut
dedb381c51 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	examples/imgui_examples.sln
#	imgui.cpp
#	imgui.h
2021-08-30 20:01:16 +02:00
ocornut
0eb45a0577 Docking: fix 58f5092 (#4310)
If we clear _ChildWindow flag we must remove it from here otherwise render loop will fail.
2021-08-27 21:29:27 +02:00
ocornut
58f5092c53 Docking: fixed settings load issue when mouse wheeling. (#4310) 2021-08-24 20:33:00 +02:00
ocornut
6bd447c885 Backends: GLFW: Fixed unused variable warning for empty assert macro. (#4459) 2021-08-22 18:46:49 +02:00
ocornut
47fb332fb2 Fix BeginDisabled(false), again, (#211, #4452, #4453) Version 1.84.1
(forced pushed since our earlier versioning didn't sort correctly in github web)

# Conflicts:
#	docs/CHANGELOG.txt
2021-08-21 00:00:27 +02:00
ocornut
2e01952b35 Fix BeginDisabled(false), (#211, #4452) 2021-08-20 20:31:17 +02:00
ocornut
5a7d18a441 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2021-08-20 18:15:25 +02:00
ocornut
9c3359ef39 IO: modify io.AddFocusEvent() to tolerate in/out for multi-viewports. Amend 2f40be6. (#3532) 2021-08-19 17:35:27 +02:00
ocornut
0b06c4b2b0 Merge branch 'master' into docking (will need further for io.AddFocusEvent)
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
2021-08-19 17:25:12 +02:00
ocornut
80b5fb51ed Backends: Win32, SDL, GLFW: only honor io.WantSetMousePos when focused + fix GLFW uninstalling handler + tweaks to reduce branch drift with docking. (#787, #2445, #2696, #3751, #4377)
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
2021-08-02 16:21:13 +02:00
ocornut
f9b5168fb3 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
2021-08-02 16:00:50 +02:00
ocornut
7bfc379a23 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2021-07-19 21:58:06 +02:00
David Maas
3d5dc0d939 Added missing IMGUI_API to GetViewportPlatformMonitor. (#4309) 2021-07-12 18:29:37 +02:00
ocornut
a11f36811f Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_dx10.cpp
#	backends/imgui_impl_dx11.cpp
#	backends/imgui_impl_dx12.cpp
#	backends/imgui_impl_dx9.cpp
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_vulkan.cpp
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui_internal.h
2021-07-09 20:16:19 +02:00
ocornut
eb6f4b1a6a Docking: Fix crash when a dock node gets re-qualified as dockspace>floating>dockspace.. (#3203, #4295)
Which tends to happen when incorrectly calling DockBuilderAddNode() without ImGuiDockNodeFlags_Dockspace and using it as a Dockspace on the next frame after the floating window hosting the node has been automatically created.
2021-07-07 18:22:55 +02:00
ocornut
cd4cc9ff0d Docking: Fixed crash issues using DockBuilderRemoveNode() in some situations. (#3111, #3179, #3203, #4295)
If the deleted root node isn't part of a dockspace with a central node, it won't be "protected" but removed when last window gets removed.
2021-07-07 16:39:39 +02:00
ocornut
9e8e5ac363 Docking: Added ImGuiDockNodeFlags_NoDockingOverEmpty. Breaking definition of ImGuiDockNodeFlags_NoDockingOverOther which now means "non empty node". (#3492, #2648, #4292) 2021-07-05 13:32:36 +02:00
ocornut
6136b3844b Docking: Reworked node flags saving/inheritance... (#4292, #3834, #3633, #3521, #3492, #3335, #2999, #2648)
..so that flags enforced by docked windows via the DockNodeFlagsOverrideSet mechanism are are not left in empty dockspace nodes once the windows gets undocked.
2021-07-05 13:31:34 +02:00
ocornut
0a8ab75e4b Docking: removed DockNodeFlagsOverrideClear flags from ImGuiWindowClass. (#2999, #3521, #3633)
+ extraded bits of metrics into DebugNodeDockNodeFlags()
2021-07-05 12:58:33 +02:00
ocornut
36a0d1028c Backends: Viewports: renamed viewport storage structures ImGuiViewportDataXXXX -> ImGui_ImplXXXX_ViewportData and locals (matching naming convention in 70c60385) 2021-06-29 15:46:50 +02:00
ocornut
0f7eb00f67 Backends: amends to 1db1066 + merge minor bits from docking incl SetActiveIdUsingNavAndKeys().
No need to clear fields before deletion. DX12: renamed to match docking branch.
2021-06-29 15:31:05 +02:00
ocornut
682447306d Merge branch 'features/backends_context' into docking
# Conflicts:
#	backends/imgui_impl_dx10.cpp
#	backends/imgui_impl_dx11.cpp
#	backends/imgui_impl_dx12.cpp
#	backends/imgui_impl_dx9.cpp
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_opengl2.cpp
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_vulkan.cpp
#	backends/imgui_impl_win32.cpp
#	examples/example_apple_opengl2/main.mm
2021-06-29 14:53:25 +02:00
ocornut
ac35b4bba2 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
2021-06-24 18:21:19 +02:00
ocornut
cce307a2be Viewports: Fix popup/tooltip created without a parent window from being given a ParentViewportId value of the implicit/fallback window. (#4236, #2409)
Amend 3ead9820
2021-06-17 16:22:14 +02:00
ocornut
afabb2f3d8 Viewport: extracted code out of Begin() into WindowSyncOwnedViewport() - no other change 2021-06-17 16:12:22 +02:00
ocornut
9b417b26d9 Metrics: Tentative fix for bad printf format.
Ref b53b8f58df, a7a1b3b0a7
2021-06-14 18:24:45 +02:00
Michel Lesoinne
90deb0959a Backends, Viewports: Vulkan: Fix the use of the incorrect fence in wait for fence. (#4208)
The fence being waited upon was not the one associated with the current frame.
This results in validation error detecting a reset of command buffers still in use and resetting fences while still in use.
Read more details in #4208
2021-06-14 17:54:19 +02:00
ocornut
db0338a1f2 Nav, Drag and Drop, Docking: fixed two issues leading nav result to conflict with moving a window. (#4211, #3025) 2021-06-09 19:20:13 +02:00
ocornut
4161a67b38 ImVector: added clear_delete(), clear_destruct() helpers.
# Conflicts:
#	imgui.cpp
2021-06-09 18:44:02 +02:00
ocornut
865b2ca6f9 Added PushDisabled(), PopDisabled() currently only exposed in imgui_internal.h (#211) 2021-06-09 18:43:03 +02:00
ocornut
a44d4da87c Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_win32.cpp
2021-06-08 18:38:51 +02:00
ocornut
16abfa5eb6 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2021-06-04 17:28:45 +02:00
ocornut
f53db3541a Docking: comments (#4189) 2021-06-04 14:55:40 +02:00
ocornut
5e528d9eea Docking: Clicking on the right-most close button of a docking node closes all windows. (#4186) 2021-06-03 17:22:18 +02:00
ocornut
f03ab2a5c5 Docking: Fix IsWindowAppearing() unnecessarily returning true twice in a row. (#4177, #3982, #1497, #1061) + added a zealous assert. 2021-06-03 16:46:01 +02:00
ocornut
fa1f540e6c Docking: Amend 91704b7, window->DockXXX booleans not properly cleared when window not docked. (#4177, #3982, #1497, #1061)
Fix issue with freshly split windows/nodes incorrectly returning true to IsWindowAppearing().
2021-06-03 16:07:22 +02:00
ocornut
91704b773e Docking: Fix IsWindowAppearing() and ImGuiCond_Appearing on docked windows. (#4177, #3982, #1497, #1061) 2021-05-31 17:06:46 +02:00
ocornut
1ad1429c6d Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	docs/CHANGELOG.txt
2021-05-25 18:45:54 +02:00
ocornut
1b435ae3e0 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2021-05-24 17:49:20 +02:00
ocornut
105d82d134 Docking: Docking node tab bar honors ItemInnerSpacing.x before first tab. Tweak rendering and alignment of dock node menu marker. (#4130)
+ Fix ~0 in EndFrameDrawDimmedBackgrounds() which is obsolete way of signifying "all round corners".
2021-05-20 18:14:16 +02:00
ocornut
86c2b609ef Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_dx10.cpp
#	backends/imgui_impl_dx11.cpp
#	backends/imgui_impl_dx12.cpp
#	backends/imgui_impl_dx9.cpp
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_opengl2.cpp
#	backends/imgui_impl_opengl3.cpp
#	imgui.cpp
2021-05-19 19:05:01 +02:00
warriormaster12
2cdfcb8fd2 Backends: Vulkan: Fix for using IMGUI_IMPL_VULKAN_NO_PROTOTYPES (#4151, #3759, #3227) 2021-05-18 15:08:04 +02:00
ocornut
31290807dc Merge branch 'master' into docking
+ fix warning fix for mingw+dx9
# Conflicts:
#	backends/imgui_impl_dx9.cpp
#	imgui.cpp
2021-04-30 22:52:46 +02:00
ocornut
33cdbe97b8 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2021-04-19 20:05:59 +02:00
ocornut
34d4bc620d Merge remote-tracking branch 'origin/master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
2021-04-15 19:57:52 +02:00
ocornut
76902c482f Changelog: added docking+entries from 1.72 to 1.82 to increase their visibility. 2021-04-14 19:31:40 +02:00
ocornut
e5efa01920 Docking: Fix window menu button. Broken by 3f16a52 (#4043)
Worked on single-frame click.
2021-04-14 14:35:11 +02:00
ocornut
3f16a524c8 Docking: move NavWindow to SelectedTabId application lower to leave a chance for in-between code to alter focus. + store per-node window menu button id to simplify usage. 2021-04-13 18:45:08 +02:00
ocornut
646c873598 Docking: Fixed reappearing docked windows with no close button showing a tab with extraneous space for one frame. 2021-04-13 16:12:14 +02:00
ocornut
e87dd0e65d Docking: Fixed multiple simultaneously reappearing window from appearing undocked in their initial frame. 2021-04-12 19:47:37 +02:00
ocornut
539de4387b Docking: Fixed restoring of tab order within a dockspace or a split node.
(tests in "docking_tab_order")
2021-04-12 16:51:05 +02:00
ocornut
65cd14502c Fix popup positioning, broken by 84e6fe4. (#3991, #3982) 2021-03-31 19:10:12 +02:00
ocornut
6ddcdbe3e8 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_widgets.cpp
2021-03-31 16:41:17 +02:00
ocornut
9251eac585 Docking: fix undocking from tab-bar by moving mouse horizontally, amend 3ed07a8 + d705192.
Automation system may drag e.g. right-most tab far left (and vice-versa) and one frame and our current logic would fail at it.
2021-03-30 19:01:37 +02:00
ocornut
3ed07a8f0b Docking: removed io.ConfigDockingWithShift option. (#2109) 2021-03-30 15:00:16 +02:00
ocornut
0e0a783b8c Docking: fix undocking from tab-bar by moving mouse horizontally, broken by d705192. 2021-03-30 14:52:10 +02:00
ocornut
5991851eb9 Docking: DockSpace() returns its node ID + adding branch changelog. 2021-03-26 18:40:19 +01:00
Rokas Kupstys
a4adf60576 Backends, Viewports: GLFW: Add a workaround for stuck keys after closing a GLFW window (#3837). 2021-03-26 12:49:56 +01:00
ocornut
b79b1cb9c0 TabBar: Amend previous commit. Fix tab reordering when tab bar has scrolling.
Some tidying up with helpers + honor 16-bit offsets as with other tab bar features (unlikely single reorder can reach that but consistent)
2021-03-25 19:17:30 +01:00
Rokas Kupstys
d7051928d9 TabBar: Use mouse position instead of hardcoded +1/-1 offset when reordering tabs.
Fixes tab reordering in test engine when using fast mode.

# Conflicts:
#	imgui_widgets.cpp
2021-03-25 19:15:36 +01:00
ocornut
b305953bd1 Viewports: Hotfix for crash in monitor array access, caused by 4b9bc4902. (#3967) 2021-03-25 17:13:25 +01:00
ocornut
e7577d570e Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_dx9.cpp
#	backends/imgui_impl_sdl.cpp
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2021-03-25 16:57:01 +01:00
ocornut
ca34c81ce9 BeginMainMenuBar(): remove expectation that we don't know menu bar height ahead, allowing up to generalize placement in any direction (will be done in master)
Amend 75de34e281
2021-03-25 15:21:23 +01:00
ocornut
085cff2fe5 Viewports, Backends: Vulkan: Rebuild swapchain on VK_SUBOPTIMAL_KHR. (#3881) 2021-03-18 18:16:49 +01:00
Rokas Kupstys
b17bfdd6f4 Docking: Add support for split_outer in DockContextCalcDropPosForDocking().
Misc: Add FIXME regarding behavior of some window fields.
2021-03-18 12:21:47 +01:00
ocornut
81e0b18e38 Merge branch 'master' into docking 2021-03-16 16:10:29 +01:00
ocornut
b202fa9063 Docking: undocking nodes/windows covering most of the monitor max their size down to 90% to ease further manipulations.
Kind of a welcome hack.
2021-03-16 16:01:12 +01:00
ocornut
2231e1a369 Docking: Dockspace() never draws a background. (#3924) 2021-03-16 14:30:36 +01:00
ocornut
256594575d Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2021-03-15 20:38:34 +01:00
CheckmateAt7
cfe83c4b44
Removed deprecated flag stopping compilation (#3902) 2021-03-12 18:02:46 +01:00
ocornut
0157502eab ImDrawFlags: rework/revert c2d6d26 + 39432bf in a way that is closer to old version and back to opt-in but with default 0 = all corners. 2021-03-12 16:33:29 +01:00
ocornut
f1bf642e8f Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	misc/debuggers/imgui.natvis
2021-03-11 16:32:14 +01:00
ocornut
4b9bc49020 Viewports, Internals: added GetViewportPlatformMonitor() will a safety net to keep code portable + simplified handling of disconnected monitor in Begin(). 2021-03-10 17:10:07 +01:00
ocornut
d5a4d53000 Viewports, Backend: SDL: Fix missing ImGuiBackendFlags_HasSetMousePos flag in docking branch (ok in master), GLFW: Fix application of WantSetMousePos. (#1542, #787)
Shows how little this feature is used with nav (was designed for small devices and frankly may be dropped) - but the backend support itself we will make use of for other features.
2021-03-05 17:22:22 +01:00
ocornut
705f082674 Internals: rename RootWindow->RootWindowDockTree, RootWindowDockStop->RootWindow.
Why?  So by default RootWindow matches user expectation on both branches, and RootWindowDockTree is more intentful.
(Actually should reduce diff between master<>docking)
2021-03-05 16:24:29 +01:00
ocornut
80533ea5e1 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_widgets.cpp
2021-03-05 16:04:15 +01:00
ocornut
6aee4bcdc5 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_dx9.cpp
#	backends/imgui_impl_win32.cpp
#	docs/CHANGELOG.txt
#	imgui.cpp
2021-03-02 18:27:07 +01:00
ocornut
b794ecc079 Internals: Docking: some renaming. 2021-03-02 12:12:38 +01:00
David Maas
732cd837a9
Added missing IMGUI_API to internal docking-related structs. (#3850) 2021-02-27 21:15:38 +01:00
Rokas Kupstys
839ecce571 Internals: Add a way to request window to not process any interactions for specified number of frames. 2021-02-25 15:12:53 +01:00
ocornut
3ec14186cb Viewports: Fix setting of ImGuiViewportFlags_NoRendererClear. (#3213) 2021-02-18 14:11:14 +01:00
ocornut
a4e4f57cb0 Examples: DX9-DX11: Removed half-assed DPI awareness enable. Updated Docking/Viewports part of Changelog (e.g. removed bits that are now already in master, clarified some added bits) 2021-02-18 12:55:10 +01:00
ocornut
ffa863a3ba Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_dx10.cpp
#	backends/imgui_impl_dx11.cpp
#	backends/imgui_impl_dx12.cpp
#	backends/imgui_impl_dx9.cpp
#	backends/imgui_impl_opengl3.cpp
#	backends/imgui_impl_win32.cpp
#	docs/CHANGELOG.txt
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	imgui.cpp
2021-02-18 11:41:27 +01:00
ocornut
3d75f438bc Docking: Made close button enable logic consistent on dockspace. When no docked window have a close button or it is disabled on the node, the space is given to tabs.
Clarified close_button_is_visible vs close_button_is_enabled behavior in DockNodeUpdateTabBar().. (#3633, #3521)
Reduced alpha of disabled close button a little bit further.
Removed 'EnableCloseButton' which was actually unused (can't be infered early, need ->VisibleWindow anyway, which is not == ->ActiveWindow)
2021-02-12 21:17:31 +01:00
Adam Kewley
7180e9ac66
Remove redundant GetMainViewport decl in imgui.h (#3801, #3800) 2021-02-11 10:03:14 +01:00
ocornut
239d09804d Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2021-02-10 21:28:16 +01:00
ocornut
04f7ea818d Viewports: Setting the new (currently dummy) flags on viewports. (#3789, #1542, #3680, #3350, #3012, #2471)
Amend the merging of f14042ca78 (merge ee59d7a266)
2021-02-10 16:42:22 +01:00
ocornut
ee59d7a266 Merge branch 'features/viewport_in_master' into docking (WIP need adding code for new ImGuiViewportFlags values)
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2021-02-10 16:34:17 +01:00
ocornut
3607c42bec Viewports: Fix issue inferring viewport z-order when new popups gets created. (#3734) + Metrics updates.
Revert 6bc52667
Showing inferred order and missing flags in metrics.
2021-02-10 14:31:23 +01:00
ocornut
2a5eaf239f Misc tweaks - mostly toward minimizing diff in upcoming backport merge of a few viewport structures in master 2021-02-10 14:28:04 +01:00
ocornut
6f5f80a544 Fix for compiling imgui_internal.h without operators + made GetWorkRect() consistent with clamped WorkSize. 2021-02-09 14:08:48 +01:00
ocornut
7a516a266d Merge remote-tracking branch 'origin/master' into docking
# Conflicts:
#	backends/imgui_impl_dx12.cpp
#	backends/imgui_impl_dx9.cpp
#	imgui.cpp
#	imgui.h
2021-02-09 13:17:24 +01:00
ocornut
73ccb7e4b8 Viewports: (Breaking) turned GetWorkPos(), GetWorkSize() into straight fields -> WorkPos, WorkSize before exposing in master branch. 2021-02-09 13:15:01 +01:00
ocornut
1a3af8cb4c Viewports: trying to treat GetMainViewport() as const. Reducing unnecessary casts of ImGuiViewportP*
Metrics: readded root Drawlists node in metrics to match master.
The (void*) casts are implying const-casst but currently left GetMainViewport() as returning non-const.
2021-02-09 13:15:01 +01:00
ocornut
862bfc53d3 Viewports: Moved in own section of imgui.h ahead of merging a small part of viewport interface to master. 2021-02-09 11:47:55 +01:00
ocornut
fa55b0cb60 Viewports: (breaking) removed ImGuiPlatformIO::MainViewport which is now pretty much unused and duplicate (and misleading as we will evolve the concept)
Use GetMainViewport() if stuck.
2021-02-05 16:14:47 +01:00
ocornut
22d9a61b33 Docking: fix gap in hit test hold when using ImGuiDockNodeFlags_PassthruCentralNode touching the edge of a viewport. (#3733) 2021-02-02 15:16:46 +01:00
GamingMinds-DanielC
84e8802891 Docking: on node split, update memorized DockId for currently closed windows (#3716)
Amended by @ocornut with same fix in DockBuilderRemoveNodeChildNodes().
2021-02-01 17:56:20 +01:00
ocornut
577e7cb493 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_win32.cpp
#	docs/CHANGELOG.txt
#	imgui.cpp
2021-01-28 21:02:13 +01:00
ocornut
cff8162454 Viewports, Backends: Vulkan: handle VK_ERROR_OUT_OF_DATE_KHR when resizing secondary viewport (#3766, #3758)
Cannot repro here but appears to a user on Linux. Fix may be not super solid.
2021-01-28 16:03:59 +01:00
Sammy Fatnassi
376c88a864 Fixed some compile warnings with Clang on Windows (#3754) 2021-01-26 14:10:10 +01:00
ocornut
bb26751b94 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2021-01-21 20:38:42 +01:00
ocornut
ebbb98d519 Docking: docked window honor tab and text colors by storing them. (#2771)
Later to lead into #2700 and #2539
Move tab submission block above in DockNodeUpdateTabBar(), not strictly necessary for this change as is, but useful if needing to apply override for TitleBg* as we'd need a value for node->VisibleWindow earlier than currently set.
2021-01-18 18:32:46 +01:00
ocornut
9e4956d86b Docking: added comments. added experimental TabItemFlagsOverrideSet to ImGuiWindowClass.
(Could probably do something similar with TabBarFlagsOverrideSet+Clear for #2700 later.)
2021-01-18 18:32:46 +01:00
ocornut
388ca563db Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_dx12.cpp
2021-01-15 19:20:42 +01:00
ocornut
70703da782 Merge branch 'master' into docking 2021-01-08 18:55:16 +01:00
ocornut
b11518d7d7 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl2.cpp
#	backends/imgui_impl_opengl3.cpp
#	imgui.cpp
2021-01-05 16:46:38 +01:00
ocornut
7b53551032 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2020-12-22 17:17:49 +01:00
ocornut
06e87014f2 Merge branch 'master' into docking
# Conflicts:
#	imgui.h
#	imgui_internal.h
2020-12-11 23:10:06 +01:00
ocornut
dd4ca70b0d Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui_demo.cpp
2020-12-04 19:22:15 +01:00
ocornut
657589ab47 Backends: Vulkan+Viewports: fixed build, removed extraneous pipeline creation (770c9953, e8447dea, 6a0e85c5) (#3459, #3579) 2020-12-04 11:29:53 +01:00
ocornut
c1ffac2fee Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2020-12-03 20:05:49 +01:00
ocornut
4da92b89ed Viewports: fix incorrect whitening of popups above a modal if both use their own viewport + fix pvs warning. 2020-11-19 18:31:13 +01:00
ocornut
3dcbcd8bf0 Internals: added IsWindowAbove() for use for modal/viewport bugfix. 2020-11-19 18:31:10 +01:00
ocornut
cecf6b4209 Viewports: made standalone modals appear in taskbar + new window perform z-check before merging in main host viewport. (#3511, #1542)
This should fix a good amount of "lost modal" problems, however it is still possible to loose a modal in a host viewport if secondary viewports are configured as children above the host.
2020-11-19 16:07:07 +01:00
ocornut
b2a91dc390 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2020-11-13 22:04:28 +01:00
ocornut
ac08593b96 Merge branch 'master' into docking + tweak dock node padding + use CheckboxFlags with int
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
#	imgui_internal.h
2020-11-05 21:36:22 +01:00
ocornut
e3ac52630a Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	imgui.cpp
2020-10-31 00:47:57 +01:00
ocornut
455c21df71 Merge branch 'master' into docking + dockspace demo comments
# Conflicts:
#	backends/imgui_impl_opengl3.cpp
#	docs/CHANGELOG.txt
#	imgui_internal.h
#	imgui_widgets.cpp
2020-10-19 15:08:32 +02:00
ocornut
d3a80d9f1b Internals: Docking: More fixes to make DockNodeBeginAmendTabBar() viable (probably some issues left) 2020-10-15 15:02:05 +02:00
ocornut
b26f1530b7 Internals: Docking, Tab Bar: Add DockNodeBeginAmendTabBar() and work toward making hybrid dock node with windows tab bars somehow work (not done). 2020-10-15 12:18:20 +02:00
ocornut
bae2240eda Tab Bar: Made it possible to append to an existing tab bar by calling BeginTabBar()/EndTabBar() again.
# Conflicts:
#	imgui_widgets.cpp
2020-10-14 18:36:03 +02:00
ocornut
042a3b01d2 Merge branch 'master' into docking
# Conflicts:
#	backends/imgui_impl_dx10.cpp
#	backends/imgui_impl_dx10.h
#	backends/imgui_impl_vulkan.h
#	backends/imgui_impl_win32.cpp
#	docs/CHANGELOG.txt
#	examples/README.txt
#	examples/example_glfw_opengl2/main.cpp
#	examples/example_glfw_opengl3/main.cpp
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_sdl_directx11/main.cpp
#	examples/example_sdl_opengl2/main.cpp
#	examples/example_sdl_opengl3/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	examples/example_win32_directx10/main.cpp
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx12/main.cpp
#	examples/example_win32_directx9/main.cpp
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
#	imgui_internal.h
2020-10-14 14:44:03 +02:00
ocornut
682249396f Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2020-10-08 16:05:55 +02:00
ocornut
958e58b06b Merge branch 'master' into docking
# Conflicts:
#	examples/example_apple_opengl2/main.mm
#	imgui.cpp
2020-10-01 13:33:08 +02:00
ocornut
c49330fc52 Docking: Fix handling of WindowMenuButtonPosition == ImGuiDir_None in Docking Nodes. (#3499) 2020-09-30 14:11:22 +02:00
ocornut
fa004ae79a Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_examples.sln
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_dx12.h
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui_demo.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2020-09-22 17:00:57 +02:00
Sven Balzer
42575d4a99 Viewports, Backends: Win32: Fix toggling of ImGuiViewportFlags_TopMost (#3477) 2020-09-17 09:47:04 +02:00
ocornut
6bc526676c Viewports: Comments, removed unnecessary use of ViewportFrontMostStampCount (the LastFrontMostStampCount is enough) 2020-09-16 12:29:46 +02:00
omar
e230ec5a01 Viewports, Backends: DX12: Make secondary viewport format match main viewport one (#3462) {@BeastLe9enD] 2020-09-16 11:05:02 +02:00
omar
770c995365 Backends: Vulkan: Removed unused shader code. Fix leaks. Avoid unnecessary pipeline creation for main viewport. Amend 41e2aa2. (#3459) + Add ImGui_ImplVulkanH_CreateWindowSwapChain in ImGui_ImplVulkanH_CreateOrResizeWindow(). 2020-09-08 22:44:24 +02:00
omar
78f753ffff Merge branch 'master' into docking + incl add wd->Pipeline in ImGui_ImplVulkan_RenderDrawData platform code (#3455, #3459) 2020-09-08 17:02:58 +02:00
Doug Binks
aa8e09d7f1 Backends: GLFW: workaround for cases where glfwGetMonitorWorkarea fails (#3457) 2020-09-07 10:49:34 +02:00
ocornut
36c331ff74 Merge branch 'master' into docking
# Conflicts:
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	imgui.cpp
#	imgui_internal.h
2020-09-02 12:47:07 +02:00
ocornut
8dacb4da20 Docking: Fixed DockNode tab bar initial order broken by 8c80d533d 2020-09-02 12:11:45 +02:00
ocornut
fc625d249f Internals: Begin: update ->Hidden flags only on first begin of the frame. (ignore whitespace to see simple diff)
# Conflicts:
#	imgui.cpp
2020-09-01 15:28:06 +02:00
ocornut
34077c0140 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2020-09-01 12:07:35 +02:00
ocornut
600b8f60b4 Docking: Fixed crash in metrics. 2020-08-28 20:20:28 +02:00
ocornut
e9053515bb Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_sdl_vulkan/main.cpp
2020-08-25 19:29:06 +02:00
ocornut
30f0900b1c Docking: Fix honoring payload filter with overlapping nodes. (we incorrectly over-relied on g.HoveredDockNode when making change for #3398)
Essentially undo part of 85a661d (#3398) + ref cf31254 (#3420)
2020-08-25 19:17:46 +02:00
ocornut
831e2c920e Docking, Viewport: Fixed a rare edge-case if the window targetted by CTRL+Tab stops being rendered. 2020-08-21 18:44:56 +02:00
ocornut
cf312545e8 Docking: Fixed docking while hovering a child window. (#3420) broken by 85a661d27. Improve metrics debugging. 2020-08-21 16:34:34 +02:00
ocornut
d6f3a8848d Viewports: Backends: DirectX9: Allow D3DERR_DEVICELOST on secondary viewports. (#3424) 2020-08-21 15:02:52 +02:00
ocornut
9d20a5f0a5 Docking: DockSpace() emits ItemSize() properly + dockspace demo (works now since 05a25e5f3) 2020-08-20 22:54:33 +02:00
ocornut
ad8fdc917f Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2020-08-20 22:42:14 +02:00
ocornut
05bc204dbd Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.h
2020-08-18 17:51:43 +02:00
omar
b36d1d465d Docking: Untangle a little bit of the ActiveIdClickOffset mess. 2020-08-18 12:40:43 +02:00
ocornut
25a9209b75 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
#	imgui_widgets.cpp
2020-08-17 23:29:17 +02:00
omar
a9626e1162 Docking: Made DockBuilderAddNode() automatically call DockBuilderRemoveNode(). (#3399, #2109) 2020-08-11 11:52:13 +02:00
omar
a5ba26806f Make moving window prevent its active id from being stolen (#3392, #3243, #1738)
Amend 7b3d379, 615e9ae3
2020-08-10 16:28:46 +02:00
omar
dbc70f21a9 Docking: Fixed docking overlay bits appearing at (0,0), because of 43bd80a4. Most typically noticable when disabling multi-viewport. 2020-08-10 15:54:41 +02:00
omar
85a661d276 Docking: Storing HoveredDockNode in context which can be useful for easily detecting e.g. hovering an empty node. (#3398) 2020-08-10 12:55:37 +02:00
omar
acf043a675 Docking: Moved code unjustly in DockNodeTreeFindNodeByPos() out of it and into caller (should have no side-effect ideally). Removed dupe in Begin() from earlier merge. 2020-08-10 12:52:23 +02:00
omar
2c13a74a9d Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	imgui.cpp
2020-08-10 11:35:51 +02:00
omar
de1588928b Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2020-08-03 19:54:31 +02:00
omar
70fa37527d Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
#	imgui_draw.cpp
#	imgui_internal.h
2020-07-29 15:15:14 +02:00
Rokas Kupstys
3d4af15d1d Backends GLFW: Use GLFW_MOUSE_PASSTHROUGH when available. 2020-07-17 18:44:09 +02:00
omar
cba52b66af Backends: GLFW: Fixed enabling ImGuiBackendFlags_HasMouseHoveredViewport broken by 950539b7.
As it turns out, back-end passing NULL hovered with HasMouseHoveredViewport is also broken which defeats some of its purpose.
2020-07-17 18:14:04 +02:00
omar
f79f0e42f7 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_opengl3.cpp
#	imgui.h
2020-07-14 18:38:47 +02:00
omar
cbade7b16d Docking: Workaround recovery for node created without the _ockSpace flags later becoming DockSpace. (#3340) 2020-07-10 19:17:49 +02:00
omar
b626dd57d3 Backends: DX12, Viewports: Tidying up, renaming. 2020-07-10 12:20:03 +02:00
omar
cb1d578470 Backends: DX12, Viewports: Fixed issue on shutdown when viewports are disabled. (#3347) 2020-07-10 12:09:24 +02:00
omar
4f5aac319e Docking: moved local-ish IMGUI_DOCK_SPLITTER_SIZE to DOCKING_SPLITTER_SIZE at the top of the file. 2020-07-03 15:51:05 +02:00
omar
fc9d6b6cb5 Docking: Added experimental flags to perform more docking filtering and disable resize per axis. Designed for toolbar patterns.
The local/shared flags specs, saving and inheriting rules are pretty inconsistent at the moment.
2020-06-30 19:55:59 +02:00
omar
4bdbea8375 Docking: Rework size allocation to allow user code to override node sizes. Not all edge cases will be properly handled but this is a step toward toolbar emitting size constraints. 2020-06-30 18:53:13 +02:00
omar
2b9d88196e Docking: Rework size allocations to recover when there's no enough room for nodes + do not hold on WantLockSizeOnce forever (#3328)
(Ensure if the fact that WantLockSizeOnce was kept when only 1 child is visible was desired/desirable)
2020-06-30 18:52:02 +02:00
omar
90ea7e2f2f Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
#	imgui_internal.h
2020-06-30 16:43:16 +02:00
omar
ddabfc3477 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2020-06-29 17:15:40 +02:00
omar
f4f04cb5ec Windows: Amend 6b0cf2e6 to facilitate working in viewport branch + handle safe area padding and ConfigWindowsMoveFromTitleBarOnly.
# Conflicts:
#	imgui.cpp
2020-06-25 23:14:46 +02:00
Rokas Kupstys
d7ef56dca2 Windows: Fix unintended window size changes when resizing windows close to main viewport edges. 2020-06-25 22:58:39 +02:00
omar
5628416bd3 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
2020-06-25 14:03:40 +02:00
omar
7538bbabb6 Demo: Commented out ideas on another way to center a window. 2020-06-23 19:01:40 +02:00
omar
e1d7e14717 Viewports: used main viewport for centering (wip), clarified the meaning of how ImGuiPlatformMonitor WorkPos/WorkSize should be set if unknown, added asserts. 2020-06-23 18:42:01 +02:00
omar
a616ff5d4a BeginPopupModal() doesn't set the ImGuiWindowFlags_NoSavedSettings flag anymore, and will not always be auto-centered. (#915, #3091)
# Conflicts:
#	imgui.cpp
2020-06-23 17:54:55 +02:00
omar
76e40fe5d1 Docking: Fix misuse of PushClipRect in UpdateWindowManualResize(). (#3311) 2020-06-20 22:09:58 +02:00
omar
20d61f5f62 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2020-06-20 22:06:01 +02:00
ocornut
2665288b30 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2020-06-11 11:36:38 +02:00
ocornut
8baa4ccff5 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2020-06-06 20:31:24 +02:00
ocornut
5d472c4895 Merge branch 'master' into docking + fixes for #3259
# Conflicts:
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	examples/imgui_impl_sdl.cpp
#	imgui.cpp
2020-05-25 18:32:15 +02:00
ocornut
0fe5170bc4 Viewports: Report minimized viewports as zero DisplaySize to be consistent with main branch + comments (#1542) 2020-05-25 16:28:55 +02:00
ocornut
615e9ae345 Docking: Fix undocking (#3243), amend 7b3d3798 (#1738) 2020-05-18 15:08:47 +02:00
omar
3b3af6b731 Docking: Fix extraneous function declaration (#3236) + moved some other declarations in imgui_internal to facilitate moving docking code. 2020-05-16 16:11:42 +02:00
omar
e4d8267188 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
2020-05-16 14:14:51 +02:00
omar
1cd32d3afe Docking: moving small docking context to imgui_internal.h, removed unnecessary indirection, renaming. 2020-05-14 00:19:56 +02:00
Chris Savoie
03ea87ea28 Backends, Win32: Request monitor update when dpi awarness is enabled to make sure they have the correct dpi settings. 2020-05-11 19:31:35 +02:00
Chris Savoie
c46b79846c Metrics: Fix metrics crash with viewports. 2020-05-11 17:54:07 +02:00
omar
6636cb9f2f Viewports: Don't set ImGuiViewportFlags_NoRendererClear when ImGuiWindowFlags_NoBackground is set. (#3213) 2020-05-11 17:29:50 +02:00
Ivan Zinkevich
1e7672acf4 Backends: DX12: Fixed OBJECT_DELETED_WHILE_STILL_IN_USE on viewport resizing. (#3210)
Tested with detaching/attaching a viewport and resizing it. DX12 debug
layer is clean.
2020-05-08 17:26:46 +02:00
omar
8596f2b0fc Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2020-05-08 17:07:40 +02:00
omar
538d28e29e Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2020-05-08 00:00:03 +02:00
omar
574ff0a280 Docking, Settings: Allow reload of settings data at runtime. (#2573) 2020-05-07 23:28:29 +02:00
omar
51e568f9dc Docking: Fix to allow basic reload of non-docking .ini data (following d33021d8) + moved settings blocks 2020-05-07 23:26:59 +02:00
omar
582f4db59b Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
#	imgui_internal.h
2020-05-07 22:13:47 +02:00
omar
5116eee108 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
2020-05-04 15:05:07 +02:00
omar
7ddc1adefb Internals: FIxed commented out IMGUI_DEBUG_LOG_xxx macros, added extra. Revert incorrect 103c5edaa. 2020-04-22 16:41:18 +02:00
ocornut
266dff9bed Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui_internal.h
2020-04-20 11:33:56 +02:00
Rokas Kupstys
7f8b076f2b Viewports, Backends: GLFW: Fix windows resizing incorrectly due to GLFW firing window positioning callbacks on next frame after window is resized manually. (#2117)
+ Docking fixed PVS warning
2020-04-18 11:27:34 +02:00
Patryk Czachurski
36ac557df0
Docking: Fix unused variable warning. (#3135) 2020-04-18 11:09:44 +02:00
SergeyN
013013737f Viewports, Backends: DX12: Fix for crash caused by early resource release. (#3121) 2020-04-13 15:26:03 +02:00
omar
b8e2b2bd6b Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
2020-04-12 20:24:18 +02:00
omar
71eb4034eb Viewports: Fixed viewport merge code not testing the Minimized flag correctly. (#3118) 2020-04-12 17:48:24 +02:00
Rokas Kupstys
c142540705 Viewports, Backends: GLFW: Avoid using window positioning workaround for glfw versions that have it fixed. Amend 09780b8. 2020-04-07 14:15:46 +02:00
omar
3930472f34 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2020-04-06 18:16:13 +02:00
omar
6d03f93067 Docking: Fixed assert preventing dockspace from being stored into a tab. (#3101) 2020-04-06 15:03:01 +02:00
omar
0e884304ee Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_opengl3.cpp
#	imgui.h
2020-04-02 14:27:48 +02:00
omar
9085c2cae2 Docking: Fixed unused definition leftover from a hasty merge. 2020-03-24 18:51:04 +01:00
Rokas Kupstys
e8568f3ec9 Menus: Fix appending to main menubar (#3068). 2020-03-24 18:20:06 +01:00
omar
16a9488c13 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_draw.cpp
2020-03-19 12:44:53 +01:00
ocornut
ea0399414c Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2020-03-11 22:30:34 +01:00
ocornut
1abb02fb67 Viewports: Fix for UWP on IME code moved back-end side (#2895, #2892) + Docking: Comments. 2020-03-11 22:28:31 +01:00
ocornut
fbaf65b8f6 Revert "Viewports: Renamed UpdatePlatformWindows > PlatformWindowsUpdate, RenderPlatformWindowsDefault -> PlatformWindowsRender, DestroyPlatformWindows > PlatformWindowsDestroy (#1542)"
This reverts commit f2c7f3b200.
2020-03-06 17:53:09 +01:00
ocornut
f2c7f3b200 Viewports: Renamed UpdatePlatformWindows > PlatformWindowsUpdate, RenderPlatformWindowsDefault -> PlatformWindowsRender, DestroyPlatformWindows > PlatformWindowsDestroy (#1542) 2020-03-06 17:28:32 +01:00
ocornut
1b579a110d Viewports: Lots of comments about setting up multi-viewports. (#1542) 2020-03-06 17:25:25 +01:00
Rokas Kupstys
7e00cde8a9 Disable false-positive warning that papeared in pvs-studio v7.06.37052.34. 2020-03-05 15:26:20 +01:00
ocornut
1ecc1db226 Fix GCC warning 2020-03-05 12:35:01 +01:00
ocornut
a7ace918fe Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_win32.cpp
#	imgui.cpp
2020-03-05 11:48:57 +01:00
ocornut
91ac93f9a6 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2020-03-03 17:06:38 +01:00
ocornut
05c3e0b898 Merge commit 'caca55c642d16cf1c2649831c5d06b1f26146d12' into docking
# Conflicts:
#	examples/imgui_impl_sdl.cpp
#	imgui.cpp
2020-03-03 17:03:47 +01:00
omar
103c5edaaa Internals: debug log macros. 2020-02-27 16:10:36 +01:00
ocornut
75de34e281 Viewports, Docking: Added per-viewport work area system for e.g. menu-bars. Fixed DocksapceOverViewport() and demo code (overlay etc) (#3035, #2889, #2474, #1542, #2109)
Clarified that BeginMenuMainBar() had an incorrect knowledge of its height (which was previously harmless).
Designed to easily allow for status bars although we don't have/use them yet, but custom code could use them.
2020-02-26 23:58:45 +01:00
ocornut
f032ad6b1f Viewports: Renamed GetRect() to GetMainRect() in prevision for work rect. Comments 2020-02-26 21:02:25 +01:00
ocornut
871727dd2f Viewports: Software mouse cursor is also scaled by current DpiScale. (amend #939) 2020-02-25 15:51:57 +01:00
Rokas Kupstys
3ff13edad9 Viewports: Improve menu positioning in multi-monitor setups.
This change uses mouse position for initial positioning of popup menus. It ensures that menu appears in expected location on monitor mouse is currently hovering. This change fixes incorrect menu positioning (permanent or on the first frame) when menu item spans multiple monitors.
2020-02-25 15:05:58 +01:00
ocornut
7d80a8f4f5 Backends: Fix ImGui_ImplSDL2_InitForMetal() in docking branch. 2020-02-20 12:21:11 +01:00
ocornut
3c80d57dc7 Viewports, Window: Avoid manually clipping resize grips and borders, which messes up with automation ability to locate the items. Also simpler and more standard.
Amend d8f9f6ba2a and 377f730054.
2020-02-19 23:43:04 +01:00
Omar
bb1e6f8af6 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx9/main.cpp
#	examples/imgui_impl_win32.cpp
#	examples/imgui_impl_win32.h
#	imgui.cpp
2020-02-17 18:33:59 +01:00
omar
8432d1bfc7 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2020-02-10 14:03:12 +01:00
omar
7e2d172ae5 Backends: GLFW, SDL: Platform monitors declared properly even if multi-viewport is not enabled. 2020-02-09 17:31:18 +01:00
omar
3bde375078 Nav, Docking: Fixed failing to restore NavId when refocusing due to missing nav window. 2020-02-02 22:40:56 +01:00
omar
365b639981 Nav, Docking: Fixed failing to restore NavId when refocusing a child within a docked window. 2020-02-02 22:17:44 +01:00
omar
d4fc525614 Nav, Focus: Fixed messed up Ctrl+Tab order with Docked windows.
Amend d9bca0d853, fc41839cab, fc42528f13 for docking.
2020-02-02 21:24:53 +01:00
omar
5be649e082 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2020-02-02 21:21:54 +01:00
omar
4b4be11fd2 Docking: Clarifying that DockNode!=NULL when DockIsActive. Comments. Cleanup. 2020-01-31 14:57:47 +01:00
omar
e7bfcb970e Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
#	imgui_internal.h
2020-01-30 15:21:16 +01:00
Rokas Kupstys
7794b104c5 Backends: SDL/Viewports: Fix crash when SDL backend is used with DirectX graphics API and system does not support Vulkan.
We must pass this flag only when we intend to render using vulkan backend.
2020-01-29 14:03:04 +01:00
omar
3b828e6f96 Fix following bbe946f (ImRect <> ImVec4) 2020-01-28 20:29:07 +01:00
omar
bbe946fb6c Minor fixes/tweaks (some to reduce drift wiih master branch) 2020-01-28 20:08:04 +01:00
omar
377f730054 Fix resizing viewport-owning windows when mouse pos is outside the InnerClipRect (can happen with OS decoration on). (#1542) 2020-01-27 17:57:07 +01:00
omar
f5528001f6 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_opengl2.cpp
#	imgui.cpp
#	imgui_internal.h
2020-01-27 14:57:00 +01:00
omar
f68075b333 Docking: Added DockNodeFlagsOverrideSet/DockNodeFlagsOverrideClear (experimental) 2020-01-24 14:20:52 +01:00
omar
f1b5c742ff Viewports: Add various comments 2020-01-20 19:59:55 +01:00
omar
7e068da2bd Docking: Internals: Renamed members from XxxxID to XxxxxId to be more consistent with rest of the codebase (still some inconsistency left that are harder to fix) 2020-01-20 19:29:25 +01:00
omar
44174b1fa1 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_win32.cpp
#	examples/imgui_impl_win32.h
#	imgui.cpp
#	imgui_internal.h
2020-01-14 20:01:27 +01:00
omar
861f786d81 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
2020-01-10 14:38:09 +01:00
Rokas Kupstys
f6951bb67d Viewports: SDL2: Honor NoTaskBarIcon flag under non Win32 OS. (#2117) 2020-01-07 21:13:24 +01:00
omar
3b1b5266e5 Docking: Fixed a bug where the tab bar of a hidden dockspace would keep requesting focus. (#2960) 2020-01-02 22:50:56 +01:00
omar
c163b856d7 Docking: Fix for IMGUI_DEBUG_INI_SETTINGS=1, comments 2020-01-02 22:35:29 +01:00
omar
07eb7adbb4 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2019-12-20 16:36:41 +01:00
omar
4c108d22f0 Minor bits, placeholder aimed at facilitating merging of Tables branch into Docking
# Conflicts:
#	imgui.cpp
2019-12-19 17:01:22 +01:00
omar
c706ff6f3a Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_sdl.cpp
#	imgui.cpp
2019-12-18 20:49:41 +01:00
omar
992736dc5d Merge branch 'refs/heads/master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_sdl.cpp
#	examples/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2019-12-13 17:06:27 +01:00
omar
927580d4a8 Docking: Cleanup, rename DockNodePreviewDockCalc() -> DockNodePreviewDockSetup() 2019-12-04 23:06:36 +01:00
omar
a1e4af62d3 Docking: Fix bug added in 71a58261 + Misc docking omments 2019-11-28 20:52:46 +01:00
omar
28dd8d7efd Docking: Fixed various conflicts not properly resolved on 813e0c1
New git client confusion.
2019-11-27 19:27:44 +01:00
omar
4dff49b2f1 Docking, Viewports: Moving code.
Moved NewFrame() sanity checks in NewFrameSanityChecks().
Moved some of DockNodeUpdate() into DockNodeUpdateForRootNode().
2019-11-27 19:13:15 +01:00
omar
71a58261f6 Docking: Internals: Removed redundancy in code path leading to the BeginAsDockableDragDropSource(), clarified UpdateMouseMovingWindowEndFrame()
Note that the ConfigWindowsMoveFromTitleBarOnly path for UpdateMouseMovingWindowEndFrame() would previously test the window->RootWindow title bar instead of window->RootWindowDockStop. This didn't have any side effect afaik because we wouldn't enter that function anyway as clicking on any tab bar would trigger the move before UpdateMouseMovingWindowEndFrame() does it. However for consistency made the UpdateMouseMovingWindowEndFrame()code more correct.
+ minor renaming
2019-11-27 18:57:01 +01:00
omar
8d1b82d596 Docking: Internals: Rename StartMouseDragFromTitleBar() -> StartMouseMovingWindowOrNode(), clarify. 2019-11-27 15:51:15 +01:00
omar
3096e7a9cd Viewports: Preserve last known size for minimized main viewport to be consistent with secondary viewports.
Amend 606175b9, d8ab2c1a.
However becomes inconsistent with viewport-enabled setup. Should report some of that logic in master, need back-end rework.
2019-11-26 21:02:28 +01:00
omar
1c3a9c8e74 Docking: Remove Size > 0.0f asserts added in 718e15c7 and 7c183dc6. (#2690, #2109, #2906)
In #2906 the zero input came from a minimized viewport, but even without it we cannot prevent DockNode size from eventually reaching zero as padding are taken from the starting size.
In a separate commit we'll however shortcut some of the existing codepath on zero-sized viewport to reduce the likehood of lossy side-effects (just like we don't call ClampWindowRect in Begin)
2019-11-26 20:25:54 +01:00
omar
813e0c18e6 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx10.h
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx11.h
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_dx12.h
#	examples/imgui_impl_dx9.cpp
#	examples/imgui_impl_dx9.h
#	examples/imgui_impl_metal.h
#	examples/imgui_impl_metal.mm
#	examples/imgui_impl_opengl3.cpp
#	examples/imgui_impl_opengl3.h
#	examples/imgui_impl_vulkan.cpp
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2019-11-26 12:23:43 +01:00
omar
3a82994429 Docking: Can undock from the small triangle button. (#2109,. #2645) 2019-11-22 23:12:16 +01:00
omar
106184bbea Docking: Fixed node->HasCloseButton not honoring ImGuiDockNodeFlags_NoCloseButton in a floating node, leading to empty space at the right of tab-bars with those flags. (#2109) 2019-11-22 23:11:21 +01:00
omar
3895363432 Merge branch 'master' into docking inc alter GetWindowResizeID
# Conflicts:
#	imgui.cpp
2019-11-18 13:58:50 +01:00
omar
a1e43c682a Merge branch 'master' into docking (with fixes)
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-11-15 15:32:36 +01:00
omar
c3fd4ae473 Docking: comments 2019-11-12 11:06:02 +01:00
omar
69b5c2f541 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-11-08 15:45:12 +01:00
omar
a704614b3e Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2019-11-04 16:33:57 +01:00
omar
6024051a2f Viewport: Fixed 32380a0 (#2876) 2019-10-29 21:18:01 +01:00
omar
b3e94f5de8 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_opengl3.cpp
#	imgui_widgets.cpp
2019-10-29 17:21:19 +01:00
omar
32380a0112 Viewport: Store current dpi scale in context. 2019-10-29 16:43:11 +01:00
omar
664fb38e39 Docking: child windows don't use style.ChildRounding. 2019-10-25 11:13:51 +02:00
omar
0cbb96895a Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_dx12.cpp
#	imgui.cpp
#	imgui.h
#	imgui_widgets.cpp
2019-10-24 15:11:37 +02:00
omar
7b77cb3bb8 Backend: DX12: Fixed incorrect assert (#2851) 2019-10-21 13:38:33 +02:00
omar
6faad0c34f Backend: DX12: Amend 899e485. Fix memory leaks. Remove unused variable. (#2851)
(cherry picked from commit 39e2db6d94c295e7468c6a5fb39d247c641fb123)
2019-10-18 18:21:44 +02:00
Ilya.Sevrikov
05c1f2795a Add multi-viewports for DX12. (#2851)
(cherry picked from commit 899e48565d1ecefde06063f99c75e702adcef175)
2019-10-18 18:21:35 +02:00
omar
7feccf9ab2 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx10.h
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx11.h
#	examples/imgui_impl_dx9.cpp
#	examples/imgui_impl_dx9.h
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_opengl2.cpp
#	examples/imgui_impl_opengl2.h
#	examples/imgui_impl_opengl3.cpp
#	examples/imgui_impl_opengl3.h
#	imgui.cpp
2019-10-18 16:50:30 +02:00
omar
bf4880f6a2 Merge branch 'master' into docking 2019-10-07 19:14:37 +02:00
omar
e0c0e53edf Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2019-10-04 19:22:42 +02:00
omar
6994bf10bc Merge branch 'master' into docking + fix for RenderMouseCursor()
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui_draw.cpp
#	imgui_internal.h
2019-09-24 17:14:51 +02:00
omar
3233d85d2f Merge branch 'master' into docking 2019-09-22 22:16:11 +02:00
omar
13f00331da Docking: Added ImGuiDockNodeFlags_NoDocking flag. (#2109) 2019-09-21 14:50:02 +02:00
omar
af93c21cf9 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-09-18 17:27:14 +02:00
omar
cf98290873 Backends: DirectX9: Workaround for windows not refreshing when main viewport has no draw call. (#2560) 2019-09-17 18:32:26 +02:00
omar
1ca6ff974c Viewport: fix to allow multiple shutdown / calls to DestroyPlatformWindows(). (#2769) 2019-09-17 18:02:58 +02:00
omar
575df6f192 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui_draw.cpp
#	imgui_internal.h
2019-09-17 16:35:50 +02:00
omar
0bdc145343 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-08-31 19:19:00 +02:00
omar
d049a7988c Docking: comments for DockBuilder API. 2019-08-31 16:51:12 +02:00
omar
a4af3cc814 Viewport, GLFW: Fix for #2756 under Windows. 2019-08-29 15:53:33 +02:00
Rokas Kupstys
a89a3cd2f1 Viewports, GLFW: Fix window having incorrect size after uncollapse. Issue manifests on Linux when window is in it's own viewport. (#2756, #2117) 2019-08-29 15:49:52 +02:00
Rokas Kupstys
09780b8b3d Viewport: Fix setting window size on macos (glfw). (#2767, #2117)
MacOS positions windows by their bottom-left corner why the rest of the world (including imgui) position windows by the top-left corner. This created an issue where collapsing imgui window would cause window header to remain at the bottom the full window rect. Likewise resizing window by using sizing handle caused window to grow upwards when we tried to expand window downwards.

This workaround moves window to the opposite direction by the delta of size change creating an illusion that windows are positioned by their top-left corner.
2019-08-29 13:02:42 +02:00
omar
9e294be5c5 Docking: Fix for node created at the same time as windows that are still resizing (typically with io.ConfigDockingAlwaysTabBar) to not be zero/min sized. (#2109)
The fix delay their visibility by one frame, which is not ideal but not very problematic as the .ini data gets populated after that
2019-08-29 10:45:33 +02:00
omar
a01d149369 Fixed context popup windows from not having the NoDocking flag. (#2763) 2019-08-28 10:52:17 +02:00
omar
483534b525 Internals: Using simpler ImVec2ih construct + fixed misnamed member. 2019-08-23 12:31:14 +02:00
omar
e1fca8d982 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-08-23 12:21:49 +02:00
omar
10a202422a Docking: Extracted some of BeginDocked() into a DockContextBindNodeToWindow() function.
Moved one of the undocking blurb to favor fast path.
(Commit intended to have no functional side effects)
2019-08-22 13:51:17 +02:00
omar
27431dcc6b Docking: fix BeginDocked() path that creates node so that SetNextWindowDockID() doesn't immediately discard the node..(#2109)
Amend 515ecbddc2, not sure at this point if the (auto_dock_node) flag was needed at all.
Comments. Exposed DockContextGenNodeID() in imgui_internal.h
2019-08-22 13:51:16 +02:00
omar
d8f9f6ba2a Viewport: Fixed issue where resize grip would display hovered (before of extruded hit rectangle) while mouse is still off the OS bounds so click would miss it and focus the OS window behind expected one. (#1542) 2019-08-22 13:51:16 +02:00
omar
72090b646f Fixed incorrect assignment of IsFallbackWindow which would tag dock node host windows created in NewFrame() as such, messing with popup viewport inheritance. 2019-08-22 11:35:17 +02:00
omar
aedcd2fb1a Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_dx11.cpp
#	imgui.cpp
2019-08-19 21:49:53 +02:00
omar
76ccbb899d Viewport: Fix modal/popup window being stuck in unowned hidden viewport associated to fallback window without stealing it back. (#1542)
Viewport: Fix modal reference viewport when opened outside of another window.
+ Comments
2019-08-19 11:58:30 +02:00
omar
5d87ee8d82 Internals: Added function index for Viewport and Docking. Renamed a few functions. 2019-08-16 15:29:58 +02:00
omar
451c756b01 Docking: Modals don't need to set ImGuiViewportFlags_NoFocusOnClick. This also mitigate the common described by #2445, which becomes particularly bad with unfocused modal. (#1542) 2019-08-01 16:23:54 -07:00
omar
3aa9aae0be Docking: Fix a crash that could occur with a malformed ini file (DockNode Parent value pointing to a missing node) 2019-08-01 15:50:05 -07:00
omar
967073ba3d Viewport: Handle case where host window gets moved and resized simultaneous (toggling maximized state). There's no perfect solution there, than using io.ConfigViewportsNoAutoMerge = false. (#1542) 2019-07-31 20:08:06 -07:00
omar
b8d8355f10 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2019-07-31 14:34:58 -07:00
omar
07c52a25ff Docking: Recording dockspace parent window so pruning doesn't zealously lose the location of nodes. (#2109) 2019-07-29 15:56:59 -07:00
omar
cb2de62bb1 Docking: Renaming, comments. 2019-07-29 15:56:59 -07:00
Chris Savoie
949a9fa2cb Vulkan: Fix crash when viewports are disabled and memory leak on shutdown. (#2698) 2019-07-29 15:52:30 -07:00
omar
a1164399b0 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2019-07-27 18:21:41 -07:00
omar
e5b905481d Viewport: Refactored ViewportFlagsOverrideMask+ViewportFlagsOverrideValue into ViewportFlagsOverrideSet+ViewportFlagsOverrideClear which appears easier to grasp. (#1542)
(cherry picked from commit 9437630872e7ca19065bee78fcafaab54a0d5bf2)
2019-07-24 13:45:18 -07:00
omar
7c183dc6a1 Docking: Explicitly inhibit constraint when docked for now (#2690, #2109)
Added asserts to catch issues.
2019-07-24 11:18:13 -07:00
omar
7fbd72b735 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-07-23 21:40:57 -07:00
omar
969278fc0b Docking: Fixed dragging/resizing from OS decoration not marking settings as dirty.
Internals: Added IMGUI_DEBUG_LOG_DOCKING, IMGUI_DEBUG_LOG_VIEWPORT macros to easily enable/disable a bunch of logging code.
2019-07-23 21:29:43 -07:00
omar
efc4c0fe9d Internals: Made IMGUI_DEBUG_LOG redefinable in imconfig.h. Comments. Fix to allow Metrics's NodeWindow() being called with a NULL window. 2019-07-23 21:26:15 -07:00
omar
81b24bd728 Docking: Moving types in imgui.h 2019-07-23 13:37:52 -07:00
omar
db2581bee9 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2019-07-23 13:35:01 -07:00
omar
75136d3bea Internals: Removed ShowDockingDemo(), moved into Metrics. Metrics: Added more links to browse window->node, node->window, node->node etc. 2019-07-22 11:51:04 -07:00
omar
0e6a096afd Docking: Renamed io.ConfigDockingTabBarOnSingleWindows to io.ConfigDockingAlwaysTabBar. (#2109)
Added ImGuiWindowClass::DockingAlwaysTabBar to set on individual windows.
2019-07-22 11:29:22 -07:00
omar
6f8d34768d Docking: Removed seemingly unnecessary test in TabItemEx() for undocking tab leading to window move. Added ImGuiDockNode::IsFloatingNode() helper to clarify code intent in various places. 2019-07-22 11:02:44 -07:00
omar
9cda3035fd Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_sdl.cpp
#	imgui.cpp
2019-07-22 10:29:14 -07:00
omar
47f5ad32b7 Perform simple check: error if Docking or Viewport are enabled _exactly_ on frame 1 (instead of frame 0 or later), which is a common error leading to loss of .ini data. (#2109) 2019-07-21 12:05:04 -07:00
omar
9f35ba8546 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2019-07-19 15:19:10 -07:00
omar
7fd34d4f30 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-07-17 18:48:16 -07:00
omar
bb2aa5e770 Docking: Making it possible to undock a node by clicking on the tab bar / title bar for the node. (#2645, #2109) 2019-07-17 13:55:00 -07:00
omar
56e10f1c35 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2019-07-16 18:29:31 -07:00
omar
718e15c7de Docking: Fix so that an appearing window making a dock node reappear won't have a zero-size on its first frame (because dock node ->Size was 0.0 unlike ->SizeRef) (#2109)
Docking: Added ImGuiDockNode to .natvis file.
2019-07-16 11:45:52 -07:00
omar
8bc6d976cb Docking: Fixed using ImGuiDockNodeFlags_AutoHideTabBar with ConfigDockingTabBarOnSingleWindows. (#2109) 2019-07-15 14:17:01 -07:00
omar
dd80db87a6 Viewport: Added ImGuiViewportFlags_NoAutoMerge to prevent merging into host viewport in a per-window basis via the ImGuiWindowClass override mechanism. (#1542) 2019-07-15 13:35:21 -07:00
omar
1f54c16f52 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2019-07-02 18:47:10 +02:00
omar
50d421fa19 Docking: Fixed GetBackgroundDrawList(), GetForegroundDrawList() overwriting ImDrawList flags after clear, leading to the AllowVtxOffset flag not being cleared. (#2638) 2019-06-26 09:52:25 +02:00
omar
adbbd17cb6 Addendum to #2635. Add support for multi-viewports in SDL+DX!! example. making all Win32-centric back-ends handle PlatformHandleRaw. Using the field to use/store the HWND for internal purpose in SDL/GLFW back-ends. (#1542) 2019-06-18 23:37:57 +02:00
Vincent Hamm
3e8eebfbec Viewport: Added PlatformHandleRaw. Update SDL+DX11 example. (#1542, #2635) 2019-06-18 23:16:52 +02:00
omar
2cbc0f1287 Restore SLN which in Docking branch includes more projects. 2019-06-18 23:13:12 +02:00
omar
e2c1f0a7cd Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2019-06-18 23:12:50 +02:00
omar
ca43436cd3 Fix monitor dpi info not being copied to main viewport when multi-viewports are not enabled. (#2621, #1676) + Tweaks, short path in FindPlatformMonitorForRect(). 2019-06-17 11:19:34 +02:00
omar
b27fd87177 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui.h
2019-06-17 11:10:14 +02:00
omar
07d3083279 Docking: Fixed rendering of outer decoration happening on non-visible docked window (#2623, #2109). Revealed by 0770449. We are actually better than before now, as previously those would get unnecessarily get rendered into a hidden draw list. 2019-06-13 10:19:14 +02:00
omar
d3d998a885 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/README.txt
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
#	imgui_widgets.cpp
2019-06-12 18:40:50 +02:00
omar
5f409c6fcc Merge branch 'master' into docking
# Conflicts:
#	examples/example_apple_opengl2/main.mm
#	examples/example_emscripten/main.cpp
#	examples/example_glfw_opengl2/main.cpp
#	examples/example_glfw_opengl3/main.cpp
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_glut_opengl2/main.cpp
#	examples/example_sdl_opengl2/main.cpp
#	examples/example_sdl_opengl3/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	examples/example_win32_directx10/main.cpp
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx12/main.cpp
#	examples/example_win32_directx9/main.cpp
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_sdl.cpp
#	imgui.cpp
#	imgui_widgets.cpp
2019-06-06 16:20:12 +02:00
omar
63310acd58 Synced/merged minor cruft from master branch to minimize drift. Only meaningful change AFAIK is removing ImGuiComboFlags_PopupAlignLeft flag from the tab list combo emitted by TabBar. 2019-06-06 16:16:18 +02:00
omar
e6850891cc Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-06-05 16:09:06 +02:00
omar
440ad0b440 Merge branch 'master' into docking 2019-06-05 00:37:20 +02:00
omar
5cdd788f30 Comments (#2599). Moved branch Changelog above 1.71 wip one. Added some missing changelog bits. 2019-06-05 00:37:14 +02:00
omar
596d81a973 Merge branch 'master' into docking 2019-05-31 12:09:40 +02:00
omar
84f3ecc231 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-05-30 18:52:24 +02:00
omar
cc48f1e5dd Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_metal.h
#	examples/imgui_impl_metal.mm
2019-05-30 16:47:11 +02:00
omar
8dc04a4c9f Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx9.cpp
#	examples/imgui_impl_opengl3.cpp
#	imgui.h
#	imgui_demo.cpp
2019-05-29 16:32:27 +02:00
omar
c72040a715 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx10.h
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx11.h
#	examples/imgui_impl_dx9.cpp
#	examples/imgui_impl_dx9.h
#	examples/imgui_impl_opengl3.cpp
#	examples/imgui_impl_opengl3.h
#	examples/imgui_impl_osx.h
#	examples/imgui_impl_osx.mm
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
#	imgui_internal.h
2019-05-29 16:20:26 +02:00
omar
c7c1bf177b Docking: Fixed DockBuilderRemoveNode() from overwriting other parent node flags when trying to move the CentralNode flag. 2019-05-28 00:06:21 +02:00
omar
5b0e59d9d5 Docking: Saving local _NoResize flag. (#2583) 2019-05-27 22:11:21 +02:00
omar
7c06d9f043 Docking: Saving the NoTabBar, NoWindowMenuButton, NoCloseButton fields of dock node into the .ini file. Added them to the Metrics window. (#2583, #2423, #2109). 2019-05-27 17:06:17 +02:00
omar
511e32e8ca Docking: Clarified terminology of docking/tablist/collapse button into Window Menu button matching master. Added private ImGuiDockNodeFlags_NoWindowMenuButton, ImGuiDockNodeFlags_NoCloseButton flags. (#2583, #2109) 2019-05-27 12:35:20 +02:00
omar
e5dfa0855f Docking: Honor style.WindowMenuButtonPosition setting in docking node. 2019-05-24 21:59:44 +02:00
omar
afad952450 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2019-05-24 21:58:17 +02:00
omar
fda1365c15 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-05-23 00:04:25 +02:00
omar
04022114d9 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2019-05-21 14:47:29 +02:00
omar
1575a3fbcd Docking: Fixed temporarily losing Dockspace flag when merging remaining sibling back into a parent node. (#2563, #2109)
Would trigger an assert in the Passthru hole path. Broken by fd5859ed.
2019-05-19 17:00:17 +02:00
omar
7e772f6a51 Docking: Fixed undocking whole node (from collapse/docking menu button) from losing its size/pos. Made collapose/docking menu id easier to compute for testing. 2019-05-18 18:42:59 +02:00
omar
2e5860b5a0 Docking: Fixed incomplete merge of 36e714a leading to undocking. #2109 2019-05-18 13:00:00 +02:00
omar
4158cba1ff Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_win32.cpp
#	imgui.cpp
#	imgui_internal.h
2019-05-13 19:23:18 +02:00
Chris Savoie
b955e485f1 Fixed unused variables warnings when asserts are compiled out. (#2551) 2019-05-12 17:53:08 +02:00
Alzathar
02d6d2d487 Platform Binding for GLFW updated with the release of GLFW 3.3 (#2547)
* With the release of GLFW 3.3, it is now possible to detect correctly monitors working area (see GLFW_HAS_MONITOR_WORK_AREA). GLFW 3.3 also introduced the window hint GLFW_FOCUS_ON_SHOW. This fixed the case where a new created window (viewport) takes the focus even if not visible.

* Disable a GLFW 3.2 windows hack when GLFW 3.3 is detected (related to window focused when shown).
2019-05-11 10:54:56 +02:00
omar
b668726a38 Fixed a PVS Studio static analyzer warning. 2019-05-10 22:58:24 +02:00
omar
835a8b2c9b Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2019-05-10 22:56:43 +02:00
omar
239c8732d7 Viewports: Minor tweaks. (#2471) 2019-05-08 18:33:08 +02:00
omar
9bf3f910c8 Viewports: Fix to avoid SetNextWindowViewport being overrided by creation of a standalone viewport. (#2544, #1542) 2019-05-08 18:20:13 +02:00
omar
e6c982509d Examples: DirectX9: Fixes for multi-viewports. Avoid using a depth/stencil target for secondary viewport. (#2520, #2502) 2019-05-06 12:12:32 +02:00
omar
9ddb8493d5 Examples: DirectX9: Fixes for multi-viewports, destroying all swap chains. (#2520, #2502) 2019-05-06 12:07:29 +02:00
omar
76e61958fd Merge branch 'master' into docking
# Conflicts:
#	examples/README.txt
#	examples/imgui_impl_dx9.cpp
#	imgui.cpp
#	imgui.h
2019-05-06 10:16:43 +02:00
ibachar
4f22a45cb5 Removed git merge leftovers 2019-05-04 15:02:28 +02:00
omar
825b61e4ba Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_dx9.cpp
#	examples/imgui_impl_opengl2.cpp
#	examples/imgui_impl_opengl3.cpp
#	examples/imgui_impl_vulkan.cpp
#	imgui.cpp
2019-05-02 14:56:47 +02:00
omar
7e67aba286 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-04-29 13:06:55 +02:00
omar
a649d904d7 Examples: Emscripten: Fixed not enabling Docking and Nav by default. (#2494) 2019-04-26 00:28:28 +02:00
omar
dfb82d5c22 Merge branch 'master' into docking
# Conflicts:
#	examples/example_sdl_opengl2/main.cpp
#	examples/example_sdl_opengl3/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	examples/imgui_impl_sdl.cpp
#	examples/imgui_impl_sdl.h
#	imgui.cpp
2019-04-25 17:53:11 +02:00
omar
d0fb547dc1 Viewports: Avoid rendering/swapping secondary viewports that are minimized. (#1542, #2496) 2019-04-22 11:46:04 +02:00
omar
20f0cb0281 Docking: Fixed an issue where DockBuilderSplitNode() wouldn't update the CentralNode shortcut immediately, which was problematic for immediately following DockBuilderDockWindow(). (#2109) 2019-04-19 20:28:43 +02:00
omar
03b64defa5 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2019-04-19 19:52:45 +02:00
omar
655ebe4eaf Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
2019-04-16 13:14:10 +02:00
omar
b89202824e Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_sdl.cpp
2019-04-15 16:03:17 +02:00
omar
f70eacee8e Docking: Internal: Added helper for automation to process docking at the mouse level. 2019-04-13 19:50:30 +02:00
omar
433a7556c7 Docking: Fixed another issue where the resulting node of a split would sometimes recall the pos/size of previous host window. Spent a whole day adding framework for testing more of docking so hopefully we'll heading toward the magical world of less regressions. (#2109) 2019-04-13 19:19:56 +02:00
omar
712203dbcb Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-04-13 18:53:00 +02:00
omar
800fb26606 Docking: Renamed target_node > node in some functions to facilitate debugger watch use across functions. 2019-04-13 00:36:24 +02:00
omar
224f087a5f Docking: Rename typo Autority -> Authority + Rename DockContextNewFrameUpdateDocking -> DockContextUpdateDocking. 2019-04-13 00:36:24 +02:00
omar
092426bed2 Docking: Hold Shift to force disable docking. (#2109) 2019-04-13 00:27:44 +02:00
omar
c6f1b7b92a Tests: Added hook/tweaks for imgui-test engine. + Fixed warnings. 2019-04-13 00:27:44 +02:00
omar
328e4fa7e7 Merge branch 'master' into docking
# Conflicts:
#	imgui_demo.cpp
2019-04-11 15:53:38 +02:00
omar
f3110a57cd Docking: Fixed an issue where newly created dock node override hosted window pos/size (#2109, #2386) 2019-04-11 14:51:01 +02:00
omar
cf029b3e1c Merge branch 'master' into docking 2019-04-08 18:05:52 +02:00
omar
7056032483 Merge branch 'vulkan_fix_docking' into docking 2019-04-07 16:23:34 +02:00
omar
50ceb25003 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_vulkan.cpp
2019-04-07 16:23:31 +02:00
omar
9c364b16ff Merge branch 'vulkan_fix_master' into vulkan_fix_docking 2019-04-05 20:30:42 +02:00
omar
d61caf5714 Vulkan, Viewports: ImGui_ImplVulkan_RenderDrawData and renderer back-end automatically manage ImGui_ImplVulkanH_WindowRenderBuffers for each viewports so user doesn't have to do it. (#2461, #2348, #2378, #2097) 2019-04-05 18:52:45 +02:00
omar
e70f866ed2 Merge branch 'vulkan_fix_master' into vulkan_fix_docking (WARNING: as is the validation layer will error on same vertex/index buffer being used for all frames)
# Conflicts:
#	examples/imgui_impl_vulkan.cpp
#	examples/imgui_impl_vulkan.h
2019-04-05 18:27:15 +02:00
MindSpunk
9acb158990 Vulkan, Viewports: Fix for resizing viewport windows crashing. (#2472) 2019-04-05 16:51:35 +02:00
omar
1ba79baab5 Vulkan, Viewports: Fixed ImGui_ImplVulkan_SetWindowSize() not recreating command-buffers, fence etc. (#2472, #2461, #2071) 2019-04-05 16:33:41 +02:00
omar
01de69de36 Vulkan: Note for unsupported feature with multi-viewports. (#2071) 2019-04-05 00:25:42 +02:00
omar
8ec24036d7 Vulkan: Viewports: Removed redundant field. 2019-04-05 00:01:25 +02:00
omar
29269d2aa8 Merge branch 'vulkan_fix_master' into vulkan_fix_docking
# Conflicts:
#	examples/imgui_impl_vulkan.cpp
2019-04-04 23:55:33 +02:00
omar
43a85dd02e Merge branch 'master' into docking 2019-04-04 22:10:18 +02:00
omar
9ba64f9fe3 Viewport: Fixed PushClipRectFullScreen() missing out on negative coordinates. Among other things, the outer highlight during CTRL+Tab wouldn't appear in negative coordinates monitors. (~#2176, #1542) 2019-04-04 22:02:36 +02:00
omar
49fb8e6c45 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_dx9.cpp
#	examples/imgui_impl_opengl3.cpp
2019-04-03 11:17:26 +02:00
omar
9bf6509c6e Docking: Fixed focus restore lagging by a frame when a tab stops being submitted. (#2109) Building on a little build of technical debt there, should transition toward a more general docking-agnostic system (#2304) 2019-03-28 18:43:27 +01:00
omar
5af385ea78 Viewport: Renamed member + added note about a Docking issue with restoring focus. 2019-03-28 18:02:03 +01:00
omar
47219dd5c6 Docking: Remove code in BeginDocked() to set HiddenFramesCannotSkipItems based on upcoming tab bar selection, solely based on focus (might break something subtle?). Follow-up to c355ed1267. (#2453, #2109) 2019-03-28 16:13:06 +01:00
omar
b6ae8a0dca Docking: Disable SkipItems when directly/programmatically focused (possible generalization of code currently in BeginDocked which relies on tab bar interaction, will remove that code in next commit). (#2453, #2109) 2019-03-28 16:11:50 +01:00
omar
a33d45d7cd Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2019-03-28 15:48:25 +01:00
omar
5a665e423c Docking: Added ImGuiDockNodeFlags_NoTabBar (not exposed publicly). (#2423, #2109) 2019-03-27 20:44:49 +01:00
omar
fc95da8aa3 Docking: Internals: Moved CentralNode and HiddenTabBar state into LocalFlags for consistency. (#2423, #2109) 2019-03-27 20:32:44 +01:00
omar
fd5859ed04 Docking: Separating SharedFlags vs LocalFlags in dock node so settings can be applied to individual nodes. Made _NoResize logic on single node applies as expected. (#2423, #2109) 2019-03-27 19:00:36 +01:00
omar
75e3793f4d Docking: Fix DockBuilderAddNode() not storing flags when creating floating node. 2019-03-27 17:36:52 +01:00
omar
8d4b5fef1d Renamed ImGuiDockNodeFlags_Dockspace to ImGuiDockNodeFlags_DockSpace for consistency. DockBuilderCopyDockspace() to DockBuilderCopyDockSpace(). Made casing consistent elsewhere. (#2109) 2019-03-27 17:36:52 +01:00
omar
04a9ce3a18 Docking: Renamed ImGuiDockNodeFlags_PassthruDockspace to ImGuiDockNodeFlags_PassthruCentralNode. + Comments, shallow tweaks. (#2109) 2019-03-27 16:16:31 +01:00
omar
87883abd86 Docking: Tweak and silencing PVS studio static analyzer (back to zero warnings among our selected ones). 2019-03-26 14:15:56 +01:00
Tom Watson
f20725eada Docking: Fixed an issue where windows docked into a node that's part of their dockspace wouldn't recover their order correctly after init. (#2109)
(It only worked on floating dock node for the accidental reason that BeginDocked would generally early out on the first frame)
2019-03-26 13:58:03 +01:00
omar
26646f2450 Docking: Wrapping tab bar creation/destroy to make it easier to debug them. 2019-03-26 12:41:50 +01:00
omar
f208fd7ebb Docking: Fixed crash with ImGuiDockNodeFlags_AutoHideTabBar flag. (#2423, #2109) 2019-03-26 12:33:58 +01:00
omar
9350158d61 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui_internal.h
2019-03-25 16:08:09 +01:00
omar
7a5196601e Docking: BeginDocked() doesn't need to rely on tab bar data (will allow removing tab bar). 2019-03-18 09:48:06 -07:00
omar
c7619d4a6a Docking: Preserve existing docked nodes when setting the ImGuiDockNodeFlags_NoDockingInCentralNode flag. (#2423, #2109) 2019-03-18 09:48:00 -07:00
omar
7ba774a440 Viewports: Fixed being unable to refocus windows when ConfigViewportsNoTaskBarIcon + ConfigViewportsNoDecoration are enabled. (#2420, #1542) [@PathogenDavid] + comments. 2019-03-15 15:35:46 +01:00
omar
b1af4d36ce Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/example_win32_directx10/main.cpp
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx12/main.cpp
#	examples/example_win32_directx9/main.cpp
2019-03-13 15:30:35 +01:00
omar
c3f20f6b81 Viewport: DestroyPlatformWindow() skips calling user function if PlatformWindowCreated is set. + Clarified comment about implicit Debug viewport which may be hogging a viewport. 2019-03-13 11:27:30 +01:00
David Maas
e7dca4fec2 Fixed main viewport not being marked as created, which broke updating the IME input position for the main viewport.
This change also removes the logic scattered about that compensated for PlatformWindowCreated being wrong for the main viewport.
2019-03-13 10:59:32 +01:00
omar
9afb849e16 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_sdl.cpp
2019-03-12 18:28:47 +01:00
omar
e1acb0b1fa Docking: Fixed node merging altering window position incorrectly in a way that would make SizeContents incorrect for the next frame (making scrollbar flicker). (#2414, #2109) 2019-03-11 19:46:37 +01:00
omar
3ead9820f7 Viewport: Popups and Tooltips viewports are correctly parented to the parent window's viewport. (#2409, #1542) 2019-03-11 16:51:46 +01:00
omar
f7db4fad31 Merge branch 'master' into docking
# Conflicts:
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx12/main.cpp
#	examples/example_win32_directx9/main.cpp
#	imgui.cpp
2019-03-11 16:08:16 +01:00
omar
cf4fcc4735 Viewports: Fixed delayed window pos->viewport pos sync leading to monitor not being updated at the time of clamping window position in Begin. (#2415, #1542) 2019-03-11 13:15:00 +01:00
omar
3eedb542a6 Viewports: Renamed ConfigViewportsNoParent to ConfigViewportsNoDefaultParent. Fix outdated comments in examples. 2019-03-11 11:07:23 +01:00
omar
ecf7666624 Docking: Fixed an issue where removing the last window from a dockspace node that is not a central node without remove the node. (#2414, #2109) 2019-03-10 22:19:18 +01:00
omar
d77d3416d3 Merge branch 'master' into docking 2019-03-07 18:40:55 +01:00
omar
5ce93bc0cc Refactor: Move viewport code under other subsystem to simplify merging (4) (moving in multiple commits to make diff/patch behave nicely) 2019-03-07 18:39:31 +01:00
omar
54a129a2e2 Refactor: Move viewport code under other subsystem to simplify merging (3) (moving in multiple commits to make diff/patch behave nicely) 2019-03-07 18:38:40 +01:00
omar
bdf60dac6a Refactor: Move viewport code under other subsystem to simplify merging (2) (moving in multiple commits to make diff/patch behave nicely) 2019-03-07 18:37:17 +01:00
omar
bbb543fc16 Refactor: Move viewport code under other subsystem to simplify merging (1) (moving in multiple commits to make diff/patch behave nicely) 2019-03-07 18:36:11 +01:00
omar
28d8eb220b Fix for Android char being unsigned by default (#2408) 2019-03-07 16:07:16 +01:00
Gilad Reich
0a6c5bc234 Examples: DirectX9: Added support for multi-viewport (#2394) 2019-03-06 21:36:42 +01:00
omar
e91d275b10 Merge branch 'master' into docking
# Conflicts:
#	imgui_demo.cpp
2019-03-06 21:18:46 +01:00
David Maas
8b8ab1db5b Removed redundant declaration of SetNextWindowClass. (#2402) 2019-03-06 09:39:16 +01:00
omar
e02d6014bf Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-03-05 22:13:38 +01:00
omar
8414c0bb09 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2019-03-04 18:08:19 +01:00
omar
49eb5f0280 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_opengl3.cpp
2019-03-03 23:34:56 +01:00
Richard Mitton
7a536f1bd2 Examples + Viewport: GLFW: context wasn't set when using multiple windows. (#2392) 2019-03-03 23:01:43 +01:00
omar
ff0c6c2bde Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2019-02-27 19:00:09 +01:00
omar
4eecf80a4b Moved Settings section above Docking to facilitate master<>docking merges. 2019-02-26 15:34:47 +01:00
omar
104294c7e4 Moved Logging/Capturing section above Docking to facilitate master<>docking merges. 2019-02-26 15:33:50 +01:00
omar
6b43a314bf Merge branch 'master' into docking 2019-02-26 12:53:38 +01:00
omar
8915f7933a Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2019-02-24 23:24:07 +01:00
omar
87ded34f9f Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_opengl3.cpp
#	imgui_widgets.cpp
2019-02-22 12:29:18 +01:00
omar
ff0f9aa856 Comments for Linux/Mac (#2117) 2019-02-19 16:36:06 +01:00
omar
9dc02464a4 Merge branch 'master' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2019-02-19 13:04:35 +01:00
omar
7573d10a4a Docking: Fixed bad ever-growing/ leak (accumulating text into TabsNames forever, fix d38f4dc14 from February 5th, affected docking branch only). (#2109) 2019-02-18 16:50:39 +01:00
omar
5412cdf2c8 Docking: Made DockBuilderSplitNode/DockNodeTreeSplit work even if the node doesn't have a size yet. (#2357, #2109)
Followup to fa0ce4b7d, at that time I came to the conclusion that programmatic split couldn't work without knowing the size ahead of it. I forgot the reason for that.  May bite us back!
2019-02-18 16:23:54 +01:00
omar
3de440fda2 Docking: Fixed assert in DockContextProcessDock() preventing some uses of DockNodeBuilder api. (#2357, #2109) 2019-02-18 16:13:17 +01:00
omar
5bf9029bf9 Merge branch 'master' into docking 2019-02-18 12:16:13 +01:00
omar
09c9bf2edb Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2019-02-14 20:35:11 +01:00
omar
b46076458c Examples: Win32: Removed unused code left-over from merge e9c625a1dc 2019-02-13 18:29:49 +01:00
omar
8691b56136 Merge branch 'master' into docking 2019-02-12 10:30:48 +01:00
omar
7f6a025c93 Viewport: SDL: Inherit SDL_WINDOW_ALLOW_HIGHDPI flag from main viewport. (#2306) 2019-02-11 19:00:33 +01:00
omar
2cada3c143 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_opengl2.cpp
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui_widgets.cpp
2019-02-11 18:59:49 +01:00
omar
4a3a895be9 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
2019-02-06 14:47:53 +01:00
omar
f6fbb99a9c Examples: SDL: Fix for Emscripten/Android/iOS on Docking branch. 2019-02-05 15:45:26 +01:00
omar
be107ba8f8 Merge branch 'master' into docking
# Conflicts:
#	imgui_internal.h
#	imgui_widgets.cpp
2019-02-05 13:52:32 +01:00
omar
f902435a53 Docking: Fixed less of node size/pos caused by 1f2bdd37 (#2109) 2019-02-03 18:58:07 +01:00
omar
80d51c692a Docking: Fixed dragging docked window with _NoMove flag (#2325) 2019-02-03 18:44:30 +01:00
omar
7227454dca Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui.h
2019-02-03 17:31:16 +01:00
omar
f087359621 Revert part of change from 5536eded. Fixed drag and drop in docking branch. (#2331, reopening #2325) 2019-02-03 13:54:04 +01:00
omar
e215809c4d Removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already). 2019-02-01 17:06:40 +01:00
omar
03b0266b59 Examples: Made imgui_impl_win32 drag gdi32.lib for GetDeviceCaps(). (#2327) 2019-02-01 15:23:25 +01:00
omar
d1c45c0d76 Merge branch 'master' into docking (enable range_select merge)
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-02-01 12:25:49 +01:00
omar
e30babef09 Fixed Clang/Win32 warning. 2019-02-01 11:22:53 +01:00
omar
a608156da3 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2019-02-01 11:19:26 +01:00
omar
65a2350a5f Docking: Extracted code into a DocknodeUpdateTabListMenu() functions + minor other changes. 2019-02-01 11:12:37 +01:00
omar
cbf24a9151 Comments. Fix duplicate entries in About box. Synchronize a few small changes from Master branch. 2019-02-01 11:04:04 +01:00
omar
f906d53f7d Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2019-01-31 19:19:35 +01:00
omar
1f2bdd37b3 Docking: Builder: Added DockBuilderSetNodePos, DockBuilderSetNodeSize, allow DockBuilderAddNode creating floating node (dockspace requires ImGuiDockNodeFlags_Dockspace) (#2109) 2019-01-31 17:01:15 +01:00
omar
dc8ff68871 Docking: VisibleWindow of a node spread its _NoMove attribute to the node (fixed dragging or undocking of dock node host from collapse button). (#2325, #2109) 2019-01-31 15:22:40 +01:00
omar
5536edede9 Docking: Fixed faulty undocking of windows with the _NoMove flag. (#2325, #2109)
Whereas BeginAsDockableDragDropTarget could be reworked to filter, we simply set g.HoveredWindowUnderMovingWindow to be NULL when MovingWindow is not set, which was the initial intent.
Also fixed some comments and removed unused braces in TabItemEx().
2019-01-31 14:59:45 +01:00
omar
578e15f006 Docking: Removed unnecessary ImGuiTabItemFlags_DockedWindow internal flag. 2019-01-31 14:55:00 +01:00
omar
e1143377c2 Viewport: Added ImGuiViewportFlags_NoFocusOnClick + support in imgui_impl_win32. Made windows with no decoration always set the _NoFocus flags. (#1542, #2117)
Fix e.g. clicking on protruding combo box stealing highlight from parent window with decoration.
2019-01-30 21:39:05 +01:00
omar
8563ef3ce4 Viewport: Popups by default merge into parent/host viewport as they have no decoration (same as menu/child). (#1542) 2019-01-30 21:13:07 +01:00
omar
37fb531d1c Docking: Comments and tidying up (should be no-op) 2019-01-29 18:54:56 +01:00
omar
86d3bba157 Added ImGuiDockNodeFlags_AutoHideTabBar. (#2109) 2019-01-29 18:28:31 +01:00
omar
2ccc6d2ed1 Docking: Exposing extra flag in Configuration panel. Moved some forgotten Changelog entries at the right place. 2019-01-29 18:28:31 +01:00
omar
13a5f5ba8b Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2019-01-27 16:46:35 +01:00
omar
737a3644fc Removed trailing spaces (docking branch) 2019-01-27 14:57:07 +01:00
omar
07ff47bf1b Docking: Fixed various border / padding related inconsistency with dock node vs floating windows. (#2109) 2019-01-23 19:54:45 +01:00
omar
0737433c71 When resizing from an edge, the border is more visible and better follow the rounded corners. Border rendering moved to RenderOuterBorders so it can be called in a different order for docking. (#1495, #822) 2019-01-23 19:24:35 +01:00
omar
0bda7f196d Docking: Fixed overlapping issue with greyed out close button. 2019-01-23 19:24:35 +01:00
omar
9f96fcff3c Docking: Added ImGuiDockNodeFlags_Dockspace instead of node internal IsDockspace toward allowing the DockBuilder API to create non-dockspace nodes. 2019-01-23 19:24:34 +01:00
omar
bfacbac7c4 Docking: Fix a focusing issue where dock node wouldn't be moved to the front as expected. 2019-01-23 11:05:00 +01:00
omar
86fce79a6c Comments + clear out VisibleWinodw field (should have no effect) 2019-01-23 10:50:58 +01:00
omar
c81a5a6070 Docking: Comments and renaming locals to facilitate debugging. 2019-01-22 12:38:10 +01:00
omar
0947fa3de0 Merge branch 'viewport' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-01-21 16:54:37 +01:00
omar
cb9a6b8a8b Merge branch 'master' into viewport
# Conflicts:
#	examples/README.txt
#	imgui.cpp
2019-01-21 16:52:22 +01:00
omar
2d21a64fed Comments 2019-01-21 14:25:13 +01:00
omar
f94af2f5c5 Merge branch 'viewport' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui_draw.cpp
2019-01-20 22:13:35 +01:00
omar
8079344cee Merge branch 'master' into viewport
# Conflicts:
#	examples/example_sdl_vulkan/main.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_sdl.cpp
#	examples/imgui_impl_vulkan.h
#	imgui.cpp
2019-01-20 22:12:06 +01:00
omar
82e31d34f0 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_win32.cpp
2019-01-18 12:31:33 +01:00
omar
acdb4823dd Examples: Win32: Fix for older Windows SDK. 2019-01-17 14:35:26 +01:00
omar
b5144e477f Merge branch 'viewport' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2019-01-17 14:06:42 +01:00
omar
e9c625a1dc Merge branch 'master' into viewport
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_win32.cpp
#	imgui_demo.cpp
2019-01-17 14:05:40 +01:00
omar
d1851ed6b7 Various tweaks and fixes as suggested by PVS Studio (thanks PVS Studio!) [docking branch] 2019-01-16 16:19:38 +01:00
omar
32c4e01267 Various tweaks and fixes as suggested by PVS Studio (thanks PVS Studio!) 2019-01-16 16:13:23 +01:00
omar
2f9bae140b Docking: Demo: Fixed docking document window into parent window. (#2286) 2019-01-16 14:43:27 +01:00
omar
8a45c56c2c Merge branch 'viewport' into docking 2019-01-15 21:22:29 +01:00
omar
9391a97fbf Merge branch 'master' into viewport
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_win32.cpp
#	examples/imgui_impl_win32.h
2019-01-15 21:22:21 +01:00
omar
79d497edae Viewport: Made platform_io.Monitors mandatory for proper multi-viewport use. 2019-01-15 21:20:00 +01:00
omar
515ad62335 Merge branch 'viewport' into docking
# Conflicts:
#	docs/TODO.txt
2019-01-15 15:14:16 +01:00
omar
73353fad64 Merge branch 'master' into viewport 2019-01-15 15:13:29 +01:00
omar
ff4bd758ca Merge branch 'viewport' into docking 2019-01-14 21:30:07 +01:00
omar
e24674fc0e Merge branch 'master' into viewport 2019-01-14 21:30:01 +01:00
omar
529fccd9c2 Merge branch 'viewport' into docking 2019-01-13 14:19:40 +01:00
omar
4ee4f65c70 Merge branch 'master' into viewport 2019-01-13 14:19:31 +01:00
omar
7cc86d4bc9 Docking: Fixed docking a split node into the empty central node of a dockspace leading to the central node tag being incorrectly carried along. (#2109) 2019-01-10 18:20:52 +01:00
omar
8011197c50 Merge branch 'viewport' into docking
# Conflicts:
#	imgui.cpp
2019-01-10 16:02:32 +01:00
omar
c96aaef132 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui.h
2019-01-10 16:01:36 +01:00
omar
6b32570644 Merge branch 'viewport' into docking
# Conflicts:
#	imgui_internal.h
#	imgui_widgets.cpp
2019-01-07 21:29:15 +01:00
omar
5af930f97a Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2019-01-07 21:28:29 +01:00
omar
515ecbddc2 Docking: Fix for handling of orphan/inactive dock node with ConfigDockingTabBarOnSingleWindows (would crash). 2019-01-03 23:02:40 +01:00
omar
7f7e8eeecd Docking: Fixed a bug undocking a window from its tab when it is the only docked window of a root dockspace with ConfigDockingTabBarOnSingleWindows enabled. 2019-01-03 22:11:14 +01:00
omar
4e98d4329b Comments 2019-01-03 21:59:13 +01:00
omar
5278da98d2 Merge branch 'viewport' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui_demo.cpp
2019-01-03 21:40:08 +01:00
omar
e1ed27aeaa (Breaking change) Reorganized Viewports advanced flags, moved into new io.ConfigViewportsXXX flags. Pay attention that ImGuiConfigFlags_ViewportsDecoration became ConfigViewportsNoDecoeration, so the value is inverted! (#1542) 2019-01-03 21:33:33 +01:00
omar
c8349d3305 Viewport: Added ConfigViewportsNoParent to parent viewport default to NULL and not main viewport. Fix eg.. popups appearing erroneously focusing parent window. 2019-01-03 21:28:54 +01:00
omar
606175b98f Viewport: Fix for minimization of individual viewports (the current back-end forcing a parent/child relationship between secondary viewports and the main viewport have hidden this issue). Follows d8ab2c1ac. 2019-01-03 21:27:47 +01:00
omar
05bc323be0 Viewport: Fixed minimization of main viewport leading to it being omitted from platform_io.Viewport list where the users assume it is at index 0. Fix d8ab2c1ac. It wasn't a problem when other viewports were child of the main viewport because they would all be minimized together. (#1542) 2019-01-03 21:27:39 +01:00
omar
599a52629a Viewport: Added minimum viable information in the Changelog. 2019-01-03 17:46:23 +01:00
omar
c3efccaa9c Docking: Merge fix duplicate line + added assert to ease debugging. 2019-01-02 23:49:31 +01:00
omar
b26f16a27f Merge branch 'viewport' into docking
# Conflicts:
#	imgui.cpp
2019-01-02 23:16:10 +01:00
omar
a0c2e55e8c Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2019-01-02 23:11:52 +01:00
omar
5aebfedfad Docking: Forward WindowClass from node to host window. 2019-01-02 21:41:00 +01:00
omar
ce1626a51e Merge branch 'viewport' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2019-01-02 21:36:21 +01:00
omar
0cabe4dedf Viewport: Added ImGuiWindowClass / SetNextWindowClass() (concept imported from Docking ImGuiDockFamily), which currently allows to overwrite viewport flags on a per-window basis. Exposed FindViewportByID(). Win32: Support for ParentViewportId. (#1542) 2019-01-02 21:33:23 +01:00
omar
0d6e3ab2b0 Docking: Renamed SetNextWindowId() -> SetNextWindowID() for consistency. (function vs member are still horribly inconsistent atm) 2019-01-02 21:28:16 +01:00
omar
cfcad42b89 Viewport: Win32: Workaround to the fact that ::WindowFromPoint() seems to return Windows using ImGuiViewportFlags_NoInputs / HTTRANSPARENT when dragging nearby the platform title bar. This is to allow using platform decoration. I don't understand this well atm. (#1542) 2019-01-02 19:03:45 +01:00
omar
4a6f95acc8 Viewport: Added Platform_UpdateWindow hook for general purpose: Rework Win32 code to reflect viewport flags changes into Win32 while the window is active. 2019-01-02 19:03:36 +01:00
omar
5305c32242 Viewport: Reorder flags. Set owned viewport common decoration flags in Begin(). Moved code in UpdateViewportsEndFrame() before we introduce family/class based overrides. 2019-01-02 19:03:11 +01:00
omar
951c9dd68b Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_sdl.cpp
2019-01-02 19:00:31 +01:00
omar
4ea9fdbbea Docking: Agressively assert when CentralNode is a not a leaf node in order to find our bug. 2019-01-02 16:22:45 +01:00
omar
e194219f2e Renamed ImGuiDockFamily to ImGuiWindowClass. Renamed CompatibleWithClassZero to DockingAllowUnclassed. (#2109) 2019-01-02 16:22:44 +01:00
omar
a71d3c8cb3 Viewport: Misc comments following user feedbacks.. 2018-12-21 18:40:16 +01:00
omar
238321c159 Fix merge in Docking branch, remove ConfigDockingWithShift flag from DX11 example + misnamed function. 2018-12-21 16:56:26 +01:00
omar
e181b0c3fc Merge branch 'viewport' into docking 2018-12-21 16:53:13 +01:00
omar
9d0bc3f9ab Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_sdl.cpp
2018-12-21 16:43:12 +01:00
omar
afe9c5c5f7 Examples: SDL: Fixed compilation for SDL 2..0.3 and less (running on our test servers) and clarified a bit of the messy situation. Followup to 8dd83c5. (#1542, #2117) 2018-12-21 16:26:17 +01:00
omar
81a2546cea Merge branch 'viewport' into docking
# Conflicts:
#	examples/example_allegro5/main.cpp
#	examples/example_win32_directx9/main.cpp
2018-12-20 23:06:29 +01:00
omar
ee5560a958 Merge branch 'master' into viewport + added style tweak block when viewports are enabled
# Conflicts:
#	examples/example_glfw_opengl3/main.cpp
#	examples/example_sdl_opengl3/main.cpp
#	examples/example_win32_directx11/main.cpp
2018-12-20 23:04:40 +01:00
omar
62cfdceac1 Examples: Viewport: Moved the "make current GL context" to reduce the amount of call and hopefully be more explicit about viewport enabled vs disabled requirements. (#1542) 2018-12-20 22:40:22 +01:00
omar
d9fda22763 Viewport: Fixed not clearing request flags in main viewport, which led some back-end (SDL) to break on resize as PlatformRequestResize would stay true forever and inhibit new sizes passed to AddUpdateViewport(). (#1542) 2018-12-20 22:33:51 +01:00
omar
8dd83c5fe8 Examples: SDL: SDL_GetMouseState() seems problematic, movements feels laggy in the non-viewport code path. (#1542, #2117) 2018-12-20 22:28:31 +01:00
omar
5794c0491a Docking: Fix an edge case failing to dock into an explicit dockspace which only have inactive nodes (because all the windows are inactive). (#2246, #2109) 2018-12-20 19:20:26 +01:00
omar
e043b89814 Merge branch 'viewport' into docking
# Conflicts:
#	imgui.h
2018-12-20 17:03:21 +01:00
omar
8fc19d2194 Removed IMGUI_HAS_TABS from Docking branch, it's not defined anywhere anymore. 2018-12-20 16:56:48 +01:00
omar
02501f07c3 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui.h
2018-12-20 16:54:32 +01:00
omar
a0e5bb9532 Viewport: Corrected/clarified comments. Moved RenderPlatformWindowsDefault() next to UpdatePlatformWindow(). Removed unnecessary flag check. 2018-12-20 16:49:31 +01:00
omar
088ef6623a Merge branch 'viewport' into docking 2018-12-18 15:03:01 +01:00
omar
9c916cdaf9 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-12-18 15:02:35 +01:00
omar
ac9512e095 Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
2018-12-14 18:46:24 +01:00
omar
5d20da1b36 Viewport, DPI: Now using DpiScale from the ImGuiPlatformMonitor array instead of calling Platform_GetWindowDpiScale() before the platform window creation. Might even tentatively see if things work out without Platform_GetWindowDpiScale. (#1676) 2018-12-14 12:12:26 +01:00
omar
9b09c7597f Merge branch 'viewport' into docking
# Conflicts:
#	imgui_demo.cpp
2018-12-13 19:21:51 +01:00
omar
2a1e903f43 Merge branch 'master' into viewport
# Conflicts:
#	imgui.h
2018-12-13 19:20:34 +01:00
omar
e50894c95e Metrics: Fixed crash when viewports are disabled (g.MouseLastHoveredViewport is never set). 2018-12-13 19:16:44 +01:00
omar
991b16cc6a Merge branch 'master' into docking
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
#	imgui_widgets.cpp
2018-12-11 19:46:46 +01:00
omar
2886e0b6f5 Demo: Fix collateral damage of 54a60aa 2018-12-11 13:25:29 +01:00
omar
067b691fd8 Merge branch 'viewport' into docking
# Conflicts:
#	docs/TODO.txt
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
#	imgui_draw.cpp
#	imgui_internal.h
#	imgui_widgets.cpp
2018-12-11 13:23:00 +01:00
omar
c40feabe4d Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2018-12-11 12:41:40 +01:00
omar
2d4018aa89 Docking: Fix io.ConfigWindowsMoveFromTitleBarOnly for docking branch. 2018-12-11 11:03:28 +01:00
omar
e6439e1a16 Merge branch 'viewport' into docking + moved io.ConfigFlags ImGuiConfigFlags_DockingNoSplit to io.ConfigDockingNoSplit
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
2018-12-10 16:21:49 +01:00
omar
26b9e2d0a5 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
2018-12-10 16:14:31 +01:00
omar
3a5e758ee3 Tabs: Fixed crash when using TabItem in a regular (non-docking) tab bar. (#2231) 2018-12-08 12:35:15 +01:00
omar
f768727284 Merge branch 'viewport' into docking
# Conflicts:
#	imgui.cpp
2018-12-06 16:36:17 +01:00
omar
a03846bd9e Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2018-12-06 16:33:39 +01:00
omar
f3a0b17bb8 Viewport: Win32, GLFW, SDL: Clarified back-ends by using global mouse position direction. GLFW: disabled io.MouseHoveredViewport setting under Mac/Linux. (#1542, #2117) + various comments. 2018-12-06 16:30:10 +01:00
omar
ac52d9d44c Viewport: Fix handling of PlatformRequestResize/PlatformRequestPos. when OS decoration are enabled via ImGuiConfigFlags_ViewportsDecoration . 2018-12-06 15:36:36 +01:00
omar
e2082a675c Viewport: Fix handling of PlatformRequestResize/PlatformRequestPos. when OS decoration are enabled via ImGuiConfigFlags_ViewportsDecoration . 2018-12-05 23:39:04 +01:00
omar
b94f0241f1 Docking: Adjusting the docking popup menu position so it tends to stay within the same viewport. 2018-12-05 21:19:42 +01:00
omar
b96b1f2412 Docking: Documenting an issue. Renamed member of ImGuiDockFamily. 2018-12-04 16:38:27 +01:00
omar
6644f1ff64 Docking: Added io.ConfigDockingTabBarOnSingleWindows option (mostly made possible by the previous fixes).
Note that dock node have regressions compared to current floating window: no collapse, no auto-resize, resize grip under the scrollbar, border issues, general overhead. Will tackle those.
2018-12-04 13:37:46 +01:00
omar
8cac70d8af Docking: Focus fix (missing line in 8bac6d4) 2018-12-04 13:34:16 +01:00
omar
5105c6c0d0 Merge branch 'viewport' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
2018-12-04 00:06:26 +01:00
omar
3a678d48b1 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
2018-12-04 00:05:45 +01:00
omar
8bac6d428d Docking: Another attempt at tidying the inconsistent focus / tab bar reordering issues, and toward generalizing single window dock nodes. (#2109) 2018-12-04 00:01:20 +01:00
omar
2da200fc16 Docking: Fix generalizing the transition from loose windows to dock node so we can switch to single window dock node while transferring viewports (vs creating two viewports and dropping one). + Extracted DockContextGenNodeID out of DockContextAddNode(). 2018-12-04 00:01:19 +01:00
omar
f6b6ad1959 Viewport: Minor tweaks, better struct layout. 2018-12-03 20:30:00 +01:00
omar
3e84f7cd1d Viewport: Fixed a viewport bug which led some popups to merge in underlying host viewport when they should be z-over their parent viewport. 2018-12-03 18:16:47 +01:00
omar
ac10889bde Merge branch 'viewport' into docking
# Conflicts:
#	docs/CHANGELOG.txt
2018-12-03 11:44:51 +01:00
omar
89a530b442 Somehow VS keeps modifying this GUID so I am going to playing along with it. 2018-12-03 11:44:08 +01:00
omar
65e579e558 Merge branch 'master' into viewport
# Conflicts:
#	docs/CHANGELOG.txt
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_opengl2.cpp
#	examples/imgui_impl_opengl3.cpp
#	examples/imgui_impl_sdl.cpp
#	examples/imgui_impl_vulkan.cpp
#	examples/imgui_impl_win32.cpp
#	imgui.h
#	imgui_demo.cpp
2018-12-03 11:41:53 +01:00
omar
34e18ef771 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. 2018-11-30 23:48:39 +01:00
omar
8289e5f6b4 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. 2018-11-30 23:48:25 +01:00
omar
025e00cccc About: Added build/system info relating to Docking branch. 2018-11-30 18:29:35 +01:00
omar
f78b5a0cdb Merge branch 'viewport' into docking 2018-11-30 18:27:14 +01:00
omar
ec49a486c7 About: Added build/system info relating to Viewport branch. 2018-11-30 18:27:04 +01:00
omar
afeefadb4e Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_opengl2.cpp
#	examples/imgui_impl_opengl3.cpp
#	examples/imgui_impl_sdl.cpp
#	examples/imgui_impl_win32.cpp
#	imgui.h
2018-11-30 18:24:43 +01:00
omar
a423f032ee About, IO: Added io.BackendPlatformName, io.BackendRendererName for informational/QA purpose. 2018-11-30 18:18:15 +01:00
omar
4ef06f5aa2 Added ShowAboutWindow(), About Window now showing various config/build information. 2018-11-30 18:02:01 +01:00
omar
753223bd7b Merge branch 'viewport' into docking
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2018-11-30 14:38:54 +01:00
omar
f663277591 Merge misc/shallow changes from Docking branch to minimize drift: moved some blocks, added comments. 2018-11-30 14:35:13 +01:00
omar
1c7be88a1a Viewport: Fixed a bug where tooltips on their first frame didn't find a monitor leading to the "recovery" code to revert it to the main viewport for a frame. (#1542) 2018-11-30 14:35:13 +01:00
omar
3c114b280a Merge branch 'viewport' into docking
# Conflicts:
#	imgui_internal.h
2018-11-29 21:30:26 +01:00
omar
2fbbcaa339 Viewport: Avoid calling platform functions when window is not created (apart from Platform_GetWindowDpiScale, documented as such). Main viewport situation is still ambiguous. (#1542) 2018-11-29 21:28:47 +01:00
omar
36cbe1e521 Viewport: Misc renaming. 2018-11-29 21:21:04 +01:00
omar
19d17ed274 Docking: Added io.ConfigDockingTransparentPayload option (to use with ImGuiConfigFlags_ViewportsNoMerge) 2018-11-29 16:18:01 +01:00
omar
01f940dc9a Viewport: imgui_impl_sdl2: Added support for PlatformIO Platform_SetWindowAlpha. 2018-11-28 22:50:48 +01:00
omar
19c4fa8dd5 Examples: DX12: Fixed compilation of imgui_impl_dx12.cpp in viewport branch. Multi-viewport is still not functional. 2018-11-28 15:43:00 +01:00
omar
3bcc25f588 Merge branch 'viewport' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2018-11-27 19:56:23 +01:00
omar
4cadb57c46 Viewport: Comments. 2018-11-27 19:53:33 +01:00
omar
99c32ed4a5 Merge branch 'master' into viewport 2018-11-27 19:46:40 +01:00
omar
c08b4b46f4 Viewport: Better support for toggling ImGuiConfigFlags_ViewportsEnable. (#2196) 2018-11-27 19:46:36 +01:00
omar
e138a5fcb5 Docking: Fixed debug Rebuild operation. 2018-11-27 17:40:25 +01:00
omar
fc16e54612 Docking: Maintain CentralNode. When SetNextWindowDockID() on a now split node id, we dig to find the central node or the last focused node. (#2109) 2018-11-27 13:35:05 +01:00
omar
4575354bc0 Docking: Comments + maiintain LastFrameFocused per node + using bitfiield for docking bools. 2018-11-27 13:29:09 +01:00
omar
3f51c831de Docking: Added internal DockBuilderGetCentralNode(). Fixed being unable to undock whole node from dock button in DockSpace with a central node. (#2109) 2018-11-26 22:18:55 +01:00
omar
962dcb466d Docking: Added ImGuiDockNodeFlags_NoResize. (#2109) 2018-11-26 21:52:40 +01:00
omar
b8d9c5c130 Merge branch 'viewport' into docking
# Conflicts:
#	imgui.cpp
2018-11-26 21:36:48 +01:00
omar
1a0d2578a1 Viewport: Merging fixes + relying on multiple viewport overlaps. Follow-up to previous attempts are reworking the split/merge mechanisms. (#1542) 2018-11-26 21:35:44 +01:00
omar
12a1e7d04e Viewport: Comment to suggest making WindowBg opaque when viewports are enabled. 2018-11-26 19:20:37 +01:00
omar
4a8efd7e68 Docking: Hidden tab-bar triangle reflects focus but using Button colors. (#2109) 2018-11-26 17:57:01 +01:00
omar
66cfbbff5e Docking: Fixed double-overlay when dragging window over one of the (four cardinal) outer drop boxes. (#2109) 2018-11-26 17:39:38 +01:00
omar
d23c69d319 Docking: Added context menu option to hide the tab bar of single-window dock nodes, similar to Unreal. (#2109) 2018-11-26 17:25:06 +01:00
omar
1e7b50aeae Viewport: Fixes moving child menu viewport (fix 379733a). 2018-11-26 16:56:58 +01:00
omar
c93e92671a Viewport: Fixes moving child menu viewport (fix 379733a). 2018-11-26 16:55:40 +01:00
omar
ddc3f8f069 Merge branch 'viewport' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui.cpp
#	imgui_internal.h
2018-11-26 15:32:04 +01:00
omar
5261e5a6ba Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_sdl.cpp
2018-11-26 14:53:51 +01:00
omar
379733aba1 Viewport: Fix viewport regression with protruding child window creating their own viewport. (fixes cae4d02, 760c1d95) (#1542) 2018-11-26 14:53:04 +01:00
omar
131de7ab62 Docking: Added ImGuiConfigFlags_DockingNoSplit flag. (#2109) 2018-11-23 18:42:16 +01:00
omar
d8ab2c1ac9 Viewport: Added support for minimized window which caused problem when ImGuiBackendFlags_HasMouseHoveredViewport was not supported. (#1542) + todo 2018-11-23 16:55:33 +01:00
omar
862781b195 Viewport: Avoid unnecessary reapplying platform pos/size every frame. (#2205) + Fix GLFW ImGui_ImplGlfw_CreateWindow() from not applying position immediately. Clear LastNameHash properly (bug already fixed in Docking branch) 2018-11-23 16:35:17 +01:00
omar
cae4d020dc Viewport: Merging/Extracting to/from main host viewport is now performed based on current state rather than triggers. Windows which don't fit in host window are now consistently in their own viewport. Toward simplifying the UpdateSelectWindowViewport() function. Probably broke something.. (#1542) 2018-11-22 21:18:14 +01:00
omar
1f78e08427 Viewport: UpdateTryMergeWindowIntoHostViewport() calls BringWindowToDisplayFront() - possible now that BringWindowToFocusFront() is a different function. 2018-11-22 21:16:43 +01:00
omar
760c1d95b9 Viewport: Merging/Extracting to/from main host viewport is now performed based on current state rather than triggers. Windows which don't fit in host window are now consistently in their own viewport. Toward simplifying the UpdateSelectWindowViewport() function. Probably broke something.. (#1542) 2018-11-22 21:13:07 +01:00
omar
510f0e505c Viewport: UpdateTryMergeWindowIntoHostViewport() calls BringWindowToDisplayFront() - possible now that BringWindowToFocusFront() is a different function. 2018-11-22 20:13:55 +01:00
omar
d9c54826bb Viewport: Stop relying on viewport->CreatedPlatformWindow to create Platform_DestroyWindow and Renderer_DestroyWindow. Explicitly require Platform_GetWindowFocus() to require supporting empty data. 2018-11-22 17:27:35 +01:00
omar
2515413080 Merge branch 'viewport' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui_widgets.cpp
2018-11-22 15:29:18 +01:00
omar
d87b80c6c1 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-11-22 15:28:27 +01:00
omar
4a43f347bb Merge branch 'viewport' into docking
# Conflicts:
#	examples/example_allegro5/main.cpp
#	examples/example_marmalade/main.cpp
2018-11-15 14:00:01 +01:00
omar
dcbf976a8e Merge branch 'master' into viewport + comments
# Conflicts:
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
2018-11-15 13:58:46 +01:00
omar
f2d577c33f Viewport: BeginMainMenuBar(): explicitly set viewport to avoid creating new one when ImGuiConfigFlags_ViewportsNoMerge is set + misc shallow changes. 2018-11-13 22:14:40 +01:00
omar
ae34241f8b Viewport: BeginMainMenuBar(): explicitly set viewport to avoid creating new one when ImGuiConfigFlags_ViewportsNoMerge is set + misc shallow changes. 2018-11-13 22:11:39 +01:00
omar
1546153ca2 Docking: Fixed a regression where clicking a Tab wouldn't immediately set NavWindow. Which led to breaking the NavSaveLastChildNavWindow/NavRestoreLastChildNavWindow logic. (#2109) 2018-11-13 19:31:10 +01:00
omar
a3d6554e8e Merge branch 'master' into viewport + specific changes for GLFW callbacks
# Conflicts:
#	examples/example_glfw_opengl3/main.cpp
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx9/main.cpp
#	examples/imgui_impl_glfw.cpp
2018-11-08 16:56:51 +01:00
omar
565af90958 Merge branch 'viewport' into docking 2018-11-06 09:52:38 +01:00
omar
797f2044cd Viewport: Fixed SDL+OpenGL2 example to work with multi-viewports. (#2175) 2018-11-06 09:51:09 +01:00
omar
5ea08394f5 Examples: SDL: Tweaked Windows instructions and batch files. (#2175) 2018-11-06 09:46:43 +01:00
omar
9ee86f22b7 Examples: Win32: Handle UTf-8 in platform window title setting. (#2164) 2018-11-05 17:37:06 +01:00
omar
52ca91ca57 Merge branch 'master' into viewport 2018-11-05 17:29:31 +01:00
omar
168af9b377 Merge branch 'viewport' into docking
# Conflicts:
#	imgui_demo.cpp
2018-10-25 23:45:19 +02:00
omar
1a6eea012d Docking: Tweaked tooltip on tabs so they don't show immediately when holding and releasing a tab (using HoveredIdNotActiveTimer) + Minor refactor + Removed legacy .ini parsing. 2018-10-25 23:41:32 +02:00
omar
50f6e12d31 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-10-25 23:41:13 +02:00
omar
c547b2e8ee Added DockSpaceOverViewport() call, not sure about this because of the menu bar limitation. (#2109) 2018-10-25 15:34:53 +02:00
omar
56ba60ee68 Docking: Fixed not saving .ini file correct if DockingEnable flag is cleared. (#2109) 2018-10-24 12:25:58 +02:00
omar
f270c81c49 Viewport, Docking: Fixed incorrectly setting the ImGuiViewportFlags_NoInputs flag, affecting split docking node. (#2109) 2018-10-23 18:26:45 +02:00
omar
745fda081e Viewport, Docking: Fixed incorrectly setting the ImGuiViewportFlags_NoInputs flag, affecting split docking node. (#2109) 2018-10-23 18:26:35 +02:00
omar
5f8c9ae0ef Merge branch 'viewport' into docking
# Conflicts:
#	imgui.cpp
#	imgui.h
2018-10-18 10:57:54 +02:00
omar
056af2b1af Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui.h
2018-10-18 10:56:26 +02:00
Brandon
5f79a28a07 Examples: SDL: Fixed usage of SDL_GetDisplayDPI (#2137, #1676) 2018-10-18 10:48:18 +02:00
omar
69db792bf0 Viewport: Exposed GetOverlayDrawList(ImGuiViewport* viewport) in public API. (#1542, #1660, #1878, etc.) 2018-10-15 17:38:36 +02:00
omar
8b956216b7 Demo: Testing return value of BeginTabBar() for consistency. 2018-10-15 17:19:52 +02:00
omar
e6cc547a94 Merge branch 'viewport' into docking
# Conflicts:
#	imgui.cpp
#	imgui_widgets.cpp
2018-10-12 15:51:31 +02:00
omar
e73217d6f7 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_sdl.cpp
#	imgui.cpp
2018-10-12 15:50:48 +02:00
omar
2eaf5b03df Fixes crash introduced in previous commit 9cf94d5. 2018-10-12 13:30:00 +02:00
omar
c398153b40 Merge branch 'master' into docking
# Conflicts:
#	examples/imgui_impl_sdl.cpp
#	imgui.cpp
#	imgui_internal.h
2018-10-12 13:01:20 +02:00
omar
33994bbfa1 Docking: Fixed Modal window from being dockable. 2018-10-12 12:56:56 +02:00
omar
7525637804 Merge branch 'viewport' into docking. 15ec78e Fixes the update of title buffer when docked in a leaf dock node with a single window. Added comment about overwriting DockIsActive in DockNodeUpdate().
# Conflicts:
#	imgui.cpp
2018-10-11 21:36:00 +02:00
omar
15ec78e9d8 Internal: Moved stored window name update code to the first_begin_of_the_frame block. This will be useful in the Docking branch. 2018-10-11 21:32:20 +02:00
omar
3a7828de6b Viewport: Added ImGuiConfigFlags_ViewportsDecoration to re-enable platform decoration (#1542) 2018-10-09 18:35:45 +02:00
omar
7b3433c68b Viewport: Added ImGuiConfigFlags_ViewportsDecoration to re-enable platform decoration (#1542) 2018-10-09 18:33:39 +02:00
omar
84507cc744 Docking: Kept ImGuiDockNodeFlags_PassthruDockspace and removed ImGuiDockNodeFlags_PassthruInEmptyNodes, ImGuiDockNodeFlags_RenderWindowBg. Doesn't include ImGuiDockNodeFlags_NoDockingInCentralNode. (#2109) 2018-10-08 12:37:10 +02:00
omar
cb76c086e0 Docking: Removed context parameter from internal DockBuilderXXX api at it is expected we transition it to be public facing. (#2109) 2018-10-05 16:14:51 +02:00
omar
407822e6a5 BeginTabItem: Fixed missing parameter name in .h file messing up with cimgui generator. (#2115) 2018-10-04 19:39:02 +02:00
omar
4e30698706 Docking: Added ImGuiDockNodeFlags_PassthruDockspace mode (subdivided in three flags: ImGuiDockNodeFlags_NoDockingInCentralNode, ImGuiDockNodeFlags_PassthruInEmptyNodes, ImGuiDockNodeFlags_RenderWindowBg). Added internal facility for register a rectangular hit-test hole in window. Updated DockSpace demo accordingly. (#2109) 2018-10-03 22:32:23 +02:00
omar
2dd8338e7d Docking: Added ImGuiDockNodeFlags_NoOuterBorder, tweaked DockSpace demo to remove window border. Made docking splitter use the same standard setting as resizing from edges. (#2109) 2018-10-03 18:30:36 +02:00
omar
059560d28b ButtonBehavior, ImGuiButtonFlags_FlattenChildren flag can be used from a child window. Would typically affect calling SplitterBehavior() from a child window. 2018-10-03 18:11:35 +02:00
omar
d348d86df4 Docking: Renamed "DocRoot/DocumentRoot" to "CentralNode", more self explanatory. Moved Splitter update higher up in DockNodeUpdate() + minor misc tweak. (#2109) 2018-10-03 17:50:07 +02:00
omar
1d3862b6b3 Docking: Added ImGuiDockNodeFlags_NoDockingInsideDocRootNode flag. Honoring ImGuiDockNodeFlags_NoSplit in child node is already split (so we can use DockBuilder and then lock the layout). Added those options to the demo. (#2109) 2018-10-03 14:57:28 +02:00
omar
bd82539ad5 Docking: Fixed DockSpace() child window displaying a scrollbar behind the node backgrounds. Rename ImGuiCol_DockingBg to ImGuiCol_DockingEmptyBg. Added ImGuiDockNode::IsLeaftNode(). (#2109) 2018-10-03 14:42:47 +02:00
omar
83f55c9de5 Merge branch 'viewport' into docking 2018-10-02 18:55:48 +02:00
omar
33b88a0339 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-10-02 18:55:36 +02:00
omar
44bfa24cc3 Docking: Fixed crash using DockBuilderSplitNode(). (#2109) 2018-10-02 11:09:53 +02:00
omar
2cff3f6a65 Docking: Renamed io.ConfigDockingWithKeyMode to io.ConfigDockingWithShift. 2018-10-01 18:35:21 +02:00
omar
b48ed9ebc0 Docking: Better tracking of current dock id for inactive and uncreated windows (in settings etc.). + Fixed assert when docking a single-visible leaf node of a hierarchy into another 2018-10-01 11:56:26 +02:00
omar
4e717b524c Docking: Fixes for C++03 compilers. 2018-10-01 10:40:43 +02:00
omar
ae657a349a Docking: Fixed extracting a dock node from a document root: document root should be preserved. 2018-09-30 23:39:38 +02:00
omar
ed3c015f4e Docking: Reorganizing some of the tab-bar selection and window focus related code. 2018-09-30 23:39:38 +02:00
omar
9cfc40c2cc Docking: Demo: Displaying a message if master docking flag is disabled. + DockSpace() early out + comments. 2018-09-30 23:39:37 +02:00
omar
6ebc63d3ef Docking: Various sanity fixes + fixed tab-bar items sorting issue when docking single window with a dock node into single window without dock node. 2018-09-30 22:07:57 +02:00
omar
1ae0a1e658 Docking: Fix DockContextRebuild() temporarily invalidating dockid reference leading to undesirable merging of nodes. 2018-09-30 19:34:03 +02:00
omar
46dff42239 Docking: Fixed dock node with single window accidental stealing of non-owned host viewport (leading to general havoc). 2018-09-30 19:30:51 +02:00
omar
35d1fb7b34 Style: Added style.TabRounding setting. 2018-09-30 18:41:07 +02:00
omar
876a3299fc Docking: Added DockBuilderCopyDockspace() wip. Added DockBuilderCopyWindowSettings(), renamed DockBuilderForkNode() to DockBuilderCopyNode(). 2018-09-28 17:58:55 +02:00
omar
93896d550e Added FindOrCreateWindowSettings() internal helper. 2018-09-26 23:01:51 +02:00
omar
18ffb7dd86 Docking: Reworked DockContextPruneUnusedSettingsNodes() to prune entire unused trees. 2018-09-26 23:01:51 +02:00
omar
c0a89f8f4e ImPool: Added Reserve() helper function. 2018-09-26 21:51:30 +02:00
omar
c6193d0605 Merge branch 'viewport' into docking 2018-09-26 21:35:09 +02:00
omar
6cc380fc41 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_win32.cpp
#	examples/imgui_impl_win32.h
#	imgui.cpp
2018-09-26 21:34:52 +02:00
omar
4053d9d638 Docking: Fixed tab order restoring (follow up to 67be485e, broken in 455dc6e2) 2018-09-26 17:11:37 +02:00
omar
45731cca19 Docking: Added DockBuilderForkNode() primitive for usage for user code to fork/copy entire layouts. This will probably need to be added to as I find ways to migrate patterns from user code to the library. Added IMGUI_DEBUG_DOCKING_INI helper to facilitate debugging. (+1 squashed commits) 2018-09-26 17:11:37 +02:00
omar
dc92431328 Docking: Minor renaming. DockContextAddNode() uses 0 as marker for automatic ID selection + TODO update and moved docking entries to docs/TODO.txt 2018-09-26 12:58:14 +02:00
omar
d3e8e5731a Docking: Renamed SetNextWindowDock() to SetNextWindowDockId(). Added GetWindowDockId(). 2018-09-25 17:45:06 +02:00
omar
53a5d32df1 Docking: Reworked SetNextWindowUserType() as SetNextWindowDockFamily(), allowing multiple scene to be tagged with their scene id and not receive tabs from other scene + persistent storage for family id to allow for docking tree fork/remap. 2018-09-25 16:15:25 +02:00
omar
85e1e2b0c8 Docking: Added DockBuilderGetNode() wrapper for consistency. 2018-09-25 14:14:07 +02:00
omar
9960ccddb2 Docking: Added DockBuilderRemoveNode() + various tweaks. Fixed dragging/undocking dock node from CollapseButton. 2018-09-24 23:19:18 +02:00
omar
4021776d0f Docking: Fix for undocking node where the dockspace node is attached to an immovable parent window. + Tweak .ini output. 2018-09-24 22:14:12 +02:00
omar
fa0ce4b7d5 Docking: Some DockBuilder functions are applied on settings data if windows are not present. Added DockBuilderCreateNode which needs a size else if we can't split properly. DockNodeTreeSplit() doesn't clamp SizeRef. (+1 squashed commits) 2018-09-24 16:38:44 +02:00
omar
2a5ce1849a Docking, Viewport: Reworked viewport inheritance/transition so that extracting a dock node from a split node owning its viewport will have both viewports be in the expected OS z-order. (The lower window re-use the exiting viewport, the detached node uses a new viewport: 2018-09-24 10:53:51 +02:00
omar
ae4b838840 Docking, Viewport: Rework ownership transfer/stealing to fix issues where non-child windows could be stick marked as not owning their viewport. 2018-09-24 10:48:56 +02:00
omar
79c075ca09 Docking+Viewport: Fixed PlatformRequestClose (e.g. ALT-F4) being redrected to the first window of the docking node instead of the selected one. 2018-09-24 10:48:55 +02:00
omar
1127804109 Viewport: Misc tweaks. 2018-09-24 10:39:15 +02:00
omar
67be485e24 Docking: Fixed losing tab bar selection when extracting a whole docked node + reusing existing dock node when possible. 2018-09-21 16:23:00 +02:00
omar
fda57f48d5 Merge branch 'viewport' into docking
# Conflicts:
#	examples/example_glfw_opengl2/main.cpp
#	examples/example_glfw_opengl3/main.cpp
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_sdl_opengl2/main.cpp
#	examples/example_sdl_opengl3/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	examples/example_win32_directx10/main.cpp
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx12/main.cpp
#	examples/example_win32_directx9/main.cpp
2018-09-21 11:52:32 +02:00
omar
840652830d Docking: Fixed undocking on whole dock node from leaving undesirable empty node in the docking tree. Fixed calls to MarkIniSettingsDirty(). 2018-09-21 11:50:49 +02:00
omar
5eabf44021 Nav: Use Platform_SetWindowFocus when CTRL+Tabbing to another viewport. 2018-09-21 11:49:43 +02:00
omar
599d5f185c TabBar: Recover if SelectedTabId doesn't exist anymore. 2018-09-21 11:02:03 +02:00
omar
7abc368927 Viewport: GLFW: Build fix for pre GLFW 3.2 (#1542) 2018-09-20 18:46:36 +02:00
omar
b57baa5ba0 Viewport: Enabled viewports by default in more example apps. 2018-09-20 10:31:23 +02:00
omar
3e47978a80 Docking: Renamed ImGuiDockSpaceFlags to ImGuiDockNodeFlags. Clarified in comments/demos that DockSpace creates a Node. Renamed IsExplicitRoot to IsDockSpace. Assert against explicitly calling DockSpace twice in a frame. 2018-09-20 09:52:51 +02:00
omar
e647f89c33 Docking: Added undocking of whole dock node by dragging from the Collapse button. Super useful and works great! 2018-09-19 22:38:40 +02:00
omar
82978fc88f Docking: Fix of title bar flicker during rebuild. Fixed dragging of DockNode always triggering BeginAsDockableDragDropSource() when io.ConfigDockingWithKeyMod is false. 2018-09-19 19:41:31 +02:00
omar
95d49c3b98 Docking: Internals renaming LastExplicitSize to SizeRef (invalidate .ini data) + todo 2018-09-19 18:25:26 +02:00
omar
455dc6e229 Docking: Creating tab bar and adding window into tab bar immediately (not sure why I didn't do that before). Probably broke something subtle, will find out. *Edit* Initially broke restoring selected tab. 2018-09-19 16:00:13 +02:00
omar
291bfe6841 Docking: work to allow programmatic control of dock nodes, various refactor + assert fix. Probably broke something (but I haven't found what yet!) 2018-09-19 16:00:13 +02:00
omar
35032d41fa Docking: Internals: Transitioning some code toward consistently using ImGuiContext* ctx parameter instead of ImGuiDockContext 2018-09-17 17:06:52 +02:00
omar
28094b7cea Docking: Fixed central docking display with ImGuiDockSpaceFlags_NoSplit, affecting in particular with io.ConfigDockingWithKeyMod = false. + comments, asserts 2018-09-17 15:39:35 +02:00
omar
b55b9aee9b Fixed bad merge (a82be53) where we lost the version number in Docking branch + moved Docking related API together for now. 2018-09-14 18:09:46 +02:00
omar
0f1c21a6c9 Docking: Changed DockSpace() signature to take an ID, as ID will frequently be used by other API it makes more sense to let the user compute it. 2018-09-14 18:09:04 +02:00
omar
175bab4f5f Docking: Removed SplitRatio from ImGuiDockNode and ImGuiDockNodeSettings, which we don't need anymore. 2018-09-14 17:51:30 +02:00
omar
ba7b68798d Docking: Misc rework/rename toward being able to rebuild a branch selectively, so we can honor settings changes on a per Dockspace basis. + Comments 2018-09-14 16:01:47 +02:00
omar
e32256b4b4 Merge branch 'viewport' into docking
# Conflicts:
#	docs/CHANGELOG.txt
#	imgui_demo.cpp
#	imgui_internal.h
2018-09-14 11:38:10 +02:00
omar
132d8c5a99 Viewport: Increased threshold for setting ImGuiViewportFlags_NoFocusOnAppearing. (#1542), 2 doesn't seem enough with some docking setup. 2018-09-14 11:37:17 +02:00
omar
b85f345369 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx9.cpp
#	examples/imgui_impl_opengl2.cpp
#	examples/imgui_impl_opengl3.cpp
#	examples/imgui_impl_vulkan.cpp
2018-09-14 11:32:55 +02:00
omar
85a3fb3bef Viewport: Fix an issue introduced on ~August 16, which would assert when viewport are disabled. Also made the DestroyPlatformWindow process more sturdy. (#1542) 2018-09-13 17:11:06 +02:00
omar
6d91055462 Docking: Fixed floating->docking transition on a platform window mistakenly destroying the platform window because the upcoming tab isn't visible and triggers viewport GC. Fixed missing title bar data on recreate window. 2018-09-13 16:56:57 +02:00
omar
136fc56af0 Docking: Better handling of window losing its dock node or having its dock node not active. 2018-09-13 14:38:37 +02:00
omar
c355ed1267 Docking: Flicker fix when clicking on a Tab leading of a new window, in particular would be noticeable when using nested tab bars. 2018-09-13 12:44:29 +02:00
omar
1cefc48f13 Docking: Internal renaming and comments. + Fixed DockNodeMoveChildNodes() to transfer the LastExplicitSize value (was inconsequential afaik). 2018-09-11 18:53:08 +02:00
omar
211a9c8fd2 Docking: Added ImGuiDockSpaceFlags_KeepAliveOnly, important for multiple level of tabs. (also renamed ImGuiDockFlags to ImGuiDockSpaceFlags.) 2018-09-11 17:58:09 +02:00
omar
f29b3b4033 Nav: Added a way for code to cancel Alt for menu toggle (ImGuiNavInput_KeyMenu_). Cancelling out on platform window. close request. (#1542, #787) 2018-09-11 15:35:53 +02:00
omar
df65d4a14f Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2018-09-11 11:18:46 +02:00
omar
c4e26f4b92 Nav: Added a way for code to cancel Alt for menu toggle (ImGuiNavInput_KeyMenu_). Cancelling out on platform window. close request. (#1542, #787) 2018-09-10 22:19:54 +02:00
omar
416918429d Docking: Added Type enum in ImGuiDockRequest. Renamed fields. DockSpace() skips node update if already submitted (when transitioning from implicit -> explicit DockSpace). 2018-09-10 22:09:43 +02:00
omar
d5692bff00 Nav, Focus: Fixed ImGuiWindowFlags_NoBringToFrontOnFocus windows not being restoring focus properly after the main menu bar or last focused window is deactivated. 2018-09-10 20:30:14 +02:00
omar
dcef0c0237 Docking: Updating LastFrameActive earlier in Begin() because BeginDocked() will need to use it. Extracted some code into a DockNodeIsDropAllowedOne() function. Comments. 2018-09-10 20:23:03 +02:00
omar
a68c98bb67 Docking: Added SetNextWindowUserType() + user type filtering in dockspace and window merging. Added DockSpace() flag ImGuiDockFlags_NoSplit. Renaming. Reworked the DockNodeUpdateFindOnlyNodeWithWindows code so DockNodeUpdate can access the first window. 2018-09-10 14:32:00 +02:00
omar
b872aa5c8e Docking: io.ConfigResizeWindowsFromEdges default to true in Docking branch. Moved code in BeginTabItem(). 2018-09-10 11:24:27 +02:00
omar
a82be53407 Merge branch 'docking2' into viewport_docking
# Conflicts:
#	examples/example_glfw_opengl2/main.cpp
#	examples/example_glfw_opengl3/main.cpp
#	examples/example_glfw_vulkan/main.cpp
#	examples/example_sdl_opengl3/main.cpp
#	examples/example_sdl_vulkan/main.cpp
#	examples/example_win32_directx10/main.cpp
#	examples/example_win32_directx11/main.cpp
#	examples/example_win32_directx12/main.cpp
#	imgui.cpp
#	imgui.h
#	imgui_demo.cpp
#	imgui_internal.h
2018-09-06 22:28:21 +02:00
omar
49533bc86e Examples: Enabled Docking + Nav by default in the branch. (#351) 2018-09-06 21:53:35 +02:00
omar
e381f22ac1 Docking: Added Docking system. (Part 3) (#351) 2018-09-06 21:45:46 +02:00
omar
9ac1e93aa1 Docking: Added Docking system. (Part 2) (#351) 2018-09-06 21:45:46 +02:00
omar
bd5b38e232 Docking: Added Docking system. Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable. (Part 1) (#351) 2018-09-06 21:45:46 +02:00
omar
5adcb9ce6d Docking: Added empty skeleton/sections to facilitate diff/patch of incoming code (otherwise git gives us a messier patch). 2018-09-06 21:45:45 +02:00
omar
2ec135c9f7 Docking: Added ImVec2[] non const operator. Added ImStrSkipBlank. Reseting some values earlier in Begin. Added IMGUI_DEBUG_LOG() helper. Added docking source code section. 2018-09-06 21:45:45 +02:00
omar
58d46e1fe6 Tabs: Added BeginTabBar(), EndTabBar(), BeginTabItem(), EndTabItem() + demo. (#261, #351) 2018-09-06 21:45:44 +02:00
omar
c039a77d21 Internals: Added ImPool helper structure. Moved ImVec1f. 2018-09-06 21:45:10 +02:00
omar
741bdf151a Added ImGuiWindowFlags_UnsavedDocument flags. 2018-09-06 21:45:10 +02:00
omar
5070c769b8 Internals: Windows hidden with HiddenFramesRegular (but NOT HiddenFramesForResize) preserve their SizeContents, so restoring a auto-resize window after it's been hidden by tabs won't reset its size for a frame. Arguable. Let's see how it goes. (Followup to b48e295bddbf965d7382ec5578ed05d2fe601114) 2018-09-06 21:45:09 +02:00
omar
52e0de84a9 Internals: Split RenderTextClipped into two functions. 2018-09-06 21:45:09 +02:00
omar
b974fffea0 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-09-06 15:59:35 +02:00
omar
a2616c79fe Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-09-06 11:42:11 +02:00
omar
31b5b18611 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-09-05 20:59:27 +02:00
omar
8601c39571 Viewport: Making the code a little more sturdy (flag changes) + added descriptions. (#1542) 2018-09-05 17:50:55 +02:00
omar
af27ec296b Merge branch 'master' into viewport + added viewport ConfigFlags/BackendFlags
# Conflicts:
#	imgui.cpp
#	imgui.h
2018-09-05 17:38:47 +02:00
omar
a848807847 Minor inconsequential merges from Master/Docking branches 2018-09-05 11:51:45 +02:00
omar
bdb30d7145 Merge branch 'master' into viewport 2018-09-05 11:08:57 +02:00
omar
897e5c6231 Viewport: Moved code following refactor. (#2036, #1542) 2018-09-05 11:08:44 +02:00
omar
1007873d94 Misc: merge minor/inconsequential stuff from Docking branch to reduce drift. 2018-09-03 19:51:22 +02:00
omar
fd201a90f1 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-08-31 18:39:02 +02:00
omar
a52ce7ac8b Merge branch 'master' into viewport 2018-08-31 11:14:05 +02:00
omar
fd90afef43 Refactor: Internals: Moved Viewport functions in imgui.cpp in their own section. (part 3) (#2036, #1542) 2018-08-31 11:11:18 +02:00
omar
5207afa0dd Refactor: Internals: Moved Viewport functions in imgui.cpp in their own section. (part 2) (#2036, #1542) 2018-08-31 11:06:21 +02:00
omar
0699310b9c Merge branch 'viewport_164' into viewport 2018-08-31 10:28:37 +02:00
omar
0c24fe276c Merge branch 'master_164' into viewport_164
# Conflicts:
#	imgui.cpp
#	imgui_draw.cpp
#	imgui_widgets.cpp
2018-08-31 10:28:21 +02:00
omar
c83391262e Refactor: Internals: Moved Tooltip functions in imgui.cpp in their own section + comments. (#2036) 2018-08-30 21:21:14 +02:00
omar
00262d51ad Refactor: Internals: Moved Popup functions in imgui.cpp in their own section. (part 3) (#2036) 2018-08-30 21:19:30 +02:00
omar
d7c04ccbfb Refactor: Internals: Moved Popup functions in imgui.cpp in their own section. (part 2) (#2036) 2018-08-30 21:18:16 +02:00
omar
b1f263b34b Refactor: Internals: Moved Popup functions in imgui.cpp in their own section. (part 1) (#2036) 2018-08-30 21:16:30 +02:00
omar
a58e4dfd0f Refactor: Moved Scrollbar function from imgui.cpp to imgui_widgets.cpp, added file index (#2036) 2018-08-30 21:16:23 +02:00
omar
18d6490dbd Merge branch 'master_164' into viewport_164
# Conflicts:
#	imgui.cpp
2018-08-30 20:36:37 +02:00
omar
346f83e014 Refactor: Internals: Moved Navigation functions in imgui.cpp in their own section. DONE! (part 9) (#2036, #787) 2018-08-30 19:41:02 +02:00
omar
fefcc77f13 Refactor: Internals: Moved Navigation functions in imgui.cpp in their own section. (part 8) (#2036, #787) 2018-08-30 19:40:40 +02:00
omar
b6cdfef442 Refactor: Internals: Moved Navigation functions in imgui.cpp in their own section. (part 7) (#2036, #787) 2018-08-30 19:38:44 +02:00
omar
172e426ba9 Refactor: Internals: Restored new lines in NavUpdate() ... (part 6) (#2036, #787) 2018-08-30 19:36:59 +02:00
omar
f74d9ec7f7 Refactor: Internals: Moved Navigation functions in imgui.cpp in their own section (moved NavUpdate which would not diff properly unless empty lines were removed, hence the previous patch). (part 5) (#2036, #787) 2018-08-30 19:36:40 +02:00
omar
9093166eea Refactor: Internals: Removing new lines from NavUpdate solely because I couldn't find another way to get a neat diff/patch when moving it. (part 4) (#2036, #787) 2018-08-30 19:35:19 +02:00
omar
f5ed5478e1 Refactor: Internals: Moved Navigation functions in imgui.cpp in their own section (extracted some code out of NavUpdate()). (part 3) (#2036, #787) 2018-08-30 19:35:12 +02:00
omar
9a4234ea8e Refactor: Internals: Moved Navigation functions in imgui.cpp in their own section. (part 2) (#2036, #787) 2018-08-30 19:35:06 +02:00
omar
af002dc861 Refactor: Internals: Moved Navigation functions in imgui.cpp in their own section. (part 1) (#2036, #787) 2018-08-30 19:34:48 +02:00
omar
adeb993122 Refactor: Internals: Moved Logging functions in imgui.cpp in their own section. (#2036) 2018-08-30 19:33:02 +02:00
omar
81bc4265e5 Refactor: Internals: Moved Settings functions in imgui.cpp in their own section. (#2036) 2018-08-30 19:32:52 +02:00
omar
a44c5f7afe Refactor: Internals: Moved various functions in imgui.cpp (#2036) 2018-08-30 19:30:17 +02:00
omar
66b51940bd Refactor: Moved README, ChangeLog, TODO files to docs/ folder + update Changelog. (#2036) 2018-08-30 19:30:10 +02:00
omar
d4e49a2697 Merge commit '2714f8fa23d8ca44e98272baf885d12b5185d084' into viewport_164
# Conflicts:
#	imgui.cpp
#	imgui_widgets.cpp
2018-08-30 19:29:46 +02:00
omar
521405488b Refactor: Moved Slider/Drag/Input functions + support DataType stuff from imgui.cpp to imgui_widgets.cpp (#2036) 2018-08-30 19:21:50 +02:00
omar
24dfa0c957 Refactor: Moved InputText functions from imgui.cpp to imgui_widgets.cpp (#2036) 2018-08-30 19:12:33 +02:00
omar
158a65c98f Refactor: Moved ColorEdit/ColorPicker/ColorButton/etc. functions from imgui.cpp to imgui_widgets.cpp (#2036) 2018-08-30 19:04:49 +02:00
omar
6caf074bd5 Refactor: Moved Tree/Selectable functions from imgui.cpp to imgui_widgets.cpp (#2036) 2018-08-30 19:04:42 +02:00
omar
905e14f384 Refactor: Moved Plot/Value functions from imgui.cpp to imgui_widgets.cpp (#2036) 2018-08-30 19:04:36 +02:00
omar
4be79a8955 Refactor: Moved Menu functions from imgui.cpp to imgui_widgets.cpp (#2036) 2018-08-30 19:04:04 +02:00
omar
2d952504ed Refactor: Moved Combo/ListBox functions from imgui.cpp to imgui_widgets.cpp (#2036) 2018-08-30 19:01:05 +02:00
omar
43219d36a6 Refactor: Moved Button/Image/Checkbox/RadioButton/Bullet/ProgressBar functions from imgui.cpp to imgui_widgets.cpp (#2036) 2018-08-30 19:00:59 +02:00
omar
99b27488e7 Refactor: Moved Text functions from imgui.cpp to imgui_widgets.cpp (#2036) 2018-08-30 19:00:52 +02:00
omar
18972c5513 Refactor: Added imgui_widgets.cpp headers to easily merge in the functions in all our branches. (#2036) 2018-08-30 19:00:42 +02:00
omar
e312363007 Refactor: Added empty imgui_widgets.cpp + updated project files / makefiles etc. accordingly (#2036) 2018-08-30 19:00:33 +02:00
omar
6c34bffbb5 Version 1.64 WIP 2018-08-30 19:00:22 +02:00
omar
36b2f64051 Merge branch 'master' into viewport
# Conflicts:
#	examples/example_glfw_opengl3/main.cpp
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui_internal.h
2018-08-29 17:40:52 +02:00
omar
705ff49400 Examples: Vulkan: Viewport: Tweak to improve framerate on multiple-viewport situations, tho it is still halving the unthrottled framerate on nvidia for some reason.. Followup to 4dea032 (#1542) 2018-08-25 21:21:14 +02:00
omar
f81caac459 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui.h
2018-08-25 21:19:42 +02:00
omar
0ada716184 Examples: Viewport: Disabling swap intervals / vsync on secondary context to match what the DX11 bindings is doing. (#1542) 2018-08-25 20:15:18 +02:00
omar
e9c849884a Viewport: Fixed warnings due to bad merge. 2018-08-24 15:42:31 +02:00
omar
a4191857c1 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_vulkan.h
#	imgui.cpp
2018-08-22 21:35:44 +02:00
omar
9d7480774f Merge branch 'master' into viewport 2018-08-17 11:37:03 -07:00
omar
5d630c930d Viewport: DestroyPlatformWindows() checks for the bool CreatedPlatformWindow flag correctly. Note that we set CreatedPlatformWindow=true for the main viewport to allow the back-end to store data in the public Viewport structure (for consistency). (#1542) 2018-08-15 16:15:44 -07:00
omar
9852649e97 Viewport: Initial viewport DpiScale only queried on viewport creation. Because AddUpdateViewport() is called repeatedly on MovingWindow or with ImGuiConfigFlags_ViewportsNoMerge, the DpiScale update would break ImGuiConfigFlags_DpiEnableScaleViewports. (#1542) 2018-08-14 19:17:33 -07:00
omar
1722a31155 Viewport: ImGuiWindowFlags_NoFocusOnAppearing affects viewport accordingly. (#1542) 2018-08-14 14:58:19 -07:00
omar
e5f2295398 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_opengl2.cpp
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
2018-08-13 17:50:48 -07:00
omar
8ef0ca9765 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_sdl.cpp
#	imgui.cpp
2018-08-01 12:27:56 +02:00
omar
c031ea088a Viewport: Fixed an assert on loss of valid mouse position while dragging a tooltip (would happen often when using debugger breakpoint). Not totally sure about best solution, may not be important. 2018-07-31 13:46:37 +02:00
omar
9824bf1ba1 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
2018-07-31 12:12:56 +02:00
omar
0095b7a0ea Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2018-07-26 23:55:23 +02:00
omar
6b4f6cd2c5 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-07-26 19:25:55 +02:00
omar
1b646a4440 Nav: Tweaked CTRL+TAB to hide visual noise on fast switch + fading out screen dimming and highlight to make the experience less harsh 2018-07-26 19:01:51 +02:00
omar
f22024cb19 Internals: Exposed NavScoreItemGetQuadrant() as ImGetDirQuadrantFromDelta() in imgui_internal.h 2018-07-24 16:54:29 +02:00
omar
049c515840 Added non-const ImVec2 [] operator for consistency (and because some docking code needs it.) 2018-07-24 16:54:19 +02:00
omar
352695bc57 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_sdl.cpp
#	imgui.cpp
2018-07-24 16:50:49 +02:00
omar
74077491ce Viewport: Fixed a situation when the implicit Debug window can hold on a zombie viewport which platform window is not properly destroyed. (#1542) 2018-07-22 16:24:06 +02:00
omar
23b67e6ff5 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-07-17 19:52:14 +02:00
omar
7b4fbf4301 Viewport: Removed the need for the back-end to fill io.MousePosViewport, it seems unnecessary at this point. (#1542) 2018-07-17 16:37:10 +02:00
omar
b8b74970d7 Internals: Viewport: Renamed g.MouseRefViewport to g.MouseViewport. (#1542) 2018-07-17 16:04:47 +02:00
omar
defbf1c4b3 Viewport: when moving window we use the moving window viewport unless drag and dropping. This is to fix e.g. IsItemHovered() + Tooltip pattern that may be active while moving a window. (#1542) 2018-07-17 15:56:02 +02:00
omar
16c6734bcb Viewport: Revert part of 7abf72e, the viewport ownership stealing is problematic. (#1542). Will rework in the context of docking. (+1 squashed commits)
+ Fixed unused prototype warning (left-over from a merge)
2018-07-17 15:14:19 +02:00
omar
ee98a069f0 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	imgui_demo.cpp
2018-07-16 22:25:36 +02:00
omar
b30b82835a Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
#	imgui_internal.h
2018-07-12 11:48:49 +02:00
omar
d107146687 Viewport: Fixed CTRL+TAB windowing list displaying too many dimming layers (fix dd61c48 for viewport branch) 2018-07-12 11:19:17 +02:00
omar
88df66ec83 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_opengl3.cpp
#	imgui.cpp
#	imgui.h
#	imgui_draw.cpp
#	imgui_internal.h
2018-07-12 10:03:18 +02:00
omar
ce18371d1b Internals: Fixed CalcSizeContents() returning negative value on first run (inconsequential afaik, but fixing for sanity) 2018-07-09 21:49:49 +02:00
omar
9dea27b273 Viewport: Made it possible for the moving window to detach and recreate its own Viewport (used by Docking) 2018-07-09 21:18:41 +02:00
omar
140ece0aeb Internals: HoveredWindowUnderMovingWindow special handling for drag and drop of window without altering the _NoInputs window flag, which worked but messed up the IsWindowHovered() user-facing flags. 2018-07-09 21:18:10 +02:00
omar
7abf72ec78 Viewport: Reapply/recover ownership of viewport which is convenient for docking but also can recover from faulty .ini files. (#1542) 2018-07-09 21:13:51 +02:00
omar
574185426c Internals: Misc/shallow merge from Docking branch. 2018-07-09 21:06:46 +02:00
omar
dd61c4802a Nav: Added a CTRL+TAB window list and changed the highlight system accordingly. (#787) 2018-07-09 19:22:49 +02:00
omar
14cef31467 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-07-09 16:24:01 +02:00
omar
6277781e83 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-07-08 13:08:16 +02:00
omar
770cba0bd0 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_glfw.h
#	examples/imgui_impl_sdl.cpp
#	examples/imgui_impl_sdl.h
#	examples/imgui_impl_win32.cpp
#	examples/imgui_impl_win32.h
#	imgui.cpp
#	imgui_internal.h
2018-07-02 20:13:16 +02:00
omar
c38fe6b0e1 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-06-26 12:41:36 +02:00
omar
d3ee3e7ab5 Fixed merge. 2018-06-23 09:39:05 +02:00
omar
ce500f8727 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_win32.cpp
2018-06-22 12:01:42 +02:00
omar
9a5f742e63 Fixed merge. 2018-06-15 19:48:51 +02:00
omar
7e6700d261 Viewport: Fix lagging overlay clipping rectangle on viewport owning window (affecting sync of multi-layered docking overlays). This was extremely tricky to find and fix (*). (#1541)
(*) Merely assigning viewport->Pos = pos in UpdateMovingWindow() broke a series of thing because the code that assign viewports and viewport flags relied on moving window leaving its own viewport the first time to set the NoInputs flag.
2018-06-15 19:40:17 +02:00
omar
c71522adc5 Viewport: Comments. Removed misleading test for !window->ViewportOwned in UpdateSelectWindowViewport(). (#1541) 2018-06-15 19:40:00 +02:00
omar
70b0bd13aa Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_opengl2.cpp
#	examples/imgui_impl_opengl2.h
#	examples/imgui_impl_opengl3.cpp
#	examples/imgui_impl_opengl3.h
#	imgui.cpp
#	imgui.h
2018-06-14 15:30:15 +02:00
omar
087ab2acbf Examples: Fixed example vcproj names in Viewport branch. 2018-06-13 15:59:21 +02:00
omar
24aeca3d0c Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx10.h
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_glfw.h
#	examples/imgui_impl_opengl2.cpp
#	examples/imgui_impl_opengl2.h
#	examples/imgui_impl_opengl3.cpp
#	examples/imgui_impl_sdl.cpp
#	examples/imgui_impl_sdl.h
#	examples/imgui_impl_vulkan.h
#	examples/imgui_impl_win32.cpp
2018-06-12 16:24:24 +02:00
omar
9660657e95 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_sdl.cpp
2018-06-10 15:59:35 +02:00
omar
13a3a2d0f3 Merge branch 'examples_refactor2' into viewport (#1870)
# Conflicts:
#	examples/README.txt
#	examples/directx11_example/main.cpp
#	examples/directx12_example/main.cpp
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_glfw.cpp
#	examples/imgui_impl_opengl2.cpp
#	examples/imgui_impl_opengl2.h
#	examples/imgui_impl_opengl3.cpp
#	examples/imgui_impl_sdl2.cpp
#	examples/imgui_impl_sdl2.h
#	examples/imgui_impl_vulkan.cpp
#	examples/imgui_impl_vulkan.h
#	examples/imgui_impl_win32.cpp
#	examples/imgui_impl_win32.h
#	examples/opengl2_example/main.cpp
#	examples/opengl3_example/main.cpp
#	examples/sdl_opengl2_example/main.cpp
#	examples/sdl_opengl3_example/main.cpp
#	examples/sdl_vulkan_example/main.cpp
#	examples/vulkan_example/main.cpp
#	imgui.cpp
#	imgui.h
2018-06-10 15:04:46 +02:00
omar
ff4f40de41 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-06-08 20:22:07 +02:00
omar
24fc7c30dd Examples: Documentation 2018-06-08 00:00:12 +02:00
omar
06aa9d8d9a Examples: Fixed Makefile, batch files. 2018-06-07 22:30:10 +02:00
omar
8c374512fd Examples, Platform: Removed the call to ImGui::NewFrame() from the platform _NewFrame() function e.g. ImGui_ImplWin32_NewFrame(), ImGui_ImplSDL2_NewFrame(), ImGui_ImplGlfw_NewFrame(), etc. Moved to main.cpp for consistency. (#1542) 2018-06-07 22:10:31 +02:00
omar
77d51ebf24 Examples: Added .. folder in include path to remove the awkward #include "../imgui_impl_xxx.h" statements. 2018-06-07 19:20:04 +02:00
omar
93b032ea92 Merge branch 'master' into viewport
# Conflicts:
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
#	imgui.cpp
2018-06-05 15:51:52 +02:00
omar
03c8a78f04 Merge branch 'master' into viewport
# Conflicts:
#	examples/opengl2_example/imgui_impl_glfw_gl2.cpp
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.h
#	examples/vulkan_example/imgui_impl_glfw_vulkan.cpp
2018-05-25 12:44:56 +02:00
omar
002e513b82 Added float GetWindowDpiScale(). (#1542, #1676) 2018-05-23 18:25:37 +02:00
omar
ed84b2aaeb Viewport, Platform: Fixed a crash if the back-end set the PlatformRequestMove/PlatformRequestSize flags while viewports were disabled (it happened in the SDL back-end, and generally we want to tolerate it to make back-end implementation simpler). (#1542) 2018-05-23 18:01:50 +02:00
omar
1176460e44 Viewport: Fixed using ImGuiConfigFlags_ViewportsNoMerge always showing the Debug window by testing the Active flag as well. (#1542) 2018-05-19 20:45:49 +02:00
omar
01429e7d16 Merge branch 'master' into viewport
# Conflicts:
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
#	imgui.cpp
#	imgui.h
2018-05-17 15:03:56 +02:00
omar
4c35e00f49 Viewport: Made GetWindowViewport() not flag the window as written to. 2018-05-16 22:48:54 +02:00
omar
7f960616e0 Viewport: When resizing/moving a window using the host OS/WM we attempt to merge back into host viewport. (#1542) 2018-05-16 14:34:46 +02:00
omar
1cafdb5b46 Viewport: Added GetWindowViewport() to query the current viewport for the current window. Comments. (#1542) 2018-05-15 11:04:07 +02:00
omar
b0fb340b57 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
2018-05-14 13:15:21 +02:00
omar
85f3ba844c Merge branch 'master' into viewport
# Conflicts:
#	examples/sdl_opengl2_example/imgui_impl_sdl_gl2.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
#	imgui.cpp
#	imgui.h
2018-05-11 22:22:41 +02:00
omar
090eb437ed Viewport, Platform: Cleaned up xxx_UpdateMouseCursor() functions to make them more consistent. (#1542) 2018-05-11 16:41:43 +02:00
omar
d574604a5d Viewport, Platform: Win32: Fixed handling of io.WantSetMousePos + added a bunch of comments. GLFW, SDL2: Added handling of io.WantSetMousePos. (#1542) 2018-05-11 16:41:03 +02:00
omar
6eacddb50f Viewport: Changed Monitor field to use Pos+Size (more consistent), changed FullMin,FullMax to MainPos,MainSize. Made main viewport accessible in PlatformIO on first frame. Fixed casing of ImGuiViewportFlags_TopMost flag. (#1542) 2018-05-10 13:10:04 +02:00
omar
4ff23d3306 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx9.cpp
#	imgui.cpp
#	imgui.h
2018-05-07 22:23:58 +02:00
omar
c7687fc1d6 Viewports: Comments on ImGuiConfigFlags_DpiEnableScaleViewports and ImGuiConfigFlags_DpiEnableScaleFonts. (#1542) 2018-05-07 10:44:08 +02:00
omar
c47d34cf70 Viewport: Exposing SetNextWindowViewport(). Used in demo and old/obsolete SetNextWindowPosCenter() (which is an interesting case). Fixed back-end likely crash calling GetFocus() after viewport destruction. Fixed metrics crash. 2018-04-27 15:13:22 +02:00
omar
cd51f37fc0 Viewport, Platform: Refresh monitor list (win32, glfw) + avoid calling GetWindowFocus before platform window creation to not require of backend to null-check things inconsistently. (#1542) 2018-04-26 16:18:47 +02:00
omar
da70c837da Viewport: Removed unnecessary fields (now that the coordinate system is consistent accross viewports): MouseRefPrevViewport, MouseClickedPosViewportId. (#1542) 2018-04-26 15:30:19 +02:00
omar
f1ae07e532 Viewport, Platform: Using Platform_GetWindowFocus to provide a much stronger heuristic of platform z-order, in replacement for when the back-end cannot provide io.MouseHoveredViewport. The pressure for it to work well increased with the use of viewports by popups/menus. (#1542) 2018-04-26 11:52:38 +02:00
omar
d9cd494eaf Viewport: Moved ScaleWindow* code in a proper location. Various comments. 2018-04-25 23:21:26 +02:00
omar
5979233a3c Misc: tweaks + minor changes merged from master to reduce branch drift. Removed code that ended up unused. 2018-04-25 18:23:39 +02:00
omar
0b1d6a0d52 Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2018-04-25 18:13:23 +02:00
omar
7b433605f9 Viewport: Avoid creating viewport on drag (fix cc882b0723) 2018-04-25 15:38:32 +02:00
omar
3b9b1956cd Merge branch 'master' into viewport
# Conflicts:
#	examples/allegro5_example/imgui_impl_a5.cpp
#	examples/allegro5_example/imgui_impl_a5.h
#	examples/allegro5_example/imgui_impl_allegro5.cpp
#	examples/allegro5_example/imgui_impl_allegro5.h
#	examples/allegro5_example/main.cpp
#	examples/imgui_impl_allegro5.cpp
#	examples/imgui_impl_allegro5.h
#	imgui.cpp
#	imgui_internal.h
2018-04-25 15:32:04 +02:00
omar
7a41e0b1ea Platform: Added platform_io.Platform_SetWindowFocus, Platform_GetWindowFocus function wrappers (unused yet). Exact specs tbd because our simplified concept of focus doesn't necessary match the more complex OS native concepts. (#1542) 2018-04-25 15:15:14 +02:00
omar
cc882b0723 Viewport: Tidying up AddUpdateViewport() calls. Moved flags argument. Removed extraneous mid-frame call to FindPlatformMonitorFromRect(). (#1542) 2018-04-25 15:14:51 +02:00
omar
6d6580f6be Viewport: Fixed glitches with newly appearing menus creating viewport while the underlying imgui window should be hidden. (#1542) 2018-04-25 11:23:58 +02:00
omar
7684f53328 Viewport: Fixed issues with popups drifting in particular when reference mouse position become invalid (e.g. changing app focus while viewported-menu is open). Storing monitor index in viewport at beginning of the frame. (#1542) 2018-04-25 11:23:58 +02:00
omar
e3e4b7bdf5 Viewport: Fixed mouse hover flicker on mouse button release frame after moving a window. (#1542)
Platform: Clarifying some comments in back-ends.
2018-04-24 17:10:27 +02:00
omar
679f4882a5 Removed presumably obsolete MovingWindow tests which prevent move/merge logic in viewport branch from working in all situations (e.g. docking away when ActiveId is the ID of a tab) 2018-04-24 17:10:26 +02:00
omar
cb78e62df9 Viewport, Platform: Fixed IME positioning for multi-viewport. Moved API from ImGuiIO to ImGuiPlatformIO. Because it is extremely unlikely to people redefined this API manually the moving-forward-breakage is ok. (#1542)
SDL2 ime support under Win32 never worked properly because of SDL interferences.
2018-04-24 12:40:38 +02:00
omar
376f2aec54 Viewport: Clamp windows within monitors + fallback rescue window when it is out of sight (e.g. removed monitor, changed resolution) + Win32: declare primary monitor at the beginning of the list. (#1542) 2018-04-23 23:01:37 +02:00
omar
010757266e Viewports: Todos, Tooltips/menus not automatically forced into their own viewport when the NoMerge flag is set (however the multiplication of viewports makes them more likely to protude and create their own). Win32: try to make primary monitor the first tin the list. (#1542) 2018-04-23 23:00:14 +02:00
omar
d268471285 Viewport: Added ImGuiConfigFlags_ViewportsNoMerge flag (to enforce a platform window for all floating windows) + minor tidying up and addition of non-functional wip code. 2018-04-23 18:56:25 +02:00
omar
423577e14e Viewport, Platforms: SDL: Fixed initial focus click being ignored as a mouse button. GLFW: Fixed mouse cursor support for multi-viewport with GLFW 3.3 (current master) - somehow doesn't appear to work with GLFW 3.2 but I'm not too fussed about it. (#1542) 2018-04-23 16:46:25 +02:00
omar
f1c31ebc67 Viewport: Fixed initial popup positioning not using the monitor area properly. (#1542) 2018-04-23 12:52:01 +02:00
omar
4433ce4312 Viewport, Platform: Added work area in ImGuiPlatformMonitor. Renamed fields. (#1542) 2018-04-23 12:38:20 +02:00
omar
456bbffcc4 Viewport: Switched to using unified platform-absolute mouse coordinates, which simplify lots of problems and simplify/reduce tricky conversions, makes ImVec2 less ambiguous. Fixed various viewport/windowing/popups/synchronization bugs. Settings on host-viewport are stored as relative (made settings decently compatible between viewport enable/disabled settings). Merged ImGuiViewport::Pos and ::PlatformPos. Tweaked thumbnails. Better, smaller code. (#1542) 2018-04-20 21:36:36 +02:00
omar
17a7f352b5 Viewporrt. Examples: DirectX10,11: Make the platform SetWindowSize handler not crash on failure to resize, which could happen (rarely) on invalid data or bug in the code. 2018-04-19 17:23:43 +02:00
omar
637d9c42bf Viewport: WIP for Tooltips, Popups, Menus to create their own viewport. Resizing a window allows it to leave the main viewport. (#1542) 2018-04-19 13:12:02 +02:00
omar
1c385c2ca4 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_dx9.cpp
#	examples/opengl2_example/imgui_impl_glfw_gl2.cpp
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/sdl_opengl2_example/imgui_impl_sdl_gl2.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
#	examples/vulkan_example/imgui_impl_glfw_vulkan.cpp
#	imgui.cpp
#	imgui_internal.h
2018-04-18 19:06:49 +02:00
omar
25f25d546d Viewport: Fixed manual mouse resize to handle mouse viewport change, which will allow resizing a window while it changes viewport. Releasing manual resize may merge a window. Added ConvertViewportPosToViewportPos() helper. Renamed NewFrameUpdateMovingWindowDropViewport() to UpdateTryMergeWindowIntoHostViewport() and removed the now-unnecessary half of the function. + renaming (#1542) 2018-04-17 23:34:19 +02:00
omar
6ac50634e3 Viewport: Tweaked selection of g.MouseRefViewport, in particular aimed at fixing browsing child-menus while holding mouse buttons with menus in multiple viewports. (#1542) 2018-04-17 18:25:05 +02:00
omar
50e453a3e2 Viewport: Comments, tweaks, renaming. Removed unnecessary stuff. Fixed zealous Clang warning. (#1542) 2018-04-17 18:25:05 +02:00
omar
4649bf042e Viewport: Render: Fix draw list build code to allow child windows to be in a different viewports (which will happen with e.g. extruding menus). (#1542) 2018-04-16 17:12:00 +02:00
omar
2bd0ee27f0 Viewport: Shuffled code in Begin to reset size of reappearing popups prior to selecting viewport, to avoid mistakenly using an old size. Moved code out of UpdateSelectWindowViewport() to the section of Begin where positions is being locked down, to avoid code in-between duplicating this. (#1542) 2018-04-16 17:12:00 +02:00
omar
0d16492eb7 Viewport: Moved ImGuiWindowFlags_FullViewport to an internal ViewportOwned flag. Renamed AddViewport to AddUpdateViewport. (#Viewport: Shuffled code in Begin to reset size of reappearing popups prior to selecting viewport, to avoid mistakenly using an old size. Moved code out of UpdateSelectWindowViewport() to the section of Begin where positions is being locked down, to avoid code in-between duplicating this. (#1542)) 2018-04-16 17:11:59 +02:00
omar
2ae19801a9 Viewport: Remove old code that never worked (testing wrong flag type, always false) + shuffled a few things in Begin() to clarify dependencies. Fixed viewport change on Begin/Begin/End/End patterns. (#1542) 2018-04-16 17:11:59 +02:00
omar
950539b768 Viewport, Platform, DPI: Back-end store per-monitor DPI information in ImGuiPlatformMonitor. (#1542, #1676) 2018-04-13 20:26:36 +02:00
omar
f270d6c52c Viewport: Fix to allow changing/animated window name to be reflected in the OS e.g. task bar, so named documents can appear properly. (#1542) 2018-04-13 16:21:34 +02:00
omar
22d6f00110 Viewport: Fixed DPI changing viewport from interfering with moving another window (disabling code) + metrics crash fix on closed viewport window + Windows 10 call to SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) for DPI, with no noticeable improvements. (#1542, #1676) 2018-04-13 11:14:06 +02:00
omar
38e357ef10 Viewport: Virtual mouse position are patched immediately when viewports are moved in the virtual space, avoiding interaction glitchs on a resizing frame. (#1542) 2018-04-12 19:57:35 +02:00
omar
0b7f3edc26 Viewport: Debug/metrics tweaks + renaming comments 2018-04-12 19:57:34 +02:00
omar
285269ef55 Viewport, Platform: Added ImGuiViewportFlags_TopMost that will be used by tooltip window (without it, clicking and holding the window emitting the tooltip would move the tooltip to the back) + GLFW backend fixes for non-win32 platforms. (#1542) 2018-04-11 21:27:19 +02:00
omar
e25da4230b Merge branch 'master' into viewport
# Conflicts:
#	imgui.cpp
#	imgui_internal.h
2018-04-11 21:25:44 +02:00
omar
8be6f40ae1 Viewport: per-viewport overlay draw list created on demand. With this pattern it'll be easier to consider adding more (e.g. background draw list). (#545) 2018-04-11 21:21:52 +02:00
omar
83bd3595a4 Viewport: Merged ImGuiPlatformData into ImGuiPlatformIO. Comments. (#1542) 2018-04-10 22:58:39 +02:00
omar
32ee0a3947 Viewport, Platform: Added a way to register monitor bounds to imgui so they can be used to clamp individual-viewport tooltips/popups so they don't straddle monitors. (#1542) 2018-04-10 22:32:08 +02:00
omar
7ddc22b326 Viewports, DPI: Renamed config flags. (#1542) 2018-04-10 20:02:43 +02:00
omar
0d5042f0f3 Viewport: Popups, Tooltips can individually request no task bar icons to the platform layer. (#1542) 2018-04-10 19:15:44 +02:00
omar
0eaddb4dcd Viewport: shuffled some code in the UpdateSelectWindowViewport() function. 2018-04-10 18:47:23 +02:00
omar
74a11e2087 Viewport: Merge fix conflicting flags. 2018-04-09 22:15:46 +02:00
omar
d4dd448511 Examples, Platform, Viewport: Fixed inconsistent window ownership issues. Added comments. Made Win32/SDL back-ends track ownership. 2018-04-09 22:01:58 +02:00
omar
56ad2a2d74 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/opengl2_example/imgui_impl_glfw_gl2.cpp
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/vulkan_example/main.cpp
#	imgui.h
2018-04-09 19:35:14 +02:00
omar
f421e73b40 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_dx9.cpp
#	examples/opengl2_example/imgui_impl_glfw_gl2.cpp
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/sdl_opengl2_example/imgui_impl_sdl_gl2.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
#	examples/vulkan_example/imgui_impl_glfw_vulkan.cpp
#	imgui.cpp
#	imgui.h
#	imgui_internal.h
2018-04-06 23:36:23 +02:00
omar
72899318e6 Viewport, Platform, Examples: Added support for transparent window via PlatformIO Platform_SetWindowAlpha (#1542) + fixes for GLFW 3.3 2018-04-05 17:07:46 +02:00
omar
84c6ea0cee Viewport: Comments about honoring ImGuiViewportFlags_NoInputs and MouseHoveredViewport. (#1542) 2018-04-05 12:27:17 +02:00
omar
c23b5463c7 Viewport: Moving a window accross viewports tries to preserve the dragging pivot (that is assuming that the window will be evenly scaled by DPI, aka Style is scaled). (#1542) 2018-04-05 11:40:33 +02:00
omar
9d8bc79025 Viewport: Renamed RenderPlatformWindows() to RenderPlatformWindowsDefault(), tweaked examples and emphasis optional Viewport code path. (#1542) 2018-04-05 11:06:00 +02:00
omar
0cad274b87 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_dx9.cpp
#	examples/opengl2_example/imgui_impl_glfw_gl2.cpp
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/sdl_opengl2_example/imgui_impl_sdl_gl2.cpp
#	examples/sdl_opengl2_example/imgui_impl_sdl_gl2.h
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.h
#	imgui.cpp
2018-04-04 19:39:42 +02:00
omar
ac8931b2e9 Viewport: Moved OverlayDrawList to be a per-viewport instead of being global + fix overlay clipping glitch during viewport creation frame + support for software mouse cursor stradding over multiple viewport. The overlay draw list move is rather important as draw lists are not shared among viewports anymore and we can do a swap of their data without copying it. (#1542) 2018-03-22 22:09:42 +01:00
omar
4f112f898e Viewport: Avoid modifying MousePos in UpdateWindowViewport just for the sake of docking test, sheering MousePos during the frame is problematic + minor renaming. (#1542) 2018-03-22 21:14:55 +01:00
omar
e5ba982be0 Nav: Fixed a crash with IMGUI_DEBUG_NAV_SCORING enabled + added info to Metrics. 2018-03-21 22:48:23 +01:00
omar
200754b013 Examples: GLFW: Don't alter cursor mode if GLFW_CURSOR input mode is GLFW_CURSOR_DISABLED. (#1202) [@PhilCK] 2018-03-20 22:42:05 +01:00
omar
42ad3c1dd3 Examples: OpenGL2: Added multi-viewport support in the OpenGL2 back-end. (#1542) + Metrics: Fix undisplayed flag. 2018-03-20 22:19:41 +01:00
omar
172570acae Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_dx9.cpp
#	examples/opengl2_example/imgui_impl_glfw_gl2.cpp
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/sdl_opengl2_example/imgui_impl_sdl_gl2.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
#	examples/vulkan_example/imgui_impl_glfw_vulkan.cpp
#	imgui.h
2018-03-20 22:14:34 +01:00
omar
c29971cf72 Merge branch 'master' into viewport
# Conflicts:
#	examples/sdl_opengl2_example/main.cpp
#	examples/sdl_opengl3_example/main.cpp
#	examples/vulkan_example/main.cpp
2018-03-20 16:05:31 +01:00
omar
ccc9a22db3 Viewport: Changelog + Internals: Renamed viewport mouse fields for consistency (going to add more). (#1542) 2018-03-19 22:59:55 +01:00
omar
c00523dba4 Viewport: Added extra Metrics and debug features. 2018-03-19 18:07:12 +01:00
omar
9d5ec05150 Viewport, Platform: Update the contents of GetPlatformData() in EndFrame() so back-end can access it even if UpdatePlatformWindows hasn't been called. (#1542) 2018-03-19 17:33:21 +01:00
omar
2fecd332fc Viewport, Platform: Added void* to render/swap buffer functions. Comments. (#1542, #1042) 2018-03-19 15:20:47 +01:00
omar
0e09032750 Viewport, Examples: Renamed types used by examples. (#1542) 2018-03-18 22:19:02 +01:00
omar
46b61427e1 Viewport, Platform: Refactored platform interface. Removed need to use imgui_internal.h in backends. Split viewport into public facing ImGuiViewport and internal structure. Exposing enough data to provide custom tweaked renderers. Renamed handlers, fixed lots of inconsistencies. (#1542, #1042) 2018-03-18 18:44:57 +01:00
omar
bcf4ed28a9 Merge branch 'master' into viewport
# Conflicts:
#	imgui.h
2018-03-18 12:51:57 +01:00
omar
6cfc9e6256 Merge branch 'master' into viewport
# Conflicts:
#	imgui.h
2018-03-17 21:20:01 +01:00
omar
1ab236d9df Viewport, Platform: Internal renaming to use more consistent (OsDesktopPos > PlatformPos). (#1542) 2018-03-15 20:07:48 +01:00
omar
2e1ac0f683 Viewport, Platform: SDL: Makes the CreateViewport function restore current GL context so in theory it is free from side-effect. That said, it seems like there is a bug in SDL because our CreateViewport (currently in Render(), not for long) have affect a jerky side-effect if SDL_GL_MakeCurrent() is called before Render(). (#1542) 2018-03-15 19:25:23 +01:00
omar
8364d1ca6c Viewport: Removed back-end renderer code that implied we need to clear with WindowBg color. Added NoRendererClear flag. (#1542, #1042) 2018-03-15 18:17:04 +01:00
omar
09d8943967 Examples Refactor: GLFW: Explicit functions to init GLFW with OpenGL or Vulkan since we cannot read the api hints from glfw. 2018-03-15 16:42:21 +01:00
omar
6e58a95a01 Viewport, Platform, Examples: Changes to resizing flow + restored support for Platform events affecting the ImGui windows (so Decorated windows are functional). (#1542, #1042) ..
SDL: Added platform move/resize/close support.
GLFW: Added platform move/resize support. Moved Close to use callback for consistency.
Win32:
Vulkan: Fixed resize support.
Naming is WIP "PlatforrmRequestXXX" is too ambiguous. Basically we either have a ImGui->Platform flow or a Platform->ImGui flow. Working a bigger refactor now.
2018-03-15 10:57:22 +01:00
omar
207ad45983 Metrics: Displaying all draw lists of a window (if it uses layer 0 and has already been appended to earlier in the frame). 2018-03-14 17:50:11 +01:00
omar
83ef61fa56 Examples: SDL: Fix for versions olders than 2.0.6 2018-03-14 14:14:16 +01:00
omar
d0e0b106f0 Examples: SDL,GLFW,Vulkan: The Platform<>Renderer link is handled by SDL/GLFW platforms, both can compile without Vulkan headers, SDL+Vulkan is now on part with GLFW+Vulkan (aka broken the same way!). (#1542) 2018-03-13 23:16:15 +01:00
omar
98b66a5fc9 Examples: Using draw_data->DisplaySize, followup to c50198debe. Fix Vulkan secondary viewport rendering. SDL+Vulkan: Matched changes. Fix vcprojs. (#1542, #1042) 2018-03-13 23:07:12 +01:00
omar
921bb92eec Viewport: Fixed software mouse cursor from appearing in all multiple lists simultaneously. (#1542) 2018-03-13 16:20:34 +01:00
omar
c50198debe Viewport: Obsoleted io.DisplayPos (which was a Viewport branch thing), added ImDrawData::DisplayPos, DisplaySize (#1542) wip 2018-03-13 16:20:27 +01:00
omar
6371474031 Viewport: Removed unnecessary function hoop. 2018-03-13 16:20:19 +01:00
omar
8657201257 Merge branch 'master' into viewport 2018-03-13 16:20:02 +01:00
omar
b88492746e Examples, Viewport: Vulkan: Experiment (broken) multi-viewport support, merging code from ParticlePeter branches. (#1542, #1042) 2018-03-12 18:43:25 +01:00
omar
f6fc28dfd2 Merge branch 'master' into viewport (inc Vulkan resize fix merge #1042) 2018-03-12 17:50:32 +01:00
omar
cdeef65b05 Examples: Vulkan: Passing Queue, QueueFamily to binding. Fixed scissor (fixed in master). ImGui_ImplVulkanH_DestroyWindowData() waits for device to be idle. (#1042) 2018-03-12 17:37:28 +01:00
omar
1e81a53e75 Examples: DPI: Minor warning fix. (#1676) 2018-03-12 16:22:24 +01:00
omar
5e63711084 Viewport, DPI: Some early work on per-viewport DPI support. At the moment the easiest way is to replace fonts during the ChangedViewport callback, but down the line we should aim at handling some of it at ImFont level. (#1542, #1676) 2018-03-12 10:31:39 +01:00
omar
a2fbcc9ad4 Examples: DPI: Portable DPI related helpers in the _Win32 examples. Using one in examples's main.cpp, the GetDpiScale functions are not wired anywhere for now. (#1542, #1676) 2018-03-12 10:31:39 +01:00
omar
10030ff3ec Viewport: Fix dropping back viewport not being moved to the front of the window list. (Now that viewport are more tighly coupled to a single root window) (#1542) 2018-03-12 10:31:38 +01:00
omar
648735a4cf Viewport, DPI: Don't activate current window until a viewport has been selected. At this point we'll have the proper size/scale for the current DPI + fix viewport callback when appending to an existing window more than once a frame. (#1542, #1676) 2018-03-12 10:31:38 +01:00
omar
a4629b0b36 Viewport, DPI: Select viewport before locking style sizes and before handling double-click-on-title-bar to collapse. (#1542, #1676) 2018-03-12 10:31:38 +01:00
omar
64cbbed152 Merge branch 'master' into viewport 2018-03-09 10:41:12 +01:00
omar
43f375b2f2 Viewport,Platform: Added GetWindowDpiScale() platform interface, changes of scale are reflected by positioning and resizing windows in their given viewport. (#1542) 2018-03-09 10:40:38 +01:00
omar
1eb89d7e3b Viewport: Changed signature of ResizeViewport to be consistent with other similar functions. 2018-03-08 20:32:34 +01:00
omar
4d46383100 Viewport: Coupling non-main viewport to one window. Viewport name derived from the window. Added ImGuiConfigFlags_PlatformNoTaskBar, off by default (aka re-established task-bars by default for now). (#1542) 2018-03-08 20:27:01 +01:00
omar
aa3fe81c87 Examples: DPI: Hacked in a quick compile-and-run-everywhere call to SetProcessDpiAwareness(), will need to revisit. 2018-03-08 18:46:30 +01:00
omar
9ea16e344a Viewport: Disable extra viewports from hosting other windows. (#1542) 2018-03-07 16:34:18 +01:00
omar
d8719cf59b Fixed warnings. 2018-03-07 14:46:53 +01:00
omar
9dcc07422e Viewport: Reorganized viewport enable flags. Both user + platform + renderer need to enable a flag. (#1542) 2018-03-07 12:35:26 +01:00
omar
52c78820aa Examples: SDL: Fix for pre 2.0.4. 2018-03-07 12:19:19 +01:00
omar
19b92751b9 Examples: Updated Makefile and batch files to work with new examples. Using lowercase "gl.h" as it seems this is what Linux wants. 2018-03-07 12:05:47 +01:00
omar
f318f2d5ea Examples: Added Makefile for SDL+OpenGL2 example. (#1668) 2018-03-07 11:51:41 +01:00
omar
21ff03978a Viewport: Modal display their darkneing/whitening layer over all viewports. (#1542) 2018-03-07 11:36:37 +01:00
omar
25fd9d6132 Viewport: Various sanity fixes. Popup always inherit viewport from their parent for now. (#1542) 2018-03-07 10:50:30 +01:00
omar
3637193556 Merge branch 'master' into viewport
# Conflicts:
#	examples/imgui_impl_glfw.h
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.h
#	imgui.cpp
2018-03-06 20:02:40 +01:00
omar
8e3274e137 Viewport: Tracking current viewport we are appending to + added callback in PlatformInterface for DPI purpose (WIP). (#1542) 2018-03-05 22:31:12 +01:00
omar
c4a158656e Merge branch 'master' into viewport
# Conflicts:
#	examples/allegro5_example/main.cpp
#	examples/directx10_example/main.cpp
#	examples/directx11_example/main.cpp
#	examples/directx12_example/main.cpp
#	examples/directx9_example/main.cpp
#	examples/imgui_impl_dx10.cpp
#	examples/imgui_impl_dx11.cpp
#	examples/imgui_impl_dx12.cpp
#	examples/imgui_impl_dx9.cpp
#	examples/imgui_impl_glfw.h
#	examples/imgui_impl_vulkan.cpp
#	examples/opengl2_example/imgui_impl_glfw_gl2.cpp
#	examples/opengl2_example/main.cpp
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/opengl3_example/main.cpp
#	examples/sdl_opengl2_example/imgui_impl_sdl_gl2.cpp
#	examples/sdl_opengl2_example/main.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
#	examples/sdl_opengl3_example/main.cpp
#	examples/vulkan_example/main.cpp
#	imgui.cpp
#	imgui.h
2018-03-03 23:13:31 +01:00
omar
e026c8d3b7 Viewport: Give a chance to platform and renderer to actually destroy their data. Otherwise the regular ImplXXX_Shutdown + following by DestroyContext() order fails to fullifl this. (#1542) 2018-03-03 22:53:31 +01:00
omar
cab41d954e Examples: Vulkan: Further refactor. 2018-03-03 22:38:24 +01:00
omar
e0cbfd74d7 Examples: Vulkan: Moved CreateOrResizeWindowData func to imgui_impl_vulkan.h 2018-03-02 23:59:21 +01:00
omar
426930e028 Examples: Vulkan: Moved main.cpp data structures to imgui_impl_vulkan.h as shared helpers for the benefit of both the example and the platform/viewport renderer interface. 2018-03-02 23:05:23 +01:00
omar
e9fa17e1bf Viewport: Replaced UpdatePlatformWindows/RenderPlatformWindows by RenderAdditionalViewports(). The update is always called in EndFrame(). (#1542) 2018-03-02 22:44:06 +01:00
omar
b807347e94 Viewport: When enabled we assert against using RenderDrawListFn to make user more aware of rendering order. (#1542) 2018-03-02 22:22:14 +01:00
omar
7113fc7dee Examples: Vulkan: Moved variables into per-window data, refactored/tweaks to that the bug functions main.cpp for both SDL and GLFW examples match (they'll probably be moved to imgui_impl_vulkan as helpers). 2018-03-02 21:37:14 +01:00
omar
e0f283cfcb Examples: Vulkan: Fix 7b968b098e 2018-03-02 20:09:21 +01:00
omar
7b968b098e Examples: Vulkan: Reduced duplicate code by skipping present on the first frame. Amend 201d589714 by @ParticlePeter 2018-03-02 20:01:18 +01:00
omar
e927a6ac4a Examples: Vulkan: Various tweak. Misc refactor into per-frame data. Duplicate buffer creation code moved to CreateOrResizeBuffer(). 2018-03-02 19:40:09 +01:00
omar
9da475e4e8 Examples: GLFW, Vulkan: GLFW binding viewport tweaks to supports Vulkan better (do not call SwapBuffer, share context etc.). Added DUMMY (empty) platform/viewport interface in the viewport code. 2018-03-02 19:24:24 +01:00
omar
5b282bdd48 Examples: Renamed glfw error callback so it's more clear what it is. 2018-03-02 19:24:23 +01:00
omar
fc80f2b41a Merge branch 'examples_refactor' into viewport
# Conflicts:
#	examples/directx10_example/main.cpp
#	examples/directx11_example/main.cpp
#	examples/directx12_example/main.cpp
#	examples/opengl3_example/main.cpp
#	examples/sdl_opengl2_example/main.cpp
#	examples/sdl_opengl3_example/main.cpp
#	examples/sdl_vulkan_example/main.cpp
#	examples/vulkan_example/main.cpp
#	imgui.h
2018-03-01 23:27:11 +01:00
omar
68e9ef9885 Examples: Vulkan: SDL: Fixed missing resize handler (not properly merged from #1367) + tweaks. 2018-03-01 23:22:02 +01:00
omar
296db2ed33 Examples: Vulkan: Moved code into shared helpers: ImGui_ImplVulkan_SelectSurfaceFormat, ImGui_ImplVulkan_SelectPresentMode. 2018-03-01 23:22:02 +01:00
omar
3171d61dfc Examples: Vulkan: Various tweaks to name variable more consistently like Vulkan + a few comments + a few imgui style code compaction. 2018-03-01 23:22:01 +01:00
omar
00b9e70ba2 Viewport: Always be lenient with invalid mouse position during dragging, since they are provided by back-end and technically acceptable inputs + comments. (#1542) 2018-03-01 20:19:36 +01:00
omar
57e9f61852 Examples: Vulkan: Debug report tweak + always enable in Debug build. 2018-03-01 18:59:07 +01:00
omar
cf365ed00b Examples: Fixed enabling IMGUI_VULKAN_DEBUG_REPORT which was broken during refactor because of duplicate 'extensions' local variable. 2018-03-01 18:41:19 +01:00
omar
d98a5d54aa Renamed ImGuiNavFlags io.NavFlags to ImGuiConfigFlags io.ConfigFlags. (#787) 2018-02-28 19:03:39 +01:00
omar
8074d56bdd Renamed ImGuiNavFlags io.NavFlags to ImGuiConfigFlags io.ConfigFlags. (#787) 2018-02-28 18:58:34 +01:00
omar
fc3c3de70d Examples: DX10: Multi viewport/platform support (based on DX11 version). (#1542) 2018-02-28 18:35:16 +01:00
omar
997d1bd0eb Examples: NULL pointers for consistency. 2018-02-27 23:34:28 +01:00
omar
baef79415b Examples: DX12: Empty skeleton toward implementing the multi-viewport api for DirectX12. (WIP/test API) (#1542, #301) 2018-02-27 23:34:28 +01:00
omar
cb601d79e8 Examples: SDL: Initial attempt at implementing the viewport/platform api. (WIP/test API) (#1542)
ImGui_ImplSDL2_Init() now takes a SDL GL context.
2018-02-27 23:34:27 +01:00
omar
4cee46f909 Examples: GLFW + OpenGL3: Initial attempt at implementing the viewport/platform api. (WIP/test API) (#1542) 2018-02-27 23:27:41 +01:00
omar
25349b31d7 Examples: DX11 + Win32: Initial attempt at implementing the viewport/platform api. (WIP/test API) (#1542) 2018-02-27 23:26:51 +01:00
omar
735267d27c Viewport: Initial viewport branch+ platform api commit (squashed from previous commits, still very WIP) (#1542) 2018-02-27 23:25:39 +01:00
omar
b5ced477f4 Metrics: Added option to show begin order, useful for debugging. 2018-02-27 23:02:50 +01:00
omar
67319a71e5 Internal: Minor renaming. 2018-02-27 22:58:27 +01:00
omar
184a6f1198 Internals: Moving window: test mouse validity while translating window + using SetWindowPos(). 2018-02-27 22:56:22 +01:00
omar
b32bb4e6e3 Removed DisplayVisibleMin/DisplayVisibleMax facility (as part of # 1542). Misc comments. 2018-02-27 22:55:18 +01:00
omar
0e62b7d68a Clearing next window data at the end of Begin() more reliably. Misc comments. 2018-02-27 22:47:45 +01:00
omar
a761779b12 Internals: Settings: Added ReadCloseFn to allow handlers to sanitize data on a per-entry basis. 2018-02-27 22:32:45 +01:00
omar
29510fcb83 Examples: Misc tweaks/fixes. 2018-02-27 10:29:37 +01:00
omar
3f335b0d42 Merge branch 'master' into examples_refactor
# Conflicts:
#	examples/opengl3_example/imgui_impl_glfw_gl3.cpp
#	examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp
2018-02-26 18:22:36 +01:00
omar
ffda84cfae Examples: DirectX12: Merged to new example format, imgui_impl_dx12.cpp contains the DX12 stuff, couple with imgui_impl_win32.cpp 2018-02-23 10:56:06 +01:00
omar
e6bc840f6f Merge branch 'master' into examples_refactor 2018-02-23 10:47:32 +01:00
omar
0b26387a2b Simplified .gitignore list 2018-02-21 23:14:55 +01:00
omar
f7ef10e547 Examples: Titles/comments in headers 2018-02-21 23:05:17 +01:00
omar
91cadc1130 Merge branch 'master' into examples_refactor 2018-02-21 22:47:03 +01:00
omar
47d1360124 Examples: Using SDL2_DIR instead of SDL_DIR (more standard). 2018-02-21 22:41:46 +01:00
omar
f67699456c Examples: Added SDL+Vulkan example, the abstraction worked here :) (ref #1367) 2018-02-21 22:41:04 +01:00
omar
387f724d33 Examples: Vulkan: Formatting and tweaks (to match SDL's main). 2018-02-21 22:39:49 +01:00
omar
bcdfd5d61c Merge branch 'master' into examples_refactor 2018-02-20 16:18:02 +01:00
omar
e660d92fa5 Examples: GLFW: Added mouse cursors support (#1495) 2018-02-19 22:29:52 +01:00
omar
9fdf72e42b Examples: WIn32: Prefixing every Win32 function calls with :: to denote global namespace in a consistent manner. 2018-02-18 21:23:11 +01:00
omar
df9051ded2 Examples: Vulkan: Added support for io.DisplayPos. 2018-02-18 21:15:51 +01:00
omar
230c5ca735 Examples: Vulkan: Fixed GLFW calls. 2018-02-18 21:15:41 +01:00
omar
3bd3693fb7 Examples: DirectX10, DirectX11, OpenGL2, OpenGL3: Added support for io.DisplayPos. 2018-02-18 21:09:28 +01:00
omar
45cbebad64 Added dummy io.DisplayPos field. 2018-02-18 21:04:17 +01:00
omar
6d0f9244b8 Examples: Allegro5, Marmalade: Moved bindings to parent folder. Renamed Allegro stuff from *A5_ to *Allegro5_ 2018-02-18 20:26:20 +01:00
omar
80a8aea7e3 Examples: Added SDL, Vulkan examples to .sln file. 2018-02-18 20:26:20 +01:00
omar
4f0db01f7c Examples: DirectX9: Reusing imgui_impl_win32, removed that code from imgui_impl_dx9 2018-02-18 20:26:20 +01:00
omar
6cd4e30b58 Examples: DirectX10: Reusing imgui_impl_win32, removed that code from imgui_impl_dx10 2018-02-18 20:26:20 +01:00
omar
19540479d4 Examples: DirectX11: Extracted imgui_impl_dx11.* instead imgui_impl_dx11 and imgui_impl_win32 2018-02-18 20:26:20 +01:00
omar
90dffb5a06 Examples: Vulkan: Extracted into imgui_impl_vulkan.*, reused imgui_impl_glfw* files. 2018-02-18 20:26:20 +01:00
omar
ef521d1e0b Examples: SDL: Extracted into imgui_impl_sdl.*, reused imgui_impl_opengl* files. 2018-02-18 20:26:20 +01:00
omar
42c32bf00c Examples: OpenGL2, OpenGL3: Added glPixelStorei() calls borrowed from SDL examples. 2018-02-18 20:26:20 +01:00
omar
c8a9969511 Examples: GLFW+GL2: Moved glfw, gl2 files to root folder, split imgui_impl_glfw_gl2 into _opengl2 and reused imgui_impl_glfw 2018-02-18 20:26:20 +01:00
omar
b0a8734c92 Examples: GLFW+GL3: Split imgui_impl_glfw_gl3 into imgui_impl_glfw and imgui_impl_gl3 (wip) 2018-02-18 20:26:19 +01:00
omar
8d0723c2c3 ImFontAtlas: Added IsBuilt() helper. 2018-02-18 20:26:19 +01:00
70 changed files with 11801 additions and 434 deletions

View File

@ -6,7 +6,8 @@
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Clipboard support (from Allegro 5.1.12) // [X] Platform: Clipboard support (from Allegro 5.1.12)
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// Issues: // Missing features:
// [ ] Renderer: Multi-viewport support (multiple windows)..
// [ ] Renderer: The renderer is suboptimal as we need to convert vertices manually. // [ ] Renderer: The renderer is suboptimal as we need to convert vertices manually.
// [ ] Platform: Missing gamepad support. // [ ] Platform: Missing gamepad support.

View File

@ -6,7 +6,8 @@
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Clipboard support (from Allegro 5.1.12) // [X] Platform: Clipboard support (from Allegro 5.1.12)
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// Issues: // Missing features:
// [ ] Renderer: Multi-viewport support (multiple windows)..
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually. // [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
// [ ] Platform: Missing gamepad support. // [ ] Platform: Missing gamepad support.

View File

@ -8,6 +8,7 @@
// [ ] Platform: Clipboard support. // [ ] Platform: Clipboard support.
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android. // [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
// [ ] Platform: Multi-viewport support (multiple windows). Not meaningful on Android.
// Important: // Important:
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this. // - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446) // - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)

View File

@ -8,6 +8,7 @@
// [ ] Platform: Clipboard support. // [ ] Platform: Clipboard support.
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android. // [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
// [ ] Platform: Multi-viewport support (multiple windows). Not meaningful on Android.
// Important: // Important:
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this. // - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446) // - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)

View File

@ -4,6 +4,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -15,6 +16,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11. // 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). // 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
// 2021-05-19: DirectX10: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) // 2021-05-19: DirectX10: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
@ -79,6 +81,10 @@ static ImGui_ImplDX10_Data* ImGui_ImplDX10_GetBackendData()
return ImGui::GetCurrentContext() ? (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData : nullptr; return ImGui::GetCurrentContext() ? (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
} }
// Forward Declarations
static void ImGui_ImplDX10_InitPlatformInterface();
static void ImGui_ImplDX10_ShutdownPlatformInterface();
// Functions // Functions
static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* ctx) static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* ctx)
{ {
@ -542,6 +548,7 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device)
io.BackendRendererUserData = (void*)bd; io.BackendRendererUserData = (void*)bd;
io.BackendRendererName = "imgui_impl_dx10"; io.BackendRendererName = "imgui_impl_dx10";
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
// Get factory from device // Get factory from device
IDXGIDevice* pDXGIDevice = nullptr; IDXGIDevice* pDXGIDevice = nullptr;
@ -558,6 +565,8 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device)
if (pDXGIAdapter) pDXGIAdapter->Release(); if (pDXGIAdapter) pDXGIAdapter->Release();
bd->pd3dDevice->AddRef(); bd->pd3dDevice->AddRef();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplDX10_InitPlatformInterface();
return true; return true;
} }
@ -567,12 +576,13 @@ void ImGui_ImplDX10_Shutdown()
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui_ImplDX10_ShutdownPlatformInterface();
ImGui_ImplDX10_InvalidateDeviceObjects(); ImGui_ImplDX10_InvalidateDeviceObjects();
if (bd->pFactory) { bd->pFactory->Release(); } if (bd->pFactory) { bd->pFactory->Release(); }
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); } if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
io.BackendRendererName = nullptr; io.BackendRendererName = nullptr;
io.BackendRendererUserData = nullptr; io.BackendRendererUserData = nullptr;
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset; io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
IM_DELETE(bd); IM_DELETE(bd);
} }
@ -585,6 +595,129 @@ void ImGui_ImplDX10_NewFrame()
ImGui_ImplDX10_CreateDeviceObjects(); ImGui_ImplDX10_CreateDeviceObjects();
} }
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
struct ImGui_ImplDX10_ViewportData
{
IDXGISwapChain* SwapChain;
ID3D10RenderTargetView* RTView;
ImGui_ImplDX10_ViewportData() { SwapChain = nullptr; RTView = nullptr; }
~ImGui_ImplDX10_ViewportData() { IM_ASSERT(SwapChain == nullptr && RTView == nullptr); }
};
static void ImGui_ImplDX10_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
ImGui_ImplDX10_ViewportData* vd = IM_NEW(ImGui_ImplDX10_ViewportData)();
viewport->RendererUserData = vd;
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
IM_ASSERT(hwnd != 0);
// Create swap chain
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferDesc.Width = (UINT)viewport->Size.x;
sd.BufferDesc.Height = (UINT)viewport->Size.y;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = hwnd;
sd.Windowed = TRUE;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
IM_ASSERT(vd->SwapChain == nullptr && vd->RTView == nullptr);
bd->pFactory->CreateSwapChain(bd->pd3dDevice, &sd, &vd->SwapChain);
// Create the render target
if (vd->SwapChain)
{
ID3D10Texture2D* pBackBuffer;
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
pBackBuffer->Release();
}
}
static void ImGui_ImplDX10_DestroyWindow(ImGuiViewport* viewport)
{
// The main viewport (owned by the application) will always have RendererUserData == 0 here since we didn't create the data for it.
if (ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData)
{
if (vd->SwapChain)
vd->SwapChain->Release();
vd->SwapChain = nullptr;
if (vd->RTView)
vd->RTView->Release();
vd->RTView = nullptr;
IM_DELETE(vd);
}
viewport->RendererUserData = nullptr;
}
static void ImGui_ImplDX10_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData;
if (vd->RTView)
{
vd->RTView->Release();
vd->RTView = nullptr;
}
if (vd->SwapChain)
{
ID3D10Texture2D* pBackBuffer = nullptr;
vd->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
if (pBackBuffer == nullptr) { fprintf(stderr, "ImGui_ImplDX10_SetWindowSize() failed creating buffers.\n"); return; }
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
pBackBuffer->Release();
}
}
static void ImGui_ImplDX10_RenderViewport(ImGuiViewport* viewport, void*)
{
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData;
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
bd->pd3dDevice->OMSetRenderTargets(1, &vd->RTView, nullptr);
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
bd->pd3dDevice->ClearRenderTargetView(vd->RTView, (float*)&clear_color);
ImGui_ImplDX10_RenderDrawData(viewport->DrawData);
}
static void ImGui_ImplDX10_SwapBuffers(ImGuiViewport* viewport, void*)
{
ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData;
vd->SwapChain->Present(0, 0); // Present without vsync
}
void ImGui_ImplDX10_InitPlatformInterface()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Renderer_CreateWindow = ImGui_ImplDX10_CreateWindow;
platform_io.Renderer_DestroyWindow = ImGui_ImplDX10_DestroyWindow;
platform_io.Renderer_SetWindowSize = ImGui_ImplDX10_SetWindowSize;
platform_io.Renderer_RenderWindow = ImGui_ImplDX10_RenderViewport;
platform_io.Renderer_SwapBuffers = ImGui_ImplDX10_SwapBuffers;
}
void ImGui_ImplDX10_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif // #ifndef IMGUI_DISABLE #endif // #ifndef IMGUI_DISABLE

View File

@ -4,6 +4,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -4,6 +4,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -15,6 +16,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11. // 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). // 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) // 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
@ -80,6 +82,10 @@ static ImGui_ImplDX11_Data* ImGui_ImplDX11_GetBackendData()
return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : nullptr; return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
} }
// Forward Declarations
static void ImGui_ImplDX11_InitPlatformInterface();
static void ImGui_ImplDX11_ShutdownPlatformInterface();
// Functions // Functions
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx) static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
{ {
@ -554,6 +560,7 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
io.BackendRendererUserData = (void*)bd; io.BackendRendererUserData = (void*)bd;
io.BackendRendererName = "imgui_impl_dx11"; io.BackendRendererName = "imgui_impl_dx11";
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
// Get factory from device // Get factory from device
IDXGIDevice* pDXGIDevice = nullptr; IDXGIDevice* pDXGIDevice = nullptr;
@ -573,6 +580,9 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
bd->pd3dDevice->AddRef(); bd->pd3dDevice->AddRef();
bd->pd3dDeviceContext->AddRef(); bd->pd3dDeviceContext->AddRef();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplDX11_InitPlatformInterface();
return true; return true;
} }
@ -582,13 +592,14 @@ void ImGui_ImplDX11_Shutdown()
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui_ImplDX11_ShutdownPlatformInterface();
ImGui_ImplDX11_InvalidateDeviceObjects(); ImGui_ImplDX11_InvalidateDeviceObjects();
if (bd->pFactory) { bd->pFactory->Release(); } if (bd->pFactory) { bd->pFactory->Release(); }
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); } if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); } if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); }
io.BackendRendererName = nullptr; io.BackendRendererName = nullptr;
io.BackendRendererUserData = nullptr; io.BackendRendererUserData = nullptr;
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset; io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
IM_DELETE(bd); IM_DELETE(bd);
} }
@ -601,6 +612,129 @@ void ImGui_ImplDX11_NewFrame()
ImGui_ImplDX11_CreateDeviceObjects(); ImGui_ImplDX11_CreateDeviceObjects();
} }
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
struct ImGui_ImplDX11_ViewportData
{
IDXGISwapChain* SwapChain;
ID3D11RenderTargetView* RTView;
ImGui_ImplDX11_ViewportData() { SwapChain = nullptr; RTView = nullptr; }
~ImGui_ImplDX11_ViewportData() { IM_ASSERT(SwapChain == nullptr && RTView == nullptr); }
};
static void ImGui_ImplDX11_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
ImGui_ImplDX11_ViewportData* vd = IM_NEW(ImGui_ImplDX11_ViewportData)();
viewport->RendererUserData = vd;
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
IM_ASSERT(hwnd != 0);
// Create swap chain
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferDesc.Width = (UINT)viewport->Size.x;
sd.BufferDesc.Height = (UINT)viewport->Size.y;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = hwnd;
sd.Windowed = TRUE;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
IM_ASSERT(vd->SwapChain == nullptr && vd->RTView == nullptr);
bd->pFactory->CreateSwapChain(bd->pd3dDevice, &sd, &vd->SwapChain);
// Create the render target
if (vd->SwapChain)
{
ID3D11Texture2D* pBackBuffer;
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
pBackBuffer->Release();
}
}
static void ImGui_ImplDX11_DestroyWindow(ImGuiViewport* viewport)
{
// The main viewport (owned by the application) will always have RendererUserData == nullptr since we didn't create the data for it.
if (ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData)
{
if (vd->SwapChain)
vd->SwapChain->Release();
vd->SwapChain = nullptr;
if (vd->RTView)
vd->RTView->Release();
vd->RTView = nullptr;
IM_DELETE(vd);
}
viewport->RendererUserData = nullptr;
}
static void ImGui_ImplDX11_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData;
if (vd->RTView)
{
vd->RTView->Release();
vd->RTView = nullptr;
}
if (vd->SwapChain)
{
ID3D11Texture2D* pBackBuffer = nullptr;
vd->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
if (pBackBuffer == nullptr) { fprintf(stderr, "ImGui_ImplDX11_SetWindowSize() failed creating buffers.\n"); return; }
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
pBackBuffer->Release();
}
}
static void ImGui_ImplDX11_RenderWindow(ImGuiViewport* viewport, void*)
{
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData;
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
bd->pd3dDeviceContext->OMSetRenderTargets(1, &vd->RTView, nullptr);
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
bd->pd3dDeviceContext->ClearRenderTargetView(vd->RTView, (float*)&clear_color);
ImGui_ImplDX11_RenderDrawData(viewport->DrawData);
}
static void ImGui_ImplDX11_SwapBuffers(ImGuiViewport* viewport, void*)
{
ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData;
vd->SwapChain->Present(0, 0); // Present without vsync
}
static void ImGui_ImplDX11_InitPlatformInterface()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Renderer_CreateWindow = ImGui_ImplDX11_CreateWindow;
platform_io.Renderer_DestroyWindow = ImGui_ImplDX11_DestroyWindow;
platform_io.Renderer_SetWindowSize = ImGui_ImplDX11_SetWindowSize;
platform_io.Renderer_RenderWindow = ImGui_ImplDX11_RenderWindow;
platform_io.Renderer_SwapBuffers = ImGui_ImplDX11_SwapBuffers;
}
static void ImGui_ImplDX11_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif // #ifndef IMGUI_DISABLE #endif // #ifndef IMGUI_DISABLE

View File

@ -4,6 +4,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -4,6 +4,8 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// FIXME: The transition from removing a viewport and moving the window in an existing hosted viewport tends to flicker.
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. // Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. // This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
@ -23,6 +25,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11. // 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). // 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
// 2021-05-19: DirectX12: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) // 2021-05-19: DirectX12: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
@ -54,7 +57,6 @@
#endif #endif
// DirectX data // DirectX data
struct ImGui_ImplDX12_RenderBuffers;
struct ImGui_ImplDX12_Data struct ImGui_ImplDX12_Data
{ {
ID3D12Device* pd3dDevice; ID3D12Device* pd3dDevice;
@ -67,10 +69,7 @@ struct ImGui_ImplDX12_Data
ID3D12DescriptorHeap* pd3dSrvDescHeap; ID3D12DescriptorHeap* pd3dSrvDescHeap;
UINT numFramesInFlight; UINT numFramesInFlight;
ImGui_ImplDX12_RenderBuffers* pFrameResources; ImGui_ImplDX12_Data() { memset((void*)this, 0, sizeof(*this)); }
UINT frameIndex;
ImGui_ImplDX12_Data() { memset((void*)this, 0, sizeof(*this)); frameIndex = UINT_MAX; }
}; };
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts // Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
@ -89,11 +88,88 @@ struct ImGui_ImplDX12_RenderBuffers
int VertexBufferSize; int VertexBufferSize;
}; };
// Buffers used for secondary viewports created by the multi-viewports systems
struct ImGui_ImplDX12_FrameContext
{
ID3D12CommandAllocator* CommandAllocator;
ID3D12Resource* RenderTarget;
D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetCpuDescriptors;
};
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
// Main viewport created by application will only use the Resources field.
// Secondary viewports created by this backend will use all the fields (including Window fields),
struct ImGui_ImplDX12_ViewportData
{
// Window
ID3D12CommandQueue* CommandQueue;
ID3D12GraphicsCommandList* CommandList;
ID3D12DescriptorHeap* RtvDescHeap;
IDXGISwapChain3* SwapChain;
ID3D12Fence* Fence;
UINT64 FenceSignaledValue;
HANDLE FenceEvent;
UINT NumFramesInFlight;
ImGui_ImplDX12_FrameContext* FrameCtx;
// Render buffers
UINT FrameIndex;
ImGui_ImplDX12_RenderBuffers* FrameRenderBuffers;
ImGui_ImplDX12_ViewportData(UINT num_frames_in_flight)
{
CommandQueue = nullptr;
CommandList = nullptr;
RtvDescHeap = nullptr;
SwapChain = nullptr;
Fence = nullptr;
FenceSignaledValue = 0;
FenceEvent = nullptr;
NumFramesInFlight = num_frames_in_flight;
FrameCtx = new ImGui_ImplDX12_FrameContext[NumFramesInFlight];
FrameIndex = UINT_MAX;
FrameRenderBuffers = new ImGui_ImplDX12_RenderBuffers[NumFramesInFlight];
for (UINT i = 0; i < NumFramesInFlight; ++i)
{
FrameCtx[i].CommandAllocator = nullptr;
FrameCtx[i].RenderTarget = nullptr;
// Create buffers with a default size (they will later be grown as needed)
FrameRenderBuffers[i].IndexBuffer = nullptr;
FrameRenderBuffers[i].VertexBuffer = nullptr;
FrameRenderBuffers[i].VertexBufferSize = 5000;
FrameRenderBuffers[i].IndexBufferSize = 10000;
}
}
~ImGui_ImplDX12_ViewportData()
{
IM_ASSERT(CommandQueue == nullptr && CommandList == nullptr);
IM_ASSERT(RtvDescHeap == nullptr);
IM_ASSERT(SwapChain == nullptr);
IM_ASSERT(Fence == nullptr);
IM_ASSERT(FenceEvent == nullptr);
for (UINT i = 0; i < NumFramesInFlight; ++i)
{
IM_ASSERT(FrameCtx[i].CommandAllocator == nullptr && FrameCtx[i].RenderTarget == nullptr);
IM_ASSERT(FrameRenderBuffers[i].IndexBuffer == nullptr && FrameRenderBuffers[i].VertexBuffer == nullptr);
}
delete[] FrameCtx; FrameCtx = nullptr;
delete[] FrameRenderBuffers; FrameRenderBuffers = nullptr;
}
};
struct VERTEX_CONSTANT_BUFFER_DX12 struct VERTEX_CONSTANT_BUFFER_DX12
{ {
float mvp[4][4]; float mvp[4][4];
}; };
// Forward Declarations
static void ImGui_ImplDX12_InitPlatformInterface();
static void ImGui_ImplDX12_ShutdownPlatformInterface();
// Functions // Functions
static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, ImGui_ImplDX12_RenderBuffers* fr) static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, ImGui_ImplDX12_RenderBuffers* fr)
{ {
@ -167,11 +243,10 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
return; return;
// FIXME: I'm assuming that this only gets called once per frame!
// If not, we can't just re-allocate the IB or VB, we'll have to do a proper allocator.
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
bd->frameIndex = bd->frameIndex + 1; ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)draw_data->OwnerViewport->RendererUserData;
ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[bd->frameIndex % bd->numFramesInFlight]; vd->FrameIndex++;
ImGui_ImplDX12_RenderBuffers* fr = &vd->FrameRenderBuffers[vd->FrameIndex % bd->numFramesInFlight];
// Create and grow vertex/index buffers if needed // Create and grow vertex/index buffers if needed
if (fr->VertexBuffer == nullptr || fr->VertexBufferSize < draw_data->TotalVtxCount) if (fr->VertexBuffer == nullptr || fr->VertexBufferSize < draw_data->TotalVtxCount)
@ -678,6 +753,13 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
return true; return true;
} }
static void ImGui_ImplDX12_DestroyRenderBuffers(ImGui_ImplDX12_RenderBuffers* render_buffers)
{
SafeRelease(render_buffers->IndexBuffer);
SafeRelease(render_buffers->VertexBuffer);
render_buffers->IndexBufferSize = render_buffers->VertexBufferSize = 0;
}
void ImGui_ImplDX12_InvalidateDeviceObjects() void ImGui_ImplDX12_InvalidateDeviceObjects()
{ {
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
@ -689,13 +771,6 @@ void ImGui_ImplDX12_InvalidateDeviceObjects()
SafeRelease(bd->pPipelineState); SafeRelease(bd->pPipelineState);
SafeRelease(bd->pFontTextureResource); SafeRelease(bd->pFontTextureResource);
io.Fonts->SetTexID(0); // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well. io.Fonts->SetTexID(0); // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
for (UINT i = 0; i < bd->numFramesInFlight; i++)
{
ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[i];
SafeRelease(fr->IndexBuffer);
SafeRelease(fr->VertexBuffer);
}
} }
bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap, bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
@ -710,25 +785,21 @@ bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FO
io.BackendRendererUserData = (void*)bd; io.BackendRendererUserData = (void*)bd;
io.BackendRendererName = "imgui_impl_dx12"; io.BackendRendererName = "imgui_impl_dx12";
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplDX12_InitPlatformInterface();
bd->pd3dDevice = device; bd->pd3dDevice = device;
bd->RTVFormat = rtv_format; bd->RTVFormat = rtv_format;
bd->hFontSrvCpuDescHandle = font_srv_cpu_desc_handle; bd->hFontSrvCpuDescHandle = font_srv_cpu_desc_handle;
bd->hFontSrvGpuDescHandle = font_srv_gpu_desc_handle; bd->hFontSrvGpuDescHandle = font_srv_gpu_desc_handle;
bd->pFrameResources = new ImGui_ImplDX12_RenderBuffers[num_frames_in_flight];
bd->numFramesInFlight = num_frames_in_flight; bd->numFramesInFlight = num_frames_in_flight;
bd->pd3dSrvDescHeap = cbv_srv_heap; bd->pd3dSrvDescHeap = cbv_srv_heap;
bd->frameIndex = UINT_MAX;
// Create buffers with a default size (they will later be grown as needed) // Create a dummy ImGui_ImplDX12_ViewportData holder for the main viewport,
for (int i = 0; i < num_frames_in_flight; i++) // Since this is created and managed by the application, we will only use the ->Resources[] fields.
{ ImGuiViewport* main_viewport = ImGui::GetMainViewport();
ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[i]; main_viewport->RendererUserData = IM_NEW(ImGui_ImplDX12_ViewportData)(bd->numFramesInFlight);
fr->IndexBuffer = nullptr;
fr->VertexBuffer = nullptr;
fr->IndexBufferSize = 10000;
fr->VertexBufferSize = 5000;
}
return true; return true;
} }
@ -739,12 +810,24 @@ void ImGui_ImplDX12_Shutdown()
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
// Manually delete main viewport render resources in-case we haven't initialized for viewports
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
if (ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)main_viewport->RendererUserData)
{
// We could just call ImGui_ImplDX12_DestroyWindow(main_viewport) as a convenience but that would be misleading since we only use data->Resources[]
for (UINT i = 0; i < bd->numFramesInFlight; i++)
ImGui_ImplDX12_DestroyRenderBuffers(&vd->FrameRenderBuffers[i]);
IM_DELETE(vd);
main_viewport->RendererUserData = nullptr;
}
// Clean up windows and device objects // Clean up windows and device objects
ImGui_ImplDX12_ShutdownPlatformInterface();
ImGui_ImplDX12_InvalidateDeviceObjects(); ImGui_ImplDX12_InvalidateDeviceObjects();
delete[] bd->pFrameResources;
io.BackendRendererName = nullptr; io.BackendRendererName = nullptr;
io.BackendRendererUserData = nullptr; io.BackendRendererUserData = nullptr;
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset; io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
IM_DELETE(bd); IM_DELETE(bd);
} }
@ -757,6 +840,246 @@ void ImGui_ImplDX12_NewFrame()
ImGui_ImplDX12_CreateDeviceObjects(); ImGui_ImplDX12_CreateDeviceObjects();
} }
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
static void ImGui_ImplDX12_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
ImGui_ImplDX12_ViewportData* vd = IM_NEW(ImGui_ImplDX12_ViewportData)(bd->numFramesInFlight);
viewport->RendererUserData = vd;
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
IM_ASSERT(hwnd != 0);
vd->FrameIndex = UINT_MAX;
// Create command queue.
D3D12_COMMAND_QUEUE_DESC queue_desc = {};
queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
HRESULT res = S_OK;
res = bd->pd3dDevice->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&vd->CommandQueue));
IM_ASSERT(res == S_OK);
// Create command allocator.
for (UINT i = 0; i < bd->numFramesInFlight; ++i)
{
res = bd->pd3dDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&vd->FrameCtx[i].CommandAllocator));
IM_ASSERT(res == S_OK);
}
// Create command list.
res = bd->pd3dDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, vd->FrameCtx[0].CommandAllocator, nullptr, IID_PPV_ARGS(&vd->CommandList));
IM_ASSERT(res == S_OK);
vd->CommandList->Close();
// Create fence.
res = bd->pd3dDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&vd->Fence));
IM_ASSERT(res == S_OK);
vd->FenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
IM_ASSERT(vd->FenceEvent != nullptr);
// Create swap chain
// FIXME-VIEWPORT: May want to copy/inherit swap chain settings from the user/application.
DXGI_SWAP_CHAIN_DESC1 sd1;
ZeroMemory(&sd1, sizeof(sd1));
sd1.BufferCount = bd->numFramesInFlight;
sd1.Width = (UINT)viewport->Size.x;
sd1.Height = (UINT)viewport->Size.y;
sd1.Format = bd->RTVFormat;
sd1.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd1.SampleDesc.Count = 1;
sd1.SampleDesc.Quality = 0;
sd1.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
sd1.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
sd1.Scaling = DXGI_SCALING_NONE;
sd1.Stereo = FALSE;
IDXGIFactory4* dxgi_factory = nullptr;
res = ::CreateDXGIFactory1(IID_PPV_ARGS(&dxgi_factory));
IM_ASSERT(res == S_OK);
IDXGISwapChain1* swap_chain = nullptr;
res = dxgi_factory->CreateSwapChainForHwnd(vd->CommandQueue, hwnd, &sd1, nullptr, nullptr, &swap_chain);
IM_ASSERT(res == S_OK);
dxgi_factory->Release();
// Or swapChain.As(&mSwapChain)
IM_ASSERT(vd->SwapChain == nullptr);
swap_chain->QueryInterface(IID_PPV_ARGS(&vd->SwapChain));
swap_chain->Release();
// Create the render targets
if (vd->SwapChain)
{
D3D12_DESCRIPTOR_HEAP_DESC desc = {};
desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
desc.NumDescriptors = bd->numFramesInFlight;
desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
desc.NodeMask = 1;
HRESULT hr = bd->pd3dDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&vd->RtvDescHeap));
IM_ASSERT(hr == S_OK);
SIZE_T rtv_descriptor_size = bd->pd3dDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle = vd->RtvDescHeap->GetCPUDescriptorHandleForHeapStart();
for (UINT i = 0; i < bd->numFramesInFlight; i++)
{
vd->FrameCtx[i].RenderTargetCpuDescriptors = rtv_handle;
rtv_handle.ptr += rtv_descriptor_size;
}
ID3D12Resource* back_buffer;
for (UINT i = 0; i < bd->numFramesInFlight; i++)
{
IM_ASSERT(vd->FrameCtx[i].RenderTarget == nullptr);
vd->SwapChain->GetBuffer(i, IID_PPV_ARGS(&back_buffer));
bd->pd3dDevice->CreateRenderTargetView(back_buffer, nullptr, vd->FrameCtx[i].RenderTargetCpuDescriptors);
vd->FrameCtx[i].RenderTarget = back_buffer;
}
}
for (UINT i = 0; i < bd->numFramesInFlight; i++)
ImGui_ImplDX12_DestroyRenderBuffers(&vd->FrameRenderBuffers[i]);
}
static void ImGui_WaitForPendingOperations(ImGui_ImplDX12_ViewportData* vd)
{
HRESULT hr = S_FALSE;
if (vd && vd->CommandQueue && vd->Fence && vd->FenceEvent)
{
hr = vd->CommandQueue->Signal(vd->Fence, ++vd->FenceSignaledValue);
IM_ASSERT(hr == S_OK);
::WaitForSingleObject(vd->FenceEvent, 0); // Reset any forgotten waits
hr = vd->Fence->SetEventOnCompletion(vd->FenceSignaledValue, vd->FenceEvent);
IM_ASSERT(hr == S_OK);
::WaitForSingleObject(vd->FenceEvent, INFINITE);
}
}
static void ImGui_ImplDX12_DestroyWindow(ImGuiViewport* viewport)
{
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
if (ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData)
{
ImGui_WaitForPendingOperations(vd);
SafeRelease(vd->CommandQueue);
SafeRelease(vd->CommandList);
SafeRelease(vd->SwapChain);
SafeRelease(vd->RtvDescHeap);
SafeRelease(vd->Fence);
::CloseHandle(vd->FenceEvent);
vd->FenceEvent = nullptr;
for (UINT i = 0; i < bd->numFramesInFlight; i++)
{
SafeRelease(vd->FrameCtx[i].RenderTarget);
SafeRelease(vd->FrameCtx[i].CommandAllocator);
ImGui_ImplDX12_DestroyRenderBuffers(&vd->FrameRenderBuffers[i]);
}
IM_DELETE(vd);
}
viewport->RendererUserData = nullptr;
}
static void ImGui_ImplDX12_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData;
ImGui_WaitForPendingOperations(vd);
for (UINT i = 0; i < bd->numFramesInFlight; i++)
SafeRelease(vd->FrameCtx[i].RenderTarget);
if (vd->SwapChain)
{
ID3D12Resource* back_buffer = nullptr;
vd->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
for (UINT i = 0; i < bd->numFramesInFlight; i++)
{
vd->SwapChain->GetBuffer(i, IID_PPV_ARGS(&back_buffer));
bd->pd3dDevice->CreateRenderTargetView(back_buffer, nullptr, vd->FrameCtx[i].RenderTargetCpuDescriptors);
vd->FrameCtx[i].RenderTarget = back_buffer;
}
}
}
static void ImGui_ImplDX12_RenderWindow(ImGuiViewport* viewport, void*)
{
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData;
ImGui_ImplDX12_FrameContext* frame_context = &vd->FrameCtx[vd->FrameIndex % bd->numFramesInFlight];
UINT back_buffer_idx = vd->SwapChain->GetCurrentBackBufferIndex();
const ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barrier.Transition.pResource = vd->FrameCtx[back_buffer_idx].RenderTarget;
barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
// Draw
ID3D12GraphicsCommandList* cmd_list = vd->CommandList;
frame_context->CommandAllocator->Reset();
cmd_list->Reset(frame_context->CommandAllocator, nullptr);
cmd_list->ResourceBarrier(1, &barrier);
cmd_list->OMSetRenderTargets(1, &vd->FrameCtx[back_buffer_idx].RenderTargetCpuDescriptors, FALSE, nullptr);
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
cmd_list->ClearRenderTargetView(vd->FrameCtx[back_buffer_idx].RenderTargetCpuDescriptors, (float*)&clear_color, 0, nullptr);
cmd_list->SetDescriptorHeaps(1, &bd->pd3dSrvDescHeap);
ImGui_ImplDX12_RenderDrawData(viewport->DrawData, cmd_list);
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
cmd_list->ResourceBarrier(1, &barrier);
cmd_list->Close();
vd->CommandQueue->Wait(vd->Fence, vd->FenceSignaledValue);
vd->CommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&cmd_list);
vd->CommandQueue->Signal(vd->Fence, ++vd->FenceSignaledValue);
}
static void ImGui_ImplDX12_SwapBuffers(ImGuiViewport* viewport, void*)
{
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData;
vd->SwapChain->Present(0, 0);
while (vd->Fence->GetCompletedValue() < vd->FenceSignaledValue)
::SwitchToThread();
}
void ImGui_ImplDX12_InitPlatformInterface()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Renderer_CreateWindow = ImGui_ImplDX12_CreateWindow;
platform_io.Renderer_DestroyWindow = ImGui_ImplDX12_DestroyWindow;
platform_io.Renderer_SetWindowSize = ImGui_ImplDX12_SetWindowSize;
platform_io.Renderer_RenderWindow = ImGui_ImplDX12_RenderWindow;
platform_io.Renderer_SwapBuffers = ImGui_ImplDX12_SwapBuffers;
}
void ImGui_ImplDX12_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif // #ifndef IMGUI_DISABLE #endif // #ifndef IMGUI_DISABLE

View File

@ -4,6 +4,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. // Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
// See imgui_impl_dx12.cpp file for details. // See imgui_impl_dx12.cpp file for details.

View File

@ -4,6 +4,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -15,6 +16,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-02-12: DirectX9: Using RGBA format when supported by the driver to avoid CPU side conversion. (#6575) // 2024-02-12: DirectX9: Using RGBA format when supported by the driver to avoid CPU side conversion. (#6575)
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11. // 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). // 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
@ -76,6 +78,12 @@ static ImGui_ImplDX9_Data* ImGui_ImplDX9_GetBackendData()
return ImGui::GetCurrentContext() ? (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData : nullptr; return ImGui::GetCurrentContext() ? (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
} }
// Forward Declarations
static void ImGui_ImplDX9_InitPlatformInterface();
static void ImGui_ImplDX9_ShutdownPlatformInterface();
static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows();
static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows();
// Functions // Functions
static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data) static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
{ {
@ -272,6 +280,11 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
global_vtx_offset += cmd_list->VtxBuffer.Size; global_vtx_offset += cmd_list->VtxBuffer.Size;
} }
// When using multi-viewports, it appears that there's an odd logic in DirectX9 which prevent subsequent windows
// from rendering until the first window submits at least one draw call, even once. That's our workaround. (see #2560)
if (global_vtx_offset == 0)
bd->pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 0, 0, 0);
// Restore the DX9 transform // Restore the DX9 transform
bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world); bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view); bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
@ -293,10 +306,14 @@ bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
io.BackendRendererUserData = (void*)bd; io.BackendRendererUserData = (void*)bd;
io.BackendRendererName = "imgui_impl_dx9"; io.BackendRendererName = "imgui_impl_dx9";
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
bd->pd3dDevice = device; bd->pd3dDevice = device;
bd->pd3dDevice->AddRef(); bd->pd3dDevice->AddRef();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplDX9_InitPlatformInterface();
return true; return true;
} }
@ -306,11 +323,12 @@ void ImGui_ImplDX9_Shutdown()
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui_ImplDX9_ShutdownPlatformInterface();
ImGui_ImplDX9_InvalidateDeviceObjects(); ImGui_ImplDX9_InvalidateDeviceObjects();
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); } if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
io.BackendRendererName = nullptr; io.BackendRendererName = nullptr;
io.BackendRendererUserData = nullptr; io.BackendRendererUserData = nullptr;
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset; io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
IM_DELETE(bd); IM_DELETE(bd);
} }
@ -384,6 +402,7 @@ bool ImGui_ImplDX9_CreateDeviceObjects()
return false; return false;
if (!ImGui_ImplDX9_CreateFontsTexture()) if (!ImGui_ImplDX9_CreateFontsTexture())
return false; return false;
ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows();
return true; return true;
} }
@ -395,6 +414,7 @@ void ImGui_ImplDX9_InvalidateDeviceObjects()
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; } if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; } if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
if (bd->FontTexture) { bd->FontTexture->Release(); bd->FontTexture = nullptr; ImGui::GetIO().Fonts->SetTexID(0); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well. if (bd->FontTexture) { bd->FontTexture->Release(); bd->FontTexture = nullptr; ImGui::GetIO().Fonts->SetTexID(0); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows();
} }
void ImGui_ImplDX9_NewFrame() void ImGui_ImplDX9_NewFrame()
@ -406,6 +426,148 @@ void ImGui_ImplDX9_NewFrame()
ImGui_ImplDX9_CreateDeviceObjects(); ImGui_ImplDX9_CreateDeviceObjects();
} }
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
struct ImGui_ImplDX9_ViewportData
{
IDirect3DSwapChain9* SwapChain;
D3DPRESENT_PARAMETERS d3dpp;
ImGui_ImplDX9_ViewportData() { SwapChain = nullptr; ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); }
~ImGui_ImplDX9_ViewportData() { IM_ASSERT(SwapChain == nullptr); }
};
static void ImGui_ImplDX9_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
ImGui_ImplDX9_ViewportData* vd = IM_NEW(ImGui_ImplDX9_ViewportData)();
viewport->RendererUserData = vd;
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
IM_ASSERT(hwnd != 0);
ZeroMemory(&vd->d3dpp, sizeof(D3DPRESENT_PARAMETERS));
vd->d3dpp.Windowed = TRUE;
vd->d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
vd->d3dpp.BackBufferWidth = (UINT)viewport->Size.x;
vd->d3dpp.BackBufferHeight = (UINT)viewport->Size.y;
vd->d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
vd->d3dpp.hDeviceWindow = hwnd;
vd->d3dpp.EnableAutoDepthStencil = FALSE;
vd->d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
vd->d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync
HRESULT hr = bd->pd3dDevice->CreateAdditionalSwapChain(&vd->d3dpp, &vd->SwapChain); IM_UNUSED(hr);
IM_ASSERT(hr == D3D_OK);
IM_ASSERT(vd->SwapChain != nullptr);
}
static void ImGui_ImplDX9_DestroyWindow(ImGuiViewport* viewport)
{
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
if (ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData)
{
if (vd->SwapChain)
vd->SwapChain->Release();
vd->SwapChain = nullptr;
ZeroMemory(&vd->d3dpp, sizeof(D3DPRESENT_PARAMETERS));
IM_DELETE(vd);
}
viewport->RendererUserData = nullptr;
}
static void ImGui_ImplDX9_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData;
if (vd->SwapChain)
{
vd->SwapChain->Release();
vd->SwapChain = nullptr;
vd->d3dpp.BackBufferWidth = (UINT)size.x;
vd->d3dpp.BackBufferHeight = (UINT)size.y;
HRESULT hr = bd->pd3dDevice->CreateAdditionalSwapChain(&vd->d3dpp, &vd->SwapChain); IM_UNUSED(hr);
IM_ASSERT(hr == D3D_OK);
}
}
static void ImGui_ImplDX9_RenderWindow(ImGuiViewport* viewport, void*)
{
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData;
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
LPDIRECT3DSURFACE9 render_target = nullptr;
LPDIRECT3DSURFACE9 last_render_target = nullptr;
LPDIRECT3DSURFACE9 last_depth_stencil = nullptr;
vd->SwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &render_target);
bd->pd3dDevice->GetRenderTarget(0, &last_render_target);
bd->pd3dDevice->GetDepthStencilSurface(&last_depth_stencil);
bd->pd3dDevice->SetRenderTarget(0, render_target);
bd->pd3dDevice->SetDepthStencilSurface(nullptr);
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
{
D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*255.0f), (int)(clear_color.y*255.0f), (int)(clear_color.z*255.0f), (int)(clear_color.w*255.0f));
bd->pd3dDevice->Clear(0, nullptr, D3DCLEAR_TARGET, clear_col_dx, 1.0f, 0);
}
ImGui_ImplDX9_RenderDrawData(viewport->DrawData);
// Restore render target
bd->pd3dDevice->SetRenderTarget(0, last_render_target);
bd->pd3dDevice->SetDepthStencilSurface(last_depth_stencil);
render_target->Release();
last_render_target->Release();
if (last_depth_stencil) last_depth_stencil->Release();
}
static void ImGui_ImplDX9_SwapBuffers(ImGuiViewport* viewport, void*)
{
ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData;
HRESULT hr = vd->SwapChain->Present(nullptr, nullptr, vd->d3dpp.hDeviceWindow, nullptr, 0);
// Let main application handle D3DERR_DEVICELOST by resetting the device.
IM_ASSERT(SUCCEEDED(hr) || hr == D3DERR_DEVICELOST);
}
static void ImGui_ImplDX9_InitPlatformInterface()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Renderer_CreateWindow = ImGui_ImplDX9_CreateWindow;
platform_io.Renderer_DestroyWindow = ImGui_ImplDX9_DestroyWindow;
platform_io.Renderer_SetWindowSize = ImGui_ImplDX9_SetWindowSize;
platform_io.Renderer_RenderWindow = ImGui_ImplDX9_RenderWindow;
platform_io.Renderer_SwapBuffers = ImGui_ImplDX9_SwapBuffers;
}
static void ImGui_ImplDX9_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
for (int i = 1; i < platform_io.Viewports.Size; i++)
if (!platform_io.Viewports[i]->RendererUserData)
ImGui_ImplDX9_CreateWindow(platform_io.Viewports[i]);
}
static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
for (int i = 1; i < platform_io.Viewports.Size; i++)
if (platform_io.Viewports[i]->RendererUserData)
ImGui_ImplDX9_DestroyWindow(platform_io.Viewports[i]);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif // #ifndef IMGUI_DISABLE #endif // #ifndef IMGUI_DISABLE

View File

@ -4,6 +4,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -9,6 +9,9 @@
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+). // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// Issues:
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -20,6 +23,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO: // 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn // - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn // - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
@ -36,6 +40,7 @@
// 2023-03-16: Inputs: Fixed key modifiers handling on secondary viewports (docking branch). Broken on 2023/01/04. (#6248, #6034) // 2023-03-16: Inputs: Fixed key modifiers handling on secondary viewports (docking branch). Broken on 2023/01/04. (#6248, #6034)
// 2023-03-14: Emscripten: Avoid using glfwGetError() and glfwGetGamepadState() which are not correctly implemented in Emscripten emulation. (#6240) // 2023-03-14: Emscripten: Avoid using glfwGetError() and glfwGetGamepadState() which are not correctly implemented in Emscripten emulation. (#6240)
// 2023-02-03: Emscripten: Registering custom low-level mouse wheel handler to get more accurate scrolling impulses on Emscripten. (#4019, #6096) // 2023-02-03: Emscripten: Registering custom low-level mouse wheel handler to get more accurate scrolling impulses on Emscripten. (#4019, #6096)
// 2023-01-18: Handle unsupported glfwGetVideoMode() call on e.g. Emscripten.
// 2023-01-04: Inputs: Fixed mods state on Linux when using Alt-GR text input (e.g. German keyboard layout), could lead to broken text input. Revert a 2022/01/17 change were we resumed using mods provided by GLFW, turns out they were faulty. // 2023-01-04: Inputs: Fixed mods state on Linux when using Alt-GR text input (e.g. German keyboard layout), could lead to broken text input. Revert a 2022/01/17 change were we resumed using mods provided by GLFW, turns out they were faulty.
// 2022-11-22: Perform a dummy glfwGetError() read to cancel missing names with glfwGetKeyName(). (#5908) // 2022-11-22: Perform a dummy glfwGetError() read to cancel missing names with glfwGetKeyName(). (#5908)
// 2022-10-18: Perform a dummy glfwGetError() read to cancel missing mouse cursors errors. Using GLFW_VERSION_COMBINED directly. (#5785) // 2022-10-18: Perform a dummy glfwGetError() read to cancel missing mouse cursors errors. Using GLFW_VERSION_COMBINED directly. (#5785)
@ -120,11 +125,29 @@
// We gather version tests as define in order to easily see which features are version-dependent. // We gather version tests as define in order to easily see which features are version-dependent.
#define GLFW_VERSION_COMBINED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 + GLFW_VERSION_REVISION) #define GLFW_VERSION_COMBINED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 + GLFW_VERSION_REVISION)
#define GLFW_HAS_WINDOW_TOPMOST (GLFW_VERSION_COMBINED >= 3200) // 3.2+ GLFW_FLOATING
#define GLFW_HAS_WINDOW_HOVERED (GLFW_VERSION_COMBINED >= 3300) // 3.3+ GLFW_HOVERED
#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwSetWindowOpacity
#define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetMonitorContentScale
#if defined(__EMSCRIPTEN__) || defined(__SWITCH__) // no Vulkan support in GLFW for Emscripten or homebrew Nintendo Switch
#define GLFW_HAS_VULKAN (0)
#else
#define GLFW_HAS_VULKAN (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwCreateWindowSurface
#endif
#define GLFW_HAS_FOCUS_WINDOW (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwFocusWindow
#define GLFW_HAS_FOCUS_ON_SHOW (GLFW_VERSION_COMBINED >= 3300) // 3.3+ GLFW_FOCUS_ON_SHOW
#define GLFW_HAS_MONITOR_WORK_AREA (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetMonitorWorkarea
#define GLFW_HAS_OSX_WINDOW_POS_FIX (GLFW_VERSION_COMBINED >= 3301) // 3.3.1+ Fixed: Resizing window repositions it on MacOS #1553
#ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released? #ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_COMBINED >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR #define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_COMBINED >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
#else #else
#define GLFW_HAS_NEW_CURSORS (0) #define GLFW_HAS_NEW_CURSORS (0)
#endif #endif
#ifdef GLFW_MOUSE_PASSTHROUGH // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2020-07-17 (passthrough)
#define GLFW_HAS_MOUSE_PASSTHROUGH (GLFW_VERSION_COMBINED >= 3400) // 3.4+ GLFW_MOUSE_PASSTHROUGH
#else
#define GLFW_HAS_MOUSE_PASSTHROUGH (0)
#endif
#define GLFW_HAS_GAMEPAD_API (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetGamepadState() new api #define GLFW_HAS_GAMEPAD_API (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetGamepadState() new api
#define GLFW_HAS_GETKEYNAME (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwGetKeyName() #define GLFW_HAS_GETKEYNAME (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwGetKeyName()
#define GLFW_HAS_GETERROR (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetError() #define GLFW_HAS_GETERROR (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetError()
@ -145,8 +168,10 @@ struct ImGui_ImplGlfw_Data
GLFWwindow* MouseWindow; GLFWwindow* MouseWindow;
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT]; GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
ImVec2 LastValidMousePos; ImVec2 LastValidMousePos;
GLFWwindow* KeyOwnerWindows[GLFW_KEY_LAST];
bool InstalledCallbacks; bool InstalledCallbacks;
bool CallbacksChainForAllWindows; bool CallbacksChainForAllWindows;
bool WantUpdateMonitors;
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3 #ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
const char* CanvasSelector; const char* CanvasSelector;
#endif #endif
@ -179,6 +204,11 @@ static ImGui_ImplGlfw_Data* ImGui_ImplGlfw_GetBackendData()
return ImGui::GetCurrentContext() ? (ImGui_ImplGlfw_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr; return ImGui::GetCurrentContext() ? (ImGui_ImplGlfw_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
} }
// Forward Declarations
static void ImGui_ImplGlfw_UpdateMonitors();
static void ImGui_ImplGlfw_InitPlatformInterface();
static void ImGui_ImplGlfw_ShutdownPlatformInterface();
// Functions // Functions
static ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int key) static ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int key)
{ {
@ -394,6 +424,9 @@ void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int keycode, int scancode, i
ImGui_ImplGlfw_UpdateKeyModifiers(window); ImGui_ImplGlfw_UpdateKeyModifiers(window);
if (keycode >= 0 && keycode < IM_ARRAYSIZE(bd->KeyOwnerWindows))
bd->KeyOwnerWindows[keycode] = (action == GLFW_PRESS) ? window : nullptr;
keycode = ImGui_ImplGlfw_TranslateUntranslatedKey(keycode, scancode); keycode = ImGui_ImplGlfw_TranslateUntranslatedKey(keycode, scancode);
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
@ -419,6 +452,13 @@ void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y)
bd->PrevUserCallbackCursorPos(window, x, y); bd->PrevUserCallbackCursorPos(window, x, y);
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
int window_x, window_y;
glfwGetWindowPos(window, &window_x, &window_y);
x += window_x;
y += window_y;
}
io.AddMousePosEvent((float)x, (float)y); io.AddMousePosEvent((float)x, (float)y);
bd->LastValidMousePos = ImVec2((float)x, (float)y); bd->LastValidMousePos = ImVec2((float)x, (float)y);
} }
@ -457,7 +497,8 @@ void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int) void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int)
{ {
// Unused in 'master' branch but 'docking' branch will use this, so we declare it ahead of it so if you have to install callbacks you can install this one too. ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
bd->WantUpdateMonitors = true;
} }
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3 #ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
@ -479,32 +520,7 @@ static EM_BOOL ImGui_ImplEmscripten_WheelCallback(int, const EmscriptenWheelEven
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
// GLFW doesn't allow to distinguish Mouse vs TouchScreen vs Pen. static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
// Add support for Win32 (based on imgui_impl_win32), because we rely on _TouchScreen info to trickle inputs differently.
static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo()
{
LPARAM extra_info = ::GetMessageExtraInfo();
if ((extra_info & 0xFFFFFF80) == 0xFF515700)
return ImGuiMouseSource_Pen;
if ((extra_info & 0xFFFFFF80) == 0xFF515780)
return ImGuiMouseSource_TouchScreen;
return ImGuiMouseSource_Mouse;
}
static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
switch (msg)
{
case WM_MOUSEMOVE: case WM_NCMOUSEMOVE:
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: case WM_LBUTTONUP:
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: case WM_RBUTTONUP:
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: case WM_MBUTTONUP:
case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: case WM_XBUTTONUP:
ImGui::GetIO().AddMouseSourceEvent(GetMouseSourceFromMessageExtraInfo());
break;
}
return ::CallWindowProcW(bd->PrevWndProc, hWnd, msg, wParam, lParam);
}
#endif #endif
void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window) void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
@ -580,9 +596,16 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
io.BackendPlatformName = "imgui_impl_glfw"; io.BackendPlatformName = "imgui_impl_glfw";
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
#ifndef __EMSCRIPTEN__
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
#endif
#if GLFW_HAS_MOUSE_PASSTHROUGH || GLFW_HAS_WINDOW_HOVERED
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
#endif
bd->Window = window; bd->Window = window;
bd->Time = 0.0; bd->Time = 0.0;
bd->WantUpdateMonitors = true;
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_SetClipboardTextFn = [](ImGuiContext*, const char* text) { glfwSetClipboardString(NULL, text); }; platform_io.Platform_SetClipboardTextFn = [](ImGuiContext*, const char* text) { glfwSetClipboardString(NULL, text); };
@ -621,6 +644,10 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
if (install_callbacks) if (install_callbacks)
ImGui_ImplGlfw_InstallCallbacks(window); ImGui_ImplGlfw_InstallCallbacks(window);
// Update monitors the first time (note: monitor callback are broken in GLFW 3.2 and earlier, see github.com/glfw/glfw/issues/784)
ImGui_ImplGlfw_UpdateMonitors();
glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback);
// Set platform dependent data in viewport // Set platform dependent data in viewport
ImGuiViewport* main_viewport = ImGui::GetMainViewport(); ImGuiViewport* main_viewport = ImGui::GetMainViewport();
main_viewport->PlatformHandle = (void*)bd->Window; main_viewport->PlatformHandle = (void*)bd->Window;
@ -631,6 +658,8 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
#else #else
IM_UNUSED(main_viewport); IM_UNUSED(main_viewport);
#endif #endif
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplGlfw_InitPlatformInterface();
// Windows: register a WndProc hook so we can intercept some messages. // Windows: register a WndProc hook so we can intercept some messages.
#ifdef _WIN32 #ifdef _WIN32
@ -664,6 +693,8 @@ void ImGui_ImplGlfw_Shutdown()
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui_ImplGlfw_ShutdownPlatformInterface();
if (bd->InstalledCallbacks) if (bd->InstalledCallbacks)
ImGui_ImplGlfw_RestoreCallbacks(bd->Window); ImGui_ImplGlfw_RestoreCallbacks(bd->Window);
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3 #ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
@ -683,7 +714,7 @@ void ImGui_ImplGlfw_Shutdown()
io.BackendPlatformName = nullptr; io.BackendPlatformName = nullptr;
io.BackendPlatformUserData = nullptr; io.BackendPlatformUserData = nullptr;
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad); io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
IM_DELETE(bd); IM_DELETE(bd);
} }
@ -691,10 +722,15 @@ static void ImGui_ImplGlfw_UpdateMouseData()
{ {
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
// (those braces are here to reduce diff with multi-viewports support in 'docking' branch) ImGuiID mouse_viewport_id = 0;
const ImVec2 mouse_pos_prev = io.MousePos;
for (int n = 0; n < platform_io.Viewports.Size; n++)
{ {
GLFWwindow* window = bd->Window; ImGuiViewport* viewport = platform_io.Viewports[n];
GLFWwindow* window = (GLFWwindow*)viewport->PlatformHandle;
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3 #ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
const bool is_window_focused = true; const bool is_window_focused = true;
#else #else
@ -703,19 +739,54 @@ static void ImGui_ImplGlfw_UpdateMouseData()
if (is_window_focused) if (is_window_focused)
{ {
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user) // (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
// When multi-viewports are enabled, all Dear ImGui positions are same as OS positions.
if (io.WantSetMousePos) if (io.WantSetMousePos)
glfwSetCursorPos(window, (double)io.MousePos.x, (double)io.MousePos.y); glfwSetCursorPos(window, (double)(mouse_pos_prev.x - viewport->Pos.x), (double)(mouse_pos_prev.y - viewport->Pos.y));
// (Optional) Fallback to provide mouse position when focused (ImGui_ImplGlfw_CursorPosCallback already provides this when hovered or captured) // (Optional) Fallback to provide mouse position when focused (ImGui_ImplGlfw_CursorPosCallback already provides this when hovered or captured)
if (bd->MouseWindow == nullptr) if (bd->MouseWindow == nullptr)
{ {
double mouse_x, mouse_y; double mouse_x, mouse_y;
glfwGetCursorPos(window, &mouse_x, &mouse_y); glfwGetCursorPos(window, &mouse_x, &mouse_y);
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
// Single viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
// Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
int window_x, window_y;
glfwGetWindowPos(window, &window_x, &window_y);
mouse_x += window_x;
mouse_y += window_y;
}
bd->LastValidMousePos = ImVec2((float)mouse_x, (float)mouse_y); bd->LastValidMousePos = ImVec2((float)mouse_x, (float)mouse_y);
io.AddMousePosEvent((float)mouse_x, (float)mouse_y); io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
} }
} }
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
// - [X] GLFW >= 3.3 backend ON WINDOWS ONLY does correctly ignore viewports with the _NoInputs flag (since we implement hit via our WndProc hook)
// On other platforms we rely on the library fallbacking to its own search when reporting a viewport with _NoInputs flag.
// - [!] GLFW <= 3.2 backend CANNOT correctly ignore viewports with the _NoInputs flag, and CANNOT reported Hovered Viewport because of mouse capture.
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
// by the backend, and use its flawed heuristic to guess the viewport behind.
// - [X] GLFW backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
// FIXME: This is currently only correct on Win32. See what we do below with the WM_NCHITTEST, missing an equivalent for other systems.
// See https://github.com/glfw/glfw/issues/1236 if you want to help in making this a GLFW feature.
#if GLFW_HAS_MOUSE_PASSTHROUGH
const bool window_no_input = (viewport->Flags & ImGuiViewportFlags_NoInputs) != 0;
glfwSetWindowAttrib(window, GLFW_MOUSE_PASSTHROUGH, window_no_input);
#endif
#if GLFW_HAS_MOUSE_PASSTHROUGH || GLFW_HAS_WINDOW_HOVERED
if (glfwGetWindowAttrib(window, GLFW_HOVERED))
mouse_viewport_id = viewport->ID;
#else
// We cannot use bd->MouseWindow maintained from CursorEnter/Leave callbacks, because it is locked to the window capturing mouse.
#endif
} }
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
io.AddMouseViewportEvent(mouse_viewport_id);
} }
static void ImGui_ImplGlfw_UpdateMouseCursor() static void ImGui_ImplGlfw_UpdateMouseCursor()
@ -726,9 +797,10 @@ static void ImGui_ImplGlfw_UpdateMouseCursor()
return; return;
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
// (those braces are here to reduce diff with multi-viewports support in 'docking' branch) ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
for (int n = 0; n < platform_io.Viewports.Size; n++)
{ {
GLFWwindow* window = bd->Window; GLFWwindow* window = (GLFWwindow*)platform_io.Viewports[n]->PlatformHandle;
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor) if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
{ {
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
@ -797,6 +869,50 @@ static void ImGui_ImplGlfw_UpdateGamepads()
#undef MAP_ANALOG #undef MAP_ANALOG
} }
static void ImGui_ImplGlfw_UpdateMonitors()
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
bd->WantUpdateMonitors = false;
int monitors_count = 0;
GLFWmonitor** glfw_monitors = glfwGetMonitors(&monitors_count);
if (monitors_count == 0) // Preserve existing monitor list if there are none. Happens on macOS sleeping (#5683)
return;
platform_io.Monitors.resize(0);
for (int n = 0; n < monitors_count; n++)
{
ImGuiPlatformMonitor monitor;
int x, y;
glfwGetMonitorPos(glfw_monitors[n], &x, &y);
const GLFWvidmode* vid_mode = glfwGetVideoMode(glfw_monitors[n]);
if (vid_mode == nullptr)
continue; // Failed to get Video mode (e.g. Emscripten does not support this function)
monitor.MainPos = monitor.WorkPos = ImVec2((float)x, (float)y);
monitor.MainSize = monitor.WorkSize = ImVec2((float)vid_mode->width, (float)vid_mode->height);
#if GLFW_HAS_MONITOR_WORK_AREA
int w, h;
glfwGetMonitorWorkarea(glfw_monitors[n], &x, &y, &w, &h);
if (w > 0 && h > 0) // Workaround a small GLFW issue reporting zero on monitor changes: https://github.com/glfw/glfw/pull/1761
{
monitor.WorkPos = ImVec2((float)x, (float)y);
monitor.WorkSize = ImVec2((float)w, (float)h);
}
#endif
#if GLFW_HAS_PER_MONITOR_DPI
// Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.
float x_scale, y_scale;
glfwGetMonitorContentScale(glfw_monitors[n], &x_scale, &y_scale);
if (x_scale == 0.0f)
continue; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
monitor.DpiScale = x_scale;
#endif
monitor.PlatformHandle = (void*)glfw_monitors[n]; // [...] GLFW doc states: "guaranteed to be valid only until the monitor configuration changes"
platform_io.Monitors.push_back(monitor);
}
}
void ImGui_ImplGlfw_NewFrame() void ImGui_ImplGlfw_NewFrame()
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
@ -811,6 +927,8 @@ void ImGui_ImplGlfw_NewFrame()
io.DisplaySize = ImVec2((float)w, (float)h); io.DisplaySize = ImVec2((float)w, (float)h);
if (w > 0 && h > 0) if (w > 0 && h > 0)
io.DisplayFramebufferScale = ImVec2((float)display_w / (float)w, (float)display_h / (float)h); io.DisplayFramebufferScale = ImVec2((float)display_w / (float)w, (float)display_h / (float)h);
if (bd->WantUpdateMonitors)
ImGui_ImplGlfw_UpdateMonitors();
// Setup time step // Setup time step
// (Accept glfwGetTime() not returning a monotonically increasing value. Seems to happens on disconnecting peripherals and probably on VMs and Emscripten, see #6491, #6189, #6114, #3644) // (Accept glfwGetTime() not returning a monotonically increasing value. Seems to happens on disconnecting peripherals and probably on VMs and Emscripten, see #6491, #6189, #6114, #3644)
@ -889,6 +1007,399 @@ void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow* window, const char* c
} }
#endif // #ifdef EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 #endif // #ifdef EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
struct ImGui_ImplGlfw_ViewportData
{
GLFWwindow* Window;
bool WindowOwned;
int IgnoreWindowPosEventFrame;
int IgnoreWindowSizeEventFrame;
#ifdef _WIN32
WNDPROC PrevWndProc;
#endif
ImGui_ImplGlfw_ViewportData() { memset(this, 0, sizeof(*this)); IgnoreWindowSizeEventFrame = IgnoreWindowPosEventFrame = -1; }
~ImGui_ImplGlfw_ViewportData() { IM_ASSERT(Window == nullptr); }
};
static void ImGui_ImplGlfw_WindowCloseCallback(GLFWwindow* window)
{
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window))
viewport->PlatformRequestClose = true;
}
// GLFW may dispatch window pos/size events after calling glfwSetWindowPos()/glfwSetWindowSize().
// However: depending on the platform the callback may be invoked at different time:
// - on Windows it appears to be called within the glfwSetWindowPos()/glfwSetWindowSize() call
// - on Linux it is queued and invoked during glfwPollEvents()
// Because the event doesn't always fire on glfwSetWindowXXX() we use a frame counter tag to only
// ignore recent glfwSetWindowXXX() calls.
static void ImGui_ImplGlfw_WindowPosCallback(GLFWwindow* window, int, int)
{
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window))
{
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
{
bool ignore_event = (ImGui::GetFrameCount() <= vd->IgnoreWindowPosEventFrame + 1);
//data->IgnoreWindowPosEventFrame = -1;
if (ignore_event)
return;
}
viewport->PlatformRequestMove = true;
}
}
static void ImGui_ImplGlfw_WindowSizeCallback(GLFWwindow* window, int, int)
{
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window))
{
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
{
bool ignore_event = (ImGui::GetFrameCount() <= vd->IgnoreWindowSizeEventFrame + 1);
//data->IgnoreWindowSizeEventFrame = -1;
if (ignore_event)
return;
}
viewport->PlatformRequestResize = true;
}
}
static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGui_ImplGlfw_ViewportData* vd = IM_NEW(ImGui_ImplGlfw_ViewportData)();
viewport->PlatformUserData = vd;
// GLFW 3.2 unfortunately always set focus on glfwCreateWindow() if GLFW_VISIBLE is set, regardless of GLFW_FOCUSED
// With GLFW 3.3, the hint GLFW_FOCUS_ON_SHOW fixes this problem
glfwWindowHint(GLFW_VISIBLE, false);
glfwWindowHint(GLFW_FOCUSED, false);
#if GLFW_HAS_FOCUS_ON_SHOW
glfwWindowHint(GLFW_FOCUS_ON_SHOW, false);
#endif
glfwWindowHint(GLFW_DECORATED, (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? false : true);
#if GLFW_HAS_WINDOW_TOPMOST
glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false);
#endif
GLFWwindow* share_window = (bd->ClientApi == GlfwClientApi_OpenGL) ? bd->Window : nullptr;
vd->Window = glfwCreateWindow((int)viewport->Size.x, (int)viewport->Size.y, "No Title Yet", nullptr, share_window);
vd->WindowOwned = true;
viewport->PlatformHandle = (void*)vd->Window;
#ifdef _WIN32
viewport->PlatformHandleRaw = glfwGetWin32Window(vd->Window);
#elif defined(__APPLE__)
viewport->PlatformHandleRaw = (void*)glfwGetCocoaWindow(vd->Window);
#endif
glfwSetWindowPos(vd->Window, (int)viewport->Pos.x, (int)viewport->Pos.y);
// Install GLFW callbacks for secondary viewports
glfwSetWindowFocusCallback(vd->Window, ImGui_ImplGlfw_WindowFocusCallback);
glfwSetCursorEnterCallback(vd->Window, ImGui_ImplGlfw_CursorEnterCallback);
glfwSetCursorPosCallback(vd->Window, ImGui_ImplGlfw_CursorPosCallback);
glfwSetMouseButtonCallback(vd->Window, ImGui_ImplGlfw_MouseButtonCallback);
glfwSetScrollCallback(vd->Window, ImGui_ImplGlfw_ScrollCallback);
glfwSetKeyCallback(vd->Window, ImGui_ImplGlfw_KeyCallback);
glfwSetCharCallback(vd->Window, ImGui_ImplGlfw_CharCallback);
glfwSetWindowCloseCallback(vd->Window, ImGui_ImplGlfw_WindowCloseCallback);
glfwSetWindowPosCallback(vd->Window, ImGui_ImplGlfw_WindowPosCallback);
glfwSetWindowSizeCallback(vd->Window, ImGui_ImplGlfw_WindowSizeCallback);
if (bd->ClientApi == GlfwClientApi_OpenGL)
{
glfwMakeContextCurrent(vd->Window);
glfwSwapInterval(0);
}
}
static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
{
if (vd->WindowOwned)
{
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
::RemovePropA(hwnd, "IMGUI_VIEWPORT");
#endif
// Release any keys that were pressed in the window being destroyed and are still held down,
// because we will not receive any release events after window is destroyed.
for (int i = 0; i < IM_ARRAYSIZE(bd->KeyOwnerWindows); i++)
if (bd->KeyOwnerWindows[i] == vd->Window)
ImGui_ImplGlfw_KeyCallback(vd->Window, i, 0, GLFW_RELEASE, 0); // Later params are only used for main viewport, on which this function is never called.
glfwDestroyWindow(vd->Window);
}
vd->Window = nullptr;
IM_DELETE(vd);
}
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
}
static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport)
{
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
#if defined(_WIN32)
// GLFW hack: Hide icon from task bar
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
{
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
ex_style &= ~WS_EX_APPWINDOW;
ex_style |= WS_EX_TOOLWINDOW;
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
}
// GLFW hack: install hook for WM_NCHITTEST message handler
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
::SetPropA(hwnd, "IMGUI_VIEWPORT", viewport);
vd->PrevWndProc = (WNDPROC)::GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
::SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
#endif
#if !GLFW_HAS_FOCUS_ON_SHOW
// GLFW hack: GLFW 3.2 has a bug where glfwShowWindow() also activates/focus the window.
// The fix was pushed to GLFW repository on 2018/01/09 and should be included in GLFW 3.3 via a GLFW_FOCUS_ON_SHOW window attribute.
// See https://github.com/glfw/glfw/issues/1189
// FIXME-VIEWPORT: Implement same work-around for Linux/OSX in the meanwhile.
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
{
::ShowWindow(hwnd, SW_SHOWNA);
return;
}
#endif
#endif
glfwShowWindow(vd->Window);
}
static ImVec2 ImGui_ImplGlfw_GetWindowPos(ImGuiViewport* viewport)
{
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
int x = 0, y = 0;
glfwGetWindowPos(vd->Window, &x, &y);
return ImVec2((float)x, (float)y);
}
static void ImGui_ImplGlfw_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
{
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
vd->IgnoreWindowPosEventFrame = ImGui::GetFrameCount();
glfwSetWindowPos(vd->Window, (int)pos.x, (int)pos.y);
}
static ImVec2 ImGui_ImplGlfw_GetWindowSize(ImGuiViewport* viewport)
{
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
int w = 0, h = 0;
glfwGetWindowSize(vd->Window, &w, &h);
return ImVec2((float)w, (float)h);
}
static void ImGui_ImplGlfw_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
#if __APPLE__ && !GLFW_HAS_OSX_WINDOW_POS_FIX
// Native OS windows are positioned from the bottom-left corner on macOS, whereas on other platforms they are
// positioned from the upper-left corner. GLFW makes an effort to convert macOS style coordinates, however it
// doesn't handle it when changing size. We are manually moving the window in order for changes of size to be based
// on the upper-left corner.
int x, y, width, height;
glfwGetWindowPos(vd->Window, &x, &y);
glfwGetWindowSize(vd->Window, &width, &height);
glfwSetWindowPos(vd->Window, x, y - height + size.y);
#endif
vd->IgnoreWindowSizeEventFrame = ImGui::GetFrameCount();
glfwSetWindowSize(vd->Window, (int)size.x, (int)size.y);
}
static void ImGui_ImplGlfw_SetWindowTitle(ImGuiViewport* viewport, const char* title)
{
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
glfwSetWindowTitle(vd->Window, title);
}
static void ImGui_ImplGlfw_SetWindowFocus(ImGuiViewport* viewport)
{
#if GLFW_HAS_FOCUS_WINDOW
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
glfwFocusWindow(vd->Window);
#else
// FIXME: What are the effect of not having this function? At the moment imgui doesn't actually call SetWindowFocus - we set that up ahead, will answer that question later.
(void)viewport;
#endif
}
static bool ImGui_ImplGlfw_GetWindowFocus(ImGuiViewport* viewport)
{
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
return glfwGetWindowAttrib(vd->Window, GLFW_FOCUSED) != 0;
}
static bool ImGui_ImplGlfw_GetWindowMinimized(ImGuiViewport* viewport)
{
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
return glfwGetWindowAttrib(vd->Window, GLFW_ICONIFIED) != 0;
}
#if GLFW_HAS_WINDOW_ALPHA
static void ImGui_ImplGlfw_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
{
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
glfwSetWindowOpacity(vd->Window, alpha);
}
#endif
static void ImGui_ImplGlfw_RenderWindow(ImGuiViewport* viewport, void*)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
if (bd->ClientApi == GlfwClientApi_OpenGL)
glfwMakeContextCurrent(vd->Window);
}
static void ImGui_ImplGlfw_SwapBuffers(ImGuiViewport* viewport, void*)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
if (bd->ClientApi == GlfwClientApi_OpenGL)
{
glfwMakeContextCurrent(vd->Window);
glfwSwapBuffers(vd->Window);
}
}
//--------------------------------------------------------------------------------------------------------
// Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface)
//--------------------------------------------------------------------------------------------------------
// Avoid including <vulkan.h> so we can build without it
#if GLFW_HAS_VULKAN
#ifndef VULKAN_H_
#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
#else
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
#endif
VK_DEFINE_HANDLE(VkInstance)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
struct VkAllocationCallbacks;
enum VkResult { VK_RESULT_MAX_ENUM = 0x7FFFFFFF };
#endif // VULKAN_H_
extern "C" { extern GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); }
static int ImGui_ImplGlfw_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
IM_UNUSED(bd);
IM_ASSERT(bd->ClientApi == GlfwClientApi_Vulkan);
VkResult err = glfwCreateWindowSurface((VkInstance)vk_instance, vd->Window, (const VkAllocationCallbacks*)vk_allocator, (VkSurfaceKHR*)out_vk_surface);
return (int)err;
}
#endif // GLFW_HAS_VULKAN
static void ImGui_ImplGlfw_InitPlatformInterface()
{
// Register platform interface (will be coupled with a renderer interface)
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_CreateWindow = ImGui_ImplGlfw_CreateWindow;
platform_io.Platform_DestroyWindow = ImGui_ImplGlfw_DestroyWindow;
platform_io.Platform_ShowWindow = ImGui_ImplGlfw_ShowWindow;
platform_io.Platform_SetWindowPos = ImGui_ImplGlfw_SetWindowPos;
platform_io.Platform_GetWindowPos = ImGui_ImplGlfw_GetWindowPos;
platform_io.Platform_SetWindowSize = ImGui_ImplGlfw_SetWindowSize;
platform_io.Platform_GetWindowSize = ImGui_ImplGlfw_GetWindowSize;
platform_io.Platform_SetWindowFocus = ImGui_ImplGlfw_SetWindowFocus;
platform_io.Platform_GetWindowFocus = ImGui_ImplGlfw_GetWindowFocus;
platform_io.Platform_GetWindowMinimized = ImGui_ImplGlfw_GetWindowMinimized;
platform_io.Platform_SetWindowTitle = ImGui_ImplGlfw_SetWindowTitle;
platform_io.Platform_RenderWindow = ImGui_ImplGlfw_RenderWindow;
platform_io.Platform_SwapBuffers = ImGui_ImplGlfw_SwapBuffers;
#if GLFW_HAS_WINDOW_ALPHA
platform_io.Platform_SetWindowAlpha = ImGui_ImplGlfw_SetWindowAlpha;
#endif
#if GLFW_HAS_VULKAN
platform_io.Platform_CreateVkSurface = ImGui_ImplGlfw_CreateVkSurface;
#endif
// Register main window handle (which is owned by the main application, not by us)
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
ImGui_ImplGlfw_ViewportData* vd = IM_NEW(ImGui_ImplGlfw_ViewportData)();
vd->Window = bd->Window;
vd->WindowOwned = false;
main_viewport->PlatformUserData = vd;
main_viewport->PlatformHandle = (void*)bd->Window;
}
static void ImGui_ImplGlfw_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
//-----------------------------------------------------------------------------
// WndProc hook (declared here because we will need access to ImGui_ImplGlfw_ViewportData)
#ifdef _WIN32
static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo()
{
LPARAM extra_info = ::GetMessageExtraInfo();
if ((extra_info & 0xFFFFFF80) == 0xFF515700)
return ImGuiMouseSource_Pen;
if ((extra_info & 0xFFFFFF80) == 0xFF515780)
return ImGuiMouseSource_TouchScreen;
return ImGuiMouseSource_Mouse;
}
static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
WNDPROC prev_wndproc = bd->PrevWndProc;
ImGuiViewport* viewport = (ImGuiViewport*)::GetPropA(hWnd, "IMGUI_VIEWPORT");
if (viewport != NULL)
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
prev_wndproc = vd->PrevWndProc;
switch (msg)
{
// GLFW doesn't allow to distinguish Mouse vs TouchScreen vs Pen.
// Add support for Win32 (based on imgui_impl_win32), because we rely on _TouchScreen info to trickle inputs differently.
case WM_MOUSEMOVE: case WM_NCMOUSEMOVE:
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: case WM_LBUTTONUP:
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: case WM_RBUTTONUP:
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: case WM_MBUTTONUP:
case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: case WM_XBUTTONUP:
ImGui::GetIO().AddMouseSourceEvent(GetMouseSourceFromMessageExtraInfo());
break;
// We have submitted https://github.com/glfw/glfw/pull/1568 to allow GLFW to support "transparent inputs".
// In the meanwhile we implement custom per-platform workarounds here (FIXME-VIEWPORT: Implement same work-around for Linux/OSX!)
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED
case WM_NCHITTEST:
{
// Let mouse pass-through the window. This will allow the backend to call io.AddMouseViewportEvent() properly (which is OPTIONAL).
// The ImGuiViewportFlags_NoInputs flag is set while dragging a viewport, as want to detect the window behind the one we are dragging.
// If you cannot easily access those viewport flags from your windowing/event code: you may manually synchronize its state e.g. in
// your main loop after calling UpdatePlatformWindows(). Iterate all viewports/platform windows and pass the flag to your windowing system.
if (viewport && (viewport->Flags & ImGuiViewportFlags_NoInputs))
return HTTRANSPARENT;
break;
}
#endif
}
return ::CallWindowProcW(prev_wndproc, hWnd, msg, wParam, lParam);
}
#endif // #ifdef _WIN32
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if defined(__clang__) #if defined(__clang__)

View File

@ -1,6 +1,7 @@
// dear imgui: Platform Backend for GLFW // dear imgui: Platform Backend for GLFW
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..) // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
// (Requires: GLFW 3.1+. Prefer GLFW 3.3+ for full feature support.)
// Implemented features: // Implemented features:
// [X] Platform: Clipboard support. // [X] Platform: Clipboard support.
@ -8,6 +9,9 @@
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+). // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// Issues:
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -7,7 +7,7 @@
// Implemented features: // Implemented features:
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// Issues: // Missing features:
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I // [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
// [ ] Platform: Missing horizontal mouse wheel support. // [ ] Platform: Missing horizontal mouse wheel support.
// [ ] Platform: Missing mouse cursor shape/visibility support. // [ ] Platform: Missing mouse cursor shape/visibility support.

View File

@ -7,7 +7,7 @@
// Implemented features: // Implemented features:
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// Issues: // Missing features:
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I // [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
// [ ] Platform: Missing horizontal mouse wheel support. // [ ] Platform: Missing horizontal mouse wheel support.
// [ ] Platform: Missing mouse cursor shape/visibility support. // [ ] Platform: Missing mouse cursor shape/visibility support.

View File

@ -4,6 +4,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -4,6 +4,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -15,6 +16,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Metal: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2022-08-23: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'. // 2022-08-23: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'.
// 2022-07-05: Metal: Add dispatch synchronization. // 2022-07-05: Metal: Add dispatch synchronization.
// 2022-06-30: Metal: Use __bridge for ARC based systems. // 2022-06-30: Metal: Use __bridge for ARC based systems.
@ -38,6 +40,12 @@
#import <time.h> #import <time.h>
#import <Metal/Metal.h> #import <Metal/Metal.h>
// Forward Declarations
static void ImGui_ImplMetal_InitPlatformInterface();
static void ImGui_ImplMetal_ShutdownPlatformInterface();
static void ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows();
static void ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows();
#pragma mark - Support classes #pragma mark - Support classes
// A wrapper around a MTLBuffer object that knows the last time it was reused // A wrapper around a MTLBuffer object that knows the last time it was reused
@ -132,10 +140,14 @@ bool ImGui_ImplMetal_Init(id<MTLDevice> device)
io.BackendRendererUserData = (void*)bd; io.BackendRendererUserData = (void*)bd;
io.BackendRendererName = "imgui_impl_metal"; io.BackendRendererName = "imgui_impl_metal";
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
bd->SharedMetalContext = [[MetalContext alloc] init]; bd->SharedMetalContext = [[MetalContext alloc] init];
bd->SharedMetalContext.device = device; bd->SharedMetalContext.device = device;
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplMetal_InitPlatformInterface();
return true; return true;
} }
@ -143,13 +155,14 @@ void ImGui_ImplMetal_Shutdown()
{ {
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData(); ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
ImGui_ImplMetal_ShutdownPlatformInterface();
ImGui_ImplMetal_DestroyDeviceObjects(); ImGui_ImplMetal_DestroyDeviceObjects();
ImGui_ImplMetal_DestroyBackendData(); ImGui_ImplMetal_DestroyBackendData();
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
io.BackendRendererName = nullptr; io.BackendRendererName = nullptr;
io.BackendRendererUserData = nullptr; io.BackendRendererUserData = nullptr;
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset; io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
} }
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor) void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
@ -367,6 +380,7 @@ bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device)
depthStencilDescriptor.depthWriteEnabled = NO; depthStencilDescriptor.depthWriteEnabled = NO;
depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways; depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor]; bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows();
ImGui_ImplMetal_CreateFontsTexture(device); ImGui_ImplMetal_CreateFontsTexture(device);
return true; return true;
@ -376,9 +390,155 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
{ {
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData(); ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
ImGui_ImplMetal_DestroyFontsTexture(); ImGui_ImplMetal_DestroyFontsTexture();
ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows();
[bd->SharedMetalContext.renderPipelineStateCache removeAllObjects]; [bd->SharedMetalContext.renderPipelineStateCache removeAllObjects];
} }
#pragma mark - Multi-viewport support
#import <QuartzCore/CAMetalLayer.h>
#if TARGET_OS_OSX
#import <Cocoa/Cocoa.h>
#endif
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
struct ImGuiViewportDataMetal
{
CAMetalLayer* MetalLayer;
id<MTLCommandQueue> CommandQueue;
MTLRenderPassDescriptor* RenderPassDescriptor;
void* Handle = nullptr;
bool FirstFrame = true;
};
static void ImGui_ImplMetal_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
ImGuiViewportDataMetal* data = IM_NEW(ImGuiViewportDataMetal)();
viewport->RendererUserData = data;
// PlatformHandleRaw should always be a NSWindow*, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
// Some back-ends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the NSWindow*.
void* handle = viewport->PlatformHandleRaw ? viewport->PlatformHandleRaw : viewport->PlatformHandle;
IM_ASSERT(handle != nullptr);
id<MTLDevice> device = bd->SharedMetalContext.device;
CAMetalLayer* layer = [CAMetalLayer layer];
layer.device = device;
layer.framebufferOnly = YES;
layer.pixelFormat = bd->SharedMetalContext.framebufferDescriptor.colorPixelFormat;
#if TARGET_OS_OSX
NSWindow* window = (__bridge NSWindow*)handle;
NSView* view = window.contentView;
view.layer = layer;
view.wantsLayer = YES;
#endif
data->MetalLayer = layer;
data->CommandQueue = [device newCommandQueue];
data->RenderPassDescriptor = [[MTLRenderPassDescriptor alloc] init];
data->Handle = handle;
}
static void ImGui_ImplMetal_DestroyWindow(ImGuiViewport* viewport)
{
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
if (ImGuiViewportDataMetal* data = (ImGuiViewportDataMetal*)viewport->RendererUserData)
IM_DELETE(data);
viewport->RendererUserData = nullptr;
}
inline static CGSize MakeScaledSize(CGSize size, CGFloat scale)
{
return CGSizeMake(size.width * scale, size.height * scale);
}
static void ImGui_ImplMetal_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGuiViewportDataMetal* data = (ImGuiViewportDataMetal*)viewport->RendererUserData;
data->MetalLayer.drawableSize = MakeScaledSize(CGSizeMake(size.x, size.y), viewport->DpiScale);
}
static void ImGui_ImplMetal_RenderWindow(ImGuiViewport* viewport, void*)
{
ImGuiViewportDataMetal* data = (ImGuiViewportDataMetal*)viewport->RendererUserData;
#if TARGET_OS_OSX
void* handle = viewport->PlatformHandleRaw ? viewport->PlatformHandleRaw : viewport->PlatformHandle;
NSWindow* window = (__bridge NSWindow*)handle;
// Always render the first frame, regardless of occlusionState, to avoid an initial flicker
if ((window.occlusionState & NSWindowOcclusionStateVisible) == 0 && !data->FirstFrame)
{
// Do not render windows which are completely occluded. Calling -[CAMetalLayer nextDrawable] will hang for
// approximately 1 second if the Metal layer is completely occluded.
return;
}
data->FirstFrame = false;
viewport->DpiScale = (float)window.backingScaleFactor;
if (data->MetalLayer.contentsScale != viewport->DpiScale)
{
data->MetalLayer.contentsScale = viewport->DpiScale;
data->MetalLayer.drawableSize = MakeScaledSize(window.frame.size, viewport->DpiScale);
}
viewport->DrawData->FramebufferScale = ImVec2(viewport->DpiScale, viewport->DpiScale);
#endif
id <CAMetalDrawable> drawable = [data->MetalLayer nextDrawable];
if (drawable == nil)
return;
MTLRenderPassDescriptor* renderPassDescriptor = data->RenderPassDescriptor;
renderPassDescriptor.colorAttachments[0].texture = drawable.texture;
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(0, 0, 0, 0);
if ((viewport->Flags & ImGuiViewportFlags_NoRendererClear) == 0)
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
id <MTLCommandBuffer> commandBuffer = [data->CommandQueue commandBuffer];
id <MTLRenderCommandEncoder> renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
ImGui_ImplMetal_RenderDrawData(viewport->DrawData, commandBuffer, renderEncoder);
[renderEncoder endEncoding];
[commandBuffer presentDrawable:drawable];
[commandBuffer commit];
}
static void ImGui_ImplMetal_InitPlatformInterface()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Renderer_CreateWindow = ImGui_ImplMetal_CreateWindow;
platform_io.Renderer_DestroyWindow = ImGui_ImplMetal_DestroyWindow;
platform_io.Renderer_SetWindowSize = ImGui_ImplMetal_SetWindowSize;
platform_io.Renderer_RenderWindow = ImGui_ImplMetal_RenderWindow;
}
static void ImGui_ImplMetal_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
static void ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
for (int i = 1; i < platform_io.Viewports.Size; i++)
if (!platform_io.Viewports[i]->RendererUserData)
ImGui_ImplMetal_CreateWindow(platform_io.Viewports[i]);
}
static void ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
for (int i = 1; i < platform_io.Viewports.Size; i++)
if (platform_io.Viewports[i]->RendererUserData)
ImGui_ImplMetal_DestroyWindow(platform_io.Viewports[i]);
}
#pragma mark - MetalBuffer implementation #pragma mark - MetalBuffer implementation
@implementation MetalBuffer @implementation MetalBuffer

View File

@ -3,6 +3,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -22,6 +23,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-06-28: OpenGL: ImGui_ImplOpenGL2_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL2_DestroyFontsTexture(). (#7748) // 2024-06-28: OpenGL: ImGui_ImplOpenGL2_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL2_DestroyFontsTexture(). (#7748)
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11. // 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
// 2021-12-08: OpenGL: Fixed mishandling of the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86. // 2021-12-08: OpenGL: Fixed mishandling of the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
@ -80,6 +82,10 @@ static ImGui_ImplOpenGL2_Data* ImGui_ImplOpenGL2_GetBackendData()
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL2_Data*)ImGui::GetIO().BackendRendererUserData : nullptr; return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL2_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
} }
// Forward Declarations
static void ImGui_ImplOpenGL2_InitPlatformInterface();
static void ImGui_ImplOpenGL2_ShutdownPlatformInterface();
// Functions // Functions
bool ImGui_ImplOpenGL2_Init() bool ImGui_ImplOpenGL2_Init()
{ {
@ -91,6 +97,10 @@ bool ImGui_ImplOpenGL2_Init()
ImGui_ImplOpenGL2_Data* bd = IM_NEW(ImGui_ImplOpenGL2_Data)(); ImGui_ImplOpenGL2_Data* bd = IM_NEW(ImGui_ImplOpenGL2_Data)();
io.BackendRendererUserData = (void*)bd; io.BackendRendererUserData = (void*)bd;
io.BackendRendererName = "imgui_impl_opengl2"; io.BackendRendererName = "imgui_impl_opengl2";
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplOpenGL2_InitPlatformInterface();
return true; return true;
} }
@ -101,9 +111,11 @@ void ImGui_ImplOpenGL2_Shutdown()
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui_ImplOpenGL2_ShutdownPlatformInterface();
ImGui_ImplOpenGL2_DestroyDeviceObjects(); ImGui_ImplOpenGL2_DestroyDeviceObjects();
io.BackendRendererName = nullptr; io.BackendRendererName = nullptr;
io.BackendRendererUserData = nullptr; io.BackendRendererUserData = nullptr;
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasViewports;
IM_DELETE(bd); IM_DELETE(bd);
} }
@ -297,6 +309,35 @@ void ImGui_ImplOpenGL2_DestroyDeviceObjects()
ImGui_ImplOpenGL2_DestroyFontsTexture(); ImGui_ImplOpenGL2_DestroyFontsTexture();
} }
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
static void ImGui_ImplOpenGL2_RenderWindow(ImGuiViewport* viewport, void*)
{
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
{
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);
}
ImGui_ImplOpenGL2_RenderDrawData(viewport->DrawData);
}
static void ImGui_ImplOpenGL2_InitPlatformInterface()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL2_RenderWindow;
}
static void ImGui_ImplOpenGL2_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if defined(__clang__) #if defined(__clang__)

View File

@ -3,6 +3,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -5,7 +5,8 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
// [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only). // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// About WebGL/ES: // About WebGL/ES:
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES. // - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
@ -22,6 +23,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-06-28: OpenGL: ImGui_ImplOpenGL3_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL3_DestroyFontsTexture(). (#7748) // 2024-06-28: OpenGL: ImGui_ImplOpenGL3_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL3_DestroyFontsTexture(). (#7748)
// 2024-05-07: OpenGL: Update loader for Linux to support EGL/GLVND. (#7562) // 2024-05-07: OpenGL: Update loader for Linux to support EGL/GLVND. (#7562)
// 2024-04-16: OpenGL: Detect ES3 contexts on desktop based on version string, to e.g. avoid calling glPolygonMode() on them. (#7447) // 2024-04-16: OpenGL: Detect ES3 contexts on desktop based on version string, to e.g. avoid calling glPolygonMode() on them. (#7447)
@ -249,6 +251,10 @@ static ImGui_ImplOpenGL3_Data* ImGui_ImplOpenGL3_GetBackendData()
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr; return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
} }
// Forward Declarations
static void ImGui_ImplOpenGL3_InitPlatformInterface();
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface();
// OpenGL vertex attribute state (for ES 1.0 and ES 2.0 only) // OpenGL vertex attribute state (for ES 1.0 and ES 2.0 only)
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY #ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
struct ImGui_ImplOpenGL3_VtxAttribState struct ImGui_ImplOpenGL3_VtxAttribState
@ -341,6 +347,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
if (bd->GlVersion >= 320) if (bd->GlVersion >= 320)
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
#endif #endif
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
// Store GLSL version string so we can refer to it later in case we recreate shaders. // Store GLSL version string so we can refer to it later in case we recreate shaders.
// Note: GLSL version is NOT the same as GL version. Leave this to nullptr if unsure. // Note: GLSL version is NOT the same as GL version. Leave this to nullptr if unsure.
@ -381,6 +388,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
} }
#endif #endif
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplOpenGL3_InitPlatformInterface();
return true; return true;
} }
@ -390,10 +400,11 @@ void ImGui_ImplOpenGL3_Shutdown()
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui_ImplOpenGL3_ShutdownPlatformInterface();
ImGui_ImplOpenGL3_DestroyDeviceObjects(); ImGui_ImplOpenGL3_DestroyDeviceObjects();
io.BackendRendererName = nullptr; io.BackendRendererName = nullptr;
io.BackendRendererUserData = nullptr; io.BackendRendererUserData = nullptr;
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset; io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
IM_DELETE(bd); IM_DELETE(bd);
} }
@ -949,6 +960,34 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects()
ImGui_ImplOpenGL3_DestroyFontsTexture(); ImGui_ImplOpenGL3_DestroyFontsTexture();
} }
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
static void ImGui_ImplOpenGL3_RenderWindow(ImGuiViewport* viewport, void*)
{
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
{
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);
}
ImGui_ImplOpenGL3_RenderDrawData(viewport->DrawData);
}
static void ImGui_ImplOpenGL3_InitPlatformInterface()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL3_RenderWindow;
}
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if defined(__GNUC__) #if defined(__GNUC__)

View File

@ -5,7 +5,8 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
// [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only). // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// About WebGL/ES: // About WebGL/ES:
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES. // - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.

View File

@ -10,6 +10,10 @@
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend). // [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: IME support. // [X] Platform: IME support.
// [x] Platform: Multi-viewport / platform windows.
// Issues:
// [ ] Platform: Multi-viewport: Window size not correctly reported when enabling io.ConfigViewportsNoDecoration
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -10,6 +10,10 @@
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend). // [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: IME support. // [X] Platform: IME support.
// [x] Platform: Multi-viewport / platform windows.
// Issues:
// [ ] Platform: Multi-viewport: Window size not correctly reported when enabling io.ConfigViewportsNoDecoration
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -29,6 +33,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO: // 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn // - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn // - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
@ -96,6 +101,9 @@ static void ImGui_ImplOSX_DestroyBackendData() { IM_DELETE(
static inline CFTimeInterval GetMachAbsoluteTimeInSeconds() { return (CFTimeInterval)(double)(clock_gettime_nsec_np(CLOCK_UPTIME_RAW) / 1e9); } static inline CFTimeInterval GetMachAbsoluteTimeInSeconds() { return (CFTimeInterval)(double)(clock_gettime_nsec_np(CLOCK_UPTIME_RAW) / 1e9); }
// Forward Declarations // Forward Declarations
static void ImGui_ImplOSX_InitPlatformInterface();
static void ImGui_ImplOSX_ShutdownPlatformInterface();
static void ImGui_ImplOSX_UpdateMonitors();
static void ImGui_ImplOSX_AddTrackingArea(NSView* _Nonnull view); static void ImGui_ImplOSX_AddTrackingArea(NSView* _Nonnull view);
static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view); static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
@ -142,9 +150,25 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
NSWindow* window = view.window; NSWindow* window = view.window;
if (!window) if (!window)
return; return;
NSRect contentRect = [window contentRectForFrameRect:window.frame];
NSRect rect = NSMakeRect(_posX, contentRect.size.height - _posY, 0, 0); ImGuiIO& io = ImGui::GetIO();
_imeRect = [window convertRectToScreen:rect]; if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
NSRect frame = window.frame;
NSRect contentRect = window.contentLayoutRect;
if (window.styleMask & NSWindowStyleMaskFullSizeContentView) // No title bar windows should be considered.
contentRect = frame;
NSRect firstScreenFrame = NSScreen.screens[0].frame;
_imeRect = NSMakeRect(_posX, _posY, 0, 0);
_imeRect.origin.y = firstScreenFrame.size.height - _imeRect.size.height - _imeRect.origin.y; // Opposite of ConvertNSRect()
}
else
{
NSRect contentRect = [window contentRectForFrameRect:window.frame];
NSRect rect = NSMakeRect(_posX, contentRect.size.height - _posY, 0, 0);
_imeRect = [window convertRectToScreen:rect];
}
} }
- (void)viewDidMoveToWindow - (void)viewDidMoveToWindow
@ -239,6 +263,7 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
- (void)onApplicationBecomeActive:(NSNotification*)aNotification; - (void)onApplicationBecomeActive:(NSNotification*)aNotification;
- (void)onApplicationBecomeInactive:(NSNotification*)aNotification; - (void)onApplicationBecomeInactive:(NSNotification*)aNotification;
- (void)displaysDidChange:(NSNotification*)aNotification;
@end @end
@ -256,6 +281,11 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
io.AddFocusEvent(false); io.AddFocusEvent(false);
} }
- (void)displaysDidChange:(NSNotification*)aNotification
{
ImGui_ImplOSX_UpdateMonitors();
}
@end @end
// Functions // Functions
@ -407,11 +437,16 @@ bool ImGui_ImplOSX_Init(NSView* view)
io.BackendPlatformName = "imgui_impl_osx"; io.BackendPlatformName = "imgui_impl_osx";
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
//io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) //io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
//io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
bd->Observer = [ImGuiObserver new]; bd->Observer = [ImGuiObserver new];
bd->Window = view.window ?: NSApp.orderedWindows.firstObject; bd->Window = view.window ?: NSApp.orderedWindows.firstObject;
ImGuiViewport* main_viewport = ImGui::GetMainViewport(); ImGuiViewport* main_viewport = ImGui::GetMainViewport();
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (__bridge_retained void*)bd->Window; main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (__bridge_retained void*)bd->Window;
ImGui_ImplOSX_UpdateMonitors();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplOSX_InitPlatformInterface();
// Load cursors. Some of them are undocumented. // Load cursors. Some of them are undocumented.
bd->MouseCursorHidden = false; bd->MouseCursorHidden = false;
@ -501,12 +536,12 @@ void ImGui_ImplOSX_Shutdown()
bd->Monitor = nullptr; bd->Monitor = nullptr;
} }
ImGui_ImplOSX_ShutdownPlatformInterface();
ImGui_ImplOSX_DestroyBackendData(); ImGui_ImplOSX_DestroyBackendData();
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
io.BackendPlatformName = nullptr; io.BackendPlatformName = nullptr;
io.BackendPlatformUserData = nullptr; io.BackendPlatformUserData = nullptr;
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasGamepad); io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports);
} }
static void ImGui_ImplOSX_UpdateMouseCursor() static void ImGui_ImplOSX_UpdateMouseCursor()
@ -683,14 +718,23 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
if (event.type == NSEventTypeMouseMoved || event.type == NSEventTypeLeftMouseDragged || event.type == NSEventTypeRightMouseDragged || event.type == NSEventTypeOtherMouseDragged) if (event.type == NSEventTypeMouseMoved || event.type == NSEventTypeLeftMouseDragged || event.type == NSEventTypeRightMouseDragged || event.type == NSEventTypeOtherMouseDragged)
{ {
NSPoint mousePoint = event.locationInWindow; NSPoint mousePoint;
if (event.window == nil) if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
mousePoint = [[view window] convertPointFromScreen:mousePoint]; {
mousePoint = [view convertPoint:mousePoint fromView:nil]; mousePoint = NSEvent.mouseLocation;
if ([view isFlipped]) mousePoint.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - mousePoint.y; // Normalize y coordinate to top-left of main display.
mousePoint = NSMakePoint(mousePoint.x, mousePoint.y); }
else else
mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y); {
mousePoint = event.locationInWindow;
if (event.window == nil)
mousePoint = [[view window] convertPointFromScreen:mousePoint];
mousePoint = [view convertPoint:mousePoint fromView:nil]; // Convert to local coordinates of view
if ([view isFlipped])
mousePoint = NSMakePoint(mousePoint.x, mousePoint.y);
else
mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y);
}
io.AddMouseSourceEvent(GetMouseSource(event)); io.AddMouseSourceEvent(GetMouseSource(event));
io.AddMousePosEvent((float)mousePoint.x, (float)mousePoint.y); io.AddMousePosEvent((float)mousePoint.x, (float)mousePoint.y);
return io.WantCaptureMouse; return io.WantCaptureMouse;
@ -818,6 +862,294 @@ static void ImGui_ImplOSX_AddTrackingArea(NSView* _Nonnull view)
}]; }];
} }
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
struct ImGuiViewportDataOSX
{
NSWindow* Window;
bool WindowOwned;
ImGuiViewportDataOSX() { WindowOwned = false; }
~ImGuiViewportDataOSX() { IM_ASSERT(Window == nil); }
};
@interface ImGui_ImplOSX_Window: NSWindow
@end
@implementation ImGui_ImplOSX_Window
- (BOOL)canBecomeKeyWindow
{
return YES;
}
@end
static void ConvertNSRect(NSRect* r)
{
NSRect firstScreenFrame = NSScreen.screens[0].frame;
IM_ASSERT(firstScreenFrame.origin.x == 0 && firstScreenFrame.origin.y == 0);
r->origin.y = firstScreenFrame.size.height - r->origin.y - r->size.height;
}
static void ImGui_ImplOSX_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
ImGuiViewportDataOSX* data = IM_NEW(ImGuiViewportDataOSX)();
viewport->PlatformUserData = data;
NSScreen* screen = bd->Window.screen;
NSRect rect = NSMakeRect(viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y);
ConvertNSRect(&rect);
NSWindowStyleMask styleMask = 0;
if (viewport->Flags & ImGuiViewportFlags_NoDecoration)
styleMask |= NSWindowStyleMaskBorderless;
else
styleMask |= NSWindowStyleMaskTitled | NSWindowStyleMaskResizable | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable;
NSWindow* window = [[ImGui_ImplOSX_Window alloc] initWithContentRect:rect
styleMask:styleMask
backing:NSBackingStoreBuffered
defer:YES
screen:screen];
if (viewport->Flags & ImGuiViewportFlags_TopMost)
[window setLevel:NSFloatingWindowLevel];
window.title = @"Untitled";
window.opaque = YES;
KeyEventResponder* view = [[KeyEventResponder alloc] initWithFrame:rect];
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6 && ceil(NSAppKitVersionNumber) < NSAppKitVersionNumber10_15)
[view setWantsBestResolutionOpenGLSurface:YES];
window.contentView = view;
data->Window = window;
data->WindowOwned = true;
viewport->PlatformRequestResize = false;
viewport->PlatformHandle = viewport->PlatformHandleRaw = (__bridge_retained void*)window;
}
static void ImGui_ImplOSX_DestroyWindow(ImGuiViewport* viewport)
{
NSWindow* window = (__bridge_transfer NSWindow*)viewport->PlatformHandleRaw;
window = nil;
if (ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData)
{
NSWindow* window = data->Window;
if (window != nil && data->WindowOwned)
{
window.contentView = nil;
window.contentViewController = nil;
[window orderOut:nil];
}
data->Window = nil;
IM_DELETE(data);
}
viewport->PlatformUserData = viewport->PlatformHandle = viewport->PlatformHandleRaw = nullptr;
}
static void ImGui_ImplOSX_ShowWindow(ImGuiViewport* viewport)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
[data->Window orderFront:nil];
else
[data->Window makeKeyAndOrderFront:nil];
[data->Window setIsVisible:YES];
}
static ImVec2 ImGui_ImplOSX_GetWindowPos(ImGuiViewport* viewport)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
NSWindow* window = data->Window;
NSRect frame = window.frame;
NSRect contentRect = window.contentLayoutRect;
if (window.styleMask & NSWindowStyleMaskFullSizeContentView) // No title bar windows should be considered.
contentRect = frame;
NSRect firstScreenFrame = NSScreen.screens[0].frame;
return ImVec2(frame.origin.x, firstScreenFrame.size.height - frame.origin.y - contentRect.size.height);
}
static void ImGui_ImplOSX_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
NSWindow* window = data->Window;
NSSize size = window.frame.size;
NSRect r = NSMakeRect(pos.x, pos.y, size.width, size.height);
ConvertNSRect(&r);
[window setFrameOrigin:r.origin];
}
static ImVec2 ImGui_ImplOSX_GetWindowSize(ImGuiViewport* viewport)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
NSWindow* window = data->Window;
NSSize size = window.contentLayoutRect.size;
return ImVec2(size.width, size.height);
}
static void ImGui_ImplOSX_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
NSWindow* window = data->Window;
NSRect rect = window.frame;
rect.origin.y -= (size.y - rect.size.height);
rect.size.width = size.x;
rect.size.height = size.y;
[window setFrame:rect display:YES];
}
static void ImGui_ImplOSX_SetWindowFocus(ImGuiViewport* viewport)
{
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
[data->Window makeKeyAndOrderFront:bd->Window];
}
static bool ImGui_ImplOSX_GetWindowFocus(ImGuiViewport* viewport)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
return data->Window.isKeyWindow;
}
static bool ImGui_ImplOSX_GetWindowMinimized(ImGuiViewport* viewport)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
return data->Window.isMiniaturized;
}
static void ImGui_ImplOSX_SetWindowTitle(ImGuiViewport* viewport, const char* title)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
data->Window.title = [NSString stringWithUTF8String:title];
}
static void ImGui_ImplOSX_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
IM_ASSERT(alpha >= 0.0f && alpha <= 1.0f);
data->Window.alphaValue = alpha;
}
static float ImGui_ImplOSX_GetWindowDpiScale(ImGuiViewport* viewport)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);
return data->Window.backingScaleFactor;
}
static void ImGui_ImplOSX_UpdateMonitors()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Monitors.resize(0);
NSRect firstScreenFrame = NSScreen.screens[0].frame;
IM_ASSERT(firstScreenFrame.origin.x == 0 && firstScreenFrame.origin.y == 0);
for (NSScreen* screen in NSScreen.screens)
{
NSRect frame = screen.frame;
NSRect visibleFrame = screen.visibleFrame;
ConvertNSRect(&frame);
ConvertNSRect(&visibleFrame);
ImGuiPlatformMonitor imgui_monitor;
imgui_monitor.MainPos = ImVec2(frame.origin.x, frame.origin.y);
imgui_monitor.MainSize = ImVec2(frame.size.width, frame.size.height);
imgui_monitor.WorkPos = ImVec2(visibleFrame.origin.x, visibleFrame.origin.y);
imgui_monitor.WorkSize = ImVec2(visibleFrame.size.width, visibleFrame.size.height);
imgui_monitor.DpiScale = screen.backingScaleFactor;
imgui_monitor.PlatformHandle = (__bridge_retained void*)screen;
platform_io.Monitors.push_back(imgui_monitor);
}
}
static void ImGui_ImplOSX_InitPlatformInterface()
{
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
// Register platform interface (will be coupled with a renderer interface)
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_CreateWindow = ImGui_ImplOSX_CreateWindow;
platform_io.Platform_DestroyWindow = ImGui_ImplOSX_DestroyWindow;
platform_io.Platform_ShowWindow = ImGui_ImplOSX_ShowWindow;
platform_io.Platform_SetWindowPos = ImGui_ImplOSX_SetWindowPos;
platform_io.Platform_GetWindowPos = ImGui_ImplOSX_GetWindowPos;
platform_io.Platform_SetWindowSize = ImGui_ImplOSX_SetWindowSize;
platform_io.Platform_GetWindowSize = ImGui_ImplOSX_GetWindowSize;
platform_io.Platform_SetWindowFocus = ImGui_ImplOSX_SetWindowFocus;
platform_io.Platform_GetWindowFocus = ImGui_ImplOSX_GetWindowFocus;
platform_io.Platform_GetWindowMinimized = ImGui_ImplOSX_GetWindowMinimized;
platform_io.Platform_SetWindowTitle = ImGui_ImplOSX_SetWindowTitle;
platform_io.Platform_SetWindowAlpha = ImGui_ImplOSX_SetWindowAlpha;
platform_io.Platform_GetWindowDpiScale = ImGui_ImplOSX_GetWindowDpiScale; // FIXME-DPI
// Register main window handle (which is owned by the main application, not by us)
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
ImGuiViewportDataOSX* data = IM_NEW(ImGuiViewportDataOSX)();
data->Window = bd->Window;
data->WindowOwned = false;
main_viewport->PlatformUserData = data;
main_viewport->PlatformHandle = (__bridge void*)bd->Window;
[NSNotificationCenter.defaultCenter addObserver:bd->Observer
selector:@selector(displaysDidChange:)
name:NSApplicationDidChangeScreenParametersNotification
object:nil];
}
static void ImGui_ImplOSX_ShutdownPlatformInterface()
{
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
[NSNotificationCenter.defaultCenter removeObserver:bd->Observer
name:NSApplicationDidChangeScreenParametersNotification
object:nil];
bd->Observer = nullptr;
bd->Window = nullptr;
if (bd->Monitor != nullptr)
{
[NSEvent removeMonitor:bd->Monitor];
bd->Monitor = nullptr;
}
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)main_viewport->PlatformUserData;
IM_DELETE(data);
main_viewport->PlatformUserData = nullptr;
ImGui::DestroyPlatformWindows();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif // #ifndef IMGUI_DISABLE #endif // #ifndef IMGUI_DISABLE

View File

@ -9,7 +9,11 @@
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [X] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!. // [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// Issues:
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// [x] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -21,6 +25,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO: // 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn // - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn // - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
@ -56,7 +61,7 @@
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range. // 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
// 2021-08-17: Calling io.AddFocusEvent() on SDL_WINDOWEVENT_FOCUS_GAINED/SDL_WINDOWEVENT_FOCUS_LOST. // 2021-08-17: Calling io.AddFocusEvent() on SDL_WINDOWEVENT_FOCUS_GAINED/SDL_WINDOWEVENT_FOCUS_LOST.
// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, requires SDL 2.0.5+) // 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, requires SDL 2.0.5+)
// 2021-06-29: *BREAKING CHANGE* Removed 'SDL_Window* window' parameter to ImGui_ImplSDL2_NewFrame() which was unnecessary. // 2021-06:29: *BREAKING CHANGE* Removed 'SDL_Window* window' parameter to ImGui_ImplSDL2_NewFrame() which was unnecessary.
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). // 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
// 2021-03-22: Rework global mouse pos availability check listing supported platforms explicitly, effectively fixing mouse access on Raspberry Pi. (#2837, #3950) // 2021-03-22: Rework global mouse pos availability check listing supported platforms explicitly, effectively fixing mouse access on Raspberry Pi. (#2837, #3950)
// 2020-05-25: Misc: Report a zero display-size when window is minimized, to be consistent with other backends. // 2020-05-25: Misc: Report a zero display-size when window is minimized, to be consistent with other backends.
@ -97,6 +102,7 @@
#endif #endif
// SDL // SDL
// (the multi-viewports feature requires SDL features supported from SDL 2.0.4+. SDL 2.0.5+ is highly recommended)
#include <SDL.h> #include <SDL.h>
#include <SDL_syswm.h> #include <SDL_syswm.h>
#ifdef __APPLE__ #ifdef __APPLE__
@ -111,7 +117,16 @@
#else #else
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0 #define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
#endif #endif
#define SDL_HAS_WINDOW_ALPHA SDL_VERSION_ATLEAST(2,0,5)
#define SDL_HAS_ALWAYS_ON_TOP SDL_VERSION_ATLEAST(2,0,5)
#define SDL_HAS_USABLE_DISPLAY_BOUNDS SDL_VERSION_ATLEAST(2,0,5)
#define SDL_HAS_PER_MONITOR_DPI SDL_VERSION_ATLEAST(2,0,4)
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6) #define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
#define SDL_HAS_DISPLAY_EVENT SDL_VERSION_ATLEAST(2,0,9)
#define SDL_HAS_SHOW_WINDOW_ACTIVATION_HINT SDL_VERSION_ATLEAST(2,0,18)
#if !SDL_HAS_VULKAN
static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
#endif
// SDL Data // SDL Data
struct ImGui_ImplSDL2_Data struct ImGui_ImplSDL2_Data
@ -121,6 +136,8 @@ struct ImGui_ImplSDL2_Data
SDL_Renderer* Renderer; SDL_Renderer* Renderer;
Uint64 Time; Uint64 Time;
char* ClipboardTextData; char* ClipboardTextData;
bool UseVulkan;
bool WantUpdateMonitors;
// Mouse handling // Mouse handling
Uint32 MouseWindowID; Uint32 MouseWindowID;
@ -129,6 +146,7 @@ struct ImGui_ImplSDL2_Data
SDL_Cursor* MouseLastCursor; SDL_Cursor* MouseLastCursor;
int MouseLastLeaveFrame; int MouseLastLeaveFrame;
bool MouseCanUseGlobalState; bool MouseCanUseGlobalState;
bool MouseCanReportHoveredViewport; // This is hard to use/unreliable on SDL so we'll set ImGuiBackendFlags_HasMouseHoveredViewport dynamically based on state.
// Gamepad handling // Gamepad handling
ImVector<SDL_GameController*> Gamepads; ImVector<SDL_GameController*> Gamepads;
@ -147,6 +165,11 @@ static ImGui_ImplSDL2_Data* ImGui_ImplSDL2_GetBackendData()
return ImGui::GetCurrentContext() ? (ImGui_ImplSDL2_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr; return ImGui::GetCurrentContext() ? (ImGui_ImplSDL2_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
} }
// Forward Declarations
static void ImGui_ImplSDL2_UpdateMonitors();
static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context);
static void ImGui_ImplSDL2_ShutdownPlatformInterface();
// Functions // Functions
static const char* ImGui_ImplSDL2_GetClipboardText(ImGuiContext*) static const char* ImGui_ImplSDL2_GetClipboardText(ImGuiContext*)
{ {
@ -163,13 +186,13 @@ static void ImGui_ImplSDL2_SetClipboardText(ImGuiContext*, const char* text)
} }
// Note: native IME will only display if user calls SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1") _before_ SDL_CreateWindow(). // Note: native IME will only display if user calls SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1") _before_ SDL_CreateWindow().
static void ImGui_ImplSDL2_PlatformSetImeData(ImGuiContext*, ImGuiViewport*, ImGuiPlatformImeData* data) static void ImGui_ImplSDL2_PlatformSetImeData(ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data)
{ {
if (data->WantVisible) if (data->WantVisible)
{ {
SDL_Rect r; SDL_Rect r;
r.x = (int)data->InputPos.x; r.x = (int)(data->InputPos.x - viewport->Pos.x);
r.y = (int)data->InputPos.y; r.y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight);
r.w = 1; r.w = 1;
r.h = (int)data->InputLineHeight; r.h = (int)data->InputLineHeight;
SDL_SetTextInputRect(&r); SDL_SetTextInputRect(&r);
@ -316,15 +339,13 @@ static void ImGui_ImplSDL2_UpdateKeyModifiers(SDL_Keymod sdl_key_mods)
static ImGuiViewport* ImGui_ImplSDL2_GetViewportForWindowID(Uint32 window_id) static ImGuiViewport* ImGui_ImplSDL2_GetViewportForWindowID(Uint32 window_id)
{ {
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); return ImGui::FindViewportByPlatformHandle((void*)(intptr_t)window_id);
return (window_id == bd->WindowID) ? ImGui::GetMainViewport() : NULL;
} }
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data. // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data. // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event) bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
{ {
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
@ -338,6 +359,13 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
if (ImGui_ImplSDL2_GetViewportForWindowID(event->motion.windowID) == NULL) if (ImGui_ImplSDL2_GetViewportForWindowID(event->motion.windowID) == NULL)
return false; return false;
ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y); ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y);
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
int window_x, window_y;
SDL_GetWindowPosition(SDL_GetWindowFromID(event->motion.windowID), &window_x, &window_y);
mouse_pos.x += window_x;
mouse_pos.y += window_y;
}
io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse); io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
io.AddMousePosEvent(mouse_pos.x, mouse_pos.y); io.AddMousePosEvent(mouse_pos.x, mouse_pos.y);
return true; return true;
@ -397,10 +425,21 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions. io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
return true; return true;
} }
#if SDL_HAS_DISPLAY_EVENT
case SDL_DISPLAYEVENT:
{
// 2.0.26 has SDL_DISPLAYEVENT_CONNECTED/SDL_DISPLAYEVENT_DISCONNECTED/SDL_DISPLAYEVENT_ORIENTATION,
// so change of DPI/Scaling are not reflected in this event. (SDL3 has it)
bd->WantUpdateMonitors = true;
return true;
}
#endif
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
{ {
if (ImGui_ImplSDL2_GetViewportForWindowID(event->window.windowID) == NULL) ImGuiViewport* viewport = ImGui_ImplSDL2_GetViewportForWindowID(event->window.windowID);
if (viewport == NULL)
return false; return false;
// - When capturing mouse, SDL will send a bunch of conflicting LEAVE/ENTER event on every mouse move, but the final ENTER tends to be right. // - When capturing mouse, SDL will send a bunch of conflicting LEAVE/ENTER event on every mouse move, but the final ENTER tends to be right.
// - However we won't get a correct LEAVE event for a captured window. // - However we won't get a correct LEAVE event for a captured window.
// - In some cases, when detaching a window from main viewport SDL may send SDL_WINDOWEVENT_ENTER one frame too late, // - In some cases, when detaching a window from main viewport SDL may send SDL_WINDOWEVENT_ENTER one frame too late,
@ -416,8 +455,14 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
bd->MouseLastLeaveFrame = ImGui::GetFrameCount() + 1; bd->MouseLastLeaveFrame = ImGui::GetFrameCount() + 1;
if (window_event == SDL_WINDOWEVENT_FOCUS_GAINED) if (window_event == SDL_WINDOWEVENT_FOCUS_GAINED)
io.AddFocusEvent(true); io.AddFocusEvent(true);
else if (event->window.event == SDL_WINDOWEVENT_FOCUS_LOST) else if (window_event == SDL_WINDOWEVENT_FOCUS_LOST)
io.AddFocusEvent(false); io.AddFocusEvent(false);
else if (window_event == SDL_WINDOWEVENT_CLOSE)
viewport->PlatformRequestClose = true;
else if (window_event == SDL_WINDOWEVENT_MOVED)
viewport->PlatformRequestMove = true;
else if (window_event == SDL_WINDOWEVENT_RESIZED)
viewport->PlatformRequestResize = true;
return true; return true;
} }
case SDL_CONTROLLERDEVICEADDED: case SDL_CONTROLLERDEVICEADDED:
@ -455,13 +500,24 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)(); ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)();
io.BackendPlatformUserData = (void*)bd; io.BackendPlatformUserData = (void*)bd;
io.BackendPlatformName = "imgui_impl_sdl2"; io.BackendPlatformName = "imgui_impl_sdl2";
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
if (mouse_can_use_global_state)
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
bd->Window = window; bd->Window = window;
bd->WindowID = SDL_GetWindowID(window); bd->WindowID = SDL_GetWindowID(window);
bd->Renderer = renderer; bd->Renderer = renderer;
// SDL on Linux/OSX doesn't report events for unfocused windows (see https://github.com/ocornut/imgui/issues/4960)
// We will use 'MouseCanReportHoveredViewport' to set 'ImGuiBackendFlags_HasMouseHoveredViewport' dynamically each frame.
bd->MouseCanUseGlobalState = mouse_can_use_global_state; bd->MouseCanUseGlobalState = mouse_can_use_global_state;
#ifndef __APPLE__
bd->MouseCanReportHoveredViewport = bd->MouseCanUseGlobalState;
#else
bd->MouseCanReportHoveredViewport = false;
#endif
bd->WantUpdateMonitors = true;
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText; platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
@ -524,7 +580,11 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0"); SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
#endif #endif
(void)sdl_gl_context; // Unused in 'master' branch. // We need SDL_CaptureMouse(), SDL_GetGlobalMouseState() from SDL 2.0.4+ to support multiple viewports.
// We left the call to ImGui_ImplSDL2_InitPlatformInterface() outside of #ifdef to avoid unused-function warnings.
if ((io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) && (io.BackendFlags & ImGuiBackendFlags_PlatformHasViewports))
ImGui_ImplSDL2_InitPlatformInterface(window, sdl_gl_context);
return true; return true;
} }
@ -538,7 +598,11 @@ bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
#if !SDL_HAS_VULKAN #if !SDL_HAS_VULKAN
IM_ASSERT(0 && "Unsupported"); IM_ASSERT(0 && "Unsupported");
#endif #endif
return ImGui_ImplSDL2_Init(window, nullptr, nullptr); if (!ImGui_ImplSDL2_Init(window, nullptr, nullptr))
return false;
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
bd->UseVulkan = true;
return true;
} }
bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window) bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
@ -572,6 +636,8 @@ void ImGui_ImplSDL2_Shutdown()
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui_ImplSDL2_ShutdownPlatformInterface();
if (bd->ClipboardTextData) if (bd->ClipboardTextData)
SDL_free(bd->ClipboardTextData); SDL_free(bd->ClipboardTextData);
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++) for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
@ -580,10 +646,11 @@ void ImGui_ImplSDL2_Shutdown()
io.BackendPlatformName = nullptr; io.BackendPlatformName = nullptr;
io.BackendPlatformUserData = nullptr; io.BackendPlatformUserData = nullptr;
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad); io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
IM_DELETE(bd); IM_DELETE(bd);
} }
// This code is incredibly messy because some of the functions we need for full viewport support are not available in SDL < 2.0.4.
static void ImGui_ImplSDL2_UpdateMouseData() static void ImGui_ImplSDL2_UpdateMouseData()
{ {
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
@ -594,25 +661,56 @@ static void ImGui_ImplSDL2_UpdateMouseData()
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE); SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
SDL_Window* focused_window = SDL_GetKeyboardFocus(); SDL_Window* focused_window = SDL_GetKeyboardFocus();
const bool is_app_focused = (bd->Window == focused_window); const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui_ImplSDL2_GetViewportForWindowID(SDL_GetWindowID(focused_window)) != NULL));
#else #else
SDL_Window* focused_window = bd->Window;
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
#endif #endif
if (is_app_focused) if (is_app_focused)
{ {
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user) // (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
if (io.WantSetMousePos) if (io.WantSetMousePos)
SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y); {
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
SDL_WarpMouseGlobal((int)io.MousePos.x, (int)io.MousePos.y);
else
#endif
SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y);
}
// (Optional) Fallback to provide mouse position when focused (SDL_MOUSEMOTION already provides this when hovered or captured) // (Optional) Fallback to provide mouse position when focused (SDL_MOUSEMOTION already provides this when hovered or captured)
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0) if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
{ {
int window_x, window_y, mouse_x_global, mouse_y_global; // Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
SDL_GetGlobalMouseState(&mouse_x_global, &mouse_y_global); // Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
SDL_GetWindowPosition(bd->Window, &window_x, &window_y); int mouse_x, mouse_y, window_x, window_y;
io.AddMousePosEvent((float)(mouse_x_global - window_x), (float)(mouse_y_global - window_y)); SDL_GetGlobalMouseState(&mouse_x, &mouse_y);
if (!(io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
{
SDL_GetWindowPosition(focused_window, &window_x, &window_y);
mouse_x -= window_x;
mouse_y -= window_y;
}
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
} }
} }
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
// - [!] SDL backend does NOT correctly ignore viewports with the _NoInputs flag.
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
// by the backend, and use its flawed heuristic to guess the viewport behind.
// - [X] SDL backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
{
ImGuiID mouse_viewport_id = 0;
if (ImGuiViewport* mouse_viewport = ImGui_ImplSDL2_GetViewportForWindowID(bd->MouseWindowID))
mouse_viewport_id = mouse_viewport->ID;
io.AddMouseViewportEvent(mouse_viewport_id);
}
} }
static void ImGui_ImplSDL2_UpdateMouseCursor() static void ImGui_ImplSDL2_UpdateMouseCursor()
@ -746,6 +844,43 @@ static void ImGui_ImplSDL2_UpdateGamepads()
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767); ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767);
} }
// FIXME: Note that doesn't update with DPI/Scaling change only as SDL2 doesn't have an event for it (SDL3 has).
static void ImGui_ImplSDL2_UpdateMonitors()
{
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Monitors.resize(0);
bd->WantUpdateMonitors = false;
int display_count = SDL_GetNumVideoDisplays();
for (int n = 0; n < display_count; n++)
{
// Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.
ImGuiPlatformMonitor monitor;
SDL_Rect r;
SDL_GetDisplayBounds(n, &r);
monitor.MainPos = monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
monitor.MainSize = monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
#if SDL_HAS_USABLE_DISPLAY_BOUNDS
SDL_GetDisplayUsableBounds(n, &r);
monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
#endif
#if SDL_HAS_PER_MONITOR_DPI
// FIXME-VIEWPORT: On MacOS SDL reports actual monitor DPI scale, ignoring OS configuration. We may want to set
// DpiScale to cocoa_window.backingScaleFactor here.
float dpi = 0.0f;
if (!SDL_GetDisplayDPI(n, &dpi, nullptr, nullptr))
{
if (dpi <= 0.0f)
continue; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
monitor.DpiScale = dpi / 96.0f;
}
#endif
monitor.PlatformHandle = (void*)(intptr_t)n;
platform_io.Monitors.push_back(monitor);
}
}
void ImGui_ImplSDL2_NewFrame() void ImGui_ImplSDL2_NewFrame()
{ {
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
@ -766,6 +901,10 @@ void ImGui_ImplSDL2_NewFrame()
if (w > 0 && h > 0) if (w > 0 && h > 0)
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h); io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
// Update monitors
if (bd->WantUpdateMonitors)
ImGui_ImplSDL2_UpdateMonitors();
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution) // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644) // (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
static Uint64 frequency = SDL_GetPerformanceFrequency(); static Uint64 frequency = SDL_GetPerformanceFrequency();
@ -782,6 +921,13 @@ void ImGui_ImplSDL2_NewFrame()
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX); io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
} }
// Our io.AddMouseViewportEvent() calls will only be valid when not capturing.
// Technically speaking testing for 'bd->MouseButtonsDown == 0' would be more rigorous, but testing for payload reduces noise and potential side-effects.
if (bd->MouseCanReportHoveredViewport && ImGui::GetDragDropPayload() == nullptr)
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport;
else
io.BackendFlags &= ~ImGuiBackendFlags_HasMouseHoveredViewport;
ImGui_ImplSDL2_UpdateMouseData(); ImGui_ImplSDL2_UpdateMouseData();
ImGui_ImplSDL2_UpdateMouseCursor(); ImGui_ImplSDL2_UpdateMouseCursor();
@ -789,6 +935,256 @@ void ImGui_ImplSDL2_NewFrame()
ImGui_ImplSDL2_UpdateGamepads(); ImGui_ImplSDL2_UpdateGamepads();
} }
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
struct ImGui_ImplSDL2_ViewportData
{
SDL_Window* Window;
Uint32 WindowID;
bool WindowOwned;
SDL_GLContext GLContext;
ImGui_ImplSDL2_ViewportData() { Window = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
~ImGui_ImplSDL2_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
};
static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
ImGui_ImplSDL2_ViewportData* vd = IM_NEW(ImGui_ImplSDL2_ViewportData)();
viewport->PlatformUserData = vd;
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
ImGui_ImplSDL2_ViewportData* main_viewport_data = (ImGui_ImplSDL2_ViewportData*)main_viewport->PlatformUserData;
// Share GL resources with main context
bool use_opengl = (main_viewport_data->GLContext != nullptr);
SDL_GLContext backup_context = nullptr;
if (use_opengl)
{
backup_context = SDL_GL_GetCurrentContext();
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
SDL_GL_MakeCurrent(main_viewport_data->Window, main_viewport_data->GLContext);
}
Uint32 sdl_flags = 0;
sdl_flags |= use_opengl ? SDL_WINDOW_OPENGL : (bd->UseVulkan ? SDL_WINDOW_VULKAN : 0);
sdl_flags |= SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_ALLOW_HIGHDPI;
sdl_flags |= SDL_WINDOW_HIDDEN;
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0;
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
#if !defined(_WIN32)
// See SDL hack in ImGui_ImplSDL2_ShowWindow().
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_SKIP_TASKBAR : 0;
#endif
#if SDL_HAS_ALWAYS_ON_TOP
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
#endif
vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Pos.x, (int)viewport->Pos.y, (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);
vd->WindowOwned = true;
if (use_opengl)
{
vd->GLContext = SDL_GL_CreateContext(vd->Window);
SDL_GL_SetSwapInterval(0);
}
if (use_opengl && backup_context)
SDL_GL_MakeCurrent(vd->Window, backup_context);
viewport->PlatformHandle = (void*)(intptr_t)SDL_GetWindowID(vd->Window);
viewport->PlatformHandleRaw = nullptr;
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWindowWMInfo(vd->Window, &info))
{
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
viewport->PlatformHandleRaw = info.info.win.window;
#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
viewport->PlatformHandleRaw = (void*)info.info.cocoa.window;
#endif
}
}
static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)
{
if (ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData)
{
if (vd->GLContext && vd->WindowOwned)
SDL_GL_DeleteContext(vd->GLContext);
if (vd->Window && vd->WindowOwned)
SDL_DestroyWindow(vd->Window);
vd->GLContext = nullptr;
vd->Window = nullptr;
IM_DELETE(vd);
}
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
}
static void ImGui_ImplSDL2_ShowWindow(ImGuiViewport* viewport)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
#if defined(_WIN32)
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
// SDL hack: Hide icon from task bar
// Note: SDL 2.0.6+ has a SDL_WINDOW_SKIP_TASKBAR flag which is supported under Windows but the way it create the window breaks our seamless transition.
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
{
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
ex_style &= ~WS_EX_APPWINDOW;
ex_style |= WS_EX_TOOLWINDOW;
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
}
#endif
#if SDL_HAS_SHOW_WINDOW_ACTIVATION_HINT
SDL_SetHint(SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN, (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing) ? "1" : "0");
#elif defined(_WIN32)
// SDL hack: SDL always activate/focus windows :/
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
{
::ShowWindow(hwnd, SW_SHOWNA);
return;
}
#endif
SDL_ShowWindow(vd->Window);
}
static ImVec2 ImGui_ImplSDL2_GetWindowPos(ImGuiViewport* viewport)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
int x = 0, y = 0;
SDL_GetWindowPosition(vd->Window, &x, &y);
return ImVec2((float)x, (float)y);
}
static void ImGui_ImplSDL2_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
SDL_SetWindowPosition(vd->Window, (int)pos.x, (int)pos.y);
}
static ImVec2 ImGui_ImplSDL2_GetWindowSize(ImGuiViewport* viewport)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
int w = 0, h = 0;
SDL_GetWindowSize(vd->Window, &w, &h);
return ImVec2((float)w, (float)h);
}
static void ImGui_ImplSDL2_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
SDL_SetWindowSize(vd->Window, (int)size.x, (int)size.y);
}
static void ImGui_ImplSDL2_SetWindowTitle(ImGuiViewport* viewport, const char* title)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
SDL_SetWindowTitle(vd->Window, title);
}
#if SDL_HAS_WINDOW_ALPHA
static void ImGui_ImplSDL2_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
SDL_SetWindowOpacity(vd->Window, alpha);
}
#endif
static void ImGui_ImplSDL2_SetWindowFocus(ImGuiViewport* viewport)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
SDL_RaiseWindow(vd->Window);
}
static bool ImGui_ImplSDL2_GetWindowFocus(ImGuiViewport* viewport)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0;
}
static bool ImGui_ImplSDL2_GetWindowMinimized(ImGuiViewport* viewport)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_MINIMIZED) != 0;
}
static void ImGui_ImplSDL2_RenderWindow(ImGuiViewport* viewport, void*)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
if (vd->GLContext)
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
}
static void ImGui_ImplSDL2_SwapBuffers(ImGuiViewport* viewport, void*)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
if (vd->GLContext)
{
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
SDL_GL_SwapWindow(vd->Window);
}
}
// Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface)
// SDL is graceful enough to _not_ need <vulkan/vulkan.h> so we can safely include this.
#if SDL_HAS_VULKAN
#include <SDL_vulkan.h>
static int ImGui_ImplSDL2_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
{
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
(void)vk_allocator;
SDL_bool ret = SDL_Vulkan_CreateSurface(vd->Window, (VkInstance)vk_instance, (VkSurfaceKHR*)out_vk_surface);
return ret ? 0 : 1; // ret ? VK_SUCCESS : VK_NOT_READY
}
#endif // SDL_HAS_VULKAN
static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context)
{
// Register platform interface (will be coupled with a renderer interface)
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_CreateWindow = ImGui_ImplSDL2_CreateWindow;
platform_io.Platform_DestroyWindow = ImGui_ImplSDL2_DestroyWindow;
platform_io.Platform_ShowWindow = ImGui_ImplSDL2_ShowWindow;
platform_io.Platform_SetWindowPos = ImGui_ImplSDL2_SetWindowPos;
platform_io.Platform_GetWindowPos = ImGui_ImplSDL2_GetWindowPos;
platform_io.Platform_SetWindowSize = ImGui_ImplSDL2_SetWindowSize;
platform_io.Platform_GetWindowSize = ImGui_ImplSDL2_GetWindowSize;
platform_io.Platform_SetWindowFocus = ImGui_ImplSDL2_SetWindowFocus;
platform_io.Platform_GetWindowFocus = ImGui_ImplSDL2_GetWindowFocus;
platform_io.Platform_GetWindowMinimized = ImGui_ImplSDL2_GetWindowMinimized;
platform_io.Platform_SetWindowTitle = ImGui_ImplSDL2_SetWindowTitle;
platform_io.Platform_RenderWindow = ImGui_ImplSDL2_RenderWindow;
platform_io.Platform_SwapBuffers = ImGui_ImplSDL2_SwapBuffers;
#if SDL_HAS_WINDOW_ALPHA
platform_io.Platform_SetWindowAlpha = ImGui_ImplSDL2_SetWindowAlpha;
#endif
#if SDL_HAS_VULKAN
platform_io.Platform_CreateVkSurface = ImGui_ImplSDL2_CreateVkSurface;
#endif
// Register main window handle (which is owned by the main application, not by us)
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
ImGui_ImplSDL2_ViewportData* vd = IM_NEW(ImGui_ImplSDL2_ViewportData)();
vd->Window = window;
vd->WindowID = SDL_GetWindowID(window);
vd->WindowOwned = false;
vd->GLContext = sdl_gl_context;
main_viewport->PlatformUserData = vd;
main_viewport->PlatformHandle = (void*)(intptr_t)vd->WindowID;
}
static void ImGui_ImplSDL2_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if defined(__clang__) #if defined(__clang__)

View File

@ -8,7 +8,11 @@
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [X] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!. // [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// Issues:
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// [x] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -10,6 +10,10 @@
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [x] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable' -> the OS animation effect when window gets created/destroyed is problematic. SDL2 backend doesn't have issue.
// Issues:
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -21,6 +25,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-09-03: Update for SDL3 api changes: SDL_GetGamepads() memory ownership revert. (#7918, #7898, #7807) // 2024-09-03: Update for SDL3 api changes: SDL_GetGamepads() memory ownership revert. (#7918, #7898, #7807)
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO: // 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn // - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
@ -91,6 +96,8 @@ struct ImGui_ImplSDL3_Data
SDL_Renderer* Renderer; SDL_Renderer* Renderer;
Uint64 Time; Uint64 Time;
char* ClipboardTextData; char* ClipboardTextData;
bool UseVulkan;
bool WantUpdateMonitors;
// IME handling // IME handling
SDL_Window* ImeWindow; SDL_Window* ImeWindow;
@ -102,11 +109,12 @@ struct ImGui_ImplSDL3_Data
SDL_Cursor* MouseLastCursor; SDL_Cursor* MouseLastCursor;
int MousePendingLeaveFrame; int MousePendingLeaveFrame;
bool MouseCanUseGlobalState; bool MouseCanUseGlobalState;
bool MouseCanReportHoveredViewport; // This is hard to use/unreliable on SDL so we'll set ImGuiBackendFlags_HasMouseHoveredViewport dynamically based on state.
// Gamepad handling // Gamepad handling
ImVector<SDL_Gamepad*> Gamepads; ImVector<SDL_Gamepad*> Gamepads;
ImGui_ImplSDL3_GamepadMode GamepadMode; ImGui_ImplSDL3_GamepadMode GamepadMode;
bool WantUpdateGamepadsList; bool WantUpdateGamepadsList;
ImGui_ImplSDL3_Data() { memset((void*)this, 0, sizeof(*this)); } ImGui_ImplSDL3_Data() { memset((void*)this, 0, sizeof(*this)); }
}; };
@ -120,6 +128,11 @@ static ImGui_ImplSDL3_Data* ImGui_ImplSDL3_GetBackendData()
return ImGui::GetCurrentContext() ? (ImGui_ImplSDL3_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr; return ImGui::GetCurrentContext() ? (ImGui_ImplSDL3_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
} }
// Forward Declarations
static void ImGui_ImplSDL3_UpdateMonitors();
static void ImGui_ImplSDL3_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context);
static void ImGui_ImplSDL3_ShutdownPlatformInterface();
// Functions // Functions
static const char* ImGui_ImplSDL3_GetClipboardText(ImGuiContext*) static const char* ImGui_ImplSDL3_GetClipboardText(ImGuiContext*)
{ {
@ -149,8 +162,8 @@ static void ImGui_ImplSDL3_PlatformSetImeData(ImGuiContext*, ImGuiViewport* view
if (data->WantVisible) if (data->WantVisible)
{ {
SDL_Rect r; SDL_Rect r;
r.x = (int)data->InputPos.x; r.x = (int)(data->InputPos.x - viewport->Pos.x);
r.y = (int)data->InputPos.y; r.y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight);
r.w = 1; r.w = 1;
r.h = (int)data->InputLineHeight; r.h = (int)data->InputLineHeight;
SDL_SetTextInputArea(window, &r, 0); SDL_SetTextInputArea(window, &r, 0);
@ -301,18 +314,15 @@ static void ImGui_ImplSDL3_UpdateKeyModifiers(SDL_Keymod sdl_key_mods)
io.AddKeyEvent(ImGuiMod_Super, (sdl_key_mods & SDL_KMOD_GUI) != 0); io.AddKeyEvent(ImGuiMod_Super, (sdl_key_mods & SDL_KMOD_GUI) != 0);
} }
static ImGuiViewport* ImGui_ImplSDL3_GetViewportForWindowID(SDL_WindowID window_id) static ImGuiViewport* ImGui_ImplSDL3_GetViewportForWindowID(SDL_WindowID window_id)
{ {
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData(); return ImGui::FindViewportByPlatformHandle((void*)(intptr_t)window_id);
return (window_id == bd->WindowID) ? ImGui::GetMainViewport() : NULL;
} }
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data. // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data. // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event) bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
{ {
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData(); ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
@ -326,6 +336,13 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
if (ImGui_ImplSDL3_GetViewportForWindowID(event->motion.windowID) == NULL) if (ImGui_ImplSDL3_GetViewportForWindowID(event->motion.windowID) == NULL)
return false; return false;
ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y); ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y);
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
int window_x, window_y;
SDL_GetWindowPosition(SDL_GetWindowFromID(event->motion.windowID), &window_x, &window_y);
mouse_pos.x += window_x;
mouse_pos.y += window_y;
}
io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse); io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
io.AddMousePosEvent(mouse_pos.x, mouse_pos.y); io.AddMousePosEvent(mouse_pos.x, mouse_pos.y);
return true; return true;
@ -381,6 +398,15 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
io.SetKeyEventNativeData(key, event->key.key, event->key.scancode, event->key.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions. io.SetKeyEventNativeData(key, event->key.key, event->key.scancode, event->key.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
return true; return true;
} }
case SDL_EVENT_DISPLAY_ORIENTATION:
case SDL_EVENT_DISPLAY_ADDED:
case SDL_EVENT_DISPLAY_REMOVED:
case SDL_EVENT_DISPLAY_MOVED:
case SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED:
{
bd->WantUpdateMonitors = true;
return true;
}
case SDL_EVENT_WINDOW_MOUSE_ENTER: case SDL_EVENT_WINDOW_MOUSE_ENTER:
{ {
if (ImGui_ImplSDL3_GetViewportForWindowID(event->window.windowID) == NULL) if (ImGui_ImplSDL3_GetViewportForWindowID(event->window.windowID) == NULL)
@ -408,6 +434,21 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
io.AddFocusEvent(event->type == SDL_EVENT_WINDOW_FOCUS_GAINED); io.AddFocusEvent(event->type == SDL_EVENT_WINDOW_FOCUS_GAINED);
return true; return true;
} }
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
case SDL_EVENT_WINDOW_MOVED:
case SDL_EVENT_WINDOW_RESIZED:
{
ImGuiViewport* viewport = ImGui_ImplSDL3_GetViewportForWindowID(event->window.windowID);
if (viewport == NULL)
return false;
if (event->type == SDL_EVENT_WINDOW_CLOSE_REQUESTED)
viewport->PlatformRequestClose = true;
if (event->type == SDL_EVENT_WINDOW_MOVED)
viewport->PlatformRequestMove = true;
if (event->type == SDL_EVENT_WINDOW_RESIZED)
viewport->PlatformRequestResize = true;
return true;
}
case SDL_EVENT_GAMEPAD_ADDED: case SDL_EVENT_GAMEPAD_ADDED:
case SDL_EVENT_GAMEPAD_REMOVED: case SDL_EVENT_GAMEPAD_REMOVED:
{ {
@ -453,11 +494,22 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
io.BackendPlatformName = "imgui_impl_sdl3"; io.BackendPlatformName = "imgui_impl_sdl3";
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
if (mouse_can_use_global_state)
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
bd->Window = window; bd->Window = window;
bd->WindowID = SDL_GetWindowID(window); bd->WindowID = SDL_GetWindowID(window);
bd->Renderer = renderer; bd->Renderer = renderer;
// SDL on Linux/OSX doesn't report events for unfocused windows (see https://github.com/ocornut/imgui/issues/4960)
// We will use 'MouseCanReportHoveredViewport' to set 'ImGuiBackendFlags_HasMouseHoveredViewport' dynamically each frame.
bd->MouseCanUseGlobalState = mouse_can_use_global_state; bd->MouseCanUseGlobalState = mouse_can_use_global_state;
#ifndef __APPLE__
bd->MouseCanReportHoveredViewport = bd->MouseCanUseGlobalState;
#else
bd->MouseCanReportHoveredViewport = false;
#endif
bd->WantUpdateMonitors = true;
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText; platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
@ -489,27 +541,35 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
// (This is unfortunately a global SDL setting, so enabling it might have a side-effect on your application. // (This is unfortunately a global SDL setting, so enabling it might have a side-effect on your application.
// It is unlikely to make a difference, but if your app absolutely needs to ignore the initial on-focus click: // It is unlikely to make a difference, but if your app absolutely needs to ignore the initial on-focus click:
// you can ignore SDL_EVENT_MOUSE_BUTTON_DOWN events coming right after a SDL_WINDOWEVENT_FOCUS_GAINED) // you can ignore SDL_EVENT_MOUSE_BUTTON_DOWN events coming right after a SDL_WINDOWEVENT_FOCUS_GAINED)
#ifdef SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
#endif
// From 2.0.22: Disable auto-capture, this is preventing drag and drop across multiple windows (see #5710) // From 2.0.22: Disable auto-capture, this is preventing drag and drop across multiple windows (see #5710)
#ifdef SDL_HINT_MOUSE_AUTO_CAPTURE
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0"); SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
#endif
// SDL 3.x : see https://github.com/libsdl-org/SDL/issues/6659
SDL_SetHint("SDL_BORDERLESS_WINDOWED_STYLE", "0");
// We need SDL_CaptureMouse(), SDL_GetGlobalMouseState() from SDL 2.0.4+ to support multiple viewports.
// We left the call to ImGui_ImplSDL3_InitPlatformInterface() outside of #ifdef to avoid unused-function warnings.
if ((io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) && (io.BackendFlags & ImGuiBackendFlags_PlatformHasViewports))
ImGui_ImplSDL3_InitPlatformInterface(window, sdl_gl_context);
return true; return true;
} }
// Should technically be a SDL_GLContext but due to typedef it is sane to keep it void* in public interface.
bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context) bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
{ {
IM_UNUSED(sdl_gl_context); // Viewport branch will need this.
return ImGui_ImplSDL3_Init(window, nullptr, sdl_gl_context); return ImGui_ImplSDL3_Init(window, nullptr, sdl_gl_context);
} }
bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window) bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window)
{ {
return ImGui_ImplSDL3_Init(window, nullptr, nullptr); if (!ImGui_ImplSDL3_Init(window, nullptr, nullptr))
return false;
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
bd->UseVulkan = true;
return true;
} }
bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window) bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window)
@ -543,6 +603,8 @@ void ImGui_ImplSDL3_Shutdown()
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui_ImplSDL3_ShutdownPlatformInterface();
if (bd->ClipboardTextData) if (bd->ClipboardTextData)
SDL_free(bd->ClipboardTextData); SDL_free(bd->ClipboardTextData);
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++) for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
@ -551,10 +613,11 @@ void ImGui_ImplSDL3_Shutdown()
io.BackendPlatformName = nullptr; io.BackendPlatformName = nullptr;
io.BackendPlatformUserData = nullptr; io.BackendPlatformUserData = nullptr;
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad); io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
IM_DELETE(bd); IM_DELETE(bd);
} }
// This code is incredibly messy because some of the functions we need for full viewport support are not available in SDL < 2.0.4.
static void ImGui_ImplSDL3_UpdateMouseData() static void ImGui_ImplSDL3_UpdateMouseData()
{ {
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData(); ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
@ -565,7 +628,7 @@ static void ImGui_ImplSDL3_UpdateMouseData()
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE); SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
SDL_Window* focused_window = SDL_GetKeyboardFocus(); SDL_Window* focused_window = SDL_GetKeyboardFocus();
const bool is_app_focused = (bd->Window == focused_window); const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui_ImplSDL3_GetViewportForWindowID(SDL_GetWindowID(focused_window)) != NULL));
#else #else
SDL_Window* focused_window = bd->Window; SDL_Window* focused_window = bd->Window;
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
@ -574,19 +637,47 @@ static void ImGui_ImplSDL3_UpdateMouseData()
{ {
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user) // (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
if (io.WantSetMousePos) if (io.WantSetMousePos)
SDL_WarpMouseInWindow(bd->Window, io.MousePos.x, io.MousePos.y); {
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
SDL_WarpMouseGlobal(io.MousePos.x, io.MousePos.y);
else
#endif
SDL_WarpMouseInWindow(bd->Window, io.MousePos.x, io.MousePos.y);
}
// (Optional) Fallback to provide mouse position when focused (SDL_EVENT_MOUSE_MOTION already provides this when hovered or captured) // (Optional) Fallback to provide mouse position when focused (SDL_EVENT_MOUSE_MOTION already provides this when hovered or captured)
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0) if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
{ {
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window) // Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
float mouse_x_global, mouse_y_global; // Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
float mouse_x, mouse_y;
int window_x, window_y; int window_x, window_y;
SDL_GetGlobalMouseState(&mouse_x_global, &mouse_y_global); SDL_GetGlobalMouseState(&mouse_x, &mouse_y);
SDL_GetWindowPosition(focused_window, &window_x, &window_y); if (!(io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
io.AddMousePosEvent(mouse_x_global - window_x, mouse_y_global - window_y); {
SDL_GetWindowPosition(focused_window, &window_x, &window_y);
mouse_x -= window_x;
mouse_y -= window_y;
}
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
} }
} }
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
// - [!] SDL backend does NOT correctly ignore viewports with the _NoInputs flag.
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
// by the backend, and use its flawed heuristic to guess the viewport behind.
// - [X] SDL backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
{
ImGuiID mouse_viewport_id = 0;
if (ImGuiViewport* mouse_viewport = ImGui_ImplSDL3_GetViewportForWindowID(bd->MouseWindowID))
mouse_viewport_id = mouse_viewport->ID;
io.AddMouseViewportEvent(mouse_viewport_id);
}
} }
static void ImGui_ImplSDL3_UpdateMouseCursor() static void ImGui_ImplSDL3_UpdateMouseCursor()
@ -721,6 +812,38 @@ static void ImGui_ImplSDL3_UpdateGamepads()
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_GAMEPAD_AXIS_RIGHTY, +thumb_dead_zone, +32767); ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_GAMEPAD_AXIS_RIGHTY, +thumb_dead_zone, +32767);
} }
static void ImGui_ImplSDL3_UpdateMonitors()
{
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Monitors.resize(0);
bd->WantUpdateMonitors = false;
int display_count;
SDL_DisplayID* displays = SDL_GetDisplays(&display_count);
for (int n = 0; n < display_count; n++)
{
// Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.
SDL_DisplayID display_id = displays[n];
ImGuiPlatformMonitor monitor;
SDL_Rect r;
SDL_GetDisplayBounds(display_id, &r);
monitor.MainPos = monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
monitor.MainSize = monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
SDL_GetDisplayUsableBounds(display_id, &r);
monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
// FIXME-VIEWPORT: On MacOS SDL reports actual monitor DPI scale, ignoring OS configuration. We may want to set
// DpiScale to cocoa_window.backingScaleFactor here.
monitor.DpiScale = SDL_GetDisplayContentScale(display_id);
monitor.PlatformHandle = (void*)(intptr_t)n;
if (monitor.DpiScale <= 0.0f)
continue; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
platform_io.Monitors.push_back(monitor);
}
SDL_free(displays);
}
void ImGui_ImplSDL3_NewFrame() void ImGui_ImplSDL3_NewFrame()
{ {
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData(); ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
@ -738,6 +861,10 @@ void ImGui_ImplSDL3_NewFrame()
if (w > 0 && h > 0) if (w > 0 && h > 0)
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h); io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
// Update monitors
if (bd->WantUpdateMonitors)
ImGui_ImplSDL3_UpdateMonitors();
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution) // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644) // (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
static Uint64 frequency = SDL_GetPerformanceFrequency(); static Uint64 frequency = SDL_GetPerformanceFrequency();
@ -754,6 +881,13 @@ void ImGui_ImplSDL3_NewFrame()
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX); io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
} }
// Our io.AddMouseViewportEvent() calls will only be valid when not capturing.
// Technically speaking testing for 'bd->MouseButtonsDown == 0' would be more rigorous, but testing for payload reduces noise and potential side-effects.
if (bd->MouseCanReportHoveredViewport && ImGui::GetDragDropPayload() == nullptr)
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport;
else
io.BackendFlags &= ~ImGuiBackendFlags_HasMouseHoveredViewport;
ImGui_ImplSDL3_UpdateMouseData(); ImGui_ImplSDL3_UpdateMouseData();
ImGui_ImplSDL3_UpdateMouseCursor(); ImGui_ImplSDL3_UpdateMouseCursor();
@ -761,6 +895,226 @@ void ImGui_ImplSDL3_NewFrame()
ImGui_ImplSDL3_UpdateGamepads(); ImGui_ImplSDL3_UpdateGamepads();
} }
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
struct ImGui_ImplSDL3_ViewportData
{
SDL_Window* Window;
Uint32 WindowID;
bool WindowOwned;
SDL_GLContext GLContext;
ImGui_ImplSDL3_ViewportData() { Window = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
~ImGui_ImplSDL3_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
};
static void ImGui_ImplSDL3_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
ImGui_ImplSDL3_ViewportData* vd = IM_NEW(ImGui_ImplSDL3_ViewportData)();
viewport->PlatformUserData = vd;
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
ImGui_ImplSDL3_ViewportData* main_viewport_data = (ImGui_ImplSDL3_ViewportData*)main_viewport->PlatformUserData;
// Share GL resources with main context
bool use_opengl = (main_viewport_data->GLContext != nullptr);
SDL_GLContext backup_context = nullptr;
if (use_opengl)
{
backup_context = SDL_GL_GetCurrentContext();
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
SDL_GL_MakeCurrent(main_viewport_data->Window, main_viewport_data->GLContext);
}
Uint32 sdl_flags = 0;
sdl_flags |= use_opengl ? SDL_WINDOW_OPENGL : (bd->UseVulkan ? SDL_WINDOW_VULKAN : 0);
sdl_flags |= SDL_GetWindowFlags(bd->Window);
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0;
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
#if !defined(_WIN32)
// See SDL hack in ImGui_ImplSDL3_ShowWindow().
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_UTILITY : 0;
#endif
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);
SDL_SetWindowPosition(vd->Window, (int)viewport->Pos.x, (int)viewport->Pos.y);
vd->WindowOwned = true;
if (use_opengl)
{
vd->GLContext = SDL_GL_CreateContext(vd->Window);
SDL_GL_SetSwapInterval(0);
}
if (use_opengl && backup_context)
SDL_GL_MakeCurrent(vd->Window, backup_context);
ImGui_ImplSDL3_SetupPlatformHandles(viewport, vd->Window);
}
static void ImGui_ImplSDL3_DestroyWindow(ImGuiViewport* viewport)
{
if (ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData)
{
if (vd->GLContext && vd->WindowOwned)
SDL_GL_DestroyContext(vd->GLContext);
if (vd->Window && vd->WindowOwned)
SDL_DestroyWindow(vd->Window);
vd->GLContext = nullptr;
vd->Window = nullptr;
IM_DELETE(vd);
}
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
}
static void ImGui_ImplSDL3_ShowWindow(ImGuiViewport* viewport)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
#if defined(_WIN32)
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
// SDL hack: Hide icon from task bar
// Note: SDL 3.0.0+ has a SDL_WINDOW_UTILITY flag which is supported under Windows but the way it create the window breaks our seamless transition.
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
{
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
ex_style &= ~WS_EX_APPWINDOW;
ex_style |= WS_EX_TOOLWINDOW;
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
}
#endif
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing) ? "0" : "1");
SDL_ShowWindow(vd->Window);
}
static ImVec2 ImGui_ImplSDL3_GetWindowPos(ImGuiViewport* viewport)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
int x = 0, y = 0;
SDL_GetWindowPosition(vd->Window, &x, &y);
return ImVec2((float)x, (float)y);
}
static void ImGui_ImplSDL3_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
SDL_SetWindowPosition(vd->Window, (int)pos.x, (int)pos.y);
}
static ImVec2 ImGui_ImplSDL3_GetWindowSize(ImGuiViewport* viewport)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
int w = 0, h = 0;
SDL_GetWindowSize(vd->Window, &w, &h);
return ImVec2((float)w, (float)h);
}
static void ImGui_ImplSDL3_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
SDL_SetWindowSize(vd->Window, (int)size.x, (int)size.y);
}
static void ImGui_ImplSDL3_SetWindowTitle(ImGuiViewport* viewport, const char* title)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
SDL_SetWindowTitle(vd->Window, title);
}
static void ImGui_ImplSDL3_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
SDL_SetWindowOpacity(vd->Window, alpha);
}
static void ImGui_ImplSDL3_SetWindowFocus(ImGuiViewport* viewport)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
SDL_RaiseWindow(vd->Window);
}
static bool ImGui_ImplSDL3_GetWindowFocus(ImGuiViewport* viewport)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0;
}
static bool ImGui_ImplSDL3_GetWindowMinimized(ImGuiViewport* viewport)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_MINIMIZED) != 0;
}
static void ImGui_ImplSDL3_RenderWindow(ImGuiViewport* viewport, void*)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
if (vd->GLContext)
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
}
static void ImGui_ImplSDL3_SwapBuffers(ImGuiViewport* viewport, void*)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
if (vd->GLContext)
{
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
SDL_GL_SwapWindow(vd->Window);
}
}
// Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface)
// SDL is graceful enough to _not_ need <vulkan/vulkan.h> so we can safely include this.
#include <SDL3/SDL_vulkan.h>
static int ImGui_ImplSDL3_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
{
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
(void)vk_allocator;
SDL_bool ret = SDL_Vulkan_CreateSurface(vd->Window, (VkInstance)vk_instance, (VkAllocationCallbacks*)vk_allocator, (VkSurfaceKHR*)out_vk_surface);
return ret ? 0 : 1; // ret ? VK_SUCCESS : VK_NOT_READY
}
static void ImGui_ImplSDL3_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context)
{
// Register platform interface (will be coupled with a renderer interface)
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_CreateWindow = ImGui_ImplSDL3_CreateWindow;
platform_io.Platform_DestroyWindow = ImGui_ImplSDL3_DestroyWindow;
platform_io.Platform_ShowWindow = ImGui_ImplSDL3_ShowWindow;
platform_io.Platform_SetWindowPos = ImGui_ImplSDL3_SetWindowPos;
platform_io.Platform_GetWindowPos = ImGui_ImplSDL3_GetWindowPos;
platform_io.Platform_SetWindowSize = ImGui_ImplSDL3_SetWindowSize;
platform_io.Platform_GetWindowSize = ImGui_ImplSDL3_GetWindowSize;
platform_io.Platform_SetWindowFocus = ImGui_ImplSDL3_SetWindowFocus;
platform_io.Platform_GetWindowFocus = ImGui_ImplSDL3_GetWindowFocus;
platform_io.Platform_GetWindowMinimized = ImGui_ImplSDL3_GetWindowMinimized;
platform_io.Platform_SetWindowTitle = ImGui_ImplSDL3_SetWindowTitle;
platform_io.Platform_RenderWindow = ImGui_ImplSDL3_RenderWindow;
platform_io.Platform_SwapBuffers = ImGui_ImplSDL3_SwapBuffers;
platform_io.Platform_SetWindowAlpha = ImGui_ImplSDL3_SetWindowAlpha;
platform_io.Platform_CreateVkSurface = ImGui_ImplSDL3_CreateVkSurface;
// Register main window handle (which is owned by the main application, not by us)
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
ImGui_ImplSDL3_ViewportData* vd = IM_NEW(ImGui_ImplSDL3_ViewportData)();
vd->Window = window;
vd->WindowID = SDL_GetWindowID(window);
vd->WindowOwned = false;
vd->GLContext = (SDL_GLContext)sdl_gl_context;
main_viewport->PlatformUserData = vd;
main_viewport->PlatformHandle = (void*)(intptr_t)vd->WindowID;
}
static void ImGui_ImplSDL3_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if defined(__clang__) #if defined(__clang__)

View File

@ -10,6 +10,11 @@
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [x] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable' -> the OS animation effect when window gets created/destroyed is problematic. SDL2 backend doesn't have issue.
// Issues:
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -10,6 +10,8 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// Missing features:
// [ ] Renderer: Multi-viewport support (multiple windows).
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -10,6 +10,8 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// Missing features:
// [ ] Renderer: Multi-viewport support (multiple windows).
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -12,6 +12,9 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows).
// FIXME: Missing way to share textures betweens renderers: shttps://github.com/libsdl-org/SDL/issues/6742
// FIXME: Missing way to specify a projection matrix, so our vertices in absolute coordinates are not displayed correctly in multi-viewports mode.
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -22,6 +25,7 @@
// - Introduction, links and more at the top of imgui.cpp // - Introduction, links and more at the top of imgui.cpp
// CHANGELOG // CHANGELOG
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface. (#5835)
// 2024-07-01: Update for SDL3 api changes: SDL_RenderGeometryRaw() uint32 version was removed (SDL#9009). // 2024-07-01: Update for SDL3 api changes: SDL_RenderGeometryRaw() uint32 version was removed (SDL#9009).
// 2024-05-14: *BREAKING CHANGE* ImGui_ImplSDLRenderer3_RenderDrawData() requires SDL_Renderer* passed as parameter. // 2024-05-14: *BREAKING CHANGE* ImGui_ImplSDLRenderer3_RenderDrawData() requires SDL_Renderer* passed as parameter.
// 2024-02-12: Amend to query SDL_RenderViewportSet() and restore viewport accordingly. // 2024-02-12: Amend to query SDL_RenderViewportSet() and restore viewport accordingly.
@ -49,7 +53,8 @@ struct ImGui_ImplSDLRenderer3_Data
{ {
SDL_Renderer* Renderer; // Main viewport's renderer SDL_Renderer* Renderer; // Main viewport's renderer
SDL_Texture* FontTexture; SDL_Texture* FontTexture;
ImVector<SDL_FColor> ColorBuffer; ImVector<SDL_FColor> ColorBuffer; // Transformed color buffer
ImVector<ImVec2> PosBuffer; // Transformed pos buffer (for multi-viewports only)
ImGui_ImplSDLRenderer3_Data() { memset((void*)this, 0, sizeof(*this)); } ImGui_ImplSDLRenderer3_Data() { memset((void*)this, 0, sizeof(*this)); }
}; };
@ -61,6 +66,10 @@ static ImGui_ImplSDLRenderer3_Data* ImGui_ImplSDLRenderer3_GetBackendData()
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr; return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
} }
// Forward Declarations
static void ImGui_ImplSDLRenderer3_InitPlatformInterface();
static void ImGui_ImplSDLRenderer3_ShutdownPlatformInterface();
// Functions // Functions
bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer) bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
{ {
@ -74,9 +83,13 @@ bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
io.BackendRendererUserData = (void*)bd; io.BackendRendererUserData = (void*)bd;
io.BackendRendererName = "imgui_impl_sdlrenderer3"; io.BackendRendererName = "imgui_impl_sdlrenderer3";
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
bd->Renderer = renderer; bd->Renderer = renderer;
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplSDLRenderer3_InitPlatformInterface();
return true; return true;
} }
@ -86,6 +99,7 @@ void ImGui_ImplSDLRenderer3_Shutdown()
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui_ImplSDLRenderer3_ShutdownPlatformInterface();
ImGui_ImplSDLRenderer3_DestroyDeviceObjects(); ImGui_ImplSDLRenderer3_DestroyDeviceObjects();
io.BackendRendererName = nullptr; io.BackendRendererName = nullptr;
@ -203,13 +217,32 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
SDL_SetRenderClipRect(renderer, &r); SDL_SetRenderClipRect(renderer, &r);
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos)); const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
int xy_stride = (int)sizeof(ImDrawVert);
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv)); const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.19+ const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.19+
// FIXME-OPT: Transform position manually
// FIXME-OPT: Note that SDL_RenderGeometryRaw() does another transform for colors..
if (draw_data->DisplayPos.x != 0.0f || draw_data->DisplayPos.y != 0.0f)
{
const float off_x = draw_data->DisplayPos.x;
const float off_y = draw_data->DisplayPos.y;
bd->PosBuffer.resize(pcmd->ElemCount);
const ImDrawVert* p_in = vtx_buffer + pcmd->VtxOffset;
ImVec2* p_out = bd->PosBuffer.Data;
for (int remaining = pcmd->ElemCount; remaining > 0; remaining--, p_out++, p_in++)
{
p_out->x = p_in->pos.x - off_x;
p_out->y = p_in->pos.y - off_y;
}
xy = (const float*)bd->PosBuffer.Data;
xy_stride = (int)sizeof(ImVec2);
}
// Bind texture, Draw // Bind texture, Draw
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID(); SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
SDL_RenderGeometryRaw8BitColor(renderer, bd->ColorBuffer, tex, SDL_RenderGeometryRaw8BitColor(renderer, bd->ColorBuffer, tex,
xy, (int)sizeof(ImDrawVert), xy, xy_stride,
color, (int)sizeof(ImDrawVert), color, (int)sizeof(ImDrawVert),
uv, (int)sizeof(ImDrawVert), uv, (int)sizeof(ImDrawVert),
cmd_list->VtxBuffer.Size - pcmd->VtxOffset, cmd_list->VtxBuffer.Size - pcmd->VtxOffset,
@ -274,6 +307,77 @@ void ImGui_ImplSDLRenderer3_DestroyDeviceObjects()
ImGui_ImplSDLRenderer3_DestroyFontsTexture(); ImGui_ImplSDLRenderer3_DestroyFontsTexture();
} }
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
struct ImGui_ImplSDLRenderer3_ViewportData
{
SDL_Renderer* Renderer;
ImGui_ImplSDLRenderer3_ViewportData() { Renderer = nullptr; }
~ImGui_ImplSDLRenderer3_ViewportData() { IM_ASSERT(Renderer == nullptr); }
};
static void ImGui_ImplSDLRenderer3_CreateWindow(ImGuiViewport* viewport)
{
//ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
ImGui_ImplSDLRenderer3_ViewportData* vd = IM_NEW(ImGui_ImplSDLRenderer3_ViewportData)();
viewport->RendererUserData = vd;
SDL_Window* window = (SDL_Window*)viewport->PlatformHandle;
vd->Renderer = SDL_CreateRenderer(window, nullptr);
SDL_SetRenderVSync(vd->Renderer, 0);
IM_ASSERT(vd->Renderer != NULL);
}
static void ImGui_ImplSDLRenderer3_DestroyWindow(ImGuiViewport* viewport)
{
// The main viewport (owned by the application) will always have RendererUserData == nullptr since we didn't create the data for it.
if (ImGui_ImplSDLRenderer3_ViewportData* vd = (ImGui_ImplSDLRenderer3_ViewportData*)viewport->RendererUserData)
{
SDL_DestroyRenderer(vd->Renderer);
vd->Renderer = nullptr;
IM_DELETE(vd);
}
viewport->RendererUserData = nullptr;
}
static void ImGui_ImplSDLRenderer3_RenderWindow(ImGuiViewport* viewport, void*)
{
ImGui_ImplSDLRenderer3_ViewportData* vd = (ImGui_ImplSDLRenderer3_ViewportData*)viewport->RendererUserData;
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
{
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
SDL_SetRenderDrawColor(vd->Renderer, (Uint8)(clear_color.x * 255), (Uint8)(clear_color.y * 255), (Uint8)(clear_color.z * 255), (Uint8)(clear_color.w * 255));
SDL_RenderClear(vd->Renderer);
}
ImGui_ImplSDLRenderer3_RenderDrawData(viewport->DrawData, vd->Renderer);
}
static void ImGui_ImplSDLRenderer3_SwapBuffers(ImGuiViewport* viewport, void*)
{
ImGui_ImplSDLRenderer3_ViewportData* vd = (ImGui_ImplSDLRenderer3_ViewportData*)viewport->RendererUserData;
SDL_RenderPresent(vd->Renderer);
}
static void ImGui_ImplSDLRenderer3_InitPlatformInterface()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Renderer_CreateWindow = ImGui_ImplSDLRenderer3_CreateWindow;
platform_io.Renderer_DestroyWindow = ImGui_ImplSDLRenderer3_DestroyWindow;
platform_io.Renderer_RenderWindow = ImGui_ImplSDLRenderer3_RenderWindow;
platform_io.Renderer_SwapBuffers = ImGui_ImplSDLRenderer3_SwapBuffers;
}
static void ImGui_ImplSDLRenderer3_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if defined(__clang__) #if defined(__clang__)

View File

@ -12,6 +12,7 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows).
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -2,8 +2,9 @@
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) // This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
// Implemented features: // Implemented features:
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions. // [x] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [x] Renderer: Multi-viewport / platform windows. With issues (flickering when creating a new viewport).
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'. // Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. // This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
@ -33,6 +34,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-04-19: Vulkan: Added convenience support for Volk via IMGUI_IMPL_VULKAN_USE_VOLK define (you can also use IMGUI_IMPL_VULKAN_NO_PROTOTYPES + wrap Volk via ImGui_ImplVulkan_LoadFunctions().) // 2024-04-19: Vulkan: Added convenience support for Volk via IMGUI_IMPL_VULKAN_USE_VOLK define (you can also use IMGUI_IMPL_VULKAN_NO_PROTOTYPES + wrap Volk via ImGui_ImplVulkan_LoadFunctions().)
// 2024-02-14: *BREAKING CHANGE*: Moved RenderPass parameter from ImGui_ImplVulkan_Init() function to ImGui_ImplVulkan_InitInfo structure. Not required when using dynamic rendering. // 2024-02-14: *BREAKING CHANGE*: Moved RenderPass parameter from ImGui_ImplVulkan_Init() function to ImGui_ImplVulkan_InitInfo structure. Not required when using dynamic rendering.
// 2024-02-12: *BREAKING CHANGE*: Dynamic rendering now require filling PipelineRenderingCreateInfo structure. // 2024-02-12: *BREAKING CHANGE*: Dynamic rendering now require filling PipelineRenderingCreateInfo structure.
@ -104,6 +106,7 @@ void ImGui_ImplVulkan_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulka
void ImGui_ImplVulkan_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkan_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator); void ImGui_ImplVulkan_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkan_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator); void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator);
void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator); void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator);
void ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(VkDevice device, const VkAllocationCallbacks* allocator);
void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count); void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator); void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator);
@ -120,15 +123,18 @@ static bool g_FunctionsLoaded = true;
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateMemory) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateMemory) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAcquireNextImageKHR) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBeginCommandBuffer) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkBeginCommandBuffer) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindBufferMemory) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindBufferMemory) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindImageMemory) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindImageMemory) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBeginRenderPass) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindDescriptorSets) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindDescriptorSets) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindIndexBuffer) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindIndexBuffer) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindPipeline) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindPipeline) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindVertexBuffers) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindVertexBuffers) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdCopyBufferToImage) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdCopyBufferToImage) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdDrawIndexed) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdDrawIndexed) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdEndRenderPass) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPipelineBarrier) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPipelineBarrier) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPushConstants) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPushConstants) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdSetScissor) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdSetScissor) \
@ -174,13 +180,17 @@ static bool g_FunctionsLoaded = true;
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceFormatsKHR) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceFormatsKHR) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfacePresentModesKHR) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfacePresentModesKHR) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceSupportKHR) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetSwapchainImagesKHR) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetSwapchainImagesKHR) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkMapMemory) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkMapMemory) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueuePresentKHR) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueSubmit) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueSubmit) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueWaitIdle) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueWaitIdle) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkResetCommandPool) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkResetCommandPool) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkResetFences) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUnmapMemory) \ IMGUI_VULKAN_FUNC_MAP_MACRO(vkUnmapMemory) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUpdateDescriptorSets) IMGUI_VULKAN_FUNC_MAP_MACRO(vkUpdateDescriptorSets) \
IMGUI_VULKAN_FUNC_MAP_MACRO(vkWaitForFences)
// Define function pointers // Define function pointers
#define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func; #define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func;
@ -214,6 +224,19 @@ struct ImGui_ImplVulkan_WindowRenderBuffers
ImGui_ImplVulkan_FrameRenderBuffers* FrameRenderBuffers; ImGui_ImplVulkan_FrameRenderBuffers* FrameRenderBuffers;
}; };
// For multi-viewport support:
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
struct ImGui_ImplVulkan_ViewportData
{
ImGui_ImplVulkanH_Window Window; // Used by secondary viewports only
ImGui_ImplVulkan_WindowRenderBuffers RenderBuffers; // Used by all viewports
bool WindowOwned;
bool SwapChainNeedRebuild; // Flag when viewport swapchain resized in the middle of processing a frame
ImGui_ImplVulkan_ViewportData() { WindowOwned = SwapChainNeedRebuild = false; memset(&RenderBuffers, 0, sizeof(RenderBuffers)); }
~ImGui_ImplVulkan_ViewportData() { }
};
// Vulkan data // Vulkan data
struct ImGui_ImplVulkan_Data struct ImGui_ImplVulkan_Data
{ {
@ -222,7 +245,8 @@ struct ImGui_ImplVulkan_Data
VkPipelineCreateFlags PipelineCreateFlags; VkPipelineCreateFlags PipelineCreateFlags;
VkDescriptorSetLayout DescriptorSetLayout; VkDescriptorSetLayout DescriptorSetLayout;
VkPipelineLayout PipelineLayout; VkPipelineLayout PipelineLayout;
VkPipeline Pipeline; VkPipeline Pipeline; // pipeline for main render pass (created by app)
VkPipeline PipelineForViewports; // pipeline for secondary viewports (created by backend)
VkShaderModule ShaderModuleVert; VkShaderModule ShaderModuleVert;
VkShaderModule ShaderModuleFrag; VkShaderModule ShaderModuleFrag;
@ -249,6 +273,10 @@ struct ImGui_ImplVulkan_Data
// SHADERS // SHADERS
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Forward Declarations
static void ImGui_ImplVulkan_InitPlatformInterface();
static void ImGui_ImplVulkan_ShutdownPlatformInterface();
// backends/vulkan/glsl_shader.vert, compiled with: // backends/vulkan/glsl_shader.vert, compiled with:
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert // # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
/* /*
@ -486,8 +514,10 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
if (pipeline == VK_NULL_HANDLE) if (pipeline == VK_NULL_HANDLE)
pipeline = bd->Pipeline; pipeline = bd->Pipeline;
// Allocate array to store enough vertex/index buffers // Allocate array to store enough vertex/index buffers. Each unique viewport gets its own storage.
ImGui_ImplVulkan_WindowRenderBuffers* wrb = &bd->MainWindowRenderBuffers; ImGui_ImplVulkan_ViewportData* viewport_renderer_data = (ImGui_ImplVulkan_ViewportData*)draw_data->OwnerViewport->RendererUserData;
IM_ASSERT(viewport_renderer_data != nullptr);
ImGui_ImplVulkan_WindowRenderBuffers* wrb = &viewport_renderer_data->RenderBuffers;
if (wrb->FrameRenderBuffers == nullptr) if (wrb->FrameRenderBuffers == nullptr)
{ {
wrb->Index = 0; wrb->Index = 0;
@ -1032,7 +1062,7 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
{ {
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
ImGui_ImplVulkan_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator); ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(v->Device, v->Allocator);
ImGui_ImplVulkan_DestroyFontsTexture(); ImGui_ImplVulkan_DestroyFontsTexture();
if (bd->FontCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->FontCommandPool, 1, &bd->FontCommandBuffer); bd->FontCommandBuffer = VK_NULL_HANDLE; } if (bd->FontCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->FontCommandPool, 1, &bd->FontCommandBuffer); bd->FontCommandBuffer = VK_NULL_HANDLE; }
@ -1043,6 +1073,7 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
if (bd->DescriptorSetLayout) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayout, v->Allocator); bd->DescriptorSetLayout = VK_NULL_HANDLE; } if (bd->DescriptorSetLayout) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayout, v->Allocator); bd->DescriptorSetLayout = VK_NULL_HANDLE; }
if (bd->PipelineLayout) { vkDestroyPipelineLayout(v->Device, bd->PipelineLayout, v->Allocator); bd->PipelineLayout = VK_NULL_HANDLE; } if (bd->PipelineLayout) { vkDestroyPipelineLayout(v->Device, bd->PipelineLayout, v->Allocator); bd->PipelineLayout = VK_NULL_HANDLE; }
if (bd->Pipeline) { vkDestroyPipeline(v->Device, bd->Pipeline, v->Allocator); bd->Pipeline = VK_NULL_HANDLE; } if (bd->Pipeline) { vkDestroyPipeline(v->Device, bd->Pipeline, v->Allocator); bd->Pipeline = VK_NULL_HANDLE; }
if (bd->PipelineForViewports) { vkDestroyPipeline(v->Device, bd->PipelineForViewports, v->Allocator); bd->PipelineForViewports = VK_NULL_HANDLE; }
} }
bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data) bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data)
@ -1100,6 +1131,7 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
io.BackendRendererUserData = (void*)bd; io.BackendRendererUserData = (void*)bd;
io.BackendRendererName = "imgui_impl_vulkan"; io.BackendRendererName = "imgui_impl_vulkan";
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
IM_ASSERT(info->Instance != VK_NULL_HANDLE); IM_ASSERT(info->Instance != VK_NULL_HANDLE);
IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE); IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE);
@ -1115,6 +1147,13 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
ImGui_ImplVulkan_CreateDeviceObjects(); ImGui_ImplVulkan_CreateDeviceObjects();
// Our render function expect RendererUserData to be storing the window render buffer we need (for the main viewport we won't use ->Window)
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
main_viewport->RendererUserData = IM_NEW(ImGui_ImplVulkan_ViewportData)();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplVulkan_InitPlatformInterface();
return true; return true;
} }
@ -1124,10 +1163,21 @@ void ImGui_ImplVulkan_Shutdown()
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
// First destroy objects in all viewports
ImGui_ImplVulkan_DestroyDeviceObjects(); ImGui_ImplVulkan_DestroyDeviceObjects();
// Manually delete main viewport render data in-case we haven't initialized for viewports
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
if (ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)main_viewport->RendererUserData)
IM_DELETE(vd);
main_viewport->RendererUserData = nullptr;
// Clean up windows
ImGui_ImplVulkan_ShutdownPlatformInterface();
io.BackendRendererName = nullptr; io.BackendRendererName = nullptr;
io.BackendRendererUserData = nullptr; io.BackendRendererUserData = nullptr;
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset; io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
IM_DELETE(bd); IM_DELETE(bd);
} }
@ -1147,10 +1197,12 @@ void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count)
if (bd->VulkanInitInfo.MinImageCount == min_image_count) if (bd->VulkanInitInfo.MinImageCount == min_image_count)
return; return;
IM_ASSERT(0); // FIXME-VIEWPORT: Unsupported. Need to recreate all swap chains!
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
VkResult err = vkDeviceWaitIdle(v->Device); VkResult err = vkDeviceWaitIdle(v->Device);
check_vk_result(err); check_vk_result(err);
ImGui_ImplVulkan_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator); ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(v->Device, v->Allocator);
bd->VulkanInitInfo.MinImageCount = min_image_count; bd->VulkanInitInfo.MinImageCount = min_image_count;
} }
@ -1385,8 +1437,6 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
wd->ImageCount = 0; wd->ImageCount = 0;
if (wd->RenderPass) if (wd->RenderPass)
vkDestroyRenderPass(device, wd->RenderPass, allocator); vkDestroyRenderPass(device, wd->RenderPass, allocator);
if (wd->Pipeline)
vkDestroyPipeline(device, wd->Pipeline, allocator);
// If min image count was not specified, request different count of images dependent on selected present mode // If min image count was not specified, request different count of images dependent on selected present mode
if (min_image_count == 0) if (min_image_count == 0)
@ -1539,6 +1589,7 @@ void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevic
IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!"); IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!");
(void)instance; (void)instance;
ImGui_ImplVulkanH_CreateWindowSwapChain(physical_device, device, wd, allocator, width, height, min_image_count); ImGui_ImplVulkanH_CreateWindowSwapChain(physical_device, device, wd, allocator, width, height, min_image_count);
//ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline, g_VulkanInitInfo.Subpass);
ImGui_ImplVulkanH_CreateWindowCommandBuffers(physical_device, device, wd, queue_family, allocator); ImGui_ImplVulkanH_CreateWindowCommandBuffers(physical_device, device, wd, queue_family, allocator);
} }
@ -1555,7 +1606,6 @@ void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui
IM_FREE(wd->FrameSemaphores); IM_FREE(wd->FrameSemaphores);
wd->Frames = nullptr; wd->Frames = nullptr;
wd->FrameSemaphores = nullptr; wd->FrameSemaphores = nullptr;
vkDestroyPipeline(device, wd->Pipeline, allocator);
vkDestroyRenderPass(device, wd->RenderPass, allocator); vkDestroyRenderPass(device, wd->RenderPass, allocator);
vkDestroySwapchainKHR(device, wd->Swapchain, allocator); vkDestroySwapchainKHR(device, wd->Swapchain, allocator);
vkDestroySurfaceKHR(instance, wd->Surface, allocator); vkDestroySurfaceKHR(instance, wd->Surface, allocator);
@ -1583,6 +1633,297 @@ void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH
fsd->ImageAcquiredSemaphore = fsd->RenderCompleteSemaphore = VK_NULL_HANDLE; fsd->ImageAcquiredSemaphore = fsd->RenderCompleteSemaphore = VK_NULL_HANDLE;
} }
void ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(VkDevice device, const VkAllocationCallbacks* allocator)
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
for (int n = 0; n < platform_io.Viewports.Size; n++)
if (ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)platform_io.Viewports[n]->RendererUserData)
ImGui_ImplVulkan_DestroyWindowRenderBuffers(device, &vd->RenderBuffers, allocator);
}
//--------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
ImGui_ImplVulkan_ViewportData* vd = IM_NEW(ImGui_ImplVulkan_ViewportData)();
viewport->RendererUserData = vd;
ImGui_ImplVulkanH_Window* wd = &vd->Window;
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
// Create surface
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
VkResult err = (VkResult)platform_io.Platform_CreateVkSurface(viewport, (ImU64)v->Instance, (const void*)v->Allocator, (ImU64*)&wd->Surface);
check_vk_result(err);
// Check for WSI support
VkBool32 res;
vkGetPhysicalDeviceSurfaceSupportKHR(v->PhysicalDevice, v->QueueFamily, wd->Surface, &res);
if (res != VK_TRUE)
{
IM_ASSERT(0); // Error: no WSI support on physical device
return;
}
// Select Surface Format
ImVector<VkFormat> requestSurfaceImageFormats;
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
for (uint32_t n = 0; n < v->PipelineRenderingCreateInfo.colorAttachmentCount; n++)
requestSurfaceImageFormats.push_back(v->PipelineRenderingCreateInfo.pColorAttachmentFormats[n]);
#endif
const VkFormat defaultFormats[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
for (VkFormat format : defaultFormats)
requestSurfaceImageFormats.push_back(format);
const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(v->PhysicalDevice, wd->Surface, requestSurfaceImageFormats.Data, (size_t)requestSurfaceImageFormats.Size, requestSurfaceColorSpace);
// Select Present Mode
// FIXME-VULKAN: Even thought mailbox seems to get us maximum framerate with a single window, it halves framerate with a second window etc. (w/ Nvidia and SDK 1.82.1)
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(v->PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes));
//printf("[vulkan] Secondary window selected PresentMode = %d\n", wd->PresentMode);
// Create SwapChain, RenderPass, Framebuffer, etc.
wd->ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
wd->UseDynamicRendering = v->UseDynamicRendering;
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, wd, v->QueueFamily, v->Allocator, (int)viewport->Size.x, (int)viewport->Size.y, v->MinImageCount);
vd->WindowOwned = true;
// Create pipeline (shared by all secondary viewports)
if (bd->PipelineForViewports == VK_NULL_HANDLE)
ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &bd->PipelineForViewports, 0);
}
static void ImGui_ImplVulkan_DestroyWindow(ImGuiViewport* viewport)
{
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
if (ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData)
{
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
if (vd->WindowOwned)
ImGui_ImplVulkanH_DestroyWindow(v->Instance, v->Device, &vd->Window, v->Allocator);
ImGui_ImplVulkan_DestroyWindowRenderBuffers(v->Device, &vd->RenderBuffers, v->Allocator);
IM_DELETE(vd);
}
viewport->RendererUserData = nullptr;
}
static void ImGui_ImplVulkan_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData;
if (vd == nullptr) // This is nullptr for the main viewport (which is left to the user/app to handle)
return;
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
vd->Window.ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, &vd->Window, v->QueueFamily, v->Allocator, (int)size.x, (int)size.y, v->MinImageCount);
}
static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*)
{
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData;
ImGui_ImplVulkanH_Window* wd = &vd->Window;
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
VkResult err;
if (vd->SwapChainNeedRebuild)
{
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, wd, v->QueueFamily, v->Allocator, (int)viewport->Size.x, (int)viewport->Size.y, v->MinImageCount);
vd->SwapChainNeedRebuild = false;
}
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex];
ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[wd->SemaphoreIndex];
{
{
err = vkAcquireNextImageKHR(v->Device, wd->Swapchain, UINT64_MAX, fsd->ImageAcquiredSemaphore, VK_NULL_HANDLE, &wd->FrameIndex);
if (err == VK_ERROR_OUT_OF_DATE_KHR)
{
// Since we are not going to swap this frame anyway, it's ok that recreation happens on next frame.
vd->SwapChainNeedRebuild = true;
return;
}
check_vk_result(err);
fd = &wd->Frames[wd->FrameIndex];
}
for (;;)
{
err = vkWaitForFences(v->Device, 1, &fd->Fence, VK_TRUE, 100);
if (err == VK_SUCCESS) break;
if (err == VK_TIMEOUT) continue;
check_vk_result(err);
}
{
err = vkResetCommandPool(v->Device, fd->CommandPool, 0);
check_vk_result(err);
VkCommandBufferBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
check_vk_result(err);
}
{
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
}
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
if (v->UseDynamicRendering)
{
// Transition swapchain image to a layout suitable for drawing.
VkImageMemoryBarrier barrier = {};
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
barrier.image = fd->Backbuffer;
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
barrier.subresourceRange.levelCount = 1;
barrier.subresourceRange.layerCount = 1;
vkCmdPipelineBarrier(fd->CommandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier);
VkRenderingAttachmentInfo attachmentInfo = {};
attachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR;
attachmentInfo.imageView = fd->BackbufferView;
attachmentInfo.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
attachmentInfo.resolveMode = VK_RESOLVE_MODE_NONE;
attachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachmentInfo.clearValue = wd->ClearValue;
VkRenderingInfo renderingInfo = {};
renderingInfo.sType = VK_STRUCTURE_TYPE_RENDERING_INFO_KHR;
renderingInfo.renderArea.extent.width = wd->Width;
renderingInfo.renderArea.extent.height = wd->Height;
renderingInfo.layerCount = 1;
renderingInfo.viewMask = 0;
renderingInfo.colorAttachmentCount = 1;
renderingInfo.pColorAttachments = &attachmentInfo;
ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR(fd->CommandBuffer, &renderingInfo);
}
else
#endif
{
VkRenderPassBeginInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
info.renderPass = wd->RenderPass;
info.framebuffer = fd->Framebuffer;
info.renderArea.extent.width = wd->Width;
info.renderArea.extent.height = wd->Height;
info.clearValueCount = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? 0 : 1;
info.pClearValues = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? nullptr : &wd->ClearValue;
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
}
}
ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, bd->PipelineForViewports);
{
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
if (v->UseDynamicRendering)
{
ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR(fd->CommandBuffer);
// Transition image to a layout suitable for presentation
VkImageMemoryBarrier barrier = {};
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
barrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
barrier.image = fd->Backbuffer;
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
barrier.subresourceRange.levelCount = 1;
barrier.subresourceRange.layerCount = 1;
vkCmdPipelineBarrier(fd->CommandBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier);
}
else
#endif
{
vkCmdEndRenderPass(fd->CommandBuffer);
}
{
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo info = {};
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.waitSemaphoreCount = 1;
info.pWaitSemaphores = &fsd->ImageAcquiredSemaphore;
info.pWaitDstStageMask = &wait_stage;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
info.signalSemaphoreCount = 1;
info.pSignalSemaphores = &fsd->RenderCompleteSemaphore;
err = vkEndCommandBuffer(fd->CommandBuffer);
check_vk_result(err);
err = vkResetFences(v->Device, 1, &fd->Fence);
check_vk_result(err);
err = vkQueueSubmit(v->Queue, 1, &info, fd->Fence);
check_vk_result(err);
}
}
}
static void ImGui_ImplVulkan_SwapBuffers(ImGuiViewport* viewport, void*)
{
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData;
ImGui_ImplVulkanH_Window* wd = &vd->Window;
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
if (vd->SwapChainNeedRebuild) // Frame data became invalid in the middle of rendering
return;
VkResult err;
uint32_t present_index = wd->FrameIndex;
ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[wd->SemaphoreIndex];
VkPresentInfoKHR info = {};
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
info.waitSemaphoreCount = 1;
info.pWaitSemaphores = &fsd->RenderCompleteSemaphore;
info.swapchainCount = 1;
info.pSwapchains = &wd->Swapchain;
info.pImageIndices = &present_index;
err = vkQueuePresentKHR(v->Queue, &info);
if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR)
{
vd->SwapChainNeedRebuild = true;
if (err == VK_ERROR_OUT_OF_DATE_KHR)
return;
}
else
{
check_vk_result(err);
}
wd->FrameIndex = (wd->FrameIndex + 1) % wd->ImageCount; // This is for the next vkWaitForFences()
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->SemaphoreCount; // Now we can use the next set of semaphores
}
void ImGui_ImplVulkan_InitPlatformInterface()
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
IM_ASSERT(platform_io.Platform_CreateVkSurface != nullptr && "Platform needs to setup the CreateVkSurface handler.");
platform_io.Renderer_CreateWindow = ImGui_ImplVulkan_CreateWindow;
platform_io.Renderer_DestroyWindow = ImGui_ImplVulkan_DestroyWindow;
platform_io.Renderer_SetWindowSize = ImGui_ImplVulkan_SetWindowSize;
platform_io.Renderer_RenderWindow = ImGui_ImplVulkan_RenderWindow;
platform_io.Renderer_SwapBuffers = ImGui_ImplVulkan_SwapBuffers;
}
void ImGui_ImplVulkan_ShutdownPlatformInterface()
{
ImGui::DestroyPlatformWindows();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif // #ifndef IMGUI_DISABLE #endif // #ifndef IMGUI_DISABLE

View File

@ -2,8 +2,9 @@
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) // This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
// Implemented features: // Implemented features:
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions. // [x] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [x] Renderer: Multi-viewport / platform windows. With issues (flickering when creating a new viewport).
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'. // Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
// See imgui_impl_vulkan.cpp file for details. // See imgui_impl_vulkan.cpp file for details.
@ -137,8 +138,8 @@ struct ImGui_ImplVulkanH_Frame;
struct ImGui_ImplVulkanH_Window; struct ImGui_ImplVulkanH_Window;
// Helpers // Helpers
IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wnd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count); IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator); IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator);
IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space); IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space);
IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count); IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count);
IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode); IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
@ -173,7 +174,6 @@ struct ImGui_ImplVulkanH_Window
VkSurfaceFormatKHR SurfaceFormat; VkSurfaceFormatKHR SurfaceFormat;
VkPresentModeKHR PresentMode; VkPresentModeKHR PresentMode;
VkRenderPass RenderPass; VkRenderPass RenderPass;
VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
bool UseDynamicRendering; bool UseDynamicRendering;
bool ClearEnable; bool ClearEnable;
VkClearValue ClearValue; VkClearValue ClearValue;

View File

@ -5,6 +5,8 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// Missing features:
// [ ] Renderer: Multi-viewport support (multiple windows). Not meaningful on the web.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -5,6 +5,8 @@
// Implemented features: // Implemented features:
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID! // [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// Missing features:
// [ ] Renderer: Multi-viewport support (multiple windows). Not meaningful on the web.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -7,6 +7,7 @@
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
@ -21,6 +22,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-07-08: Inputs: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN. (#7768) // 2024-07-08: Inputs: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN. (#7768)
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys. // 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
// 2023-09-25: Inputs: Synthesize key-down event on key-up for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit it (same behavior as GLFW/SDL). // 2023-09-25: Inputs: Synthesize key-down event on key-up for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit it (same behavior as GLFW/SDL).
@ -103,6 +105,11 @@ typedef DWORD(WINAPI* PFN_XInputGetState)(DWORD, XINPUT_STATE*);
#pragma GCC diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader) #pragma GCC diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader)
#endif #endif
// Forward Declarations
static void ImGui_ImplWin32_InitPlatformInterface(bool platform_has_own_dc);
static void ImGui_ImplWin32_ShutdownPlatformInterface();
static void ImGui_ImplWin32_UpdateMonitors();
struct ImGui_ImplWin32_Data struct ImGui_ImplWin32_Data
{ {
HWND hWnd; HWND hWnd;
@ -113,6 +120,7 @@ struct ImGui_ImplWin32_Data
INT64 TicksPerSecond; INT64 TicksPerSecond;
ImGuiMouseCursor LastMouseCursor; ImGuiMouseCursor LastMouseCursor;
UINT32 KeyboardCodePage; UINT32 KeyboardCodePage;
bool WantUpdateMonitors;
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
bool HasGamepad; bool HasGamepad;
@ -163,17 +171,21 @@ static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
io.BackendPlatformName = "imgui_impl_win32"; io.BackendPlatformName = "imgui_impl_win32";
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
bd->hWnd = (HWND)hwnd; bd->hWnd = (HWND)hwnd;
bd->WantUpdateMonitors = true;
bd->TicksPerSecond = perf_frequency; bd->TicksPerSecond = perf_frequency;
bd->Time = perf_counter; bd->Time = perf_counter;
bd->LastMouseCursor = ImGuiMouseCursor_COUNT; bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
ImGui_ImplWin32_UpdateKeyboardCodePage(); ImGui_ImplWin32_UpdateKeyboardCodePage();
// Set platform dependent data in viewport // Our mouse update function expect PlatformHandle to be filled for the main viewport
ImGuiViewport* main_viewport = ImGui::GetMainViewport(); ImGuiViewport* main_viewport = ImGui::GetMainViewport();
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (void*)bd->hWnd; main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (void*)bd->hWnd;
IM_UNUSED(platform_has_own_dc); // Used in 'docking' branch if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
ImGui_ImplWin32_InitPlatformInterface(platform_has_own_dc);
// Dynamically load XInput library // Dynamically load XInput library
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
@ -216,6 +228,8 @@ void ImGui_ImplWin32_Shutdown()
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?"); IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGui_ImplWin32_ShutdownPlatformInterface();
// Unload XInput library // Unload XInput library
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
if (bd->XInputDLL) if (bd->XInputDLL)
@ -224,7 +238,7 @@ void ImGui_ImplWin32_Shutdown()
io.BackendPlatformName = nullptr; io.BackendPlatformName = nullptr;
io.BackendPlatformUserData = nullptr; io.BackendPlatformUserData = nullptr;
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad); io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
IM_DELETE(bd); IM_DELETE(bd);
} }
@ -298,33 +312,59 @@ static void ImGui_ImplWin32_UpdateKeyModifiers()
io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_LWIN) || IsVkDown(VK_RWIN)); io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_LWIN) || IsVkDown(VK_RWIN));
} }
// This code supports multi-viewports (multiple OS Windows mapped into different Dear ImGui viewports)
// Because of that, it is a little more complicated than your typical single-viewport binding code!
static void ImGui_ImplWin32_UpdateMouseData() static void ImGui_ImplWin32_UpdateMouseData()
{ {
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData(); ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
IM_ASSERT(bd->hWnd != 0); IM_ASSERT(bd->hWnd != 0);
POINT mouse_screen_pos;
bool has_mouse_screen_pos = ::GetCursorPos(&mouse_screen_pos) != 0;
HWND focused_window = ::GetForegroundWindow(); HWND focused_window = ::GetForegroundWindow();
const bool is_app_focused = (focused_window == bd->hWnd); const bool is_app_focused = (focused_window && (focused_window == bd->hWnd || ::IsChild(focused_window, bd->hWnd) || ImGui::FindViewportByPlatformHandle((void*)focused_window)));
if (is_app_focused) if (is_app_focused)
{ {
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user) // (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
// When multi-viewports are enabled, all Dear ImGui positions are same as OS positions.
if (io.WantSetMousePos) if (io.WantSetMousePos)
{ {
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y }; POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
if (::ClientToScreen(bd->hWnd, &pos)) if ((io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) == 0)
::SetCursorPos(pos.x, pos.y); ::ClientToScreen(focused_window, &pos);
::SetCursorPos(pos.x, pos.y);
} }
// (Optional) Fallback to provide mouse position when focused (WM_MOUSEMOVE already provides this when hovered or captured) // (Optional) Fallback to provide mouse position when focused (WM_MOUSEMOVE already provides this when hovered or captured)
// This also fills a short gap when clicking non-client area: WM_NCMOUSELEAVE -> modal OS move -> gap -> WM_NCMOUSEMOVE // This also fills a short gap when clicking non-client area: WM_NCMOUSELEAVE -> modal OS move -> gap -> WM_NCMOUSEMOVE
if (!io.WantSetMousePos && bd->MouseTrackedArea == 0) if (!io.WantSetMousePos && bd->MouseTrackedArea == 0 && has_mouse_screen_pos)
{ {
POINT pos; // Single viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
if (::GetCursorPos(&pos) && ::ScreenToClient(bd->hWnd, &pos)) // (This is the position you can get with ::GetCursorPos() + ::ScreenToClient() or WM_MOUSEMOVE.)
io.AddMousePosEvent((float)pos.x, (float)pos.y); // Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
// (This is the position you can get with ::GetCursorPos() or WM_MOUSEMOVE + ::ClientToScreen(). In theory adding viewport->Pos to a client position would also be the same.)
POINT mouse_pos = mouse_screen_pos;
if (!(io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
::ScreenToClient(bd->hWnd, &mouse_pos);
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
} }
} }
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
// - [X] Win32 backend correctly ignore viewports with the _NoInputs flag (here using ::WindowFromPoint with WM_NCHITTEST + HTTRANSPARENT in WndProc does that)
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
// by the backend, and use its flawed heuristic to guess the viewport behind.
// - [X] Win32 backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
ImGuiID mouse_viewport_id = 0;
if (has_mouse_screen_pos)
if (HWND hovered_hwnd = ::WindowFromPoint(mouse_screen_pos))
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)hovered_hwnd))
mouse_viewport_id = viewport->ID;
io.AddMouseViewportEvent(mouse_viewport_id);
} }
// Gamepad navigation mapping // Gamepad navigation mapping
@ -384,6 +424,37 @@ static void ImGui_ImplWin32_UpdateGamepads()
#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD #endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
} }
static BOOL CALLBACK ImGui_ImplWin32_UpdateMonitors_EnumFunc(HMONITOR monitor, HDC, LPRECT, LPARAM)
{
MONITORINFO info = {};
info.cbSize = sizeof(MONITORINFO);
if (!::GetMonitorInfo(monitor, &info))
return TRUE;
ImGuiPlatformMonitor imgui_monitor;
imgui_monitor.MainPos = ImVec2((float)info.rcMonitor.left, (float)info.rcMonitor.top);
imgui_monitor.MainSize = ImVec2((float)(info.rcMonitor.right - info.rcMonitor.left), (float)(info.rcMonitor.bottom - info.rcMonitor.top));
imgui_monitor.WorkPos = ImVec2((float)info.rcWork.left, (float)info.rcWork.top);
imgui_monitor.WorkSize = ImVec2((float)(info.rcWork.right - info.rcWork.left), (float)(info.rcWork.bottom - info.rcWork.top));
imgui_monitor.DpiScale = ImGui_ImplWin32_GetDpiScaleForMonitor(monitor);
imgui_monitor.PlatformHandle = (void*)monitor;
if (imgui_monitor.DpiScale <= 0.0f)
return TRUE; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
ImGuiPlatformIO& io = ImGui::GetPlatformIO();
if (info.dwFlags & MONITORINFOF_PRIMARY)
io.Monitors.push_front(imgui_monitor);
else
io.Monitors.push_back(imgui_monitor);
return TRUE;
}
static void ImGui_ImplWin32_UpdateMonitors()
{
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
ImGui::GetPlatformIO().Monitors.resize(0);
::EnumDisplayMonitors(nullptr, nullptr, ImGui_ImplWin32_UpdateMonitors_EnumFunc, 0);
bd->WantUpdateMonitors = false;
}
void ImGui_ImplWin32_NewFrame() void ImGui_ImplWin32_NewFrame()
{ {
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData(); ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
@ -394,6 +465,8 @@ void ImGui_ImplWin32_NewFrame()
RECT rect = { 0, 0, 0, 0 }; RECT rect = { 0, 0, 0, 0 };
::GetClientRect(bd->hWnd, &rect); ::GetClientRect(bd->hWnd, &rect);
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top)); io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
if (bd->WantUpdateMonitors)
ImGui_ImplWin32_UpdateMonitors();
// Setup time step // Setup time step
INT64 current_time = 0; INT64 current_time = 0;
@ -610,8 +683,11 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
bd->MouseTrackedArea = area; bd->MouseTrackedArea = area;
} }
POINT mouse_pos = { (LONG)GET_X_LPARAM(lParam), (LONG)GET_Y_LPARAM(lParam) }; POINT mouse_pos = { (LONG)GET_X_LPARAM(lParam), (LONG)GET_Y_LPARAM(lParam) };
if (msg == WM_NCMOUSEMOVE && ::ScreenToClient(hwnd, &mouse_pos) == FALSE) // WM_NCMOUSEMOVE are provided in absolute coordinates. bool want_absolute_pos = (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) != 0;
return 0; if (msg == WM_MOUSEMOVE && want_absolute_pos) // WM_MOUSEMOVE are client-relative coordinates.
::ClientToScreen(hwnd, &mouse_pos);
if (msg == WM_NCMOUSEMOVE && !want_absolute_pos) // WM_NCMOUSEMOVE are absolute coordinates.
::ScreenToClient(hwnd, &mouse_pos);
io.AddMouseSourceEvent(mouse_source); io.AddMouseSourceEvent(mouse_source);
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y); io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
return 0; return 0;
@ -750,6 +826,9 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
bd->WantUpdateHasGamepad = true; bd->WantUpdateHasGamepad = true;
#endif #endif
return 0; return 0;
case WM_DISPLAYCHANGE:
bd->WantUpdateMonitors = true;
return 0;
} }
return 0; return 0;
} }
@ -814,6 +893,10 @@ typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWAR
// Helper function to enable DPI awareness without setting up a manifest // Helper function to enable DPI awareness without setting up a manifest
void ImGui_ImplWin32_EnableDpiAwareness() void ImGui_ImplWin32_EnableDpiAwareness()
{ {
// Make sure monitors will be updated with latest correct scaling
if (ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData())
bd->WantUpdateMonitors = true;
if (_IsWindows10OrGreater()) if (_IsWindows10OrGreater())
{ {
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
@ -913,6 +996,370 @@ void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd)
} }
} }
//---------------------------------------------------------------------------------------------------------
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
//--------------------------------------------------------------------------------------------------------
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
struct ImGui_ImplWin32_ViewportData
{
HWND Hwnd;
HWND HwndParent;
bool HwndOwned;
DWORD DwStyle;
DWORD DwExStyle;
ImGui_ImplWin32_ViewportData() { Hwnd = HwndParent = nullptr; HwndOwned = false; DwStyle = DwExStyle = 0; }
~ImGui_ImplWin32_ViewportData() { IM_ASSERT(Hwnd == nullptr); }
};
static void ImGui_ImplWin32_GetWin32StyleFromViewportFlags(ImGuiViewportFlags flags, DWORD* out_style, DWORD* out_ex_style)
{
if (flags & ImGuiViewportFlags_NoDecoration)
*out_style = WS_POPUP;
else
*out_style = WS_OVERLAPPEDWINDOW;
if (flags & ImGuiViewportFlags_NoTaskBarIcon)
*out_ex_style = WS_EX_TOOLWINDOW;
else
*out_ex_style = WS_EX_APPWINDOW;
if (flags & ImGuiViewportFlags_TopMost)
*out_ex_style |= WS_EX_TOPMOST;
}
static HWND ImGui_ImplWin32_GetHwndFromViewportID(ImGuiID viewport_id)
{
if (viewport_id != 0)
if (ImGuiViewport* viewport = ImGui::FindViewportByID(viewport_id))
return (HWND)viewport->PlatformHandle;
return nullptr;
}
static void ImGui_ImplWin32_CreateWindow(ImGuiViewport* viewport)
{
ImGui_ImplWin32_ViewportData* vd = IM_NEW(ImGui_ImplWin32_ViewportData)();
viewport->PlatformUserData = vd;
// Select style and parent window
ImGui_ImplWin32_GetWin32StyleFromViewportFlags(viewport->Flags, &vd->DwStyle, &vd->DwExStyle);
vd->HwndParent = ImGui_ImplWin32_GetHwndFromViewportID(viewport->ParentViewportId);
// Create window
RECT rect = { (LONG)viewport->Pos.x, (LONG)viewport->Pos.y, (LONG)(viewport->Pos.x + viewport->Size.x), (LONG)(viewport->Pos.y + viewport->Size.y) };
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle);
vd->Hwnd = ::CreateWindowEx(
vd->DwExStyle, _T("ImGui Platform"), _T("Untitled"), vd->DwStyle, // Style, class name, window name
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, // Window area
vd->HwndParent, nullptr, ::GetModuleHandle(nullptr), nullptr); // Owner window, Menu, Instance, Param
vd->HwndOwned = true;
viewport->PlatformRequestResize = false;
viewport->PlatformHandle = viewport->PlatformHandleRaw = vd->Hwnd;
// Secondary viewports store their imgui context
::SetPropA(vd->Hwnd, "IMGUI_CONTEXT", ImGui::GetCurrentContext());
}
static void ImGui_ImplWin32_DestroyWindow(ImGuiViewport* viewport)
{
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
if (ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData)
{
if (::GetCapture() == vd->Hwnd)
{
// Transfer capture so if we started dragging from a window that later disappears, we'll still receive the MOUSEUP event.
::ReleaseCapture();
::SetCapture(bd->hWnd);
}
if (vd->Hwnd && vd->HwndOwned)
::DestroyWindow(vd->Hwnd);
vd->Hwnd = nullptr;
IM_DELETE(vd);
}
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
}
static void ImGui_ImplWin32_ShowWindow(ImGuiViewport* viewport)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
// ShowParent() also brings parent to front, which is not always desirable,
// so we temporarily disable parenting. (#7354)
if (vd->HwndParent != NULL)
::SetWindowLongPtr(vd->Hwnd, GWLP_HWNDPARENT, (LONG_PTR)nullptr);
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
::ShowWindow(vd->Hwnd, SW_SHOWNA);
else
::ShowWindow(vd->Hwnd, SW_SHOW);
// Restore
if (vd->HwndParent != NULL)
::SetWindowLongPtr(vd->Hwnd, GWLP_HWNDPARENT, (LONG_PTR)vd->HwndParent);
}
static void ImGui_ImplWin32_UpdateWindow(ImGuiViewport* viewport)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
// Update Win32 parent if it changed _after_ creation
// Unlike style settings derived from configuration flags, this is more likely to change for advanced apps that are manipulating ParentViewportID manually.
HWND new_parent = ImGui_ImplWin32_GetHwndFromViewportID(viewport->ParentViewportId);
if (new_parent != vd->HwndParent)
{
// Win32 windows can either have a "Parent" (for WS_CHILD window) or an "Owner" (which among other thing keeps window above its owner).
// Our Dear Imgui-side concept of parenting only mostly care about what Win32 call "Owner".
// The parent parameter of CreateWindowEx() sets up Parent OR Owner depending on WS_CHILD flag. In our case an Owner as we never use WS_CHILD.
// Calling ::SetParent() here would be incorrect: it will create a full child relation, alter coordinate system and clipping.
// Calling ::SetWindowLongPtr() with GWLP_HWNDPARENT seems correct although poorly documented.
// https://devblogs.microsoft.com/oldnewthing/20100315-00/?p=14613
vd->HwndParent = new_parent;
::SetWindowLongPtr(vd->Hwnd, GWLP_HWNDPARENT, (LONG_PTR)vd->HwndParent);
}
// (Optional) Update Win32 style if it changed _after_ creation.
// Generally they won't change unless configuration flags are changed, but advanced uses (such as manually rewriting viewport flags) make this useful.
DWORD new_style;
DWORD new_ex_style;
ImGui_ImplWin32_GetWin32StyleFromViewportFlags(viewport->Flags, &new_style, &new_ex_style);
// Only reapply the flags that have been changed from our point of view (as other flags are being modified by Windows)
if (vd->DwStyle != new_style || vd->DwExStyle != new_ex_style)
{
// (Optional) Update TopMost state if it changed _after_ creation
bool top_most_changed = (vd->DwExStyle & WS_EX_TOPMOST) != (new_ex_style & WS_EX_TOPMOST);
HWND insert_after = top_most_changed ? ((viewport->Flags & ImGuiViewportFlags_TopMost) ? HWND_TOPMOST : HWND_NOTOPMOST) : 0;
UINT swp_flag = top_most_changed ? 0 : SWP_NOZORDER;
// Apply flags and position (since it is affected by flags)
vd->DwStyle = new_style;
vd->DwExStyle = new_ex_style;
::SetWindowLong(vd->Hwnd, GWL_STYLE, vd->DwStyle);
::SetWindowLong(vd->Hwnd, GWL_EXSTYLE, vd->DwExStyle);
RECT rect = { (LONG)viewport->Pos.x, (LONG)viewport->Pos.y, (LONG)(viewport->Pos.x + viewport->Size.x), (LONG)(viewport->Pos.y + viewport->Size.y) };
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle); // Client to Screen
::SetWindowPos(vd->Hwnd, insert_after, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, swp_flag | SWP_NOACTIVATE | SWP_FRAMECHANGED);
::ShowWindow(vd->Hwnd, SW_SHOWNA); // This is necessary when we alter the style
viewport->PlatformRequestMove = viewport->PlatformRequestResize = true;
}
}
static ImVec2 ImGui_ImplWin32_GetWindowPos(ImGuiViewport* viewport)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
POINT pos = { 0, 0 };
::ClientToScreen(vd->Hwnd, &pos);
return ImVec2((float)pos.x, (float)pos.y);
}
static void ImGui_ImplWin32_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
RECT rect = { (LONG)pos.x, (LONG)pos.y, (LONG)pos.x, (LONG)pos.y };
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle);
::SetWindowPos(vd->Hwnd, nullptr, rect.left, rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
}
static ImVec2 ImGui_ImplWin32_GetWindowSize(ImGuiViewport* viewport)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
RECT rect;
::GetClientRect(vd->Hwnd, &rect);
return ImVec2(float(rect.right - rect.left), float(rect.bottom - rect.top));
}
static void ImGui_ImplWin32_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
RECT rect = { 0, 0, (LONG)size.x, (LONG)size.y };
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle); // Client to Screen
::SetWindowPos(vd->Hwnd, nullptr, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
}
static void ImGui_ImplWin32_SetWindowFocus(ImGuiViewport* viewport)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
::BringWindowToTop(vd->Hwnd);
::SetForegroundWindow(vd->Hwnd);
::SetFocus(vd->Hwnd);
}
static bool ImGui_ImplWin32_GetWindowFocus(ImGuiViewport* viewport)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
return ::GetForegroundWindow() == vd->Hwnd;
}
static bool ImGui_ImplWin32_GetWindowMinimized(ImGuiViewport* viewport)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
return ::IsIconic(vd->Hwnd) != 0;
}
static void ImGui_ImplWin32_SetWindowTitle(ImGuiViewport* viewport, const char* title)
{
// ::SetWindowTextA() doesn't properly handle UTF-8 so we explicitely convert our string.
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
int n = ::MultiByteToWideChar(CP_UTF8, 0, title, -1, nullptr, 0);
ImVector<wchar_t> title_w;
title_w.resize(n);
::MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w.Data, n);
::SetWindowTextW(vd->Hwnd, title_w.Data);
}
static void ImGui_ImplWin32_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
IM_ASSERT(alpha >= 0.0f && alpha <= 1.0f);
if (alpha < 1.0f)
{
DWORD style = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE) | WS_EX_LAYERED;
::SetWindowLongW(vd->Hwnd, GWL_EXSTYLE, style);
::SetLayeredWindowAttributes(vd->Hwnd, 0, (BYTE)(255 * alpha), LWA_ALPHA);
}
else
{
DWORD style = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED;
::SetWindowLongW(vd->Hwnd, GWL_EXSTYLE, style);
}
}
static float ImGui_ImplWin32_GetWindowDpiScale(ImGuiViewport* viewport)
{
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
IM_ASSERT(vd->Hwnd != 0);
return ImGui_ImplWin32_GetDpiScaleForHwnd(vd->Hwnd);
}
// FIXME-DPI: Testing DPI related ideas
static void ImGui_ImplWin32_OnChangedViewport(ImGuiViewport* viewport)
{
(void)viewport;
#if 0
ImGuiStyle default_style;
//default_style.WindowPadding = ImVec2(0, 0);
//default_style.WindowBorderSize = 0.0f;
//default_style.ItemSpacing.y = 3.0f;
//default_style.FramePadding = ImVec2(0, 0);
default_style.ScaleAllSizes(viewport->DpiScale);
ImGuiStyle& style = ImGui::GetStyle();
style = default_style;
#endif
}
static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
// Allow secondary viewport WndProc to be called regardless of current context
ImGuiContext* hwnd_ctx = (ImGuiContext*)::GetPropA(hWnd, "IMGUI_CONTEXT");
ImGuiContext* prev_ctx = ImGui::GetCurrentContext();
if (hwnd_ctx != prev_ctx && hwnd_ctx != NULL)
ImGui::SetCurrentContext(hwnd_ctx);
LRESULT result = 0;
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
result = true;
else if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)hWnd))
{
switch (msg)
{
case WM_CLOSE:
viewport->PlatformRequestClose = true;
break;
case WM_MOVE:
viewport->PlatformRequestMove = true;
break;
case WM_SIZE:
viewport->PlatformRequestResize = true;
break;
case WM_MOUSEACTIVATE:
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnClick)
result = MA_NOACTIVATE;
break;
case WM_NCHITTEST:
// Let mouse pass-through the window. This will allow the backend to call io.AddMouseViewportEvent() correctly. (which is optional).
// The ImGuiViewportFlags_NoInputs flag is set while dragging a viewport, as want to detect the window behind the one we are dragging.
// If you cannot easily access those viewport flags from your windowing/event code: you may manually synchronize its state e.g. in
// your main loop after calling UpdatePlatformWindows(). Iterate all viewports/platform windows and pass the flag to your windowing system.
if (viewport->Flags & ImGuiViewportFlags_NoInputs)
result = HTTRANSPARENT;
break;
}
}
if (result == 0)
result = DefWindowProc(hWnd, msg, wParam, lParam);
if (hwnd_ctx != prev_ctx && hwnd_ctx != NULL)
ImGui::SetCurrentContext(prev_ctx);
return result;
}
static void ImGui_ImplWin32_InitPlatformInterface(bool platform_has_own_dc)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW | (platform_has_own_dc ? CS_OWNDC : 0);
wcex.lpfnWndProc = ImGui_ImplWin32_WndProcHandler_PlatformWindow;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = ::GetModuleHandle(nullptr);
wcex.hIcon = nullptr;
wcex.hCursor = nullptr;
wcex.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
wcex.lpszMenuName = nullptr;
wcex.lpszClassName = _T("ImGui Platform");
wcex.hIconSm = nullptr;
::RegisterClassEx(&wcex);
ImGui_ImplWin32_UpdateMonitors();
// Register platform interface (will be coupled with a renderer interface)
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_CreateWindow = ImGui_ImplWin32_CreateWindow;
platform_io.Platform_DestroyWindow = ImGui_ImplWin32_DestroyWindow;
platform_io.Platform_ShowWindow = ImGui_ImplWin32_ShowWindow;
platform_io.Platform_SetWindowPos = ImGui_ImplWin32_SetWindowPos;
platform_io.Platform_GetWindowPos = ImGui_ImplWin32_GetWindowPos;
platform_io.Platform_SetWindowSize = ImGui_ImplWin32_SetWindowSize;
platform_io.Platform_GetWindowSize = ImGui_ImplWin32_GetWindowSize;
platform_io.Platform_SetWindowFocus = ImGui_ImplWin32_SetWindowFocus;
platform_io.Platform_GetWindowFocus = ImGui_ImplWin32_GetWindowFocus;
platform_io.Platform_GetWindowMinimized = ImGui_ImplWin32_GetWindowMinimized;
platform_io.Platform_SetWindowTitle = ImGui_ImplWin32_SetWindowTitle;
platform_io.Platform_SetWindowAlpha = ImGui_ImplWin32_SetWindowAlpha;
platform_io.Platform_UpdateWindow = ImGui_ImplWin32_UpdateWindow;
platform_io.Platform_GetWindowDpiScale = ImGui_ImplWin32_GetWindowDpiScale; // FIXME-DPI
platform_io.Platform_OnChangedViewport = ImGui_ImplWin32_OnChangedViewport; // FIXME-DPI
// Register main window handle (which is owned by the main application, not by us)
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
ImGui_ImplWin32_ViewportData* vd = IM_NEW(ImGui_ImplWin32_ViewportData)();
vd->Hwnd = bd->hWnd;
vd->HwndOwned = false;
main_viewport->PlatformUserData = vd;
main_viewport->PlatformHandle = (void*)bd->hWnd;
}
static void ImGui_ImplWin32_ShutdownPlatformInterface()
{
::UnregisterClass(_T("ImGui Platform"), ::GetModuleHandle(nullptr));
ImGui::DestroyPlatformWindows();
}
//--------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------
#if defined(__GNUC__) #if defined(__GNUC__)

View File

@ -7,6 +7,7 @@
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.

View File

@ -118,6 +118,16 @@ Other changes:
to handle minimization without burning CPU or GPU by running unthrottled code. (#7844) to handle minimization without burning CPU or GPU by running unthrottled code. (#7844)
- Examples: SDL3: Update for API changes: SDL_Init() returns 0 on failure. - Examples: SDL3: Update for API changes: SDL_Init() returns 0 on failure.
Docking+Viewports Branch:
- Viewports: added optional platform_io.Platform_GetWindowWorkAreaInsets() hook
to allow backends to alter the default per-viewport work-area. (#7823)
- Backends: don't report monitors with DpiScale of 0, which seemed to be reported for
virtual monitors instead by accessibility drivers. (#7902) [@nicolasnoble, @ocornut]
- Backends: SDL2, SDL3: using SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN to support the
ImGuiViewportFlags_NoFocusOnAppearing flag, instead of using a Win32-specific hack.
(#7896) [@RT2Code]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.91.0 (Released 2024-07-30) VERSION 1.91.0 (Released 2024-07-30)
----------------------------------------------------------------------- -----------------------------------------------------------------------
@ -277,6 +287,16 @@ Other changes:
- Backends: GLFW+Emscripten: Fixed Emscripten warning when using mouse wheel on some setups - Backends: GLFW+Emscripten: Fixed Emscripten warning when using mouse wheel on some setups
"Unable to preventDefault inside passive event listener". (#7647, #7600) [@ypujante] "Unable to preventDefault inside passive event listener". (#7647, #7600) [@ypujante]
Docking+Viewports Branch:
- Viewports: Always update fallback monitor to primary monitor if there's one.
- Backends: OSX: Fixed NSAppKitVersion version limit for setWantsBestResolutionOpenGLSurface
usage. (#7814) [@YGXXD]
- Backends: SDL3: Fixed a bug preventing ImGuiViewportFlags_NoFocusOnAppearing support from
working (Windows only).
- Backends: Vulkan: ImGui_ImplVulkan_SwapBuffers() used by secondary viewports still proceeds
increasing frame counters on VK_SUBOPTIMAL_KHR. (#7825, #3881) [@NostraMagister]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.90.9 (Released 2024-07-01) VERSION 1.90.9 (Released 2024-07-01)
@ -357,6 +377,19 @@ Other changes:
returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671) returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671)
[@AndreiNego, @ocornut] [@AndreiNego, @ocornut]
Docking+Viewports Branch:
- Windows, Menus: Fixed an issue where the size of sub-menu in their own viewport
would be erroneously clamped to the size of main viewport. (#7730)
- Merged GetBackgroundDrawList() and GetBackgroundDrawList(ImGuiViewport* viewport)
api entry points into a same one GetBackgroundDrawList(ImGuiViewport* viewport = NULL);
- Merged GetForegroundDrawList() and GetForegroundDrawList(ImGuiViewport* viewport)
api entry points into a same one GetForegroundDrawList(ImGuiViewport* viewport = NULL);
- Backends: SDL3: Update for introduction of SDL_GLContext from void*. (#7701, #7702)
[@bcsanches]
- Backends: Win32: Secondary viewports WndProc handler retrieve/set imgui context from
the HWND, allowing WndProc dispatch to work in multi-context setups.
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.90.8 (Released 2024-06-06) VERSION 1.90.8 (Released 2024-06-06)
@ -507,6 +540,15 @@ versions of IsKeyPressed(), IsKeyChordPressed(), IsMouseClicked() prior to this
those API public. Only past users of imgui_internal.h with the extra parameters will be affected. those API public. Only past users of imgui_internal.h with the extra parameters will be affected.
Added asserts for valid flags in various functions to detect _some_ misuses, BUT NOT ALL. Added asserts for valid flags in various functions to detect _some_ misuses, BUT NOT ALL.
Docking+Viewports Branch:
- Docking: *BREAKING* changed signature of DockSpaceOverViewport() to allow passing
an explicit dockspace id if desired. (#7611)
Before: DockSpaceOverViewport(const ImGuiViewport* viewport = NULL, ImGuiDockNodeFlags flags = 0, ...);
After: DockSpaceOverViewport(ImGuiID dockspace_id = 0, const ImGuiViewport* viewport = NULL, ImGuiDockNodeFlags flags = 0, ...);
Simply add a leading 0 to your existing calls to DockSpaceOverViewport() if you have any.
- Tables: resizing border hit-rect scales according to current monitor dpi scale.
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.90.6 (Released 2024-05-08) VERSION 1.90.6 (Released 2024-05-08)
@ -565,6 +607,18 @@ Other changes:
- Examples: GLFW+WebGPU: Added support for WebGPU-native/Dawn (#7435, #7132) [@eliasdaler, @Zelif] - Examples: GLFW+WebGPU: Added support for WebGPU-native/Dawn (#7435, #7132) [@eliasdaler, @Zelif]
- Examples: GLFW+WebGPU: Renamed example_emscripten_wgpu/ to example_glfw_wgpu/. (#7435, #7132) - Examples: GLFW+WebGPU: Renamed example_emscripten_wgpu/ to example_glfw_wgpu/. (#7435, #7132)
Docking+Viewports Branch:
- Docking: when io.ConfigDockingWithShift is enabled, fixed help tooltip erroneously
reading SetNextWindowXXX() data. (#6709, #4643, #7491) [@ocornut, @cfillion]
- Viewports: fixed outer-right edge of MenuBar clipping rectangle off by one when window
is located on a monitor with negative coordinates. (#6861, #2884) [@cfillion]
- Backends: Vulkan: reworked swap-chain resize handling for secondary viewports, fix for
typical Linux setups. (#2626, #3390, #3758, #7508, #7513) [@RoryO, @InsideBSITheSecond]
- Backends: Vulkan: create a custom pipeline for secondary viewports. Fixes issues
when user created main viewport uses a different renderpass. (#6325, #6305, #7398,
#3459, #3253, #3522) [@skaman, @FunMiles]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.90.5 (Released 2024-04-11) VERSION 1.90.5 (Released 2024-04-11)
@ -621,6 +675,11 @@ Other changes:
Adding a link to the crawlable version, even though it is not intended for humans, Adding a link to the crawlable version, even though it is not intended for humans,
to increase its search rank. to increase its search rank.
Docking+Viewports Branch:
- Backends: Win32: made it so that an appearing viewport showing up doesn't bring
its parent to front. (#7354)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.90.4 (Released 2024-02-22) VERSION 1.90.4 (Released 2024-02-22)
@ -654,6 +713,13 @@ Other changes:
- Demo: Custom Rendering: better demonstrate PathArcTo(), PathBezierQuadraticCurveTo(), - Demo: Custom Rendering: better demonstrate PathArcTo(), PathBezierQuadraticCurveTo(),
PathBezierCubicCurveTo(), PathStroke(), PathFillConvex() functions. PathBezierCubicCurveTo(), PathStroke(), PathFillConvex() functions.
Docking+Viewports Branch:
- Backends: GLFW: enable ImGuiBackendFlags_HasMouseHoveredViewport support with GLFW 3.3.x,
as required specs for it was relaxed in 1.87. This enable better viewport hovering detection
without GLFW 3.4's GLFW_MOUSE_PASSTHROUGH, with less reliance on dear imgui's own heuristic
of platform windows order. (#7316)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.90.3 (Released 2024-02-14) VERSION 1.90.3 (Released 2024-02-14)
@ -742,6 +808,18 @@ Other changes:
Often requested in some form (#6962, #5219, #3290, #4627, #5054, #3878, #2881, #1506, #1216, #968), Often requested in some form (#6962, #5219, #3290, #4627, #5054, #3878, #2881, #1506, #1216, #968),
and useful for interactive completion/suggestions popups (#2057, #718) and useful for interactive completion/suggestions popups (#2057, #718)
Docking+Viewports Branch:
- Added ImGuiWindowClass::FocusRouteParentWindowId as a way to connect the focus route between
a tool window to a parent document window, so that Shortcuts in the documents are routed when the
tool is focused (regardless of whether the tool is docked or in a floating viewport, etc.) (#6798)
- Added ImGuiDockNodeFlags_DockedWindowsInFocusRoute to automatically make a dockspace connect
the focus route of its docked window. This is provided a convenience in case you have windows
where a connection is not explicit. (#6798)
- Viewports: Fixed moving accross monitors when io.ConfigWindowsMoveFromTitleBarOnly is set. (#7299, #3071)
- Backends: OSX: Fixed not submitting Monitors info when viewports are not enabled, leading to
missing e.g. DpiScale info. (#7257) [@actboy168]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.90.1 (Released 2024-01-10) VERSION 1.90.1 (Released 2024-01-10)
@ -846,6 +924,15 @@ Other changes:
(#6751) [@Traveller23, @ypujante] (#6751) [@Traveller23, @ypujante]
- Examples: SDL3: Minor fixes following recent SDL3 in-progress development. - Examples: SDL3: Minor fixes following recent SDL3 in-progress development.
Docking+Viewports Branch:
- Windows: Fixed ImGuiCol_TitleBg/Active alpha being used for viewport-owned windows. (#7181) [@PathogenDavid]
- Backends: DX12: Changed swapchain scaling mode to DXGI_SCALING_NONE to reduce artifacts as
queued frames aren't synchronized with platform window resizes. (#7152, #7153) [@SuperWangKai]
- Backends: OSX: Fixed monitor and window position by correctly transforming Y origin on multi-viewports
multi-monitor setups. (#7028, #7101, #6009, #6432) [@dmirty-kuzmenko, @734vin]
- Backends: OSX: Fixed IME position in multi-monitor multi-viewports setups. (#7028) [@734vin]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.90.0 (Released 2023-11-15) VERSION 1.90.0 (Released 2023-11-15)
@ -1040,6 +1127,8 @@ Other changes:
Fixed leaks, and added ImGui_ImplVulkan_DestroyFontsTexture() (probably no need to call this directly). Fixed leaks, and added ImGui_ImplVulkan_DestroyFontsTexture() (probably no need to call this directly).
(#6943, #6715, #6327, #3743, #4618) (#6943, #6715, #6327, #3743, #4618)
[@helynranta, @thomasherzog, @guybrush77, @albin-johansson, @MiroKaku, @benbatya-fb, @ocornut] [@helynranta, @thomasherzog, @guybrush77, @albin-johansson, @MiroKaku, @benbatya-fb, @ocornut]
- Backends: Vulkan: use specified ColorAttachmentFormat when creating a secondary window when enabling
UseDynamicRendering option. (#6999, #5446, #5037) [@raaaviol]
- Backends: GLFW: Clear emscripten's MouseWheel callback before shutdown. (#6790, #6096, #4019) [@halx99] - Backends: GLFW: Clear emscripten's MouseWheel callback before shutdown. (#6790, #6096, #4019) [@halx99]
- Backends: GLFW: Added support for F13 to F24 function keys. (#6891) - Backends: GLFW: Added support for F13 to F24 function keys. (#6891)
- Backends: SDL2, SDL3: Added support for F13 to F24 function keys, AppBack, AppForward. (#6891) - Backends: SDL2, SDL3: Added support for F13 to F24 function keys, AppBack, AppForward. (#6891)
@ -1057,6 +1146,31 @@ Other changes:
- Examples: GLFW+Vulkan, SDL+Vulkan: Simplified and removed code due to backend improvements. - Examples: GLFW+Vulkan, SDL+Vulkan: Simplified and removed code due to backend improvements.
- Internals: Renamed ImFloor() to ImTrunc(). Renamed ImFloorSigned() to ImFloor(). (#6861) - Internals: Renamed ImFloor() to ImTrunc(). Renamed ImFloorSigned() to ImFloor(). (#6861)
Docking+Viewports Branch:
- Viewports: Fixed window inner clipping rectangle off by one when window is located on a monitor
with negative coordinates. While it is expected that other small issues with arise from this
situation, at the moment we are fixing the most noticeable one. (#6861, #2884) [@Vuhdo, @alektron]
- Docking: revised undocking to reduce accidental whole-node undocking:
- cannot undock a whole node by dragging from empty space in tab-bar.
- can undock whole node by dragging from window/collapse menu button.
- can undock single window by dragging from its tab.
- can still move (but not undock) whole node or whole hierarchy when node is part of a
floating hierarchy.
- added tooltip when hovering the collapse/window menu button, to faciliate understanding
that whole dock node may be undocked or grabbed from here.
- Docking: Fixed an issue leading to incorrect restoration of selected tab in dock nodes that
don't carry the currently focused window. (#2304)
- Docking: added ImGuiDockNodeFlags_NoUndocking. (#2999, #6823, #6780, #3492)
- Docking: renamed ImGuiDockNodeFlags_NoSplit to ImGuiDockNodeFlags_NoDockingSplit.
- Docking: renamed ImGuiDockNodeFlags_NoDockingInCentralNode to ImGuiDockNodeFlags_NoDockingOverCentralNode.
- Docking: Internals: renamed ImGuiDockNodeFlags_NoDockingSplitMe to ImGuiDockNodeFlags_NoDockingSplit.
- Docking: Fixed a bug where ClassId compare tests (when using SetNextWindowClass) on success would
prevent further filter from running, namely the one that prevent docking over a popup.
- Backends: GLFW: Fixed an assertion in situation where the WndProc handler is different between
main and secondary viewport (may happen due to third-party hooks). (#6889)
- Backends: DX9: Fixed incorrect assert triggering on reopening session with minimized windows. (#3424)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89.9 (Released 2023-09-04) VERSION 1.89.9 (Released 2023-09-04)
@ -1114,6 +1228,11 @@ Other changes:
- Examples: Emscripten+WebGPU: Fixed WGPUInstance creation process + use preferred - Examples: Emscripten+WebGPU: Fixed WGPUInstance creation process + use preferred
framebuffer format. (#6640, #6748) [@smileorigin] framebuffer format. (#6640, #6748) [@smileorigin]
Docking+Viewports Branch:
- Docking: when io.ConfigDockingWithShift is enabled, staying stationary while moving
a window displays an help tooltip to increase affordance. (#6709, #4643)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89.8 (Released 2023-08-01) VERSION 1.89.8 (Released 2023-08-01)
@ -1182,6 +1301,16 @@ Other changes:
- Examples: Vulkan: Creating minimal descriptor pools to fit only what is needed by - Examples: Vulkan: Creating minimal descriptor pools to fit only what is needed by
example. (#6642) [@SaschaWillem] example. (#6642) [@SaschaWillem]
Docking+Viewports Branch:
- Docking, Style: resizing separators use same colors as window borders (ImGuiCol_Border)
for consistency. With default styles it doesn't make a big difference. (#2522) [@rmitton]
In the future if we promote using thick value for inner/outer docking padding we may
need to introduce new colors for it.
- Docking: added style.DockingSeparatorSize, ImGuiStyleVar_DockingSeparatorSize. Now
also scaled by style.ScaleAllSizes(). (#3481, #4721, #2522) [@PossiblyAShrub, @wobbier]
- Docking: fixed rendering of docked-window scrollbar above outer border. (#2522)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89.7 (Released 2023-07-04) VERSION 1.89.7 (Released 2023-07-04)
@ -1277,6 +1406,23 @@ Other changes:
- Examples: Win32+OpenGL3: Changed DefWindowProc() to DefWindowProcW() to match other examples - Examples: Win32+OpenGL3: Changed DefWindowProc() to DefWindowProcW() to match other examples
and support the example app being compiled without UNICODE. (#6516, #5725, #5961, #5975) [@yenixing] and support the example app being compiled without UNICODE. (#6516, #5725, #5961, #5975) [@yenixing]
Docking+Viewports Branch:
- Viewports+Docking: Fixed extraneous viewport+platform-window recreation in various
combination of showing or hiding windows, docking with/without split, undocking.
While with some backends and without OS decorations, some extraneous window recreation
were visibly not noticeable, they would typically become noticeable when enabling
OS decorations on those windows (e.g. Windows title bar fade-in/animation).
- Viewports: Closing a viewport via OS/platform means (e.g. OS close button or task-bar menu),
mark all windows in this viewport as closed.
- Docking: Fixed one-frame flickering on reappearing windows binding to a dock node
where a later-submitted window was already bound.
- Docking: Fixed dragging from title-bar empty space (regression from 1.88 related to
keeping ID alive when calling low-level ButtonBehavior() directly). (#5181, #2645)
- Docking: [Internal] DockBuilderDockWindow() API calls don't clear docking order
if the target node is same as existing one.
- Backends: Win32: Added support for changing ParentViewportID after viewport creation.
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89.6 (Released 2023-05-31) VERSION 1.89.6 (Released 2023-05-31)
@ -1346,6 +1492,23 @@ Other changes:
- Examples: Added SDL3+SDL_Renderer example. (#6286) - Examples: Added SDL3+SDL_Renderer example. (#6286)
- Examples: Updated all Visual Studio projects and batches to use /utf-8 argument. - Examples: Updated all Visual Studio projects and batches to use /utf-8 argument.
Docking+Viewports Branch:
- Viewports: Fixed platform-side focus (e.g. Alt+Tab) from leading to accidental
closure of Modal windows. Regression from 1.89.5. (#6357, #6299)
- Viewports: Fixed loss of imgui-side focus when dragging a secondary viewport back in
main viewport, due to platform-side handling changes. Regression from 1.89.5 (#6299)
- Viewports: Avoid applying imgui-side focus when focus change is due to a viewport
destruction. Fixes erroneous popup closure on closing a previous popup. (#6462, #6299)
- Viewports: Added void* ImGuiPlatformMonitor::PlatformHandle field (backend-dependant),
for usage by user code.
- Backends: GLFW: Preserve monitor list when there are no monitor, may briefly
happen when recovering from macOS sleeping mode. (#5683) [@Guistac]
- Backends: SDL2: Update monitor list when receiving a display event. (#6348)
Note however that SDL2 currently doesn't have an event for a DPI/Scaling change,
so monitor data won't be updated in this situation.
- Backends: SDL3: Update monitor list when receiving a display event. (#6348)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89.5 (Released 2023-04-13) VERSION 1.89.5 (Released 2023-04-13)
@ -1403,7 +1566,6 @@ Other changes:
is to other IME function such as SDL_SetTextInputRect(). (#6306, #6071, #1953) is to other IME function such as SDL_SetTextInputRect(). (#6306, #6071, #1953)
- Backends: GLFW: Added support on Win32 only for io.AddMouseSourceEvent() to discriminate - Backends: GLFW: Added support on Win32 only for io.AddMouseSourceEvent() to discriminate
Mouse/TouchScreen/Pen. (#2334, #2702) Mouse/TouchScreen/Pen. (#2334, #2702)
- Backends: GLFW: Fixed key modifiers handling on secondary viewports. (#6248, #6034) [@aiekick]
- Backends: Android: Added support for io.AddMouseSourceEvent() to discriminate Mouse/TouchScreen/Pen. - Backends: Android: Added support for io.AddMouseSourceEvent() to discriminate Mouse/TouchScreen/Pen.
(#6315) [@PathogenDavid] (#6315) [@PathogenDavid]
- Backends: OSX: Added support for io.AddMouseSourceEvent() to discriminate Mouse/Pen. - Backends: OSX: Added support for io.AddMouseSourceEvent() to discriminate Mouse/Pen.
@ -1419,6 +1581,16 @@ Other changes:
- TestSuite: Added variety of new regression tests and improved/amended existing ones - TestSuite: Added variety of new regression tests and improved/amended existing ones
in imgui_test_engine/ repo. [@PathogenDavid, @ocornut] in imgui_test_engine/ repo. [@PathogenDavid, @ocornut]
Docking+Viewports Branch:
- Viewports: Setting focus from Platform/OS (e.g. via decoration, or Alt-Tab) sets corresponding
focus at Dear ImGui level (generally last focused window in the viewport). (#6299)
- Docking: Fixed using GetItemXXX() or IsItemXXX() functions after a DockSpace(). (#6217)
- Backends: GLFW: Fixed key modifiers handling on secondary viewports. (#6248, #6034) [@aiekick]
- Backends: GLFW: Fixed Emscripten erroneously enabling multi-viewport support, leading to assert. (#5683)
- Backends: SDL2/SDL3: Fixed IME text input rectangle position with viewports. (#6071, #1953)
- Backends: SDL3: Fixed for compilation with multi-viewports. (#6255) [@P3RK4N]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89.4 (Released 2023-03-14) VERSION 1.89.4 (Released 2023-03-14)
@ -1493,7 +1665,6 @@ Other changes:
and ImGuiConfigFlags_NavEnableGamepad by default. (#787) and ImGuiConfigFlags_NavEnableGamepad by default. (#787)
- Internals: Misc tweaks to facilitate applying an explicit-context patch. (#5856) [@Dragnalith] - Internals: Misc tweaks to facilitate applying an explicit-context patch. (#5856) [@Dragnalith]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89.3 (Released 2023-02-14) VERSION 1.89.3 (Released 2023-02-14)
----------------------------------------------------------------------- -----------------------------------------------------------------------
@ -1594,6 +1765,10 @@ Other changes:
- Examples: SDL2+SDL_Renderer: Added call to SDL_RenderSetScale() to fix display on a - Examples: SDL2+SDL_Renderer: Added call to SDL_RenderSetScale() to fix display on a
Retina display (albeit lower-res as our other unmodified examples). (#6121, #6065, #5931). Retina display (albeit lower-res as our other unmodified examples). (#6121, #6065, #5931).
Docking+Viewports Branch:
- Backends: GLFW: Handle unsupported glfwGetVideoMode() for Emscripten. (#6096)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89.2 (Released 2023-01-05) VERSION 1.89.2 (Released 2023-01-05)
@ -1644,6 +1819,17 @@ All changes:
- Backends: Vulkan: Fixed sampler passed to ImGui_ImplVulkan_AddTexture() not being honored as we were using - Backends: Vulkan: Fixed sampler passed to ImGui_ImplVulkan_AddTexture() not being honored as we were using
an immutable sampler. (#5502, #6001, #914) [@martin-ejdestig, @rytisss] an immutable sampler. (#5502, #6001, #914) [@martin-ejdestig, @rytisss]
Docking+Viewports Branch:
- Docking: Internals: fixed DockBuilderCopyDockSpace() crashing when windows not in the
remapping list are docked on the left or top side of a split. (#6035)
- Docking: fixed DockSpace() with ImGuiDockNodeFlags_KeepAliveOnly marking current window
as written to, even if it doesn't technically submit an item. This allow using KeepAliveOnly
from any window location. (#6037)
- Backends: OSX: fixed typo in ImGui_ImplOSX_GetWindowSize that would cause issues when resiing
from OS decorations, if they are enabled on secondary viewports. (#6009) [@sivu]
- Backends: Metal: fixed secondary viewport rendering. (#6015) [@dmirty-kuzmenko]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89.1 (Released 2022-11-24) VERSION 1.89.1 (Released 2022-11-24)
@ -1670,6 +1856,13 @@ Other changes:
- Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908) - Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908)
- Backends: WebGPU: fixed validation error with default depth buffer settings. (#5869, #5914) [@kdchambers] - Backends: WebGPU: fixed validation error with default depth buffer settings. (#5869, #5914) [@kdchambers]
Docking+Viewports Branch:
- Viewports: Fixed collapsed windows setting ImGuiViewportFlags_NoRendererClear without
making title bar color opaque, leading to potential texture/fb garbage being visible.
Right now as we don't fully support transparent viewports (#2766), so we turn that
'TitleBgCollapsed' color opaque just lke we do for 'WindowBG' on uncollapsed windows.
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.89 (Released 2022-11-15) VERSION 1.89 (Released 2022-11-15)
@ -1861,6 +2054,23 @@ Other Changes:
- Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symmetry. (#914, #5738). - Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symmetry. (#914, #5738).
- Backends: WebGPU: fixed rendering when a depth buffer is enabled. (#5869) [@brainlag] - Backends: WebGPU: fixed rendering when a depth buffer is enabled. (#5869) [@brainlag]
Docking+Viewports Branch:
- Docking: Fixed incorrect focus highlight on docking node when focusing a menu. (#5702)
- Docking, Nav: Fixed using gamepad/keyboard navigation not being able enter menu layer when
it only contained the standard Collapse/Close buttons and no actual menu. (#5463, #4792)
- Docking: Fixed regression introduced in v1.87 when docked window content not rendered
while switching between with CTRL+Tab. [@rokups]
- Docking: Fixed amending into an existing tab bar from rendering invisible items. (#5515)
- Docking: Made spacing between dock nodes not a dropping gap. When hovering it only
outer-docking drop markers are visible.
- Docking+Viewports: Fixed undocking window node causing parent viewports to become unresponsive
in certain situation (e.g. hidden tab bar). (#5503) [@rokups]
- Backends: SDL: Fixed building backend under non-OSX Apple targets (e.g. iPhone). (#5665)
- Backends: SDL: Fixed drag'n drop crossing a viewport border losing mouse coordinates. (#5710, #5012)
- Backends: GLFW: Fixed leftover static variable preventing from changing or
reinitializing backend while application is running. (#4616, #5434) [@rtoumazet]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.88 (Released 2022-06-21) VERSION 1.88 (Released 2022-06-21)
@ -1995,6 +2205,26 @@ Other Changes:
- Examples: Emscripten+WebGPU: Fix building for latest WebGPU specs. (#3632) - Examples: Emscripten+WebGPU: Fix building for latest WebGPU specs. (#3632)
- Examples: OSX+Metal, OSX+OpenGL: Removed now-unnecessary calls to ImGui_ImplOSX_HandleEvent(). (#4821) - Examples: OSX+Metal, OSX+OpenGL: Removed now-unnecessary calls to ImGui_ImplOSX_HandleEvent(). (#4821)
Docking+Viewports Branch:
- Docking: Fixed floating docked nodes not being clamped into viewport workrect to stay reachable
when io.ConfigWindowsMoveFromTitleBarOnly is true and multi-viewports are disabled. (#5044)
- Docking: Fixed a regression where moving window would be interrupted after undocking a tab
when io.ConfigDockingAlwaysTabBar is true. (#5324) [@rokups]
- Docking: Fixed incorrect focus highlight on docking node when focusing empty central node
or a child window which was manually injected into a dockspace window.
- Docking, Modal: Fixed a crash when opening popup from a parent which is being docked on the same frame. (#5401)
- Viewports: Fixed an issue where MouseViewport was lagging by a frame when using 1.87 Input Queue.
A common side-effect would be that when releasing a window drag the underlying window would highlight
for a frame. (#5837, #4921) [@cfillion]
- Viewports: Fixed translating a host viewport from briefly altering the size of AlwaysAutoResize windows. (#5057)
- Viewports: Fixed main viewport size not matching ImDrawData::DisplaySize for one frame during resize
when multi-viewports are disabled. (#4900)
- Backends: SDL: Fixed dragging out main viewport broken on some SDL setups. (#5012) [@rokups]
- Backends: OSX: Added support for multi-viewports. [@stuartcarnie, @metarutaiga] (#4821, #2778)
- Backends: Metal: Added support for multi-viewports. [@stuartcarnie, @metarutaiga] (#4821, #2778)
- Examples: OSX+Metal, SDL+Metal, GLFW+Metal: Added support for multi-viewports. [@rokups]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.87 (Released 2022-02-07) VERSION 1.87 (Released 2022-02-07)
@ -2137,6 +2367,29 @@ Other Changes:
- Backends: WebGPU: Fixed incorrect size parameters in wgpuRenderPassEncoderSetIndexBuffer() and - Backends: WebGPU: Fixed incorrect size parameters in wgpuRenderPassEncoderSetIndexBuffer() and
wgpuRenderPassEncoderSetVertexBuffer() calls. (#4891) [@FeepsDev] wgpuRenderPassEncoderSetVertexBuffer() calls. (#4891) [@FeepsDev]
Docking+Viewports Branch:
- Docking: Fixed a CTRL+TAB crash when aiming at an empty docked window. (#4792)
- Docking: Tabs use their own identifier instead of the Window identifier.
(This will invalidate some stored .ini data such as last selected tab, sorry!)
- Docking: Fixed size constraints not working on single window holding on a dock id (still doesn't work on docked windows).
- Docking: Fixed CTRL+TAB back into a docked window not selecting menu layer when no item are on main layer.
- Viewports, IO: Added io.AddMouseViewportEvent() function to queue hovered viewport change (when known by backend).
- Viewports: Relaxed specs for backend supporting ImGuiBackendFlags_HasMouseHoveredViewport: it is now _optional_
for the backend to have to ignore viewports with the _NoInputs flag when call io.AddMouseViewportEvent(). It is
much better if they can (Win32 and GLFW 3.3+ backends can, SDL and GLFW 3.2 backends cannot, they are lacking data).
A concrete example is: when dragging a viewport for docking, the viewport is marked with _NoInputs to allow us
to pick the target viewports for docking. If the backend reports a viewport with _NoInputs when calling the
io.AddMouseViewportEvent() function, then Dear ImGui will revert to its flawed heuristic to find the viewport under.
By lowering those specs, we allow the SDL and more backend to support this, only relying on the heuristic in a few
drag and drop situations rather that relying on it everywhere.
- Viewports: Fixed a CTRL+TAB crash with viewports enabled when the window list needs to appears in
its own viewport (regression from 1.86). (#4023, #787)
- Viewports: Fixed active InputText() from preventing viewports to merge. (#4212)
- Backends: SDL: Added support for ImGuiBackendFlags_HasMouseHoveredViewport now that its specs have been lowered.
- (Breaking) Removed ImGuiPlatformIO::Platform_SetImeInputPos() in favor of newly standardized
io.SetPlatformImeDataFn() function. Should not affect more than default backends.
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.86 (Released 2021-12-22) VERSION 1.86 (Released 2021-12-22)
@ -2235,6 +2488,24 @@ Other Changes:
wgpuRenderPassEncoderSetIndexBuffer() functions as validation layers appears to not do what the wgpuRenderPassEncoderSetIndexBuffer() functions as validation layers appears to not do what the
in-flux specs says. (#4766) [@meshula] in-flux specs says. (#4766) [@meshula]
Docking+Viewports Branch:
- Docking: Revert removal of io.ConfigDockingWithShift config option (removed in 1.83). (#4643)
- Docking: Fixed a bug undocking windows docked into a non-visible or _KeepAliveOnly dockspace
when unrelated windows submitted before the dockspace have dynamic visibility. (#4757)
- Docking, Style: Docked windows honor ImGuiCol_WindowBg. (#2700, #2539)
- Docking, Style: Docked windows honor display their border properly. (#2522)
- Docking: Fixed incorrectly rounded tab bars for dock node that are not at the top of their dock tree.
- Docking: Fixed single-frame node pos/size inconsistencies when window stop or start being submitted.
- Docking: Prevent docking any window created above a popup/modal. (#4317)
- Viewports: Made it possible to explicitly assign ImGuiWindowClass::ParentViewportId to 0 in order
to ensure a window is not parented. Previously this would use the global default (which might be 0,
but not always as it would depend on io.ConfigViewportsNoDefaultParent). (#3152, #2871)
- Viewports: Fixed tooltip in own viewport over modal from being incorrectly dimmed. (#4729)
- Viewports: Fixed CTRL+TAB highlight outline on docked windows not always fitting in host viewport.
- Backends: Made it possible to shutdown default Platform Backends before the Renderer backends. (#4656)
- Disabled: Fixed nested BeginDisabled()/EndDisabled() bug in Docking branch due to bad merge. (#4655, #4452, #4453, #4462)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.85 (Released 2021-10-12) VERSION 1.85 (Released 2021-10-12)
@ -2253,6 +2524,10 @@ Breaking Changes:
Can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead but it's not Can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead but it's not
very useful in practice, and the only use of it in the demo was illfit. very useful in practice, and the only use of it in the demo was illfit.
Using 'GetContentRegionAvail().x' is generally a better choice. Using 'GetContentRegionAvail().x' is generally a better choice.
- (Docking branch) IsWindowFocused() and IsWindowHovered() with only the _ChildWindows flag
and without the _RootWindow flag used to leak docking hierarchy, so a docked window would
return as the child of the window hosting the dockspace. This was inconsistent and incorrect
with other behaviors so we fixed it. Added a new _DockHierarchy flag to opt-in this behavior.
Other Changes: Other Changes:
@ -2326,6 +2601,29 @@ Other Changes:
- Backends: All renderers: Normalize clipping rect handling across backends. (#4464) - Backends: All renderers: Normalize clipping rect handling across backends. (#4464)
- Examples: Added SDL + SDL_Renderer example in "examples/example_sdl_sdlrenderer/" folder. (#3926) [@1bsyl] - Examples: Added SDL + SDL_Renderer example in "examples/example_sdl_sdlrenderer/" folder. (#3926) [@1bsyl]
Docking+Viewports Branch:
- IsWindowFocused: Fixed using ImGuiFocusedFlags_ChildWindows (without _RootWindow) from leaking the
docking hierarchy. Added ImGuiFocusedFlags_DockHierarchy flag to consider docking hierarchy in the test.
- IsWindowHovered: Fixed using ImGuiHoveredFlags_ChildWindows (without _RootWindow) from leaking the
docking hierarchy. Added ImGuiHoveredFlags_DockHierarchy flag to consider docking hierarchy in the test.
- Nav: Fixed an issue with losing focus on docked windows when pressing Alt while keyboard navigation
is disabled. (#4547, #4439) [@PathogenDavid]
- Docking: Fixed IsItemHovered() and functions depending on it (e.g. BeginPopupContextItem()) when
called after Begin() on a docked window (broken 2021/03/04). (#3851)
- Docking: Improved resizing system so that non-central zone are better at keeping their fixed size.
The algorithm is still not handling the allocation of size ideally for nested sibling, but it got better.
- Docking: Fixed settings load issue when mouse wheeling. (#4310)
- Docking: Fixed manually created floating node with a central node from not hiding when windows are gone.
- Docking + Drag and Drop: Fixed using BeginDragDropSource() or BeginDragDropTarget() inside a Begin()
that returned false because the window is docked. (#4515)
- Viewports: Fixed a crash while a window owning its viewport disappear while being dragged.
It would manifest when e.g. reconfiguring dock nodes while dragging.
- Viewports: Fixed unnecessary creation of temporary viewports when multiple docked windows
got reassigned to a new node (created mid-frame) which already has a HostWindow.
- Viewports: Fixed window with viewport ini data immediately merged into a host viewport from
leaving a temporary viewport alive for a frame (would leak into backend).
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.84.2 (Released 2021-08-23) VERSION 1.84.2 (Released 2021-08-23)
@ -2462,6 +2760,25 @@ Other Changes:
- Examples: Updated all .vcxproj to VS2015 (toolset v140) to facilitate usage with vcpkg. - Examples: Updated all .vcxproj to VS2015 (toolset v140) to facilitate usage with vcpkg.
- Examples: SDL2: Accommodate for vcpkg install having headers in SDL2/SDL.h vs SDL.h. - Examples: SDL2: Accommodate for vcpkg install having headers in SDL2/SDL.h vs SDL.h.
Docking+Viewports Branch:
- Docking: Clicking on the right-most close button of a docking node closes all windows. (#4186)
- Docking: Fix IsWindowAppearing() and ImGuiCond_Appearing on docked windows. (#4177, #3982, #1497, #1061)
- Docking: Fix crash using DockBuilderRemoveNode() in some situations. (#3111, #3179, #3203, #4295) [@hsimyu]
- Docking: Fix crash when a dock node gets re-qualified as dockspace>floating>dockspace, which tends to happen
when incorrectly calling DockBuilderAddNode() without ImGuiDockNodeFlags_Dockspace and using it as a Dockspace
on the next frame after the floating window hosting the node has been automatically created. (#3203, #4295)
- Docking: Reworked node flags saving/inheritance so that flags enforced by docked windows via the
DockNodeFlagsOverrideSet mechanism are are not left in empty dockspace nodes once the windows gets undocked.
(#4292, #3834, #3633, #3521, #3492, #3335, #2999, #2648)
- Docking: (Internal/Experimental) Removed DockNodeFlagsOverrideClear flags from ImGuiWindowClass as
it is ambiguous how to apply them and we haven't got a use out of them yet.
- Docking: Fixed ImGuiWindowFlags_UnsavedDocument clipping label in docked windows when there are
no close button. (#5745)
- Viewports: Fix popup/tooltip created without a parent window from being given a ParentViewportId value
from the implicit/fallback window. (#4236, #2409)
- Backends: Vulkan: Fix the use of the incorrect fence for secondary viewports. (#4208) [@FunMiles]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.83 (Released 2021-05-24) VERSION 1.83 (Released 2021-05-24)
@ -2546,6 +2863,22 @@ Other Changes:
- Docs: Improvements to description of using colored glyphs/emojis. (#4169, #3369) - Docs: Improvements to description of using colored glyphs/emojis. (#4169, #3369)
- Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios] - Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios]
Docking+Viewports Branch:
- [Breaking] Removed io.ConfigDockingWithShift config option. Behavior always equivalent to having the
option set to false (dock/undock by default, hold shift to avoid docking). (#2109)
- Docking: DockSpace() returns its node ID.
- Docking: Dockspace() never draws a background. (#3924)
- Docking: Undocking nodes/windows covering most of the monitor max their size down to 90% to ease manipulations.
- Docking: Docking node tab bar honors ItemInnerSpacing.x before first tab. (#4130)
- Docking: Tweak rendering and alignment of dock node menu marker. (#4130)
- Docking: Fixed restoring of tab order within a dockspace or a split node.
- Docking: Fixed reappearing docked windows with no close button showing a tab with extraneous space for one frame.
- Docking: Fixed multiple simultaneously reappearing window from appearing undocked for one frame.
- Viewports: Hotfix for crash in monitor array access, caused by 4b9bc4902. (#3967)
- Backends, Viewports: GLFW: Add a workaround for stuck keys after closing a GLFW window (#3837).
- Backends, Viewports: Vulkan: Rebuild swapchain on VK_SUBOPTIMAL_KHR. (#3881)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.82 (Released 2021-02-15) VERSION 1.82 (Released 2021-02-15)
@ -2641,6 +2974,13 @@ Other Changes:
scheduled builds builds are not required. [@rokups] scheduled builds builds are not required. [@rokups]
- Log/Capture: Added LogTextV, a va_list variant of LogText. [@PathogenDavid] - Log/Capture: Added LogTextV, a va_list variant of LogText. [@PathogenDavid]
Docking+Viewports Branch:
- Viewports: Fix setting of ImGuiViewportFlags_NoRendererClear. (#3213)
- Viewports: Added GetViewportPlatformMonitor() with a safety net to keep code portable.
- Viewports, Backends: SDL: Fix missing ImGuiBackendFlags_HasSetMousePos flag in docking branch.
- Viewports, Backends: GLFW: Fix application of WantSetMousePos. (#1542, #787)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.81 (Released 2021-02-10) VERSION 1.81 (Released 2021-02-10)
@ -2722,6 +3062,17 @@ Other Changes:
- Examples: WebGPU: Added Emscripten+WebGPU example. (#3632) [@bfierz] - Examples: WebGPU: Added Emscripten+WebGPU example. (#3632) [@bfierz]
- Backends: GLFW: Added ImGui_ImplGlfw_InitForOther() initialization call to use with non OpenGL API. (#3632) - Backends: GLFW: Added ImGui_ImplGlfw_InitForOther() initialization call to use with non OpenGL API. (#3632)
Docking+Viewports Branch:
- Docking: Fix losing docking information on closed windows for which the hosting node was split. (#3716) [@GamingMinds-DanielC]
- Docking: Fix gap in hit test hole when using ImGuiDockNodeFlags_PassthruCentralNode touching the edge of a viewport. (#3733)
- Viewports: (Breaking) removed ImGuiPlatformIO::MainViewport which is now pretty much unused and duplicate
(and misleading as we will evolve the concept).
- Viewports: (Breaking) turned ImGuiViewport::GetWorkPos(), ImGuiViewport::GetWorkSize() into regular fields
(WorkPos, WorkSize) before exposing in master branch.
- Viewports: Fix issue inferring viewport z-order when new popups gets created. (#3734) + Metrics updates.
- Viewports, Backends: Vulkan: handle VK_ERROR_OUT_OF_DATE_KHR when resizing secondary viewport (#3766, #3758)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.80 (Released 2021-01-21) VERSION 1.80 (Released 2021-01-21)
@ -2841,6 +3192,14 @@ Other Changes:
- Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md, and improved them. - Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md, and improved them.
- Docs: Consistently renamed all occurrences of "binding" and "back-end" to "backend" in comments and docs. - Docs: Consistently renamed all occurrences of "binding" and "back-end" to "backend" in comments and docs.
Docking+Viewports Branch:
- Docking: Docked windows honor change of tab and text colors. (#2771)
- Docking: Support for appending into existing tab-bar made to work with Docking + internal helper DockNodeBeginAmendTabBar().
- Docking: Added experimental TabItemFlagsOverrideSet to ImGuiWindowClass.
- Viewports: Fixed incorrect whitening of popups above a modal if both use their own viewport.
- Viewports: Backends: Vulkan: Fixed build, removed extraneous pipeline creation. (#3459, #3579)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.79 (Released 2020-10-08) VERSION 1.79 (Released 2020-10-08)
@ -2935,6 +3294,21 @@ Other Changes:
- Examples: DX12: Added '#define ImTextureID ImU64' in project and build files to also allow building - Examples: DX12: Added '#define ImTextureID ImU64' in project and build files to also allow building
on 32-bit systems. Added project to default Visual Studio solution file. (#301) on 32-bit systems. Added project to default Visual Studio solution file. (#301)
Docking+Viewports Branch:
- Docking: DockSpace() emits ItemSize() properly (useful when not filling all space).
- Docking: Fixed docking while hovering a child window. (#3420) broken by 85a661d. Improve metrics debugging.
- Docking: Fix honoring payload filter with overlapping nodes (we incorrectly over-relied on g.HoveredDockNode
when making change for #3398).
- Docking: Fix handling of WindowMenuButtonPosition == ImGuiDir_None in Docking Nodes. (#3499)
- Viewports: Fixed a rare edge-case if the window targeted by CTRL+Tab stops being rendered.
- Viewports, Backends: DX12: Make secondary viewport format match main viewport one (#3462) {@BeastLe9enD]
- Viewports: Backends: Vulkan: Removed unused shader code. Fix leaks. Avoid unnecessary pipeline creation for main
viewport. (#3459) + Add ImGui_ImplVulkanH_CreateWindowSwapChain in ImGui_ImplVulkanH_CreateOrResizeWindow().
- Viewports: Backends: DirectX9: Recover from D3DERR_DEVICELOST on secondary viewports. (#3424)
- Viewports, Backends: Win32: Fix toggling of ImGuiViewportFlags_TopMost (#3477) [@Kodokuna]
- Viewports: Backends: GLFW: Workaround for cases where glfwGetMonitorWorkarea fails (#3457) [@dougbinks]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.78 (Released 2020-08-18) VERSION 1.78 (Released 2020-08-18)
@ -3036,6 +3410,23 @@ Other Changes:
- Examples: Vulkan: Fixed GLFW+Vulkan and SDL+Vulkan clear color not being set. (#3390) [@RoryO] - Examples: Vulkan: Fixed GLFW+Vulkan and SDL+Vulkan clear color not being set. (#3390) [@RoryO]
- CI: Emscripten has stopped their support for their fastcomp backend, switching to latest sdk [@Xipiryon] - CI: Emscripten has stopped their support for their fastcomp backend, switching to latest sdk [@Xipiryon]
Docking+Viewports Branch:
- Docking: Made DockBuilderAddNode() automatically call DockBuilderRemoveNode(). (#3399, #2109)
- Docking: Storing HoveredDockNode in context which can be useful for easily detecting e.g. hovering an
empty node. (#3398)
- Docking: Fixed docking overlay bits appearing at (0,0), because of 43bd80a. Most typically noticeable
when disabling multi-viewport.
- Docking: Workaround recovery for node created without the _DockSpace flags later becoming a DockSpace. (#3340)
- Docking: Rework size allocations to recover when there's no enough room for nodes + do not hold on
_WantLockSizeOnce forever. (#3328)
- Docking: Rework size allocation to allow user code to override node sizes. Not all edge cases will be
properly handled but this is a step toward toolbar emitting size constraints.
- Docking: Added experimental flags to perform more docking filtering and disable resize per axis.
Designed for toolbar patterns.
- Viewports, Backends, GLFW: Use GLFW_MOUSE_PASSTHROUGH when available.
- Viewports, Backends: DX12: Fixed issue on shutdown when viewports are disabled. (#3347)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.77 (Released 2020-06-29) VERSION 1.77 (Released 2020-06-29)
@ -3127,6 +3518,17 @@ Other Changes:
- Examples: Apple: Fixed example_apple_metal and example_apple_opengl2 using imgui_impl_osx.mm - Examples: Apple: Fixed example_apple_metal and example_apple_opengl2 using imgui_impl_osx.mm
not forwarding right and center mouse clicks. (#3260) [@nburrus] not forwarding right and center mouse clicks. (#3260) [@nburrus]
Docking+Viewports Branch:
- Viewports: Don't set ImGuiViewportFlags_NoRendererClear when ImGuiWindowFlags_NoBackground is set. (#3213)
- Viewports: Report minimized viewports as zero DisplaySize to be consistent with main branch. (#1542)
- Docking, Settings: Allow reload of settings data at runtime. (#2573)
- Backends, GLFW: Fix windows resizing incorrectly on Linux due to GLFW firing window positioning
callbacks on next frame after window is resized manually. (#2117)
- Backends: DX12: Fix OBJECT_DELETED_WHILE_STILL_IN_USE on viewport resizing. (#3210)
- Backends: DX12: Fix for crash caused by early resource release. (#3121)
- Backends, Win32: Request monitor update when DPI awareness is enabled to make sure they have the correct DPI settings.
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.76 (Released 2020-04-12) VERSION 1.76 (Released 2020-04-12)
@ -3199,6 +3601,20 @@ Other Changes:
- Examples: SDL+DX11: Fixed resizing main window. (#3057) [@joeslay] - Examples: SDL+DX11: Fixed resizing main window. (#3057) [@joeslay]
- Examples: Added SDL+Metal example application. (#3017) [@coding-jackalope] - Examples: Added SDL+Metal example application. (#3017) [@coding-jackalope]
Docking+Viewports Branch:
- Docking: Fixed assert preventing dockspace from being created instead a hidden tab. (#3101)
- Viewports: Fixed secondary viewports accidentally merging into a minimized host viewport. (#3118)
- Viewports, Docking: Added per-viewport work area system for e.g. menu-bars. Fixed DockspaceOverViewport()
and demo code (overlay etc) accordingly. (#3035, #2889, #2474, #1542, #2109)
- Viewports: Improve menu positioning in multi-monitor setups. [@rokups]
- Viewports: Software mouse cursor is also scaled by current DpiScale. (amend #939)
- Viewports: Avoid manually clipping resize grips and borders, which messes up with automation ability
to locate those items. Also simpler and more standard.
- Viewports: Fix for UWP in the imgui_impl_win32.cpp IME handler. (#2895, #2892).
- Viewports: Bunch of extra of comments to facilitate setting up multi-viewports.
- Viewports, GLFW: Avoid using window positioning workaround for GLFW 3.3+ versions that have it fixed.
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.75 (Released 2020-02-10) VERSION 1.75 (Released 2020-02-10)
@ -3297,6 +3713,21 @@ Other Changes:
- Examples: Metal: Wrapped main loop in @autoreleasepool block to ensure allocations get freed - Examples: Metal: Wrapped main loop in @autoreleasepool block to ensure allocations get freed
even if underlying system event loop gets paused due to app nap. (#2910, #2917) [@bear24rw] even if underlying system event loop gets paused due to app nap. (#2910, #2917) [@bear24rw]
Docking+Viewports Branch:
- Docking + Nav: Fixed messed up Ctrl+Tab order with docked windows.
- Docking + Nav: Fixed failing to restore NavId when refocusing a child within a docked window.
- Docking + Nav: Fixed failing to restore NavId when refocusing due to missing nav window (when
it stops being submitted).
- Docking: Fixed a bug where the tab bar of a hidden dockspace would keep requesting focus. (#2960)
- Docking: Added experimental DockNodeFlagsOverrideSet/DockNodeFlagsOverrideClear flags in ImGuiWindowClass
(currently experimenting with toolbar idioms).
- Viewports: Fix resizing viewport-owning windows when mouse pos is outside the InnerClipRect
(can happen with OS decoration enabled).
- Viewports: Preserve last known size for minimized main viewport to be consistent with secondary viewports.
- Backends: SDL: Honor NoTaskBarIcon flag under non Win32 OS. (#2117)
- Backends: GLFW, SDL: Platform monitors declared properly even if multi-viewport is not enabled.
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.74 (Released 2019-11-25) VERSION 1.74 (Released 2019-11-25)
@ -3376,6 +3807,14 @@ Other Changes:
- CI: Set up a bunch of continuous-integration tests using GitHub Actions. We now compile many of the example - CI: Set up a bunch of continuous-integration tests using GitHub Actions. We now compile many of the example
applications on Windows, Linux, MacOS, iOS, Emscripten. Removed Travis integration. (#2865) [@rokups] applications on Windows, Linux, MacOS, iOS, Emscripten. Removed Travis integration. (#2865) [@rokups]
Docking+Viewports Branch:
- Docking: Can undock from the small triangle button. (#2109,. #2645)
- Docking: Fixed node->HasCloseButton not honoring ImGuiDockNodeFlags_NoCloseButton in a floating node,
leading to empty space at the right of tab-bars with those flags. (#2109)
- Docking: Made docked windows not use style.ChildRounding.
- Multi-viewports: Added multi-viewport support in the DX12 back-end. (#2851) [@obfuscate]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.73 (Released 2019-09-24) VERSION 1.73 (Released 2019-09-24)
@ -3438,6 +3877,28 @@ Other Changes:
- Misc: Updated stb_rect_pack.h from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic, - Misc: Updated stb_rect_pack.h from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic,
fix handling of rectangles too large to fit inside texture). (#2762) [@tido64] fix handling of rectangles too large to fit inside texture). (#2762) [@tido64]
Docking+Viewports Branch:
- Docking: Fix BeginDocked() path that creates node so that SetNextWindowDockID() doesn't immediately discard the node. (#2109)
- Docking: Fix for node created at the same time as windows that are still resizing (typically with
io.ConfigDockingAlwaysTabBar) to not be zero/min sized. (#2109). The fix delays their visibility by one frame,
which is not ideal but not very problematic as the .ini data gets populated after that.
- Docking: Fix a crash that could occur with a malformed ini file (DockNode Parent value pointing to a missing node).
- Viewport: Fix modal/popup window being stuck in unowned hidden viewport associated to fallback window without stealing
it back. Fix modal reference viewport when opened outside of another window. (#1542)
- Viewport: Modals don't need to set ImGuiViewportFlags_NoFocusOnClick, this also mitigate the issue described by #2445,
which becomes particularly bad with unfocused modal. (#1542)
- Viewport: better case case where host window gets moved and resized simultaneous (toggling maximized state).
There's no perfect solution there, than using io.ConfigViewportsNoAutoMerge = false. (#1542)
- Viewport, Docking: Fixed incorrect assignment of IsFallbackWindow which would tag dock node host windows created
in NewFrame() as such, messing with popup viewport inheritance.
- Viewport: Fixed issue where resize grip would display as hovered while mouse is still off the OS bounds so a click
would miss it and focus the OS window behind expected one. (#1542)
- Viewport: Fix to allow multiple shutdown / calls to DestroyPlatformWindows(). (#2769)
- Viewport: Backends: GLFW: Fix setting window size on macOS (#2767, #2117) [@rokups]
- Viewport: Backends: GLFW+Linux: Fix window having incorrect size after uncollapse. (#2756, #2117) [@rokups]
- Viewport: Backends: DirectX9: Workaround for windows not refreshing when main viewport has no draw call. (#2560)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.72b (Released 2019-07-31) VERSION 1.72b (Released 2019-07-31)
@ -3540,6 +4001,25 @@ Other Changes:
(#2482, #2632) [@josiahmanson] (#2482, #2632) [@josiahmanson]
- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm] - Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm]
Docking+Viewports Branch:
- Docking: Making it possible to undock a node by clicking on the tab bar / title bar for the node. (#2645).
- Docking: Explicitly inhibit constraint when docked for now. Fix clipping issue related to constraints. (#2690).
- Docking: Fixed dragging/resizing from OS decoration not marking settings as dirty.
- Docking: Renamed io.ConfigDockingTabBarOnSingleWindows to io.ConfigDockingAlwaysTabBar.
Added ImGuiWindowClass::DockingAlwaysTabBar to set on individual windows.
- Docking: Perform simple check: assert if Docking or Viewport are enabled exactly on frame 1 (instead of frame 0
or later), which is a common user error leading to loss of .ini data on load.
- Docking: Fix so that an appearing window making a dock node reappear won't have a zero-size on its first frame.
- Docking: Fixed using ImGuiDockNodeFlags_AutoHideTabBar with io.ConfigDockingTabBarOnSingleWindows.
- Docking: Added ImGuiDockNode to .natvis file.
- Docking: Fixed support for large meshes in GetBackgroundDrawList(), GetForegroundDrawList(). (#2638)
- Viewport: Fix monitor dpi info not being copied to main viewport when multi-viewports are not enabled. (#2621, #1676)
- Viewport: Refactored ImGuiWindowClass's ViewportFlagsOverrideMask + ViewportFlagsOverrideValue into
ViewportFlagsOverrideSet + ViewportFlagsOverrideClear which appears easier to grasp. (#1542)
- Viewport: Added ImGuiViewportFlags_NoAutoMerge to prevent merging into host viewport in a per-window basis
via the ImGuiWindowClass override mechanism. (#1542)
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.71 (Released 2019-06-12) VERSION 1.71 (Released 2019-06-12)
@ -3879,6 +4359,7 @@ Breaking Changes:
- Renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete). - Renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete).
Other Changes: Other Changes:
- Added BETA api for Tab Bar/Tabs widgets: (#261, #351) - Added BETA api for Tab Bar/Tabs widgets: (#261, #351)
- Added BeginTabBar(), EndTabBar(), BeginTabItem(), EndTabItem(), SetTabItemClosed() API. - Added BeginTabBar(), EndTabBar(), BeginTabItem(), EndTabItem(), SetTabItemClosed() API.
- Added ImGuiTabBarFlags flags for BeginTabBar(). - Added ImGuiTabBarFlags flags for BeginTabBar().

View File

@ -129,7 +129,35 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
- separator: width, thickness, centering (#1643, #2657) - separator: width, thickness, centering (#1643, #2657)
- splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319) - splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
- docking: merge docking branch (#2109) - docking: B: ordering currently held in tab bar should be implicitly held by windows themselves (also see #2304)
- docking: B- tab bar: the order/focus restoring code could be part of TabBar and not DockNode? (#8)
- docking: B~ rework code to be able to lazily create tab bar instance in a single place. The _Unsorted tab flag could be replacing a trailing-counter in DockNode?
- docking: B~ fully track windows/settings reference in dock nodes. perhaps find a representation that allows facilitate use of dock builder functions.
- docking: B~ 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.
- docking: B: when docking outer, perform size locking on neighbors nodes the same way we do it with splitters, so other nodes are not resized.
- docking: B~ central node resizing behavior incorrect.
- docking: B: changing title font/style per-window is not supported as dock nodes are created in NewFrame.
- docking: B- dock node inside its own viewports creates 1 temporary viewport per window on startup before ditching them (doesn't affect the user nor request platform windows to be created, but unnecessary)
- docking: B- resize sibling locking behavior may be less desirable if we merged same-axis sibling in a same node level?
- docking: B- single visible node part of a hidden split hierarchy (OnlyNodeWithWindows != NULL) should show a normal title bar (not a tab bar)
- docking: B~ SetNextWindowDock() calls (with conditional) -> defer everything to DockContextUpdate (repro: Documents->[X]Windows->Dock 1 elsewhere->Click Redock All
- docking: B~ tidy up tab list popup buttons features (available with manual tab-bar, see ImGuiTabBarFlags_NoTabListPopupButton code, not used by docking nodes)
- docking: B- SetNextWindowDockId(0) with a second Begin() in the frame will asserts
- docking: B: resize grip drawn in host window typically appears under scrollbar.
- docking: B: resize grip auto-resize on multiple node hierarchy doesn't make much sense or should be improved?
- docking: B- SetNextWindowFocus() doesn't seem to apply if the window is hidden this frame, need repro (#4)
- docking: B- resizing a dock tree small currently has glitches (overlapping collapse and close button, etc.)
- docking: B- dpi: look at interaction with the hi-dpi and multi-dpi stuff.
- docking: B- tab bar: appearing on first frame with a dumb layout would do less harm that not appearing? (when behind dynamic branch) or store titles + render in EndTabBar()
- docking: B- tab bar: make selected tab always shows its full title?
- docking: B- hide close button on single tab bar?
- docking: B- nav: design interactions so nav controls can dock/undock
- docking: B- dockspace: flag to lock the dock tree and/or sizes (ImGuiDockNodeFlags_Locked?)
- docking: B- reintroduce collapsing a floating dock node. also collapsing a docked dock node!
- docking: B- allow dragging a non-floating dock node by clicking on the title-bar-looking section (not just the collapse/menu button)
- docking: B- option to remember undocked window size? (instead of keeping their docked size) (relate to #2104)
- docking: C- nav: CTRL+TAB highlighting tabs shows the mismatch between focus-stack and tab-order (not visible in VS because it doesn't highlight the tabs)
- docking: C- after a dock/undock, the Scrollbar Status update in Begin() should use an updated e.g. size_y_for_scrollbars to avoid a 1 frame scrollbar flicker.
- tabs: "there is currently a problem because TabItem() will try to submit their own tooltip after 0.50 second, and this will have the effect of making your tooltip flicker once." -> tooltip priority work (WIP branch) - tabs: "there is currently a problem because TabItem() will try to submit their own tooltip after 0.50 second, and this will have the effect of making your tooltip flicker once." -> tooltip priority work (WIP branch)
- tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing. - tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing.
@ -302,6 +330,20 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
- nav/windowing: Resizing window will currently fail with certain types of resizing constraints/callback applied - nav/windowing: Resizing window will currently fail with certain types of resizing constraints/callback applied
- focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622) - focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
- viewport: make it possible to have no main/hosting viewport
- viewport: We set ImGuiViewportFlags_NoFocusOnAppearing in a way that is required for GLFW/SDL binding, but could be handled better without
on a custom e.g. Win32 bindings. It prevents newly dragged-out viewports from taking the focus, which makes ALT+F4 more ambiguous.
- viewport: not focusing newly undocked viewport means clicking back on previous one doesn't bring OS window to front.
- viewport: with platform decoration enabled, platform may force constraint (e.g. minimum size)
- viewport: use getfocus/setfocus api to synchronize imgui<>platform focus better (e.g imgui-side ctrl-tab can focus os window, OS initial setup and alt-tab can focus imgui window etc.)
- viewport: store per-viewport/monitor DPI in .ini file so an application reload or main window changing DPI on reload can be properly patched for.
- viewport: implicit/fallback Debug window can hog a zombie viewport (harmless, noisy?) > could at least clear out the reference on a per session basis?
- viewport: need to clarify how to use GetMousePos() from a user point of view.
- platform: glfw: no support for ImGuiBackendFlags_HasMouseHoveredViewport.
- platform: sdl: no support for ImGuiBackendFlags_HasMouseHoveredViewport. maybe we could use SDL_GetMouseFocus() / SDL_WINDOW_MOUSE_FOCUS if imgui could fallback on its heuristic when NoInputs is set
- platform: sdl: no refresh of monitor/display (SDL doesn't seem to have an event for it).
- platform: sdl: multi-viewport + minimized window seems to break mouse wheel events (at least under Win32).
- inputs: support track pad style scrolling & slider edit. - inputs: support track pad style scrolling & slider edit.
- inputs/io: backspace and arrows in the context of a text input could use system repeat rate. - inputs/io: backspace and arrows in the context of a text input could use system repeat rate.
- inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808) - inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808)

View File

@ -40,6 +40,7 @@ int main(int, char**)
ImGui::CreateContext(); ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();

View File

@ -7,7 +7,10 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
050450AB2768052600AB6805 /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
050450AD276863B000AB6805 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 050450AC276863B000AB6805 /* QuartzCore.framework */; };
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05318E0E274C397200A8DE2E /* GameController.framework */; }; 05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05318E0E274C397200A8DE2E /* GameController.framework */; };
05A275442773BEA20084EF39 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05A275432773BEA20084EF39 /* QuartzCore.framework */; };
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; }; 07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; }; 07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; }; 5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
@ -33,7 +36,11 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
050450AC276863B000AB6805 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
05318E0E274C397200A8DE2E /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; }; 05318E0E274C397200A8DE2E /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
05A2754027728F5B0084EF39 /* imgui_impl_metal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_metal.h; path = ../../backends/imgui_impl_metal.h; sourceTree = "<group>"; };
05A2754127728F5B0084EF39 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../backends/imgui_impl_osx.h; sourceTree = "<group>"; };
05A275432773BEA20084EF39 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; };
07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = "<group>"; }; 07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = "<group>"; };
07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = "<group>"; }; 07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = "<group>"; };
5079822D257677DB0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = ../../imgui_tables.cpp; sourceTree = "<group>"; }; 5079822D257677DB0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = ../../imgui_tables.cpp; sourceTree = "<group>"; };
@ -66,6 +73,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
05A275442773BEA20084EF39 /* QuartzCore.framework in Frameworks */,
8309BD8F253CCAAA0045E2A1 /* UIKit.framework in Frameworks */, 8309BD8F253CCAAA0045E2A1 /* UIKit.framework in Frameworks */,
83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */, 83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */,
83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */, 83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */,
@ -76,6 +84,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
050450AD276863B000AB6805 /* QuartzCore.framework in Frameworks */,
8309BDC6253CCCFE0045E2A1 /* AppKit.framework in Frameworks */, 8309BDC6253CCCFE0045E2A1 /* AppKit.framework in Frameworks */,
83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */, 83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */,
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */, 05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */,
@ -136,6 +145,8 @@
83BBE9E320EB46B800295997 /* Frameworks */ = { 83BBE9E320EB46B800295997 /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
050450AC276863B000AB6805 /* QuartzCore.framework */,
05A275432773BEA20084EF39 /* QuartzCore.framework */,
05318E0E274C397200A8DE2E /* GameController.framework */, 05318E0E274C397200A8DE2E /* GameController.framework */,
8309BDC5253CCCFE0045E2A1 /* AppKit.framework */, 8309BDC5253CCCFE0045E2A1 /* AppKit.framework */,
8309BD8E253CCAAA0045E2A1 /* UIKit.framework */, 8309BD8E253CCAAA0045E2A1 /* UIKit.framework */,
@ -153,7 +164,9 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
5079822D257677DB0038A28D /* imgui_tables.cpp */, 5079822D257677DB0038A28D /* imgui_tables.cpp */,
05A2754027728F5B0084EF39 /* imgui_impl_metal.h */,
8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal.mm */, 8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal.mm */,
05A2754127728F5B0084EF39 /* imgui_impl_osx.h */,
8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */, 8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */,
83BBEA0420EB54E700295997 /* imconfig.h */, 83BBEA0420EB54E700295997 /* imconfig.h */,
83BBEA0320EB54E700295997 /* imgui.cpp */, 83BBEA0320EB54E700295997 /* imgui.cpp */,
@ -268,9 +281,9 @@
8309BDBB253CCCAD0045E2A1 /* imgui_impl_metal.mm in Sources */, 8309BDBB253CCCAD0045E2A1 /* imgui_impl_metal.mm in Sources */,
83BBEA0920EB54E700295997 /* imgui.cpp in Sources */, 83BBEA0920EB54E700295997 /* imgui.cpp in Sources */,
83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */, 83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */,
83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */, 83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */,
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */, 5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */,
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */, 07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */,
8309BDA5253CCC070045E2A1 /* main.mm in Sources */, 8309BDA5253CCC070045E2A1 /* main.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@ -281,10 +294,10 @@
files = ( files = (
8309BDBE253CCCB60045E2A1 /* imgui_impl_metal.mm in Sources */, 8309BDBE253CCCB60045E2A1 /* imgui_impl_metal.mm in Sources */,
8309BDBF253CCCB60045E2A1 /* imgui_impl_osx.mm in Sources */, 8309BDBF253CCCB60045E2A1 /* imgui_impl_osx.mm in Sources */,
83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */, 83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */,
83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */, 83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */,
83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */, 83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */,
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */, 050450AB2768052600AB6805 /* imgui_tables.cpp in Sources */,
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */, 07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */,
8309BDA8253CCC080045E2A1 /* main.mm in Sources */, 8309BDA8253CCC080045E2A1 /* main.mm in Sources */,
); );

View File

@ -60,11 +60,21 @@
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Renderer backend // Setup Renderer backend
ImGui_ImplMetal_Init(_device); ImGui_ImplMetal_Init(_device);
@ -195,6 +205,13 @@
// Present // Present
[commandBuffer presentDrawable:view.currentDrawable]; [commandBuffer presentDrawable:view.currentDrawable];
[commandBuffer commit]; [commandBuffer commit];
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
} }
-(void)mtkView:(MTKView*)view drawableSizeWillChange:(CGSize)size -(void)mtkView:(MTKView*)view drawableSizeWillChange:(CGSize)size

View File

@ -47,11 +47,21 @@
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplOSX_Init(self); ImGui_ImplOSX_Init(self);
ImGui_ImplOpenGL2_Init(); ImGui_ImplOpenGL2_Init();
@ -136,6 +146,13 @@
ImGui_ImplOpenGL2_RenderDrawData(draw_data); ImGui_ImplOpenGL2_RenderDrawData(draw_data);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
// Present // Present
[[self openGLContext] flushBuffer]; [[self openGLContext] flushBuffer];

View File

@ -33,11 +33,21 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
// Setup style // Setup style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Load Fonts // Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
@ -69,7 +79,7 @@ int main(int, char**)
id <MTLCommandQueue> commandQueue = [device newCommandQueue]; id <MTLCommandQueue> commandQueue = [device newCommandQueue];
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplGlfw_InitForOther(window, true);
ImGui_ImplMetal_Init(device); ImGui_ImplMetal_Init(device);
NSWindow *nswin = glfwGetCocoaWindow(window); NSWindow *nswin = glfwGetCocoaWindow(window);
@ -157,6 +167,13 @@ int main(int, char**)
ImGui::Render(); ImGui::Render();
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder); ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
[renderEncoder popDebugGroup]; [renderEncoder popDebugGroup];
[renderEncoder endEncoding]; [renderEncoder endEncoding];

View File

@ -52,11 +52,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL2_Init(); ImGui_ImplOpenGL2_Init();
@ -155,6 +167,17 @@ int main(int, char**)
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
//glUseProgram(last_program); //glUseProgram(last_program);
// Update and Render additional Platform Windows
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
// For this specific demo app we could also call glfwMakeContextCurrent(window) directly)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow* backup_current_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backup_current_context);
}
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
glfwSwapBuffers(window); glfwSwapBuffers(window);
} }

View File

@ -77,11 +77,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplGlfw_InitForOpenGL(window, true);
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
@ -184,6 +196,17 @@ int main(int, char**)
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
// Update and Render additional Platform Windows
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
// For this specific demo app we could also call glfwMakeContextCurrent(window) directly)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow* backup_current_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backup_current_context);
}
glfwSwapBuffers(window); glfwSwapBuffers(window);
} }
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__

View File

@ -429,11 +429,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplGlfw_InitForVulkan(window, true); ImGui_ImplGlfw_InitForVulkan(window, true);
ImGui_ImplVulkan_InitInfo init_info = {}; ImGui_ImplVulkan_InitInfo init_info = {};
@ -544,17 +556,25 @@ int main(int, char**)
// Rendering // Rendering
ImGui::Render(); ImGui::Render();
ImDrawData* draw_data = ImGui::GetDrawData(); ImDrawData* main_draw_data = ImGui::GetDrawData();
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f); const bool main_is_minimized = (main_draw_data->DisplaySize.x <= 0.0f || main_draw_data->DisplaySize.y <= 0.0f);
if (!is_minimized) wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w;
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w;
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
wd->ClearValue.color.float32[3] = clear_color.w;
if (!main_is_minimized)
FrameRender(wd, main_draw_data);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{ {
wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w; ImGui::UpdatePlatformWindows();
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w; ImGui::RenderPlatformWindowsDefault();
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
wd->ClearValue.color.float32[3] = clear_color.w;
FrameRender(wd, draw_data);
FramePresent(wd);
} }
// Present Main Platform Window
if (!main_is_minimized)
FramePresent(wd);
} }
// Cleanup // Cleanup

View File

@ -93,6 +93,7 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();

View File

@ -61,6 +61,7 @@ int main(int argc, char** argv)
ImGui::CreateContext(); ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
@ -78,7 +79,6 @@ int main(int argc, char** argv)
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
ImGui_ImplGLUT_InstallFuncs(); ImGui_ImplGLUT_InstallFuncs();
// Load Fonts // Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.

View File

@ -71,11 +71,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplSDL2_InitForD3D(window); ImGui_ImplSDL2_InitForD3D(window);
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
@ -181,6 +193,13 @@ int main(int, char**)
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha); g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
g_pSwapChain->Present(1, 0); // Present with vsync g_pSwapChain->Present(1, 0); // Present with vsync
//g_pSwapChain->Present(0, 0); // Present without vsync //g_pSwapChain->Present(0, 0); // Present without vsync
} }

View File

@ -24,11 +24,21 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
// Setup style // Setup style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Load Fonts // Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
@ -168,6 +178,13 @@ int main(int, char**)
ImGui::Render(); ImGui::Render();
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder); ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
[renderEncoder popDebugGroup]; [renderEncoder popDebugGroup];
[renderEncoder endEncoding]; [renderEncoder endEncoding];

View File

@ -57,11 +57,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplSDL2_InitForOpenGL(window, gl_context); ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
ImGui_ImplOpenGL2_Init(); ImGui_ImplOpenGL2_Init();
@ -160,6 +172,19 @@ int main(int, char**)
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
// Update and Render additional Platform Windows
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
// For this specific demo app we could also call SDL_GL_MakeCurrent(window, gl_context) directly)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
}
SDL_GL_SwapWindow(window); SDL_GL_SwapWindow(window);
} }

View File

@ -84,11 +84,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplSDL2_InitForOpenGL(window, gl_context); ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
ImGui_ImplOpenGL3_Init(glsl_version); ImGui_ImplOpenGL3_Init(glsl_version);
@ -194,6 +206,19 @@ int main(int, char**)
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
// Update and Render additional Platform Windows
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
// For this specific demo app we could also call SDL_GL_MakeCurrent(window, gl_context) directly)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
}
SDL_GL_SwapWindow(window); SDL_GL_SwapWindow(window);
} }
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__

View File

@ -59,6 +59,7 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();

View File

@ -429,11 +429,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons;
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplSDL2_InitForVulkan(window); ImGui_ImplSDL2_InitForVulkan(window);
ImGui_ImplVulkan_InitInfo init_info = {}; ImGui_ImplVulkan_InitInfo init_info = {};
@ -553,17 +565,25 @@ int main(int, char**)
// Rendering // Rendering
ImGui::Render(); ImGui::Render();
ImDrawData* draw_data = ImGui::GetDrawData(); ImDrawData* main_draw_data = ImGui::GetDrawData();
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f); const bool main_is_minimized = (main_draw_data->DisplaySize.x <= 0.0f || main_draw_data->DisplaySize.y <= 0.0f);
if (!is_minimized) wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w;
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w;
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
wd->ClearValue.color.float32[3] = clear_color.w;
if (!main_is_minimized)
FrameRender(wd, main_draw_data);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{ {
wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w; ImGui::UpdatePlatformWindows();
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w; ImGui::RenderPlatformWindowsDefault();
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
wd->ClearValue.color.float32[3] = clear_color.w;
FrameRender(wd, draw_data);
FramePresent(wd);
} }
// Present Main Platform Window
if (!main_is_minimized)
FramePresent(wd);
} }
// Cleanup // Cleanup

View File

@ -80,11 +80,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplSDL3_InitForOpenGL(window, gl_context); ImGui_ImplSDL3_InitForOpenGL(window, gl_context);
ImGui_ImplOpenGL3_Init(glsl_version); ImGui_ImplOpenGL3_Init(glsl_version);
@ -190,6 +202,19 @@ int main(int, char**)
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
// Update and Render additional Platform Windows
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
// For this specific demo app we could also call SDL_GL_MakeCurrent(window, gl_context) directly)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
}
SDL_GL_SwapWindow(window); SDL_GL_SwapWindow(window);
} }
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__

View File

@ -32,13 +32,17 @@ int main(int, char**)
} }
// Create window with SDL_Renderer graphics context // Create window with SDL_Renderer graphics context
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN; Uint32 window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_Renderer example", 1280, 720, window_flags); SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_Renderer example", 1280, 720, window_flags);
if (window == nullptr) if (window == nullptr)
{ {
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError()); printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
return -1; return -1;
} }
for (int n = 0; n < SDL_GetNumRenderDrivers(); n++)
printf("- render driver %d: %s\n", n, SDL_GetRenderDriver(n));
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr); SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr);
SDL_SetRenderVSync(renderer, 1); SDL_SetRenderVSync(renderer, 1);
if (renderer == nullptr) if (renderer == nullptr)
@ -55,6 +59,8 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
@ -165,6 +171,14 @@ int main(int, char**)
SDL_SetRenderDrawColorFloat(renderer, clear_color.x, clear_color.y, clear_color.z, clear_color.w); SDL_SetRenderDrawColorFloat(renderer, clear_color.x, clear_color.y, clear_color.z, clear_color.w);
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer); ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__

View File

@ -54,11 +54,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplWin32_Init(hwnd); ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX10_Init(g_pd3dDevice); ImGui_ImplDX10_Init(g_pd3dDevice);
@ -167,6 +179,13 @@ int main(int, char**)
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha); g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
// Present // Present
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync //HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
@ -186,7 +205,6 @@ int main(int, char**)
} }
// Helper functions // Helper functions
bool CreateDeviceD3D(HWND hWnd) bool CreateDeviceD3D(HWND hWnd)
{ {
// Setup swap chain // Setup swap chain

View File

@ -54,11 +54,28 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
//io.ConfigViewportsNoDefaultParent = true;
//io.ConfigDockingAlwaysTabBar = true;
//io.ConfigDockingTransparentPayload = true;
//io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleFonts; // FIXME-DPI: Experimental. THIS CURRENTLY DOESN'T WORK AS EXPECTED. DON'T USE IN USER APP!
//io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleViewports; // FIXME-DPI: Experimental.
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplWin32_Init(hwnd); ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
@ -167,6 +184,13 @@ int main(int, char**)
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha); g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
// Present // Present
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync //HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
@ -186,7 +210,6 @@ int main(int, char**)
} }
// Helper functions // Helper functions
bool CreateDeviceD3D(HWND hWnd) bool CreateDeviceD3D(HWND hWnd)
{ {
// Setup swap chain // Setup swap chain
@ -241,6 +264,10 @@ void CleanupRenderTarget()
if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = nullptr; } if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = nullptr; }
} }
#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0 // From Windows SDK 8.1+ headers
#endif
// Forward declare message handler from imgui_impl_win32.cpp // Forward declare message handler from imgui_impl_win32.cpp
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
@ -269,6 +296,15 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_DESTROY: case WM_DESTROY:
::PostQuitMessage(0); ::PostQuitMessage(0);
return 0; return 0;
case WM_DPICHANGED:
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports)
{
//const int dpi = HIWORD(wParam);
//printf("WM_DPICHANGED to %d (%.0f%%)\n", dpi, (float)dpi / 96.0f * 100.0f);
const RECT* suggested_rect = (RECT*)lParam;
::SetWindowPos(hWnd, nullptr, suggested_rect->left, suggested_rect->top, suggested_rect->right - suggested_rect->left, suggested_rect->bottom - suggested_rect->top, SWP_NOZORDER | SWP_NOACTIVATE);
}
break;
} }
return ::DefWindowProcW(hWnd, msg, wParam, lParam); return ::DefWindowProcW(hWnd, msg, wParam, lParam);
} }

View File

@ -90,11 +90,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplWin32_Init(hwnd); ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT, ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT,
@ -220,6 +232,13 @@ int main(int, char**)
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList); g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault(nullptr, (void*)g_pd3dCommandList);
}
// Present // Present
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync //HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
@ -246,7 +265,6 @@ int main(int, char**)
} }
// Helper functions // Helper functions
bool CreateDeviceD3D(HWND hWnd) bool CreateDeviceD3D(HWND hWnd)
{ {
// Setup swap chain // Setup swap chain

View File

@ -52,11 +52,23 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
//io.ConfigViewportsNoAutoMerge = true;
//io.ConfigViewportsNoTaskBarIcon = true;
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsLight(); //ImGui::StyleColorsLight();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplWin32_Init(hwnd); ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX9_Init(g_pd3dDevice); ImGui_ImplDX9_Init(g_pd3dDevice);
@ -177,6 +189,14 @@ int main(int, char**)
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
g_pd3dDevice->EndScene(); g_pd3dDevice->EndScene();
} }
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
}
HRESULT result = g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr); HRESULT result = g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr);
if (result == D3DERR_DEVICELOST) if (result == D3DERR_DEVICELOST)
g_DeviceLost = true; g_DeviceLost = true;
@ -195,7 +215,6 @@ int main(int, char**)
} }
// Helper functions // Helper functions
bool CreateDeviceD3D(HWND hWnd) bool CreateDeviceD3D(HWND hWnd)
{ {
if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == nullptr) if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == nullptr)
@ -231,6 +250,10 @@ void ResetDevice()
ImGui_ImplDX9_CreateDeviceObjects(); ImGui_ImplDX9_CreateDeviceObjects();
} }
#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0 // From Windows SDK 8.1+ headers
#endif
// Forward declare message handler from imgui_impl_win32.cpp // Forward declare message handler from imgui_impl_win32.cpp
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
@ -259,6 +282,15 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_DESTROY: case WM_DESTROY:
::PostQuitMessage(0); ::PostQuitMessage(0);
return 0; return 0;
case WM_DPICHANGED:
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports)
{
//const int dpi = HIWORD(wParam);
//printf("WM_DPICHANGED to %d (%.0f%%)\n", dpi, (float)dpi / 96.0f * 100.0f);
const RECT* suggested_rect = (RECT*)lParam;
::SetWindowPos(hWnd, nullptr, suggested_rect->left, suggested_rect->top, suggested_rect->right - suggested_rect->left, suggested_rect->bottom - suggested_rect->top, SWP_NOZORDER | SWP_NOACTIVATE);
}
break;
} }
return ::DefWindowProcW(hWnd, msg, wParam, lParam); return ::DefWindowProcW(hWnd, msg, wParam, lParam);
} }

View File

@ -33,6 +33,42 @@ void CleanupDeviceWGL(HWND hWnd, WGL_WindowData* data);
void ResetDeviceWGL(); void ResetDeviceWGL();
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
// Support function for multi-viewports
// Unlike most other backend combination, we need specific hooks to combine Win32+OpenGL.
// We could in theory decide to support Win32-specific code in OpenGL backend via e.g. an hypothetical ImGui_ImplOpenGL3_InitForRawWin32().
static void Hook_Renderer_CreateWindow(ImGuiViewport* viewport)
{
assert(viewport->RendererUserData == NULL);
WGL_WindowData* data = IM_NEW(WGL_WindowData);
CreateDeviceWGL((HWND)viewport->PlatformHandle, data);
viewport->RendererUserData = data;
}
static void Hook_Renderer_DestroyWindow(ImGuiViewport* viewport)
{
if (viewport->RendererUserData != NULL)
{
WGL_WindowData* data = (WGL_WindowData*)viewport->RendererUserData;
CleanupDeviceWGL((HWND)viewport->PlatformHandle, data);
IM_DELETE(data);
viewport->RendererUserData = NULL;
}
}
static void Hook_Platform_RenderWindow(ImGuiViewport* viewport, void*)
{
// Activate the platform window DC in the OpenGL rendering context
if (WGL_WindowData* data = (WGL_WindowData*)viewport->RendererUserData)
wglMakeCurrent(data->hDC, g_hRC);
}
static void Hook_Renderer_SwapBuffers(ImGuiViewport* viewport, void*)
{
if (WGL_WindowData* data = (WGL_WindowData*)viewport->RendererUserData)
::SwapBuffers(data->hDC);
}
// Main code // Main code
int main(int, char**) int main(int, char**)
{ {
@ -62,15 +98,39 @@ int main(int, char**)
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
// Setup Dear ImGui style // Setup Dear ImGui style
ImGui::StyleColorsDark(); ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic(); //ImGui::StyleColorsClassic();
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
// Setup Platform/Renderer backends // Setup Platform/Renderer backends
ImGui_ImplWin32_InitForOpenGL(hwnd); ImGui_ImplWin32_InitForOpenGL(hwnd);
ImGui_ImplOpenGL3_Init(); ImGui_ImplOpenGL3_Init();
// Win32+GL needs specific hooks for viewport, as there are specific things needed to tie Win32 and GL api.
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
IM_ASSERT(platform_io.Renderer_CreateWindow == NULL);
IM_ASSERT(platform_io.Renderer_DestroyWindow == NULL);
IM_ASSERT(platform_io.Renderer_SwapBuffers == NULL);
IM_ASSERT(platform_io.Platform_RenderWindow == NULL);
platform_io.Renderer_CreateWindow = Hook_Renderer_CreateWindow;
platform_io.Renderer_DestroyWindow = Hook_Renderer_DestroyWindow;
platform_io.Renderer_SwapBuffers = Hook_Renderer_SwapBuffers;
platform_io.Platform_RenderWindow = Hook_Platform_RenderWindow;
}
// Load Fonts // Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
@ -163,6 +223,16 @@ int main(int, char**)
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
// Update and Render additional Platform Windows
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
// Restore the OpenGL rendering context to the main window DC, since platform windows might have changed it.
wglMakeCurrent(g_MainWindow.hDC, g_hRC);
}
// Present // Present
::SwapBuffers(g_MainWindow.hDC); ::SwapBuffers(g_MainWindow.hDC);
} }

6200
imgui.cpp

File diff suppressed because it is too large Load Diff

286
imgui.h
View File

@ -31,6 +31,8 @@
#define IMGUI_VERSION "1.91.1" #define IMGUI_VERSION "1.91.1"
#define IMGUI_VERSION_NUM 19110 #define IMGUI_VERSION_NUM 19110
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
#define IMGUI_HAS_DOCK // Docking WIP branch
/* /*
@ -43,13 +45,13 @@ Index of this file:
// [SECTION] Helpers: Debug log, Memory allocations macros, ImVector<> // [SECTION] Helpers: Debug log, Memory allocations macros, ImVector<>
// [SECTION] ImGuiStyle // [SECTION] ImGuiStyle
// [SECTION] ImGuiIO // [SECTION] ImGuiIO
// [SECTION] Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload) // [SECTION] Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiWindowClass, ImGuiPayload)
// [SECTION] Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, Math Operators, ImColor) // [SECTION] Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, Math Operators, ImColor)
// [SECTION] Multi-Select API flags and structures (ImGuiMultiSelectFlags, ImGuiMultiSelectIO, ImGuiSelectionRequest, ImGuiSelectionBasicStorage, ImGuiSelectionExternalStorage) // [SECTION] Multi-Select API flags and structures (ImGuiMultiSelectFlags, ImGuiMultiSelectIO, ImGuiSelectionRequest, ImGuiSelectionBasicStorage, ImGuiSelectionExternalStorage)
// [SECTION] Drawing API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawFlags, ImDrawListFlags, ImDrawList, ImDrawData) // [SECTION] Drawing API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawFlags, ImDrawListFlags, ImDrawList, ImDrawData)
// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont) // [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont)
// [SECTION] Viewports (ImGuiViewportFlags, ImGuiViewport) // [SECTION] Viewports (ImGuiViewportFlags, ImGuiViewport)
// [SECTION] ImGuiPlatformIO + other Platform Dependent Interfaces (ImGuiPlatformImeData) // [SECTION] ImGuiPlatformIO + other Platform Dependent Interfaces (ImGuiPlatformMonitor, ImGuiPlatformImeData)
// [SECTION] Obsolete functions and types // [SECTION] Obsolete functions and types
*/ */
@ -179,8 +181,9 @@ struct ImGuiListClipper; // Helper to manually clip large list of ite
struct ImGuiMultiSelectIO; // Structure to interact with a BeginMultiSelect()/EndMultiSelect() block struct ImGuiMultiSelectIO; // Structure to interact with a BeginMultiSelect()/EndMultiSelect() block
struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame
struct ImGuiPayload; // User data payload for drag and drop operations struct ImGuiPayload; // User data payload for drag and drop operations
struct ImGuiPlatformIO; // Interface between platform/renderer backends and ImGui (e.g. Clipboard, IME hooks). Extends ImGuiIO. In docking branch, this gets extended to support multi-viewports. struct ImGuiPlatformIO; // Interface between platform/renderer backends and ImGui (e.g. Clipboard, IME, Multi-Viewport support). Extends ImGuiIO.
struct ImGuiPlatformImeData; // Platform IME data for io.PlatformSetImeDataFn() function. struct ImGuiPlatformImeData; // Platform IME data for io.PlatformSetImeDataFn() function.
struct ImGuiPlatformMonitor; // Multi-viewport support: user-provided bounds for each connected monitor/display. Used when positioning popups and tooltips to avoid them straddling monitors
struct ImGuiSelectionBasicStorage; // Optional helper to store multi-selection state + apply multi-selection requests. struct ImGuiSelectionBasicStorage; // Optional helper to store multi-selection state + apply multi-selection requests.
struct ImGuiSelectionExternalStorage;//Optional helper to apply multi-selection requests to existing randomly accessible storage. struct ImGuiSelectionExternalStorage;//Optional helper to apply multi-selection requests to existing randomly accessible storage.
struct ImGuiSelectionRequest; // A selection request (stored in ImGuiMultiSelectIO) struct ImGuiSelectionRequest; // A selection request (stored in ImGuiMultiSelectIO)
@ -192,7 +195,8 @@ struct ImGuiTableSortSpecs; // Sorting specifications for a table (often
struct ImGuiTableColumnSortSpecs; // Sorting specification for one column of a table struct ImGuiTableColumnSortSpecs; // Sorting specification for one column of a table
struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder) struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder)
struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]") struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]")
struct ImGuiViewport; // A Platform Window (always only one in 'master' branch), in the future may represent Platform Monitor struct ImGuiViewport; // A Platform Window (always 1 unless multi-viewport are enabled. One per platform window to output to). In the future may represent Platform Monitor
struct ImGuiWindowClass; // Window class (rare/advanced uses: provide hints to the platform backend via altered viewport flags and parent/child info)
// Enumerations // Enumerations
// - We don't use strongly typed enums much because they add constraints (can't extend in private code, can't store typed in bit fields, extra casting on iteration) // - We don't use strongly typed enums much because they add constraints (can't extend in private code, can't store typed in bit fields, extra casting on iteration)
@ -226,6 +230,7 @@ typedef int ImGuiChildFlags; // -> enum ImGuiChildFlags_ // Flags: f
typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc. typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc.
typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags
typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo() typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo()
typedef int ImGuiDockNodeFlags; // -> enum ImGuiDockNodeFlags_ // Flags: for DockSpace()
typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload() typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload()
typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused() typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused()
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc. typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
@ -395,10 +400,12 @@ namespace ImGui
IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options. IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options.
IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered and hoverable (e.g. not blocked by a popup/modal)? See ImGuiHoveredFlags_ for options. IMPORTANT: If you are trying to check whether your mouse should be dispatched to Dear ImGui or to your underlying app, you should not use this function! Use the 'io.WantCaptureMouse' boolean for that! Refer to FAQ entry "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?" for details. IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered and hoverable (e.g. not blocked by a popup/modal)? See ImGuiHoveredFlags_ for options. IMPORTANT: If you are trying to check whether your mouse should be dispatched to Dear ImGui or to your underlying app, you should not use this function! Use the 'io.WantCaptureMouse' boolean for that! Refer to FAQ entry "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?" for details.
IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives
IMGUI_API float GetWindowDpiScale(); // get DPI scale currently associated to the current window's viewport.
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (IT IS UNLIKELY YOU EVER NEED TO USE THIS. Consider always using GetCursorScreenPos() and GetContentRegionAvail() instead) IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (IT IS UNLIKELY YOU EVER NEED TO USE THIS. Consider always using GetCursorScreenPos() and GetContentRegionAvail() instead)
IMGUI_API ImVec2 GetWindowSize(); // get current window size (IT IS UNLIKELY YOU EVER NEED TO USE THIS. Consider always using GetCursorScreenPos() and GetContentRegionAvail() instead) IMGUI_API ImVec2 GetWindowSize(); // get current window size (IT IS UNLIKELY YOU EVER NEED TO USE THIS. Consider always using GetCursorScreenPos() and GetContentRegionAvail() instead)
IMGUI_API float GetWindowWidth(); // get current window width (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for GetWindowSize().x. IMGUI_API float GetWindowWidth(); // get current window width (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for GetWindowSize().x.
IMGUI_API float GetWindowHeight(); // get current window height (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for GetWindowSize().y. IMGUI_API float GetWindowHeight(); // get current window height (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for GetWindowSize().y.
IMGUI_API ImGuiViewport*GetWindowViewport(); // get viewport currently associated to the current window.
// Window manipulation // Window manipulation
// - Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin). // - Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin).
@ -410,6 +417,7 @@ namespace ImGui
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin() IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin()
IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // set next window scrolling value (use < 0.0f to not affect a given axis). IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // set next window scrolling value (use < 0.0f to not affect a given axis).
IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground. IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
IMGUI_API void SetNextWindowViewport(ImGuiID viewport_id); // set next window viewport
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects. IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects. IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed(). IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
@ -861,6 +869,26 @@ namespace ImGui
IMGUI_API bool TabItemButton(const char* label, ImGuiTabItemFlags flags = 0); // create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar. IMGUI_API bool TabItemButton(const char* label, ImGuiTabItemFlags flags = 0); // create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar.
IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name. IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
// Docking
// [BETA API] Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable.
// Note: You can use most Docking facilities without calling any API. You DO NOT need to call DockSpace() to use Docking!
// - Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking.
// - Drag from window menu button (upper-left button) to undock an entire node (all windows).
// - When io.ConfigDockingWithShift == true, you instead need to hold SHIFT to enable docking.
// About dockspaces:
// - Use DockSpaceOverViewport() to create a window covering the screen or a specific viewport + a dockspace inside it.
// This is often used with ImGuiDockNodeFlags_PassthruCentralNode to make it transparent.
// - Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
// - Important: Dockspaces need to be submitted _before_ any window they can host. Submit it early in your frame!
// - Important: Dockspaces need to be kept alive if hidden, otherwise windows docked into it will be undocked.
// e.g. if you have multiple tabs with a dockspace inside each tab: submit the non-visible dockspaces with ImGuiDockNodeFlags_KeepAliveOnly.
IMGUI_API ImGuiID DockSpace(ImGuiID dockspace_id, const ImVec2& size = ImVec2(0, 0), ImGuiDockNodeFlags flags = 0, const ImGuiWindowClass* window_class = NULL);
IMGUI_API ImGuiID DockSpaceOverViewport(ImGuiID dockspace_id = 0, const ImGuiViewport* viewport = NULL, ImGuiDockNodeFlags flags = 0, const ImGuiWindowClass* window_class = NULL);
IMGUI_API void SetNextWindowDockID(ImGuiID dock_id, ImGuiCond cond = 0); // set next window dock id
IMGUI_API void SetNextWindowClass(const ImGuiWindowClass* window_class); // set next window class (control docking compatibility + provide hints to platform backend via custom viewport flags and platform parent/child relationship)
IMGUI_API ImGuiID GetWindowDockID();
IMGUI_API bool IsWindowDocked(); // is current window docked into another window?
// Logging/Capture // Logging/Capture
// - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging. // - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging.
IMGUI_API void LogToTTY(int auto_open_depth = -1); // start logging to tty (stdout) IMGUI_API void LogToTTY(int auto_open_depth = -1); // start logging to tty (stdout)
@ -933,8 +961,8 @@ namespace ImGui
IMGUI_API ImGuiViewport* GetMainViewport(); // return primary/default viewport. This can never be NULL. IMGUI_API ImGuiViewport* GetMainViewport(); // return primary/default viewport. This can never be NULL.
// Background/Foreground Draw Lists // Background/Foreground Draw Lists
IMGUI_API ImDrawList* GetBackgroundDrawList(); // this draw list will be the first rendered one. Useful to quickly draw shapes/text behind dear imgui contents. IMGUI_API ImDrawList* GetBackgroundDrawList(ImGuiViewport* viewport = NULL); // get background draw list for the given viewport or viewport associated to the current window. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
IMGUI_API ImDrawList* GetForegroundDrawList(); // this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents. IMGUI_API ImDrawList* GetForegroundDrawList(ImGuiViewport* viewport = NULL); // get foreground draw list for the given viewport or viewport associated to the current window. this draw list will be the top-most rendered one. Useful to quickly draw shapes/text over dear imgui contents.
// Miscellaneous Utilities // Miscellaneous Utilities
IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped. IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped.
@ -1049,6 +1077,15 @@ namespace ImGui
IMGUI_API void* MemAlloc(size_t size); IMGUI_API void* MemAlloc(size_t size);
IMGUI_API void MemFree(void* ptr); IMGUI_API void MemFree(void* ptr);
// (Optional) Platform/OS interface for multi-viewport support
// Read comments around the ImGuiPlatformIO structure for more details.
// Note: You may use GetWindowViewport() to get the current viewport of the current window.
IMGUI_API void UpdatePlatformWindows(); // call in main loop. will call CreateWindow/ResizeWindow/etc. platform functions for each secondary viewport, and DestroyWindow for each inactive viewport.
IMGUI_API void RenderPlatformWindowsDefault(void* platform_render_arg = NULL, void* renderer_render_arg = NULL); // call in main loop. will call RenderWindow/SwapBuffers platform functions for each secondary viewport which doesn't have the ImGuiViewportFlags_Minimized flag set. May be reimplemented by user for custom rendering needs.
IMGUI_API void DestroyPlatformWindows(); // call DestroyWindow platform functions for all viewports. call from backend Shutdown() if you need to close platform windows before imgui shutdown. otherwise will be called by DestroyContext().
IMGUI_API ImGuiViewport* FindViewportByID(ImGuiID id); // this is a helper for backends.
IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle); // this is a helper for backends. the type platform_handle is decided by the backend (e.g. HWND, MyWindow*, GLFWwindow* etc.)
} // namespace ImGui } // namespace ImGui
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1079,6 +1116,7 @@ enum ImGuiWindowFlags_
ImGuiWindowFlags_NoNavInputs = 1 << 16, // No gamepad/keyboard navigation within the window ImGuiWindowFlags_NoNavInputs = 1 << 16, // No gamepad/keyboard navigation within the window
ImGuiWindowFlags_NoNavFocus = 1 << 17, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB) ImGuiWindowFlags_NoNavFocus = 1 << 17, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
ImGuiWindowFlags_UnsavedDocument = 1 << 18, // Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar. ImGuiWindowFlags_UnsavedDocument = 1 << 18, // Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
ImGuiWindowFlags_NoDocking = 1 << 19, // Disable docking of this window
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse, ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
@ -1089,6 +1127,7 @@ enum ImGuiWindowFlags_
ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup() ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup()
ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal() ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal()
ImGuiWindowFlags_ChildMenu = 1 << 28, // Don't use! For internal use by BeginMenu() ImGuiWindowFlags_ChildMenu = 1 << 28, // Don't use! For internal use by BeginMenu()
ImGuiWindowFlags_DockNodeHost = 1 << 29, // Don't use! For internal use by Begin()/NewFrame()
// Obsolete names // Obsolete names
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
@ -1302,7 +1341,7 @@ enum ImGuiFocusedFlags_
ImGuiFocusedFlags_RootWindow = 1 << 1, // Test from root window (top most parent of the current hierarchy) ImGuiFocusedFlags_RootWindow = 1 << 1, // Test from root window (top most parent of the current hierarchy)
ImGuiFocusedFlags_AnyWindow = 1 << 2, // Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ! ImGuiFocusedFlags_AnyWindow = 1 << 2, // Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ!
ImGuiFocusedFlags_NoPopupHierarchy = 1 << 3, // Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow) ImGuiFocusedFlags_NoPopupHierarchy = 1 << 3, // Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow)
//ImGuiFocusedFlags_DockHierarchy = 1 << 4, // Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow) ImGuiFocusedFlags_DockHierarchy = 1 << 4, // Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow)
ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows, ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows,
}; };
@ -1316,7 +1355,7 @@ enum ImGuiHoveredFlags_
ImGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy) ImGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy)
ImGuiHoveredFlags_AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered ImGuiHoveredFlags_AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered
ImGuiHoveredFlags_NoPopupHierarchy = 1 << 3, // IsWindowHovered() only: Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow) ImGuiHoveredFlags_NoPopupHierarchy = 1 << 3, // IsWindowHovered() only: Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow)
//ImGuiHoveredFlags_DockHierarchy = 1 << 4, // IsWindowHovered() only: Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow) ImGuiHoveredFlags_DockHierarchy = 1 << 4, // IsWindowHovered() only: Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow)
ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 5, // Return true even if a popup window is normally blocking access to this item/window ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 5, // Return true even if a popup window is normally blocking access to this item/window
//ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 6, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet. //ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 6, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 7, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns. ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 7, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns.
@ -1346,6 +1385,27 @@ enum ImGuiHoveredFlags_
ImGuiHoveredFlags_NoSharedDelay = 1 << 17, // IsItemHovered() only: Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays) ImGuiHoveredFlags_NoSharedDelay = 1 << 17, // IsItemHovered() only: Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays)
}; };
// Flags for ImGui::DockSpace(), shared/inherited by child nodes.
// (Some flags can be applied to individual nodes directly)
// FIXME-DOCK: Also see ImGuiDockNodeFlagsPrivate_ which may involve using the WIP and internal DockBuilder api.
enum ImGuiDockNodeFlags_
{
ImGuiDockNodeFlags_None = 0,
ImGuiDockNodeFlags_KeepAliveOnly = 1 << 0, // // Don't display the dockspace node but keep it alive. Windows docked into this dockspace node won't be undocked.
//ImGuiDockNodeFlags_NoCentralNode = 1 << 1, // // Disable Central Node (the node which can stay empty)
ImGuiDockNodeFlags_NoDockingOverCentralNode = 1 << 2, // // Disable docking over the Central Node, which will be always kept empty.
ImGuiDockNodeFlags_PassthruCentralNode = 1 << 3, // // Enable passthru dockspace: 1) DockSpace() will render a ImGuiCol_WindowBg background covering everything excepted the Central Node when empty. Meaning the host window should probably use SetNextWindowBgAlpha(0.0f) prior to Begin() when using this. 2) When Central Node is empty: let inputs pass-through + won't display a DockingEmptyBg background. See demo for details.
ImGuiDockNodeFlags_NoDockingSplit = 1 << 4, // // Disable other windows/nodes from splitting this node.
ImGuiDockNodeFlags_NoResize = 1 << 5, // Saved // Disable resizing node using the splitter/separators. Useful with programmatically setup dockspaces.
ImGuiDockNodeFlags_AutoHideTabBar = 1 << 6, // // Tab bar will automatically hide when there is a single window in the dock node.
ImGuiDockNodeFlags_NoUndocking = 1 << 7, // // Disable undocking this node.
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
ImGuiDockNodeFlags_NoSplit = ImGuiDockNodeFlags_NoDockingSplit, // Renamed in 1.90
ImGuiDockNodeFlags_NoDockingInCentralNode = ImGuiDockNodeFlags_NoDockingOverCentralNode, // Renamed in 1.90
#endif
};
// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload() // Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
enum ImGuiDragDropFlags_ enum ImGuiDragDropFlags_
{ {
@ -1600,6 +1660,15 @@ enum ImGuiConfigFlags_
ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead. ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead.
ImGuiConfigFlags_NoKeyboard = 1 << 6, // Instruct dear imgui to disable keyboard inputs and interactions. This is done by ignoring keyboard events and clearing existing states. ImGuiConfigFlags_NoKeyboard = 1 << 6, // Instruct dear imgui to disable keyboard inputs and interactions. This is done by ignoring keyboard events and clearing existing states.
// [BETA] Docking
ImGuiConfigFlags_DockingEnable = 1 << 7, // Docking enable flags.
// [BETA] Viewports
// When using viewports it is recommended that your default value for ImGuiCol_WindowBg is opaque (Alpha=1.0) so transition to a viewport won't be noticeable.
ImGuiConfigFlags_ViewportsEnable = 1 << 10, // Viewport enable flags (require both ImGuiBackendFlags_PlatformHasViewports + ImGuiBackendFlags_RendererHasViewports set by the respective backends)
ImGuiConfigFlags_DpiEnableScaleViewports= 1 << 14, // [BETA: Don't use] FIXME-DPI: Reposition and resize imgui windows when the DpiScale of a viewport changed (mostly useful for the main viewport hosting other window). Note that resizing the main window itself is up to your application.
ImGuiConfigFlags_DpiEnableScaleFonts = 1 << 15, // [BETA: Don't use] FIXME-DPI: Request bitmap-scaled fonts to match DpiScale. This is a very low-quality workaround. The correct way to handle DPI is _currently_ to replace the atlas and/or fonts in the Platform_OnChangedViewport callback, but this is all early work in progress.
// User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are NOT used by core Dear ImGui) // User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are NOT used by core Dear ImGui)
ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware. ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware.
ImGuiConfigFlags_IsTouchScreen = 1 << 21, // Application is using a touch screen instead of a mouse. ImGuiConfigFlags_IsTouchScreen = 1 << 21, // Application is using a touch screen instead of a mouse.
@ -1613,6 +1682,11 @@ enum ImGuiBackendFlags_
ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Backend Platform supports honoring GetMouseCursor() value to change the OS cursor shape. ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Backend Platform supports honoring GetMouseCursor() value to change the OS cursor shape.
ImGuiBackendFlags_HasSetMousePos = 1 << 2, // Backend Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set). ImGuiBackendFlags_HasSetMousePos = 1 << 2, // Backend Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set).
ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3, // Backend Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices. ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3, // Backend Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices.
// [BETA] Viewports
ImGuiBackendFlags_PlatformHasViewports = 1 << 10, // Backend Platform supports multiple viewports.
ImGuiBackendFlags_HasMouseHoveredViewport=1 << 11, // Backend Platform supports calling io.AddMouseViewportEvent() with the viewport under the mouse. IF POSSIBLE, ignore viewports with the ImGuiViewportFlags_NoInputs flag (Win32 backend, GLFW 3.30+ backend can do this, SDL backend cannot). If this cannot be done, Dear ImGui needs to use a flawed heuristic to find the viewport under.
ImGuiBackendFlags_RendererHasViewports = 1 << 12, // Backend Renderer supports multiple viewports.
}; };
// Enumeration for PushStyleColor() / PopStyleColor() // Enumeration for PushStyleColor() / PopStyleColor()
@ -1658,6 +1732,8 @@ enum ImGuiCol_
ImGuiCol_TabDimmed, // Tab background, when tab-bar is unfocused & tab is unselected ImGuiCol_TabDimmed, // Tab background, when tab-bar is unfocused & tab is unselected
ImGuiCol_TabDimmedSelected, // Tab background, when tab-bar is unfocused & tab is selected ImGuiCol_TabDimmedSelected, // Tab background, when tab-bar is unfocused & tab is selected
ImGuiCol_TabDimmedSelectedOverline,//..horizontal overline, when tab-bar is unfocused & tab is selected ImGuiCol_TabDimmedSelectedOverline,//..horizontal overline, when tab-bar is unfocused & tab is selected
ImGuiCol_DockingPreview, // Preview overlay color when about to docking something
ImGuiCol_DockingEmptyBg, // Background color for empty node (e.g. CentralNode with no window docked into it)
ImGuiCol_PlotLines, ImGuiCol_PlotLines,
ImGuiCol_PlotLinesHovered, ImGuiCol_PlotLinesHovered,
ImGuiCol_PlotHistogram, ImGuiCol_PlotHistogram,
@ -1727,6 +1803,7 @@ enum ImGuiStyleVar_
ImGuiStyleVar_SeparatorTextBorderSize, // float SeparatorTextBorderSize ImGuiStyleVar_SeparatorTextBorderSize, // float SeparatorTextBorderSize
ImGuiStyleVar_SeparatorTextAlign, // ImVec2 SeparatorTextAlign ImGuiStyleVar_SeparatorTextAlign, // ImVec2 SeparatorTextAlign
ImGuiStyleVar_SeparatorTextPadding, // ImVec2 SeparatorTextPadding ImGuiStyleVar_SeparatorTextPadding, // ImVec2 SeparatorTextPadding
ImGuiStyleVar_DockingSeparatorSize, // float DockingSeparatorSize
ImGuiStyleVar_COUNT ImGuiStyleVar_COUNT
}; };
@ -2174,6 +2251,7 @@ struct ImGuiStyle
ImVec2 SeparatorTextPadding; // Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y. ImVec2 SeparatorTextPadding; // Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
ImVec2 DisplayWindowPadding; // Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen. ImVec2 DisplayWindowPadding; // Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen.
ImVec2 DisplaySafeAreaPadding; // Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured). ImVec2 DisplaySafeAreaPadding; // Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).
float DockingSeparatorSize; // Thickness of resizing border between docked windows
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later. float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later.
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList). bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList). bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList).
@ -2237,6 +2315,18 @@ struct ImGuiIO
ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0]. ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0].
ImVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale. ImVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale.
// Docking options (when ImGuiConfigFlags_DockingEnable is set)
bool ConfigDockingNoSplit; // = false // Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
bool ConfigDockingWithShift; // = false // Enable docking with holding Shift key (reduce visual noise, allows dropping in wider space)
bool ConfigDockingAlwaysTabBar; // = false // [BETA] [FIXME: This currently creates regression with auto-sizing and general overhead] Make every single floating window display within a docking node.
bool ConfigDockingTransparentPayload;// = false // [BETA] Make window or viewport transparent when docking and only display docking boxes on the target viewport. Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.
// Viewport options (when ImGuiConfigFlags_ViewportsEnable is set)
bool ConfigViewportsNoAutoMerge; // = false; // Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it. May also set ImGuiViewportFlags_NoAutoMerge on individual viewport.
bool ConfigViewportsNoTaskBarIcon; // = false // Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, ImGuiViewportFlags_NoTaskBarIcon will be set on it.
bool ConfigViewportsNoDecoration; // = true // Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations, ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size).
bool ConfigViewportsNoDefaultParent; // = false // Disable default OS parenting to main viewport for secondary viewports. By default, viewports are marked with ParentViewportId = <main_viewport>, expecting the platform backend to setup a parent/child relationship between the OS windows (some backend may ignore this). Set to true if you want the default to be 0, then all viewports will be top-level OS windows.
// Miscellaneous options // Miscellaneous options
bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations. bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations.
bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // Swap Cmd<>Ctrl keys + OS X style text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl. bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // Swap Cmd<>Ctrl keys + OS X style text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl.
@ -2305,6 +2395,7 @@ struct ImGuiIO
IMGUI_API void AddMouseButtonEvent(int button, bool down); // Queue a mouse button change IMGUI_API void AddMouseButtonEvent(int button, bool down); // Queue a mouse button change
IMGUI_API void AddMouseWheelEvent(float wheel_x, float wheel_y); // Queue a mouse wheel update. wheel_y<0: scroll down, wheel_y>0: scroll up, wheel_x<0: scroll right, wheel_x>0: scroll left. IMGUI_API void AddMouseWheelEvent(float wheel_x, float wheel_y); // Queue a mouse wheel update. wheel_y<0: scroll down, wheel_y>0: scroll up, wheel_x<0: scroll right, wheel_x>0: scroll left.
IMGUI_API void AddMouseSourceEvent(ImGuiMouseSource source); // Queue a mouse source change (Mouse/TouchScreen/Pen) IMGUI_API void AddMouseSourceEvent(ImGuiMouseSource source); // Queue a mouse source change (Mouse/TouchScreen/Pen)
IMGUI_API void AddMouseViewportEvent(ImGuiID id); // Queue a mouse hovered viewport. Requires backend to set ImGuiBackendFlags_HasMouseHoveredViewport to call this (for multi-viewport support).
IMGUI_API void AddFocusEvent(bool focused); // Queue a gain/loss of focus for the application (generally based on OS/platform focus of your window) IMGUI_API void AddFocusEvent(bool focused); // Queue a gain/loss of focus for the application (generally based on OS/platform focus of your window)
IMGUI_API void AddInputCharacter(unsigned int c); // Queue a new character input IMGUI_API void AddInputCharacter(unsigned int c); // Queue a new character input
IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue a new character input from a UTF-16 character, it can be a surrogate IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue a new character input from a UTF-16 character, it can be a surrogate
@ -2353,6 +2444,7 @@ struct ImGuiIO
float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. >0 scrolls Up, <0 scrolls Down. Hold SHIFT to turn vertical scroll into horizontal scroll. float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. >0 scrolls Up, <0 scrolls Down. Hold SHIFT to turn vertical scroll into horizontal scroll.
float MouseWheelH; // Mouse wheel Horizontal. >0 scrolls Left, <0 scrolls Right. Most users don't have a mouse with a horizontal wheel, may not be filled by all backends. float MouseWheelH; // Mouse wheel Horizontal. >0 scrolls Left, <0 scrolls Right. Most users don't have a mouse with a horizontal wheel, may not be filled by all backends.
ImGuiMouseSource MouseSource; // Mouse actual input peripheral (Mouse/TouchScreen/Pen). ImGuiMouseSource MouseSource; // Mouse actual input peripheral (Mouse/TouchScreen/Pen).
ImGuiID MouseHoveredViewport; // (Optional) Modify using io.AddMouseViewportEvent(). With multi-viewports: viewport the OS mouse is hovering. If possible _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag is much better (few backends can handle that). Set io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport if you can provide this info. If you don't imgui will infer the value using the rectangles and last focused time of the viewports it knows about (ignoring other OS windows).
bool KeyCtrl; // Keyboard modifier down: Control bool KeyCtrl; // Keyboard modifier down: Control
bool KeyShift; // Keyboard modifier down: Shift bool KeyShift; // Keyboard modifier down: Shift
bool KeyAlt; // Keyboard modifier down: Alt bool KeyAlt; // Keyboard modifier down: Alt
@ -2376,6 +2468,7 @@ struct ImGuiIO
bool MouseCtrlLeftAsRightClick; // (OSX) Set to true when the current click was a ctrl-click that spawned a simulated right click bool MouseCtrlLeftAsRightClick; // (OSX) Set to true when the current click was a ctrl-click that spawned a simulated right click
float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked) float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
float MouseDownDurationPrev[5]; // Previous time the mouse button has been down float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
ImVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point
float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point (used for moving thresholds) float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point (used for moving thresholds)
float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui. float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui.
bool AppFocusLost; // Only modify via AddFocusEvent() bool AppFocusLost; // Only modify via AddFocusEvent()
@ -2461,6 +2554,28 @@ struct ImGuiSizeCallbackData
ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing. ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing.
}; };
// [ALPHA] Rarely used / very advanced uses only. Use with SetNextWindowClass() and DockSpace() functions.
// Important: the content of this class is still highly WIP and likely to change and be refactored
// before we stabilize Docking features. Please be mindful if using this.
// Provide hints:
// - To the platform backend via altered viewport flags (enable/disable OS decoration, OS task bar icons, etc.)
// - To the platform backend for OS level parent/child relationships of viewport.
// - To the docking system for various options and filtering.
struct ImGuiWindowClass
{
ImGuiID ClassId; // User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others.
ImGuiID ParentViewportId; // Hint for the platform backend. -1: use default. 0: request platform backend to not parent the platform. != 0: request platform backend to create a parent<>child relationship between the platform windows. Not conforming backends are free to e.g. parent every viewport to the main viewport or not.
ImGuiID FocusRouteParentWindowId; // ID of parent window for shortcut focus route evaluation, e.g. Shortcut() call from Parent Window will succeed when this window is focused.
ImGuiViewportFlags ViewportFlagsOverrideSet; // Viewport flags to set when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
ImGuiViewportFlags ViewportFlagsOverrideClear; // Viewport flags to clear when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
ImGuiTabItemFlags TabItemFlagsOverrideSet; // [EXPERIMENTAL] TabItem flags to set when a window of this class gets submitted into a dock node tab bar. May use with ImGuiTabItemFlags_Leading or ImGuiTabItemFlags_Trailing.
ImGuiDockNodeFlags DockNodeFlagsOverrideSet; // [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
bool DockingAlwaysTabBar; // Set to true to enforce single floating windows of this class always having their own docking node (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
bool DockingAllowUnclassed; // Set to true to allow windows of this class to be docked/merged with an unclassed window. // FIXME-DOCK: Move to DockNodeFlags override?
ImGuiWindowClass() { memset(this, 0, sizeof(*this)); ParentViewportId = (ImGuiID)-1; DockingAllowUnclassed = true; }
};
// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload() // Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload()
struct ImGuiPayload struct ImGuiPayload
{ {
@ -3164,7 +3279,7 @@ struct ImDrawList
struct ImDrawData struct ImDrawData
{ {
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called. bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
int CmdListsCount; // Number of ImDrawList* to render (should always be == CmdLists.size) int CmdListsCount; // Number of ImDrawList* to render
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
ImVector<ImDrawList*> CmdLists; // Array of ImDrawList* to render. The ImDrawLists are owned by ImGuiContext and only pointed to from here. ImVector<ImDrawList*> CmdLists; // Array of ImDrawList* to render. The ImDrawLists are owned by ImGuiContext and only pointed to from here.
@ -3447,11 +3562,24 @@ enum ImGuiViewportFlags_
ImGuiViewportFlags_None = 0, ImGuiViewportFlags_None = 0,
ImGuiViewportFlags_IsPlatformWindow = 1 << 0, // Represent a Platform Window ImGuiViewportFlags_IsPlatformWindow = 1 << 0, // Represent a Platform Window
ImGuiViewportFlags_IsPlatformMonitor = 1 << 1, // Represent a Platform Monitor (unused yet) ImGuiViewportFlags_IsPlatformMonitor = 1 << 1, // Represent a Platform Monitor (unused yet)
ImGuiViewportFlags_OwnedByApp = 1 << 2, // Platform Window: Is created/managed by the application (rather than a dear imgui backend) ImGuiViewportFlags_OwnedByApp = 1 << 2, // Platform Window: Is created/managed by the user application? (rather than our backend)
ImGuiViewportFlags_NoDecoration = 1 << 3, // Platform Window: Disable platform decorations: title bar, borders, etc. (generally set all windows, but if ImGuiConfigFlags_ViewportsDecoration is set we only set this on popups/tooltips)
ImGuiViewportFlags_NoTaskBarIcon = 1 << 4, // Platform Window: Disable platform task bar icon (generally set on popups/tooltips, or all windows if ImGuiConfigFlags_ViewportsNoTaskBarIcon is set)
ImGuiViewportFlags_NoFocusOnAppearing = 1 << 5, // Platform Window: Don't take focus when created.
ImGuiViewportFlags_NoFocusOnClick = 1 << 6, // Platform Window: Don't take focus when clicked on.
ImGuiViewportFlags_NoInputs = 1 << 7, // Platform Window: Make mouse pass through so we can drag this window while peaking behind it.
ImGuiViewportFlags_NoRendererClear = 1 << 8, // Platform Window: Renderer doesn't need to clear the framebuffer ahead (because we will fill it entirely).
ImGuiViewportFlags_NoAutoMerge = 1 << 9, // Platform Window: Avoid merging this window into another host window. This can only be set via ImGuiWindowClass viewport flags override (because we need to now ahead if we are going to create a viewport in the first place!).
ImGuiViewportFlags_TopMost = 1 << 10, // Platform Window: Display on top (for tooltips only).
ImGuiViewportFlags_CanHostOtherWindows = 1 << 11, // Viewport can host multiple imgui windows (secondary viewports are associated to a single window). // FIXME: In practice there's still probably code making the assumption that this is always and only on the MainViewport. Will fix once we add support for "no main viewport".
// Output status flags (from Platform)
ImGuiViewportFlags_IsMinimized = 1 << 12, // Platform Window: Window is minimized, can skip render. When minimized we tend to avoid using the viewport pos/size for clipping window or testing if they are contained in the viewport.
ImGuiViewportFlags_IsFocused = 1 << 13, // Platform Window: Window is focused (last call to Platform_GetWindowFocus() returned true)
}; };
// - Currently represents the Platform Window created by the application which is hosting our Dear ImGui windows. // - Currently represents the Platform Window created by the application which is hosting our Dear ImGui windows.
// - In 'docking' branch with multi-viewport enabled, we extend this concept to have multiple active viewports. // - With multi-viewport enabled, we extend this concept to have multiple active viewports.
// - In the future we will extend this concept further to also represent Platform Monitor and support a "no main platform window" operation mode. // - In the future we will extend this concept further to also represent Platform Monitor and support a "no main platform window" operation mode.
// - About Main Area vs Work Area: // - About Main Area vs Work Area:
// - Main Area = entire viewport. // - Main Area = entire viewport.
@ -3465,12 +3593,26 @@ struct ImGuiViewport
ImVec2 Size; // Main Area: Size of the viewport. ImVec2 Size; // Main Area: Size of the viewport.
ImVec2 WorkPos; // Work Area: Position of the viewport minus task bars, menus bars, status bars (>= Pos) ImVec2 WorkPos; // Work Area: Position of the viewport minus task bars, menus bars, status bars (>= Pos)
ImVec2 WorkSize; // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size) ImVec2 WorkSize; // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size)
float DpiScale; // 1.0f = 96 DPI = No extra scale.
ImGuiID ParentViewportId; // (Advanced) 0: no parent. Instruct the platform backend to setup a parent/child relationship between platform windows.
ImDrawData* DrawData; // The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame().
// Platform/Backend Dependent Data // Platform/Backend Dependent Data
void* PlatformHandle; // void* to hold higher-level, platform window handle (e.g. HWND, GLFWWindow*, SDL_Window*) // Our design separate the Renderer and Platform backends to facilitate combining default backends with each others.
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (under Win32 this is expected to be a HWND, unused for other platforms) // When our create your own backend for a custom engine, it is possible that both Renderer and Platform will be handled
// by the same system and you may not need to use all the UserData/Handle fields.
// The library never uses those fields, they are merely storage to facilitate backend implementation.
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function.
void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function.
void* PlatformHandle; // void* to hold higher-level, platform window handle (e.g. HWND, GLFWWindow*, SDL_Window*), for FindViewportByPlatformHandle().
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (under Win32 this is expected to be a HWND, unused for other platforms), when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
bool PlatformWindowCreated; // Platform window has been created (Platform_CreateWindow() has been called). This is false during the first frame where a viewport is being created.
bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position)
bool PlatformRequestResize; // Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size)
bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)
ImGuiViewport() { memset(this, 0, sizeof(*this)); } ImGuiViewport() { memset(this, 0, sizeof(*this)); }
~ImGuiViewport() { IM_ASSERT(PlatformUserData == NULL && RendererUserData == NULL); }
// Helpers // Helpers
ImVec2 GetCenter() const { return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); } ImVec2 GetCenter() const { return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); }
@ -3478,7 +3620,53 @@ struct ImGuiViewport
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] Platform Dependent Interfaces // [SECTION] ImGuiPlatformIO + other Platform Dependent Interfaces (ImGuiPlatformMonitor, ImGuiPlatformImeData)
//-----------------------------------------------------------------------------
// [BETA] (Optional) Multi-Viewport Support!
// If you are new to Dear ImGui and trying to integrate it into your engine, you can probably ignore this for now.
//
// This feature allows you to seamlessly drag Dear ImGui windows outside of your application viewport.
// This is achieved by creating new Platform/OS windows on the fly, and rendering into them.
// Dear ImGui manages the viewport structures, and the backend create and maintain one Platform/OS window for each of those viewports.
//
// See Recap: https://github.com/ocornut/imgui/wiki/Multi-Viewports
// See Glossary https://github.com/ocornut/imgui/wiki/Glossary for details about some of the terminology.
//
// About the coordinates system:
// - When multi-viewports are enabled, all Dear ImGui coordinates become absolute coordinates (same as OS coordinates!)
// - So e.g. ImGui::SetNextWindowPos(ImVec2(0,0)) will position a window relative to your primary monitor!
// - If you want to position windows relative to your main application viewport, use ImGui::GetMainViewport()->Pos as a base position.
//
// Steps to use multi-viewports in your application, when using a default backend from the examples/ folder:
// - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// - Backend: The backend initialization will setup all necessary ImGuiPlatformIO's functions and update monitors info every frame.
// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render().
// - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls.
//
// Steps to use multi-viewports in your application, when using a custom backend:
// - Important: THIS IS NOT EASY TO DO and comes with many subtleties not described here!
// It's also an experimental feature, so some of the requirements may evolve.
// Consider using default backends if you can. Either way, carefully follow and refer to examples/ backends for details.
// - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// - Backend: Hook ImGuiPlatformIO's Platform_* and Renderer_* callbacks (see below).
// Set 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports' and 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports'.
// Update ImGuiPlatformIO's Monitors list every frame.
// Update MousePos every frame, in absolute coordinates.
// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render().
// You may skip calling RenderPlatformWindowsDefault() if its API is not convenient for your needs. Read comments below.
// - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls.
//
// About ImGui::RenderPlatformWindowsDefault():
// - This function is a mostly a _helper_ for the common-most cases, and to facilitate using default backends.
// - You can check its simple source code to understand what it does.
// It basically iterates secondary viewports and call 4 functions that are setup in ImGuiPlatformIO, if available:
// Platform_RenderWindow(), Renderer_RenderWindow(), Platform_SwapBuffers(), Renderer_SwapBuffers()
// Those functions pointers exists only for the benefit of RenderPlatformWindowsDefault().
// - If you have very specific rendering needs (e.g. flipping multiple swap-chain simultaneously, unusual sync/threading issues, etc.),
// you may be tempted to ignore RenderPlatformWindowsDefault() and write customized code to perform your renderingg.
// You may decide to setup the platform_io's *RenderWindow and *SwapBuffers pointers and call your functions through those pointers,
// or you may decide to never setup those pointers and call your code directly. They are a convenience, not an obligatory interface.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Access via ImGui::GetPlatformIO() // Access via ImGui::GetPlatformIO()
@ -3487,7 +3675,7 @@ struct ImGuiPlatformIO
IMGUI_API ImGuiPlatformIO(); IMGUI_API ImGuiPlatformIO();
//------------------------------------------------------------------ //------------------------------------------------------------------
// Input - Interface with OS/backends // Input - Interface with OS/backends (basic)
//------------------------------------------------------------------ //------------------------------------------------------------------
// Optional: Access OS clipboard // Optional: Access OS clipboard
@ -3510,6 +3698,74 @@ struct ImGuiPlatformIO
// Optional: Platform locale // Optional: Platform locale
// [Experimental] Configure decimal point e.g. '.' or ',' useful for some languages (e.g. German), generally pulled from *localeconv()->decimal_point // [Experimental] Configure decimal point e.g. '.' or ',' useful for some languages (e.g. German), generally pulled from *localeconv()->decimal_point
ImWchar Platform_LocaleDecimalPoint; // '.' ImWchar Platform_LocaleDecimalPoint; // '.'
//------------------------------------------------------------------
// Input - Interface with OS/backends (Multi-Viewport support!)
//------------------------------------------------------------------
// For reference, the second column shows which function are generally calling the Platform Functions:
// N = ImGui::NewFrame() ~ beginning of the dear imgui frame: read info from platform/OS windows (latest size/position)
// F = ImGui::Begin(), ImGui::EndFrame() ~ during the dear imgui frame
// U = ImGui::UpdatePlatformWindows() ~ after the dear imgui frame: create and update all platform/OS windows
// R = ImGui::RenderPlatformWindowsDefault() ~ render
// D = ImGui::DestroyPlatformWindows() ~ shutdown
// The general idea is that NewFrame() we will read the current Platform/OS state, and UpdatePlatformWindows() will write to it.
// The handlers are designed so we can mix and match two imgui_impl_xxxx files, one Platform backend and one Renderer backend.
// Custom engine backends will often provide both Platform and Renderer interfaces together and so may not need to use all functions.
// Platform functions are typically called _before_ their Renderer counterpart, apart from Destroy which are called the other way.
// Platform Backend functions (e.g. Win32, GLFW, SDL) ------------------- Called by -----
void (*Platform_CreateWindow)(ImGuiViewport* vp); // . . U . . // Create a new platform window for the given viewport
void (*Platform_DestroyWindow)(ImGuiViewport* vp); // N . U . D //
void (*Platform_ShowWindow)(ImGuiViewport* vp); // . . U . . // Newly created windows are initially hidden so SetWindowPos/Size/Title can be called on them before showing the window
void (*Platform_SetWindowPos)(ImGuiViewport* vp, ImVec2 pos); // . . U . . // Set platform window position (given the upper-left corner of client area)
ImVec2 (*Platform_GetWindowPos)(ImGuiViewport* vp); // N . . . . //
void (*Platform_SetWindowSize)(ImGuiViewport* vp, ImVec2 size); // . . U . . // Set platform window client area size (ignoring OS decorations such as OS title bar etc.)
ImVec2 (*Platform_GetWindowSize)(ImGuiViewport* vp); // N . . . . // Get platform window client area size
void (*Platform_SetWindowFocus)(ImGuiViewport* vp); // N . . . . // Move window to front and set input focus
bool (*Platform_GetWindowFocus)(ImGuiViewport* vp); // . . U . . //
bool (*Platform_GetWindowMinimized)(ImGuiViewport* vp); // N . . . . // Get platform window minimized state. When minimized, we generally won't attempt to get/set size and contents will be culled more easily
void (*Platform_SetWindowTitle)(ImGuiViewport* vp, const char* str); // . . U . . // Set platform window title (given an UTF-8 string)
void (*Platform_SetWindowAlpha)(ImGuiViewport* vp, float alpha); // . . U . . // (Optional) Setup global transparency (not per-pixel transparency)
void (*Platform_UpdateWindow)(ImGuiViewport* vp); // . . U . . // (Optional) Called by UpdatePlatformWindows(). Optional hook to allow the platform backend from doing general book-keeping every frame.
void (*Platform_RenderWindow)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Main rendering (platform side! This is often unused, or just setting a "current" context for OpenGL bindings). 'render_arg' is the value passed to RenderPlatformWindowsDefault().
void (*Platform_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers (platform side! This is often unused!). 'render_arg' is the value passed to RenderPlatformWindowsDefault().
float (*Platform_GetWindowDpiScale)(ImGuiViewport* vp); // N . . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Return DPI scale for this viewport. 1.0f = 96 DPI.
void (*Platform_OnChangedViewport)(ImGuiViewport* vp); // . F . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Called during Begin() every time the viewport we are outputting into changes, so backend has a chance to swap fonts to adjust style.
ImVec4 (*Platform_GetWindowWorkAreaInsets)(ImGuiViewport* vp); // N . . . . // (Optional) [BETA] Get initial work area inset for the viewport (won't be covered by main menu bar, dockspace over viewport etc.). Default to (0,0),(0,0). 'safeAreaInsets' in iOS land, 'DisplayCutout' in Android land.
int (*Platform_CreateVkSurface)(ImGuiViewport* vp, ImU64 vk_inst, const void* vk_allocators, ImU64* out_vk_surface); // (Optional) For a Vulkan Renderer to call into Platform code (since the surface creation needs to tie them both).
// Renderer Backend functions (e.g. DirectX, OpenGL, Vulkan) ------------ Called by -----
void (*Renderer_CreateWindow)(ImGuiViewport* vp); // . . U . . // Create swap chain, frame buffers etc. (called after Platform_CreateWindow)
void (*Renderer_DestroyWindow)(ImGuiViewport* vp); // N . U . D // Destroy swap chain, frame buffers etc. (called before Platform_DestroyWindow)
void (*Renderer_SetWindowSize)(ImGuiViewport* vp, ImVec2 size); // . . U . . // Resize swap chain, frame buffers etc. (called after Platform_SetWindowSize)
void (*Renderer_RenderWindow)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Clear framebuffer, setup render target, then render the viewport->DrawData. 'render_arg' is the value passed to RenderPlatformWindowsDefault().
void (*Renderer_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers. 'render_arg' is the value passed to RenderPlatformWindowsDefault().
// (Optional) Monitor list
// - Updated by: app/backend. Update every frame to dynamically support changing monitor or DPI configuration.
// - Used by: dear imgui to query DPI info, clamp popups/tooltips within same monitor and not have them straddle monitors.
ImVector<ImGuiPlatformMonitor> Monitors;
//------------------------------------------------------------------
// Output - List of viewports to render into platform windows
//------------------------------------------------------------------
// Viewports list (the list is updated by calling ImGui::EndFrame or ImGui::Render)
// (in the future we will attempt to organize this feature to remove the need for a "main viewport")
ImVector<ImGuiViewport*> Viewports; // Main viewports, followed by all secondary viewports.
};
// (Optional) This is required when enabling multi-viewport. Represent the bounds of each connected monitor/display and their DPI.
// We use this information for multiple DPI support + clamping the position of popups and tooltips so they don't straddle multiple monitors.
struct ImGuiPlatformMonitor
{
ImVec2 MainPos, MainSize; // Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
ImVec2 WorkPos, WorkSize; // Coordinates without task bars / side bars / menu bars. Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
float DpiScale; // 1.0f = 96 DPI
void* PlatformHandle; // Backend dependant data (e.g. HMONITOR, GLFWmonitor*, SDL Display Index, NSScreen*)
ImGuiPlatformMonitor() { MainPos = MainSize = WorkPos = WorkSize = ImVec2(0, 0); DpiScale = 1.0f; PlatformHandle = NULL; }
}; };
// (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function. // (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function.

View File

@ -94,6 +94,7 @@ Index of this file:
// [SECTION] Example App: Fullscreen window / ShowExampleAppFullscreen() // [SECTION] Example App: Fullscreen window / ShowExampleAppFullscreen()
// [SECTION] Example App: Manipulating window titles / ShowExampleAppWindowTitles() // [SECTION] Example App: Manipulating window titles / ShowExampleAppWindowTitles()
// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering() // [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
// [SECTION] Example App: Docking, DockSpace / ShowExampleAppDockSpace()
// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments() // [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
// [SECTION] Example App: Assets Browser / ShowExampleAppAssetsBrowser() // [SECTION] Example App: Assets Browser / ShowExampleAppAssetsBrowser()
@ -207,6 +208,7 @@ 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);
static void ShowExampleAppCustomRendering(bool* p_open); static void ShowExampleAppCustomRendering(bool* p_open);
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);
@ -248,6 +250,16 @@ static void HelpMarker(const char* desc)
} }
} }
static void ShowDockingDisabledMessage()
{
ImGuiIO& io = ImGui::GetIO();
ImGui::Text("ERROR: Docking is not enabled! See Demo > Configuration.");
ImGui::Text("Set io.ConfigFlags |= ImGuiConfigFlags_DockingEnable in your code, or ");
ImGui::SameLine(0.0f, 0.0f);
if (ImGui::SmallButton("click here"))
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
}
// Helper to wire demo markers located in code to an interactive browser // Helper to wire demo markers located in code to an interactive browser
typedef void (*ImGuiDemoMarkerCallback)(const char* file, int line, const char* section, void* user_data); typedef void (*ImGuiDemoMarkerCallback)(const char* file, int line, const char* section, void* user_data);
extern ImGuiDemoMarkerCallback GImGuiDemoMarkerCallback; extern ImGuiDemoMarkerCallback GImGuiDemoMarkerCallback;
@ -352,6 +364,7 @@ struct ImGuiDemoWindowData
bool ShowAppConsole = false; bool ShowAppConsole = false;
bool ShowAppCustomRendering = false; bool ShowAppCustomRendering = false;
bool ShowAppDocuments = false; bool ShowAppDocuments = false;
bool ShowAppDockSpace = false;
bool ShowAppLog = false; bool ShowAppLog = false;
bool ShowAppLayout = false; bool ShowAppLayout = false;
bool ShowAppPropertyEditor = false; bool ShowAppPropertyEditor = false;
@ -390,7 +403,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
// Examples Apps (accessible from the "Examples" menu) // Examples Apps (accessible from the "Examples" menu)
if (demo_data.ShowMainMenuBar) { ShowExampleAppMainMenuBar(); } if (demo_data.ShowMainMenuBar) { ShowExampleAppMainMenuBar(); }
if (demo_data.ShowAppDocuments) { ShowExampleAppDocuments(&demo_data.ShowAppDocuments); } 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_data.ShowAppDocuments) { ShowExampleAppDocuments(&demo_data.ShowAppDocuments); } // ...process the Document app next, as it may also use a DockSpace()
if (demo_data.ShowAppAssetsBrowser) { ShowExampleAppAssetsBrowser(&demo_data.ShowAppAssetsBrowser); } if (demo_data.ShowAppAssetsBrowser) { ShowExampleAppAssetsBrowser(&demo_data.ShowAppAssetsBrowser); }
if (demo_data.ShowAppConsole) { ShowExampleAppConsole(&demo_data.ShowAppConsole); } if (demo_data.ShowAppConsole) { ShowExampleAppConsole(&demo_data.ShowAppConsole); }
if (demo_data.ShowAppCustomRendering) { ShowExampleAppCustomRendering(&demo_data.ShowAppCustomRendering); } if (demo_data.ShowAppCustomRendering) { ShowExampleAppCustomRendering(&demo_data.ShowAppCustomRendering); }
@ -427,6 +441,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
static bool no_nav = false; static bool no_nav = false;
static bool no_background = false; static bool no_background = false;
static bool no_bring_to_front = false; static bool no_bring_to_front = false;
static bool no_docking = false;
static bool unsaved_document = false; static bool unsaved_document = false;
ImGuiWindowFlags window_flags = 0; ImGuiWindowFlags window_flags = 0;
@ -439,6 +454,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
if (no_nav) window_flags |= ImGuiWindowFlags_NoNav; if (no_nav) window_flags |= ImGuiWindowFlags_NoNav;
if (no_background) window_flags |= ImGuiWindowFlags_NoBackground; if (no_background) window_flags |= ImGuiWindowFlags_NoBackground;
if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus; if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus;
if (no_docking) window_flags |= ImGuiWindowFlags_NoDocking;
if (unsaved_document) window_flags |= ImGuiWindowFlags_UnsavedDocument; if (unsaved_document) window_flags |= ImGuiWindowFlags_UnsavedDocument;
if (no_close) p_open = NULL; // Don't pass our bool* to Begin if (no_close) p_open = NULL; // Don't pass our bool* to Begin
@ -529,6 +545,44 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor); ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
ImGui::SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something)."); ImGui::SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).");
ImGui::SeparatorText("Docking");
ImGui::CheckboxFlags("io.ConfigFlags: DockingEnable", &io.ConfigFlags, ImGuiConfigFlags_DockingEnable);
ImGui::SameLine();
if (io.ConfigDockingWithShift)
HelpMarker("Drag from window title bar or their tab to dock/undock. Hold SHIFT to enable docking.\n\nDrag from window menu button (upper-left button) to undock an entire node (all windows).");
else
HelpMarker("Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking.\n\nDrag from window menu button (upper-left button) to undock an entire node (all windows).");
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
ImGui::Indent();
ImGui::Checkbox("io.ConfigDockingNoSplit", &io.ConfigDockingNoSplit);
ImGui::SameLine(); HelpMarker("Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.");
ImGui::Checkbox("io.ConfigDockingWithShift", &io.ConfigDockingWithShift);
ImGui::SameLine(); HelpMarker("Enable docking when holding Shift only (allow to drop in wider space, reduce visual noise)");
ImGui::Checkbox("io.ConfigDockingAlwaysTabBar", &io.ConfigDockingAlwaysTabBar);
ImGui::SameLine(); HelpMarker("Create a docking node and tab-bar on single floating windows.");
ImGui::Checkbox("io.ConfigDockingTransparentPayload", &io.ConfigDockingTransparentPayload);
ImGui::SameLine(); HelpMarker("Make window or viewport transparent when docking and only display docking boxes on the target viewport. Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.");
ImGui::Unindent();
}
ImGui::SeparatorText("Multi-viewports");
ImGui::CheckboxFlags("io.ConfigFlags: ViewportsEnable", &io.ConfigFlags, ImGuiConfigFlags_ViewportsEnable);
ImGui::SameLine(); HelpMarker("[beta] Enable beta multi-viewports support. See ImGuiPlatformIO for details.");
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
ImGui::Indent();
ImGui::Checkbox("io.ConfigViewportsNoAutoMerge", &io.ConfigViewportsNoAutoMerge);
ImGui::SameLine(); HelpMarker("Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it.");
ImGui::Checkbox("io.ConfigViewportsNoTaskBarIcon", &io.ConfigViewportsNoTaskBarIcon);
ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the task bar icon state right away).");
ImGui::Checkbox("io.ConfigViewportsNoDecoration", &io.ConfigViewportsNoDecoration);
ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the decoration right away).");
ImGui::Checkbox("io.ConfigViewportsNoDefaultParent", &io.ConfigViewportsNoDefaultParent);
ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the parenting right away).");
ImGui::Unindent();
}
ImGui::SeparatorText("Widgets"); ImGui::SeparatorText("Widgets");
ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink); ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink);
ImGui::SameLine(); HelpMarker("Enable blinking cursor (optional as some users consider it to be distracting)."); ImGui::SameLine(); HelpMarker("Enable blinking cursor (optional as some users consider it to be distracting).");
@ -568,12 +622,16 @@ void ImGui::ShowDemoWindow(bool* p_open)
"Those flags are set by the backends (imgui_impl_xxx files) to specify their capabilities.\n" "Those flags are set by the backends (imgui_impl_xxx files) to specify their capabilities.\n"
"Here we expose them as read-only fields to avoid breaking interactions with your backend."); "Here we expose them as read-only fields to avoid breaking interactions with your backend.");
// Make a local copy to avoid modifying actual backend flags.
// FIXME: Maybe we need a BeginReadonly() equivalent to keep label bright? // FIXME: Maybe we need a BeginReadonly() equivalent to keep label bright?
ImGui::BeginDisabled(); ImGui::BeginDisabled();
ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &io.BackendFlags, ImGuiBackendFlags_HasGamepad); ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &io.BackendFlags, ImGuiBackendFlags_HasGamepad);
ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &io.BackendFlags, ImGuiBackendFlags_HasMouseCursors); ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &io.BackendFlags, ImGuiBackendFlags_HasMouseCursors);
ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", &io.BackendFlags, ImGuiBackendFlags_HasSetMousePos); ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", &io.BackendFlags, ImGuiBackendFlags_HasSetMousePos);
ImGui::CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", &io.BackendFlags, ImGuiBackendFlags_RendererHasVtxOffset); ImGui::CheckboxFlags("io.BackendFlags: PlatformHasViewports", &io.BackendFlags, ImGuiBackendFlags_PlatformHasViewports);
ImGui::CheckboxFlags("io.BackendFlags: HasMouseHoveredViewport",&io.BackendFlags, ImGuiBackendFlags_HasMouseHoveredViewport);
ImGui::CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", &io.BackendFlags, ImGuiBackendFlags_RendererHasVtxOffset);
ImGui::CheckboxFlags("io.BackendFlags: RendererHasViewports", &io.BackendFlags, ImGuiBackendFlags_RendererHasViewports);
ImGui::EndDisabled(); ImGui::EndDisabled();
ImGui::TreePop(); ImGui::TreePop();
ImGui::Spacing(); ImGui::Spacing();
@ -624,6 +682,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::TableNextColumn(); ImGui::Checkbox("No nav", &no_nav); ImGui::TableNextColumn(); ImGui::Checkbox("No nav", &no_nav);
ImGui::TableNextColumn(); ImGui::Checkbox("No background", &no_background); ImGui::TableNextColumn(); ImGui::Checkbox("No background", &no_background);
ImGui::TableNextColumn(); ImGui::Checkbox("No bring to front", &no_bring_to_front); ImGui::TableNextColumn(); ImGui::Checkbox("No bring to front", &no_bring_to_front);
ImGui::TableNextColumn(); ImGui::Checkbox("No docking", &no_docking);
ImGui::TableNextColumn(); ImGui::Checkbox("Unsaved document", &unsaved_document); ImGui::TableNextColumn(); ImGui::Checkbox("Unsaved document", &unsaved_document);
ImGui::EndTable(); ImGui::EndTable();
} }
@ -666,6 +725,7 @@ static void ShowDemoWindowMenuBar(ImGuiDemoWindowData* demo_data)
ImGui::MenuItem("Console", NULL, &demo_data->ShowAppConsole); ImGui::MenuItem("Console", NULL, &demo_data->ShowAppConsole);
ImGui::MenuItem("Custom rendering", NULL, &demo_data->ShowAppCustomRendering); ImGui::MenuItem("Custom rendering", NULL, &demo_data->ShowAppCustomRendering);
ImGui::MenuItem("Documents", NULL, &demo_data->ShowAppDocuments); ImGui::MenuItem("Documents", NULL, &demo_data->ShowAppDocuments);
ImGui::MenuItem("Dockspace", NULL, &demo_data->ShowAppDockSpace);
ImGui::MenuItem("Log", NULL, &demo_data->ShowAppLog); ImGui::MenuItem("Log", NULL, &demo_data->ShowAppLog);
ImGui::MenuItem("Property editor", NULL, &demo_data->ShowAppPropertyEditor); ImGui::MenuItem("Property editor", NULL, &demo_data->ShowAppPropertyEditor);
ImGui::MenuItem("Simple layout", NULL, &demo_data->ShowAppLayout); ImGui::MenuItem("Simple layout", NULL, &demo_data->ShowAppLayout);
@ -2776,18 +2836,24 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
"IsWindowFocused() = %d\n" "IsWindowFocused() = %d\n"
"IsWindowFocused(_ChildWindows) = %d\n" "IsWindowFocused(_ChildWindows) = %d\n"
"IsWindowFocused(_ChildWindows|_NoPopupHierarchy) = %d\n" "IsWindowFocused(_ChildWindows|_NoPopupHierarchy) = %d\n"
"IsWindowFocused(_ChildWindows|_DockHierarchy) = %d\n"
"IsWindowFocused(_ChildWindows|_RootWindow) = %d\n" "IsWindowFocused(_ChildWindows|_RootWindow) = %d\n"
"IsWindowFocused(_ChildWindows|_RootWindow|_NoPopupHierarchy) = %d\n" "IsWindowFocused(_ChildWindows|_RootWindow|_NoPopupHierarchy) = %d\n"
"IsWindowFocused(_ChildWindows|_RootWindow|_DockHierarchy) = %d\n"
"IsWindowFocused(_RootWindow) = %d\n" "IsWindowFocused(_RootWindow) = %d\n"
"IsWindowFocused(_RootWindow|_NoPopupHierarchy) = %d\n" "IsWindowFocused(_RootWindow|_NoPopupHierarchy) = %d\n"
"IsWindowFocused(_RootWindow|_DockHierarchy) = %d\n"
"IsWindowFocused(_AnyWindow) = %d\n", "IsWindowFocused(_AnyWindow) = %d\n",
ImGui::IsWindowFocused(), ImGui::IsWindowFocused(),
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows), ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows),
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_NoPopupHierarchy), ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_NoPopupHierarchy),
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_DockHierarchy),
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow), ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow),
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_NoPopupHierarchy), ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_NoPopupHierarchy),
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_DockHierarchy),
ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow), ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow),
ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_NoPopupHierarchy), ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_NoPopupHierarchy),
ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_DockHierarchy),
ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow)); ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow));
// Testing IsWindowHovered() function with its various flags. // Testing IsWindowHovered() function with its various flags.
@ -2797,10 +2863,13 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
"IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n" "IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n"
"IsWindowHovered(_ChildWindows) = %d\n" "IsWindowHovered(_ChildWindows) = %d\n"
"IsWindowHovered(_ChildWindows|_NoPopupHierarchy) = %d\n" "IsWindowHovered(_ChildWindows|_NoPopupHierarchy) = %d\n"
"IsWindowHovered(_ChildWindows|_DockHierarchy) = %d\n"
"IsWindowHovered(_ChildWindows|_RootWindow) = %d\n" "IsWindowHovered(_ChildWindows|_RootWindow) = %d\n"
"IsWindowHovered(_ChildWindows|_RootWindow|_NoPopupHierarchy) = %d\n" "IsWindowHovered(_ChildWindows|_RootWindow|_NoPopupHierarchy) = %d\n"
"IsWindowHovered(_ChildWindows|_RootWindow|_DockHierarchy) = %d\n"
"IsWindowHovered(_RootWindow) = %d\n" "IsWindowHovered(_RootWindow) = %d\n"
"IsWindowHovered(_RootWindow|_NoPopupHierarchy) = %d\n" "IsWindowHovered(_RootWindow|_NoPopupHierarchy) = %d\n"
"IsWindowHovered(_RootWindow|_DockHierarchy) = %d\n"
"IsWindowHovered(_ChildWindows|_AllowWhenBlockedByPopup) = %d\n" "IsWindowHovered(_ChildWindows|_AllowWhenBlockedByPopup) = %d\n"
"IsWindowHovered(_AnyWindow) = %d\n" "IsWindowHovered(_AnyWindow) = %d\n"
"IsWindowHovered(_Stationary) = %d\n", "IsWindowHovered(_Stationary) = %d\n",
@ -2809,10 +2878,13 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem), ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows), ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows),
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy), ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy),
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_DockHierarchy),
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow), ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow),
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_NoPopupHierarchy), ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_NoPopupHierarchy),
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_DockHierarchy),
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow), ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow),
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_NoPopupHierarchy), ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_NoPopupHierarchy),
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_DockHierarchy),
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_AllowWhenBlockedByPopup), ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_AllowWhenBlockedByPopup),
ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow), ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow),
ImGui::IsWindowHovered(ImGuiHoveredFlags_Stationary)); ImGui::IsWindowHovered(ImGuiHoveredFlags_Stationary));
@ -2825,10 +2897,13 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
// Calling IsItemHovered() after begin returns the hovered status of the title bar. // Calling IsItemHovered() after begin returns the hovered status of the title bar.
// This is useful in particular if you want to create a context menu associated to the title bar of a window. // This is useful in particular if you want to create a context menu associated to the title bar of a window.
// This will also work when docked into a Tab (the Tab replace the Title Bar and guarantee the same properties).
static bool test_window = false; static bool test_window = false;
ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window); ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
if (test_window) if (test_window)
{ {
// FIXME-DOCK: This window cannot be docked within the ImGui Demo window, this will cause a feedback loop and get them stuck.
// Could we fix this through an ImGuiWindowClass feature? Or an API call to tag our parent as "don't skip items"?
ImGui::Begin("Title bar Hovered/Active tests", &test_window); ImGui::Begin("Title bar Hovered/Active tests", &test_window);
if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered() if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
{ {
@ -7702,6 +7777,12 @@ void ImGui::ShowAboutWindow(bool* p_open)
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
ImGui::Text("define: __EMSCRIPTEN__"); ImGui::Text("define: __EMSCRIPTEN__");
ImGui::Text("Emscripten: %d.%d.%d", __EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__); ImGui::Text("Emscripten: %d.%d.%d", __EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__);
#endif
#ifdef IMGUI_HAS_VIEWPORT
ImGui::Text("define: IMGUI_HAS_VIEWPORT");
#endif
#ifdef IMGUI_HAS_DOCK
ImGui::Text("define: IMGUI_HAS_DOCK");
#endif #endif
ImGui::Separator(); ImGui::Separator();
ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL"); ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL");
@ -7713,7 +7794,19 @@ void ImGui::ShowAboutWindow(bool* p_open)
if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard"); if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard");
if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse"); if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse");
if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange"); if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange");
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable) ImGui::Text(" DockingEnable");
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) ImGui::Text(" ViewportsEnable");
if (io.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports) ImGui::Text(" DpiEnableScaleViewports");
if (io.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleFonts) ImGui::Text(" DpiEnableScaleFonts");
if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor"); if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor");
if (io.ConfigViewportsNoAutoMerge) ImGui::Text("io.ConfigViewportsNoAutoMerge");
if (io.ConfigViewportsNoTaskBarIcon) ImGui::Text("io.ConfigViewportsNoTaskBarIcon");
if (io.ConfigViewportsNoDecoration) ImGui::Text("io.ConfigViewportsNoDecoration");
if (io.ConfigViewportsNoDefaultParent) ImGui::Text("io.ConfigViewportsNoDefaultParent");
if (io.ConfigDockingNoSplit) ImGui::Text("io.ConfigDockingNoSplit");
if (io.ConfigDockingWithShift) ImGui::Text("io.ConfigDockingWithShift");
if (io.ConfigDockingAlwaysTabBar) ImGui::Text("io.ConfigDockingAlwaysTabBar");
if (io.ConfigDockingTransparentPayload) ImGui::Text("io.ConfigDockingTransparentPayload");
if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors"); if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors");
if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink"); if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink");
if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges"); if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges");
@ -7723,7 +7816,10 @@ void ImGui::ShowAboutWindow(bool* p_open)
if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad"); if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad");
if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors"); if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors");
if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos"); if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos");
if (io.BackendFlags & ImGuiBackendFlags_PlatformHasViewports) ImGui::Text(" PlatformHasViewports");
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)ImGui::Text(" HasMouseHoveredViewport");
if (io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) ImGui::Text(" RendererHasVtxOffset"); if (io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) ImGui::Text(" RendererHasVtxOffset");
if (io.BackendFlags & ImGuiBackendFlags_RendererHasViewports) ImGui::Text(" RendererHasViewports");
ImGui::Separator(); ImGui::Separator();
ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight); ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight);
ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y); ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y);
@ -7899,6 +7995,9 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f"); ImGui::SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f");
ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f"); ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
ImGui::SeparatorText("Docking");
ImGui::SliderFloat("DockingSplitterSize", &style.DockingSeparatorSize, 0.0f, 12.0f, "%.0f");
ImGui::SeparatorText("Tooltips"); ImGui::SeparatorText("Tooltips");
for (int n = 0; n < 2; n++) for (int n = 0; n < 2; n++)
if (ImGui::TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse" : "HoverFlagsForTooltipNav")) if (ImGui::TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse" : "HoverFlagsForTooltipNav"))
@ -9145,6 +9244,8 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
else else
{ {
ImGui::Text("(Hold SHIFT to display a dummy viewport)"); ImGui::Text("(Hold SHIFT to display a dummy viewport)");
if (ImGui::IsWindowDocked())
ImGui::Text("Warning: Sizing Constraints won't work if the window is docked!");
if (ImGui::Button("Set 200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine(); if (ImGui::Button("Set 200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
if (ImGui::Button("Set 500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine(); if (ImGui::Button("Set 500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
if (ImGui::Button("Set 800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); } if (ImGui::Button("Set 800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
@ -9171,7 +9272,7 @@ static void ShowExampleAppSimpleOverlay(bool* p_open)
{ {
static int location = 0; static int location = 0;
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
if (location >= 0) if (location >= 0)
{ {
const float PAD = 10.0f; const float PAD = 10.0f;
@ -9184,6 +9285,7 @@ static void ShowExampleAppSimpleOverlay(bool* p_open)
window_pos_pivot.x = (location & 1) ? 1.0f : 0.0f; window_pos_pivot.x = (location & 1) ? 1.0f : 0.0f;
window_pos_pivot.y = (location & 2) ? 1.0f : 0.0f; window_pos_pivot.y = (location & 2) ? 1.0f : 0.0f;
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot); ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
ImGui::SetNextWindowViewport(viewport->ID);
window_flags |= ImGuiWindowFlags_NoMove; window_flags |= ImGuiWindowFlags_NoMove;
} }
else if (location == -2) else if (location == -2)
@ -9603,6 +9705,134 @@ static void ShowExampleAppCustomRendering(bool* p_open)
ImGui::End(); ImGui::End();
} }
//-----------------------------------------------------------------------------
// [SECTION] Example App: Docking, DockSpace / ShowExampleAppDockSpace()
//-----------------------------------------------------------------------------
// Demonstrate using DockSpace() to create an explicit docking node within an existing window.
// Note: You can use most Docking facilities without calling any API. You DO NOT need to call DockSpace() to use Docking!
// - Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking.
// - Drag from window menu button (upper-left button) to undock an entire node (all windows).
// - When io.ConfigDockingWithShift == true, you instead need to hold SHIFT to enable docking.
// About dockspaces:
// - Use DockSpace() to create an explicit dock node _within_ an existing window.
// - Use DockSpaceOverViewport() to create an explicit dock node covering the screen or a specific viewport.
// This is often used with ImGuiDockNodeFlags_PassthruCentralNode.
// - Important: Dockspaces need to be submitted _before_ any window they can host. Submit it early in your frame! (*)
// - Important: Dockspaces need to be kept alive if hidden, otherwise windows docked into it will be undocked.
// e.g. if you have multiple tabs with a dockspace inside each tab: submit the non-visible dockspaces with ImGuiDockNodeFlags_KeepAliveOnly.
// (*) because of this constraint, the implicit \"Debug\" window can not be docked into an explicit DockSpace() node,
// because that window is submitted as part of the part of the NewFrame() call. An easy workaround is that you can create
// your own implicit "Debug##2" window after calling DockSpace() and leave it in the window stack for anyone to use.
void ShowExampleAppDockSpace(bool* p_open)
{
// READ THIS !!!
// TL;DR; this demo is more complicated than what most users you would normally use.
// If we remove all options we are showcasing, this demo would become:
// void ShowExampleAppDockSpace()
// {
// ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport());
// }
// In most cases you should be able to just call DockSpaceOverViewport() and ignore all the code below!
// In this specific demo, we are not using DockSpaceOverViewport() because:
// - (1) we allow the host window to be floating/moveable instead of filling the viewport (when opt_fullscreen == false)
// - (2) we allow the host window to have padding (when opt_padding == true)
// - (3) we expose many flags and need a way to have them visible.
// - (4) we have a local menu bar in the host window (vs. you could use BeginMainMenuBar() + DockSpaceOverViewport()
// in your code, but we don't here because we allow the window to be floating)
static bool opt_fullscreen = true;
static bool opt_padding = false;
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
// because it would be confusing to have two docking targets within each others.
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
if (opt_fullscreen)
{
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->WorkPos);
ImGui::SetNextWindowSize(viewport->WorkSize);
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
}
else
{
dockspace_flags &= ~ImGuiDockNodeFlags_PassthruCentralNode;
}
// When using ImGuiDockNodeFlags_PassthruCentralNode, DockSpace() will render our background
// and handle the pass-thru hole, so we ask Begin() to not render a background.
if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode)
window_flags |= ImGuiWindowFlags_NoBackground;
// Important: note that we proceed even if Begin() returns false (aka window is collapsed).
// This is because we want to keep our DockSpace() active. If a DockSpace() is inactive,
// all active windows docked into it will lose their parent and become undocked.
// We cannot preserve the docking relationship between an active window and an inactive docking, otherwise
// any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
if (!opt_padding)
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("DockSpace Demo", p_open, window_flags);
if (!opt_padding)
ImGui::PopStyleVar();
if (opt_fullscreen)
ImGui::PopStyleVar(2);
// Submit the DockSpace
ImGuiIO& io = ImGui::GetIO();
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
}
else
{
ShowDockingDisabledMessage();
}
if (ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("Options"))
{
// Disabling fullscreen would allow the window to be moved to the front of other windows,
// which we can't undo at the moment without finer window depth/z control.
ImGui::MenuItem("Fullscreen", NULL, &opt_fullscreen);
ImGui::MenuItem("Padding", NULL, &opt_padding);
ImGui::Separator();
if (ImGui::MenuItem("Flag: NoDockingOverCentralNode", "", (dockspace_flags & ImGuiDockNodeFlags_NoDockingOverCentralNode) != 0)) { dockspace_flags ^= ImGuiDockNodeFlags_NoDockingOverCentralNode; }
if (ImGui::MenuItem("Flag: NoDockingSplit", "", (dockspace_flags & ImGuiDockNodeFlags_NoDockingSplit) != 0)) { dockspace_flags ^= ImGuiDockNodeFlags_NoDockingSplit; }
if (ImGui::MenuItem("Flag: NoUndocking", "", (dockspace_flags & ImGuiDockNodeFlags_NoUndocking) != 0)) { dockspace_flags ^= ImGuiDockNodeFlags_NoUndocking; }
if (ImGui::MenuItem("Flag: NoResize", "", (dockspace_flags & ImGuiDockNodeFlags_NoResize) != 0)) { dockspace_flags ^= ImGuiDockNodeFlags_NoResize; }
if (ImGui::MenuItem("Flag: AutoHideTabBar", "", (dockspace_flags & ImGuiDockNodeFlags_AutoHideTabBar) != 0)) { dockspace_flags ^= ImGuiDockNodeFlags_AutoHideTabBar; }
if (ImGui::MenuItem("Flag: PassthruCentralNode", "", (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode) != 0, opt_fullscreen)) { dockspace_flags ^= ImGuiDockNodeFlags_PassthruCentralNode; }
ImGui::Separator();
if (ImGui::MenuItem("Close", NULL, false, p_open != NULL))
*p_open = false;
ImGui::EndMenu();
}
HelpMarker(
"When docking is enabled, you can ALWAYS dock MOST window into another! Try it now!" "\n"
"- Drag from window title bar or their tab to dock/undock." "\n"
"- Drag from window menu button (upper-left button) to undock an entire node (all windows)." "\n"
"- Hold SHIFT to disable docking (if io.ConfigDockingWithShift == false, default)" "\n"
"- Hold SHIFT to enable docking (if io.ConfigDockingWithShift == true)" "\n"
"This demo app has nothing to do with enabling docking!" "\n\n"
"This demo app only demonstrate the use of ImGui::DockSpace() which allows you to manually create a docking node _within_ another window." "\n\n"
"Read comments in ShowExampleAppDockSpace() for more details.");
ImGui::EndMenuBar();
}
ImGui::End();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments() // [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -9728,11 +9958,25 @@ void ShowExampleAppDocuments(bool* p_open)
static ExampleAppDocuments app; static ExampleAppDocuments app;
// Options // Options
enum Target
{
Target_None,
Target_Tab, // Create documents as local tab into a local tab bar
Target_DockSpaceAndWindow // Create documents as regular windows, and create an embedded dockspace
};
static Target opt_target = Target_Tab;
static bool opt_reorderable = true; static bool opt_reorderable = true;
static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_; static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_;
// When (opt_target == Target_DockSpaceAndWindow) there is the possibily that one of our child Document window (e.g. "Eggplant")
// that we emit gets docked into the same spot as the parent window ("Example: Documents").
// This would create a problematic feedback loop because selecting the "Eggplant" tab would make the "Example: Documents" tab
// not visible, which in turn would stop submitting the "Eggplant" window.
// We avoid this problem by submitting our documents window even if our parent window is not currently visible.
// Another solution may be to make the "Example: Documents" window use the ImGuiWindowFlags_NoDocking.
bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar); bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar);
if (!window_contents_visible) if (!window_contents_visible && opt_target != Target_DockSpaceAndWindow)
{ {
ImGui::End(); ImGui::End();
return; return;
@ -9776,6 +10020,12 @@ void ShowExampleAppDocuments(bool* p_open)
doc.DoForceClose(); doc.DoForceClose();
ImGui::PopID(); ImGui::PopID();
} }
ImGui::PushItemWidth(ImGui::GetFontSize() * 12);
ImGui::Combo("Output", (int*)&opt_target, "None\0TabBar+Tabs\0DockSpace+Window\0");
ImGui::PopItemWidth();
bool redock_all = false;
if (opt_target == Target_Tab) { ImGui::SameLine(); ImGui::Checkbox("Reorderable Tabs", &opt_reorderable); }
if (opt_target == Target_DockSpaceAndWindow) { ImGui::SameLine(); redock_all = ImGui::Button("Redock all"); }
ImGui::Separator(); ImGui::Separator();
@ -9789,7 +10039,8 @@ void ShowExampleAppDocuments(bool* p_open)
// hole for one-frame, both in the tab-bar and in tab-contents when closing a tab/window. // hole for one-frame, both in the tab-bar and in tab-contents when closing a tab/window.
// The rarely used SetTabItemClosed() function is a way to notify of programmatic closure to avoid the one-frame hole. // The rarely used SetTabItemClosed() function is a way to notify of programmatic closure to avoid the one-frame hole.
// Submit Tab Bar and Tabs // Tabs
if (opt_target == Target_Tab)
{ {
ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0); ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0);
tab_bar_flags |= ImGuiTabBarFlags_DrawSelectedOverline; tab_bar_flags |= ImGuiTabBarFlags_DrawSelectedOverline;
@ -9832,6 +10083,53 @@ void ShowExampleAppDocuments(bool* p_open)
ImGui::EndTabBar(); ImGui::EndTabBar();
} }
} }
else if (opt_target == Target_DockSpaceAndWindow)
{
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
app.NotifyOfDocumentsClosedElsewhere();
// Create a DockSpace node where any window can be docked
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
ImGui::DockSpace(dockspace_id);
// Create Windows
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
{
MyDocument* doc = &app.Documents[doc_n];
if (!doc->Open)
continue;
ImGui::SetNextWindowDockID(dockspace_id, redock_all ? ImGuiCond_Always : ImGuiCond_FirstUseEver);
ImGuiWindowFlags window_flags = (doc->Dirty ? ImGuiWindowFlags_UnsavedDocument : 0);
bool visible = ImGui::Begin(doc->Name, &doc->Open, window_flags);
// Cancel attempt to close when unsaved add to save queue so we can display a popup.
if (!doc->Open && doc->Dirty)
{
doc->Open = true;
app.CloseQueue.push_back(doc);
}
app.DisplayDocContextMenu(doc);
if (visible)
app.DisplayDocContents(doc);
ImGui::End();
}
}
else
{
ShowDockingDisabledMessage();
}
}
// Early out other contents
if (!window_contents_visible)
{
ImGui::End();
return;
}
// Display renaming UI // Display renaming UI
if (app.RenamingDoc != NULL) if (app.RenamingDoc != NULL)

View File

@ -218,6 +218,8 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f); colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_HeaderActive] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
@ -281,6 +283,8 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f); colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
colors[ImGuiCol_TabDimmedSelectedOverline] = colors[ImGuiCol_HeaderActive]; colors[ImGuiCol_TabDimmedSelectedOverline] = colors[ImGuiCol_HeaderActive];
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
@ -345,6 +349,8 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f); colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.26f, 0.59f, 1.00f, 1.00f); colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.26f, 0.59f, 1.00f, 1.00f);
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
@ -4213,6 +4219,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im
// - RenderArrow() // - RenderArrow()
// - RenderBullet() // - RenderBullet()
// - RenderCheckMark() // - RenderCheckMark()
// - RenderArrowDockMenu()
// - RenderArrowPointingAt() // - RenderArrowPointingAt()
// - RenderRectFilledRangeH() // - RenderRectFilledRangeH()
// - RenderRectFilledWithHole() // - RenderRectFilledWithHole()
@ -4287,6 +4294,14 @@ void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half
} }
} }
// This is less wide than RenderArrow() and we use in dock nodes instead of the regular RenderArrow() to denote a change of functionality,
// and because the saved space means that the left-most tab label can stay at exactly the same position as the label of a loose window.
void ImGui::RenderArrowDockMenu(ImDrawList* draw_list, ImVec2 p_min, float sz, ImU32 col)
{
draw_list->AddRectFilled(p_min + ImVec2(sz * 0.20f, sz * 0.15f), p_min + ImVec2(sz * 0.80f, sz * 0.30f), col);
RenderArrowPointingAt(draw_list, p_min + ImVec2(sz * 0.50f, sz * 0.85f), ImVec2(sz * 0.30f, sz * 0.40f), ImGuiDir_Down, col);
}
static inline float ImAcos01(float x) static inline float ImAcos01(float x)
{ {
if (x <= 0.0f) return IM_PI * 0.5f; if (x <= 0.0f) return IM_PI * 0.5f;
@ -4372,6 +4387,17 @@ void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer,
if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomRight); if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomRight);
} }
ImDrawFlags ImGui::CalcRoundingFlagsForRectInRect(const ImRect& r_in, const ImRect& r_outer, float threshold)
{
bool round_l = r_in.Min.x <= r_outer.Min.x + threshold;
bool round_r = r_in.Max.x >= r_outer.Max.x - threshold;
bool round_t = r_in.Min.y <= r_outer.Min.y + threshold;
bool round_b = r_in.Max.y >= r_outer.Max.y - threshold;
return ImDrawFlags_RoundCornersNone
| ((round_t && round_l) ? ImDrawFlags_RoundCornersTopLeft : 0) | ((round_t && round_r) ? ImDrawFlags_RoundCornersTopRight : 0)
| ((round_b && round_l) ? ImDrawFlags_RoundCornersBottomLeft : 0) | ((round_b && round_r) ? ImDrawFlags_RoundCornersBottomRight : 0);
}
// Helper for ColorPicker4() // Helper for ColorPicker4()
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that. // NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether. // Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.

View File

@ -92,8 +92,8 @@ Index of this file:
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
#elif defined(__GNUC__) #elif defined(__GNUC__)
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead #pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated #pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
#endif #endif
@ -131,6 +131,10 @@ struct ImGuiContext; // Main Dear ImGui context
struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine
struct ImGuiDataVarInfo; // Variable information (e.g. to access style variables from an enum) struct ImGuiDataVarInfo; // Variable information (e.g. to access style variables from an enum)
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
struct ImGuiDockContext; // Docking system context
struct ImGuiDockRequest; // Docking system dock/undock queued request
struct ImGuiDockNode; // Docking system node (hold a list of Windows OR two child dock nodes)
struct ImGuiDockNodeSettings; // Storage for a dock node in .ini file (we preserve those even if the associated dock node isn't active during the session)
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup() struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
struct ImGuiInputTextDeactivateData;// Short term storage to backup text of a deactivating InputText() while another is stealing active id struct ImGuiInputTextDeactivateData;// Short term storage to backup text of a deactivating InputText() while another is stealing active id
@ -162,12 +166,14 @@ struct ImGuiTreeNodeStackData; // Temporary storage for TreeNode().
struct ImGuiTypingSelectState; // Storage for GetTypingSelectRequest() struct ImGuiTypingSelectState; // Storage for GetTypingSelectRequest()
struct ImGuiTypingSelectRequest; // Storage for GetTypingSelectRequest() (aimed to be public) struct ImGuiTypingSelectRequest; // Storage for GetTypingSelectRequest() (aimed to be public)
struct ImGuiWindow; // Storage for one window struct ImGuiWindow; // Storage for one window
struct ImGuiWindowDockStyle; // Storage for window-style data which needs to be stored for docking purpose
struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame, in practice we currently keep it for each window) struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame, in practice we currently keep it for each window)
struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session) struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)
// Enumerations // Enumerations
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists. // Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
enum ImGuiLocKey : int; // -> enum ImGuiLocKey // Enum: a localization entry for translation. enum ImGuiLocKey : int; // -> enum ImGuiLocKey // Enum: a localization entry for translation.
typedef int ImGuiDataAuthority; // -> enum ImGuiDataAuthority_ // Enum: for storing the source authority (dock node vs window) of a field
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
// Flags // Flags
@ -220,6 +226,9 @@ namespace ImStb
// [SECTION] Macros // [SECTION] Macros
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Internal Drag and Drop payload types. String starting with '_' are reserved for Dear ImGui.
#define IMGUI_PAYLOAD_TYPE_WINDOW "_IMWINDOW" // Payload == ImGuiWindow*
// Debug Printing Into TTY // Debug Printing Into TTY
// (since IMGUI_VERSION_NUM >= 18729: IMGUI_DEBUG_LOG was reworked into IMGUI_DEBUG_PRINTF (and removed framecount from it). If you were using a #define IMGUI_DEBUG_LOG please rename) // (since IMGUI_VERSION_NUM >= 18729: IMGUI_DEBUG_LOG was reworked into IMGUI_DEBUG_PRINTF (and removed framecount from it). If you were using a #define IMGUI_DEBUG_LOG please rename)
#ifndef IMGUI_DEBUG_PRINTF #ifndef IMGUI_DEBUG_PRINTF
@ -244,6 +253,8 @@ namespace ImStb
#define IMGUI_DEBUG_LOG_CLIPPER(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventClipper) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0) #define IMGUI_DEBUG_LOG_CLIPPER(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventClipper) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_IO(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0) #define IMGUI_DEBUG_LOG_IO(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_INPUTROUTING(...) do{if (g.DebugLogFlags & ImGuiDebugLogFlags_EventInputRouting)IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0) #define IMGUI_DEBUG_LOG_INPUTROUTING(...) do{if (g.DebugLogFlags & ImGuiDebugLogFlags_EventInputRouting)IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_DOCKING(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventDocking) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_VIEWPORT(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventViewport) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
// Static Asserts // Static Asserts
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "") #define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
@ -900,7 +911,7 @@ enum ImGuiItemStatusFlags_
enum ImGuiHoveredFlagsPrivate_ enum ImGuiHoveredFlagsPrivate_
{ {
ImGuiHoveredFlags_DelayMask_ = ImGuiHoveredFlags_DelayNone | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay, ImGuiHoveredFlags_DelayMask_ = ImGuiHoveredFlags_DelayNone | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay,
ImGuiHoveredFlags_AllowedMaskForIsWindowHovered = ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_NoPopupHierarchy | ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary, ImGuiHoveredFlags_AllowedMaskForIsWindowHovered = ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_NoPopupHierarchy | ImGuiHoveredFlags_DockHierarchy | ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary,
ImGuiHoveredFlags_AllowedMaskForIsItemHovered = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled | ImGuiHoveredFlags_NoNavOverride | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayMask_, ImGuiHoveredFlags_AllowedMaskForIsItemHovered = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled | ImGuiHoveredFlags_NoNavOverride | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayMask_,
}; };
@ -1183,6 +1194,9 @@ enum ImGuiNextWindowDataFlags_
ImGuiNextWindowDataFlags_HasScroll = 1 << 7, ImGuiNextWindowDataFlags_HasScroll = 1 << 7,
ImGuiNextWindowDataFlags_HasChildFlags = 1 << 8, ImGuiNextWindowDataFlags_HasChildFlags = 1 << 8,
ImGuiNextWindowDataFlags_HasRefreshPolicy = 1 << 9, ImGuiNextWindowDataFlags_HasRefreshPolicy = 1 << 9,
ImGuiNextWindowDataFlags_HasViewport = 1 << 10,
ImGuiNextWindowDataFlags_HasDock = 1 << 11,
ImGuiNextWindowDataFlags_HasWindowClass = 1 << 12,
}; };
// Storage for SetNexWindow** functions // Storage for SetNexWindow** functions
@ -1192,17 +1206,22 @@ struct ImGuiNextWindowData
ImGuiCond PosCond; ImGuiCond PosCond;
ImGuiCond SizeCond; ImGuiCond SizeCond;
ImGuiCond CollapsedCond; ImGuiCond CollapsedCond;
ImGuiCond DockCond;
ImVec2 PosVal; ImVec2 PosVal;
ImVec2 PosPivotVal; ImVec2 PosPivotVal;
ImVec2 SizeVal; ImVec2 SizeVal;
ImVec2 ContentSizeVal; ImVec2 ContentSizeVal;
ImVec2 ScrollVal; ImVec2 ScrollVal;
ImGuiChildFlags ChildFlags; ImGuiChildFlags ChildFlags;
bool PosUndock;
bool CollapsedVal; bool CollapsedVal;
ImRect SizeConstraintRect; ImRect SizeConstraintRect;
ImGuiSizeCallback SizeCallback; ImGuiSizeCallback SizeCallback;
void* SizeCallbackUserData; void* SizeCallbackUserData;
float BgAlphaVal; // Override background alpha float BgAlphaVal; // Override background alpha
ImGuiID ViewportId;
ImGuiID DockId;
ImGuiWindowClass WindowClass;
ImVec2 MenuBarOffsetMinVal; // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?) ImVec2 MenuBarOffsetMinVal; // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?)
ImGuiWindowRefreshFlags RefreshFlagsVal; ImGuiWindowRefreshFlags RefreshFlagsVal;
@ -1370,6 +1389,7 @@ enum ImGuiInputEventType
ImGuiInputEventType_MousePos, ImGuiInputEventType_MousePos,
ImGuiInputEventType_MouseWheel, ImGuiInputEventType_MouseWheel,
ImGuiInputEventType_MouseButton, ImGuiInputEventType_MouseButton,
ImGuiInputEventType_MouseViewport,
ImGuiInputEventType_Key, ImGuiInputEventType_Key,
ImGuiInputEventType_Text, ImGuiInputEventType_Text,
ImGuiInputEventType_Focus, ImGuiInputEventType_Focus,
@ -1390,6 +1410,7 @@ enum ImGuiInputSource
struct ImGuiInputEventMousePos { float PosX, PosY; ImGuiMouseSource MouseSource; }; struct ImGuiInputEventMousePos { float PosX, PosY; ImGuiMouseSource MouseSource; };
struct ImGuiInputEventMouseWheel { float WheelX, WheelY; ImGuiMouseSource MouseSource; }; struct ImGuiInputEventMouseWheel { float WheelX, WheelY; ImGuiMouseSource MouseSource; };
struct ImGuiInputEventMouseButton { int Button; bool Down; ImGuiMouseSource MouseSource; }; struct ImGuiInputEventMouseButton { int Button; bool Down; ImGuiMouseSource MouseSource; };
struct ImGuiInputEventMouseViewport { ImGuiID HoveredViewportID; };
struct ImGuiInputEventKey { ImGuiKey Key; bool Down; float AnalogValue; }; struct ImGuiInputEventKey { ImGuiKey Key; bool Down; float AnalogValue; };
struct ImGuiInputEventText { unsigned int Char; }; struct ImGuiInputEventText { unsigned int Char; };
struct ImGuiInputEventAppFocused { bool Focused; }; struct ImGuiInputEventAppFocused { bool Focused; };
@ -1404,6 +1425,7 @@ struct ImGuiInputEvent
ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos
ImGuiInputEventMouseWheel MouseWheel; // if Type == ImGuiInputEventType_MouseWheel ImGuiInputEventMouseWheel MouseWheel; // if Type == ImGuiInputEventType_MouseWheel
ImGuiInputEventMouseButton MouseButton; // if Type == ImGuiInputEventType_MouseButton ImGuiInputEventMouseButton MouseButton; // if Type == ImGuiInputEventType_MouseButton
ImGuiInputEventMouseViewport MouseViewport; // if Type == ImGuiInputEventType_MouseViewport
ImGuiInputEventKey Key; // if Type == ImGuiInputEventType_Key ImGuiInputEventKey Key; // if Type == ImGuiInputEventType_Key
ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text
ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus
@ -1791,8 +1813,153 @@ struct IMGUI_API ImGuiMultiSelectState
// [SECTION] Docking support // [SECTION] Docking support
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#define DOCKING_HOST_DRAW_CHANNEL_BG 0 // Dock host: background fill
#define DOCKING_HOST_DRAW_CHANNEL_FG 1 // Dock host: decorations and contents
#ifdef IMGUI_HAS_DOCK #ifdef IMGUI_HAS_DOCK
// <this is filled in 'docking' branch>
// Extend ImGuiDockNodeFlags_
enum ImGuiDockNodeFlagsPrivate_
{
// [Internal]
ImGuiDockNodeFlags_DockSpace = 1 << 10, // Saved // A dockspace is a node that occupy space within an existing user window. Otherwise the node is floating and create its own window.
ImGuiDockNodeFlags_CentralNode = 1 << 11, // Saved // The central node has 2 main properties: stay visible when empty, only use "remaining" spaces from its neighbor.
ImGuiDockNodeFlags_NoTabBar = 1 << 12, // Saved // Tab bar is completely unavailable. No triangle in the corner to enable it back.
ImGuiDockNodeFlags_HiddenTabBar = 1 << 13, // Saved // Tab bar is hidden, with a triangle in the corner to show it again (NB: actual tab-bar instance may be destroyed as this is only used for single-window tab bar)
ImGuiDockNodeFlags_NoWindowMenuButton = 1 << 14, // Saved // Disable window/docking menu (that one that appears instead of the collapse button)
ImGuiDockNodeFlags_NoCloseButton = 1 << 15, // Saved // Disable close button
ImGuiDockNodeFlags_NoResizeX = 1 << 16, // //
ImGuiDockNodeFlags_NoResizeY = 1 << 17, // //
ImGuiDockNodeFlags_DockedWindowsInFocusRoute= 1 << 18, // // Any docked window will be automatically be focus-route chained (window->ParentWindowForFocusRoute set to this) so Shortcut() in this window can run when any docked window is focused.
// Disable docking/undocking actions in this dockspace or individual node (existing docked nodes will be preserved)
// Those are not exposed in public because the desirable sharing/inheriting/copy-flag-on-split behaviors are quite difficult to design and understand.
// The two public flags ImGuiDockNodeFlags_NoDockingOverCentralNode/ImGuiDockNodeFlags_NoDockingSplit don't have those issues.
ImGuiDockNodeFlags_NoDockingSplitOther = 1 << 19, // // Disable this node from splitting other windows/nodes.
ImGuiDockNodeFlags_NoDockingOverMe = 1 << 20, // // Disable other windows/nodes from being docked over this node.
ImGuiDockNodeFlags_NoDockingOverOther = 1 << 21, // // Disable this node from being docked over another window or non-empty node.
ImGuiDockNodeFlags_NoDockingOverEmpty = 1 << 22, // // Disable this node from being docked over an empty node (e.g. DockSpace with no other windows)
ImGuiDockNodeFlags_NoDocking = ImGuiDockNodeFlags_NoDockingOverMe | ImGuiDockNodeFlags_NoDockingOverOther | ImGuiDockNodeFlags_NoDockingOverEmpty | ImGuiDockNodeFlags_NoDockingSplit | ImGuiDockNodeFlags_NoDockingSplitOther,
// Masks
ImGuiDockNodeFlags_SharedFlagsInheritMask_ = ~0,
ImGuiDockNodeFlags_NoResizeFlagsMask_ = (int)ImGuiDockNodeFlags_NoResize | ImGuiDockNodeFlags_NoResizeX | ImGuiDockNodeFlags_NoResizeY,
// When splitting, those local flags are moved to the inheriting child, never duplicated
ImGuiDockNodeFlags_LocalFlagsTransferMask_ = (int)ImGuiDockNodeFlags_NoDockingSplit | ImGuiDockNodeFlags_NoResizeFlagsMask_ | (int)ImGuiDockNodeFlags_AutoHideTabBar | ImGuiDockNodeFlags_CentralNode | ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_HiddenTabBar | ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_NoCloseButton,
ImGuiDockNodeFlags_SavedFlagsMask_ = ImGuiDockNodeFlags_NoResizeFlagsMask_ | ImGuiDockNodeFlags_DockSpace | ImGuiDockNodeFlags_CentralNode | ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_HiddenTabBar | ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_NoCloseButton,
};
// Store the source authority (dock node vs window) of a field
enum ImGuiDataAuthority_
{
ImGuiDataAuthority_Auto,
ImGuiDataAuthority_DockNode,
ImGuiDataAuthority_Window,
};
enum ImGuiDockNodeState
{
ImGuiDockNodeState_Unknown,
ImGuiDockNodeState_HostWindowHiddenBecauseSingleWindow,
ImGuiDockNodeState_HostWindowHiddenBecauseWindowsAreResizing,
ImGuiDockNodeState_HostWindowVisible,
};
// sizeof() 156~192
struct IMGUI_API ImGuiDockNode
{
ImGuiID ID;
ImGuiDockNodeFlags SharedFlags; // (Write) Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
ImGuiDockNodeFlags LocalFlags; // (Write) Flags specific to this node
ImGuiDockNodeFlags LocalFlagsInWindows; // (Write) Flags specific to this node, applied from windows
ImGuiDockNodeFlags MergedFlags; // (Read) Effective flags (== SharedFlags | LocalFlagsInNode | LocalFlagsInWindows)
ImGuiDockNodeState State;
ImGuiDockNode* ParentNode;
ImGuiDockNode* ChildNodes[2]; // [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
ImVector<ImGuiWindow*> Windows; // Note: unordered list! Iterate TabBar->Tabs for user-order.
ImGuiTabBar* TabBar;
ImVec2 Pos; // Current position
ImVec2 Size; // Current size
ImVec2 SizeRef; // [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
ImGuiAxis SplitAxis; // [Split node only] Split axis (X or Y)
ImGuiWindowClass WindowClass; // [Root node only]
ImU32 LastBgColor;
ImGuiWindow* HostWindow;
ImGuiWindow* VisibleWindow; // Generally point to window which is ID is == SelectedTabID, but when CTRL+Tabbing this can be a different window.
ImGuiDockNode* CentralNode; // [Root node only] Pointer to central node.
ImGuiDockNode* OnlyNodeWithWindows; // [Root node only] Set when there is a single visible node within the hierarchy.
int CountNodeWithWindows; // [Root node only]
int LastFrameAlive; // Last frame number the node was updated or kept alive explicitly with DockSpace() + ImGuiDockNodeFlags_KeepAliveOnly
int LastFrameActive; // Last frame number the node was updated.
int LastFrameFocused; // Last frame number the node was focused.
ImGuiID LastFocusedNodeId; // [Root node only] Which of our child docking node (any ancestor in the hierarchy) was last focused.
ImGuiID SelectedTabId; // [Leaf node only] Which of our tab/window is selected.
ImGuiID WantCloseTabId; // [Leaf node only] Set when closing a specific tab/window.
ImGuiID RefViewportId; // Reference viewport ID from visible window when HostWindow == NULL.
ImGuiDataAuthority AuthorityForPos :3;
ImGuiDataAuthority AuthorityForSize :3;
ImGuiDataAuthority AuthorityForViewport :3;
bool IsVisible :1; // Set to false when the node is hidden (usually disabled as it has no active window)
bool IsFocused :1;
bool IsBgDrawnThisFrame :1;
bool HasCloseButton :1; // Provide space for a close button (if any of the docked window has one). Note that button may be hidden on window without one.
bool HasWindowMenuButton :1;
bool HasCentralNodeChild :1;
bool WantCloseAll :1; // Set when closing all tabs at once.
bool WantLockSizeOnce :1;
bool WantMouseMove :1; // After a node extraction we need to transition toward moving the newly created host window
bool WantHiddenTabBarUpdate :1;
bool WantHiddenTabBarToggle :1;
ImGuiDockNode(ImGuiID id);
~ImGuiDockNode();
bool IsRootNode() const { return ParentNode == NULL; }
bool IsDockSpace() const { return (MergedFlags & ImGuiDockNodeFlags_DockSpace) != 0; }
bool IsFloatingNode() const { return ParentNode == NULL && (MergedFlags & ImGuiDockNodeFlags_DockSpace) == 0; }
bool IsCentralNode() const { return (MergedFlags & ImGuiDockNodeFlags_CentralNode) != 0; }
bool IsHiddenTabBar() const { return (MergedFlags & ImGuiDockNodeFlags_HiddenTabBar) != 0; } // Hidden tab bar can be shown back by clicking the small triangle
bool IsNoTabBar() const { return (MergedFlags & ImGuiDockNodeFlags_NoTabBar) != 0; } // Never show a tab bar
bool IsSplitNode() const { return ChildNodes[0] != NULL; }
bool IsLeafNode() const { return ChildNodes[0] == NULL; }
bool IsEmpty() const { return ChildNodes[0] == NULL && Windows.Size == 0; }
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
void SetLocalFlags(ImGuiDockNodeFlags flags) { LocalFlags = flags; UpdateMergedFlags(); }
void UpdateMergedFlags() { MergedFlags = SharedFlags | LocalFlags | LocalFlagsInWindows; }
};
// List of colors that are stored at the time of Begin() into Docked Windows.
// We currently store the packed colors in a simple array window->DockStyle.Colors[].
// A better solution may involve appending into a log of colors in ImGuiContext + store offsets into those arrays in ImGuiWindow,
// but it would be more complex as we'd need to double-buffer both as e.g. drop target may refer to window from last frame.
enum ImGuiWindowDockStyleCol
{
ImGuiWindowDockStyleCol_Text,
ImGuiWindowDockStyleCol_TabHovered,
ImGuiWindowDockStyleCol_TabFocused,
ImGuiWindowDockStyleCol_TabSelected,
ImGuiWindowDockStyleCol_TabSelectedOverline,
ImGuiWindowDockStyleCol_TabDimmed,
ImGuiWindowDockStyleCol_TabDimmedSelected,
ImGuiWindowDockStyleCol_TabDimmedSelectedOverline,
ImGuiWindowDockStyleCol_COUNT
};
// We don't store style.Alpha: dock_node->LastBgColor embeds it and otherwise it would only affect the docking tab, which intuitively I would say we don't want to.
struct ImGuiWindowDockStyle
{
ImU32 Colors[ImGuiWindowDockStyleCol_COUNT];
};
struct ImGuiDockContext
{
ImGuiStorage Nodes; // Map ID -> ImGuiDockNode*: Active nodes
ImVector<ImGuiDockRequest> Requests;
ImVector<ImGuiDockNodeSettings> NodesSettings;
bool WantFullRebuild;
ImGuiDockContext() { memset(this, 0, sizeof(*this)); }
};
#endif // #ifdef IMGUI_HAS_DOCK #endif // #ifdef IMGUI_HAS_DOCK
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1803,10 +1970,23 @@ struct IMGUI_API ImGuiMultiSelectState
// Every instance of ImGuiViewport is in fact a ImGuiViewportP. // Every instance of ImGuiViewport is in fact a ImGuiViewportP.
struct ImGuiViewportP : public ImGuiViewport struct ImGuiViewportP : public ImGuiViewport
{ {
ImGuiWindow* Window; // Set when the viewport is owned by a window (and ImGuiViewportFlags_CanHostOtherWindows is NOT set)
int Idx;
int LastFrameActive; // Last frame number this viewport was activated by a window
int LastFocusedStampCount; // Last stamp number from when a window hosted by this viewport was focused (by comparing this value between two viewport we have an implicit viewport z-order we use as fallback)
ImGuiID LastNameHash;
ImVec2 LastPos;
float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent)
float LastAlpha;
bool LastFocusedHadNavWindow;// Instead of maintaining a LastFocusedWindow (which may harder to correctly maintain), we merely store weither NavWindow != NULL last time the viewport was focused.
short PlatformMonitor;
int BgFgDrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used int BgFgDrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
ImDrawList* BgFgDrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays. ImDrawList* BgFgDrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
ImDrawData DrawDataP; ImDrawData DrawDataP;
ImDrawDataBuilder DrawDataBuilder; // Temporary data while building final ImDrawData ImDrawDataBuilder DrawDataBuilder; // Temporary data while building final ImDrawData
ImVec2 LastPlatformPos;
ImVec2 LastPlatformSize;
ImVec2 LastRendererSize;
// Per-viewport work area // Per-viewport work area
// - Insets are >= 0.0f values, distance from viewport corners to work area. // - Insets are >= 0.0f values, distance from viewport corners to work area.
@ -1817,8 +1997,9 @@ struct ImGuiViewportP : public ImGuiViewport
ImVec2 BuildWorkInsetMin; // Work Area inset accumulator for current frame, to become next frame's WorkInset ImVec2 BuildWorkInsetMin; // Work Area inset accumulator for current frame, to become next frame's WorkInset
ImVec2 BuildWorkInsetMax; // " ImVec2 BuildWorkInsetMax; // "
ImGuiViewportP() { BgFgDrawListsLastFrame[0] = BgFgDrawListsLastFrame[1] = -1; BgFgDrawLists[0] = BgFgDrawLists[1] = NULL; } ImGuiViewportP() { Window = NULL; Idx = -1; LastFrameActive = BgFgDrawListsLastFrame[0] = BgFgDrawListsLastFrame[1] = LastFocusedStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; LastFocusedHadNavWindow = false; PlatformMonitor = -1; BgFgDrawLists[0] = BgFgDrawLists[1] = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); }
~ImGuiViewportP() { if (BgFgDrawLists[0]) IM_DELETE(BgFgDrawLists[0]); if (BgFgDrawLists[1]) IM_DELETE(BgFgDrawLists[1]); } ~ImGuiViewportP() { if (BgFgDrawLists[0]) IM_DELETE(BgFgDrawLists[0]); if (BgFgDrawLists[1]) IM_DELETE(BgFgDrawLists[1]); }
void ClearRequestFlags() { PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
// Calculate work rect pos/size given a set of offset (we have 1 pair of offset for rect locked from last frame data, and 1 pair for currently building rect) // Calculate work rect pos/size given a set of offset (we have 1 pair of offset for rect locked from last frame data, and 1 pair for currently building rect)
ImVec2 CalcWorkRectPos(const ImVec2& inset_min) const { return ImVec2(Pos.x + inset_min.x, Pos.y + inset_min.y); } ImVec2 CalcWorkRectPos(const ImVec2& inset_min) const { return ImVec2(Pos.x + inset_min.x, Pos.y + inset_min.y); }
@ -1841,14 +2022,19 @@ struct ImGuiViewportP : public ImGuiViewport
struct ImGuiWindowSettings struct ImGuiWindowSettings
{ {
ImGuiID ID; ImGuiID ID;
ImVec2ih Pos; ImVec2ih Pos; // NB: Settings position are stored RELATIVE to the viewport! Whereas runtime ones are absolute positions.
ImVec2ih Size; ImVec2ih Size;
ImVec2ih ViewportPos;
ImGuiID ViewportId;
ImGuiID DockId; // ID of last known DockNode (even if the DockNode is invisible because it has only 1 active window), or 0 if none.
ImGuiID ClassId; // ID of window class if specified
short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
bool Collapsed; bool Collapsed;
bool IsChild; bool IsChild;
bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context) bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context)
bool WantDelete; // Set to invalidate/delete the settings entry bool WantDelete; // Set to invalidate/delete the settings entry
ImGuiWindowSettings() { memset(this, 0, sizeof(*this)); } ImGuiWindowSettings() { memset(this, 0, sizeof(*this)); DockOrder = -1; }
char* GetName() { return (char*)(this + 1); } char* GetName() { return (char*)(this + 1); }
}; };
@ -1883,6 +2069,9 @@ enum ImGuiLocKey : int
ImGuiLocKey_WindowingPopup, ImGuiLocKey_WindowingPopup,
ImGuiLocKey_WindowingUntitled, ImGuiLocKey_WindowingUntitled,
ImGuiLocKey_CopyLink, ImGuiLocKey_CopyLink,
ImGuiLocKey_DockingHideTabBar,
ImGuiLocKey_DockingHoldShiftToDock,
ImGuiLocKey_DockingDragToUndockOrMoveNode,
ImGuiLocKey_COUNT ImGuiLocKey_COUNT
}; };
@ -1909,8 +2098,10 @@ enum ImGuiDebugLogFlags_
ImGuiDebugLogFlags_EventSelection = 1 << 5, ImGuiDebugLogFlags_EventSelection = 1 << 5,
ImGuiDebugLogFlags_EventIO = 1 << 6, ImGuiDebugLogFlags_EventIO = 1 << 6,
ImGuiDebugLogFlags_EventInputRouting = 1 << 7, ImGuiDebugLogFlags_EventInputRouting = 1 << 7,
ImGuiDebugLogFlags_EventDocking = 1 << 8,
ImGuiDebugLogFlags_EventViewport = 1 << 9,
ImGuiDebugLogFlags_EventMask_ = ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO | ImGuiDebugLogFlags_EventInputRouting, ImGuiDebugLogFlags_EventMask_ = ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO | ImGuiDebugLogFlags_EventInputRouting | ImGuiDebugLogFlags_EventDocking | ImGuiDebugLogFlags_EventViewport,
ImGuiDebugLogFlags_OutputToTTY = 1 << 20, // Also send output to TTY ImGuiDebugLogFlags_OutputToTTY = 1 << 20, // Also send output to TTY
ImGuiDebugLogFlags_OutputToTestEngine = 1 << 21, // Also send output to Test Engine ImGuiDebugLogFlags_OutputToTestEngine = 1 << 21, // Also send output to Test Engine
}; };
@ -1943,6 +2134,7 @@ struct ImGuiMetricsConfig
bool ShowDrawCmdBoundingBoxes = true; bool ShowDrawCmdBoundingBoxes = true;
bool ShowTextEncodingViewer = false; bool ShowTextEncodingViewer = false;
bool ShowAtlasTintedWithTextColor = false; bool ShowAtlasTintedWithTextColor = false;
bool ShowDockingNodes = false;
int ShowWindowsRectsType = -1; int ShowWindowsRectsType = -1;
int ShowTablesRectsType = -1; int ShowTablesRectsType = -1;
int HighlightMonitorIdx = -1; int HighlightMonitorIdx = -1;
@ -2002,15 +2194,18 @@ struct ImGuiContext
ImGuiIO IO; ImGuiIO IO;
ImGuiPlatformIO PlatformIO; ImGuiPlatformIO PlatformIO;
ImGuiStyle Style; ImGuiStyle Style;
ImGuiConfigFlags ConfigFlagsCurrFrame; // = g.IO.ConfigFlags at the time of NewFrame()
ImGuiConfigFlags ConfigFlagsLastFrame;
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back() ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window. float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height. float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
float FontScale; // == FontSize / Font->FontSize float FontScale; // == FontSize / Font->FontSize
float CurrentDpiScale; // Current window/viewport DpiScale float CurrentDpiScale; // Current window/viewport DpiScale == CurrentViewport->DpiScale
ImDrawListSharedData DrawListSharedData; ImDrawListSharedData DrawListSharedData;
double Time; double Time;
int FrameCount; int FrameCount;
int FrameCountEnded; int FrameCountEnded;
int FrameCountPlatformEnded;
int FrameCountRendered; int FrameCountRendered;
bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame() bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame()
bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed
@ -2039,7 +2234,7 @@ struct ImGuiContext
ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs. ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs.
ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set. ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
ImGuiWindow* HoveredWindowBeforeClear; // Window the mouse is hovering. Filled even with _NoMouse. This is currently useful for multi-context compositors. ImGuiWindow* HoveredWindowBeforeClear; // Window the mouse is hovering. Filled even with _NoMouse. This is currently useful for multi-context compositors.
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindow. ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindowDockTree.
ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window. ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
ImVec2 WheelingWindowRefMousePos; ImVec2 WheelingWindowRefMousePos;
int WheelingWindowStartFrame; // This may be set one frame before WheelingWindow is != NULL int WheelingWindowStartFrame; // This may be set one frame before WheelingWindow is != NULL
@ -2115,7 +2310,16 @@ struct ImGuiContext
ImVector<ImGuiTreeNodeStackData>TreeNodeStack; // Stack for TreeNode() ImVector<ImGuiTreeNodeStackData>TreeNodeStack; // Stack for TreeNode()
// Viewports // Viewports
ImVector<ImGuiViewportP*> Viewports; // Active viewports (Size==1 in 'master' branch). Each viewports hold their copy of ImDrawData. ImVector<ImGuiViewportP*> Viewports; // Active viewports (always 1+, and generally 1 unless multi-viewports are enabled). Each viewports hold their copy of ImDrawData.
ImGuiViewportP* CurrentViewport; // We track changes of viewport (happening in Begin) so we can call Platform_OnChangedViewport()
ImGuiViewportP* MouseViewport;
ImGuiViewportP* MouseLastHoveredViewport; // Last known viewport that was hovered by mouse (even if we are not hovering any viewport any more) + honoring the _NoInputs flag.
ImGuiID PlatformLastFocusedViewportId;
ImGuiPlatformMonitor FallbackMonitor; // Virtual monitor used as fallback if backend doesn't provide monitor information.
ImRect PlatformMonitorsFullWorkRect; // Bounding box of all platform monitors
int ViewportCreatedCount; // Unique sequential creation counter (mostly for testing/debugging)
int PlatformWindowsCreatedCount; // Unique sequential creation counter (mostly for testing/debugging)
int ViewportFocusedStampCount; // Every time the front-most window changes, we stamp its viewport with an incrementing counter
// Gamepad/keyboard Navigation // Gamepad/keyboard Navigation
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusedWindow' ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusedWindow'
@ -2282,6 +2486,12 @@ struct ImGuiContext
// Platform support // Platform support
ImGuiPlatformImeData PlatformImeData; // Data updated by current frame ImGuiPlatformImeData PlatformImeData; // Data updated by current frame
ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data. When changed we call the platform_io.Platform_SetImeDataFn() handler. ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data. When changed we call the platform_io.Platform_SetImeDataFn() handler.
ImGuiID PlatformImeViewport;
// Extensions
// FIXME: We could provide an API to register one slot in an array held in ImGuiContext?
ImGuiDockContext DockContext;
void (*DockNodeWindowMenuHandler)(ImGuiContext* ctx, ImGuiDockNode* node, ImGuiTabBar* tab_bar);
// Settings // Settings
bool SettingsLoaded; bool SettingsLoaded;
@ -2328,6 +2538,7 @@ struct ImGuiContext
ImGuiMetricsConfig DebugMetricsConfig; ImGuiMetricsConfig DebugMetricsConfig;
ImGuiIDStackTool DebugIDStackTool; ImGuiIDStackTool DebugIDStackTool;
ImGuiDebugAllocInfo DebugAllocInfo; ImGuiDebugAllocInfo DebugAllocInfo;
ImGuiDockNode* DebugHoveredDockNode; // Hovered dock node.
// Misc // Misc
float FramerateSecPerFrame[60]; // Calculate estimate of framerate for user over the last 60 frames.. float FramerateSecPerFrame[60]; // Calculate estimate of framerate for user over the last 60 frames..
@ -2346,13 +2557,14 @@ struct ImGuiContext
InputTextState.Ctx = this; InputTextState.Ctx = this;
Initialized = false; Initialized = false;
ConfigFlagsCurrFrame = ConfigFlagsLastFrame = ImGuiConfigFlags_None;
FontAtlasOwnedByContext = shared_font_atlas ? false : true; FontAtlasOwnedByContext = shared_font_atlas ? false : true;
Font = NULL; Font = NULL;
FontSize = FontBaseSize = FontScale = CurrentDpiScale = 0.0f; FontSize = FontBaseSize = FontScale = CurrentDpiScale = 0.0f;
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)(); IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
Time = 0.0f; Time = 0.0f;
FrameCount = 0; FrameCount = 0;
FrameCountEnded = FrameCountRendered = -1; FrameCountEnded = FrameCountPlatformEnded = FrameCountRendered = -1;
WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false; WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false;
GcCompactAll = false; GcCompactAll = false;
TestEngineHookItems = false; TestEngineHookItems = false;
@ -2408,6 +2620,12 @@ struct ImGuiContext
CurrentItemFlags = ImGuiItemFlags_None; CurrentItemFlags = ImGuiItemFlags_None;
DebugShowGroupRects = false; DebugShowGroupRects = false;
CurrentViewport = NULL;
MouseViewport = MouseLastHoveredViewport = NULL;
PlatformLastFocusedViewportId = 0;
ViewportCreatedCount = PlatformWindowsCreatedCount = 0;
ViewportFocusedStampCount = 0;
NavWindow = NULL; NavWindow = NULL;
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0; NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
NavLayer = ImGuiNavLayer_Main; NavLayer = ImGuiNavLayer_Main;
@ -2501,6 +2719,9 @@ struct ImGuiContext
PlatformImeData.InputPos = ImVec2(0.0f, 0.0f); PlatformImeData.InputPos = ImVec2(0.0f, 0.0f);
PlatformImeDataPrev.InputPos = ImVec2(-1.0f, -1.0f); // Different to ensure initial submission PlatformImeDataPrev.InputPos = ImVec2(-1.0f, -1.0f); // Different to ensure initial submission
PlatformImeViewport = 0;
DockNodeWindowMenuHandler = NULL;
SettingsLoaded = false; SettingsLoaded = false;
SettingsDirtyTimer = 0.0f; SettingsDirtyTimer = 0.0f;
@ -2528,6 +2749,7 @@ struct ImGuiContext
DebugItemPickerBreakId = 0; DebugItemPickerBreakId = 0;
DebugFlashStyleColorTime = 0.0f; DebugFlashStyleColorTime = 0.0f;
DebugFlashStyleColorIdx = ImGuiCol_COUNT; DebugFlashStyleColorIdx = ImGuiCol_COUNT;
DebugHoveredDockNode = NULL;
// Same as DebugBreakClearData(). Those fields are scattered in their respective subsystem to stay in hot-data locations // Same as DebugBreakClearData(). Those fields are scattered in their respective subsystem to stay in hot-data locations
DebugBreakInWindow = 0; DebugBreakInWindow = 0;
@ -2606,9 +2828,13 @@ struct IMGUI_API ImGuiWindow
ImGuiContext* Ctx; // Parent UI context (needs to be set explicitly by parent). ImGuiContext* Ctx; // Parent UI context (needs to be set explicitly by parent).
char* Name; // Window name, owned by the window. char* Name; // Window name, owned by the window.
ImGuiID ID; // == ImHashStr(Name) ImGuiID ID; // == ImHashStr(Name)
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_ ImGuiWindowFlags Flags, FlagsPreviousFrame; // See enum ImGuiWindowFlags_
ImGuiChildFlags ChildFlags; // Set when window is a child window. See enum ImGuiChildFlags_ ImGuiChildFlags ChildFlags; // Set when window is a child window. See enum ImGuiChildFlags_
ImGuiWindowClass WindowClass; // Advanced users only. Set with SetNextWindowClass()
ImGuiViewportP* Viewport; // Always set in Begin(). Inactive windows may have a NULL value here if their viewport was discarded. ImGuiViewportP* Viewport; // Always set in Begin(). Inactive windows may have a NULL value here if their viewport was discarded.
ImGuiID ViewportId; // We backup the viewport id (since the viewport may disappear or never be created if the window is inactive)
ImVec2 ViewportPos; // We backup the viewport position (since the viewport may disappear or never be created if the window is inactive)
int ViewportAllowPlatformMonitorExtend; // Reset to -1 every frame (index is guaranteed to be valid between NewFrame..EndFrame), only used in the Appearing frame of a tooltip/popup to enforce clamping to a given monitor
ImVec2 Pos; // Position (always rounded-up to nearest pixel) ImVec2 Pos; // Position (always rounded-up to nearest pixel)
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size) ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
ImVec2 SizeFull; // Size when non collapsed ImVec2 SizeFull; // Size when non collapsed
@ -2624,6 +2850,7 @@ struct IMGUI_API ImGuiWindow
float DecoInnerSizeX1, DecoInnerSizeY1; // Applied AFTER/OVER InnerRect. Specialized for Tables as they use specialized form of clipping and frozen rows/columns are inside InnerRect (and not part of regular decoration sizes). float DecoInnerSizeX1, DecoInnerSizeY1; // Applied AFTER/OVER InnerRect. Specialized for Tables as they use specialized form of clipping and frozen rows/columns are inside InnerRect (and not part of regular decoration sizes).
int NameBufLen; // Size of buffer storing Name. May be larger than strlen(Name)! int NameBufLen; // Size of buffer storing Name. May be larger than strlen(Name)!
ImGuiID MoveId; // == window->GetID("#MOVE") ImGuiID MoveId; // == window->GetID("#MOVE")
ImGuiID TabId; // == window->GetID("#TAB")
ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window) ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window)
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling) ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
ImVec2 Scroll; ImVec2 Scroll;
@ -2633,6 +2860,7 @@ struct IMGUI_API ImGuiWindow
ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold
ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar. ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
bool ScrollbarX, ScrollbarY; // Are scrollbars visible? bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
bool ViewportOwned;
bool Active; // Set to true on Begin(), unless Collapsed bool Active; // Set to true on Begin(), unless Collapsed
bool WasActive; bool WasActive;
bool WriteAccessed; // Set to true when any widget access the current window bool WriteAccessed; // Set to true when any widget access the current window
@ -2662,6 +2890,7 @@ struct IMGUI_API ImGuiWindow
ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use. ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use.
ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use. ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use.
ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use. ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use.
ImGuiCond SetWindowDockAllowFlags : 8; // store acceptable condition flags for SetNextWindowDock() use.
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size) ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0, 0) when positioning from top-left corner; ImVec2(0.5f, 0.5f) for centering; ImVec2(1, 1) for bottom right. ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0, 0) when positioning from top-left corner; ImVec2(0.5f, 0.5f) for centering; ImVec2(1, 1) for bottom right.
@ -2681,11 +2910,13 @@ struct IMGUI_API ImGuiWindow
ImVec2ih HitTestHoleOffset; ImVec2ih HitTestHoleOffset;
int LastFrameActive; // Last frame number the window was Active. int LastFrameActive; // Last frame number the window was Active.
int LastFrameJustFocused; // Last frame number the window was made Focused.
float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there) float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there)
float ItemWidthDefault; float ItemWidthDefault;
ImGuiStorage StateStorage; ImGuiStorage StateStorage;
ImVector<ImGuiOldColumns> ColumnsStorage; ImVector<ImGuiOldColumns> ColumnsStorage;
float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale() float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale()
float FontDpiScale;
int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back) int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back)
ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer) ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
@ -2694,6 +2925,7 @@ struct IMGUI_API ImGuiWindow
ImGuiWindow* ParentWindowInBeginStack; ImGuiWindow* ParentWindowInBeginStack;
ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window. Doesn't cross through popups/dock nodes. ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window. Doesn't cross through popups/dock nodes.
ImGuiWindow* RootWindowPopupTree; // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child. ImGuiWindow* RootWindowPopupTree; // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child.
ImGuiWindow* RootWindowDockTree; // Point to ourself or first ancestor that is not a child window. Cross through dock nodes.
ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active. ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag. ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
ImGuiWindow* ParentWindowForFocusRoute; // Set to manual link a window to its logical parent so that Shortcut() chain are honoerd (e.g. Tool linked to Document) ImGuiWindow* ParentWindowForFocusRoute; // Set to manual link a window to its logical parent so that Shortcut() chain are honoerd (e.g. Tool linked to Document)
@ -2708,6 +2940,19 @@ struct IMGUI_API ImGuiWindow
int MemoryDrawListVtxCapacity; int MemoryDrawListVtxCapacity;
bool MemoryCompacted; // Set when window extraneous data have been garbage collected bool MemoryCompacted; // Set when window extraneous data have been garbage collected
// Docking
bool DockIsActive :1; // When docking artifacts are actually visible. When this is set, DockNode is guaranteed to be != NULL. ~~ (DockNode != NULL) && (DockNode->Windows.Size > 1).
bool DockNodeIsVisible :1;
bool DockTabIsVisible :1; // Is our window visible this frame? ~~ is the corresponding tab selected?
bool DockTabWantClose :1;
short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
ImGuiWindowDockStyle DockStyle;
ImGuiDockNode* DockNode; // Which node are we docked into. Important: Prefer testing DockIsActive in many cases as this will still be set when the dock node is hidden.
ImGuiDockNode* DockNodeAsHost; // Which node are we owning (for parent windows)
ImGuiID DockId; // Backup of last valid DockNode->ID, so single window remember their dock node id even when they are not bound any more
ImGuiItemStatusFlags DockTabItemStatusFlags;
ImRect DockTabItemRect;
public: public:
ImGuiWindow(ImGuiContext* context, const char* name); ImGuiWindow(ImGuiContext* context, const char* name);
~ImGuiWindow(); ~ImGuiWindow();
@ -2720,7 +2965,7 @@ public:
// We don't use g.FontSize because the window may be != g.CurrentWindow. // We don't use g.FontSize because the window may be != g.CurrentWindow.
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); } ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
float CalcFontSize() const { ImGuiContext& g = *Ctx; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; } float CalcFontSize() const { ImGuiContext& g = *Ctx; float scale = g.FontBaseSize * FontWindowScale * FontDpiScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; }
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight)); } ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight)); }
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight; return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight); } ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight; return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight); }
}; };
@ -2743,13 +2988,15 @@ enum ImGuiTabItemFlagsPrivate_
ImGuiTabItemFlags_SectionMask_ = ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing, ImGuiTabItemFlags_SectionMask_ = ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing,
ImGuiTabItemFlags_NoCloseButton = 1 << 20, // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout) ImGuiTabItemFlags_NoCloseButton = 1 << 20, // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
ImGuiTabItemFlags_Button = 1 << 21, // Used by TabItemButton, change the tab item behavior to mimic a button ImGuiTabItemFlags_Button = 1 << 21, // Used by TabItemButton, change the tab item behavior to mimic a button
ImGuiTabItemFlags_Unsorted = 1 << 22, // [Docking] Trailing tabs with the _Unsorted flag will be sorted based on the DockOrder of their Window.
}; };
// Storage for one active tab item (sizeof() 40 bytes) // Storage for one active tab item (sizeof() 48 bytes)
struct ImGuiTabItem struct ImGuiTabItem
{ {
ImGuiID ID; ImGuiID ID;
ImGuiTabItemFlags Flags; ImGuiTabItemFlags Flags;
ImGuiWindow* Window; // When TabItem is part of a DockNode's TabBar, we hold on to a window.
int LastFrameVisible; int LastFrameVisible;
int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance
float Offset; // Position relative to beginning of tab float Offset; // Position relative to beginning of tab
@ -3114,7 +3361,7 @@ namespace ImGui
IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window); IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
IMGUI_API void UpdateWindowSkipRefresh(ImGuiWindow* window); IMGUI_API void UpdateWindowSkipRefresh(ImGuiWindow* window);
IMGUI_API ImVec2 CalcWindowNextAutoFitSize(ImGuiWindow* window); IMGUI_API ImVec2 CalcWindowNextAutoFitSize(ImGuiWindow* window);
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy); IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy, bool dock_hierarchy);
IMGUI_API bool IsWindowWithinBeginStackOf(ImGuiWindow* window, ImGuiWindow* potential_parent); IMGUI_API bool IsWindowWithinBeginStackOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
IMGUI_API bool IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below); IMGUI_API bool IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below);
IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window); IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
@ -3123,7 +3370,7 @@ namespace ImGui
IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0); IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
IMGUI_API void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size); IMGUI_API void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size);
IMGUI_API void SetWindowHiddenAndSkipItemsForCurrentFrame(ImGuiWindow* window); IMGUI_API void SetWindowHiddenAndSkipItemsForCurrentFrame(ImGuiWindow* window);
inline void SetWindowParentWindowForFocusRoute(ImGuiWindow* window, ImGuiWindow* parent_window) { window->ParentWindowForFocusRoute = parent_window; } inline void SetWindowParentWindowForFocusRoute(ImGuiWindow* window, ImGuiWindow* parent_window) { window->ParentWindowForFocusRoute = parent_window; } // You may also use SetNextWindowClass()'s FocusRouteParentWindowId field.
inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); } inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); } inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
inline ImVec2 WindowPosAbsToRel(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x - off.x, p.y - off.y); } inline ImVec2 WindowPosAbsToRel(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x - off.x, p.y - off.y); }
@ -3145,9 +3392,7 @@ namespace ImGui
// Fonts, drawing // Fonts, drawing
IMGUI_API void SetCurrentFont(ImFont* font); IMGUI_API void SetCurrentFont(ImFont* font);
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; } inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { IM_UNUSED(window); return GetForegroundDrawList(); } // This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches. inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { return GetForegroundDrawList(window->Viewport); }
IMGUI_API ImDrawList* GetBackgroundDrawList(ImGuiViewport* viewport); // get background draw list for the given viewport. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
IMGUI_API ImDrawList* GetForegroundDrawList(ImGuiViewport* viewport); // get foreground draw list for the given viewport. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
IMGUI_API void AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list); IMGUI_API void AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
// Init // Init
@ -3159,6 +3404,7 @@ namespace ImGui
IMGUI_API void UpdateHoveredWindowAndCaptureFlags(); IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
IMGUI_API void FindHoveredWindowEx(const ImVec2& pos, bool find_first_and_in_any_viewport, ImGuiWindow** out_hovered_window, ImGuiWindow** out_hovered_window_under_moving_window); IMGUI_API void FindHoveredWindowEx(const ImVec2& pos, bool find_first_and_in_any_viewport, ImGuiWindow** out_hovered_window, ImGuiWindow** out_hovered_window_under_moving_window);
IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window); IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
IMGUI_API void StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* node, bool undock);
IMGUI_API void UpdateMouseMovingWindowNewFrame(); IMGUI_API void UpdateMouseMovingWindowNewFrame();
IMGUI_API void UpdateMouseMovingWindowEndFrame(); IMGUI_API void UpdateMouseMovingWindowEndFrame();
@ -3168,7 +3414,13 @@ namespace ImGui
IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type); IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type);
// Viewports // Viewports
IMGUI_API void TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos);
IMGUI_API void ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale);
IMGUI_API void DestroyPlatformWindow(ImGuiViewportP* viewport);
IMGUI_API void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport); IMGUI_API void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
IMGUI_API void SetCurrentViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
IMGUI_API const ImGuiPlatformMonitor* GetViewportPlatformMonitor(ImGuiViewport* viewport);
IMGUI_API ImGuiViewportP* FindHoveredViewportFromPlatformWindowStack(const ImVec2& mouse_platform_pos);
// Settings // Settings
IMGUI_API void MarkIniSettingsDirty(); IMGUI_API void MarkIniSettingsDirty();
@ -3383,6 +3635,61 @@ namespace ImGui
IMGUI_API bool TestShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id); IMGUI_API bool TestShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id);
IMGUI_API ImGuiKeyRoutingData* GetShortcutRoutingData(ImGuiKeyChord key_chord); IMGUI_API ImGuiKeyRoutingData* GetShortcutRoutingData(ImGuiKeyChord key_chord);
// Docking
// (some functions are only declared in imgui.cpp, see Docking section)
IMGUI_API void DockContextInitialize(ImGuiContext* ctx);
IMGUI_API void DockContextShutdown(ImGuiContext* ctx);
IMGUI_API void DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_settings_refs); // Use root_id==0 to clear all
IMGUI_API void DockContextRebuildNodes(ImGuiContext* ctx);
IMGUI_API void DockContextNewFrameUpdateUndocking(ImGuiContext* ctx);
IMGUI_API void DockContextNewFrameUpdateDocking(ImGuiContext* ctx);
IMGUI_API void DockContextEndFrame(ImGuiContext* ctx);
IMGUI_API ImGuiID DockContextGenNodeID(ImGuiContext* ctx);
IMGUI_API void DockContextQueueDock(ImGuiContext* ctx, ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, float split_ratio, bool split_outer);
IMGUI_API void DockContextQueueUndockWindow(ImGuiContext* ctx, ImGuiWindow* window);
IMGUI_API void DockContextQueueUndockNode(ImGuiContext* ctx, ImGuiDockNode* node);
IMGUI_API void DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref = true);
IMGUI_API void DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node);
IMGUI_API bool DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload_window, ImGuiDockNode* payload_node, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos);
IMGUI_API ImGuiDockNode*DockContextFindNodeByID(ImGuiContext* ctx, ImGuiID id);
IMGUI_API void DockNodeWindowMenuHandler_Default(ImGuiContext* ctx, ImGuiDockNode* node, ImGuiTabBar* tab_bar);
IMGUI_API bool DockNodeBeginAmendTabBar(ImGuiDockNode* node);
IMGUI_API void DockNodeEndAmendTabBar();
inline ImGuiDockNode* DockNodeGetRootNode(ImGuiDockNode* node) { while (node->ParentNode) node = node->ParentNode; return node; }
inline bool DockNodeIsInHierarchyOf(ImGuiDockNode* node, ImGuiDockNode* parent) { while (node) { if (node == parent) return true; node = node->ParentNode; } return false; }
inline int DockNodeGetDepth(const ImGuiDockNode* node) { int depth = 0; while (node->ParentNode) { node = node->ParentNode; depth++; } return depth; }
inline ImGuiID DockNodeGetWindowMenuButtonId(const ImGuiDockNode* node) { return ImHashStr("#COLLAPSE", 0, node->ID); }
inline ImGuiDockNode* GetWindowDockNode() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DockNode; }
IMGUI_API bool GetWindowAlwaysWantOwnTabBar(ImGuiWindow* window);
IMGUI_API void BeginDocked(ImGuiWindow* window, bool* p_open);
IMGUI_API void BeginDockableDragDropSource(ImGuiWindow* window);
IMGUI_API void BeginDockableDragDropTarget(ImGuiWindow* window);
IMGUI_API void SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond);
// Docking - Builder function needs to be generally called before the node is used/submitted.
// - The DockBuilderXXX functions are designed to _eventually_ become a public API, but it is too early to expose it and guarantee stability.
// - Do not hold on ImGuiDockNode* pointers! They may be invalidated by any split/merge/remove operation and every frame.
// - To create a DockSpace() node, make sure to set the ImGuiDockNodeFlags_DockSpace flag when calling DockBuilderAddNode().
// You can create dockspace nodes (attached to a window) _or_ floating nodes (carry its own window) with this API.
// - DockBuilderSplitNode() create 2 child nodes within 1 node. The initial node becomes a parent node.
// - If you intend to split the node immediately after creation using DockBuilderSplitNode(), make sure
// to call DockBuilderSetNodeSize() beforehand. If you don't, the resulting split sizes may not be reliable.
// - Call DockBuilderFinish() after you are done.
IMGUI_API void DockBuilderDockWindow(const char* window_name, ImGuiID node_id);
IMGUI_API ImGuiDockNode*DockBuilderGetNode(ImGuiID node_id);
inline ImGuiDockNode* DockBuilderGetCentralNode(ImGuiID node_id) { ImGuiDockNode* node = DockBuilderGetNode(node_id); if (!node) return NULL; return DockNodeGetRootNode(node)->CentralNode; }
IMGUI_API ImGuiID DockBuilderAddNode(ImGuiID node_id = 0, ImGuiDockNodeFlags flags = 0);
IMGUI_API void DockBuilderRemoveNode(ImGuiID node_id); // Remove node and all its child, undock all windows
IMGUI_API void DockBuilderRemoveNodeDockedWindows(ImGuiID node_id, bool clear_settings_refs = true);
IMGUI_API void DockBuilderRemoveNodeChildNodes(ImGuiID node_id); // Remove all split/hierarchy. All remaining docked windows will be re-docked to the remaining root node (node_id).
IMGUI_API void DockBuilderSetNodePos(ImGuiID node_id, ImVec2 pos);
IMGUI_API void DockBuilderSetNodeSize(ImGuiID node_id, ImVec2 size);
IMGUI_API ImGuiID DockBuilderSplitNode(ImGuiID node_id, ImGuiDir split_dir, float size_ratio_for_node_at_dir, ImGuiID* out_id_at_dir, ImGuiID* out_id_at_opposite_dir); // Create 2 child nodes in this parent node.
IMGUI_API void DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_dockspace_id, ImVector<const char*>* in_window_remap_pairs);
IMGUI_API void DockBuilderCopyNode(ImGuiID src_node_id, ImGuiID dst_node_id, ImVector<ImGuiID>* out_node_remap_pairs);
IMGUI_API void DockBuilderCopyWindowSettings(const char* src_name, const char* dst_name);
IMGUI_API void DockBuilderFinish(ImGuiID node_id);
// [EXPERIMENTAL] Focus Scope // [EXPERIMENTAL] Focus Scope
// This is generally used to identify a unique input location (for e.g. a selection set) // This is generally used to identify a unique input location (for e.g. a selection set)
// There is one per window (automatically set in Begin), but: // There is one per window (automatically set in Begin), but:
@ -3493,9 +3800,11 @@ namespace ImGui
IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags); IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags);
IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id); IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
IMGUI_API ImGuiTabItem* TabBarFindTabByOrder(ImGuiTabBar* tab_bar, int order); IMGUI_API ImGuiTabItem* TabBarFindTabByOrder(ImGuiTabBar* tab_bar, int order);
IMGUI_API ImGuiTabItem* TabBarFindMostRecentlySelectedTabForActiveWindow(ImGuiTabBar* tab_bar);
IMGUI_API ImGuiTabItem* TabBarGetCurrentTab(ImGuiTabBar* tab_bar); IMGUI_API ImGuiTabItem* TabBarGetCurrentTab(ImGuiTabBar* tab_bar);
inline int TabBarGetTabOrder(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) { return tab_bar->Tabs.index_from_ptr(tab); } inline int TabBarGetTabOrder(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) { return tab_bar->Tabs.index_from_ptr(tab); }
IMGUI_API const char* TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab); IMGUI_API const char* TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
IMGUI_API void TabBarAddTab(ImGuiTabBar* tab_bar, ImGuiTabItemFlags tab_flags, ImGuiWindow* window);
IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id); IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab); IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
IMGUI_API void TabBarQueueFocus(ImGuiTabBar* tab_bar, ImGuiTabItem* tab); IMGUI_API void TabBarQueueFocus(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
@ -3528,8 +3837,10 @@ namespace ImGui
IMGUI_API void RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col); IMGUI_API void RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col);
IMGUI_API void RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz); IMGUI_API void RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz);
IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col); IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
IMGUI_API void RenderArrowDockMenu(ImDrawList* draw_list, ImVec2 p_min, float sz, ImU32 col);
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding); IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer, const ImRect& inner, ImU32 col, float rounding); IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer, const ImRect& inner, ImU32 col, float rounding);
IMGUI_API ImDrawFlags CalcRoundingFlagsForRectInRect(const ImRect& r_in, const ImRect& r_outer, float threshold);
// Widgets // Widgets
IMGUI_API void TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0); IMGUI_API void TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0);
@ -3543,7 +3854,7 @@ namespace ImGui
// Widgets: Window Decorations // Widgets: Window Decorations
IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos); IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos);
IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos); IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_node);
IMGUI_API void Scrollbar(ImGuiAxis axis); IMGUI_API void Scrollbar(ImGuiAxis axis);
IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, ImS64* p_scroll_v, ImS64 avail_v, ImS64 contents_v, ImDrawFlags flags); IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, ImS64* p_scroll_v, ImS64 avail_v, ImS64 contents_v, ImDrawFlags flags);
IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis); IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis);
@ -3627,6 +3938,7 @@ namespace ImGui
IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas);
IMGUI_API void DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end); IMGUI_API void DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end);
IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns); IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns);
IMGUI_API void DebugNodeDockNode(ImGuiDockNode* node, const char* label);
IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label); IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label);
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb); IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
IMGUI_API void DebugNodeFont(ImFont* font); IMGUI_API void DebugNodeFont(ImFont* font);
@ -3643,6 +3955,7 @@ namespace ImGui
IMGUI_API void DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* label); IMGUI_API void DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* label);
IMGUI_API void DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int windows_size, ImGuiWindow* parent_in_begin_stack); IMGUI_API void DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int windows_size, ImGuiWindow* parent_in_begin_stack);
IMGUI_API void DebugNodeViewport(ImGuiViewportP* viewport); IMGUI_API void DebugNodeViewport(ImGuiViewportP* viewport);
IMGUI_API void DebugNodePlatformMonitor(ImGuiPlatformMonitor* monitor, const char* label, int idx);
IMGUI_API void DebugRenderKeyboardPreview(ImDrawList* draw_list); IMGUI_API void DebugRenderKeyboardPreview(ImDrawList* draw_list);
IMGUI_API void DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb); IMGUI_API void DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb);

View File

@ -507,7 +507,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
item_flags |= ImGuiItemFlags_ButtonRepeat; item_flags |= ImGuiItemFlags_ButtonRepeat;
ImGuiWindow* backup_hovered_window = g.HoveredWindow; ImGuiWindow* backup_hovered_window = g.HoveredWindow;
const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredWindow && g.HoveredWindow->RootWindow == window; const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredWindow && g.HoveredWindow->RootWindowDockTree == window->RootWindowDockTree;
if (flatten_hovered_children) if (flatten_hovered_children)
g.HoveredWindow = window; g.HoveredWindow = window;
@ -863,7 +863,8 @@ bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)
return pressed; return pressed;
} }
bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos) // The Collapse button also functions as a Dock Menu button.
bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_node)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
@ -876,16 +877,21 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
return pressed; return pressed;
// Render // Render
//bool is_dock_menu = (window->DockNodeAsHost && !window->Collapsed);
ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
ImU32 text_col = GetColorU32(ImGuiCol_Text); ImU32 text_col = GetColorU32(ImGuiCol_Text);
if (hovered || held) if (hovered || held)
window->DrawList->AddRectFilled(bb.Min, bb.Max, bg_col); window->DrawList->AddRectFilled(bb.Min, bb.Max, bg_col);
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_Compact); RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_Compact);
RenderArrow(window->DrawList, bb.Min, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
if (dock_node)
RenderArrowDockMenu(window->DrawList, bb.Min, g.FontSize, text_col);
else
RenderArrow(window->DrawList, bb.Min, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
// Switch to moving the window after mouse is moved beyond the initial drag threshold // Switch to moving the window after mouse is moved beyond the initial drag threshold
if (IsItemActive() && IsMouseDragging(0)) if (IsItemActive() && IsMouseDragging(0))
StartMouseMovingWindow(window); StartMouseMovingWindowOrNode(window, dock_node, true); // Undock from window/collapse menu button
return pressed; return pressed;
} }
@ -1627,7 +1633,7 @@ void ImGui::SeparatorTextEx(ImGuiID id, const char* label, const char* label_end
const float separator_thickness = style.SeparatorTextBorderSize; const float separator_thickness = style.SeparatorTextBorderSize;
const ImVec2 min_size(label_size.x + extra_w + padding.x * 2.0f, ImMax(label_size.y + padding.y * 2.0f, separator_thickness)); const ImVec2 min_size(label_size.x + extra_w + padding.x * 2.0f, ImMax(label_size.y + padding.y * 2.0f, separator_thickness));
const ImRect bb(pos, ImVec2(window->WorkRect.Max.x, pos.y + min_size.y)); const ImRect bb(pos, ImVec2(window->WorkRect.Max.x, pos.y + min_size.y));
const float text_baseline_y = ImTrunc((bb.GetHeight() - label_size.y) * style.SeparatorTextAlign.y + 0.99999f); //ImMax(padding.y, ImFloor((style.SeparatorTextSize - label_size.y) * 0.5f)); const float text_baseline_y = ImTrunc((bb.GetHeight() - label_size.y) * style.SeparatorTextAlign.y + 0.99999f); //ImMax(padding.y, ImTrunc((style.SeparatorTextSize - label_size.y) * 0.5f));
ItemSize(min_size, text_baseline_y); ItemSize(min_size, text_baseline_y);
if (!ItemAdd(bb, id)) if (!ItemAdd(bb, id))
return; return;
@ -5169,6 +5175,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
g.PlatformImeData.WantVisible = true; g.PlatformImeData.WantVisible = true;
g.PlatformImeData.InputPos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize); g.PlatformImeData.InputPos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize);
g.PlatformImeData.InputLineHeight = g.FontSize; g.PlatformImeData.InputLineHeight = g.FontSize;
g.PlatformImeViewport = window->Viewport->ID;
} }
} }
} }
@ -8472,7 +8479,7 @@ bool ImGui::BeginMenuBar()
// We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect. // We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect.
// We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy. // We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy.
ImRect bar_rect = window->MenuBarRect(); ImRect bar_rect = window->MenuBarRect();
ImRect clip_rect(IM_ROUND(bar_rect.Min.x + window->WindowBorderSize), IM_ROUND(bar_rect.Min.y + window->WindowBorderSize), IM_ROUND(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize))), IM_ROUND(bar_rect.Max.y)); ImRect clip_rect(ImFloor(bar_rect.Min.x + window->WindowBorderSize), ImFloor(bar_rect.Min.y + window->WindowBorderSize), ImFloor(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize))), ImFloor(bar_rect.Max.y));
clip_rect.ClipWith(window->OuterRectClipped); clip_rect.ClipWith(window->OuterRectClipped);
PushClipRect(clip_rect.Min, clip_rect.Max, false); PushClipRect(clip_rect.Min, clip_rect.Max, false);
@ -8542,10 +8549,10 @@ bool ImGui::BeginViewportSideBar(const char* name, ImGuiViewport* viewport_p, Im
IM_ASSERT(dir != ImGuiDir_None); IM_ASSERT(dir != ImGuiDir_None);
ImGuiWindow* bar_window = FindWindowByName(name); ImGuiWindow* bar_window = FindWindowByName(name);
ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)(viewport_p ? viewport_p : GetMainViewport());
if (bar_window == NULL || bar_window->BeginCount == 0) if (bar_window == NULL || bar_window->BeginCount == 0)
{ {
// Calculate and set window size/position // Calculate and set window size/position
ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)(viewport_p ? viewport_p : GetMainViewport());
ImRect avail_rect = viewport->GetBuildWorkRect(); ImRect avail_rect = viewport->GetBuildWorkRect();
ImGuiAxis axis = (dir == ImGuiDir_Up || dir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X; ImGuiAxis axis = (dir == ImGuiDir_Up || dir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
ImVec2 pos = avail_rect.Min; ImVec2 pos = avail_rect.Min;
@ -8563,7 +8570,8 @@ bool ImGui::BeginViewportSideBar(const char* name, ImGuiViewport* viewport_p, Im
viewport->BuildWorkInsetMax[axis] += axis_size; viewport->BuildWorkInsetMax[axis] += axis_size;
} }
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDocking;
SetNextWindowViewport(viewport->ID); // Enforce viewport so we don't create our own viewport when ImGuiConfigFlags_ViewportsNoMerge is set.
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0)); // Lift normal size constraint PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0)); // Lift normal size constraint
bool is_open = Begin(name, NULL, window_flags); bool is_open = Begin(name, NULL, window_flags);
@ -8577,6 +8585,9 @@ bool ImGui::BeginMainMenuBar()
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)GetMainViewport(); ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)GetMainViewport();
// Notify of viewport change so GetFrameHeight() can be accurate in case of DPI change
SetCurrentViewport(NULL, viewport);
// For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set. // For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set.
// FIXME: This could be generalized as an opt-in way to clamp window->DC.CursorStartPos to avoid SafeArea? // FIXME: This could be generalized as an opt-in way to clamp window->DC.CursorStartPos to avoid SafeArea?
// FIXME: Consider removing support for safe area down the line... it's messy. Nowadays consoles have support for TV calibration in OS settings. // FIXME: Consider removing support for safe area down the line... it's messy. Nowadays consoles have support for TV calibration in OS settings.
@ -8627,7 +8638,7 @@ static bool IsRootOfOpenMenuSet()
const ImGuiPopupData* upper_popup = &g.OpenPopupStack[g.BeginPopupStack.Size]; const ImGuiPopupData* upper_popup = &g.OpenPopupStack[g.BeginPopupStack.Size];
if (window->DC.NavLayerCurrent != upper_popup->ParentNavLayer) if (window->DC.NavLayerCurrent != upper_popup->ParentNavLayer)
return false; return false;
return upper_popup->Window && (upper_popup->Window->Flags & ImGuiWindowFlags_ChildMenu) && ImGui::IsWindowChildOf(upper_popup->Window, window, true); return upper_popup->Window && (upper_popup->Window->Flags & ImGuiWindowFlags_ChildMenu) && ImGui::IsWindowChildOf(upper_popup->Window, window, true, false);
} }
bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled) bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
@ -8966,8 +8977,10 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected,
// - TabBarCalcMaxTabWidth() [Internal] // - TabBarCalcMaxTabWidth() [Internal]
// - TabBarFindTabById() [Internal] // - TabBarFindTabById() [Internal]
// - TabBarFindTabByOrder() [Internal] // - TabBarFindTabByOrder() [Internal]
// - TabBarFindMostRecentlySelectedTabForActiveWindow() [Internal]
// - TabBarGetCurrentTab() [Internal] // - TabBarGetCurrentTab() [Internal]
// - TabBarGetTabName() [Internal] // - TabBarGetTabName() [Internal]
// - TabBarAddTab() [Internal]
// - TabBarRemoveTab() [Internal] // - TabBarRemoveTab() [Internal]
// - TabBarCloseTab() [Internal] // - TabBarCloseTab() [Internal]
// - TabBarScrollClamp() [Internal] // - TabBarScrollClamp() [Internal]
@ -9088,7 +9101,8 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
// Ensure correct ordering when toggling ImGuiTabBarFlags_Reorderable flag, or when a new tab was added while being not reorderable // Ensure correct ordering when toggling ImGuiTabBarFlags_Reorderable flag, or when a new tab was added while being not reorderable
if ((flags & ImGuiTabBarFlags_Reorderable) != (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (tab_bar->TabsAddedNew && !(flags & ImGuiTabBarFlags_Reorderable))) if ((flags & ImGuiTabBarFlags_Reorderable) != (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (tab_bar->TabsAddedNew && !(flags & ImGuiTabBarFlags_Reorderable)))
ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByBeginOrder); if ((flags & ImGuiTabBarFlags_DockNode) == 0) // FIXME: TabBar with DockNode can now be hybrid
ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByBeginOrder);
tab_bar->TabsAddedNew = false; tab_bar->TabsAddedNew = false;
// Flags // Flags
@ -9370,6 +9384,10 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
tab_bar->VisibleTabId = tab_bar->SelectedTabId; tab_bar->VisibleTabId = tab_bar->SelectedTabId;
tab_bar->VisibleTabWasSubmitted = false; tab_bar->VisibleTabWasSubmitted = false;
// CTRL+TAB can override visible tab temporarily
if (g.NavWindowingTarget != NULL && g.NavWindowingTarget->DockNode && g.NavWindowingTarget->DockNode->TabBar == tab_bar)
tab_bar->VisibleTabId = scroll_to_tab_id = g.NavWindowingTarget->TabId;
// Apply request requests // Apply request requests
if (scroll_to_tab_id != 0) if (scroll_to_tab_id != 0)
TabBarScrollToTab(tab_bar, scroll_to_tab_id, sections); TabBarScrollToTab(tab_bar, scroll_to_tab_id, sections);
@ -9415,11 +9433,11 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
// Dockable windows uses Name/ID in the global namespace. Non-dockable items use the ID stack. // Dockable windows uses Name/ID in the global namespace. Non-dockable items use the ID stack.
static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label, ImGuiWindow* docked_window) static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label, ImGuiWindow* docked_window)
{ {
IM_ASSERT(docked_window == NULL); // master branch only if (docked_window != NULL)
IM_UNUSED(docked_window);
if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
{ {
ImGuiID id = ImHashStr(label); IM_UNUSED(tab_bar);
IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_DockNode);
ImGuiID id = docked_window->TabId;
KeepAliveID(id); KeepAliveID(id);
return id; return id;
} }
@ -9453,6 +9471,20 @@ ImGuiTabItem* ImGui::TabBarFindTabByOrder(ImGuiTabBar* tab_bar, int order)
return &tab_bar->Tabs[order]; return &tab_bar->Tabs[order];
} }
// FIXME: See references to #2304 in TODO.txt
ImGuiTabItem* ImGui::TabBarFindMostRecentlySelectedTabForActiveWindow(ImGuiTabBar* tab_bar)
{
ImGuiTabItem* most_recently_selected_tab = NULL;
for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
{
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
if (most_recently_selected_tab == NULL || most_recently_selected_tab->LastFrameSelected < tab->LastFrameSelected)
if (tab->Window && tab->Window->WasActive)
most_recently_selected_tab = tab;
}
return most_recently_selected_tab;
}
ImGuiTabItem* ImGui::TabBarGetCurrentTab(ImGuiTabBar* tab_bar) ImGuiTabItem* ImGui::TabBarGetCurrentTab(ImGuiTabBar* tab_bar)
{ {
if (tab_bar->LastTabItemIdx < 0 || tab_bar->LastTabItemIdx >= tab_bar->Tabs.Size) if (tab_bar->LastTabItemIdx < 0 || tab_bar->LastTabItemIdx >= tab_bar->Tabs.Size)
@ -9462,12 +9494,35 @@ ImGuiTabItem* ImGui::TabBarGetCurrentTab(ImGuiTabBar* tab_bar)
const char* ImGui::TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) const char* ImGui::TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab)
{ {
if (tab->Window)
return tab->Window->Name;
if (tab->NameOffset == -1) if (tab->NameOffset == -1)
return "N/A"; return "N/A";
IM_ASSERT(tab->NameOffset < tab_bar->TabsNames.Buf.Size); IM_ASSERT(tab->NameOffset < tab_bar->TabsNames.Buf.Size);
return tab_bar->TabsNames.Buf.Data + tab->NameOffset; return tab_bar->TabsNames.Buf.Data + tab->NameOffset;
} }
// The purpose of this call is to register tab in advance so we can control their order at the time they appear.
// Otherwise calling this is unnecessary as tabs are appending as needed by the BeginTabItem() function.
void ImGui::TabBarAddTab(ImGuiTabBar* tab_bar, ImGuiTabItemFlags tab_flags, ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(TabBarFindTabByID(tab_bar, window->TabId) == NULL);
IM_ASSERT(g.CurrentTabBar != tab_bar); // Can't work while the tab bar is active as our tab doesn't have an X offset yet, in theory we could/should test something like (tab_bar->CurrFrameVisible < g.FrameCount) but we'd need to solve why triggers the commented early-out assert in BeginTabBarEx() (probably dock node going from implicit to explicit in same frame)
if (!window->HasCloseButton)
tab_flags |= ImGuiTabItemFlags_NoCloseButton; // Set _NoCloseButton immediately because it will be used for first-frame width calculation.
ImGuiTabItem new_tab;
new_tab.ID = window->TabId;
new_tab.Flags = tab_flags;
new_tab.LastFrameVisible = tab_bar->CurrFrameVisible; // Required so BeginTabBar() doesn't ditch the tab
if (new_tab.LastFrameVisible == -1)
new_tab.LastFrameVisible = g.FrameCount - 1;
new_tab.Window = window; // Required so tab bar layout can compute the tab width before tab submission
tab_bar->Tabs.push_back(new_tab);
}
// The *TabId fields are already set by the docking system _before_ the actual TabItem was created, so we clear them regardless. // The *TabId fields are already set by the docking system _before_ the actual TabItem was created, so we clear them regardless.
void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id) void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id)
{ {
@ -9748,7 +9803,7 @@ bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags f
IM_ASSERT_USER_ERROR(tab_bar, "Needs to be called between BeginTabBar() and EndTabBar()!"); IM_ASSERT_USER_ERROR(tab_bar, "Needs to be called between BeginTabBar() and EndTabBar()!");
return false; return false;
} }
IM_ASSERT(!(flags & ImGuiTabItemFlags_Button)); // BeginTabItem() Can't be used with button flags, use TabItemButton() instead! IM_ASSERT((flags & ImGuiTabItemFlags_Button) == 0); // BeginTabItem() Can't be used with button flags, use TabItemButton() instead!
bool ret = TabItemEx(tab_bar, label, p_open, flags, NULL); bool ret = TabItemEx(tab_bar, label, p_open, flags, NULL);
if (ret && !(flags & ImGuiTabItemFlags_NoPushId)) if (ret && !(flags & ImGuiTabItemFlags_NoPushId))
@ -9858,11 +9913,14 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
const bool is_tab_button = (flags & ImGuiTabItemFlags_Button) != 0; const bool is_tab_button = (flags & ImGuiTabItemFlags_Button) != 0;
tab->LastFrameVisible = g.FrameCount; tab->LastFrameVisible = g.FrameCount;
tab->Flags = flags; tab->Flags = flags;
tab->Window = docked_window;
// Append name _WITH_ the zero-terminator // Append name _WITH_ the zero-terminator
// (regular tabs are permitted in a DockNode tab bar, but window tabs not permitted in a non-DockNode tab bar)
if (docked_window != NULL) if (docked_window != NULL)
{ {
IM_ASSERT(docked_window == NULL); // master branch only IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_DockNode);
tab->NameOffset = -1;
} }
else else
{ {
@ -9887,7 +9945,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
tab_bar->VisibleTabWasSubmitted = true; tab_bar->VisibleTabWasSubmitted = true;
// On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches // On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches
if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing) if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing && docked_window == NULL)
if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs)) if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs))
tab_contents_visible = true; tab_contents_visible = true;
@ -9935,30 +9993,82 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
} }
// Click to Select a tab // Click to Select a tab
// Allow the close button to overlap
ImGuiButtonFlags button_flags = ((is_tab_button ? ImGuiButtonFlags_PressedOnClickRelease : ImGuiButtonFlags_PressedOnClick) | ImGuiButtonFlags_AllowOverlap); ImGuiButtonFlags button_flags = ((is_tab_button ? ImGuiButtonFlags_PressedOnClickRelease : ImGuiButtonFlags_PressedOnClick) | ImGuiButtonFlags_AllowOverlap);
if (g.DragDropActive) if (g.DragDropActive && !g.DragDropPayload.IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW)) // FIXME: May be an opt-in property of the payload to disable this
button_flags |= ImGuiButtonFlags_PressedOnDragDropHold; button_flags |= ImGuiButtonFlags_PressedOnDragDropHold;
bool hovered, held; bool hovered, held;
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags); bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
if (pressed && !is_tab_button) if (pressed && !is_tab_button)
TabBarQueueFocus(tab_bar, tab); TabBarQueueFocus(tab_bar, tab);
// Drag and drop: re-order tabs // Transfer active id window so the active id is not owned by the dock host (as StartMouseMovingWindow()
if (held && !tab_appearing && IsMouseDragging(0)) // will only do it on the drag). This allows FocusWindow() to be more conservative in how it clears active id.
if (held && docked_window && g.ActiveId == id && g.ActiveIdIsJustActivated)
g.ActiveIdWindow = docked_window;
// Drag and drop a single floating window node moves it
ImGuiDockNode* node = docked_window ? docked_window->DockNode : NULL;
const bool single_floating_window_node = node && node->IsFloatingNode() && (node->Windows.Size == 1);
if (held && single_floating_window_node && IsMouseDragging(0, 0.0f))
{ {
if (!g.DragDropActive && (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)) // Move
StartMouseMovingWindow(docked_window);
}
else if (held && !tab_appearing && IsMouseDragging(0))
{
// Drag and drop: re-order tabs
int drag_dir = 0;
float drag_distance_from_edge_x = 0.0f;
if (!g.DragDropActive && ((tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (docked_window != NULL)))
{ {
// While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x // While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x
if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x) if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x)
{ {
drag_dir = -1;
drag_distance_from_edge_x = bb.Min.x - g.IO.MousePos.x;
TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos); TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos);
} }
else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x) else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x)
{ {
drag_dir = +1;
drag_distance_from_edge_x = g.IO.MousePos.x - bb.Max.x;
TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos); TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos);
} }
} }
// Extract a Dockable window out of it's tab bar
const bool can_undock = docked_window != NULL && !(docked_window->Flags & ImGuiWindowFlags_NoMove) && !(node->MergedFlags & ImGuiDockNodeFlags_NoUndocking);
if (can_undock)
{
// We use a variable threshold to distinguish dragging tabs within a tab bar and extracting them out of the tab bar
bool undocking_tab = (g.DragDropActive && g.DragDropPayload.SourceId == id);
if (!undocking_tab) //&& (!g.IO.ConfigDockingWithShift || g.IO.KeyShift)
{
float threshold_base = g.FontSize;
float threshold_x = (threshold_base * 2.2f);
float threshold_y = (threshold_base * 1.5f) + ImClamp((ImFabs(g.IO.MouseDragMaxDistanceAbs[0].x) - threshold_base * 2.0f) * 0.20f, 0.0f, threshold_base * 4.0f);
//GetForegroundDrawList()->AddRect(ImVec2(bb.Min.x - threshold_x, bb.Min.y - threshold_y), ImVec2(bb.Max.x + threshold_x, bb.Max.y + threshold_y), IM_COL32_WHITE); // [DEBUG]
float distance_from_edge_y = ImMax(bb.Min.y - g.IO.MousePos.y, g.IO.MousePos.y - bb.Max.y);
if (distance_from_edge_y >= threshold_y)
undocking_tab = true;
if (drag_distance_from_edge_x > threshold_x)
if ((drag_dir < 0 && TabBarGetTabOrder(tab_bar, tab) == 0) || (drag_dir > 0 && TabBarGetTabOrder(tab_bar, tab) == tab_bar->Tabs.Size - 1))
undocking_tab = true;
}
if (undocking_tab)
{
// Undock
// FIXME: refactor to share more code with e.g. StartMouseMovingWindow
DockContextQueueUndockWindow(&g, docked_window);
g.MovingWindow = docked_window;
SetActiveID(g.MovingWindow->MoveId, g.MovingWindow);
g.ActiveIdClickOffset -= g.MovingWindow->Pos - bb.Min;
g.ActiveIdNoClearOnFocusLoss = true;
SetActiveIdUsingAllKeyboardKeys();
}
}
} }
#if 0 #if 0
@ -9994,7 +10104,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton; flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton;
// Render tab label, process close button // Render tab label, process close button
const ImGuiID close_button_id = p_open ? GetIDWithSeed("#CLOSE", NULL, id) : 0; const ImGuiID close_button_id = p_open ? GetIDWithSeed("#CLOSE", NULL, docked_window ? docked_window->ID : id) : 0;
bool just_closed; bool just_closed;
bool text_clipped; bool text_clipped;
TabItemLabelAndCloseButton(display_draw_list, bb, tab_just_unsaved ? (flags & ~ImGuiTabItemFlags_UnsavedDocument) : flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible, &just_closed, &text_clipped); TabItemLabelAndCloseButton(display_draw_list, bb, tab_just_unsaved ? (flags & ~ImGuiTabItemFlags_UnsavedDocument) : flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible, &just_closed, &text_clipped);
@ -10004,6 +10114,11 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
TabBarCloseTab(tab_bar, tab); TabBarCloseTab(tab_bar, tab);
} }
// Forward Hovered state so IsItemHovered() after Begin() can work (even though we are technically hovering our parent)
// That state is copied to window->DockTabItemStatusFlags by our caller.
if (docked_window && (hovered || g.HoveredId == close_button_id))
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow;
// Restore main window position so user can draw there // Restore main window position so user can draw there
if (want_clip_rect) if (want_clip_rect)
PopClipRect(); PopClipRect();
@ -10038,6 +10153,16 @@ void ImGui::SetTabItemClosed(const char* label)
if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id)) if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id))
tab->WantClose = true; // Will be processed by next call to TabBarLayout() tab->WantClose = true; // Will be processed by next call to TabBarLayout()
} }
else if (ImGuiWindow* window = FindWindowByName(label))
{
if (window->DockIsActive)
if (ImGuiDockNode* node = window->DockNode)
{
ImGuiID tab_id = TabBarCalcTabID(node->TabBar, label, window);
TabBarRemoveTab(node->TabBar, tab_id);
window->DockTabWantClose = true;
}
}
} }
ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button_or_unsaved_marker) ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button_or_unsaved_marker)
@ -10052,10 +10177,9 @@ ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button_or_unsave
return ImVec2(ImMin(size.x, TabBarCalcMaxTabWidth()), size.y); return ImVec2(ImMin(size.x, TabBarCalcMaxTabWidth()), size.y);
} }
ImVec2 ImGui::TabItemCalcSize(ImGuiWindow*) ImVec2 ImGui::TabItemCalcSize(ImGuiWindow* window)
{ {
IM_ASSERT(0); // This function exists to facilitate merge with 'docking' branch. return TabItemCalcSize(window->Name, window->HasCloseButton || (window->Flags & ImGuiWindowFlags_UnsavedDocument));
return ImVec2(0.0f, 0.0f);
} }
void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col) void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col)

View File

@ -55,4 +55,8 @@ More information at: https://docs.microsoft.com/en-us/visualstudio/debugger/crea
<DisplayString>{{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags &amp; 0x01000000)?1:0,d} Popup {(Flags &amp; 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}}</DisplayString> <DisplayString>{{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags &amp; 0x01000000)?1:0,d} Popup {(Flags &amp; 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}}</DisplayString>
</Type> </Type>
<Type Name="ImGuiDockNode">
<DisplayString>{{ID {ID,x} Pos=({Pos.x,g} {Pos.y,g}) Size=({Size.x,g} {Size.y,g}) Parent {(ParentNode==0)?0:ParentNode->ID,x} Childs {(ChildNodes[0] != 0)+(ChildNodes[1] != 0)} Windows {Windows.Size} }</DisplayString>
</Type>
</AutoVisualizer> </AutoVisualizer>