mirror of
https://github.com/ocornut/imgui.git
synced 2026-07-08 18:39:40 +00:00
Compare commits
214 Commits
v1.92.1-do
...
v1.92.3-do
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62275e877a | ||
|
|
f4a3529ffc | ||
|
|
34bff4672c | ||
|
|
1c544ee941 | ||
|
|
70a43f3088 | ||
|
|
9cf9d2be83 | ||
|
|
7e473d38d3 | ||
|
|
6d834d325e | ||
|
|
f6890ed007 | ||
|
|
431f2c5abd | ||
|
|
6274ca4266 | ||
|
|
d92c8c6aff | ||
|
|
72c00f39c1 | ||
|
|
2675b7ca26 | ||
|
|
10d0162378 | ||
|
|
3c6c5692b8 | ||
|
|
e044d99710 | ||
|
|
22a6a83c54 | ||
|
|
09e7870497 | ||
|
|
cd476b27f8 | ||
|
|
9f13684d70 | ||
|
|
a4cd45f44c | ||
|
|
6d25cb844b | ||
|
|
586da87728 | ||
|
|
36133d8ac4 | ||
|
|
8c6096fcfe | ||
|
|
b6a33f8ce1 | ||
|
|
78c1d4a92c | ||
|
|
7f1e2bb8dd | ||
|
|
2f3e85bc37 | ||
|
|
e8ca7af4c0 | ||
|
|
0457a09bb9 | ||
|
|
71f45c12e9 | ||
|
|
8a94422246 | ||
|
|
ae832ce532 | ||
|
|
1e52e7b90c | ||
|
|
67085d732a | ||
|
|
f36c65661c | ||
|
|
e2b7d84e96 | ||
|
|
271f476d08 | ||
|
|
e2f314d613 | ||
|
|
8eb22ea620 | ||
|
|
55f590c1d1 | ||
|
|
dae66eb3b5 | ||
|
|
37b18acdf5 | ||
|
|
6b2cdf29bc | ||
|
|
5e5658e68f | ||
|
|
3dcd17f402 | ||
|
|
013c4ed476 | ||
|
|
2f1d1c8b2f | ||
|
|
1cd08b883c | ||
|
|
4e98fb20e2 | ||
|
|
045645e5f1 | ||
|
|
8e4955bb23 | ||
|
|
e66afbbbe0 | ||
|
|
2841c5135d | ||
|
|
bf52f4a83c | ||
|
|
14e076c5bb | ||
|
|
ea8a5a9e17 | ||
|
|
ab760992ad | ||
|
|
230418a75d | ||
|
|
16415aa39f | ||
|
|
985723ed94 | ||
|
|
a82f66a9b0 | ||
|
|
e422a38e4c | ||
|
|
11fff1ccf5 | ||
|
|
3cc7d1c81a | ||
|
|
56189cd814 | ||
|
|
a9945899c6 | ||
|
|
bc6478f651 | ||
|
|
34ab6c8a89 | ||
|
|
c63b5bd8fb | ||
|
|
8a35ce0e98 | ||
|
|
f77f68a5ed | ||
|
|
bed08daede | ||
|
|
09ebcf1779 | ||
|
|
a959617d2e | ||
|
|
02af06ea5f | ||
|
|
f937a32742 | ||
|
|
fdcd351488 | ||
|
|
026d47cd35 | ||
|
|
c63714822f | ||
|
|
26aa81a8b1 | ||
|
|
1ecc34a0b1 | ||
|
|
ee03cef14f | ||
|
|
e51d93e2f5 | ||
|
|
7d33524042 | ||
|
|
605a751571 | ||
|
|
b7cb3d93a4 | ||
|
|
20160ff1d5 | ||
|
|
3766d40394 | ||
|
|
0dd3c845eb | ||
|
|
740c566305 | ||
|
|
8dc457fda2 | ||
|
|
0ef9610e70 | ||
|
|
5c92699f5f | ||
|
|
771fae623d | ||
|
|
6351f00ff1 | ||
|
|
55cbc66508 | ||
|
|
9f969944d5 | ||
|
|
4d216d4510 | ||
|
|
aa2f40c3bb | ||
|
|
a309d2dcac | ||
|
|
87c1ab7988 | ||
|
|
319c481abb | ||
|
|
229d56e37a | ||
|
|
7d230594de | ||
|
|
75a4a48d1f | ||
|
|
9e864012ae | ||
|
|
783f1e62cc | ||
|
|
e728b96600 | ||
|
|
fe03035112 | ||
|
|
a28cb615ff | ||
|
|
515c0b526f | ||
|
|
03e39ca7f5 | ||
|
|
7c6fa8f8f7 | ||
|
|
4ebfe1cba5 | ||
|
|
42656b3aa1 | ||
|
|
89b7fc906a | ||
|
|
0c4f50090a | ||
|
|
720e94f3da | ||
|
|
321e9eb919 | ||
|
|
655601169b | ||
|
|
361e370fe0 | ||
|
|
86ec5c8342 | ||
|
|
1f7f1f54af | ||
|
|
160e3683ab | ||
|
|
45acd5e0e8 | ||
|
|
774ddb58bd | ||
|
|
4dee11a089 | ||
|
|
43e3ac0dc6 | ||
|
|
02f654cbce | ||
|
|
e1baadba84 | ||
|
|
e2a662eed8 | ||
|
|
e1a93805db | ||
|
|
af920e1e6f | ||
|
|
863e989c25 | ||
|
|
031a18c417 | ||
|
|
2b24f5fa71 | ||
|
|
e10300ed3c | ||
|
|
104f58fc48 | ||
|
|
5a6fa33b88 | ||
|
|
8239a0e0c4 | ||
|
|
50115596dc | ||
|
|
1c57dc21c2 | ||
|
|
47c41483bd | ||
|
|
ea075ed973 | ||
|
|
b431114194 | ||
|
|
cbf9e3f554 | ||
|
|
b6614f6c7c | ||
|
|
9ee3d731b5 | ||
|
|
e7d0ad092c | ||
|
|
412daf7362 | ||
|
|
c22af8c346 | ||
|
|
1bf41a0762 | ||
|
|
284283615b | ||
|
|
d163e20f63 | ||
|
|
f7eae45ae9 | ||
|
|
ff2dfc8422 | ||
|
|
7e701c18c8 | ||
|
|
90025a62c7 | ||
|
|
902b8cc39a | ||
|
|
70cfc02811 | ||
|
|
250bd66b76 | ||
|
|
c14d83d4e0 | ||
|
|
7d5fef8642 | ||
|
|
22fe9fce4c | ||
|
|
eda70b4e1a | ||
|
|
23c9362550 | ||
|
|
320c94bfaa | ||
|
|
3ef6c8410a | ||
|
|
cc1fbcc9a9 | ||
|
|
78d11cd781 | ||
|
|
7278cda039 | ||
|
|
7bb9db501c | ||
|
|
046a8eae0f | ||
|
|
a0cdac48e0 | ||
|
|
2ab3946ecb | ||
|
|
63f00dae6b | ||
|
|
80d78fad7c | ||
|
|
34debc733f | ||
|
|
87d7f7744e | ||
|
|
10dc1882c8 | ||
|
|
c6c0c3be08 | ||
|
|
da6c97203e | ||
|
|
853a46e021 | ||
|
|
075ad676aa | ||
|
|
19d1ad04f4 | ||
|
|
b884533957 | ||
|
|
174f37bdaf | ||
|
|
4f00774006 | ||
|
|
8403c49484 | ||
|
|
15e3bfac9d | ||
|
|
6cecd1a15b | ||
|
|
08620b7ceb | ||
|
|
fe1cee0837 | ||
|
|
06ab541e2f | ||
|
|
7babc24ad4 | ||
|
|
c96e9c8273 | ||
|
|
4a51295c9e | ||
|
|
9c392896b7 | ||
|
|
ea613e181c | ||
|
|
ed5bd1f9ef | ||
|
|
3401dbde92 | ||
|
|
c9e0208de4 | ||
|
|
57a816ae60 | ||
|
|
643f0e3abf | ||
|
|
8744d10235 | ||
|
|
336d9212fc | ||
|
|
79d88e2d0b | ||
|
|
a0d3e405a3 | ||
|
|
0e6e876f23 | ||
|
|
c680f54e6c | ||
|
|
4d745bc602 |
102
.github/workflows/build.yml
vendored
102
.github/workflows/build.yml
vendored
@@ -27,13 +27,28 @@ jobs:
|
|||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.26.3-VC.zip" -OutFile "SDL2-devel-2.26.3-VC.zip"
|
Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.32.8-VC.zip" -OutFile "SDL2-devel-2.32.8-VC.zip"
|
||||||
Expand-Archive -Path SDL2-devel-2.26.3-VC.zip
|
Expand-Archive -Path SDL2-devel-2.32.8-VC.zip
|
||||||
echo "SDL2_DIR=$(pwd)\SDL2-devel-2.26.3-VC\SDL2-2.26.3\" >>${env:GITHUB_ENV}
|
echo "SDL2_DIR=$(pwd)\SDL2-devel-2.32.8-VC\SDL2-2.32.8\" >>${env:GITHUB_ENV}
|
||||||
|
|
||||||
Invoke-WebRequest -Uri "https://github.com/ocornut/imgui/files/3789205/vulkan-sdk-1.1.121.2.zip" -OutFile vulkan-sdk-1.1.121.2.zip
|
Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL3-devel-3.2.18-VC.zip" -OutFile "SDL3-devel-3.2.18-VC.zip"
|
||||||
Expand-Archive -Path vulkan-sdk-1.1.121.2.zip
|
Expand-Archive -Path SDL3-devel-3.2.18-VC.zip
|
||||||
echo "VULKAN_SDK=$(pwd)\vulkan-sdk-1.1.121.2\" >>${env:GITHUB_ENV}
|
echo "SDL3_DIR=$(pwd)\SDL3-devel-3.2.18-VC\SDL3-3.2.18\" >>${env:GITHUB_ENV}
|
||||||
|
|
||||||
|
# VulkanSDK (retrieve minimal bits of the SDK from git)
|
||||||
|
$vulkanVersion = "1.4.326"
|
||||||
|
# 1. Get the vulkan headers, we will treat that folder as the sdk folder to avoid having to copy headers around
|
||||||
|
Invoke-WebRequest -Uri "https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/v$($vulkanVersion).zip" -OutFile Vulkan-Headers-$($vulkanVersion).zip
|
||||||
|
Expand-Archive -Path Vulkan-Headers-$($vulkanVersion).zip
|
||||||
|
echo "VULKAN_SDK=$(pwd)\Vulkan-Headers-$($vulkanVersion)\Vulkan-Headers-$($vulkanVersion)" >>${env:GITHUB_ENV}
|
||||||
|
# 2. Get and build the vulkan loader source code (UPDATE_DEPS=On will make it automatically fetch its dependencies)
|
||||||
|
Invoke-WebRequest -Uri "https://github.com/KhronosGroup/Vulkan-Loader/archive/refs/tags/v$($vulkanVersion).zip" -OutFile Vulkan-Loader-$($vulkanVersion).zip
|
||||||
|
Expand-Archive -Path Vulkan-Loader-$($vulkanVersion).zip
|
||||||
|
cmake -S Vulkan-Loader-$($vulkanVersion)\Vulkan-Loader-$($vulkanVersion) -B VulkanLoader-build -D UPDATE_DEPS=On
|
||||||
|
cmake --build VulkanLoader-build
|
||||||
|
# 3. Copy the built lib/dll to the expected place
|
||||||
|
mkdir Vulkan-Headers-$($vulkanVersion)\Vulkan-Headers-$($vulkanVersion)\Lib
|
||||||
|
copy VulkanLoader-build\loader\Debug\vulkan-1.* Vulkan-Headers-$($vulkanVersion)\Vulkan-Headers-$($vulkanVersion)\Lib\
|
||||||
|
|
||||||
- name: Fix Projects
|
- name: Fix Projects
|
||||||
shell: powershell
|
shell: powershell
|
||||||
@@ -102,9 +117,12 @@ jobs:
|
|||||||
cl.exe /D_USRDLL /D_WINDLL /I. example_single_file.cpp /LD /FeImGui.dll /link
|
cl.exe /D_USRDLL /D_WINDLL /I. example_single_file.cpp /LD /FeImGui.dll /link
|
||||||
cl.exe /DIMGUI_API=__declspec(dllimport) /I. ImGui.lib /Feexample_null.exe examples/example_null/main.cpp
|
cl.exe /DIMGUI_API=__declspec(dllimport) /I. ImGui.lib /Feexample_null.exe examples/example_null/main.cpp
|
||||||
|
|
||||||
|
# Win64 examples are more frequently compilted than the Win32 examples.
|
||||||
|
# More of the Win32 examples requires 'workflow_run' to reduce waste.
|
||||||
- name: Build Win32 example_glfw_opengl2
|
- name: Build Win32 example_glfw_opengl2
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build Win32 example_glfw_opengl3
|
- name: Build Win32 example_glfw_opengl3
|
||||||
shell: cmd
|
shell: cmd
|
||||||
@@ -140,72 +158,111 @@ jobs:
|
|||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
|
- name: Build Win32 example_sdl3_opengl3
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl3_opengl3/example_sdl3_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
|
||||||
|
- name: Build Win32 example_sdl3_sdlgpu3
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl3_sdlgpu3/example_sdl3_sdlgpu3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
|
- name: Build Win32 example_sdl3_sdlrenderer3
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl3_sdlrenderer3/example_sdl3_sdlrenderer3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
|
- name: Build Win32 example_sdl3_vulkan
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl3_vulkan/example_sdl3_vulkan.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build Win32 example_win32_directx9
|
- name: Build Win32 example_win32_directx9
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build Win32 example_win32_directx10
|
- name: Build Win32 example_win32_directx10
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build Win32 example_win32_directx11
|
- name: Build Win32 example_win32_directx11
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build x64 example_glfw_opengl2
|
# Windows 64-bits
|
||||||
|
- name: Build Win64 example_glfw_opengl2
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build x64 example_glfw_opengl3
|
- name: Build Win64 example_glfw_opengl3
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
- name: Build x64 example_glfw_vulkan
|
- name: Build Win64 example_glfw_vulkan
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
- name: Build x64 example_sdl2_sdlrenderer2
|
- name: Build Win64 example_sdl2_sdlrenderer2
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_sdlrenderer2/example_sdl2_sdlrenderer2.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_sdlrenderer2/example_sdl2_sdlrenderer2.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build x64 example_sdl2_vulkan
|
- name: Build Win64 example_sdl2_vulkan
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_vulkan/example_sdl2_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_vulkan/example_sdl2_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build x64 example_sdl2_opengl2
|
- name: Build Win64 example_sdl2_opengl2
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_opengl2/example_sdl2_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_opengl2/example_sdl2_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build x64 example_sdl2_opengl3
|
- name: Build Win64 example_sdl2_opengl3
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_opengl3/example_sdl2_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_opengl3/example_sdl2_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build x64 example_sdl2_directx11
|
- name: Build Win64 example_sdl2_directx11
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl2_directx11/example_sdl2_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
- name: Build x64 example_win32_directx9
|
- name: Build Win64 example_sdl3_opengl3
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl3_opengl3/example_sdl3_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
|
- name: Build Win64 example_sdl3_sdlgpu3
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl3_sdlgpu3/example_sdl3_sdlgpu3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
|
- name: Build Win64 example_sdl3_sdlrenderer3
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl3_sdlrenderer3/example_sdl3_sdlrenderer3.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
|
- name: Build Win64 example_sdl3_vulkan
|
||||||
|
shell: cmd
|
||||||
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl3_vulkan/example_sdl3_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
|
- name: Build Win64 example_win32_directx9
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build x64 example_win32_directx10
|
- name: Build Win64 example_win32_directx10
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
if: github.event_name == 'workflow_run'
|
||||||
|
|
||||||
- name: Build x64 example_win32_directx11
|
- name: Build Win64 example_win32_directx11
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
if: github.event_name == 'workflow_run'
|
|
||||||
|
|
||||||
- name: Build x64 example_win32_directx12
|
- name: Build Win64 example_win32_directx12
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release'
|
||||||
|
|
||||||
@@ -433,7 +490,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
brew install glfw3 sdl2
|
brew install glfw3 sdl2 sdl3
|
||||||
|
|
||||||
- name: Build example_null (extra warnings, clang 64-bit)
|
- name: Build example_null (extra warnings, clang 64-bit)
|
||||||
run: make -C examples/example_null WITH_EXTRA_WARNINGS=1
|
run: make -C examples/example_null WITH_EXTRA_WARNINGS=1
|
||||||
@@ -491,6 +548,9 @@ jobs:
|
|||||||
- name: Build example_sdl2_opengl3
|
- name: Build example_sdl2_opengl3
|
||||||
run: make -C examples/example_sdl2_opengl3
|
run: make -C examples/example_sdl2_opengl3
|
||||||
|
|
||||||
|
- name: Build example_sdl3_opengl3
|
||||||
|
run: make -C examples/example_sdl3_opengl3
|
||||||
|
|
||||||
- name: Build example_apple_metal
|
- name: Build example_apple_metal
|
||||||
run: xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos
|
run: xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos
|
||||||
|
|
||||||
@@ -498,7 +558,7 @@ jobs:
|
|||||||
run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2
|
run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2
|
||||||
|
|
||||||
iOS:
|
iOS:
|
||||||
runs-on: macos-latest
|
runs-on: macos-14
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/static-analysis.yml
vendored
2
.github/workflows/static-analysis.yml
vendored
@@ -42,5 +42,5 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
cd examples/example_null
|
cd examples/example_null
|
||||||
pvs-studio-analyzer trace -- make WITH_EXTRA_WARNINGS=1
|
pvs-studio-analyzer trace -- make WITH_EXTRA_WARNINGS=1
|
||||||
pvs-studio-analyzer analyze -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log
|
pvs-studio-analyzer analyze --disableLicenseExpirationCheck -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log
|
||||||
plog-converter -a 'GA:1,2;OP:1' -d V1071 -t errorfile -w pvs-studio.log
|
plog-converter -a 'GA:1,2;OP:1' -d V1071 -t errorfile -w pvs-studio.log
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -68,6 +68,7 @@ examples/example_sdl2_opengl2/example_sdl2_opengl2
|
|||||||
examples/example_sdl2_opengl3/example_sdl2_opengl3
|
examples/example_sdl2_opengl3/example_sdl2_opengl3
|
||||||
examples/example_sdl2_sdlrenderer2/example_sdl2_sdlrenderer2
|
examples/example_sdl2_sdlrenderer2/example_sdl2_sdlrenderer2
|
||||||
examples/example_sdl2_vulkan/example_sdl2_vulkan
|
examples/example_sdl2_vulkan/example_sdl2_vulkan
|
||||||
|
examples/example_sdl3_metal/example_sdl3_metal
|
||||||
examples/example_sdl3_opengl3/example_sdl3_opengl3
|
examples/example_sdl3_opengl3/example_sdl3_opengl3
|
||||||
examples/example_sdl3_sdlgpu3/example_sdl3_sdlgpu3
|
examples/example_sdl3_sdlgpu3/example_sdl3_sdlgpu3
|
||||||
examples/example_sdl3_sdlrenderer3/example_sdl3_sdlrenderer3
|
examples/example_sdl3_sdlrenderer3/example_sdl3_sdlrenderer3
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
// 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)
|
||||||
|
// 2025-08-12: Inputs: fixed missing support for ImGuiKey_PrintScreen under Windows, as raw Allegro 5 does not receive it.
|
||||||
|
// 2025-08-12: Added ImGui_ImplAllegro5_SetDisplay() function to change current ALLEGRO_DISPLAY, as Allegro applications often need to do that.
|
||||||
// 2025-07-07: Fixed texture update broken on some platforms where ALLEGRO_LOCK_WRITEONLY needed all texels to be rewritten.
|
// 2025-07-07: Fixed texture update broken on some platforms where ALLEGRO_LOCK_WRITEONLY needed all texels to be rewritten.
|
||||||
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplSDLGPU3_CreateFontsTexture() and ImGui_ImplSDLGPU3_DestroyFontsTexture().
|
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplSDLGPU3_CreateFontsTexture() and ImGui_ImplSDLGPU3_DestroyFontsTexture().
|
||||||
// 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support.
|
// 2025-02-18: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursor support.
|
||||||
@@ -161,10 +163,8 @@ void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImGui_ImplAllegro5_SetupRenderState(draw_data);
|
ImGui_ImplAllegro5_SetupRenderState(draw_data);
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
|
|
||||||
ImVector<ImDrawVertAllegro>& vertices = bd->BufVertices;
|
ImVector<ImDrawVertAllegro>& vertices = bd->BufVertices;
|
||||||
#if ALLEGRO_HAS_DRAW_INDEXED_PRIM
|
#if ALLEGRO_HAS_DRAW_INDEXED_PRIM
|
||||||
vertices.resize(draw_list->VtxBuffer.Size);
|
vertices.resize(draw_list->VtxBuffer.Size);
|
||||||
@@ -270,8 +270,6 @@ void ImGui_ImplAllegro5_UpdateTexture(ImTextureData* tex)
|
|||||||
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
|
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
|
||||||
al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE);
|
al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE);
|
||||||
ALLEGRO_BITMAP* cpu_bitmap = al_create_bitmap(tex->Width, tex->Height);
|
ALLEGRO_BITMAP* cpu_bitmap = al_create_bitmap(tex->Width, tex->Height);
|
||||||
al_set_new_bitmap_flags(new_bitmap_flags);
|
|
||||||
al_set_new_bitmap_format(new_bitmap_format);
|
|
||||||
IM_ASSERT(cpu_bitmap != nullptr && "Backend failed to create texture!");
|
IM_ASSERT(cpu_bitmap != nullptr && "Backend failed to create texture!");
|
||||||
|
|
||||||
// Upload pixels
|
// Upload pixels
|
||||||
@@ -281,10 +279,15 @@ void ImGui_ImplAllegro5_UpdateTexture(ImTextureData* tex)
|
|||||||
al_unlock_bitmap(cpu_bitmap);
|
al_unlock_bitmap(cpu_bitmap);
|
||||||
|
|
||||||
// Convert software texture to hardware texture.
|
// Convert software texture to hardware texture.
|
||||||
|
al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP);
|
||||||
|
al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA);
|
||||||
ALLEGRO_BITMAP* gpu_bitmap = al_clone_bitmap(cpu_bitmap);
|
ALLEGRO_BITMAP* gpu_bitmap = al_clone_bitmap(cpu_bitmap);
|
||||||
al_destroy_bitmap(cpu_bitmap);
|
al_destroy_bitmap(cpu_bitmap);
|
||||||
IM_ASSERT(gpu_bitmap != nullptr && "Backend failed to create texture!");
|
IM_ASSERT(gpu_bitmap != nullptr && "Backend failed to create texture!");
|
||||||
|
|
||||||
|
al_set_new_bitmap_flags(new_bitmap_flags);
|
||||||
|
al_set_new_bitmap_format(new_bitmap_format);
|
||||||
|
|
||||||
// Store identifiers
|
// Store identifiers
|
||||||
tex->SetTexID((ImTextureID)(intptr_t)gpu_bitmap);
|
tex->SetTexID((ImTextureID)(intptr_t)gpu_bitmap);
|
||||||
tex->SetStatus(ImTextureStatus_OK);
|
tex->SetStatus(ImTextureStatus_OK);
|
||||||
@@ -479,20 +482,9 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
|||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures; // We can honor ImGuiPlatformIO::Textures[] requests during render.
|
||||||
|
|
||||||
bd->Display = display;
|
|
||||||
bd->LastCursor = ALLEGRO_SYSTEM_MOUSE_CURSOR_NONE;
|
bd->LastCursor = ALLEGRO_SYSTEM_MOUSE_CURSOR_NONE;
|
||||||
|
|
||||||
// Create custom vertex declaration.
|
ImGui_ImplAllegro5_SetDisplay(display);
|
||||||
// Unfortunately Allegro doesn't support 32-bit packed colors so we have to convert them to 4 floats.
|
|
||||||
// We still use a custom declaration to use 'ALLEGRO_PRIM_TEX_COORD' instead of 'ALLEGRO_PRIM_TEX_COORD_PIXEL' else we can't do a reliable conversion.
|
|
||||||
ALLEGRO_VERTEX_ELEMENT elems[] =
|
|
||||||
{
|
|
||||||
{ ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_2, offsetof(ImDrawVertAllegro, pos) },
|
|
||||||
{ ALLEGRO_PRIM_TEX_COORD, ALLEGRO_PRIM_FLOAT_2, offsetof(ImDrawVertAllegro, uv) },
|
|
||||||
{ ALLEGRO_PRIM_COLOR_ATTR, 0, offsetof(ImDrawVertAllegro, col) },
|
|
||||||
{ 0, 0, 0 }
|
|
||||||
};
|
|
||||||
bd->VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
|
|
||||||
|
|
||||||
#if ALLEGRO_HAS_CLIPBOARD
|
#if ALLEGRO_HAS_CLIPBOARD
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
@@ -521,6 +513,33 @@ void ImGui_ImplAllegro5_Shutdown()
|
|||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplAllegro5_SetDisplay(ALLEGRO_DISPLAY* display)
|
||||||
|
{
|
||||||
|
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
||||||
|
bd->Display = display;
|
||||||
|
|
||||||
|
if (bd->VertexDecl)
|
||||||
|
{
|
||||||
|
al_destroy_vertex_decl(bd->VertexDecl);
|
||||||
|
bd->VertexDecl = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bd->Display && !bd->VertexDecl)
|
||||||
|
{
|
||||||
|
// Create custom vertex declaration.
|
||||||
|
// Unfortunately Allegro doesn't support 32-bits packed colors so we have to convert them to 4 floats.
|
||||||
|
// We still use a custom declaration to use 'ALLEGRO_PRIM_TEX_COORD' instead of 'ALLEGRO_PRIM_TEX_COORD_PIXEL' else we can't do a reliable conversion.
|
||||||
|
ALLEGRO_VERTEX_ELEMENT elems[] =
|
||||||
|
{
|
||||||
|
{ ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_2, offsetof(ImDrawVertAllegro, pos) },
|
||||||
|
{ ALLEGRO_PRIM_TEX_COORD, ALLEGRO_PRIM_FLOAT_2, offsetof(ImDrawVertAllegro, uv) },
|
||||||
|
{ ALLEGRO_PRIM_COLOR_ATTR, 0, offsetof(ImDrawVertAllegro, col) },
|
||||||
|
{ 0, 0, 0 }
|
||||||
|
};
|
||||||
|
bd->VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ev->keyboard.modifiers seems always zero so using that...
|
// ev->keyboard.modifiers seems always zero so using that...
|
||||||
static void ImGui_ImplAllegro5_UpdateKeyModifiers()
|
static void ImGui_ImplAllegro5_UpdateKeyModifiers()
|
||||||
{
|
{
|
||||||
@@ -662,6 +681,11 @@ void ImGui_ImplAllegro5_NewFrame()
|
|||||||
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
|
// Allegro 5 doesn't receive PrintScreen under Windows
|
||||||
|
#ifdef _WIN32
|
||||||
|
io.AddKeyEvent(ImGuiKey_PrintScreen, (::GetAsyncKeyState(VK_SNAPSHOT) & 0x8000) != 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Setup mouse cursor shape
|
// Setup mouse cursor shape
|
||||||
ImGui_ImplAllegro5_UpdateMouseCursor();
|
ImGui_ImplAllegro5_UpdateMouseCursor();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ IMGUI_IMPL_API void ImGui_ImplAllegro5_Shutdown();
|
|||||||
IMGUI_IMPL_API void ImGui_ImplAllegro5_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplAllegro5_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data);
|
IMGUI_IMPL_API void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* event);
|
IMGUI_IMPL_API bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* event);
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplAllegro5_SetDisplay(ALLEGRO_DISPLAY* display);
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
||||||
IMGUI_IMPL_API bool ImGui_ImplAllegro5_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplAllegro5_CreateDeviceObjects();
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ struct ImGui_ImplDX10_Data
|
|||||||
ID3D10InputLayout* pInputLayout;
|
ID3D10InputLayout* pInputLayout;
|
||||||
ID3D10Buffer* pVertexConstantBuffer;
|
ID3D10Buffer* pVertexConstantBuffer;
|
||||||
ID3D10PixelShader* pPixelShader;
|
ID3D10PixelShader* pPixelShader;
|
||||||
ID3D10SamplerState* pFontSampler;
|
ID3D10SamplerState* pTexSamplerLinear;
|
||||||
ID3D10RasterizerState* pRasterizerState;
|
ID3D10RasterizerState* pRasterizerState;
|
||||||
ID3D10BlendState* pBlendState;
|
ID3D10BlendState* pBlendState;
|
||||||
ID3D10DepthStencilState* pDepthStencilState;
|
ID3D10DepthStencilState* pDepthStencilState;
|
||||||
@@ -146,7 +146,7 @@ static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device*
|
|||||||
device->VSSetShader(bd->pVertexShader);
|
device->VSSetShader(bd->pVertexShader);
|
||||||
device->VSSetConstantBuffers(0, 1, &bd->pVertexConstantBuffer);
|
device->VSSetConstantBuffers(0, 1, &bd->pVertexConstantBuffer);
|
||||||
device->PSSetShader(bd->pPixelShader);
|
device->PSSetShader(bd->pPixelShader);
|
||||||
device->PSSetSamplers(0, 1, &bd->pFontSampler);
|
device->PSSetSamplers(0, 1, &bd->pTexSamplerLinear);
|
||||||
device->GSSetShader(nullptr);
|
device->GSSetShader(nullptr);
|
||||||
|
|
||||||
// Setup render state
|
// Setup render state
|
||||||
@@ -206,9 +206,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImDrawIdx* idx_dst = nullptr;
|
ImDrawIdx* idx_dst = nullptr;
|
||||||
bd->pVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&vtx_dst);
|
bd->pVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&vtx_dst);
|
||||||
bd->pIB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&idx_dst);
|
bd->pIB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&idx_dst);
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -264,7 +263,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
ImGui_ImplDX10_RenderState render_state;
|
ImGui_ImplDX10_RenderState render_state;
|
||||||
render_state.Device = bd->pd3dDevice;
|
render_state.Device = bd->pd3dDevice;
|
||||||
render_state.SamplerDefault = bd->pFontSampler;
|
render_state.SamplerDefault = bd->pTexSamplerLinear;
|
||||||
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
||||||
platform_io.Renderer_RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
@@ -274,9 +273,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
|
|||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale;
|
ImVec2 clip_scale = draw_data->FramebufferScale;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
@@ -571,7 +569,7 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
|||||||
desc.ComparisonFunc = D3D10_COMPARISON_ALWAYS;
|
desc.ComparisonFunc = D3D10_COMPARISON_ALWAYS;
|
||||||
desc.MinLOD = 0.f;
|
desc.MinLOD = 0.f;
|
||||||
desc.MaxLOD = 0.f;
|
desc.MaxLOD = 0.f;
|
||||||
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pFontSampler);
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerLinear);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -587,7 +585,7 @@ void ImGui_ImplDX10_InvalidateDeviceObjects()
|
|||||||
for (ImTextureData* tex : ImGui::GetPlatformIO().Textures)
|
for (ImTextureData* tex : ImGui::GetPlatformIO().Textures)
|
||||||
if (tex->RefCount == 1)
|
if (tex->RefCount == 1)
|
||||||
ImGui_ImplDX10_DestroyTexture(tex);
|
ImGui_ImplDX10_DestroyTexture(tex);
|
||||||
if (bd->pFontSampler) { bd->pFontSampler->Release(); bd->pFontSampler = nullptr; }
|
if (bd->pTexSamplerLinear) { bd->pTexSamplerLinear->Release(); bd->pTexSamplerLinear = nullptr; }
|
||||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||||
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = nullptr; }
|
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = nullptr; }
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ struct ImGui_ImplDX11_Data
|
|||||||
ID3D11InputLayout* pInputLayout;
|
ID3D11InputLayout* pInputLayout;
|
||||||
ID3D11Buffer* pVertexConstantBuffer;
|
ID3D11Buffer* pVertexConstantBuffer;
|
||||||
ID3D11PixelShader* pPixelShader;
|
ID3D11PixelShader* pPixelShader;
|
||||||
ID3D11SamplerState* pFontSampler;
|
ID3D11SamplerState* pTexSamplerLinear;
|
||||||
ID3D11RasterizerState* pRasterizerState;
|
ID3D11RasterizerState* pRasterizerState;
|
||||||
ID3D11BlendState* pBlendState;
|
ID3D11BlendState* pBlendState;
|
||||||
ID3D11DepthStencilState* pDepthStencilState;
|
ID3D11DepthStencilState* pDepthStencilState;
|
||||||
@@ -107,7 +107,7 @@ static void ImGui_ImplDX11_InitMultiViewportSupport();
|
|||||||
static void ImGui_ImplDX11_ShutdownMultiViewportSupport();
|
static void ImGui_ImplDX11_ShutdownMultiViewportSupport();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* device_ctx)
|
static void ImGui_ImplDX11_SetupRenderState(const ImDrawData* draw_data, ID3D11DeviceContext* device_ctx)
|
||||||
{
|
{
|
||||||
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceC
|
|||||||
device_ctx->VSSetShader(bd->pVertexShader, nullptr, 0);
|
device_ctx->VSSetShader(bd->pVertexShader, nullptr, 0);
|
||||||
device_ctx->VSSetConstantBuffers(0, 1, &bd->pVertexConstantBuffer);
|
device_ctx->VSSetConstantBuffers(0, 1, &bd->pVertexConstantBuffer);
|
||||||
device_ctx->PSSetShader(bd->pPixelShader, nullptr, 0);
|
device_ctx->PSSetShader(bd->pPixelShader, nullptr, 0);
|
||||||
device_ctx->PSSetSamplers(0, 1, &bd->pFontSampler);
|
device_ctx->PSSetSamplers(0, 1, &bd->pTexSamplerLinear);
|
||||||
device_ctx->GSSetShader(nullptr, nullptr, 0);
|
device_ctx->GSSetShader(nullptr, nullptr, 0);
|
||||||
device_ctx->HSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
device_ctx->HSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||||
device_ctx->DSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
device_ctx->DSSetShader(nullptr, nullptr, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||||
@@ -216,9 +216,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
return;
|
return;
|
||||||
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
|
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
|
||||||
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
|
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -280,7 +279,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImGui_ImplDX11_RenderState render_state;
|
ImGui_ImplDX11_RenderState render_state;
|
||||||
render_state.Device = bd->pd3dDevice;
|
render_state.Device = bd->pd3dDevice;
|
||||||
render_state.DeviceContext = bd->pd3dDeviceContext;
|
render_state.DeviceContext = bd->pd3dDeviceContext;
|
||||||
render_state.SamplerDefault = bd->pFontSampler;
|
render_state.SamplerDefault = bd->pTexSamplerLinear;
|
||||||
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
render_state.VertexConstantBuffer = bd->pVertexConstantBuffer;
|
||||||
platform_io.Renderer_RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
@@ -290,9 +289,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
|||||||
int global_vtx_offset = 0;
|
int global_vtx_offset = 0;
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale;
|
ImVec2 clip_scale = draw_data->FramebufferScale;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
@@ -588,7 +586,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
desc.MinLOD = 0.f;
|
desc.MinLOD = 0.f;
|
||||||
desc.MaxLOD = 0.f;
|
desc.MaxLOD = 0.f;
|
||||||
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pFontSampler);
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pTexSamplerLinear);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -605,7 +603,7 @@ void ImGui_ImplDX11_InvalidateDeviceObjects()
|
|||||||
if (tex->RefCount == 1)
|
if (tex->RefCount == 1)
|
||||||
ImGui_ImplDX11_DestroyTexture(tex);
|
ImGui_ImplDX11_DestroyTexture(tex);
|
||||||
|
|
||||||
if (bd->pFontSampler) { bd->pFontSampler->Release(); bd->pFontSampler = nullptr; }
|
if (bd->pTexSamplerLinear) { bd->pTexSamplerLinear->Release(); bd->pTexSamplerLinear = nullptr; }
|
||||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||||
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = nullptr; }
|
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = nullptr; }
|
||||||
|
|||||||
@@ -98,7 +98,10 @@ struct ImGui_ImplDX12_Data
|
|||||||
DXGI_FORMAT DSVFormat;
|
DXGI_FORMAT DSVFormat;
|
||||||
ID3D12DescriptorHeap* pd3dSrvDescHeap;
|
ID3D12DescriptorHeap* pd3dSrvDescHeap;
|
||||||
UINT numFramesInFlight;
|
UINT numFramesInFlight;
|
||||||
ImGui_ImplDX12_Texture FontTexture;
|
|
||||||
|
ImGui_ImplDX12_RenderBuffers* pFrameResources;
|
||||||
|
UINT frameIndex;
|
||||||
|
|
||||||
bool LegacySingleDescriptorUsed;
|
bool LegacySingleDescriptorUsed;
|
||||||
|
|
||||||
ImGui_ImplDX12_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplDX12_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
@@ -339,9 +342,8 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
return;
|
return;
|
||||||
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource;
|
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource;
|
||||||
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource;
|
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -372,9 +374,8 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale;
|
ImVec2 clip_scale = draw_data->FramebufferScale;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
@@ -657,26 +658,26 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
param[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
|
param[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
|
||||||
|
|
||||||
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||||
D3D12_STATIC_SAMPLER_DESC staticSampler = {};
|
D3D12_STATIC_SAMPLER_DESC staticSampler[1] = {};
|
||||||
staticSampler.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
staticSampler[0].Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
||||||
staticSampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
staticSampler[0].AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||||
staticSampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
staticSampler[0].AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||||
staticSampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
staticSampler[0].AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||||
staticSampler.MipLODBias = 0.f;
|
staticSampler[0].MipLODBias = 0.f;
|
||||||
staticSampler.MaxAnisotropy = 0;
|
staticSampler[0].MaxAnisotropy = 0;
|
||||||
staticSampler.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
|
staticSampler[0].ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
|
||||||
staticSampler.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK;
|
staticSampler[0].BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK;
|
||||||
staticSampler.MinLOD = 0.f;
|
staticSampler[0].MinLOD = 0.f;
|
||||||
staticSampler.MaxLOD = D3D12_FLOAT32_MAX;
|
staticSampler[0].MaxLOD = D3D12_FLOAT32_MAX;
|
||||||
staticSampler.ShaderRegister = 0;
|
staticSampler[0].ShaderRegister = 0;
|
||||||
staticSampler.RegisterSpace = 0;
|
staticSampler[0].RegisterSpace = 0;
|
||||||
staticSampler.ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
|
staticSampler[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
|
||||||
|
|
||||||
D3D12_ROOT_SIGNATURE_DESC desc = {};
|
D3D12_ROOT_SIGNATURE_DESC desc = {};
|
||||||
desc.NumParameters = _countof(param);
|
desc.NumParameters = _countof(param);
|
||||||
desc.pParameters = param;
|
desc.pParameters = param;
|
||||||
desc.NumStaticSamplers = 1;
|
desc.NumStaticSamplers = 1;
|
||||||
desc.pStaticSamplers = &staticSampler;
|
desc.pStaticSamplers = &staticSampler[0];
|
||||||
desc.Flags =
|
desc.Flags =
|
||||||
D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |
|
D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |
|
||||||
D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS |
|
D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS |
|
||||||
|
|||||||
@@ -236,9 +236,8 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
// FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and
|
// FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and
|
||||||
// 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR
|
// 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR
|
||||||
// 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; }
|
// 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; }
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
const ImDrawVert* vtx_src = draw_list->VtxBuffer.Data;
|
const ImDrawVert* vtx_src = draw_list->VtxBuffer.Data;
|
||||||
for (int i = 0; i < draw_list->VtxBuffer.Size; i++)
|
for (int i = 0; i < draw_list->VtxBuffer.Size; i++)
|
||||||
{
|
{
|
||||||
@@ -268,9 +267,8 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
int global_vtx_offset = 0;
|
int global_vtx_offset = 0;
|
||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
// 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)
|
||||||
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2025-09-15: Content Scales are always reported as 1.0 on Wayland. FramebufferScale are always reported as 1.0 on X11. (#8920, #8921)
|
||||||
|
// 2025-09-10: [Docking] Improve multi-viewport behavior in tiling WMs on X11 via the ImGui_ImplGlfw_SetWindowFloating() function. Note: using GLFW backend on Linux/BSD etc. requires linking with -lX11. (#8884, #8474, #8289)
|
||||||
// 2025-07-08: Made ImGui_ImplGlfw_GetContentScaleForWindow(), ImGui_ImplGlfw_GetContentScaleForMonitor() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733)
|
// 2025-07-08: Made ImGui_ImplGlfw_GetContentScaleForWindow(), ImGui_ImplGlfw_GetContentScaleForMonitor() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733)
|
||||||
// 2025-06-18: Added support for multiple Dear ImGui contexts. (#8676, #8239, #8069)
|
// 2025-06-18: Added support for multiple Dear ImGui contexts. (#8676, #8239, #8069)
|
||||||
// 2025-06-11: Added ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window) and ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor) helper to facilitate making DPI-aware apps.
|
// 2025-06-11: Added ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window) and ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor) helper to facilitate making DPI-aware apps.
|
||||||
@@ -114,20 +116,29 @@
|
|||||||
|
|
||||||
// GLFW
|
// GLFW
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#undef APIENTRY
|
#undef APIENTRY
|
||||||
#ifndef GLFW_EXPOSE_NATIVE_WIN32
|
#ifndef GLFW_EXPOSE_NATIVE_WIN32 // for glfwGetWin32Window()
|
||||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
#endif
|
#endif
|
||||||
#include <GLFW/glfw3native.h> // for glfwGetWin32Window()
|
#include <GLFW/glfw3native.h>
|
||||||
#endif
|
#elif defined(__APPLE__)
|
||||||
#ifdef __APPLE__
|
#ifndef GLFW_EXPOSE_NATIVE_COCOA // for glfwGetCocoaWindow()
|
||||||
#ifndef GLFW_EXPOSE_NATIVE_COCOA
|
|
||||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||||
#endif
|
#endif
|
||||||
#include <GLFW/glfw3native.h> // for glfwGetCocoaWindow()
|
#include <GLFW/glfw3native.h>
|
||||||
|
#elif !defined(__EMSCRIPTEN__)
|
||||||
|
#ifndef GLFW_EXPOSE_NATIVE_X11 // for glfwGetX11Window() on Freedesktop (Linux, BSD, etc.)
|
||||||
|
#define GLFW_EXPOSE_NATIVE_X11
|
||||||
|
#include <X11/Xatom.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef GLFW_EXPOSE_NATIVE_WAYLAND
|
||||||
|
#define GLFW_EXPOSE_NATIVE_WAYLAND
|
||||||
|
#endif
|
||||||
|
#include <GLFW/glfw3native.h>
|
||||||
|
#undef Status // X11 headers are leaking this.
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <unistd.h> // for usleep()
|
#include <unistd.h> // for usleep()
|
||||||
#endif
|
#endif
|
||||||
@@ -172,8 +183,13 @@
|
|||||||
#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()
|
||||||
#define GLFW_HAS_GETPLATFORM (GLFW_VERSION_COMBINED >= 3400) // 3.4+ glfwGetPlatform()
|
#define GLFW_HAS_GETPLATFORM (GLFW_VERSION_COMBINED >= 3400) // 3.4+ glfwGetPlatform()
|
||||||
|
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
||||||
|
#define GLFW_HAS_X11_OR_WAYLAND 1
|
||||||
|
#else
|
||||||
|
#define GLFW_HAS_X11_OR_WAYLAND 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// Map GLFWWindow* to ImGuiContext*.
|
// Map GLFWWindow* to ImGuiContext*.
|
||||||
// - Would be simpler if we could use glfwSetWindowUserPointer()/glfwGetWindowUserPointer(), but this is a single and shared resource.
|
// - Would be simpler if we could use glfwSetWindowUserPointer()/glfwGetWindowUserPointer(), but this is a single and shared resource.
|
||||||
// - Would be simpler if we could use e.g. std::map<> as well. But we don't.
|
// - Would be simpler if we could use e.g. std::map<> as well. But we don't.
|
||||||
// - This is not particularly optimized as we expect size to be small and queries to be rare.
|
// - This is not particularly optimized as we expect size to be small and queries to be rare.
|
||||||
@@ -183,14 +199,14 @@ static void ImGui_ImplGlfw_ContextMap_Add(GLFWwindow* window, ImGuiContext* ctx)
|
|||||||
static void ImGui_ImplGlfw_ContextMap_Remove(GLFWwindow* window) { for (ImGui_ImplGlfw_WindowToContext& entry : g_ContextMap) if (entry.Window == window) { g_ContextMap.erase_unsorted(&entry); return; } }
|
static void ImGui_ImplGlfw_ContextMap_Remove(GLFWwindow* window) { for (ImGui_ImplGlfw_WindowToContext& entry : g_ContextMap) if (entry.Window == window) { g_ContextMap.erase_unsorted(&entry); return; } }
|
||||||
static ImGuiContext* ImGui_ImplGlfw_ContextMap_Get(GLFWwindow* window) { for (ImGui_ImplGlfw_WindowToContext& entry : g_ContextMap) if (entry.Window == window) return entry.Context; return nullptr; }
|
static ImGuiContext* ImGui_ImplGlfw_ContextMap_Get(GLFWwindow* window) { for (ImGui_ImplGlfw_WindowToContext& entry : g_ContextMap) if (entry.Window == window) return entry.Context; return nullptr; }
|
||||||
|
|
||||||
// GLFW data
|
|
||||||
enum GlfwClientApi
|
enum GlfwClientApi
|
||||||
{
|
{
|
||||||
GlfwClientApi_Unknown,
|
|
||||||
GlfwClientApi_OpenGL,
|
GlfwClientApi_OpenGL,
|
||||||
GlfwClientApi_Vulkan,
|
GlfwClientApi_Vulkan,
|
||||||
|
GlfwClientApi_Unknown, // Anything else fits here.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// GLFW data
|
||||||
struct ImGui_ImplGlfw_Data
|
struct ImGui_ImplGlfw_Data
|
||||||
{
|
{
|
||||||
ImGuiContext* Context;
|
ImGuiContext* Context;
|
||||||
@@ -203,6 +219,7 @@ struct ImGui_ImplGlfw_Data
|
|||||||
bool MouseIgnoreButtonUp;
|
bool MouseIgnoreButtonUp;
|
||||||
ImVec2 LastValidMousePos;
|
ImVec2 LastValidMousePos;
|
||||||
GLFWwindow* KeyOwnerWindows[GLFW_KEY_LAST];
|
GLFWwindow* KeyOwnerWindows[GLFW_KEY_LAST];
|
||||||
|
bool IsWayland;
|
||||||
bool InstalledCallbacks;
|
bool InstalledCallbacks;
|
||||||
bool CallbacksChainForAllWindows;
|
bool CallbacksChainForAllWindows;
|
||||||
char BackendPlatformName[32];
|
char BackendPlatformName[32];
|
||||||
@@ -252,6 +269,23 @@ static void ImGui_ImplGlfw_InitMultiViewportSupport();
|
|||||||
static void ImGui_ImplGlfw_ShutdownMultiViewportSupport();
|
static void ImGui_ImplGlfw_ShutdownMultiViewportSupport();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
static bool ImGui_ImplGlfw_IsWayland()
|
||||||
|
{
|
||||||
|
#if !GLFW_HAS_X11_OR_WAYLAND
|
||||||
|
return false;
|
||||||
|
#elif GLFW_HAS_GETPLATFORM
|
||||||
|
return glfwGetPlatform() == GLFW_PLATFORM_WAYLAND;
|
||||||
|
#else
|
||||||
|
const char* version = glfwGetVersionString();
|
||||||
|
if (strstr(version, "Wayland") == NULL) // e.g. Ubuntu 22.04 ships with GLFW 3.3.6 compiled without Wayland
|
||||||
|
return false;
|
||||||
|
#ifdef GLFW_EXPOSE_NATIVE_X11
|
||||||
|
if (glfwGetX11Display() != NULL)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Not static to allow third-party code to use that if they want to (but undocumented)
|
// Not static to allow third-party code to use that if they want to (but undocumented)
|
||||||
ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int keycode, int scancode);
|
ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int keycode, int scancode);
|
||||||
@@ -619,7 +653,7 @@ void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window)
|
|||||||
bd->PrevUserCallbackMonitor = nullptr;
|
bd->PrevUserCallbackMonitor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set to 'true' to enable chaining installed callbacks for all windows (including secondary viewports created by backends or by user.
|
// Set to 'true' to enable chaining installed callbacks for all windows (including secondary viewports created by backends or by user).
|
||||||
// This is 'false' by default meaning we only chain callbacks for the main viewport.
|
// This is 'false' by default meaning we only chain callbacks for the main viewport.
|
||||||
// We cannot set this to 'true' by default because user callbacks code may be not testing the 'window' parameter of their callback.
|
// We cannot set this to 'true' by default because user callbacks code may be not testing the 'window' parameter of their callback.
|
||||||
// If you set this to 'true' your user callback code will need to make sure you are testing the 'window' parameter.
|
// If you set this to 'true' your user callback code will need to make sure you are testing the 'window' parameter.
|
||||||
@@ -669,6 +703,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
bd->Context = ImGui::GetCurrentContext();
|
bd->Context = ImGui::GetCurrentContext();
|
||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
bd->Time = 0.0;
|
bd->Time = 0.0;
|
||||||
|
bd->IsWayland = ImGui_ImplGlfw_IsWayland();
|
||||||
ImGui_ImplGlfw_ContextMap_Add(window, bd->Context);
|
ImGui_ImplGlfw_ContextMap_Add(window, bd->Context);
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
@@ -1004,6 +1039,11 @@ static void ImGui_ImplGlfw_UpdateMonitors()
|
|||||||
// - Some accessibility applications are declaring virtual monitors with a DPI of 0.0f, see #7902. We preserve this value for caller to handle.
|
// - Some accessibility applications are declaring virtual monitors with a DPI of 0.0f, see #7902. We preserve this value for caller to handle.
|
||||||
float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window)
|
float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
|
#if GLFW_HAS_X11_OR_WAYLAND
|
||||||
|
if (ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(window))
|
||||||
|
if (bd->IsWayland)
|
||||||
|
return 1.0f;
|
||||||
|
#endif
|
||||||
#if GLFW_HAS_PER_MONITOR_DPI && !(defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__))
|
#if GLFW_HAS_PER_MONITOR_DPI && !(defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__))
|
||||||
float x_scale, y_scale;
|
float x_scale, y_scale;
|
||||||
glfwGetWindowContentScale(window, &x_scale, &y_scale);
|
glfwGetWindowContentScale(window, &x_scale, &y_scale);
|
||||||
@@ -1016,6 +1056,10 @@ float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window)
|
|||||||
|
|
||||||
float ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor)
|
float ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor)
|
||||||
{
|
{
|
||||||
|
#if GLFW_HAS_X11_OR_WAYLAND
|
||||||
|
if (ImGui_ImplGlfw_IsWayland()) // We can't access our bd->IsWayland cache for a monitor.
|
||||||
|
return 1.0f;
|
||||||
|
#endif
|
||||||
#if GLFW_HAS_PER_MONITOR_DPI && !(defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__))
|
#if GLFW_HAS_PER_MONITOR_DPI && !(defined(__APPLE__) || defined(__EMSCRIPTEN__) || defined(__ANDROID__))
|
||||||
float x_scale, y_scale;
|
float x_scale, y_scale;
|
||||||
glfwGetMonitorContentScale(monitor, &x_scale, &y_scale);
|
glfwGetMonitorContentScale(monitor, &x_scale, &y_scale);
|
||||||
@@ -1032,10 +1076,17 @@ static void ImGui_ImplGlfw_GetWindowSizeAndFramebufferScale(GLFWwindow* window,
|
|||||||
int display_w, display_h;
|
int display_w, display_h;
|
||||||
glfwGetWindowSize(window, &w, &h);
|
glfwGetWindowSize(window, &w, &h);
|
||||||
glfwGetFramebufferSize(window, &display_w, &display_h);
|
glfwGetFramebufferSize(window, &display_w, &display_h);
|
||||||
|
float fb_scale_x = (w > 0) ? (float)display_w / w : 1.0f;
|
||||||
|
float fb_scale_y = (h > 0) ? (float)display_h / h : 1.0f;
|
||||||
|
#if GLFW_HAS_X11_OR_WAYLAND
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(window);
|
||||||
|
if (!bd->IsWayland)
|
||||||
|
fb_scale_x = fb_scale_y = 1.0f;
|
||||||
|
#endif
|
||||||
if (out_size != nullptr)
|
if (out_size != nullptr)
|
||||||
*out_size = ImVec2((float)w, (float)h);
|
*out_size = ImVec2((float)w, (float)h);
|
||||||
if (out_framebuffer_scale != nullptr)
|
if (out_framebuffer_scale != nullptr)
|
||||||
*out_framebuffer_scale = (w > 0 && h > 0) ? ImVec2((float)display_w / (float)w, (float)display_h / (float)h) : ImVec2(1.0f, 1.0f);
|
*out_framebuffer_scale = ImVec2(fb_scale_x, fb_scale_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_NewFrame()
|
void ImGui_ImplGlfw_NewFrame()
|
||||||
@@ -1190,6 +1241,30 @@ static void ImGui_ImplGlfw_WindowSizeCallback(GLFWwindow* window, int, int)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(__APPLE__) && !defined(_WIN32) && !defined(__EMSCRIPTEN__) && GLFW_HAS_GETPLATFORM
|
||||||
|
#define IMGUI_GLFW_HAS_SETWINDOWFLOATING
|
||||||
|
static void ImGui_ImplGlfw_SetWindowFloating(GLFWwindow* window)
|
||||||
|
{
|
||||||
|
#ifdef GLFW_EXPOSE_NATIVE_X11
|
||||||
|
if (glfwGetPlatform() == GLFW_PLATFORM_X11)
|
||||||
|
{
|
||||||
|
Display* display = glfwGetX11Display();
|
||||||
|
Window xwindow = glfwGetX11Window(window);
|
||||||
|
Atom wm_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
|
||||||
|
Atom wm_type_dialog = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||||
|
XChangeProperty(display, xwindow, wm_type, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wm_type_dialog, 1);
|
||||||
|
XSetWindowAttributes attrs;
|
||||||
|
attrs.override_redirect = False;
|
||||||
|
XChangeWindowAttributes(display, xwindow, CWOverrideRedirect, &attrs);
|
||||||
|
XFlush(display);
|
||||||
|
}
|
||||||
|
#endif // GLFW_EXPOSE_NATIVE_X11
|
||||||
|
#ifdef GLFW_EXPOSE_NATIVE_WAYLAND
|
||||||
|
// FIXME: Help needed, see #8884, #8474 for discussions about this.
|
||||||
|
#endif // GLFW_EXPOSE_NATIVE_X11
|
||||||
|
}
|
||||||
|
#endif // IMGUI_GLFW_HAS_SETWINDOWFLOATING
|
||||||
|
|
||||||
static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
||||||
{
|
{
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
@@ -1207,7 +1282,7 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
|||||||
glfwWindowHint(GLFW_FOCUSED, false);
|
glfwWindowHint(GLFW_FOCUSED, false);
|
||||||
#if GLFW_HAS_FOCUS_ON_SHOW
|
#if GLFW_HAS_FOCUS_ON_SHOW
|
||||||
glfwWindowHint(GLFW_FOCUS_ON_SHOW, false);
|
glfwWindowHint(GLFW_FOCUS_ON_SHOW, false);
|
||||||
#endif
|
#endif
|
||||||
glfwWindowHint(GLFW_DECORATED, (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? false : true);
|
glfwWindowHint(GLFW_DECORATED, (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? false : true);
|
||||||
#if GLFW_HAS_WINDOW_TOPMOST
|
#if GLFW_HAS_WINDOW_TOPMOST
|
||||||
glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false);
|
glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false);
|
||||||
@@ -1217,6 +1292,9 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
|||||||
vd->WindowOwned = true;
|
vd->WindowOwned = true;
|
||||||
ImGui_ImplGlfw_ContextMap_Add(vd->Window, bd->Context);
|
ImGui_ImplGlfw_ContextMap_Add(vd->Window, bd->Context);
|
||||||
viewport->PlatformHandle = (void*)vd->Window;
|
viewport->PlatformHandle = (void*)vd->Window;
|
||||||
|
#ifdef IMGUI_GLFW_HAS_SETWINDOWFLOATING
|
||||||
|
ImGui_ImplGlfw_SetWindowFloating(vd->Window);
|
||||||
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
viewport->PlatformHandleRaw = glfwGetWin32Window(vd->Window);
|
viewport->PlatformHandleRaw = glfwGetWin32Window(vd->Window);
|
||||||
::SetPropA((HWND)viewport->PlatformHandleRaw, "IMGUI_BACKEND_DATA", bd);
|
::SetPropA((HWND)viewport->PlatformHandleRaw, "IMGUI_BACKEND_DATA", bd);
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer>
|
|||||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdListsCount == 0)
|
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdLists.Size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
|
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
|
||||||
@@ -271,10 +271,8 @@ void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id<MTLCommandBuffer>
|
|||||||
// Render command lists
|
// Render command lists
|
||||||
size_t vertexBufferOffset = 0;
|
size_t vertexBufferOffset = 0;
|
||||||
size_t indexBufferOffset = 0;
|
size_t indexBufferOffset = 0;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
|
|
||||||
memcpy((char*)vertexBuffer.buffer.contents + vertexBufferOffset, draw_list->VtxBuffer.Data, (size_t)draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy((char*)vertexBuffer.buffer.contents + vertexBufferOffset, draw_list->VtxBuffer.Data, (size_t)draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy((char*)indexBuffer.buffer.contents + indexBufferOffset, draw_list->IdxBuffer.Data, (size_t)draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy((char*)indexBuffer.buffer.contents + indexBufferOffset, draw_list->IdxBuffer.Data, (size_t)draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,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)
|
||||||
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2025-07-15: OpenGL: Set GL_UNPACK_ALIGNMENT to 1 before updating textures. (#8802)
|
||||||
// 2025-06-11: OpenGL: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplOpenGL2_CreateFontsTexture() and ImGui_ImplOpenGL2_DestroyFontsTexture().
|
// 2025-06-11: OpenGL: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplOpenGL2_CreateFontsTexture() and ImGui_ImplOpenGL2_DestroyFontsTexture().
|
||||||
// 2024-10-07: OpenGL: Changed default texture sampler to Clamp instead of Repeat/Wrap.
|
// 2024-10-07: OpenGL: Changed default texture sampler to Clamp instead of Repeat/Wrap.
|
||||||
// 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)
|
||||||
@@ -218,9 +219,8 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
||||||
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
||||||
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, pos)));
|
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, pos)));
|
||||||
@@ -296,6 +296,7 @@ void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex)
|
|||||||
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP));
|
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP));
|
||||||
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP));
|
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP));
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
||||||
|
GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
|
||||||
GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->Width, tex->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->Width, tex->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
||||||
|
|
||||||
// Store identifiers
|
// Store identifiers
|
||||||
@@ -315,6 +316,7 @@ void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex)
|
|||||||
GLuint gl_tex_id = (GLuint)(intptr_t)tex->TexID;
|
GLuint gl_tex_id = (GLuint)(intptr_t)tex->TexID;
|
||||||
GL_CALL(glBindTexture(GL_TEXTURE_2D, gl_tex_id));
|
GL_CALL(glBindTexture(GL_TEXTURE_2D, gl_tex_id));
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->Width));
|
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->Width));
|
||||||
|
GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
|
||||||
for (ImTextureRect& r : tex->Updates)
|
for (ImTextureRect& r : tex->Updates)
|
||||||
GL_CALL(glTexSubImage2D(GL_TEXTURE_2D, 0, r.x, r.y, r.w, r.h, GL_RGBA, GL_UNSIGNED_BYTE, tex->GetPixelsAt(r.x, r.y)));
|
GL_CALL(glTexSubImage2D(GL_TEXTURE_2D, 0, r.x, r.y, r.w, r.h, GL_RGBA, GL_UNSIGNED_BYTE, tex->GetPixelsAt(r.x, r.y)));
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
// 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)
|
||||||
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2025-07-22: OpenGL: Add and call embedded loader shutdown during ImGui_ImplOpenGL3_Shutdown() to facilitate multiple init/shutdown cycles in same process. (#8792)
|
||||||
|
// 2025-07-15: OpenGL: Set GL_UNPACK_ALIGNMENT to 1 before updating textures (#8802) + restore non-WebGL/ES update path that doesn't require a CPU-side copy.
|
||||||
// 2025-06-11: OpenGL: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplOpenGL3_CreateFontsTexture() and ImGui_ImplOpenGL3_DestroyFontsTexture().
|
// 2025-06-11: OpenGL: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplOpenGL3_CreateFontsTexture() and ImGui_ImplOpenGL3_DestroyFontsTexture().
|
||||||
// 2025-06-04: OpenGL: Made GLES 3.20 contexts not access GL_CONTEXT_PROFILE_MASK nor GL_PRIMITIVE_RESTART. (#8664)
|
// 2025-06-04: OpenGL: Made GLES 3.20 contexts not access GL_CONTEXT_PROFILE_MASK nor GL_PRIMITIVE_RESTART. (#8664)
|
||||||
// 2025-02-18: OpenGL: Lazily reinitialize embedded GL loader for when calling backend from e.g. other DLL boundaries. (#8406)
|
// 2025-02-18: OpenGL: Lazily reinitialize embedded GL loader for when calling backend from e.g. other DLL boundaries. (#8406)
|
||||||
@@ -246,6 +248,7 @@ struct ImGui_ImplOpenGL3_Data
|
|||||||
GLsizeiptr VertexBufferSize;
|
GLsizeiptr VertexBufferSize;
|
||||||
GLsizeiptr IndexBufferSize;
|
GLsizeiptr IndexBufferSize;
|
||||||
bool HasPolygonMode;
|
bool HasPolygonMode;
|
||||||
|
bool HasBindSampler;
|
||||||
bool HasClipOrigin;
|
bool HasClipOrigin;
|
||||||
bool UseBufferSubData;
|
bool UseBufferSubData;
|
||||||
ImVector<char> TempBuffer;
|
ImVector<char> TempBuffer;
|
||||||
@@ -401,6 +404,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
// Detect extensions we support
|
// Detect extensions we support
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
||||||
bd->HasPolygonMode = (!bd->GlProfileIsES2 && !bd->GlProfileIsES3);
|
bd->HasPolygonMode = (!bd->GlProfileIsES2 && !bd->GlProfileIsES3);
|
||||||
|
#endif
|
||||||
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
|
bd->HasBindSampler = (bd->GlVersion >= 330 || bd->GlProfileIsES3);
|
||||||
#endif
|
#endif
|
||||||
bd->HasClipOrigin = (bd->GlVersion >= 450);
|
bd->HasClipOrigin = (bd->GlVersion >= 450);
|
||||||
#ifdef IMGUI_IMPL_OPENGL_HAS_EXTENSIONS
|
#ifdef IMGUI_IMPL_OPENGL_HAS_EXTENSIONS
|
||||||
@@ -431,6 +437,10 @@ void ImGui_ImplOpenGL3_Shutdown()
|
|||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures | ImGuiBackendFlags_RendererHasViewports);
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
|
|
||||||
|
#ifdef IMGUI_IMPL_OPENGL_LOADER_IMGL3W
|
||||||
|
imgl3wShutdown();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplOpenGL3_NewFrame()
|
void ImGui_ImplOpenGL3_NewFrame()
|
||||||
@@ -499,7 +509,7 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
|||||||
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
if (bd->GlVersion >= 330 || bd->GlProfileIsES3)
|
if (bd->HasBindSampler)
|
||||||
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 and GL ES 3.0 may set that otherwise.
|
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 and GL ES 3.0 may set that otherwise.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -547,7 +557,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
|
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
|
||||||
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
|
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
GLuint last_sampler; if (bd->GlVersion >= 330 || bd->GlProfileIsES3) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; }
|
GLuint last_sampler; if (bd->HasBindSampler) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; }
|
||||||
#endif
|
#endif
|
||||||
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
|
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
|
||||||
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
@@ -594,10 +604,8 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
|
|
||||||
// Upload vertex/index buffers
|
// Upload vertex/index buffers
|
||||||
// - OpenGL drivers are in a very sorry state nowadays....
|
// - OpenGL drivers are in a very sorry state nowadays....
|
||||||
// During 2021 we attempted to switch from glBufferData() to orphaning+glBufferSubData() following reports
|
// During 2021 we attempted to switch from glBufferData() to orphaning+glBufferSubData() following reports
|
||||||
@@ -674,7 +682,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (last_program == 0 || glIsProgram(last_program)) glUseProgram(last_program);
|
if (last_program == 0 || glIsProgram(last_program)) glUseProgram(last_program);
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
if (bd->GlVersion >= 330 || bd->GlProfileIsES3)
|
if (bd->HasBindSampler)
|
||||||
glBindSampler(0, last_sampler);
|
glBindSampler(0, last_sampler);
|
||||||
#endif
|
#endif
|
||||||
glActiveTexture(last_active_texture);
|
glActiveTexture(last_active_texture);
|
||||||
@@ -721,6 +729,17 @@ static void ImGui_ImplOpenGL3_DestroyTexture(ImTextureData* tex)
|
|||||||
|
|
||||||
void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
||||||
{
|
{
|
||||||
|
// FIXME: Consider backing up and restoring
|
||||||
|
if (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates)
|
||||||
|
{
|
||||||
|
#ifdef GL_UNPACK_ROW_LENGTH // Not on WebGL/ES
|
||||||
|
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
||||||
|
#endif
|
||||||
|
#ifdef GL_UNPACK_ALIGNMENT
|
||||||
|
GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (tex->Status == ImTextureStatus_WantCreate)
|
if (tex->Status == ImTextureStatus_WantCreate)
|
||||||
{
|
{
|
||||||
// Create and upload new texture to graphics system
|
// Create and upload new texture to graphics system
|
||||||
@@ -740,9 +759,6 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
|||||||
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
|
||||||
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
|
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
|
||||||
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
|
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
|
||||||
#ifdef GL_UNPACK_ROW_LENGTH // Not on WebGL/ES
|
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
|
|
||||||
#endif
|
|
||||||
GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->Width, tex->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->Width, tex->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
||||||
|
|
||||||
// Store identifiers
|
// Store identifiers
|
||||||
@@ -761,7 +777,7 @@ void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex)
|
|||||||
|
|
||||||
GLuint gl_tex_id = (GLuint)(intptr_t)tex->TexID;
|
GLuint gl_tex_id = (GLuint)(intptr_t)tex->TexID;
|
||||||
GL_CALL(glBindTexture(GL_TEXTURE_2D, gl_tex_id));
|
GL_CALL(glBindTexture(GL_TEXTURE_2D, gl_tex_id));
|
||||||
#if 0// GL_UNPACK_ROW_LENGTH // Not on WebGL/ES
|
#if GL_UNPACK_ROW_LENGTH // Not on WebGL/ES
|
||||||
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->Width));
|
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->Width));
|
||||||
for (ImTextureRect& r : tex->Updates)
|
for (ImTextureRect& r : tex->Updates)
|
||||||
GL_CALL(glTexSubImage2D(GL_TEXTURE_2D, 0, r.x, r.y, r.w, r.h, GL_RGBA, GL_UNSIGNED_BYTE, tex->GetPixelsAt(r.x, r.y)));
|
GL_CALL(glTexSubImage2D(GL_TEXTURE_2D, 0, r.x, r.y, r.w, r.h, GL_RGBA, GL_UNSIGNED_BYTE, tex->GetPixelsAt(r.x, r.y)));
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ typedef khronos_uint8_t GLubyte;
|
|||||||
#define GL_SCISSOR_BOX 0x0C10
|
#define GL_SCISSOR_BOX 0x0C10
|
||||||
#define GL_SCISSOR_TEST 0x0C11
|
#define GL_SCISSOR_TEST 0x0C11
|
||||||
#define GL_UNPACK_ROW_LENGTH 0x0CF2
|
#define GL_UNPACK_ROW_LENGTH 0x0CF2
|
||||||
|
#define GL_UNPACK_ALIGNMENT 0x0CF5
|
||||||
#define GL_PACK_ALIGNMENT 0x0D05
|
#define GL_PACK_ALIGNMENT 0x0D05
|
||||||
#define GL_MAX_TEXTURE_SIZE 0x0D33
|
#define GL_MAX_TEXTURE_SIZE 0x0D33
|
||||||
#define GL_TEXTURE_2D 0x0DE1
|
#define GL_TEXTURE_2D 0x0DE1
|
||||||
@@ -179,6 +180,7 @@ typedef khronos_uint8_t GLubyte;
|
|||||||
#define GL_RENDERER 0x1F01
|
#define GL_RENDERER 0x1F01
|
||||||
#define GL_VERSION 0x1F02
|
#define GL_VERSION 0x1F02
|
||||||
#define GL_EXTENSIONS 0x1F03
|
#define GL_EXTENSIONS 0x1F03
|
||||||
|
#define GL_NEAREST 0x2600
|
||||||
#define GL_LINEAR 0x2601
|
#define GL_LINEAR 0x2601
|
||||||
#define GL_TEXTURE_MAG_FILTER 0x2800
|
#define GL_TEXTURE_MAG_FILTER 0x2800
|
||||||
#define GL_TEXTURE_MIN_FILTER 0x2801
|
#define GL_TEXTURE_MIN_FILTER 0x2801
|
||||||
@@ -399,9 +401,15 @@ GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum
|
|||||||
#ifndef GL_VERSION_3_3
|
#ifndef GL_VERSION_3_3
|
||||||
#define GL_VERSION_3_3 1
|
#define GL_VERSION_3_3 1
|
||||||
#define GL_SAMPLER_BINDING 0x8919
|
#define GL_SAMPLER_BINDING 0x8919
|
||||||
|
typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers);
|
||||||
|
typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers);
|
||||||
typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);
|
typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);
|
||||||
|
typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);
|
||||||
#ifdef GL_GLEXT_PROTOTYPES
|
#ifdef GL_GLEXT_PROTOTYPES
|
||||||
|
GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers);
|
||||||
|
GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers);
|
||||||
GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler);
|
GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler);
|
||||||
|
GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param);
|
||||||
#endif
|
#endif
|
||||||
#endif /* GL_VERSION_3_3 */
|
#endif /* GL_VERSION_3_3 */
|
||||||
#ifndef GL_VERSION_4_1
|
#ifndef GL_VERSION_4_1
|
||||||
@@ -476,12 +484,13 @@ typedef GL3WglProc (*GL3WGetProcAddressProc)(const char *proc);
|
|||||||
/* gl3w api */
|
/* gl3w api */
|
||||||
GL3W_API int imgl3wInit(void);
|
GL3W_API int imgl3wInit(void);
|
||||||
GL3W_API int imgl3wInit2(GL3WGetProcAddressProc proc);
|
GL3W_API int imgl3wInit2(GL3WGetProcAddressProc proc);
|
||||||
|
GL3W_API void imgl3wShutdown(void);
|
||||||
GL3W_API int imgl3wIsSupported(int major, int minor);
|
GL3W_API int imgl3wIsSupported(int major, int minor);
|
||||||
GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc);
|
GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc);
|
||||||
|
|
||||||
/* gl3w internal state */
|
/* gl3w internal state */
|
||||||
union ImGL3WProcs {
|
union ImGL3WProcs {
|
||||||
GL3WglProc ptr[60];
|
GL3WglProc ptr[63];
|
||||||
struct {
|
struct {
|
||||||
PFNGLACTIVETEXTUREPROC ActiveTexture;
|
PFNGLACTIVETEXTUREPROC ActiveTexture;
|
||||||
PFNGLATTACHSHADERPROC AttachShader;
|
PFNGLATTACHSHADERPROC AttachShader;
|
||||||
@@ -501,6 +510,7 @@ union ImGL3WProcs {
|
|||||||
PFNGLCREATESHADERPROC CreateShader;
|
PFNGLCREATESHADERPROC CreateShader;
|
||||||
PFNGLDELETEBUFFERSPROC DeleteBuffers;
|
PFNGLDELETEBUFFERSPROC DeleteBuffers;
|
||||||
PFNGLDELETEPROGRAMPROC DeleteProgram;
|
PFNGLDELETEPROGRAMPROC DeleteProgram;
|
||||||
|
PFNGLDELETESAMPLERSPROC DeleteSamplers;
|
||||||
PFNGLDELETESHADERPROC DeleteShader;
|
PFNGLDELETESHADERPROC DeleteShader;
|
||||||
PFNGLDELETETEXTURESPROC DeleteTextures;
|
PFNGLDELETETEXTURESPROC DeleteTextures;
|
||||||
PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays;
|
PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays;
|
||||||
@@ -513,6 +523,7 @@ union ImGL3WProcs {
|
|||||||
PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray;
|
PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray;
|
||||||
PFNGLFLUSHPROC Flush;
|
PFNGLFLUSHPROC Flush;
|
||||||
PFNGLGENBUFFERSPROC GenBuffers;
|
PFNGLGENBUFFERSPROC GenBuffers;
|
||||||
|
PFNGLGENSAMPLERSPROC GenSamplers;
|
||||||
PFNGLGENTEXTURESPROC GenTextures;
|
PFNGLGENTEXTURESPROC GenTextures;
|
||||||
PFNGLGENVERTEXARRAYSPROC GenVertexArrays;
|
PFNGLGENVERTEXARRAYSPROC GenVertexArrays;
|
||||||
PFNGLGETATTRIBLOCATIONPROC GetAttribLocation;
|
PFNGLGETATTRIBLOCATIONPROC GetAttribLocation;
|
||||||
@@ -533,6 +544,7 @@ union ImGL3WProcs {
|
|||||||
PFNGLPIXELSTOREIPROC PixelStorei;
|
PFNGLPIXELSTOREIPROC PixelStorei;
|
||||||
PFNGLPOLYGONMODEPROC PolygonMode;
|
PFNGLPOLYGONMODEPROC PolygonMode;
|
||||||
PFNGLREADPIXELSPROC ReadPixels;
|
PFNGLREADPIXELSPROC ReadPixels;
|
||||||
|
PFNGLSAMPLERPARAMETERIPROC SamplerParameteri;
|
||||||
PFNGLSCISSORPROC Scissor;
|
PFNGLSCISSORPROC Scissor;
|
||||||
PFNGLSHADERSOURCEPROC ShaderSource;
|
PFNGLSHADERSOURCEPROC ShaderSource;
|
||||||
PFNGLTEXIMAGE2DPROC TexImage2D;
|
PFNGLTEXIMAGE2DPROC TexImage2D;
|
||||||
@@ -567,6 +579,7 @@ GL3W_API extern union ImGL3WProcs imgl3wProcs;
|
|||||||
#define glCreateShader imgl3wProcs.gl.CreateShader
|
#define glCreateShader imgl3wProcs.gl.CreateShader
|
||||||
#define glDeleteBuffers imgl3wProcs.gl.DeleteBuffers
|
#define glDeleteBuffers imgl3wProcs.gl.DeleteBuffers
|
||||||
#define glDeleteProgram imgl3wProcs.gl.DeleteProgram
|
#define glDeleteProgram imgl3wProcs.gl.DeleteProgram
|
||||||
|
#define glDeleteSamplers imgl3wProcs.gl.DeleteSamplers
|
||||||
#define glDeleteShader imgl3wProcs.gl.DeleteShader
|
#define glDeleteShader imgl3wProcs.gl.DeleteShader
|
||||||
#define glDeleteTextures imgl3wProcs.gl.DeleteTextures
|
#define glDeleteTextures imgl3wProcs.gl.DeleteTextures
|
||||||
#define glDeleteVertexArrays imgl3wProcs.gl.DeleteVertexArrays
|
#define glDeleteVertexArrays imgl3wProcs.gl.DeleteVertexArrays
|
||||||
@@ -579,6 +592,7 @@ GL3W_API extern union ImGL3WProcs imgl3wProcs;
|
|||||||
#define glEnableVertexAttribArray imgl3wProcs.gl.EnableVertexAttribArray
|
#define glEnableVertexAttribArray imgl3wProcs.gl.EnableVertexAttribArray
|
||||||
#define glFlush imgl3wProcs.gl.Flush
|
#define glFlush imgl3wProcs.gl.Flush
|
||||||
#define glGenBuffers imgl3wProcs.gl.GenBuffers
|
#define glGenBuffers imgl3wProcs.gl.GenBuffers
|
||||||
|
#define glGenSamplers imgl3wProcs.gl.GenSamplers
|
||||||
#define glGenTextures imgl3wProcs.gl.GenTextures
|
#define glGenTextures imgl3wProcs.gl.GenTextures
|
||||||
#define glGenVertexArrays imgl3wProcs.gl.GenVertexArrays
|
#define glGenVertexArrays imgl3wProcs.gl.GenVertexArrays
|
||||||
#define glGetAttribLocation imgl3wProcs.gl.GetAttribLocation
|
#define glGetAttribLocation imgl3wProcs.gl.GetAttribLocation
|
||||||
@@ -599,6 +613,7 @@ GL3W_API extern union ImGL3WProcs imgl3wProcs;
|
|||||||
#define glPixelStorei imgl3wProcs.gl.PixelStorei
|
#define glPixelStorei imgl3wProcs.gl.PixelStorei
|
||||||
#define glPolygonMode imgl3wProcs.gl.PolygonMode
|
#define glPolygonMode imgl3wProcs.gl.PolygonMode
|
||||||
#define glReadPixels imgl3wProcs.gl.ReadPixels
|
#define glReadPixels imgl3wProcs.gl.ReadPixels
|
||||||
|
#define glSamplerParameteri imgl3wProcs.gl.SamplerParameteri
|
||||||
#define glScissor imgl3wProcs.gl.Scissor
|
#define glScissor imgl3wProcs.gl.Scissor
|
||||||
#define glShaderSource imgl3wProcs.gl.ShaderSource
|
#define glShaderSource imgl3wProcs.gl.ShaderSource
|
||||||
#define glTexImage2D imgl3wProcs.gl.TexImage2D
|
#define glTexImage2D imgl3wProcs.gl.TexImage2D
|
||||||
@@ -631,7 +646,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
static HMODULE libgl;
|
static HMODULE libgl = NULL;
|
||||||
typedef PROC(__stdcall* GL3WglGetProcAddr)(LPCSTR);
|
typedef PROC(__stdcall* GL3WglGetProcAddr)(LPCSTR);
|
||||||
static GL3WglGetProcAddr wgl_get_proc_address;
|
static GL3WglGetProcAddr wgl_get_proc_address;
|
||||||
|
|
||||||
@@ -644,7 +659,7 @@ static int open_libgl(void)
|
|||||||
return GL3W_OK;
|
return GL3W_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_libgl(void) { FreeLibrary(libgl); }
|
static void close_libgl(void) { FreeLibrary(libgl); libgl = NULL; }
|
||||||
static GL3WglProc get_proc(const char *proc)
|
static GL3WglProc get_proc(const char *proc)
|
||||||
{
|
{
|
||||||
GL3WglProc res;
|
GL3WglProc res;
|
||||||
@@ -656,7 +671,7 @@ static GL3WglProc get_proc(const char *proc)
|
|||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
static void *libgl;
|
static void *libgl = NULL;
|
||||||
static int open_libgl(void)
|
static int open_libgl(void)
|
||||||
{
|
{
|
||||||
libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL);
|
libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL);
|
||||||
@@ -665,7 +680,7 @@ static int open_libgl(void)
|
|||||||
return GL3W_OK;
|
return GL3W_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_libgl(void) { dlclose(libgl); }
|
static void close_libgl(void) { dlclose(libgl); libgl = NULL; }
|
||||||
|
|
||||||
static GL3WglProc get_proc(const char *proc)
|
static GL3WglProc get_proc(const char *proc)
|
||||||
{
|
{
|
||||||
@@ -833,6 +848,11 @@ int imgl3wInit2(GL3WGetProcAddressProc proc)
|
|||||||
return parse_version();
|
return parse_version();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void imgl3wShutdown(void)
|
||||||
|
{
|
||||||
|
close_libgl();
|
||||||
|
}
|
||||||
|
|
||||||
int imgl3wIsSupported(int major, int minor)
|
int imgl3wIsSupported(int major, int minor)
|
||||||
{
|
{
|
||||||
if (major < 2)
|
if (major < 2)
|
||||||
@@ -863,6 +883,7 @@ static const char *proc_names[] = {
|
|||||||
"glCreateShader",
|
"glCreateShader",
|
||||||
"glDeleteBuffers",
|
"glDeleteBuffers",
|
||||||
"glDeleteProgram",
|
"glDeleteProgram",
|
||||||
|
"glDeleteSamplers",
|
||||||
"glDeleteShader",
|
"glDeleteShader",
|
||||||
"glDeleteTextures",
|
"glDeleteTextures",
|
||||||
"glDeleteVertexArrays",
|
"glDeleteVertexArrays",
|
||||||
@@ -875,6 +896,7 @@ static const char *proc_names[] = {
|
|||||||
"glEnableVertexAttribArray",
|
"glEnableVertexAttribArray",
|
||||||
"glFlush",
|
"glFlush",
|
||||||
"glGenBuffers",
|
"glGenBuffers",
|
||||||
|
"glGenSamplers",
|
||||||
"glGenTextures",
|
"glGenTextures",
|
||||||
"glGenVertexArrays",
|
"glGenVertexArrays",
|
||||||
"glGetAttribLocation",
|
"glGetAttribLocation",
|
||||||
@@ -895,6 +917,7 @@ static const char *proc_names[] = {
|
|||||||
"glPixelStorei",
|
"glPixelStorei",
|
||||||
"glPolygonMode",
|
"glPolygonMode",
|
||||||
"glReadPixels",
|
"glReadPixels",
|
||||||
|
"glSamplerParameteri",
|
||||||
"glScissor",
|
"glScissor",
|
||||||
"glShaderSource",
|
"glShaderSource",
|
||||||
"glTexImage2D",
|
"glTexImage2D",
|
||||||
|
|||||||
@@ -26,6 +26,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)
|
||||||
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2025-09-15: Content Scales are always reported as 1.0 on Wayland. (#8921)
|
||||||
// 2025-07-08: Made ImGui_ImplSDL2_GetContentScaleForWindow(), ImGui_ImplSDL2_GetContentScaleForDisplay() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733)
|
// 2025-07-08: Made ImGui_ImplSDL2_GetContentScaleForWindow(), ImGui_ImplSDL2_GetContentScaleForDisplay() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733)
|
||||||
// 2025-06-11: Added ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window) and ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index) helper to facilitate making DPI-aware apps.
|
// 2025-06-11: Added ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window) and ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index) helper to facilitate making DPI-aware apps.
|
||||||
// 2025-05-15: [Docking] Add Platform_GetWindowFramebufferScale() handler, to allow varying Retina display density on multiple monitors.
|
// 2025-05-15: [Docking] Add Platform_GetWindowFramebufferScale() handler, to allow varying Retina display density on multiple monitors.
|
||||||
@@ -825,6 +826,9 @@ float ImGui_ImplSDL2_GetContentScaleForWindow(SDL_Window* window)
|
|||||||
|
|
||||||
float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index)
|
float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_index)
|
||||||
{
|
{
|
||||||
|
const char* sdl_driver = SDL_GetCurrentVideoDriver();
|
||||||
|
if (sdl_driver && strcmp(sdl_driver, "wayland") == 0)
|
||||||
|
return 1.0f;
|
||||||
#if SDL_HAS_PER_MONITOR_DPI
|
#if SDL_HAS_PER_MONITOR_DPI
|
||||||
#if !defined(__APPLE__) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
|
#if !defined(__APPLE__) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
|
||||||
float dpi = 0.0f;
|
float dpi = 0.0f;
|
||||||
|
|||||||
@@ -24,6 +24,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)
|
||||||
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2025-09-15: Use SDL_GetWindowDisplayScale() on Mac to output DisplayFrameBufferScale. The function is more reliable during resolution changes e.g. going fullscreen. (#8703, #4414)
|
||||||
// 2025-06-27: IME: avoid calling SDL_StartTextInput() again if already active. (#8727)
|
// 2025-06-27: IME: avoid calling SDL_StartTextInput() again if already active. (#8727)
|
||||||
// 2025-05-15: [Docking] Add Platform_GetWindowFramebufferScale() handler, to allow varying Retina display density on multiple monitors.
|
// 2025-05-15: [Docking] Add Platform_GetWindowFramebufferScale() handler, to allow varying Retina display density on multiple monitors.
|
||||||
// 2025-05-06: [Docking] macOS: fixed secondary viewports not appearing on other monitors before of parenting.
|
// 2025-05-06: [Docking] macOS: fixed secondary viewports not appearing on other monitors before of parenting.
|
||||||
@@ -913,15 +914,24 @@ static void ImGui_ImplSDL3_UpdateMonitors()
|
|||||||
static void ImGui_ImplSDL3_GetWindowSizeAndFramebufferScale(SDL_Window* window, ImVec2* out_size, ImVec2* out_framebuffer_scale)
|
static void ImGui_ImplSDL3_GetWindowSizeAndFramebufferScale(SDL_Window* window, ImVec2* out_size, ImVec2* out_framebuffer_scale)
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
int display_w, display_h;
|
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
|
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
|
||||||
w = h = 0;
|
w = h = 0;
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
float fb_scale_x = SDL_GetWindowDisplayScale(window); // Seems more reliable during resolution change (#8703)
|
||||||
|
float fb_scale_y = fb_scale_x;
|
||||||
|
#else
|
||||||
|
int display_w, display_h;
|
||||||
SDL_GetWindowSizeInPixels(window, &display_w, &display_h);
|
SDL_GetWindowSizeInPixels(window, &display_w, &display_h);
|
||||||
|
float fb_scale_x = (w > 0) ? (float)display_w / w : 1.0f;
|
||||||
|
float fb_scale_y = (h > 0) ? (float)display_h / h : 1.0f;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (out_size != nullptr)
|
if (out_size != nullptr)
|
||||||
*out_size = ImVec2((float)w, (float)h);
|
*out_size = ImVec2((float)w, (float)h);
|
||||||
if (out_framebuffer_scale != nullptr)
|
if (out_framebuffer_scale != nullptr)
|
||||||
*out_framebuffer_scale = (w > 0 && h > 0) ? ImVec2((float)display_w / w, (float)display_h / h) : ImVec2(1.0f, 1.0f);
|
*out_framebuffer_scale = ImVec2(fb_scale_x, fb_scale_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL3_NewFrame()
|
void ImGui_ImplSDL3_NewFrame()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// This needs to be used along with the SDL3 Platform Backend
|
// This needs to be used along with the SDL3 Platform Backend
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use simply cast a reference to your SDL_GPUTextureSamplerBinding to ImTextureID.
|
// [X] Renderer: User texture binding. Use 'SDL_GPUTexture*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef! **IMPORTANT** Before 2025/08/08, ImTextureID was a reference to a SDL_GPUTextureSamplerBinding struct.
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
@@ -24,6 +24,9 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2025-08-20: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and ImGui_ImplSDLGPU3_InitInfo::PresentMode to configure how secondary viewports are created.
|
||||||
|
// 2025-08-08: *BREAKING* Changed ImTextureID type from SDL_GPUTextureSamplerBinding* to SDL_GPUTexture*, which is more natural and easier for user to manage. If you need to change the current sampler, you can access the ImGui_ImplSDLGPU3_RenderState struct. (#8866, #8163, #7998, #7988)
|
||||||
|
// 2025-08-08: Expose SamplerDefault and SamplerCurrent in ImGui_ImplSDLGPU3_RenderState. Allow callback to change sampler.
|
||||||
// 2025-06-25: Mapping transfer buffer for texture update use cycle=true. Fixes artifacts e.g. on Metal backend.
|
// 2025-06-25: Mapping transfer buffer for texture update use cycle=true. Fixes artifacts e.g. on Metal backend.
|
||||||
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplSDLGPU3_CreateFontsTexture() and ImGui_ImplSDLGPU3_DestroyFontsTexture().
|
// 2025-06-11: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplSDLGPU3_CreateFontsTexture() and ImGui_ImplSDLGPU3_DestroyFontsTexture().
|
||||||
// 2025-04-28: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
// 2025-04-28: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||||
@@ -38,11 +41,6 @@
|
|||||||
#include "imgui_impl_sdlgpu3_shaders.h"
|
#include "imgui_impl_sdlgpu3_shaders.h"
|
||||||
|
|
||||||
// SDL_GPU Data
|
// SDL_GPU Data
|
||||||
struct ImGui_ImplSDLGPU3_Texture
|
|
||||||
{
|
|
||||||
SDL_GPUTexture* Texture = nullptr;
|
|
||||||
SDL_GPUTextureSamplerBinding TextureSamplerBinding = { nullptr, nullptr };
|
|
||||||
};
|
|
||||||
|
|
||||||
// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplSDLGPU3_RenderDrawData()
|
// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplSDLGPU3_RenderDrawData()
|
||||||
struct ImGui_ImplSDLGPU3_FrameData
|
struct ImGui_ImplSDLGPU3_FrameData
|
||||||
@@ -63,7 +61,7 @@ struct ImGui_ImplSDLGPU3_Data
|
|||||||
SDL_GPUShader* VertexShader = nullptr;
|
SDL_GPUShader* VertexShader = nullptr;
|
||||||
SDL_GPUShader* FragmentShader = nullptr;
|
SDL_GPUShader* FragmentShader = nullptr;
|
||||||
SDL_GPUGraphicsPipeline* Pipeline = nullptr;
|
SDL_GPUGraphicsPipeline* Pipeline = nullptr;
|
||||||
SDL_GPUSampler* TexSampler = nullptr;
|
SDL_GPUSampler* TexSamplerLinear = nullptr;
|
||||||
SDL_GPUTransferBuffer* TexTransferBuffer = nullptr;
|
SDL_GPUTransferBuffer* TexTransferBuffer = nullptr;
|
||||||
uint32_t TexTransferBufferSize = 0;
|
uint32_t TexTransferBufferSize = 0;
|
||||||
|
|
||||||
@@ -86,12 +84,13 @@ static ImGui_ImplSDLGPU3_Data* ImGui_ImplSDLGPU3_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLGPU3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLGPU3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDLGPU3_SetupRenderState(ImDrawData* draw_data, SDL_GPUGraphicsPipeline* pipeline, SDL_GPUCommandBuffer* command_buffer, SDL_GPURenderPass * render_pass, ImGui_ImplSDLGPU3_FrameData* fd, uint32_t fb_width, uint32_t fb_height)
|
static void ImGui_ImplSDLGPU3_SetupRenderState(ImDrawData* draw_data, ImGui_ImplSDLGPU3_RenderState* render_state, SDL_GPUGraphicsPipeline* pipeline, SDL_GPUCommandBuffer* command_buffer, SDL_GPURenderPass* render_pass, ImGui_ImplSDLGPU3_FrameData* fd, uint32_t fb_width, uint32_t fb_height)
|
||||||
{
|
{
|
||||||
//ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData();
|
ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData();
|
||||||
|
render_state->SamplerCurrent = bd->TexSamplerLinear;
|
||||||
|
|
||||||
// Bind graphics pipeline
|
// Bind graphics pipeline
|
||||||
SDL_BindGPUGraphicsPipeline(render_pass,pipeline);
|
SDL_BindGPUGraphicsPipeline(render_pass, pipeline);
|
||||||
|
|
||||||
// Bind Vertex And Index Buffers
|
// Bind Vertex And Index Buffers
|
||||||
if (draw_data->TotalVtxCount > 0)
|
if (draw_data->TotalVtxCount > 0)
|
||||||
@@ -182,9 +181,8 @@ void ImGui_ImplSDLGPU3_PrepareDrawData(ImDrawData* draw_data, SDL_GPUCommandBuff
|
|||||||
|
|
||||||
ImDrawVert* vtx_dst = (ImDrawVert*)SDL_MapGPUTransferBuffer(v->Device, fd->VertexTransferBuffer, true);
|
ImDrawVert* vtx_dst = (ImDrawVert*)SDL_MapGPUTransferBuffer(v->Device, fd->VertexTransferBuffer, true);
|
||||||
ImDrawIdx* idx_dst = (ImDrawIdx*)SDL_MapGPUTransferBuffer(v->Device, fd->IndexTransferBuffer, true);
|
ImDrawIdx* idx_dst = (ImDrawIdx*)SDL_MapGPUTransferBuffer(v->Device, fd->IndexTransferBuffer, true);
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -230,19 +228,25 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
if (pipeline == nullptr)
|
if (pipeline == nullptr)
|
||||||
pipeline = bd->Pipeline;
|
pipeline = bd->Pipeline;
|
||||||
|
|
||||||
ImGui_ImplSDLGPU3_SetupRenderState(draw_data, pipeline, command_buffer, render_pass, fd, fb_width, fb_height);
|
|
||||||
|
|
||||||
// Will project scissor/clipping rectangles into framebuffer space
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||||
|
|
||||||
|
// Setup render state structure (for callbacks and custom texture bindings)
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
ImGui_ImplSDLGPU3_RenderState render_state;
|
||||||
|
render_state.Device = bd->InitInfo.Device;
|
||||||
|
render_state.SamplerDefault = render_state.SamplerCurrent = bd->TexSamplerLinear;
|
||||||
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
|
ImGui_ImplSDLGPU3_SetupRenderState(draw_data, &render_state, pipeline, command_buffer, render_pass, fd, fb_width, fb_height);
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||||
int global_vtx_offset = 0;
|
int global_vtx_offset = 0;
|
||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
@@ -251,7 +255,7 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
ImGui_ImplSDLGPU3_SetupRenderState(draw_data, pipeline, command_buffer, render_pass, fd, fb_width, fb_height);
|
ImGui_ImplSDLGPU3_SetupRenderState(draw_data, &render_state, pipeline, command_buffer, render_pass, fd, fb_width, fb_height);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
}
|
}
|
||||||
@@ -278,9 +282,14 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
SDL_SetGPUScissor(render_pass,&scissor_rect);
|
SDL_SetGPUScissor(render_pass,&scissor_rect);
|
||||||
|
|
||||||
// Bind DescriptorSet with font or user texture
|
// Bind DescriptorSet with font or user texture
|
||||||
SDL_BindGPUFragmentSamplers(render_pass, 0, (SDL_GPUTextureSamplerBinding*)pcmd->GetTexID(), 1);
|
SDL_GPUTextureSamplerBinding texture_sampler_binding;
|
||||||
|
texture_sampler_binding.texture = (SDL_GPUTexture*)(intptr_t)pcmd->GetTexID();
|
||||||
|
texture_sampler_binding.sampler = render_state.SamplerCurrent;
|
||||||
|
SDL_BindGPUFragmentSamplers(render_pass, 0, &texture_sampler_binding, 1);
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
// **IF YOU GET A CRASH HERE** In 1.92.2 on 2025/08/08 we have changed ImTextureID to store 'SDL_GPUTexture*' instead of storing 'SDL_GPUTextureSamplerBinding'.
|
||||||
|
// Any code loading custom texture using this backend needs to be updated.
|
||||||
SDL_DrawGPUIndexedPrimitives(render_pass, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
SDL_DrawGPUIndexedPrimitives(render_pass, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,18 +308,13 @@ void ImGui_ImplSDLGPU3_RenderDrawData(ImDrawData* draw_data, SDL_GPUCommandBuffe
|
|||||||
static void ImGui_ImplSDLGPU3_DestroyTexture(ImTextureData* tex)
|
static void ImGui_ImplSDLGPU3_DestroyTexture(ImTextureData* tex)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData();
|
ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData();
|
||||||
ImGui_ImplSDLGPU3_Texture* backend_tex = (ImGui_ImplSDLGPU3_Texture*)tex->BackendUserData;
|
SDL_GPUTexture* raw_tex = (SDL_GPUTexture*)(intptr_t)tex->GetTexID();
|
||||||
if (backend_tex == nullptr)
|
if (raw_tex != nullptr)
|
||||||
return;
|
SDL_ReleaseGPUTexture(bd->InitInfo.Device, raw_tex);
|
||||||
SDL_GPUTextureSamplerBinding* binding = (SDL_GPUTextureSamplerBinding*)(intptr_t)tex->BackendUserData;
|
|
||||||
IM_ASSERT(backend_tex->Texture == binding->texture);
|
|
||||||
SDL_ReleaseGPUTexture(bd->InitInfo.Device, backend_tex->Texture);
|
|
||||||
IM_DELETE(backend_tex);
|
|
||||||
|
|
||||||
// Clear identifiers and mark as destroyed (in order to allow e.g. calling InvalidateDeviceObjects while running)
|
// Clear identifiers and mark as destroyed (in order to allow e.g. calling InvalidateDeviceObjects while running)
|
||||||
tex->SetTexID(ImTextureID_Invalid);
|
tex->SetTexID(ImTextureID_Invalid);
|
||||||
tex->SetStatus(ImTextureStatus_Destroyed);
|
tex->SetStatus(ImTextureStatus_Destroyed);
|
||||||
tex->BackendUserData = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLGPU3_UpdateTexture(ImTextureData* tex)
|
void ImGui_ImplSDLGPU3_UpdateTexture(ImTextureData* tex)
|
||||||
@@ -324,7 +328,6 @@ void ImGui_ImplSDLGPU3_UpdateTexture(ImTextureData* tex)
|
|||||||
//IMGUI_DEBUG_LOG("UpdateTexture #%03d: WantCreate %dx%d\n", tex->UniqueID, tex->Width, tex->Height);
|
//IMGUI_DEBUG_LOG("UpdateTexture #%03d: WantCreate %dx%d\n", tex->UniqueID, tex->Width, tex->Height);
|
||||||
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == nullptr);
|
||||||
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
||||||
ImGui_ImplSDLGPU3_Texture* backend_tex = IM_NEW(ImGui_ImplSDLGPU3_Texture)();
|
|
||||||
|
|
||||||
// Create texture
|
// Create texture
|
||||||
SDL_GPUTextureCreateInfo texture_info = {};
|
SDL_GPUTextureCreateInfo texture_info = {};
|
||||||
@@ -337,19 +340,16 @@ void ImGui_ImplSDLGPU3_UpdateTexture(ImTextureData* tex)
|
|||||||
texture_info.num_levels = 1;
|
texture_info.num_levels = 1;
|
||||||
texture_info.sample_count = SDL_GPU_SAMPLECOUNT_1;
|
texture_info.sample_count = SDL_GPU_SAMPLECOUNT_1;
|
||||||
|
|
||||||
backend_tex->Texture = SDL_CreateGPUTexture(v->Device, &texture_info);
|
SDL_GPUTexture* raw_tex = SDL_CreateGPUTexture(v->Device, &texture_info);
|
||||||
backend_tex->TextureSamplerBinding.texture = backend_tex->Texture;
|
IM_ASSERT(raw_tex != nullptr && "Failed to create texture, call SDL_GetError() for more info");
|
||||||
backend_tex->TextureSamplerBinding.sampler = bd->TexSampler;
|
|
||||||
IM_ASSERT(backend_tex->Texture && "Failed to create font texture, call SDL_GetError() for more info");
|
|
||||||
|
|
||||||
// Store identifiers
|
// Store identifiers
|
||||||
tex->SetTexID((ImTextureID)(intptr_t)&backend_tex->TextureSamplerBinding);
|
tex->SetTexID((ImTextureID)(intptr_t)raw_tex);
|
||||||
tex->BackendUserData = backend_tex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates)
|
if (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLGPU3_Texture* backend_tex = (ImGui_ImplSDLGPU3_Texture*)tex->BackendUserData;
|
SDL_GPUTexture* raw_tex = (SDL_GPUTexture*)(intptr_t)tex->GetTexID();
|
||||||
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
IM_ASSERT(tex->Format == ImTextureFormat_RGBA32);
|
||||||
|
|
||||||
// Update full texture or selected blocks. We only ever write to textures regions which have never been used before!
|
// Update full texture or selected blocks. We only ever write to textures regions which have never been used before!
|
||||||
@@ -371,7 +371,7 @@ void ImGui_ImplSDLGPU3_UpdateTexture(ImTextureData* tex)
|
|||||||
transferbuffer_info.size = upload_size + 1024;
|
transferbuffer_info.size = upload_size + 1024;
|
||||||
bd->TexTransferBufferSize = upload_size + 1024;
|
bd->TexTransferBufferSize = upload_size + 1024;
|
||||||
bd->TexTransferBuffer = SDL_CreateGPUTransferBuffer(v->Device, &transferbuffer_info);
|
bd->TexTransferBuffer = SDL_CreateGPUTransferBuffer(v->Device, &transferbuffer_info);
|
||||||
IM_ASSERT(bd->TexTransferBuffer != nullptr && "Failed to create font transfer buffer, call SDL_GetError() for more information");
|
IM_ASSERT(bd->TexTransferBuffer != nullptr && "Failed to create transfer buffer, call SDL_GetError() for more information");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy to transfer buffer
|
// Copy to transfer buffer
|
||||||
@@ -387,7 +387,7 @@ void ImGui_ImplSDLGPU3_UpdateTexture(ImTextureData* tex)
|
|||||||
transfer_info.transfer_buffer = bd->TexTransferBuffer;
|
transfer_info.transfer_buffer = bd->TexTransferBuffer;
|
||||||
|
|
||||||
SDL_GPUTextureRegion texture_region = {};
|
SDL_GPUTextureRegion texture_region = {};
|
||||||
texture_region.texture = backend_tex->Texture;
|
texture_region.texture = raw_tex;
|
||||||
texture_region.x = (Uint32)upload_x;
|
texture_region.x = (Uint32)upload_x;
|
||||||
texture_region.y = (Uint32)upload_y;
|
texture_region.y = (Uint32)upload_y;
|
||||||
texture_region.w = (Uint32)upload_w;
|
texture_region.w = (Uint32)upload_w;
|
||||||
@@ -560,7 +560,7 @@ void ImGui_ImplSDLGPU3_CreateDeviceObjects()
|
|||||||
|
|
||||||
ImGui_ImplSDLGPU3_DestroyDeviceObjects();
|
ImGui_ImplSDLGPU3_DestroyDeviceObjects();
|
||||||
|
|
||||||
if (bd->TexSampler == nullptr)
|
if (bd->TexSamplerLinear == nullptr)
|
||||||
{
|
{
|
||||||
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||||
SDL_GPUSamplerCreateInfo sampler_info = {};
|
SDL_GPUSamplerCreateInfo sampler_info = {};
|
||||||
@@ -577,8 +577,8 @@ void ImGui_ImplSDLGPU3_CreateDeviceObjects()
|
|||||||
sampler_info.max_anisotropy = 1.0f;
|
sampler_info.max_anisotropy = 1.0f;
|
||||||
sampler_info.enable_compare = false;
|
sampler_info.enable_compare = false;
|
||||||
|
|
||||||
bd->TexSampler = SDL_CreateGPUSampler(v->Device, &sampler_info);
|
bd->TexSamplerLinear = SDL_CreateGPUSampler(v->Device, &sampler_info);
|
||||||
IM_ASSERT(bd->TexSampler != nullptr && "Failed to create font sampler, call SDL_GetError() for more information");
|
IM_ASSERT(bd->TexSamplerLinear != nullptr && "Failed to create sampler, call SDL_GetError() for more information");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplSDLGPU3_CreateGraphicsPipeline();
|
ImGui_ImplSDLGPU3_CreateGraphicsPipeline();
|
||||||
@@ -613,7 +613,7 @@ void ImGui_ImplSDLGPU3_DestroyDeviceObjects()
|
|||||||
if (bd->TexTransferBuffer) { SDL_ReleaseGPUTransferBuffer(v->Device, bd->TexTransferBuffer); bd->TexTransferBuffer = nullptr; }
|
if (bd->TexTransferBuffer) { SDL_ReleaseGPUTransferBuffer(v->Device, bd->TexTransferBuffer); bd->TexTransferBuffer = nullptr; }
|
||||||
if (bd->VertexShader) { SDL_ReleaseGPUShader(v->Device, bd->VertexShader); bd->VertexShader = nullptr; }
|
if (bd->VertexShader) { SDL_ReleaseGPUShader(v->Device, bd->VertexShader); bd->VertexShader = nullptr; }
|
||||||
if (bd->FragmentShader) { SDL_ReleaseGPUShader(v->Device, bd->FragmentShader); bd->FragmentShader = nullptr; }
|
if (bd->FragmentShader) { SDL_ReleaseGPUShader(v->Device, bd->FragmentShader); bd->FragmentShader = nullptr; }
|
||||||
if (bd->TexSampler) { SDL_ReleaseGPUSampler(v->Device, bd->TexSampler); bd->TexSampler = nullptr; }
|
if (bd->TexSamplerLinear) { SDL_ReleaseGPUSampler(v->Device, bd->TexSamplerLinear); bd->TexSamplerLinear = nullptr; }
|
||||||
if (bd->Pipeline) { SDL_ReleaseGPUGraphicsPipeline(v->Device, bd->Pipeline); bd->Pipeline = nullptr; }
|
if (bd->Pipeline) { SDL_ReleaseGPUGraphicsPipeline(v->Device, bd->Pipeline); bd->Pipeline = nullptr; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,7 +663,7 @@ void ImGui_ImplSDLGPU3_NewFrame()
|
|||||||
ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData();
|
ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDLGPU3_Init()?");
|
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDLGPU3_Init()?");
|
||||||
|
|
||||||
if (!bd->TexSampler)
|
if (!bd->TexSamplerLinear)
|
||||||
ImGui_ImplSDLGPU3_CreateDeviceObjects();
|
ImGui_ImplSDLGPU3_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,6 +678,7 @@ static void ImGui_ImplSDLGPU3_CreateWindow(ImGuiViewport* viewport)
|
|||||||
ImGui_ImplSDLGPU3_Data* data = ImGui_ImplSDLGPU3_GetBackendData();
|
ImGui_ImplSDLGPU3_Data* data = ImGui_ImplSDLGPU3_GetBackendData();
|
||||||
SDL_Window* window = SDL_GetWindowFromID((SDL_WindowID)(intptr_t)viewport->PlatformHandle);
|
SDL_Window* window = SDL_GetWindowFromID((SDL_WindowID)(intptr_t)viewport->PlatformHandle);
|
||||||
SDL_ClaimWindowForGPUDevice(data->InitInfo.Device, window);
|
SDL_ClaimWindowForGPUDevice(data->InitInfo.Device, window);
|
||||||
|
SDL_SetGPUSwapchainParameters(data->InitInfo.Device, window, data->InitInfo.SwapchainComposition, data->InitInfo.PresentMode);
|
||||||
viewport->RendererUserData = (void*)1;
|
viewport->RendererUserData = (void*)1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// This needs to be used along with the SDL3 Platform Backend
|
// This needs to be used along with the SDL3 Platform Backend
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use simply cast a reference to your SDL_GPUTextureSamplerBinding to ImTextureID.
|
// [X] Renderer: User texture binding. Use 'SDL_GPUTexture*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef! **IMPORTANT** Before 2025/08/08, ImTextureID was a reference to a SDL_GPUTextureSamplerBinding struct.
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
|
||||||
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
|
||||||
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
@@ -28,12 +28,14 @@
|
|||||||
#include <SDL3/SDL_gpu.h>
|
#include <SDL3/SDL_gpu.h>
|
||||||
|
|
||||||
// Initialization data, for ImGui_ImplSDLGPU_Init()
|
// Initialization data, for ImGui_ImplSDLGPU_Init()
|
||||||
// - Remember to set ColorTargetFormat to the correct format. If you're rendering to the swapchain, call SDL_GetGPUSwapchainTextureFormat to query the right value
|
// - Remember to set ColorTargetFormat to the correct format. If you're rendering to the swapchain, call SDL_GetGPUSwapchainTextureFormat() to query the right value
|
||||||
struct ImGui_ImplSDLGPU3_InitInfo
|
struct ImGui_ImplSDLGPU3_InitInfo
|
||||||
{
|
{
|
||||||
SDL_GPUDevice* Device = nullptr;
|
SDL_GPUDevice* Device = nullptr;
|
||||||
SDL_GPUTextureFormat ColorTargetFormat = SDL_GPU_TEXTUREFORMAT_INVALID;
|
SDL_GPUTextureFormat ColorTargetFormat = SDL_GPU_TEXTUREFORMAT_INVALID;
|
||||||
SDL_GPUSampleCount MSAASamples = SDL_GPU_SAMPLECOUNT_1;
|
SDL_GPUSampleCount MSAASamples = SDL_GPU_SAMPLECOUNT_1;
|
||||||
|
SDL_GPUSwapchainComposition SwapchainComposition = SDL_GPU_SWAPCHAINCOMPOSITION_SDR; // Only used in multi-viewports mode.
|
||||||
|
SDL_GPUPresentMode PresentMode = SDL_GPU_PRESENTMODE_VSYNC; // Only used in multi-viewports mode.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
||||||
@@ -50,4 +52,14 @@ IMGUI_IMPL_API void ImGui_ImplSDLGPU3_DestroyDeviceObjects();
|
|||||||
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
|
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLGPU3_UpdateTexture(ImTextureData* tex);
|
IMGUI_IMPL_API void ImGui_ImplSDLGPU3_UpdateTexture(ImTextureData* tex);
|
||||||
|
|
||||||
|
// [BETA] Selected render state data shared with callbacks.
|
||||||
|
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplSDLGPU3_RenderDrawData() call.
|
||||||
|
// (Please open an issue if you feel you need access to more data)
|
||||||
|
struct ImGui_ImplSDLGPU3_RenderState
|
||||||
|
{
|
||||||
|
SDL_GPUDevice* Device;
|
||||||
|
SDL_GPUSampler* SamplerDefault; // Default sampler (bilinear filtering)
|
||||||
|
SDL_GPUSampler* SamplerCurrent; // Current sampler (may be changed by callback)
|
||||||
|
};
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -171,9 +171,8 @@ void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
ImVec2 clip_scale = render_scale;
|
ImVec2 clip_scale = render_scale;
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
||||||
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
||||||
|
|
||||||
|
|||||||
@@ -191,9 +191,8 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
ImVec2 clip_scale = render_scale;
|
ImVec2 clip_scale = render_scale;
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data;
|
||||||
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
const ImDrawIdx* idx_buffer = draw_list->IdxBuffer.Data;
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
// 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)
|
||||||
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2025-09-04: Vulkan: Added ImGui_ImplVulkan_CreateMainPipeline(). (#8110, #8111)
|
||||||
|
// 2025-07-27: Vulkan: Fixed texture update corruption introduced on 2025-06-11. (#8801, #8755, #8840)
|
||||||
// 2025-07-07: Vulkan: Fixed texture synchronization issue introduced on 2025-06-11. (#8772)
|
// 2025-07-07: Vulkan: Fixed texture synchronization issue introduced on 2025-06-11. (#8772)
|
||||||
// 2025-06-27: Vulkan: Fixed validation errors during texture upload/update by aligning upload size to 'nonCoherentAtomSize'. (#8743, #8744)
|
// 2025-06-27: Vulkan: Fixed validation errors during texture upload/update by aligning upload size to 'nonCoherentAtomSize'. (#8743, #8744)
|
||||||
// 2025-06-11: Vulkan: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplVulkan_CreateFontsTexture() and ImGui_ImplVulkan_DestroyFontsTexture().
|
// 2025-06-11: Vulkan: Added support for ImGuiBackendFlags_RendererHasTextures, for dynamic font atlas. Removed ImGui_ImplVulkan_CreateFontsTexture() and ImGui_ImplVulkan_DestroyFontsTexture().
|
||||||
@@ -121,7 +123,7 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
|
|||||||
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);
|
||||||
|
|
||||||
// Vulkan prototypes for use with custom loaders
|
// Vulkan prototypes for use with custom loaders
|
||||||
// (see description of IMGUI_IMPL_VULKAN_NO_PROTOTYPES in imgui_impl_vulkan.h
|
// (see description of IMGUI_IMPL_VULKAN_NO_PROTOTYPES in imgui_impl_vulkan.h)
|
||||||
#if defined(VK_NO_PROTOTYPES) && !defined(VOLK_H_)
|
#if defined(VK_NO_PROTOTYPES) && !defined(VOLK_H_)
|
||||||
#define IMGUI_IMPL_VULKAN_USE_LOADER
|
#define IMGUI_IMPL_VULKAN_USE_LOADER
|
||||||
static bool g_FunctionsLoaded = false;
|
static bool g_FunctionsLoaded = false;
|
||||||
@@ -278,9 +280,10 @@ struct ImGui_ImplVulkan_Data
|
|||||||
VkShaderModule ShaderModuleVert;
|
VkShaderModule ShaderModuleVert;
|
||||||
VkShaderModule ShaderModuleFrag;
|
VkShaderModule ShaderModuleFrag;
|
||||||
VkDescriptorPool DescriptorPool;
|
VkDescriptorPool DescriptorPool;
|
||||||
|
ImVector<VkFormat> PipelineRenderingCreateInfoColorAttachmentFormats; // Deep copy of format array
|
||||||
|
|
||||||
// Texture management
|
// Texture management
|
||||||
VkSampler TexSampler;
|
VkSampler TexSamplerLinear;
|
||||||
VkCommandPool TexCommandPool;
|
VkCommandPool TexCommandPool;
|
||||||
VkCommandBuffer TexCommandBuffer;
|
VkCommandBuffer TexCommandBuffer;
|
||||||
|
|
||||||
@@ -579,9 +582,8 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, index_size, 0, (void**)&idx_dst);
|
err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, index_size, 0, (void**)&idx_dst);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -617,11 +619,11 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||||
|
VkDescriptorSet last_desc_set = VK_NULL_HANDLE;
|
||||||
int global_vtx_offset = 0;
|
int global_vtx_offset = 0;
|
||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
@@ -633,6 +635,7 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
ImGui_ImplVulkan_SetupRenderState(draw_data, pipeline, command_buffer, rb, fb_width, fb_height);
|
ImGui_ImplVulkan_SetupRenderState(draw_data, pipeline, command_buffer, rb, fb_width, fb_height);
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(draw_list, pcmd);
|
pcmd->UserCallback(draw_list, pcmd);
|
||||||
|
last_desc_set = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -658,7 +661,9 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
|
|
||||||
// Bind DescriptorSet with font or user texture
|
// Bind DescriptorSet with font or user texture
|
||||||
VkDescriptorSet desc_set = (VkDescriptorSet)pcmd->GetTexID();
|
VkDescriptorSet desc_set = (VkDescriptorSet)pcmd->GetTexID();
|
||||||
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 0, 1, &desc_set, 0, nullptr);
|
if (desc_set != last_desc_set)
|
||||||
|
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 0, 1, &desc_set, 0, nullptr);
|
||||||
|
last_desc_set = desc_set;
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
||||||
@@ -761,7 +766,7 @@ void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the Descriptor Set
|
// Create the Descriptor Set
|
||||||
backend_tex->DescriptorSet = ImGui_ImplVulkan_AddTexture(bd->TexSampler, backend_tex->ImageView, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
backend_tex->DescriptorSet = ImGui_ImplVulkan_AddTexture(bd->TexSamplerLinear, backend_tex->ImageView, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
||||||
|
|
||||||
// Store identifiers
|
// Store identifiers
|
||||||
tex->SetTexID((ImTextureID)backend_tex->DescriptorSet);
|
tex->SetTexID((ImTextureID)backend_tex->DescriptorSet);
|
||||||
@@ -849,7 +854,7 @@ void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex)
|
|||||||
VkImageMemoryBarrier copy_barrier[1] = {};
|
VkImageMemoryBarrier copy_barrier[1] = {};
|
||||||
copy_barrier[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
copy_barrier[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||||
copy_barrier[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
copy_barrier[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||||
copy_barrier[0].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
copy_barrier[0].oldLayout = (tex->Status == ImTextureStatus_WantCreate) ? VK_IMAGE_LAYOUT_UNDEFINED : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
copy_barrier[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
copy_barrier[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||||
copy_barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
copy_barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||||
copy_barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
copy_barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||||
@@ -932,7 +937,11 @@ static void ImGui_ImplVulkan_CreateShaderModules(VkDevice device, const VkAlloca
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationCallbacks* allocator, VkPipelineCache pipelineCache, VkRenderPass renderPass, VkSampleCountFlagBits MSAASamples, VkPipeline* pipeline, uint32_t subpass)
|
#if !defined(IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING) && !(defined(VK_VERSION_1_3) || defined(VK_KHR_dynamic_rendering))
|
||||||
|
typedef void VkPipelineRenderingCreateInfoKHR;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static VkPipeline ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationCallbacks* allocator, VkPipelineCache pipelineCache, VkRenderPass renderPass, VkSampleCountFlagBits MSAASamples, uint32_t subpass, const VkPipelineRenderingCreateInfoKHR* pipeline_rendering_create_info)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkan_CreateShaderModules(device, allocator);
|
ImGui_ImplVulkan_CreateShaderModules(device, allocator);
|
||||||
@@ -1036,15 +1045,19 @@ static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationC
|
|||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
if (bd->VulkanInitInfo.UseDynamicRendering)
|
if (bd->VulkanInitInfo.UseDynamicRendering)
|
||||||
{
|
{
|
||||||
IM_ASSERT(bd->VulkanInitInfo.PipelineRenderingCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR && "PipelineRenderingCreateInfo sType must be VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR");
|
IM_ASSERT(pipeline_rendering_create_info && "PipelineRenderingCreateInfo must not be nullptr when using dynamic rendering");
|
||||||
IM_ASSERT(bd->VulkanInitInfo.PipelineRenderingCreateInfo.pNext == nullptr && "PipelineRenderingCreateInfo pNext must be nullptr");
|
IM_ASSERT(pipeline_rendering_create_info->sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR && "PipelineRenderingCreateInfo::sType must be VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR");
|
||||||
info.pNext = &bd->VulkanInitInfo.PipelineRenderingCreateInfo;
|
IM_ASSERT(pipeline_rendering_create_info->pNext == nullptr && "PipelineRenderingCreateInfo::pNext must be nullptr");
|
||||||
|
info.pNext = pipeline_rendering_create_info;
|
||||||
info.renderPass = VK_NULL_HANDLE; // Just make sure it's actually nullptr.
|
info.renderPass = VK_NULL_HANDLE; // Just make sure it's actually nullptr.
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
IM_ASSERT(pipeline_rendering_create_info == nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
VkPipeline pipeline;
|
||||||
VkResult err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &info, allocator, pipeline);
|
VkResult err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &info, allocator, &pipeline);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplVulkan_CreateDeviceObjects()
|
bool ImGui_ImplVulkan_CreateDeviceObjects()
|
||||||
@@ -1053,7 +1066,7 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
VkResult err;
|
VkResult err;
|
||||||
|
|
||||||
if (!bd->TexSampler)
|
if (!bd->TexSamplerLinear)
|
||||||
{
|
{
|
||||||
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
// Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling.
|
||||||
VkSamplerCreateInfo info = {};
|
VkSamplerCreateInfo info = {};
|
||||||
@@ -1067,7 +1080,7 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
info.minLod = -1000;
|
info.minLod = -1000;
|
||||||
info.maxLod = 1000;
|
info.maxLod = 1000;
|
||||||
info.maxAnisotropy = 1.0f;
|
info.maxAnisotropy = 1.0f;
|
||||||
err = vkCreateSampler(v->Device, &info, v->Allocator, &bd->TexSampler);
|
err = vkCreateSampler(v->Device, &info, v->Allocator, &bd->TexSamplerLinear);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1118,7 +1131,22 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, v->RenderPass, v->MSAASamples, &bd->Pipeline, v->Subpass);
|
// Create pipeline
|
||||||
|
if (v->RenderPass
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
|| (v->UseDynamicRendering && v->PipelineRenderingCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR)
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_MainPipelineCreateInfo mp_info = {};
|
||||||
|
mp_info.RenderPass = v->RenderPass;
|
||||||
|
mp_info.Subpass = v->Subpass;
|
||||||
|
mp_info.MSAASamples = v->MSAASamples;
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
mp_info.PipelineRenderingCreateInfo = v->PipelineRenderingCreateInfo;
|
||||||
|
#endif
|
||||||
|
ImGui_ImplVulkan_CreateMainPipeline(mp_info);
|
||||||
|
}
|
||||||
|
|
||||||
// Create command pool/buffer for texture upload
|
// Create command pool/buffer for texture upload
|
||||||
if (!bd->TexCommandPool)
|
if (!bd->TexCommandPool)
|
||||||
@@ -1143,6 +1171,39 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplVulkan_CreateMainPipeline(const ImGui_ImplVulkan_MainPipelineCreateInfo& info)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
if (bd->Pipeline)
|
||||||
|
{
|
||||||
|
vkDestroyPipeline(v->Device, bd->Pipeline, v->Allocator);
|
||||||
|
bd->Pipeline = VK_NULL_HANDLE;
|
||||||
|
}
|
||||||
|
v->RenderPass = info.RenderPass;
|
||||||
|
v->MSAASamples = info.MSAASamples;
|
||||||
|
v->Subpass = info.Subpass;
|
||||||
|
|
||||||
|
const VkPipelineRenderingCreateInfoKHR* pipeline_rendering_create_info = nullptr;
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
if (v->UseDynamicRendering)
|
||||||
|
{
|
||||||
|
v->PipelineRenderingCreateInfo = info.PipelineRenderingCreateInfo;
|
||||||
|
pipeline_rendering_create_info = &v->PipelineRenderingCreateInfo;
|
||||||
|
if (v->PipelineRenderingCreateInfo.pColorAttachmentFormats != NULL)
|
||||||
|
{
|
||||||
|
// Deep copy buffer to reduce error-rate for end user (#8282)
|
||||||
|
ImVector<VkFormat> formats;
|
||||||
|
formats.resize((int)v->PipelineRenderingCreateInfo.colorAttachmentCount);
|
||||||
|
memcpy(formats.Data, v->PipelineRenderingCreateInfo.pColorAttachmentFormats, (size_t)formats.size_in_bytes());
|
||||||
|
formats.swap(bd->PipelineRenderingCreateInfoColorAttachmentFormats);
|
||||||
|
v->PipelineRenderingCreateInfo.pColorAttachmentFormats = bd->PipelineRenderingCreateInfoColorAttachmentFormats.Data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
bd->Pipeline = ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, v->RenderPass, v->MSAASamples, v->Subpass, pipeline_rendering_create_info);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplVulkan_DestroyDeviceObjects()
|
void ImGui_ImplVulkan_DestroyDeviceObjects()
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
@@ -1156,7 +1217,7 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
|
|||||||
|
|
||||||
if (bd->TexCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->TexCommandPool, 1, &bd->TexCommandBuffer); bd->TexCommandBuffer = VK_NULL_HANDLE; }
|
if (bd->TexCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->TexCommandPool, 1, &bd->TexCommandBuffer); bd->TexCommandBuffer = VK_NULL_HANDLE; }
|
||||||
if (bd->TexCommandPool) { vkDestroyCommandPool(v->Device, bd->TexCommandPool, v->Allocator); bd->TexCommandPool = VK_NULL_HANDLE; }
|
if (bd->TexCommandPool) { vkDestroyCommandPool(v->Device, bd->TexCommandPool, v->Allocator); bd->TexCommandPool = VK_NULL_HANDLE; }
|
||||||
if (bd->TexSampler) { vkDestroySampler(v->Device, bd->TexSampler, v->Allocator); bd->TexSampler = VK_NULL_HANDLE; }
|
if (bd->TexSamplerLinear) { vkDestroySampler(v->Device, bd->TexSamplerLinear, v->Allocator); bd->TexSamplerLinear = VK_NULL_HANDLE; }
|
||||||
if (bd->ShaderModuleVert) { vkDestroyShaderModule(v->Device, bd->ShaderModuleVert, v->Allocator); bd->ShaderModuleVert = VK_NULL_HANDLE; }
|
if (bd->ShaderModuleVert) { vkDestroyShaderModule(v->Device, bd->ShaderModuleVert, v->Allocator); bd->ShaderModuleVert = VK_NULL_HANDLE; }
|
||||||
if (bd->ShaderModuleFrag) { vkDestroyShaderModule(v->Device, bd->ShaderModuleFrag, v->Allocator); bd->ShaderModuleFrag = VK_NULL_HANDLE; }
|
if (bd->ShaderModuleFrag) { vkDestroyShaderModule(v->Device, bd->ShaderModuleFrag, v->Allocator); bd->ShaderModuleFrag = VK_NULL_HANDLE; }
|
||||||
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; }
|
||||||
@@ -1267,8 +1328,6 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
|||||||
IM_ASSERT(info->DescriptorPoolSize > 0);
|
IM_ASSERT(info->DescriptorPoolSize > 0);
|
||||||
IM_ASSERT(info->MinImageCount >= 2);
|
IM_ASSERT(info->MinImageCount >= 2);
|
||||||
IM_ASSERT(info->ImageCount >= info->MinImageCount);
|
IM_ASSERT(info->ImageCount >= info->MinImageCount);
|
||||||
if (info->UseDynamicRendering == false)
|
|
||||||
IM_ASSERT(info->RenderPass != VK_NULL_HANDLE);
|
|
||||||
|
|
||||||
bd->VulkanInitInfo = *info;
|
bd->VulkanInitInfo = *info;
|
||||||
|
|
||||||
@@ -1276,17 +1335,6 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
|||||||
vkGetPhysicalDeviceProperties(info->PhysicalDevice, &properties);
|
vkGetPhysicalDeviceProperties(info->PhysicalDevice, &properties);
|
||||||
bd->NonCoherentAtomSize = properties.limits.nonCoherentAtomSize;
|
bd->NonCoherentAtomSize = properties.limits.nonCoherentAtomSize;
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
|
||||||
if (v->PipelineRenderingCreateInfo.pColorAttachmentFormats != NULL)
|
|
||||||
{
|
|
||||||
// Deep copy buffer to reduce error-rate for end user (#8282)
|
|
||||||
VkFormat* formats_copy = (VkFormat*)IM_ALLOC(sizeof(VkFormat) * v->PipelineRenderingCreateInfo.colorAttachmentCount);
|
|
||||||
memcpy(formats_copy, v->PipelineRenderingCreateInfo.pColorAttachmentFormats, sizeof(VkFormat) * v->PipelineRenderingCreateInfo.colorAttachmentCount);
|
|
||||||
v->PipelineRenderingCreateInfo.pColorAttachmentFormats = formats_copy;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!ImGui_ImplVulkan_CreateDeviceObjects())
|
if (!ImGui_ImplVulkan_CreateDeviceObjects())
|
||||||
IM_ASSERT(0 && "ImGui_ImplVulkan_CreateDeviceObjects() failed!"); // <- Can't be hit yet.
|
IM_ASSERT(0 && "ImGui_ImplVulkan_CreateDeviceObjects() failed!"); // <- Can't be hit yet.
|
||||||
|
|
||||||
@@ -1307,9 +1355,6 @@ void ImGui_ImplVulkan_Shutdown()
|
|||||||
|
|
||||||
// First destroy objects in all viewports
|
// First destroy objects in all viewports
|
||||||
ImGui_ImplVulkan_DestroyDeviceObjects();
|
ImGui_ImplVulkan_DestroyDeviceObjects();
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
|
||||||
IM_FREE((void*)const_cast<VkFormat*>(bd->VulkanInitInfo.PipelineRenderingCreateInfo.pColorAttachmentFormats));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Manually delete main viewport render data in-case we haven't initialized for viewports
|
// Manually delete main viewport render data in-case we haven't initialized for viewports
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
@@ -1415,7 +1460,7 @@ void ImGui_ImplVulkan_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulk
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Internal / Miscellaneous Vulkan Helpers
|
// Internal / Miscellaneous Vulkan Helpers
|
||||||
// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own app.)
|
// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own engine/app.)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// You probably do NOT need to use or care about those functions.
|
// You probably do NOT need to use or care about those functions.
|
||||||
// Those functions only exist because:
|
// Those functions only exist because:
|
||||||
@@ -1425,7 +1470,7 @@ void ImGui_ImplVulkan_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulk
|
|||||||
// but it is too much code to duplicate everywhere so we exceptionally expose them.
|
// but it is too much code to duplicate everywhere so we exceptionally expose them.
|
||||||
//
|
//
|
||||||
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
|
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
|
||||||
// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work.
|
// You may read this code to learn about Vulkan, but it is recommended you use your own custom tailored code to do equivalent work.
|
||||||
// (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions)
|
// (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -1954,7 +1999,24 @@ static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
|
|||||||
|
|
||||||
// Create pipeline (shared by all secondary viewports)
|
// Create pipeline (shared by all secondary viewports)
|
||||||
if (bd->PipelineForViewports == VK_NULL_HANDLE)
|
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);
|
{
|
||||||
|
VkPipelineRenderingCreateInfoKHR* p_rendering_info = nullptr;
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
VkPipelineRenderingCreateInfoKHR rendering_info = {};
|
||||||
|
if (wd->UseDynamicRendering)
|
||||||
|
{
|
||||||
|
rendering_info.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO;
|
||||||
|
rendering_info.pNext = nullptr;
|
||||||
|
rendering_info.viewMask = 0;
|
||||||
|
rendering_info.colorAttachmentCount = 1;
|
||||||
|
rendering_info.pColorAttachmentFormats = &wd->SurfaceFormat.format;
|
||||||
|
rendering_info.depthAttachmentFormat = VK_FORMAT_UNDEFINED;
|
||||||
|
rendering_info.stencilAttachmentFormat = VK_FORMAT_UNDEFINED;
|
||||||
|
p_rendering_info = &rendering_info;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
bd->PipelineForViewports = ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, VK_NULL_HANDLE, wd->UseDynamicRendering ? VK_NULL_HANDLE : wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, 0, p_rendering_info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplVulkan_DestroyWindow(ImGuiViewport* viewport)
|
static void ImGui_ImplVulkan_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
|||||||
@@ -83,29 +83,27 @@ struct ImGui_ImplVulkan_InitInfo
|
|||||||
uint32_t QueueFamily;
|
uint32_t QueueFamily;
|
||||||
VkQueue Queue;
|
VkQueue Queue;
|
||||||
VkDescriptorPool DescriptorPool; // See requirements in note above; ignored if using DescriptorPoolSize > 0
|
VkDescriptorPool DescriptorPool; // See requirements in note above; ignored if using DescriptorPoolSize > 0
|
||||||
VkRenderPass RenderPass; // Ignored if using dynamic rendering
|
uint32_t DescriptorPoolSize; // Optional: set to create internal descriptor pool automatically instead of using DescriptorPool.
|
||||||
uint32_t MinImageCount; // >= 2
|
uint32_t MinImageCount; // >= 2
|
||||||
uint32_t ImageCount; // >= MinImageCount
|
uint32_t ImageCount; // >= MinImageCount
|
||||||
|
VkPipelineCache PipelineCache; // Optional
|
||||||
|
|
||||||
|
// Pipeline
|
||||||
|
VkRenderPass RenderPass; // Ignored if using dynamic rendering
|
||||||
|
uint32_t Subpass;
|
||||||
VkSampleCountFlagBits MSAASamples; // 0 defaults to VK_SAMPLE_COUNT_1_BIT
|
VkSampleCountFlagBits MSAASamples; // 0 defaults to VK_SAMPLE_COUNT_1_BIT
|
||||||
|
|
||||||
// (Optional)
|
|
||||||
VkPipelineCache PipelineCache;
|
|
||||||
uint32_t Subpass;
|
|
||||||
|
|
||||||
// (Optional) Set to create internal descriptor pool instead of using DescriptorPool
|
|
||||||
uint32_t DescriptorPoolSize;
|
|
||||||
|
|
||||||
// (Optional) Dynamic Rendering
|
// (Optional) Dynamic Rendering
|
||||||
// Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3.
|
// Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3 + setup PipelineRenderingCreateInfo.
|
||||||
bool UseDynamicRendering;
|
bool UseDynamicRendering;
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo;
|
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo; // Optional, valid if .sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// (Optional) Allocation, Debugging
|
// (Optional) Allocation, Debugging
|
||||||
const VkAllocationCallbacks* Allocator;
|
const VkAllocationCallbacks* Allocator;
|
||||||
void (*CheckVkResultFn)(VkResult err);
|
void (*CheckVkResultFn)(VkResult err);
|
||||||
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
|
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
||||||
@@ -115,6 +113,20 @@ IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
|||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
||||||
|
|
||||||
|
// (Advanced) Use e.g. if you need to recreate pipeline without reinitializing the backend (see #8110, #8111)
|
||||||
|
// The main window pipeline will be created by ImGui_ImplVulkan_Init() if possible (== RenderPass xor (UseDynamicRendering && PipelineRenderingCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR))
|
||||||
|
// Else, the pipeline can be created, or re-created, using ImGui_ImplVulkan_CreateMainPipeline() before rendering.
|
||||||
|
struct ImGui_ImplVulkan_MainPipelineCreateInfo
|
||||||
|
{
|
||||||
|
VkRenderPass RenderPass = VK_NULL_HANDLE;
|
||||||
|
uint32_t Subpass = 0;
|
||||||
|
VkSampleCountFlagBits MSAASamples = {};
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo; // Optional, valid if .sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplVulkan_CreateMainPipeline(const ImGui_ImplVulkan_MainPipelineCreateInfo& info); // (render_pass xor (p_dynamic_rendering && p_dynamic_rendering is correct (sType and pNext)))
|
||||||
|
|
||||||
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
|
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_UpdateTexture(ImTextureData* tex);
|
||||||
|
|
||||||
@@ -152,12 +164,12 @@ struct ImGui_ImplVulkan_RenderState
|
|||||||
//
|
//
|
||||||
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain,
|
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain,
|
||||||
// render pass, frame buffers, etc.). You may read this code if you are curious, but
|
// render pass, frame buffers, etc.). You may read this code if you are curious, but
|
||||||
// it is recommended you use you own custom tailored code to do equivalent work.
|
// it is recommended you use your own custom tailored code to do equivalent work.
|
||||||
//
|
//
|
||||||
// We don't provide a strong guarantee that we won't change those functions API.
|
// We don't provide a strong guarantee that we won't change those functions API.
|
||||||
//
|
//
|
||||||
// The ImGui_ImplVulkanH_XXX functions should NOT interact with any of the state used
|
// The ImGui_ImplVulkanH_XXX functions should NOT interact with any of the state used
|
||||||
// by the regular ImGui_ImplVulkan_XXX functions).
|
// by the regular ImGui_ImplVulkan_XXX functions.
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
struct ImGui_ImplVulkanH_Frame;
|
struct ImGui_ImplVulkanH_Frame;
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
// Avoid rendering when minimized
|
// Avoid rendering when minimized
|
||||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||||
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdListsCount == 0)
|
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdLists.Size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
|
// Catch up with texture updates. Most of the times, the list will have 1 element with an OK status, aka nothing to do.
|
||||||
@@ -444,9 +444,8 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
// Upload vertex/index data into a single contiguous GPU buffer
|
// Upload vertex/index data into a single contiguous GPU buffer
|
||||||
ImDrawVert* vtx_dst = (ImDrawVert*)fr->VertexBufferHost;
|
ImDrawVert* vtx_dst = (ImDrawVert*)fr->VertexBufferHost;
|
||||||
ImDrawIdx* idx_dst = (ImDrawIdx*)fr->IndexBufferHost;
|
ImDrawIdx* idx_dst = (ImDrawIdx*)fr->IndexBufferHost;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy(vtx_dst, draw_list->VtxBuffer.Data, draw_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy(idx_dst, draw_list->IdxBuffer.Data, draw_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
vtx_dst += draw_list->VtxBuffer.Size;
|
vtx_dst += draw_list->VtxBuffer.Size;
|
||||||
@@ -473,9 +472,8 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder
|
|||||||
int global_idx_offset = 0;
|
int global_idx_offset = 0;
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale;
|
ImVec2 clip_scale = draw_data->FramebufferScale;
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* draw_list = draw_data->CmdLists[n];
|
|
||||||
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < draw_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
const ImDrawCmd* pcmd = &draw_list->CmdBuffer[cmd_i];
|
||||||
|
|||||||
@@ -245,9 +245,8 @@ void MyImGuiBackend_RenderDrawData(ImDrawData* draw_data)
|
|||||||
// Render command lists
|
// Render command lists
|
||||||
ImVec2 clip_off = draw_data->DisplayPos;
|
ImVec2 clip_off = draw_data->DisplayPos;
|
||||||
ImVec2 clip_scale = draw_data->FramebufferScale;
|
ImVec2 clip_scale = draw_data->FramebufferScale;
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (const ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
|
||||||
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by Dear ImGui
|
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by Dear ImGui
|
||||||
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by Dear ImGui
|
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by Dear ImGui
|
||||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
|
|||||||
@@ -35,6 +35,243 @@ HOW TO UPDATE?
|
|||||||
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
||||||
- Please report any issue!
|
- Please report any issue!
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.92.3 (Released 2025-09-17)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.92.3
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- Fonts: fixed merging a font and specifying a font target in DstFont
|
||||||
|
that's not the last added font (regression in 1.92). (#8912)
|
||||||
|
- Fonts: fixed an assertion failure when a rectangle entry has been reused
|
||||||
|
1024 times (e.g. due to constant change of font size). (#8906) [@cfillion]
|
||||||
|
- Clipper, Tables: added ImGuiListClipperFlags_NoSetTableRowCounters as a way to
|
||||||
|
disable the assumption that 1 clipper item == 1 table row, which breaks when
|
||||||
|
e.g. using clipper with ItemsHeight=1 in order to clip in pixel units. (#8886)
|
||||||
|
- Scrollbar, Style: added configurable style.ScrollbarPadding value and corresponding
|
||||||
|
ImGuiStyleVar_ScrollbarPadding enum, instead of an hard-coded computed default. (#8895)
|
||||||
|
- Nav: fixed Ctrl+Tab window appearing as empty when the sole active and focused
|
||||||
|
window has the ImGuiWindowFlags_NoNavFocus flag. (#8914)
|
||||||
|
- Nav: fixed a crash that could occur when opening a popup following the processing
|
||||||
|
of a global shortcut while no windows were focused.
|
||||||
|
- Bullet: fixed tessellation which looked out of place in very large sizes.
|
||||||
|
- InputText: added ImGuiInputTextFlags_WordWrap flag to word-wrap multi-line buffers.
|
||||||
|
(#3237, #952, #1062, #7363). Current caveats:
|
||||||
|
- This is marked as beta because not being tested enough.
|
||||||
|
Please report any incorrect cursor movement, selection behavior etc. bug to #3237.
|
||||||
|
- Wrapping style is not ideal. Wrapping of long words/sections (e.g. words
|
||||||
|
larger than total available width) may be particularly unpleasing.
|
||||||
|
- Wrapping width needs to always account for the possibility of a vertical scrollbar.
|
||||||
|
- It is currently much slower than regular text fields:
|
||||||
|
- Ballpark estimate of cost on my 2019 desktop PC:
|
||||||
|
For a 100 KB text buffer: +~0.3 ms/+~1.0 ms (Optimized vs Debug builds).
|
||||||
|
- The CPU cost is very roughly proportional to text length, so a 10 KB buffer
|
||||||
|
should cost about ten times less.
|
||||||
|
- InputText, InputInt, InputFloat: fixed an issue where using Escape to revert
|
||||||
|
would not write back the reverted value during the IsItemDeactivatedAfterEdit()
|
||||||
|
frame if the provided input buffer doesn't store temporary edits.
|
||||||
|
(regression in 1.91.7) (#8915, #8273)
|
||||||
|
- InputText: fixed an issue where using Escape with ImGuiInputTextFlags_EscapeClearsAll
|
||||||
|
would not write back the cleared value during the IsItemDeactivatedAfterEdit()
|
||||||
|
frame if the provided input buffer doesn't store temporary edits. (#8915, #8273)
|
||||||
|
- InputText: allow passing an empty string with buf_size==0. (#8907)
|
||||||
|
In theory the buffer size should always account for a zero-terminator, but idioms
|
||||||
|
such as using InputTextMultiline() with ImGuiInputTextFlags_ReadOnly to display
|
||||||
|
a text blob are facilitated by allowing this.
|
||||||
|
- InputText: refactored internals to simplify and optimizing rendering of selection.
|
||||||
|
Very large selection (e.g. 1 MB) now take less overhead.
|
||||||
|
- InputText: revert a change in 1.79 where pressing Down or PageDown on the last line
|
||||||
|
of a multi-line buffer without a trailing carriage return would keep the cursor
|
||||||
|
unmoved. We revert back to move to the end of line in this situation.
|
||||||
|
- InputText: fixed pressing End (without Shift) in a multi-line selection from
|
||||||
|
mistakenly moving cursor based on selection start.
|
||||||
|
- Focus, InputText: fixed an issue where SetKeyboardFocusHere() did not work
|
||||||
|
on InputTextMultiline() fields with ImGuiInputTextFlags_AllowTabInput, since
|
||||||
|
they normally inhibit activation to allow tabbing through multiple items. (#8928)
|
||||||
|
- Selectable: added ImGuiSelectableFlags_SelectOnNav to auto-select an item when
|
||||||
|
moved into, unless Ctrl is held. (automatic when in a BeginMultiSelect() block).
|
||||||
|
- TabBar: fixed an issue were forcefully selecting a tab using internal API would
|
||||||
|
be ignored on first/appearing frame before tabs are submitted (#8929, #6681)
|
||||||
|
- DrawList: fixed CloneOutput() unnecessarily taking a copy of the ImDrawListSharedData
|
||||||
|
pointer, which could to issue when deleting the cloned list. (#8894, #1860)
|
||||||
|
- DrawList: made AddCallback() assert when passing a null callback.
|
||||||
|
- Debug Tools: ID Stack Tool: fixed using fixed-size buffers preventing long identifiers
|
||||||
|
from being displayed in the tool. (#8905, #4631)
|
||||||
|
- Debug Tools: ID Stack Tool: when ### is used, uncontributing prefix before the ###
|
||||||
|
is now skipped. (#8904, #4631)
|
||||||
|
- Debug Tools: ID Stack Tool: added option to hex-encode non-ASCII characters in
|
||||||
|
output path. (#8904, #4631)
|
||||||
|
- Debug Tools: ID Stack Tool: fixed a crash when using PushOverrideID(0) during
|
||||||
|
a query. (#8937, #4631)
|
||||||
|
- Debug Tools: Fixed assertion failure when opening a combo box while using
|
||||||
|
io.ConfigDebugBeginReturnValueOnce/ConfigDebugBeginReturnValueLoop. (#8931) [@harrymander]
|
||||||
|
- Demo: tweaked ShowFontSelector() and ShowStyleSelector() to update selection
|
||||||
|
while navigating and to not close popup automatically.
|
||||||
|
- CI: Updates Windows CI to use a more recent VulkanSDK. (#8925, #8778) [@yaz0r]
|
||||||
|
- Examples: Android: Android+OpenGL3: update Gradle project (#8888, #8878) [@scribam]
|
||||||
|
- Examples: GLFW+OpenGL2, GLFW+Vulkan, GLFW+Metal, Win32+Vulkan: Fixed not applying
|
||||||
|
content scale consistently with other examples. (#8921, #8756)
|
||||||
|
- Backends: GLFW: distinguish X11 vs Wayland to fix various scaling issues.
|
||||||
|
(#8920, #8921) [@TheBrokenRail, @pthom, @ocornut]
|
||||||
|
- window/monitor content scales are always reported as 1.0 on Wayland.
|
||||||
|
- framebuffer scales are always reported as 1.0 on X11.
|
||||||
|
- Backends: SDL2: window/monitor content scales are always reported as 1.0 on Wayland.
|
||||||
|
(#8920, #8921) [@TheBrokenRail, @pthom, @ocornut]
|
||||||
|
- Backends: SDL3: use SDL_GetWindowDisplayScale() on Mac to obtain DisplayFrameBufferScale,
|
||||||
|
fixing incorrect values during resolution changes e.g. going fullscreen.
|
||||||
|
(#8703, #4414) [@jclounge]
|
||||||
|
- Backends: SDL_GPU: Added ImGui_ImplSDLGPU3_InitInfo::SwapchainComposition and
|
||||||
|
PresentMode to configure how secondary viewports are created. Currently only used
|
||||||
|
multi-viewport mode. (#8892) [@PTSVU]
|
||||||
|
- Backends: Vulkan: added ImGui_ImplVulkan_CreateMainPipeline() to recreate pipeline
|
||||||
|
without reinitializing backend. (#8110, #8111) [@SuperRonan]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- DPI: fixed io.ConfigDpiScaleFonts from ever working since 1.92 (the irony
|
||||||
|
being that it is when it started to make sense!). As a reminder, the option
|
||||||
|
automatically copy the _current_ viewport DpiScale to style.FontScaleDpi.
|
||||||
|
This is why we separated the style.FontScaleMain and style.FontScaleDpi scaling
|
||||||
|
factor, as the later is meant to be overwritten. (#8832, #8465)
|
||||||
|
- DPI: Fixed obsoleted ImGuiConfigFlags_DpiEnableScaleFonts/_DpiEnableScaleViewports
|
||||||
|
names from setting the equivalent io.ConfigDpiScaleFonts/io.ConfigDpiScaleViewports
|
||||||
|
flag correctly (regression in 1.92).
|
||||||
|
- Docking, Style: added style.DockingNodeHasCloseButton option to hide the
|
||||||
|
Close Button attached to each docking node. (#8933)
|
||||||
|
- Backends: GLFW: improve multi-viewport behavior in tiling WMs on X11.
|
||||||
|
Note: using GLFW backend on Linux/BSD etc. requires linking with `-lX11`.
|
||||||
|
(#8884, #8474, #8289, #2117) [@Ikos3k, @Madman10K]
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.92.2b (Released 2025-08-13)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.92.2b
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Fixed IsItemHovered() failing on disabled items and items that have no
|
||||||
|
identifier (e.g. Text() calls) when holding mouse button. (#8877, #8883)
|
||||||
|
[Regression in 1.92.2].
|
||||||
|
- Made IsItemHovered() on holding mouse button down on disabled items not
|
||||||
|
leak between items when the window cannot be moved.
|
||||||
|
- Backends: Allegro5: Fixed texture format setup which didn't work on all
|
||||||
|
setups/drivers. (#8770, #8465)
|
||||||
|
- Backends: Allegro5: Added ImGui_ImplAllegro5_SetDisplay() function to
|
||||||
|
change current ALLEGRO_DISPLAY, as Allegro applications often need to do that.
|
||||||
|
- Backends: Allegro5: Fixed missing support for ImGuiKey_PrintScreen
|
||||||
|
under Windows, as raw Allegro 5 does not receive it.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Fixed a bug where closing a viewport using OS facility (e.g. ALT+F4, Close Button)
|
||||||
|
would erroneously close all windows located in the viewport, even ones docked
|
||||||
|
into nested dockspaces. Only top-most windows should be closed. (#8887) [@lailoken]
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.92.2 (Released 2025-08-11)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.92.2
|
||||||
|
|
||||||
|
Breaking Changes:
|
||||||
|
|
||||||
|
- Tabs: Renamed ImGuiTabBarFlags_FittingPolicyResizeDown to ImGuiTabBarFlags_FittingPolicyShrink.
|
||||||
|
Kept inline redirection enum (will obsolete). (#261, #351)
|
||||||
|
- Backends: SDL_GPU3: changed ImTextureID type from SDL_GPUTextureSamplerBinding* to SDL_GPUTexture*,
|
||||||
|
which is more natural and easier for user to manage. If you need to change the current sampler,
|
||||||
|
you can access the ImGui_ImplSDLGPU3_RenderState struct. (#8866, #8163, #7998, #7988)
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- Fixed an old inconsistency between IsItemHovered() and internal hovering check,
|
||||||
|
where IsItemHovered() would return true to mouse was first clicked on the
|
||||||
|
background of a non-moveable window then moved over the item or button.
|
||||||
|
Note that while it is consistent with other logic, there is a possibility
|
||||||
|
that some third-party code may accidentally relied on this. One can always use
|
||||||
|
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem to bypass the active id check.
|
||||||
|
(#8877) [@achabense, @ocornut]
|
||||||
|
- Fonts: fixed an issue when a font using MergeMode has a reference size
|
||||||
|
specified but the target font doesn't. Usually either all fonts should
|
||||||
|
have a reference size (only required when specifying e.g. GlyphOffset),
|
||||||
|
or none should have a reference size.
|
||||||
|
- Fonts: fixed a crash when changing texture format when using a legacy
|
||||||
|
backend. Most commonly would happen when calling GetTexDataAsRGBA32()
|
||||||
|
then immediately calling GetTexDataAsAlpha8(). (#8824)
|
||||||
|
- Windows: fixed an issue where resizable child windows would emit border
|
||||||
|
logic when hidden/non-visible (e.g. when in a docked window that is not
|
||||||
|
selected), impacting code not checking for BeginChild() return value. (#8815)
|
||||||
|
- Textures: Fixed support for `#define ImTextureID_Invalid` to non-zero value:
|
||||||
|
ImFontAtlas() was incorrectly cleared with zeroes. (#8860, #8745) [@cfillion]
|
||||||
|
- Tables: fixed TableGetRowIndex() which never correctly worked when using
|
||||||
|
a clipper (it exists for consistency but is almost never used, as it is
|
||||||
|
often more convenient to use index in caller-code, whereas TableGetRowIndex()
|
||||||
|
includes header rows).
|
||||||
|
- Tables: fixed imgui_internal.h's TableGetHoveredRow() the same way. (#7350, #6588, #6250)
|
||||||
|
- Tabs: added new fitting policy ImGuiTabBarFlags_FittingPolicyMixed
|
||||||
|
and made it the default. This policy shrink tab width down to a given amount,
|
||||||
|
and then beyond that it enable scrolling buttons. (#3421, #8800)
|
||||||
|
- Tabs: added style.TabMinWidthShrink, ImGuiStyleVar_TabMinWidthShrink to
|
||||||
|
control the width to shrink to in ImGuiTabBarFlags_FittingPolicyMixed mode.
|
||||||
|
(#3421, #8800).
|
||||||
|
- Tabs: when scrolling is enabled, track selected tabs when resizing down
|
||||||
|
parent container. This does not prevent to horizontally scroll it out of
|
||||||
|
view during normal operations. (#3421, #8800)
|
||||||
|
- Tabs: added style.TabMinWidthBase, ImGuiStyleVar_TabMinWidthBase to control
|
||||||
|
the base minimum width of a tab (default to 1.0f). This is the size before
|
||||||
|
any potential shrinking is applied.
|
||||||
|
- Tabs: fixed tab bar underline not drawing below scroll buttons, when
|
||||||
|
they are enabled (minor regression from 1.90). (#6820, #4859, #5022, #5239)
|
||||||
|
- Tabs: made scrolling buttons never keyboard/gamepad navigation candidates.
|
||||||
|
- Nav, Tables: fixed navigation within scrolling tables when item boundaries
|
||||||
|
goes beyond columns limits. The fix done in 1.89.6 didn't work correctly
|
||||||
|
on scrolling windows. (#8816, #2221)
|
||||||
|
- Nav: fixed a bug where ImGuiKey_NavGamepadMenu (==ImGuiKey_GamepadFaceLeft)
|
||||||
|
button couldn't toggle between main and menu layers while navigating a Modal
|
||||||
|
window. (#8834)
|
||||||
|
- Error Handling: minor improvements to error handling for TableGetSortSpecs()
|
||||||
|
and TableSetBgColor() calls. (#1651, #8499)
|
||||||
|
- Misc: fixed building with IMGUI_DISABLE_DEBUG_TOOLS only. (#8796)
|
||||||
|
- Misc: fixed building with IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION. (#8794)
|
||||||
|
- Misc: removed more redundant inline static linkage from imgui_internal.h to
|
||||||
|
facilitate using in C++ modules. (#8813, #8682, #8358) [@stripe2933]
|
||||||
|
- Misc: ImVector: skip memcpy in operator= if `Data` isn't initialized in order
|
||||||
|
to play nice with -fsanitize=undefined. (#8874) [@i25e]
|
||||||
|
- CI: Added SDL3 builds to MacOS and Windows. (#8819, #8778) [@scribam]
|
||||||
|
- CI: Updated Windows CI to use a more recent SDL2. (#8819, #8778) [@scribam]
|
||||||
|
- Examples: SDL3+Metal: added SDL3+Metal example. (#8827, #8825) [@shi-yan]
|
||||||
|
- Examples: SDL3+SDL_GPU: use SDL_WaitAndAcquireGPUSwapchainTexture() instead
|
||||||
|
of SDL_AcquireGPUSwapchainTexture(). (#8830) [@itsdanott]
|
||||||
|
- Examples: SDL3+SDL_GPU: use SDL_GPU_PRESENTMODE_VSYNC present mode.
|
||||||
|
- Backends: OpenGL3: add and call embedded loader shutdown in ImGui_ImplOpenGL3_Shutdown()
|
||||||
|
to facilitate multiple init/shutdown cycles in same process. (#8792) [@tim-rex]
|
||||||
|
- Backends: OpenGL2, OpenGL3: set GL_UNPACK_ALIGNMENT to 1 before updating
|
||||||
|
textures. (#8802) [@Daandelange]
|
||||||
|
- Backends: SDL_GPU3: expose current SDL_GPUSampler* in the ImGui_ImplSDLGPU3_RenderState
|
||||||
|
struct. (#8866, #8163, #7998, #7988)
|
||||||
|
- Backends: Vulkan: Fixed texture update corruption introduced in 1.92.0,
|
||||||
|
affecting some drivers/setups. (#8801, #8755, #8840) [@Retro52, @Miolith]
|
||||||
|
- Backends: Vulkan: Avoid calling vkCmdBindDescriptorSets() when texture
|
||||||
|
has not changed. (#8666) [@micb25]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Windows, Viewport: fixed an issue where interrupting a viewport move with
|
||||||
|
e.g. a ClearActiveID() call would leave the dragged viewport with the
|
||||||
|
normally temporary ImGuiViewportFlags_NoInputs flag, preventing further
|
||||||
|
interactions with the viewport. (#5324) (thanks @mdelaharpe)
|
||||||
|
- Viewports: added io.ConfigViewportPlatformFocusSetsImGuiFocus to opt-out
|
||||||
|
of focusing imgui windows When a platform window is focused (e.g. using Alt+Tab,
|
||||||
|
clicking Platform Title Bar). In principle this is better enabled but we
|
||||||
|
provide an opt-out because some Linux window managers tend to eagerly focus
|
||||||
|
windows (on e.g. mouse hover, or even on a simple window pos/size change).
|
||||||
|
(#6299, #6462)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.92.1 (Released 2025-07-09)
|
VERSION 1.92.1 (Released 2025-07-09)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@@ -56,6 +293,8 @@ Changes:
|
|||||||
to pass full range of information into e.g. FreeType's face_index, as higher
|
to pass full range of information into e.g. FreeType's face_index, as higher
|
||||||
bits are used from FreeType 2.6.1. (#8775) [@Valakor]
|
bits are used from FreeType 2.6.1. (#8775) [@Valakor]
|
||||||
(the field has been erroneously reduced from 32-bits to 8-bit in 1.92.0)
|
(the field has been erroneously reduced from 32-bits to 8-bit in 1.92.0)
|
||||||
|
- Fonts, Tables: fixed PushFont() having no effect when called after submitting
|
||||||
|
a hidden column. (#8865)
|
||||||
- Textures: Fixed support for `#define ImTextureID_Invalid` to non-zero value:
|
- Textures: Fixed support for `#define ImTextureID_Invalid` to non-zero value:
|
||||||
ImTextureData() was incorrectly cleared with zeroes. (#8745) [@rachit7645]
|
ImTextureData() was incorrectly cleared with zeroes. (#8745) [@rachit7645]
|
||||||
- Demo: Added "Text -> Font Size" demo section. (#8738) [@Demonese]
|
- Demo: Added "Text -> Font Size" demo section. (#8738) [@Demonese]
|
||||||
@@ -64,13 +303,13 @@ Changes:
|
|||||||
- Debug Tools: added IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS to detect
|
- Debug Tools: added IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS to detect
|
||||||
id conflicts _before_ hovering. This is very slow and should only be used
|
id conflicts _before_ hovering. This is very slow and should only be used
|
||||||
temporarily. (#8651, #7961, #7669)
|
temporarily. (#8651, #7961, #7669)
|
||||||
- Examples: GLFW+OpenGL3, GLFW+WGPU: Emscripten Makefiles uses GLFW port
|
- Examples: GLFW+OpenGL3, GLFW+WGPU: Emscripten Makefiles uses GLFW port
|
||||||
'contrib.glfw3' which offers better HiDPI support. (#8742) [@pthom]
|
'contrib.glfw3' which offers better HiDPI support. (#8742) [@pthom]
|
||||||
- Backends: GLFW, SDL2 made ImGui_ImplGLFW_GetContentScaleXXX() and
|
- Backends: GLFW, SDL2 made ImGui_ImplGLFW_GetContentScaleXXX() and
|
||||||
ImGui_ImplSDL2_GetContentScaleXXXX() helpers return 1.0f on Emscripten
|
ImGui_ImplSDL2_GetContentScaleXXXX() helpers return 1.0f on Emscripten
|
||||||
and Android platforms, matching macOS logic. (#8742, #8733) [@pthom]
|
and Android platforms, matching macOS logic. (#8742, #8733) [@pthom]
|
||||||
- Backends: SDL3: avoid calling SDL_StartTextInput() again if already active.
|
- Backends: SDL3: avoid calling SDL_StartTextInput() again if already active.
|
||||||
(fixes e.g.: an issue on iOS where the keyboard animation will popup every
|
(fixes e.g.: an issue on iOS where the keyboard animation will popup every
|
||||||
time the user types a key + probably other things) (#8727) [@morrazzzz]
|
time the user types a key + probably other things) (#8727) [@morrazzzz]
|
||||||
- Backends: OSX: added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress
|
- Backends: OSX: added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress
|
||||||
mouse cursor support. (#8739) [@cfillion]
|
mouse cursor support. (#8739) [@cfillion]
|
||||||
@@ -166,6 +405,10 @@ Breaking changes:
|
|||||||
- You can use `Metrics/Debugger->Fonts->Font->Input Glyphs Overlap Detection Tool` to
|
- You can use `Metrics/Debugger->Fonts->Font->Input Glyphs Overlap Detection Tool` to
|
||||||
see list of glyphs available in multiple font sources. This can facilitate understanding
|
see list of glyphs available in multiple font sources. This can facilitate understanding
|
||||||
which font input is providing which glyph.
|
which font input is providing which glyph.
|
||||||
|
- Fonts: **IMPORTANT** on Thread Safety:
|
||||||
|
- A few functions such as font->CalcTextSizeA() were by sheer luck (== accidentally)
|
||||||
|
thread-safe even thou we had never provided that guarantee before. They are
|
||||||
|
definitively not thread-safe anymore as new glyphs may be loaded.
|
||||||
|
|
||||||
- Textures:
|
- Textures:
|
||||||
- All API functions taking a 'ImTextureID' parameter are now taking a 'ImTextureRef':
|
- All API functions taking a 'ImTextureID' parameter are now taking a 'ImTextureRef':
|
||||||
@@ -202,7 +445,7 @@ Breaking changes:
|
|||||||
to 4096 but that limit isn't necessary anymore, and Renderer_TextureMaxWidth covers this)
|
to 4096 but that limit isn't necessary anymore, and Renderer_TextureMaxWidth covers this)
|
||||||
However you may set TexMinWidth = TexMaxWidth for the same effect.
|
However you may set TexMinWidth = TexMaxWidth for the same effect.
|
||||||
- Fonts: if you create and manage ImFontAtlas instances yourself (instead of relying on
|
- Fonts: if you create and manage ImFontAtlas instances yourself (instead of relying on
|
||||||
ImGuiContext to create one, you'll need to call ImFontAtlasUpdateNewFrame() yourself.
|
ImGuiContext to create one), you'll need to call ImFontAtlasUpdateNewFrame() yourself.
|
||||||
An assert will trigger if you don't.
|
An assert will trigger if you don't.
|
||||||
- Fonts: obsoleted ImGui::SetWindowFontScale() which is not useful anymore. Prefer using
|
- Fonts: obsoleted ImGui::SetWindowFontScale() which is not useful anymore. Prefer using
|
||||||
PushFont(NULL, style.FontSizeBase * factor) or to manipulate other scaling factors.
|
PushFont(NULL, style.FontSizeBase * factor) or to manipulate other scaling factors.
|
||||||
@@ -553,8 +796,8 @@ Docking+Viewports Branch:
|
|||||||
- Viewports: fixed handling of simultaneous move + resize (e.g. toggling maximized)
|
- Viewports: fixed handling of simultaneous move + resize (e.g. toggling maximized)
|
||||||
when ImGuiConfigFlags_DpiEnableScaleViewports is enabled.
|
when ImGuiConfigFlags_DpiEnableScaleViewports is enabled.
|
||||||
- Backends: Win32: Viewports: fixed an issue when closing a window from
|
- Backends: Win32: Viewports: fixed an issue when closing a window from
|
||||||
the OS close button (with io.ConfigViewportsNoDecoration=false) while
|
the OS close button (with io.ConfigViewportsNoDecoration=false) while
|
||||||
user code is discarding the 'bool *p_open=false output' from Begin().
|
user code is discarding the 'bool *p_open=false output' from Begin().
|
||||||
Because we allowed the Win32 window to close early, Windows destroyed
|
Because we allowed the Win32 window to close early, Windows destroyed
|
||||||
it and our imgui window became not visible even though user code was
|
it and our imgui window became not visible even though user code was
|
||||||
still submitting it. (#8670)
|
still submitting it. (#8670)
|
||||||
@@ -705,7 +948,7 @@ Other changes:
|
|||||||
with asserts enabled. (#8452)
|
with asserts enabled. (#8452)
|
||||||
- Backends: SDL2, SDL3: Using SDL_OpenURL() in platform_io.Platform_OpenInShellFn
|
- Backends: SDL2, SDL3: Using SDL_OpenURL() in platform_io.Platform_OpenInShellFn
|
||||||
handler. (#7660) [@achabense]
|
handler. (#7660) [@achabense]
|
||||||
- Backends: SDL2, SDL3: Use display bounds when SDL_GetDisplayUsableBounds()
|
- Backends: SDL2, SDL3: Use display bounds when SDL_GetDisplayUsableBounds()
|
||||||
fails or return a zero size. (#8415, #3457)
|
fails or return a zero size. (#8415, #3457)
|
||||||
- Backends: SDL2, SDL3, Win32, Allegro5: Added support for ImGuiMouseCursor_Wait
|
- Backends: SDL2, SDL3, Win32, Allegro5: Added support for ImGuiMouseCursor_Wait
|
||||||
and ImGuiMouseCursor_Progress cursors.
|
and ImGuiMouseCursor_Progress cursors.
|
||||||
@@ -733,9 +976,9 @@ Docking+Viewports Branch:
|
|||||||
|
|
||||||
- Docking: Removed legacy assert preventing to call DockBuilderSplitNode() on an existing
|
- Docking: Removed legacy assert preventing to call DockBuilderSplitNode() on an existing
|
||||||
split node. This makes using DockBuilder a little more flexible and bearable! (#8472) [@MegaMech]
|
split node. This makes using DockBuilder a little more flexible and bearable! (#8472) [@MegaMech]
|
||||||
- Viewports: fixed an issue where in certain cases, a window repositioning leading
|
- Viewports: fixed an issue where in certain cases, a window repositioning leading
|
||||||
to a monitor change could have the window incorrectly get clamped within the boundaries
|
to a monitor change could have the window incorrectly get clamped within the boundaries
|
||||||
of its previous monitor. Would happen e.g. when loading .ini data during runtime. (#8484)
|
of its previous monitor. Would happen e.g. when loading .ini data during runtime. (#8484)
|
||||||
- Viewports: fixed an assert when a window load settings with a position outside
|
- Viewports: fixed an assert when a window load settings with a position outside
|
||||||
monitor bounds, when there are multiple monitors. (#8393, #8385) [@gaborodriguez]
|
monitor bounds, when there are multiple monitors. (#8393, #8385) [@gaborodriguez]
|
||||||
- Viewports + Backends: Win32: Fixed setting title bar text when application
|
- Viewports + Backends: Win32: Fixed setting title bar text when application
|
||||||
@@ -1060,7 +1303,7 @@ Breaking changes:
|
|||||||
allows casting any pointer/integer type without warning:
|
allows casting any pointer/integer type without warning:
|
||||||
- May warn: ImGui::Image((void*)MyTextureData, ...);
|
- May warn: ImGui::Image((void*)MyTextureData, ...);
|
||||||
- May warn: ImGui::Image((void*)(intptr_t)MyTextureData, ...);
|
- May warn: ImGui::Image((void*)(intptr_t)MyTextureData, ...);
|
||||||
- Won't warn: ImGui::Image((ImTextureID)(intptr_t)MyTextureData), ...);
|
- Won't warn: ImGui::Image((ImTextureID)(intptr_t)MyTextureData, ...);
|
||||||
- Note that you can always define ImTextureID to be your own high-level structures
|
- Note that you can always define ImTextureID to be your own high-level structures
|
||||||
(with dedicated constructors and extra render parameters) if you like.
|
(with dedicated constructors and extra render parameters) if you like.
|
||||||
- IO: moved ImGuiConfigFlags_NavEnableSetMousePos to standalone io.ConfigNavMoveSetMousePos bool.
|
- IO: moved ImGuiConfigFlags_NavEnableSetMousePos to standalone io.ConfigNavMoveSetMousePos bool.
|
||||||
@@ -4870,7 +5113,7 @@ Breaking Changes:
|
|||||||
- ShowTestWindow() -> use ShowDemoWindow()
|
- ShowTestWindow() -> use ShowDemoWindow()
|
||||||
- IsRootWindowFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootWindow)
|
- IsRootWindowFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootWindow)
|
||||||
- IsRootWindowOrAnyChildFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows)
|
- IsRootWindowOrAnyChildFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows)
|
||||||
- SetNextWindowContentWidth(w) -> use SetNextWindowContentSize(ImVec2(w, 0.0f)
|
- SetNextWindowContentWidth(w) -> use SetNextWindowContentSize(ImVec2(w, 0.0f))
|
||||||
- GetItemsLineHeightWithSpacing() -> use GetFrameHeightWithSpacing()
|
- GetItemsLineHeightWithSpacing() -> use GetFrameHeightWithSpacing()
|
||||||
- ImGuiCol_ChildWindowBg -> use ImGuiCol_ChildBg
|
- ImGuiCol_ChildWindowBg -> use ImGuiCol_ChildBg
|
||||||
- ImGuiStyleVar_ChildWindowRounding -> use ImGuiStyleVar_ChildRounding
|
- ImGuiStyleVar_ChildWindowRounding -> use ImGuiStyleVar_ChildRounding
|
||||||
|
|||||||
@@ -149,6 +149,10 @@ SDL2 (Win32, Mac, Linux, etc.) + Vulkan example. <BR>
|
|||||||
This is quite long and tedious, because: Vulkan. <BR>
|
This is quite long and tedious, because: Vulkan. <BR>
|
||||||
For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp.
|
For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp.
|
||||||
|
|
||||||
|
[example_sdl3_metal/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl3_metal/) <BR>
|
||||||
|
SDL3 + Metal example (Mac). <BR>
|
||||||
|
= main.cpp + imgui_impl_sdl3.cpp + imgui_impl_metal.mm <BR>
|
||||||
|
|
||||||
[example_sdl3_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl3_opengl3/) <BR>
|
[example_sdl3_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl3_opengl3/) <BR>
|
||||||
SDL3 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example. <BR>
|
SDL3 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example. <BR>
|
||||||
= main.cpp + imgui_impl_sdl3.cpp + imgui_impl_opengl3.cpp <BR>
|
= main.cpp + imgui_impl_sdl3.cpp + imgui_impl_opengl3.cpp <BR>
|
||||||
|
|||||||
42
docs/FAQ.md
42
docs/FAQ.md
@@ -19,7 +19,7 @@ or view this file with any Markdown viewer.
|
|||||||
| **[How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?](#q-how-can-i-tell-whether-to-dispatch-mousekeyboard-to-dear-imgui-or-my-application)** |
|
| **[How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?](#q-how-can-i-tell-whether-to-dispatch-mousekeyboard-to-dear-imgui-or-my-application)** |
|
||||||
| [How can I enable keyboard or gamepad controls?](#q-how-can-i-enable-keyboard-or-gamepad-controls) |
|
| [How can I enable keyboard or gamepad controls?](#q-how-can-i-enable-keyboard-or-gamepad-controls) |
|
||||||
| [How can I use this on a machine without mouse, keyboard or screen? (input share, remote display)](#q-how-can-i-use-this-on-a-machine-without-mouse-keyboard-or-screen-input-share-remote-display) |
|
| [How can I use this on a machine without mouse, keyboard or screen? (input share, remote display)](#q-how-can-i-use-this-on-a-machine-without-mouse-keyboard-or-screen-input-share-remote-display) |
|
||||||
| [How can I create my own backend?](q-how-can-i-create-my-own-backend)
|
| [How can I create my own backend?](#q-how-can-i-create-my-own-backend)
|
||||||
| [I integrated Dear ImGui in my engine and little squares are showing instead of text...](#q-i-integrated-dear-imgui-in-my-engine-and-little-squares-are-showing-instead-of-text) |
|
| [I integrated Dear ImGui in my engine and little squares are showing instead of text...](#q-i-integrated-dear-imgui-in-my-engine-and-little-squares-are-showing-instead-of-text) |
|
||||||
| [I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-clipping-or-disappearing-when-i-move-windows-around) |
|
| [I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-clipping-or-disappearing-when-i-move-windows-around) |
|
||||||
| [I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-displaying-outside-their-expected-windows-boundaries) |
|
| [I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-displaying-outside-their-expected-windows-boundaries) |
|
||||||
@@ -389,8 +389,8 @@ node open/closed state differently. See what makes more sense in your situation!
|
|||||||
### Q: What are ImTextureID/ImTextureRef?
|
### Q: What are ImTextureID/ImTextureRef?
|
||||||
|
|
||||||
**Short explanation:**
|
**Short explanation:**
|
||||||
- Refer to [Image Loading and Displaying Examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples) on the [Wiki](https://github.com/ocornut/imgui/wiki).
|
|
||||||
- You may use functions such as `ImGui::Image()`, `ImGui::ImageButton()` or lower-level `ImDrawList::AddImage()` to emit draw calls that will use your own textures.
|
- You may use functions such as `ImGui::Image()`, `ImGui::ImageButton()` or lower-level `ImDrawList::AddImage()` to emit draw calls that will use your own textures.
|
||||||
|
- To load and display your own textures, refer to [Image Loading and Displaying Examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples) on the [Wiki](https://github.com/ocornut/imgui/wiki).
|
||||||
- Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as an opaque ImTextureID value.
|
- Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as an opaque ImTextureID value.
|
||||||
- By default ImTextureID can store up to 64-bits. You may `#define` it to a custom type/structure if you need.
|
- By default ImTextureID can store up to 64-bits. You may `#define` it to a custom type/structure if you need.
|
||||||
- Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason), but the examples linked above may be useful references.
|
- Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason), but the examples linked above may be useful references.
|
||||||
@@ -398,12 +398,20 @@ node open/closed state differently. See what makes more sense in your situation!
|
|||||||
**Details:**
|
**Details:**
|
||||||
|
|
||||||
1.92 introduced `ImTextureRef` in June 2025.
|
1.92 introduced `ImTextureRef` in June 2025.
|
||||||
- Most drawing functions using ImTextureID were changed to use ImTextureRef.
|
- All drawing functions using `ImTextureID` were changed to use `ImTextureRef`.
|
||||||
- We intentionally do not provide an implicit ImTextureRef -> ImTextureID cast operator because it is technically lossy to convert ImTextureRef to ImTextureID before rendering.
|
- You can trivially create a `ImTextureRef` from a `ImTextureID`.
|
||||||
|
- **If you use Image functions with textures that you have loaded/created yourself, you will mostly likely only ever store/manipulate `ImTextureID` and then pass them as `ImTextureRef`.**
|
||||||
|
- You only NEED to manipulate `ImTextureRef` when dealing with textures managed by the backend itself, aka mainly the atlas texture for now.
|
||||||
|
- We intentionally do not provide an implicit `ImTextureRef` -> `ImTextureID` cast operator because it is technically lossy to convert ImTextureRef to ImTextureID before rendering.
|
||||||
|
|
||||||
**ImTextureID = backend specific, low-level identifier for a texture uploaded in GPU/graphics system.**
|
**ImTextureID = backend specific, low-level identifier for a texture uploaded in GPU/graphics system.**
|
||||||
|
```cpp
|
||||||
|
#ifndef ImTextureID
|
||||||
|
typedef ImU64 ImTextureID; // Default: store up to 64-bits (any pointer or integer). A majority of backends are ok with that.
|
||||||
|
#endif
|
||||||
|
```
|
||||||
- When a Rendered Backend creates a texture, it store its native identifier into a ImTextureID value (e.g. Used by DX11 backend to a `ID3D11ShaderResourceView*`; Used by OpenGL backends to store `GLuint`; Used by SDLGPU backend to store a `SDL_GPUTextureSamplerBinding*`, etc.).
|
- When a Rendered Backend creates a texture, it store its native identifier into a ImTextureID value (e.g. Used by DX11 backend to a `ID3D11ShaderResourceView*`; Used by OpenGL backends to store `GLuint`; Used by SDLGPU backend to store a `SDL_GPUTextureSamplerBinding*`, etc.).
|
||||||
- User may submit their own textures to e.g. ImGui::Image() function by passing the same type.
|
- User may submit their own textures to e.g. `ImGui::Image()` function by passing this value.
|
||||||
- During the rendering loop, the Renderer Backend retrieve the ImTextureID, which stored inside a ImTextureRef, which is stored inside ImDrawCmd.
|
- During the rendering loop, the Renderer Backend retrieve the ImTextureID, which stored inside a ImTextureRef, which is stored inside ImDrawCmd.
|
||||||
- Compile-time type configuration:
|
- Compile-time type configuration:
|
||||||
- To use something other than a 64-bit value: add '#define ImTextureID MyTextureType*' in your imconfig.h file.
|
- To use something other than a 64-bit value: add '#define ImTextureID MyTextureType*' in your imconfig.h file.
|
||||||
@@ -411,13 +419,29 @@ node open/closed state differently. See what makes more sense in your situation!
|
|||||||
- You may decide to store a higher-level structure containing texture, sampler, shader etc. with various constructors if you like. You will need to implement ==/!= operators.
|
- You may decide to store a higher-level structure containing texture, sampler, shader etc. with various constructors if you like. You will need to implement ==/!= operators.
|
||||||
|
|
||||||
**ImTextureRef = higher-level identifier for a texture.**
|
**ImTextureRef = higher-level identifier for a texture.**
|
||||||
|
```cpp
|
||||||
|
// Store a ImTextureID _or_ a ImTextureData*.
|
||||||
|
struct ImTextureRef
|
||||||
|
{
|
||||||
|
ImTextureRef() { _TexData = NULL; _TexID = ImTextureID_Invalid; }
|
||||||
|
ImTextureRef(ImTextureID tex_id) { _TexData = NULL; _TexID = tex_id; }
|
||||||
|
inline ImTextureID GetTexID() const { return _TexData ? _TexData->TexID : _TexID; }
|
||||||
|
|
||||||
|
// Members (either are set, never both!)
|
||||||
|
ImTextureData* _TexData; // A texture, generally owned by a ImFontAtlas. Will convert to ImTextureID during render loop, after texture has been uploaded.
|
||||||
|
ImTextureID _TexID; // _OR_ Low-level backend texture identifier, if already uploaded or created by user/app. Generally provided to e.g. ImGui::Image() calls.
|
||||||
|
};
|
||||||
|
```
|
||||||
- The identifier is valid even before the texture has been uploaded to the GPU/graphics system.
|
- The identifier is valid even before the texture has been uploaded to the GPU/graphics system.
|
||||||
- This is what gets passed to functions such as `ImGui::Image()`, `ImDrawList::AddImage()`.
|
- This is what gets passed to functions such as `ImGui::Image()`, `ImDrawList::AddImage()`.
|
||||||
- This is what gets stored in draw commands (`ImDrawCmd`) to identify a texture during rendering.
|
- This is what gets stored in draw commands (`ImDrawCmd`) to identify a texture during rendering.
|
||||||
- When a texture is created by user code (e.g. custom images), we directly stores the low-level `ImTextureID`.
|
- When a texture is created by user code (e.g. custom images), we directly store the low-level `ImTextureID`.
|
||||||
- When a texture is created by the backend, we stores a `ImTextureData*` which becomes an indirection to extract the `ImTextureID` value during rendering, after texture upload has happened.
|
- Because of this, when displaying your own texture you are likely to ever only manage ImTextureID values on your side.
|
||||||
- There is no constructor to create a `ImTextureID` from a `ImTextureData*` as we don't expect this to be useful to the end-user, and it would be erroneously called by many legacy code.
|
- When a texture is created by the backend, we store a `ImTextureData*` which becomes an indirection to extract the `ImTextureID` value during rendering, after texture upload has happened.
|
||||||
- If you want to bind the current atlas when using custom rectangle, you can use `io.Fonts->TexRef`.
|
- To create a `ImTextureRef` from a `ImTextureData*` you can use `ImTextureData::GetTexRef()`.
|
||||||
|
We intentionally do not provide an `ImTextureRef` constructor for this: we don't expect this to be frequently useful to the end-user, and it would be erroneously called by many legacy code.
|
||||||
|
- There is no constructor to create a `ImTextureRef` from a `ImTextureData*` as we don't expect this to be useful to the end-user, and it would be erroneously called by many legacy code.
|
||||||
|
- If you want to bind the current atlas when using custom rectangles, you can use `io.Fonts->TexRef`.
|
||||||
- Binding generators for languages such as C (which don't have constructors), should provide a helper, e.g. `inline ImTextureRef ImTextureRefFromID(ImTextureID tex_id) { ImTextureRef tex_ref = { ._TexData = NULL, .TexID = tex_id }; return tex_ref; }`
|
- Binding generators for languages such as C (which don't have constructors), should provide a helper, e.g. `inline ImTextureRef ImTextureRefFromID(ImTextureID tex_id) { ImTextureRef tex_ref = { ._TexData = NULL, .TexID = tex_id }; return tex_ref; }`
|
||||||
|
|
||||||
**Please read documentations or tutorials on your graphics API to understand how to display textures on the screen before moving onward.**
|
**Please read documentations or tutorials on your graphics API to understand how to display textures on the screen before moving onward.**
|
||||||
|
|||||||
@@ -150,7 +150,6 @@ ImFontConfig config;
|
|||||||
config.MergeMode = true;
|
config.MergeMode = true;
|
||||||
io.Fonts->AddFontFromFileTTF("DroidSans.ttf", 0.0f, &config); // Merge into first font to add e.g. Asian characters
|
io.Fonts->AddFontFromFileTTF("DroidSans.ttf", 0.0f, &config); // Merge into first font to add e.g. Asian characters
|
||||||
io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 0.0f, &config); // Merge into first font to add Icons
|
io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 0.0f, &config); // Merge into first font to add Icons
|
||||||
io.Fonts->Build();
|
|
||||||
```
|
```
|
||||||
:rewind: **Before 1.92, or without an up to date backend:**
|
:rewind: **Before 1.92, or without an up to date backend:**
|
||||||
```cpp
|
```cpp
|
||||||
@@ -588,15 +587,18 @@ Some fonts files are available in the `misc/fonts/` folder:
|
|||||||
|
|
||||||
#### MONOSPACE FONTS
|
#### MONOSPACE FONTS
|
||||||
|
|
||||||
|
<img width="1172" height="715" alt="image" src="https://github.com/user-attachments/assets/c9702534-4877-41c9-ae0d-252933c26ced" />
|
||||||
|
|
||||||
Pixel Perfect:
|
Pixel Perfect:
|
||||||
- Proggy Fonts, by Tristan Grimmer http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php
|
- Proggy Fonts, by Tristan Grimmer http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php
|
||||||
- Sweet16, Sweet16 Mono, by Martin Sedlak (Latin + Supplemental + Extended A) https://github.com/kmar/Sweet16Font (also include an .inl file to use directly in dear imgui.)
|
- Sweet16, Sweet16 Mono, by Martin Sedlak (Latin + Supplemental + Extended A) https://github.com/kmar/Sweet16Font (also include an .inl file to use directly in dear imgui.)
|
||||||
|
|
||||||
Regular:
|
Regular:
|
||||||
- Google Noto Mono Fonts https://www.google.com/get/noto/
|
- ProggyVector if you want the old school Dear ImGui font to scale: https://github.com/bluescan/proggyfonts
|
||||||
- Typefaces for source code beautification https://github.com/chrissimpkins/codeface
|
- Google Noto Mono Fonts: https://www.google.com/get/noto/
|
||||||
- Programmation fonts http://s9w.github.io/font_compare/
|
- Typefaces for source code beautification: https://github.com/chrissimpkins/codeface
|
||||||
- Inconsolata http://www.levien.com/type/myfonts/inconsolata.html
|
- Programmation fonts: http://s9w.github.io/font_compare/
|
||||||
|
- Inconsolata: http://www.levien.com/type/myfonts/inconsolata.html
|
||||||
- Adobe Source Code Pro: Monospaced font family for ui & coding environments https://github.com/adobe-fonts/source-code-pro
|
- Adobe Source Code Pro: Monospaced font family for ui & coding environments https://github.com/adobe-fonts/source-code-pro
|
||||||
- Monospace/Fixed Width Programmer's Fonts http://www.lowing.org/fonts/
|
- Monospace/Fixed Width Programmer's Fonts http://www.lowing.org/fonts/
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Businesses: support continued development and maintenance via invoiced sponsorin
|
|||||||
| [The Pitch](#the-pitch) - [Usage](#usage) - [How it works](#how-it-works) - [Releases & Changelogs](#releases--changelogs) - [Demo](#demo) - [Getting Started & Integration](#getting-started--integration) |
|
| [The Pitch](#the-pitch) - [Usage](#usage) - [How it works](#how-it-works) - [Releases & Changelogs](#releases--changelogs) - [Demo](#demo) - [Getting Started & Integration](#getting-started--integration) |
|
||||||
:----------------------------------------------------------: |
|
:----------------------------------------------------------: |
|
||||||
| [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - **[Funding & Sponsors](https://github.com/ocornut/imgui/wiki/Funding)** - [Credits](#credits) - [License](#license) |
|
| [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - **[Funding & Sponsors](https://github.com/ocornut/imgui/wiki/Funding)** - [Credits](#credits) - [License](#license) |
|
||||||
| [Wiki](https://github.com/ocornut/imgui/wiki) - [Extensions](https://github.com/ocornut/imgui/wiki/Useful-Extensions) - [Languages bindings & frameworks backends](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) |
|
| [Wiki](https://github.com/ocornut/imgui/wiki) - [Extensions](https://github.com/ocornut/imgui/wiki/Useful-Extensions) - [Language bindings & framework backends](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) |
|
||||||
|
|
||||||
### The Pitch
|
### The Pitch
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ How to help
|
|||||||
- See [GitHub Forum/Issues](https://github.com/ocornut/imgui/issues).
|
- See [GitHub Forum/Issues](https://github.com/ocornut/imgui/issues).
|
||||||
- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest of the end-users and also to ease the maintainer into understanding and accepting it.
|
- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest of the end-users and also to ease the maintainer into understanding and accepting it.
|
||||||
- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas.
|
- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas.
|
||||||
- Be a [Funding Supporter](https://github.com/ocornut/imgui/wiki/Funding)! Have your company financially support this project via invoiced sponsors/maintenance or by buying a license for [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine) (please reach out: omar AT dearimgui DOT com).
|
- Be a [Funding Supporter](https://github.com/ocornut/imgui/wiki/Funding)! Have your company financially support this project via invoiced sponsors/maintenance or by buying a license for [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine) (please reach out: contact AT dearimgui DOT com).
|
||||||
|
|
||||||
Sponsors
|
Sponsors
|
||||||
--------
|
--------
|
||||||
@@ -214,7 +214,7 @@ Omar: "I first discovered the IMGUI paradigm at [Q-Games](https://www.q-games.co
|
|||||||
Embeds [ProggyClean.ttf](https://www.proggyfonts.net) font by Tristan Grimmer (MIT license).
|
Embeds [ProggyClean.ttf](https://www.proggyfonts.net) font by Tristan Grimmer (MIT license).
|
||||||
<br>Embeds [stb_textedit.h, stb_truetype.h, stb_rect_pack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
|
<br>Embeds [stb_textedit.h, stb_truetype.h, stb_rect_pack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain).
|
||||||
|
|
||||||
Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Also thank you to everyone posting feedback, questions and patches on GitHub.
|
Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Special thanks to Alex Evans, Patrick Doane, Marco Koegler for kindly helping. Also thank you to everyone posting feedback, questions and patches on GitHub.
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- input text multi-line: line numbers? status bar? (follow up on #200)
|
- input text multi-line: line numbers? status bar? (follow up on #200)
|
||||||
- input text multi-line: behave better when user changes input buffer while editing is active (even though it is illegal behavior). namely, the change of buffer can create a scrollbar glitch (#725)
|
- input text multi-line: behave better when user changes input buffer while editing is active (even though it is illegal behavior). namely, the change of buffer can create a scrollbar glitch (#725)
|
||||||
- input text multi-line: better horizontal scrolling support (#383, #1224)
|
- input text multi-line: better horizontal scrolling support (#383, #1224)
|
||||||
- input text multi-line: single call to AddText() should be coarse clipped on InputTextEx() end.
|
|
||||||
- input number: optional range min/max for Input*() functions
|
- input number: optional range min/max for Input*() functions
|
||||||
- input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled)
|
- input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled)
|
||||||
- input number: use mouse wheel to step up/down
|
- input number: use mouse wheel to step up/down
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ int main(int, char**)
|
|||||||
al_install_mouse();
|
al_install_mouse();
|
||||||
al_init_primitives_addon();
|
al_init_primitives_addon();
|
||||||
al_set_new_display_flags(ALLEGRO_RESIZABLE);
|
al_set_new_display_flags(ALLEGRO_RESIZABLE);
|
||||||
ALLEGRO_DISPLAY* display = al_create_display(1280, 720);
|
ALLEGRO_DISPLAY* display = al_create_display(1280, 800);
|
||||||
al_set_window_title(display, "Dear ImGui Allegro 5 example");
|
al_set_window_title(display, "Dear ImGui Allegro 5 example");
|
||||||
ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue();
|
ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue();
|
||||||
al_register_event_source(queue, al_get_display_event_source(display));
|
al_register_event_source(queue, al_get_display_event_source(display));
|
||||||
@@ -54,7 +54,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
.cxx
|
|
||||||
.externalNativeBuild
|
|
||||||
build/
|
build/
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
.idea
|
|
||||||
.gradle
|
.gradle
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
local.properties
|
local.properties
|
||||||
|
|
||||||
# Android Studio puts a Gradle wrapper here, that we don't want:
|
# Android Studio puts a Gradle wrapper here, that we don't want:
|
||||||
gradle/
|
gradle/
|
||||||
|
!gradle/libs.versions.toml
|
||||||
gradlew*
|
gradlew*
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
apply plugin: 'com.android.application'
|
plugins {
|
||||||
apply plugin: 'kotlin-android'
|
alias(libs.plugins.android.application)
|
||||||
|
alias(libs.plugins.kotlin.android)
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 33
|
namespace 'imgui.example.android'
|
||||||
buildToolsVersion "33.0.2"
|
compileSdk 36
|
||||||
ndkVersion "25.2.9519653"
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "imgui.example.android"
|
applicationId "imgui.example.android"
|
||||||
namespace "imgui.example.android"
|
minSdk 24
|
||||||
minSdkVersion 24
|
targetSdk 36
|
||||||
targetSdkVersion 33
|
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
}
|
}
|
||||||
@@ -21,26 +21,17 @@ android {
|
|||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_11
|
sourceCompatibility JavaVersion.VERSION_11
|
||||||
targetCompatibility JavaVersion.VERSION_11
|
targetCompatibility JavaVersion.VERSION_11
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget="11"
|
jvmTarget = '11'
|
||||||
}
|
}
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
path "../../CMakeLists.txt"
|
path file('../../CMakeLists.txt')
|
||||||
version '3.22.1'
|
version '3.22.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="ImGuiExample"
|
android:label="ImGuiExample"
|
||||||
|
|||||||
@@ -1,24 +1,5 @@
|
|||||||
buildscript {
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
ext.kotlin_version = '1.8.0'
|
plugins {
|
||||||
repositories {
|
alias(libs.plugins.android.application) apply false
|
||||||
google()
|
alias(libs.plugins.kotlin.android) apply false
|
||||||
mavenCentral()
|
|
||||||
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'com.android.tools.build:gradle:7.4.1'
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task clean(type: Delete) {
|
|
||||||
delete rootProject.buildDir
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
[versions]
|
||||||
|
agp = "8.12.0"
|
||||||
|
kotlin = "2.0.21"
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
|
||||||
@@ -1 +1,22 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
google {
|
||||||
|
content {
|
||||||
|
includeGroupByRegex("com\\.android.*")
|
||||||
|
includeGroupByRegex("com\\.google.*")
|
||||||
|
includeGroupByRegex("androidx.*")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
include ':app'
|
include ':app'
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ void Init(struct android_app* app)
|
|||||||
// 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
// - Android: The TTF files have to be placed into the assets/ directory (android/app/src/main/assets), we use our GetAssetData() helper to retrieve them.
|
// - Android: The TTF files have to be placed into the assets/ directory (android/app/src/main/assets), we use our GetAssetData() helper to retrieve them.
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
|
|
||||||
-(void)loadView
|
-(void)loadView
|
||||||
{
|
{
|
||||||
self.view = [[MTKView alloc] initWithFrame:CGRectMake(0, 0, 1200, 720)];
|
self.view = [[MTKView alloc] initWithFrame:CGRectMake(0, 0, 1200, 800)];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)viewDidLoad
|
-(void)viewDidLoad
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
@@ -190,7 +190,7 @@
|
|||||||
if (_window != nil)
|
if (_window != nil)
|
||||||
return (_window);
|
return (_window);
|
||||||
|
|
||||||
NSRect viewRect = NSMakeRect(100.0, 100.0, 100.0 + 1280.0, 100 + 720.0);
|
NSRect viewRect = NSMakeRect(100.0, 100.0, 100.0 + 1280.0, 100 + 800.0);
|
||||||
|
|
||||||
_window = [[NSWindow alloc] initWithContentRect:viewRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:YES];
|
_window = [[NSWindow alloc] initWithContentRect:viewRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:YES];
|
||||||
[_window setTitle:@"Dear ImGui OSX+OpenGL2 Example"];
|
[_window setTitle:@"Dear ImGui OSX+OpenGL2 Example"];
|
||||||
|
|||||||
@@ -27,33 +27,57 @@ static void glfw_error_callback(int error, const char* description)
|
|||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
|
glfwSetErrorCallback(glfw_error_callback);
|
||||||
|
if (!glfwInit())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// Create window with graphics context
|
||||||
|
float main_scale = ImGui_ImplGlfw_GetContentScaleForMonitor(glfwGetPrimaryMonitor()); // Valid on GLFW 3.3+ only
|
||||||
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
|
GLFWwindow* window = glfwCreateWindow((int)(1280 * main_scale), (int)(800 * main_scale), "Dear ImGui GLFW+Metal example", nullptr, nullptr);
|
||||||
|
if (window == nullptr)
|
||||||
|
return 1;
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
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_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup 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.
|
// Setup scaling
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
|
style.FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
|
||||||
|
io.ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
|
||||||
|
io.ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
style.WindowRounding = 0.0f;
|
style.WindowRounding = 0.0f;
|
||||||
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id <MTLDevice> device = MTLCreateSystemDefaultDevice();
|
||||||
|
id <MTLCommandQueue> commandQueue = [device newCommandQueue];
|
||||||
|
|
||||||
|
// Setup Platform/Renderer backends
|
||||||
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||||
|
ImGui_ImplMetal_Init(device);
|
||||||
|
|
||||||
// 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
@@ -64,24 +88,6 @@ int main(int, char**)
|
|||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf");
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf");
|
||||||
//IM_ASSERT(font != nullptr);
|
//IM_ASSERT(font != nullptr);
|
||||||
|
|
||||||
// Setup window
|
|
||||||
glfwSetErrorCallback(glfw_error_callback);
|
|
||||||
if (!glfwInit())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Create window with graphics context
|
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
|
||||||
GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+Metal example", nullptr, nullptr);
|
|
||||||
if (window == nullptr)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
id <MTLDevice> device = MTLCreateSystemDefaultDevice();
|
|
||||||
id <MTLCommandQueue> commandQueue = [device newCommandQueue];
|
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
|
||||||
ImGui_ImplGlfw_InitForOther(window, true);
|
|
||||||
ImGui_ImplMetal_Init(device);
|
|
||||||
|
|
||||||
NSWindow *nswin = glfwGetCocoaWindow(window);
|
NSWindow *nswin = glfwGetCocoaWindow(window);
|
||||||
CAMetalLayer *layer = [CAMetalLayer layer];
|
CAMetalLayer *layer = [CAMetalLayer layer];
|
||||||
layer.device = device;
|
layer.device = device;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui
|
|||||||
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp
|
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp
|
||||||
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
|
LINUX_GL_LIBS = -lGL
|
||||||
|
|
||||||
CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
|
CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
|
||||||
CXXFLAGS += -g -Wall -Wformat
|
CXXFLAGS += -g -Wall -Wformat
|
||||||
@@ -32,7 +33,7 @@ LIBS =
|
|||||||
|
|
||||||
ifeq ($(UNAME_S), Linux) #LINUX
|
ifeq ($(UNAME_S), Linux) #LINUX
|
||||||
ECHO_MESSAGE = "Linux"
|
ECHO_MESSAGE = "Linux"
|
||||||
LIBS += -lGL `pkg-config --static --libs glfw3`
|
LIBS += $(LINUX_GL_LIBS) -lX11 `pkg-config --static --libs glfw3`
|
||||||
|
|
||||||
CXXFLAGS += `pkg-config --cflags glfw3`
|
CXXFLAGS += `pkg-config --cflags glfw3`
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ int main(int, char**)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// Create window with graphics context
|
// Create window with graphics context
|
||||||
GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+OpenGL2 example", nullptr, nullptr);
|
float main_scale = ImGui_ImplGlfw_GetContentScaleForMonitor(glfwGetPrimaryMonitor()); // Valid on GLFW 3.3+ only
|
||||||
|
GLFWwindow* window = glfwCreateWindow((int)(1280 * main_scale), (int)(800 * main_scale), "Dear ImGui GLFW+OpenGL2 example", nullptr, nullptr);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
return 1;
|
return 1;
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
@@ -61,8 +62,14 @@ int main(int, char**)
|
|||||||
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.
|
// Setup scaling
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
|
style.FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
|
||||||
|
io.ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
|
||||||
|
io.ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
style.WindowRounding = 0.0f;
|
style.WindowRounding = 0.0f;
|
||||||
@@ -78,7 +85,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ LIBS =
|
|||||||
|
|
||||||
ifeq ($(UNAME_S), Linux) #LINUX
|
ifeq ($(UNAME_S), Linux) #LINUX
|
||||||
ECHO_MESSAGE = "Linux"
|
ECHO_MESSAGE = "Linux"
|
||||||
LIBS += $(LINUX_GL_LIBS) `pkg-config --static --libs glfw3`
|
LIBS += $(LINUX_GL_LIBS) -lX11 `pkg-config --static --libs glfw3`
|
||||||
|
|
||||||
CXXFLAGS += `pkg-config --cflags glfw3`
|
CXXFLAGS += `pkg-config --cflags glfw3`
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ find_package(Vulkan REQUIRED)
|
|||||||
#NAMES vulkan vulkan-1)
|
#NAMES vulkan vulkan-1)
|
||||||
#set(LIBRARIES "glfw;${VULKAN_LIBRARY}")
|
#set(LIBRARIES "glfw;${VULKAN_LIBRARY}")
|
||||||
set(LIBRARIES "glfw;Vulkan::Vulkan")
|
set(LIBRARIES "glfw;Vulkan::Vulkan")
|
||||||
|
# FIXME: Linux needs linking with "X11" as well?
|
||||||
|
|
||||||
# Use vulkan headers from glfw:
|
# Use vulkan headers from glfw:
|
||||||
include_directories(${GLFW_DIR}/deps)
|
include_directories(${GLFW_DIR}/deps)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ LIBS =
|
|||||||
|
|
||||||
ifeq ($(UNAME_S), Linux) #LINUX
|
ifeq ($(UNAME_S), Linux) #LINUX
|
||||||
ECHO_MESSAGE = "Linux"
|
ECHO_MESSAGE = "Linux"
|
||||||
LIBS += $(LINUX_GL_LIBS) `pkg-config --static --libs glfw3 vulkan`
|
LIBS += $(LINUX_GL_LIBS) -lX11 `pkg-config --static --libs glfw3 vulkan`
|
||||||
|
|
||||||
CXXFLAGS += `pkg-config --cflags glfw3 vulkan`
|
CXXFLAGS += `pkg-config --cflags glfw3 vulkan`
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
|||||||
@@ -357,7 +357,8 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Create window with Vulkan context
|
// Create window with Vulkan context
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+Vulkan example", nullptr, nullptr);
|
float main_scale = ImGui_ImplGlfw_GetContentScaleForMonitor(glfwGetPrimaryMonitor()); // Valid on GLFW 3.3+ only
|
||||||
|
GLFWwindow* window = glfwCreateWindow((int)(1280 * main_scale), (int)(800 * main_scale), "Dear ImGui GLFW+Vulkan example", nullptr, nullptr);
|
||||||
if (!glfwVulkanSupported())
|
if (!glfwVulkanSupported())
|
||||||
{
|
{
|
||||||
printf("GLFW: Vulkan Not Supported\n");
|
printf("GLFW: Vulkan Not Supported\n");
|
||||||
@@ -397,8 +398,14 @@ int main(int, char**)
|
|||||||
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.
|
// Setup scaling
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
|
style.FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
|
||||||
|
io.ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
|
||||||
|
io.ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
style.WindowRounding = 0.0f;
|
style.WindowRounding = 0.0f;
|
||||||
@@ -430,7 +437,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ static WGPUSurface wgpu_surface = nullptr;
|
|||||||
static WGPUTextureFormat wgpu_preferred_fmt = WGPUTextureFormat_RGBA8Unorm;
|
static WGPUTextureFormat wgpu_preferred_fmt = WGPUTextureFormat_RGBA8Unorm;
|
||||||
static WGPUSwapChain wgpu_swap_chain = nullptr;
|
static WGPUSwapChain wgpu_swap_chain = nullptr;
|
||||||
static int wgpu_swap_chain_width = 1280;
|
static int wgpu_swap_chain_width = 1280;
|
||||||
static int wgpu_swap_chain_height = 720;
|
static int wgpu_swap_chain_height = 800;
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
static bool InitWGPU(GLFWwindow* window);
|
static bool InitWGPU(GLFWwindow* window);
|
||||||
@@ -116,7 +116,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
// - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details.
|
// - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details.
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ int main(int argc, char** argv)
|
|||||||
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
|
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
|
||||||
#endif
|
#endif
|
||||||
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
|
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE);
|
||||||
glutInitWindowSize(1280, 720);
|
glutInitWindowSize(1280, 800);
|
||||||
glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
|
glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example");
|
||||||
|
|
||||||
// Setup GLUT display function
|
// Setup GLUT display function
|
||||||
@@ -84,7 +84,7 @@ int main(int argc, char** argv)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ int main(int, char**)
|
|||||||
// Setup window
|
// Setup window
|
||||||
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+DirectX11 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+DirectX11 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
@@ -107,7 +107,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
@@ -70,7 +70,7 @@ int main(int, char**)
|
|||||||
// Enable native IME.
|
// Enable native IME.
|
||||||
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
||||||
|
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL+Metal example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL+Metal example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 800, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error creating window: %s\n", SDL_GetError());
|
printf("Error creating window: %s\n", SDL_GetError());
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ int main(int, char**)
|
|||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||||
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
@@ -96,7 +96,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ int main(int, char**)
|
|||||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||||
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
@@ -136,7 +136,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ int main(int, char**)
|
|||||||
// Create window with SDL_Renderer graphics context
|
// Create window with SDL_Renderer graphics context
|
||||||
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+SDL_Renderer example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+SDL_Renderer example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
@@ -88,7 +88,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ int main(int, char**)
|
|||||||
// Create window with Vulkan graphics context
|
// Create window with Vulkan graphics context
|
||||||
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
float main_scale = ImGui_ImplSDL2_GetContentScaleForDisplay(0);
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
@@ -443,7 +443,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
48
examples/example_sdl3_metal/Makefile
Normal file
48
examples/example_sdl3_metal/Makefile
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#
|
||||||
|
# You will need SDL3 (http://www.libsdl.org):
|
||||||
|
# brew install sdl3
|
||||||
|
#
|
||||||
|
|
||||||
|
#CXX = g++
|
||||||
|
#CXX = clang++
|
||||||
|
|
||||||
|
EXE = example_sdl3_metal
|
||||||
|
IMGUI_DIR = ../..
|
||||||
|
SOURCES = main.mm
|
||||||
|
SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
|
||||||
|
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl3.cpp $(IMGUI_DIR)/backends/imgui_impl_metal.mm
|
||||||
|
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
||||||
|
|
||||||
|
LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore
|
||||||
|
LIBS += `pkg-config --libs sdl3`
|
||||||
|
LIBS += -L/usr/local/lib -L/opt/local/lib
|
||||||
|
|
||||||
|
CXXFLAGS += `pkg-config --cflags sdl3`
|
||||||
|
CXXFLAGS += -I/usr/local/include -I/opt/local/include
|
||||||
|
CXXFLAGS += -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
|
||||||
|
CXXFLAGS += -Wall -Wformat
|
||||||
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
|
||||||
|
%.o:%.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:$(IMGUI_DIR)/%.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:$(IMGUI_DIR)/backends/%.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:%.mm
|
||||||
|
$(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:$(IMGUI_DIR)/backends/%.mm
|
||||||
|
$(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $<
|
||||||
|
|
||||||
|
all: $(EXE)
|
||||||
|
@echo Build complete
|
||||||
|
|
||||||
|
$(EXE): $(OBJS)
|
||||||
|
$(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(EXE) $(OBJS)
|
||||||
208
examples/example_sdl3_metal/main.mm
Normal file
208
examples/example_sdl3_metal/main.mm
Normal file
@@ -0,0 +1,208 @@
|
|||||||
|
// Dear ImGui: standalone example application for SDL3 + Metal
|
||||||
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
|
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_sdl3.h"
|
||||||
|
#include "imgui_impl_metal.h"
|
||||||
|
#include <stdio.h> // printf, fprintf
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
|
#import <Metal/Metal.h>
|
||||||
|
#import <QuartzCore/QuartzCore.h>
|
||||||
|
|
||||||
|
// Main code
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
// Setup SDL
|
||||||
|
// [If using SDL_MAIN_USE_CALLBACKS: all code below until the main loop starts would likely be your SDL_AppInit() function]
|
||||||
|
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD))
|
||||||
|
{
|
||||||
|
printf("Error: SDL_Init(): %s\n", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create SDL window graphics context
|
||||||
|
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
||||||
|
SDL_WindowFlags window_flags = SDL_WINDOW_METAL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||||
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+Metal example", (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
||||||
|
if (window == nullptr)
|
||||||
|
{
|
||||||
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||||
|
SDL_ShowWindow(window);
|
||||||
|
|
||||||
|
// Create Metal device _before_ creating the view/layer
|
||||||
|
id<MTLDevice> metalDevice = MTLCreateSystemDefaultDevice();
|
||||||
|
if (!metalDevice)
|
||||||
|
{
|
||||||
|
printf("Error: failed to create Metal device.\n");
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
SDL_MetalView view = SDL_Metal_CreateView(window);
|
||||||
|
CAMetalLayer* layer = (__bridge CAMetalLayer*)SDL_Metal_GetLayer(view);
|
||||||
|
layer.device = metalDevice;
|
||||||
|
layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
||||||
|
|
||||||
|
id<MTLCommandQueue> commandQueue = [layer.device newCommandQueue];
|
||||||
|
MTLRenderPassDescriptor* renderPassDescriptor = [MTLRenderPassDescriptor new];
|
||||||
|
|
||||||
|
// Setup Dear ImGui context
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
ImGui::CreateContext();
|
||||||
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
|
// Setup Dear ImGui style
|
||||||
|
ImGui::StyleColorsDark();
|
||||||
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// Setup scaling
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
|
style.FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
|
||||||
|
|
||||||
|
// Setup Platform/Renderer backends
|
||||||
|
ImGui_ImplMetal_Init(layer.device);
|
||||||
|
ImGui_ImplSDL3_InitForMetal(window);
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//style.FontSizeBase = 20.0f;
|
||||||
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf");
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf");
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf");
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf");
|
||||||
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf");
|
||||||
|
//IM_ASSERT(font != nullptr);
|
||||||
|
|
||||||
|
// Our state
|
||||||
|
bool show_demo_window = true;
|
||||||
|
bool show_another_window = false;
|
||||||
|
float clear_color[4] = { 0.45f, 0.55f, 0.60f, 1.00f };
|
||||||
|
|
||||||
|
// Main loop
|
||||||
|
bool done = false;
|
||||||
|
while (!done)
|
||||||
|
{
|
||||||
|
@autoreleasepool
|
||||||
|
{
|
||||||
|
// Poll and handle events (inputs, window resize, etc.)
|
||||||
|
// 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.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.
|
||||||
|
// [If using SDL_MAIN_USE_CALLBACKS: call ImGui_ImplSDL3_ProcessEvent() from your SDL_AppEvent() function]
|
||||||
|
SDL_Event event;
|
||||||
|
while (SDL_PollEvent(&event))
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ProcessEvent(&event);
|
||||||
|
if (event.type == SDL_EVENT_QUIT)
|
||||||
|
done = true;
|
||||||
|
if (event.type == SDL_EVENT_WINDOW_CLOSE_REQUESTED && event.window.windowID == SDL_GetWindowID(window))
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// [If using SDL_MAIN_USE_CALLBACKS: all code below would likely be your SDL_AppIterate() function]
|
||||||
|
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
|
||||||
|
{
|
||||||
|
SDL_Delay(10);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width, height;
|
||||||
|
SDL_GetWindowSizeInPixels(window, &width, &height);
|
||||||
|
|
||||||
|
layer.drawableSize = CGSizeMake(width, height);
|
||||||
|
id<CAMetalDrawable> drawable = [layer nextDrawable];
|
||||||
|
|
||||||
|
id<MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];
|
||||||
|
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0] * clear_color[3], clear_color[1] * clear_color[3], clear_color[2] * clear_color[3], clear_color[3]);
|
||||||
|
renderPassDescriptor.colorAttachments[0].texture = drawable.texture;
|
||||||
|
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
|
||||||
|
renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore;
|
||||||
|
id <MTLRenderCommandEncoder> renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
|
||||||
|
[renderEncoder pushDebugGroup:@"ImGui demo"];
|
||||||
|
|
||||||
|
// Start the Dear ImGui frame
|
||||||
|
ImGui_ImplMetal_NewFrame(renderPassDescriptor);
|
||||||
|
ImGui_ImplSDL3_NewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||||
|
if (show_demo_window)
|
||||||
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
|
|
||||||
|
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window.
|
||||||
|
{
|
||||||
|
static float f = 0.0f;
|
||||||
|
static int counter = 0;
|
||||||
|
|
||||||
|
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
||||||
|
|
||||||
|
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||||
|
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
||||||
|
ImGui::Checkbox("Another Window", &show_another_window);
|
||||||
|
|
||||||
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||||
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||||
|
|
||||||
|
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||||
|
counter++;
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("counter = %d", counter);
|
||||||
|
|
||||||
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Show another simple window.
|
||||||
|
if (show_another_window)
|
||||||
|
{
|
||||||
|
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||||
|
ImGui::Text("Hello from another window!");
|
||||||
|
if (ImGui::Button("Close Me"))
|
||||||
|
show_another_window = false;
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
ImGui::Render();
|
||||||
|
ImDrawData* draw_data = ImGui::GetDrawData();
|
||||||
|
ImGui_ImplMetal_RenderDrawData(draw_data, commandBuffer, renderEncoder);
|
||||||
|
|
||||||
|
[renderEncoder popDebugGroup];
|
||||||
|
[renderEncoder endEncoding];
|
||||||
|
|
||||||
|
[commandBuffer presentDrawable:drawable];
|
||||||
|
[commandBuffer commit];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
// [If using SDL_MAIN_USE_CALLBACKS: all code below would likely be your SDL_AppQuit() function]
|
||||||
|
ImGui_ImplMetal_Shutdown();
|
||||||
|
ImGui_ImplSDL3_Shutdown();
|
||||||
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -70,7 +70,7 @@ int main(int, char**)
|
|||||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||||
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
||||||
SDL_WindowFlags window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
SDL_WindowFlags window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+OpenGL3 example", (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+OpenGL3 example", (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
@@ -126,7 +126,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// Dear ImGui: standalone example application for SDL3 + SDL_GPU
|
// Dear ImGui: standalone example application for SDL3 + SDL_GPU
|
||||||
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
|
|
||||||
// Learn about Dear ImGui:
|
// Learn about Dear ImGui:
|
||||||
// - FAQ https://dearimgui.com/faq
|
// - FAQ https://dearimgui.com/faq
|
||||||
@@ -36,7 +37,7 @@ int main(int, char**)
|
|||||||
// Create SDL window graphics context
|
// Create SDL window graphics context
|
||||||
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
||||||
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_GPU example", (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_GPU example", (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
@@ -59,7 +60,7 @@ int main(int, char**)
|
|||||||
printf("Error: SDL_ClaimWindowForGPUDevice(): %s\n", SDL_GetError());
|
printf("Error: SDL_ClaimWindowForGPUDevice(): %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SDL_SetGPUSwapchainParameters(gpu_device, window, SDL_GPU_SWAPCHAINCOMPOSITION_SDR, SDL_GPU_PRESENTMODE_MAILBOX);
|
SDL_SetGPUSwapchainParameters(gpu_device, window, SDL_GPU_SWAPCHAINCOMPOSITION_SDR, SDL_GPU_PRESENTMODE_VSYNC);
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
@@ -93,7 +94,9 @@ int main(int, char**)
|
|||||||
ImGui_ImplSDLGPU3_InitInfo init_info = {};
|
ImGui_ImplSDLGPU3_InitInfo init_info = {};
|
||||||
init_info.Device = gpu_device;
|
init_info.Device = gpu_device;
|
||||||
init_info.ColorTargetFormat = SDL_GetGPUSwapchainTextureFormat(gpu_device, window);
|
init_info.ColorTargetFormat = SDL_GetGPUSwapchainTextureFormat(gpu_device, window);
|
||||||
init_info.MSAASamples = SDL_GPU_SAMPLECOUNT_1;
|
init_info.MSAASamples = SDL_GPU_SAMPLECOUNT_1; // Only used in multi-viewports mode.
|
||||||
|
init_info.SwapchainComposition = SDL_GPU_SWAPCHAINCOMPOSITION_SDR; // Only used in multi-viewports mode.
|
||||||
|
init_info.PresentMode = SDL_GPU_PRESENTMODE_VSYNC;
|
||||||
ImGui_ImplSDLGPU3_Init(&init_info);
|
ImGui_ImplSDLGPU3_Init(&init_info);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
@@ -101,7 +104,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
@@ -165,7 +168,7 @@ int main(int, char**)
|
|||||||
ImGui::Checkbox("Another Window", &show_another_window);
|
ImGui::Checkbox("Another Window", &show_another_window);
|
||||||
|
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit4("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||||
|
|
||||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||||
counter++;
|
counter++;
|
||||||
@@ -194,7 +197,7 @@ int main(int, char**)
|
|||||||
SDL_GPUCommandBuffer* command_buffer = SDL_AcquireGPUCommandBuffer(gpu_device); // Acquire a GPU command buffer
|
SDL_GPUCommandBuffer* command_buffer = SDL_AcquireGPUCommandBuffer(gpu_device); // Acquire a GPU command buffer
|
||||||
|
|
||||||
SDL_GPUTexture* swapchain_texture;
|
SDL_GPUTexture* swapchain_texture;
|
||||||
SDL_AcquireGPUSwapchainTexture(command_buffer, window, &swapchain_texture, nullptr, nullptr); // Acquire a swapchain texture
|
SDL_WaitAndAcquireGPUSwapchainTexture(command_buffer, window, &swapchain_texture, nullptr, nullptr); // Acquire a swapchain texture
|
||||||
|
|
||||||
if (swapchain_texture != nullptr && !is_minimized)
|
if (swapchain_texture != nullptr && !is_minimized)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ int main(int, char**)
|
|||||||
// Create window with SDL_Renderer graphics context
|
// Create window with SDL_Renderer graphics context
|
||||||
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
||||||
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_Renderer example", (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_Renderer example", (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
@@ -78,7 +78,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ int main(int, char**)
|
|||||||
// Create window with Vulkan graphics context
|
// Create window with Vulkan graphics context
|
||||||
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
||||||
SDL_WindowFlags window_flags = SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
SDL_WindowFlags window_flags = SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+Vulkan example", (int)(1280 * main_scale), (int)(720 * main_scale), window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+Vulkan example", (int)(1280 * main_scale), (int)(800 * main_scale), window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
@@ -442,7 +442,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <GL/GL.h>
|
#include <GL/gl.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
// Data stored per platform window
|
// Data stored per platform window
|
||||||
@@ -72,11 +72,14 @@ static void Hook_Renderer_SwapBuffers(ImGuiViewport* viewport, void*)
|
|||||||
// Main code
|
// Main code
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
|
// Make process DPI aware and obtain main monitor scale
|
||||||
|
//ImGui_ImplWin32_EnableDpiAwareness(); // FIXME: This somehow doesn't work in the Win32+OpenGL example. Why?
|
||||||
|
float main_scale = ImGui_ImplWin32_GetDpiScaleForMonitor(::MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY));
|
||||||
|
|
||||||
// Create application window
|
// Create application window
|
||||||
//ImGui_ImplWin32_EnableDpiAwareness();
|
|
||||||
WNDCLASSEXW wc = { sizeof(wc), CS_OWNDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr };
|
WNDCLASSEXW wc = { sizeof(wc), CS_OWNDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr };
|
||||||
::RegisterClassExW(&wc);
|
::RegisterClassExW(&wc);
|
||||||
HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui Win32+OpenGL3 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, nullptr, nullptr, wc.hInstance, nullptr);
|
HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui Win32+OpenGL3 Example", WS_OVERLAPPEDWINDOW, 100, 100, (int)(1280 * main_scale), (int)(800 * main_scale), nullptr, nullptr, wc.hInstance, nullptr);
|
||||||
|
|
||||||
// Initialize OpenGL
|
// Initialize OpenGL
|
||||||
if (!CreateDeviceWGL(hwnd, &g_MainWindow))
|
if (!CreateDeviceWGL(hwnd, &g_MainWindow))
|
||||||
@@ -105,8 +108,14 @@ int main(int, char**)
|
|||||||
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.
|
// Setup scaling
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
|
style.FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
|
||||||
|
io.ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
|
||||||
|
io.ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
style.WindowRounding = 0.0f;
|
style.WindowRounding = 0.0f;
|
||||||
@@ -136,7 +145,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
@@ -352,11 +352,14 @@ static int ImGui_ImplWin32_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_ins
|
|||||||
// Main code
|
// Main code
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
|
// Make process DPI aware and obtain main monitor scale
|
||||||
|
ImGui_ImplWin32_EnableDpiAwareness();
|
||||||
|
float main_scale = ImGui_ImplWin32_GetDpiScaleForMonitor(::MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY));
|
||||||
|
|
||||||
// Create application window
|
// Create application window
|
||||||
//ImGui_ImplWin32_EnableDpiAwareness();
|
|
||||||
WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr };
|
WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr };
|
||||||
::RegisterClassExW(&wc);
|
::RegisterClassExW(&wc);
|
||||||
HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui Win32+Vulkan Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, nullptr, nullptr, wc.hInstance, nullptr);
|
HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui Win32+Vulkan Example", WS_OVERLAPPEDWINDOW, 100, 100, (int)(1280 * main_scale), (int)(800 * main_scale), nullptr, nullptr, wc.hInstance, nullptr);
|
||||||
|
|
||||||
ImVector<const char*> extensions;
|
ImVector<const char*> extensions;
|
||||||
extensions.push_back("VK_KHR_surface");
|
extensions.push_back("VK_KHR_surface");
|
||||||
@@ -379,7 +382,7 @@ int main(int, char**)
|
|||||||
// Show the window
|
// Show the window
|
||||||
// FIXME: Retrieve client size from window itself.
|
// FIXME: Retrieve client size from window itself.
|
||||||
ImGui_ImplVulkanH_Window* wd = &g_MainWindowData;
|
ImGui_ImplVulkanH_Window* wd = &g_MainWindowData;
|
||||||
SetupVulkanWindow(wd, surface, 1280, 800);
|
SetupVulkanWindow(wd, surface, (int)(1280 * main_scale), (int)(800 * main_scale));
|
||||||
::ShowWindow(hwnd, SW_SHOWDEFAULT);
|
::ShowWindow(hwnd, SW_SHOWDEFAULT);
|
||||||
::UpdateWindow(hwnd);
|
::UpdateWindow(hwnd);
|
||||||
|
|
||||||
@@ -398,8 +401,14 @@ int main(int, char**)
|
|||||||
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.
|
// Setup scaling
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
|
||||||
|
style.FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
|
||||||
|
io.ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
|
||||||
|
io.ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
style.WindowRounding = 0.0f;
|
style.WindowRounding = 0.0f;
|
||||||
@@ -433,7 +442,7 @@ int main(int, char**)
|
|||||||
// - 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.
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
// - Read 'docs/FONTS.md' for more instructions and details. If you like the default font but want it to scale better, consider using the 'ProggyVector' from the same author!
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
//style.FontSizeBase = 20.0f;
|
//style.FontSizeBase = 20.0f;
|
||||||
//io.Fonts->AddFontDefault();
|
//io.Fonts->AddFontDefault();
|
||||||
|
|||||||
132
imgui.h
132
imgui.h
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.92.1
|
// dear imgui, v1.92.3
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||||
#define IMGUI_VERSION "1.92.1"
|
#define IMGUI_VERSION "1.92.3"
|
||||||
#define IMGUI_VERSION_NUM 19210
|
#define IMGUI_VERSION_NUM 19230
|
||||||
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
||||||
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
||||||
#define IMGUI_HAS_VIEWPORT // In 'docking' WIP branch.
|
#define IMGUI_HAS_VIEWPORT // In 'docking' WIP branch.
|
||||||
@@ -102,8 +102,10 @@ Index of this file:
|
|||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
|
|
||||||
// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions.
|
// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions.
|
||||||
// (MSVC provides an equivalent mechanism via SAL Annotations but it would require the macros in a different
|
// (MSVC provides an equivalent mechanism via SAL Annotations but it requires the macros in a different
|
||||||
// location. e.g. #include <sal.h> + void myprintf(_Printf_format_string_ const char* format, ...))
|
// location. e.g. #include <sal.h> + void myprintf(_Printf_format_string_ const char* format, ...),
|
||||||
|
// and only works when using Code Analysis, rather than just normal compiling).
|
||||||
|
// (see https://github.com/ocornut/imgui/issues/8871 for a patch to enable this for MSVC's Code Analysis)
|
||||||
#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__MINGW32__) && !defined(__clang__)
|
#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__MINGW32__) && !defined(__clang__)
|
||||||
#define IM_FMTARGS(FMT) __attribute__((format(gnu_printf, FMT, FMT+1)))
|
#define IM_FMTARGS(FMT) __attribute__((format(gnu_printf, FMT, FMT+1)))
|
||||||
#define IM_FMTLIST(FMT) __attribute__((format(gnu_printf, FMT, 0)))
|
#define IM_FMTLIST(FMT) __attribute__((format(gnu_printf, FMT, 0)))
|
||||||
@@ -235,6 +237,7 @@ typedef int ImGuiTableBgTarget; // -> enum ImGuiTableBgTarget_ // Enum: A
|
|||||||
// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments.
|
// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments.
|
||||||
typedef int ImDrawFlags; // -> enum ImDrawFlags_ // Flags: for ImDrawList functions
|
typedef int ImDrawFlags; // -> enum ImDrawFlags_ // Flags: for ImDrawList functions
|
||||||
typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList instance
|
typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList instance
|
||||||
|
typedef int ImDrawTextFlags; // -> enum ImDrawTextFlags_ // Internal, do not use!
|
||||||
typedef int ImFontFlags; // -> enum ImFontFlags_ // Flags: for ImFont
|
typedef int ImFontFlags; // -> enum ImFontFlags_ // Flags: for ImFont
|
||||||
typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas
|
typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas
|
||||||
typedef int ImGuiBackendFlags; // -> enum ImGuiBackendFlags_ // Flags: for io.BackendFlags
|
typedef int ImGuiBackendFlags; // -> enum ImGuiBackendFlags_ // Flags: for io.BackendFlags
|
||||||
@@ -251,6 +254,7 @@ typedef int ImGuiInputFlags; // -> enum ImGuiInputFlags_ // Flags: f
|
|||||||
typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
|
typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
|
||||||
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag(), shared by all items
|
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag(), shared by all items
|
||||||
typedef int ImGuiKeyChord; // -> ImGuiKey | ImGuiMod_XXX // Flags: for IsKeyChordPressed(), Shortcut() etc. an ImGuiKey optionally OR-ed with one or more ImGuiMod_XXX values.
|
typedef int ImGuiKeyChord; // -> ImGuiKey | ImGuiMod_XXX // Flags: for IsKeyChordPressed(), Shortcut() etc. an ImGuiKey optionally OR-ed with one or more ImGuiMod_XXX values.
|
||||||
|
typedef int ImGuiListClipperFlags; // -> enum ImGuiListClipperFlags_// Flags: for ImGuiListClipper
|
||||||
typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
|
typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
|
||||||
typedef int ImGuiMultiSelectFlags; // -> enum ImGuiMultiSelectFlags_// Flags: for BeginMultiSelect()
|
typedef int ImGuiMultiSelectFlags; // -> enum ImGuiMultiSelectFlags_// Flags: for BeginMultiSelect()
|
||||||
typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
|
typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
|
||||||
@@ -322,7 +326,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
|
|||||||
// - When a Rendered Backend creates a texture, it store its native identifier into a ImTextureID value.
|
// - When a Rendered Backend creates a texture, it store its native identifier into a ImTextureID value.
|
||||||
// (e.g. Used by DX11 backend to a `ID3D11ShaderResourceView*`; Used by OpenGL backends to store `GLuint`;
|
// (e.g. Used by DX11 backend to a `ID3D11ShaderResourceView*`; Used by OpenGL backends to store `GLuint`;
|
||||||
// Used by SDLGPU backend to store a `SDL_GPUTextureSamplerBinding*`, etc.).
|
// Used by SDLGPU backend to store a `SDL_GPUTextureSamplerBinding*`, etc.).
|
||||||
// - User may submit their own textures to e.g. ImGui::Image() function by passing the same type.
|
// - User may submit their own textures to e.g. ImGui::Image() function by passing this value.
|
||||||
// - During the rendering loop, the Renderer Backend retrieve the ImTextureID, which stored inside a
|
// - During the rendering loop, the Renderer Backend retrieve the ImTextureID, which stored inside a
|
||||||
// ImTextureRef, which is stored inside a ImDrawCmd.
|
// ImTextureRef, which is stored inside a ImDrawCmd.
|
||||||
// - Compile-time type configuration:
|
// - Compile-time type configuration:
|
||||||
@@ -342,15 +346,17 @@ typedef ImU64 ImTextureID; // Default: store up to 64-bits (any pointer or
|
|||||||
#define ImTextureID_Invalid ((ImTextureID)0)
|
#define ImTextureID_Invalid ((ImTextureID)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ImTextureRef = higher-level identifier for a texture.
|
// ImTextureRef = higher-level identifier for a texture. Store a ImTextureID _or_ a ImTextureData*.
|
||||||
// The identifier is valid even before the texture has been uploaded to the GPU/graphics system.
|
// The identifier is valid even before the texture has been uploaded to the GPU/graphics system.
|
||||||
// This is what gets passed to functions such as `ImGui::Image()`, `ImDrawList::AddImage()`.
|
// This is what gets passed to functions such as `ImGui::Image()`, `ImDrawList::AddImage()`.
|
||||||
// This is what gets stored in draw commands (`ImDrawCmd`) to identify a texture during rendering.
|
// This is what gets stored in draw commands (`ImDrawCmd`) to identify a texture during rendering.
|
||||||
// - When a texture is created by user code (e.g. custom images), we directly stores the low-level ImTextureID.
|
// - When a texture is created by user code (e.g. custom images), we directly stores the low-level ImTextureID.
|
||||||
|
// Because of this, when displaying your own texture you are likely to ever only manage ImTextureID values on your side.
|
||||||
// - When a texture is created by the backend, we stores a ImTextureData* which becomes an indirection
|
// - When a texture is created by the backend, we stores a ImTextureData* which becomes an indirection
|
||||||
// to extract the ImTextureID value during rendering, after texture upload has happened.
|
// to extract the ImTextureID value during rendering, after texture upload has happened.
|
||||||
// - There is no constructor to create a ImTextureID from a ImTextureData* as we don't expect this
|
// - To create a ImTextureRef from a ImTextureData you can use ImTextureData::GetTexRef().
|
||||||
// to be useful to the end-user, and it would be erroneously called by many legacy code.
|
// We intentionally do not provide an ImTextureRef constructor for this: we don't expect this
|
||||||
|
// to be frequently useful to the end-user, and it would be erroneously called by many legacy code.
|
||||||
// - If you want to bind the current atlas when using custom rectangle, you can use io.Fonts->TexRef.
|
// - If you want to bind the current atlas when using custom rectangle, you can use io.Fonts->TexRef.
|
||||||
// - Binding generators for languages such as C (which don't have constructors), should provide a helper, e.g.
|
// - Binding generators for languages such as C (which don't have constructors), should provide a helper, e.g.
|
||||||
// inline ImTextureRef ImTextureRefFromID(ImTextureID tex_id) { ImTextureRef tex_ref = { ._TexData = NULL, .TexID = tex_id }; return tex_ref; }
|
// inline ImTextureRef ImTextureRefFromID(ImTextureID tex_id) { ImTextureRef tex_ref = { ._TexData = NULL, .TexID = tex_id }; return tex_ref; }
|
||||||
@@ -922,7 +928,7 @@ namespace ImGui
|
|||||||
IMGUI_API ImGuiTableSortSpecs* TableGetSortSpecs(); // get latest sort specs for the table (NULL if not sorting). Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable().
|
IMGUI_API ImGuiTableSortSpecs* TableGetSortSpecs(); // get latest sort specs for the table (NULL if not sorting). Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable().
|
||||||
IMGUI_API int TableGetColumnCount(); // return number of columns (value passed to BeginTable)
|
IMGUI_API int TableGetColumnCount(); // return number of columns (value passed to BeginTable)
|
||||||
IMGUI_API int TableGetColumnIndex(); // return current column index.
|
IMGUI_API int TableGetColumnIndex(); // return current column index.
|
||||||
IMGUI_API int TableGetRowIndex(); // return current row index.
|
IMGUI_API int TableGetRowIndex(); // return current row index (header rows are accounted for)
|
||||||
IMGUI_API const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column.
|
IMGUI_API const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column.
|
||||||
IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. Pass -1 to use current column.
|
IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. Pass -1 to use current column.
|
||||||
IMGUI_API void TableSetColumnEnabled(int column_n, bool v);// change user accessible enabled/disabled state of a column. Set to false to hide the column. User can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody)
|
IMGUI_API void TableSetColumnEnabled(int column_n, bool v);// change user accessible enabled/disabled state of a column. Set to false to hide the column. User can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody)
|
||||||
@@ -1079,8 +1085,8 @@ namespace ImGui
|
|||||||
|
|
||||||
// Inputs Utilities: Shortcut Testing & Routing [BETA]
|
// Inputs Utilities: Shortcut Testing & Routing [BETA]
|
||||||
// - ImGuiKeyChord = a ImGuiKey + optional ImGuiMod_Alt/ImGuiMod_Ctrl/ImGuiMod_Shift/ImGuiMod_Super.
|
// - ImGuiKeyChord = a ImGuiKey + optional ImGuiMod_Alt/ImGuiMod_Ctrl/ImGuiMod_Shift/ImGuiMod_Super.
|
||||||
// ImGuiKey_C // Accepted by functions taking ImGuiKey or ImGuiKeyChord arguments)
|
// ImGuiKey_C // Accepted by functions taking ImGuiKey or ImGuiKeyChord arguments
|
||||||
// ImGuiMod_Ctrl | ImGuiKey_C // Accepted by functions taking ImGuiKeyChord arguments)
|
// ImGuiMod_Ctrl | ImGuiKey_C // Accepted by functions taking ImGuiKeyChord arguments
|
||||||
// only ImGuiMod_XXX values are legal to combine with an ImGuiKey. You CANNOT combine two ImGuiKey values.
|
// only ImGuiMod_XXX values are legal to combine with an ImGuiKey. You CANNOT combine two ImGuiKey values.
|
||||||
// - The general idea is that several callers may register interest in a shortcut, and only one owner gets it.
|
// - The general idea is that several callers may register interest in a shortcut, and only one owner gets it.
|
||||||
// Parent -> call Shortcut(Ctrl+S) // When Parent is focused, Parent gets the shortcut.
|
// Parent -> call Shortcut(Ctrl+S) // When Parent is focused, Parent gets the shortcut.
|
||||||
@@ -1219,7 +1225,7 @@ enum ImGuiWindowFlags_
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::BeginChild()
|
// Flags for ImGui::BeginChild()
|
||||||
// (Legacy: bit 0 must always correspond to ImGuiChildFlags_Borders to be backward compatible with old API using 'bool border = false'.
|
// (Legacy: bit 0 must always correspond to ImGuiChildFlags_Borders to be backward compatible with old API using 'bool border = false'.)
|
||||||
// About using AutoResizeX/AutoResizeY flags:
|
// About using AutoResizeX/AutoResizeY flags:
|
||||||
// - May be combined with SetNextWindowSizeConstraints() to set a min/max size for each axis (see "Demo->Child->Auto-resize with Constraints").
|
// - May be combined with SetNextWindowSizeConstraints() to set a min/max size for each axis (see "Demo->Child->Auto-resize with Constraints").
|
||||||
// - Size measurement for a given axis is only performed when the child window is within visible boundaries, or is just appearing.
|
// - Size measurement for a given axis is only performed when the child window is within visible boundaries, or is just appearing.
|
||||||
@@ -1298,6 +1304,15 @@ enum ImGuiInputTextFlags_
|
|||||||
ImGuiInputTextFlags_CallbackResize = 1 << 22, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this)
|
ImGuiInputTextFlags_CallbackResize = 1 << 22, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this)
|
||||||
ImGuiInputTextFlags_CallbackEdit = 1 << 23, // Callback on any edit. Note that InputText() already returns true on edit + you can always use IsItemEdited(). The callback is useful to manipulate the underlying buffer while focus is active.
|
ImGuiInputTextFlags_CallbackEdit = 1 << 23, // Callback on any edit. Note that InputText() already returns true on edit + you can always use IsItemEdited(). The callback is useful to manipulate the underlying buffer while focus is active.
|
||||||
|
|
||||||
|
// Multi-line Word-Wrapping [BETA]
|
||||||
|
// - Not well tested yet. Please report any incorrect cursor movement, selection behavior etc. bug to https://github.com/ocornut/imgui/issues/3237.
|
||||||
|
// - Wrapping style is not ideal. Wrapping of long words/sections (e.g. words larger than total available width) may be particularly unpleasing.
|
||||||
|
// - Wrapping width needs to always account for the possibility of a vertical scrollbar.
|
||||||
|
// - It is much slower than regular text fields.
|
||||||
|
// Ballpark estimate of cost on my 2019 desktop PC: for a 100 KB text buffer: +~0.3 ms (Optimized) / +~1.0 ms (Debug build).
|
||||||
|
// The CPU cost is very roughly proportional to text length, so a 10 KB buffer should cost about ten times less.
|
||||||
|
ImGuiInputTextFlags_WordWrap = 1 << 24, // InputTextMultine(): word-wrap lines that are too long.
|
||||||
|
|
||||||
// Obsolete names
|
// Obsolete names
|
||||||
//ImGuiInputTextFlags_AlwaysInsertMode = ImGuiInputTextFlags_AlwaysOverwrite // [renamed in 1.82] name was not matching behavior
|
//ImGuiInputTextFlags_AlwaysInsertMode = ImGuiInputTextFlags_AlwaysOverwrite // [renamed in 1.82] name was not matching behavior
|
||||||
};
|
};
|
||||||
@@ -1374,6 +1389,7 @@ enum ImGuiSelectableFlags_
|
|||||||
ImGuiSelectableFlags_Disabled = 1 << 3, // Cannot be selected, display grayed out text
|
ImGuiSelectableFlags_Disabled = 1 << 3, // Cannot be selected, display grayed out text
|
||||||
ImGuiSelectableFlags_AllowOverlap = 1 << 4, // (WIP) Hit testing to allow subsequent widgets to overlap this one
|
ImGuiSelectableFlags_AllowOverlap = 1 << 4, // (WIP) Hit testing to allow subsequent widgets to overlap this one
|
||||||
ImGuiSelectableFlags_Highlight = 1 << 5, // Make the item be displayed as if it is hovered
|
ImGuiSelectableFlags_Highlight = 1 << 5, // Make the item be displayed as if it is hovered
|
||||||
|
ImGuiSelectableFlags_SelectOnNav = 1 << 6, // Auto-select when moved into, unless Ctrl is held. Automatic when in a BeginMultiSelect() block.
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
ImGuiSelectableFlags_DontClosePopups = ImGuiSelectableFlags_NoAutoClosePopups, // Renamed in 1.91.0
|
ImGuiSelectableFlags_DontClosePopups = ImGuiSelectableFlags_NoAutoClosePopups, // Renamed in 1.91.0
|
||||||
@@ -1407,10 +1423,17 @@ enum ImGuiTabBarFlags_
|
|||||||
ImGuiTabBarFlags_NoTabListScrollingButtons = 1 << 4, // Disable scrolling buttons (apply when fitting policy is ImGuiTabBarFlags_FittingPolicyScroll)
|
ImGuiTabBarFlags_NoTabListScrollingButtons = 1 << 4, // Disable scrolling buttons (apply when fitting policy is ImGuiTabBarFlags_FittingPolicyScroll)
|
||||||
ImGuiTabBarFlags_NoTooltip = 1 << 5, // Disable tooltips when hovering a tab
|
ImGuiTabBarFlags_NoTooltip = 1 << 5, // Disable tooltips when hovering a tab
|
||||||
ImGuiTabBarFlags_DrawSelectedOverline = 1 << 6, // Draw selected overline markers over selected tab
|
ImGuiTabBarFlags_DrawSelectedOverline = 1 << 6, // Draw selected overline markers over selected tab
|
||||||
ImGuiTabBarFlags_FittingPolicyResizeDown = 1 << 7, // Resize tabs when they don't fit
|
|
||||||
ImGuiTabBarFlags_FittingPolicyScroll = 1 << 8, // Add scroll buttons when tabs don't fit
|
// Fitting/Resize policy
|
||||||
ImGuiTabBarFlags_FittingPolicyMask_ = ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_FittingPolicyScroll,
|
ImGuiTabBarFlags_FittingPolicyMixed = 1 << 7, // Shrink down tabs when they don't fit, until width is style.TabMinWidthShrink, then enable scrolling buttons.
|
||||||
ImGuiTabBarFlags_FittingPolicyDefault_ = ImGuiTabBarFlags_FittingPolicyResizeDown,
|
ImGuiTabBarFlags_FittingPolicyShrink = 1 << 8, // Shrink down tabs when they don't fit
|
||||||
|
ImGuiTabBarFlags_FittingPolicyScroll = 1 << 9, // Enable scrolling buttons when tabs don't fit
|
||||||
|
ImGuiTabBarFlags_FittingPolicyMask_ = ImGuiTabBarFlags_FittingPolicyMixed | ImGuiTabBarFlags_FittingPolicyShrink | ImGuiTabBarFlags_FittingPolicyScroll,
|
||||||
|
ImGuiTabBarFlags_FittingPolicyDefault_ = ImGuiTabBarFlags_FittingPolicyMixed,
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
ImGuiTabBarFlags_FittingPolicyResizeDown = ImGuiTabBarFlags_FittingPolicyShrink, // Renamed in 1.92.2
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::BeginTabItem()
|
// Flags for ImGui::BeginTabItem()
|
||||||
@@ -1872,11 +1895,14 @@ enum ImGuiStyleVar_
|
|||||||
ImGuiStyleVar_CellPadding, // ImVec2 CellPadding
|
ImGuiStyleVar_CellPadding, // ImVec2 CellPadding
|
||||||
ImGuiStyleVar_ScrollbarSize, // float ScrollbarSize
|
ImGuiStyleVar_ScrollbarSize, // float ScrollbarSize
|
||||||
ImGuiStyleVar_ScrollbarRounding, // float ScrollbarRounding
|
ImGuiStyleVar_ScrollbarRounding, // float ScrollbarRounding
|
||||||
|
ImGuiStyleVar_ScrollbarPadding, // float ScrollbarPadding
|
||||||
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
|
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
|
||||||
ImGuiStyleVar_GrabRounding, // float GrabRounding
|
ImGuiStyleVar_GrabRounding, // float GrabRounding
|
||||||
ImGuiStyleVar_ImageBorderSize, // float ImageBorderSize
|
ImGuiStyleVar_ImageBorderSize, // float ImageBorderSize
|
||||||
ImGuiStyleVar_TabRounding, // float TabRounding
|
ImGuiStyleVar_TabRounding, // float TabRounding
|
||||||
ImGuiStyleVar_TabBorderSize, // float TabBorderSize
|
ImGuiStyleVar_TabBorderSize, // float TabBorderSize
|
||||||
|
ImGuiStyleVar_TabMinWidthBase, // float TabMinWidthBase
|
||||||
|
ImGuiStyleVar_TabMinWidthShrink, // float TabMinWidthShrink
|
||||||
ImGuiStyleVar_TabBarBorderSize, // float TabBarBorderSize
|
ImGuiStyleVar_TabBarBorderSize, // float TabBarBorderSize
|
||||||
ImGuiStyleVar_TabBarOverlineSize, // float TabBarOverlineSize
|
ImGuiStyleVar_TabBarOverlineSize, // float TabBarOverlineSize
|
||||||
ImGuiStyleVar_TableAngledHeadersAngle, // float TableAngledHeadersAngle
|
ImGuiStyleVar_TableAngledHeadersAngle, // float TableAngledHeadersAngle
|
||||||
@@ -2247,7 +2273,7 @@ struct ImVector
|
|||||||
// Constructors, destructor
|
// Constructors, destructor
|
||||||
inline ImVector() { Size = Capacity = 0; Data = NULL; }
|
inline ImVector() { Size = Capacity = 0; Data = NULL; }
|
||||||
inline ImVector(const ImVector<T>& src) { Size = Capacity = 0; Data = NULL; operator=(src); }
|
inline ImVector(const ImVector<T>& src) { Size = Capacity = 0; Data = NULL; operator=(src); }
|
||||||
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); if (src.Data) memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
|
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); if (Data && src.Data) memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
|
||||||
inline ~ImVector() { if (Data) IM_FREE(Data); } // Important: does not destruct anything
|
inline ~ImVector() { if (Data) IM_FREE(Data); } // Important: does not destruct anything
|
||||||
|
|
||||||
inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } } // Important: does not destruct anything
|
inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } } // Important: does not destruct anything
|
||||||
@@ -2337,12 +2363,15 @@ struct ImGuiStyle
|
|||||||
float ColumnsMinSpacing; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1).
|
float ColumnsMinSpacing; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1).
|
||||||
float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar.
|
float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar.
|
||||||
float ScrollbarRounding; // Radius of grab corners for scrollbar.
|
float ScrollbarRounding; // Radius of grab corners for scrollbar.
|
||||||
|
float ScrollbarPadding; // Padding of scrollbar grab within its frame (same for both axises).
|
||||||
float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar.
|
float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar.
|
||||||
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||||
float LogSliderDeadzone; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
|
float LogSliderDeadzone; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
|
||||||
float ImageBorderSize; // Thickness of border around Image() calls.
|
float ImageBorderSize; // Thickness of border around Image() calls.
|
||||||
float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
||||||
float TabBorderSize; // Thickness of border around tabs.
|
float TabBorderSize; // Thickness of border around tabs.
|
||||||
|
float TabMinWidthBase; // Minimum tab width, to make tabs larger than their contents. TabBar buttons are not affected.
|
||||||
|
float TabMinWidthShrink; // Minimum tab width after shrinking, when using ImGuiTabBarFlags_FittingPolicyMixed policy.
|
||||||
float TabCloseButtonMinWidthSelected; // -1: always visible. 0.0f: visible when hovered. >0.0f: visible when hovered if minimum width.
|
float TabCloseButtonMinWidthSelected; // -1: always visible. 0.0f: visible when hovered. >0.0f: visible when hovered if minimum width.
|
||||||
float TabCloseButtonMinWidthUnselected; // -1: always visible. 0.0f: visible when hovered. >0.0f: visible when hovered if minimum width. FLT_MAX: never show close button when unselected.
|
float TabCloseButtonMinWidthUnselected; // -1: always visible. 0.0f: visible when hovered. >0.0f: visible when hovered if minimum width. FLT_MAX: never show close button when unselected.
|
||||||
float TabBarBorderSize; // Thickness of tab-bar separator, which takes on the tab active color to denote focus.
|
float TabBarBorderSize; // Thickness of tab-bar separator, which takes on the tab active color to denote focus.
|
||||||
@@ -2360,6 +2389,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).
|
||||||
|
bool DockingNodeHasCloseButton; // Docking node has their own CloseButton() to close all docked windows.
|
||||||
float DockingSeparatorSize; // Thickness of resizing border between docked windows
|
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).
|
||||||
@@ -2456,6 +2486,7 @@ struct ImGuiIO
|
|||||||
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 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 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.
|
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.
|
||||||
|
bool ConfigViewportPlatformFocusSetsImGuiFocus; //= true // When a platform window is focused (e.g. using Alt+Tab, clicking Platform Title Bar), apply corresponding focus on imgui windows (may clear focus/active id from imgui windows location in other platform windows). In principle this is better enabled but we provide an opt-out, because some Linux window managers tend to eagerly focus windows (e.g. on mouse hover, or even a simple window pos/size change).
|
||||||
|
|
||||||
// DPI/Scaling options
|
// DPI/Scaling options
|
||||||
// This may keep evolving during 1.92.x releases. Expect some turbulence.
|
// This may keep evolving during 1.92.x releases. Expect some turbulence.
|
||||||
@@ -2510,7 +2541,7 @@ struct ImGuiIO
|
|||||||
// Option to enable various debug tools showing buttons that will call the IM_DEBUG_BREAK() macro.
|
// Option to enable various debug tools showing buttons that will call the IM_DEBUG_BREAK() macro.
|
||||||
// - The Item Picker tool will be available regardless of this being enabled, in order to maximize its discoverability.
|
// - The Item Picker tool will be available regardless of this being enabled, in order to maximize its discoverability.
|
||||||
// - Requires a debugger being attached, otherwise IM_DEBUG_BREAK() options will appear to crash your application.
|
// - Requires a debugger being attached, otherwise IM_DEBUG_BREAK() options will appear to crash your application.
|
||||||
// e.g. io.ConfigDebugIsDebuggerPresent = ::IsDebuggerPresent() on Win32, or refer to ImOsIsDebuggerPresent() imgui_test_engine/imgui_te_utils.cpp for a Unix compatible version).
|
// e.g. io.ConfigDebugIsDebuggerPresent = ::IsDebuggerPresent() on Win32, or refer to ImOsIsDebuggerPresent() imgui_test_engine/imgui_te_utils.cpp for a Unix compatible version.
|
||||||
bool ConfigDebugIsDebuggerPresent; // = false // Enable various tools calling IM_DEBUG_BREAK().
|
bool ConfigDebugIsDebuggerPresent; // = false // Enable various tools calling IM_DEBUG_BREAK().
|
||||||
|
|
||||||
// Tools to detect code submitting items with conflicting/duplicate IDs
|
// Tools to detect code submitting items with conflicting/duplicate IDs
|
||||||
@@ -2609,13 +2640,13 @@ struct ImGuiIO
|
|||||||
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).
|
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: Ctrl (non-macOS), Cmd (macOS)
|
||||||
bool KeyShift; // Keyboard modifier down: Shift
|
bool KeyShift; // Keyboard modifier down: Shift
|
||||||
bool KeyAlt; // Keyboard modifier down: Alt
|
bool KeyAlt; // Keyboard modifier down: Alt
|
||||||
bool KeySuper; // Keyboard modifier down: Cmd/Super/Windows
|
bool KeySuper; // Keyboard modifier down: Windows/Super (non-macOS), Ctrl (macOS)
|
||||||
|
|
||||||
// Other state maintained from data above + IO function calls
|
// Other state maintained from data above + IO function calls
|
||||||
ImGuiKeyChord KeyMods; // Key mods flags (any of ImGuiMod_Ctrl/ImGuiMod_Shift/ImGuiMod_Alt/ImGuiMod_Super flags, same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags. Read-only, updated by NewFrame()
|
ImGuiKeyChord KeyMods; // Key mods flags (any of ImGuiMod_Ctrl/ImGuiMod_Shift/ImGuiMod_Alt/ImGuiMod_Super flags, same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags). Read-only, updated by NewFrame()
|
||||||
ImGuiKeyData KeysData[ImGuiKey_NamedKey_COUNT];// Key state for all known keys. MUST use 'key - ImGuiKey_NamedKey_BEGIN' as index. Use IsKeyXXX() functions to access this.
|
ImGuiKeyData KeysData[ImGuiKey_NamedKey_COUNT];// Key state for all known keys. MUST use 'key - ImGuiKey_NamedKey_BEGIN' as index. Use IsKeyXXX() functions to access this.
|
||||||
bool WantCaptureMouseUnlessPopupClose; // Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
|
bool WantCaptureMouseUnlessPopupClose; // Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
|
||||||
ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
|
ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
|
||||||
@@ -2693,10 +2724,10 @@ struct ImGuiInputTextCallbackData
|
|||||||
ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only // [Completion,History]
|
ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only // [Completion,History]
|
||||||
char* Buf; // Text buffer // Read-write // [Resize] Can replace pointer / [Completion,History,Always] Only write to pointed data, don't replace the actual pointer!
|
char* Buf; // Text buffer // Read-write // [Resize] Can replace pointer / [Completion,History,Always] Only write to pointed data, don't replace the actual pointer!
|
||||||
int BufTextLen; // Text length (in bytes) // Read-write // [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length()
|
int BufTextLen; // Text length (in bytes) // Read-write // [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length()
|
||||||
int BufSize; // Buffer size (in bytes) = capacity+1 // Read-only // [Resize,Completion,History,Always] Include zero-terminator storage. In C land == ARRAYSIZE(my_char_array), in C++ land: string.capacity()+1
|
int BufSize; // Buffer size (in bytes) = capacity+1 // Read-only // [Resize,Completion,History,Always] Include zero-terminator storage. In C land: == ARRAYSIZE(my_char_array), in C++ land: string.capacity()+1
|
||||||
bool BufDirty; // Set if you modify Buf/BufTextLen! // Write // [Completion,History,Always]
|
bool BufDirty; // Set if you modify Buf/BufTextLen! // Write // [Completion,History,Always]
|
||||||
int CursorPos; // // Read-write // [Completion,History,Always]
|
int CursorPos; // // Read-write // [Completion,History,Always]
|
||||||
int SelectionStart; // // Read-write // [Completion,History,Always] == to SelectionEnd when no selection)
|
int SelectionStart; // // Read-write // [Completion,History,Always] == to SelectionEnd when no selection
|
||||||
int SelectionEnd; // // Read-write // [Completion,History,Always]
|
int SelectionEnd; // // Read-write // [Completion,History,Always]
|
||||||
|
|
||||||
// Helper functions for text manipulation.
|
// Helper functions for text manipulation.
|
||||||
@@ -2887,6 +2918,13 @@ struct ImGuiStorage
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Flags for ImGuiListClipper (currently not fully exposed in function calls: a future refactor will likely add this to ImGuiListClipper::Begin function equivalent)
|
||||||
|
enum ImGuiListClipperFlags_
|
||||||
|
{
|
||||||
|
ImGuiListClipperFlags_None = 0,
|
||||||
|
ImGuiListClipperFlags_NoSetTableRowCounters = 1 << 0, // [Internal] Disabled modifying table row counters. Avoid assumption that 1 clipper item == 1 table row.
|
||||||
|
};
|
||||||
|
|
||||||
// Helper: Manually clip large list of items.
|
// Helper: Manually clip large list of items.
|
||||||
// If you have lots evenly spaced items and you have random access to the list, you can perform coarse
|
// If you have lots evenly spaced items and you have random access to the list, you can perform coarse
|
||||||
// clipping based on visibility to only submit items that are in view.
|
// clipping based on visibility to only submit items that are in view.
|
||||||
@@ -2917,6 +2955,7 @@ struct ImGuiListClipper
|
|||||||
double StartPosY; // [Internal] Cursor position at the time of Begin() or after table frozen rows are all processed
|
double StartPosY; // [Internal] Cursor position at the time of Begin() or after table frozen rows are all processed
|
||||||
double StartSeekOffsetY; // [Internal] Account for frozen rows in a table and initial loss of precision in very large windows.
|
double StartSeekOffsetY; // [Internal] Account for frozen rows in a table and initial loss of precision in very large windows.
|
||||||
void* TempData; // [Internal] Internal data
|
void* TempData; // [Internal] Internal data
|
||||||
|
ImGuiListClipperFlags Flags; // [Internal] Flags, currently not yet well exposed.
|
||||||
|
|
||||||
// items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step, and you can call SeekCursorForItem() manually if you need)
|
// items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step, and you can call SeekCursorForItem() manually if you need)
|
||||||
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
|
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
|
||||||
@@ -3227,7 +3266,7 @@ struct ImDrawCmd
|
|||||||
|
|
||||||
// Since 1.83: returns ImTextureID associated with this draw call. Warning: DO NOT assume this is always same as 'TextureId' (we will change this function for an upcoming feature)
|
// Since 1.83: returns ImTextureID associated with this draw call. Warning: DO NOT assume this is always same as 'TextureId' (we will change this function for an upcoming feature)
|
||||||
// Since 1.92: removed ImDrawCmd::TextureId field, the getter function must be used!
|
// Since 1.92: removed ImDrawCmd::TextureId field, the getter function must be used!
|
||||||
inline ImTextureID GetTexID() const; // == (TexRef._TexData ? TexRef._TexData->TexID : TexRef._TexID
|
inline ImTextureID GetTexID() const; // == (TexRef._TexData ? TexRef._TexData->TexID : TexRef._TexID)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Vertex layout
|
// Vertex layout
|
||||||
@@ -3423,7 +3462,7 @@ struct ImDrawList
|
|||||||
|
|
||||||
// Advanced: Miscellaneous
|
// Advanced: Miscellaneous
|
||||||
IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
|
IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
|
||||||
IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer.
|
IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer. For multi-threaded rendering, consider using `imgui_threaded_rendering` from https://github.com/ocornut/imgui_club instead.
|
||||||
|
|
||||||
// Advanced: Channels
|
// Advanced: Channels
|
||||||
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives)
|
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives)
|
||||||
@@ -3479,7 +3518,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. (== CmdLists.Size). Exists for legacy reason.
|
int CmdListsCount; // == CmdLists.Size. (OBSOLETE: exists for legacy reasons). 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.
|
||||||
@@ -3544,7 +3583,7 @@ struct ImTextureRect
|
|||||||
struct ImTextureData
|
struct ImTextureData
|
||||||
{
|
{
|
||||||
//------------------------------------------ core / backend ---------------------------------------
|
//------------------------------------------ core / backend ---------------------------------------
|
||||||
int UniqueID; // w - // Sequential index to facilitate identifying a texture when debugging/printing. Unique per atlas.
|
int UniqueID; // w - // [DEBUG] Sequential index to facilitate identifying a texture when debugging/printing. Unique per atlas.
|
||||||
ImTextureStatus Status; // rw rw // ImTextureStatus_OK/_WantCreate/_WantUpdates/_WantDestroy. Always use SetStatus() to modify!
|
ImTextureStatus Status; // rw rw // ImTextureStatus_OK/_WantCreate/_WantUpdates/_WantDestroy. Always use SetStatus() to modify!
|
||||||
void* BackendUserData; // - rw // Convenience storage for backend. Some backends may have enough with TexID.
|
void* BackendUserData; // - rw // Convenience storage for backend. Some backends may have enough with TexID.
|
||||||
ImTextureID TexID; // r w // Backend-specific texture identifier. Always use SetTexID() to modify! The identifier will stored in ImDrawCmd::GetTexID() and passed to backend's RenderDrawData function.
|
ImTextureID TexID; // r w // Backend-specific texture identifier. Always use SetTexID() to modify! The identifier will stored in ImDrawCmd::GetTexID() and passed to backend's RenderDrawData function.
|
||||||
@@ -3562,7 +3601,7 @@ struct ImTextureData
|
|||||||
bool WantDestroyNextFrame; // rw - // [Internal] Queued to set ImTextureStatus_WantDestroy next frame. May still be used in the current frame.
|
bool WantDestroyNextFrame; // rw - // [Internal] Queued to set ImTextureStatus_WantDestroy next frame. May still be used in the current frame.
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
ImTextureData() { memset(this, 0, sizeof(*this)); TexID = ImTextureID_Invalid; }
|
ImTextureData() { memset(this, 0, sizeof(*this)); Status = ImTextureStatus_Destroyed; TexID = ImTextureID_Invalid; }
|
||||||
~ImTextureData() { DestroyPixels(); }
|
~ImTextureData() { DestroyPixels(); }
|
||||||
IMGUI_API void Create(ImTextureFormat format, int w, int h);
|
IMGUI_API void Create(ImTextureFormat format, int w, int h);
|
||||||
IMGUI_API void DestroyPixels();
|
IMGUI_API void DestroyPixels();
|
||||||
@@ -3724,7 +3763,7 @@ struct ImFontAtlas
|
|||||||
// - User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID().
|
// - User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID().
|
||||||
// - The pitch is always = Width * BytesPerPixels (1 or 4)
|
// - The pitch is always = Width * BytesPerPixels (1 or 4)
|
||||||
// - Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into
|
// - Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into
|
||||||
// the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste.
|
// the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste).
|
||||||
// - From 1.92 with backends supporting ImGuiBackendFlags_RendererHasTextures:
|
// - From 1.92 with backends supporting ImGuiBackendFlags_RendererHasTextures:
|
||||||
// - Calling Build(), GetTexDataAsAlpha8(), GetTexDataAsRGBA32() is not needed.
|
// - Calling Build(), GetTexDataAsAlpha8(), GetTexDataAsRGBA32() is not needed.
|
||||||
// - In backend: replace calls to ImFontAtlas::SetTexID() with calls to ImTextureData::SetTexID() after honoring texture creation.
|
// - In backend: replace calls to ImFontAtlas::SetTexID() with calls to ImTextureData::SetTexID() after honoring texture creation.
|
||||||
@@ -3839,7 +3878,7 @@ struct ImFontAtlas
|
|||||||
IMGUI_API ImFontAtlasRectId AddCustomRectFontGlyphForSize(ImFont* font, float font_size, ImWchar codepoint, int w, int h, float advance_x, const ImVec2& offset = ImVec2(0, 0)); // ADDED AND OBSOLETED in 1.92.X
|
IMGUI_API ImFontAtlasRectId AddCustomRectFontGlyphForSize(ImFont* font, float font_size, ImWchar codepoint, int w, int h, float advance_x, const ImVec2& offset = ImVec2(0, 0)); // ADDED AND OBSOLETED in 1.92.X
|
||||||
#endif
|
#endif
|
||||||
//unsigned int FontBuilderFlags; // OBSOLETED in 1.92.X: Renamed to FontLoaderFlags.
|
//unsigned int FontBuilderFlags; // OBSOLETED in 1.92.X: Renamed to FontLoaderFlags.
|
||||||
//int TexDesiredWidth; // OBSOLETED in 1.92.X: Force texture width before calling Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height)
|
//int TexDesiredWidth; // OBSOLETED in 1.92.X: Force texture width before calling Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
|
||||||
//typedef ImFontAtlasRect ImFontAtlasCustomRect; // OBSOLETED in 1.92.X
|
//typedef ImFontAtlasRect ImFontAtlasCustomRect; // OBSOLETED in 1.92.X
|
||||||
//typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+
|
//typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+
|
||||||
//typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+
|
//typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+
|
||||||
@@ -3864,9 +3903,10 @@ struct ImFontBaked
|
|||||||
float Ascent, Descent; // 4+4 // out // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize] (unscaled)
|
float Ascent, Descent; // 4+4 // out // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize] (unscaled)
|
||||||
unsigned int MetricsTotalSurface:26;// 3 // out // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
unsigned int MetricsTotalSurface:26;// 3 // out // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
||||||
unsigned int WantDestroy:1; // 0 // // Queued for destroy
|
unsigned int WantDestroy:1; // 0 // // Queued for destroy
|
||||||
unsigned int LockLoadingFallback:1; // 0 // //
|
unsigned int LoadNoFallback:1; // 0 // // Disable loading fallback in lower-level calls.
|
||||||
int LastUsedFrame; // 4 // // Record of that time this was bounds
|
unsigned int LoadNoRenderOnLayout:1;// 0 // // Enable a two-steps mode where CalcTextSize() calls will load AdvanceX *without* rendering/packing glyphs. Only advantagous if you know that the glyph is unlikely to actually be rendered, otherwise it is slower because we'd do one query on the first CalcTextSize and one query on the first Draw.
|
||||||
ImGuiID BakedId; // 4 //
|
int LastUsedFrame; // 4 // // Record of that time this was bounds
|
||||||
|
ImGuiID BakedId; // 4 // // Unique ID for this baked storage
|
||||||
ImFont* ContainerFont; // 4-8 // in // Parent font
|
ImFont* ContainerFont; // 4-8 // in // Parent font
|
||||||
void* FontLoaderDatas; // 4-8 // // Font loader opaque storage (per baked font * sources): single contiguous buffer allocated by imgui, passed to loader.
|
void* FontLoaderDatas; // 4-8 // // Font loader opaque storage (per baked font * sources): single contiguous buffer allocated by imgui, passed to loader.
|
||||||
|
|
||||||
@@ -3927,10 +3967,10 @@ struct ImFont
|
|||||||
// 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
|
// 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
|
||||||
// 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
|
// 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
|
||||||
IMGUI_API ImFontBaked* GetFontBaked(float font_size, float density = -1.0f); // Get or create baked data for given size
|
IMGUI_API ImFontBaked* GetFontBaked(float font_size, float density = -1.0f); // Get or create baked data for given size
|
||||||
IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL); // utf8
|
IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** out_remaining = NULL);
|
||||||
IMGUI_API const char* CalcWordWrapPosition(float size, const char* text, const char* text_end, float wrap_width);
|
IMGUI_API const char* CalcWordWrapPosition(float size, const char* text, const char* text_end, float wrap_width);
|
||||||
IMGUI_API void RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, ImWchar c, const ImVec4* cpu_fine_clip = NULL);
|
IMGUI_API void RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, ImWchar c, const ImVec4* cpu_fine_clip = NULL);
|
||||||
IMGUI_API void RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false);
|
IMGUI_API void RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, ImDrawTextFlags flags = 0);
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
inline const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) { return CalcWordWrapPosition(LegacySize * scale, text, text_end, wrap_width); }
|
inline const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) { return CalcWordWrapPosition(LegacySize * scale, text, text_end, wrap_width); }
|
||||||
#endif
|
#endif
|
||||||
@@ -4214,24 +4254,24 @@ struct ImGuiPlatformImeData
|
|||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
// OBSOLETED in 1.92.0 (from June 2025)
|
// OBSOLETED in 1.92.0 (from June 2025)
|
||||||
static inline void PushFont(ImFont* font) { PushFont(font, font ? font->LegacySize : 0.0f); }
|
inline void PushFont(ImFont* font) { PushFont(font, font ? font->LegacySize : 0.0f); }
|
||||||
IMGUI_API void SetWindowFontScale(float scale); // Set font scale factor for current window. Prefer using PushFont(NULL, style.FontSizeBase * factor) or use style.FontScaleMain to scale all windows.
|
IMGUI_API void SetWindowFontScale(float scale); // Set font scale factor for current window. Prefer using PushFont(NULL, style.FontSizeBase * factor) or use style.FontScaleMain to scale all windows.
|
||||||
// OBSOLETED in 1.91.9 (from February 2025)
|
// OBSOLETED in 1.91.9 (from February 2025)
|
||||||
IMGUI_API void Image(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col); // <-- 'border_col' was removed in favor of ImGuiCol_ImageBorder. If you use 'tint_col', use ImageWithBg() instead.
|
IMGUI_API void Image(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col); // <-- 'border_col' was removed in favor of ImGuiCol_ImageBorder. If you use 'tint_col', use ImageWithBg() instead.
|
||||||
// OBSOLETED in 1.91.0 (from July 2024)
|
// OBSOLETED in 1.91.0 (from July 2024)
|
||||||
static inline void PushButtonRepeat(bool repeat) { PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat); }
|
inline void PushButtonRepeat(bool repeat) { PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat); }
|
||||||
static inline void PopButtonRepeat() { PopItemFlag(); }
|
inline void PopButtonRepeat() { PopItemFlag(); }
|
||||||
static inline void PushTabStop(bool tab_stop) { PushItemFlag(ImGuiItemFlags_NoTabStop, !tab_stop); }
|
inline void PushTabStop(bool tab_stop) { PushItemFlag(ImGuiItemFlags_NoTabStop, !tab_stop); }
|
||||||
static inline void PopTabStop() { PopItemFlag(); }
|
inline void PopTabStop() { PopItemFlag(); }
|
||||||
IMGUI_API ImVec2 GetContentRegionMax(); // Content boundaries max (e.g. window boundaries including scrolling, or current column boundaries). You should never need this. Always use GetCursorScreenPos() and GetContentRegionAvail()!
|
IMGUI_API ImVec2 GetContentRegionMax(); // Content boundaries max (e.g. window boundaries including scrolling, or current column boundaries). You should never need this. Always use GetCursorScreenPos() and GetContentRegionAvail()!
|
||||||
IMGUI_API ImVec2 GetWindowContentRegionMin(); // Content boundaries min for the window (roughly (0,0)-Scroll), in window-local coordinates. You should never need this. Always use GetCursorScreenPos() and GetContentRegionAvail()!
|
IMGUI_API ImVec2 GetWindowContentRegionMin(); // Content boundaries min for the window (roughly (0,0)-Scroll), in window-local coordinates. You should never need this. Always use GetCursorScreenPos() and GetContentRegionAvail()!
|
||||||
IMGUI_API ImVec2 GetWindowContentRegionMax(); // Content boundaries max for the window (roughly (0,0)+Size-Scroll), in window-local coordinates. You should never need this. Always use GetCursorScreenPos() and GetContentRegionAvail()!
|
IMGUI_API ImVec2 GetWindowContentRegionMax(); // Content boundaries max for the window (roughly (0,0)+Size-Scroll), in window-local coordinates. You should never need this. Always use GetCursorScreenPos() and GetContentRegionAvail()!
|
||||||
// OBSOLETED in 1.90.0 (from September 2023)
|
// OBSOLETED in 1.90.0 (from September 2023)
|
||||||
static inline bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags window_flags = 0) { return BeginChild(id, size, ImGuiChildFlags_FrameStyle, window_flags); }
|
inline bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags window_flags = 0) { return BeginChild(id, size, ImGuiChildFlags_FrameStyle, window_flags); }
|
||||||
static inline void EndChildFrame() { EndChild(); }
|
inline void EndChildFrame() { EndChild(); }
|
||||||
//static inline bool BeginChild(const char* str_id, const ImVec2& size_arg, bool borders, ImGuiWindowFlags window_flags){ return BeginChild(str_id, size_arg, borders ? ImGuiChildFlags_Borders : ImGuiChildFlags_None, window_flags); } // Unnecessary as true == ImGuiChildFlags_Borders
|
//inline bool BeginChild(const char* str_id, const ImVec2& size_arg, bool borders, ImGuiWindowFlags window_flags){ return BeginChild(str_id, size_arg, borders ? ImGuiChildFlags_Borders : ImGuiChildFlags_None, window_flags); } // Unnecessary as true == ImGuiChildFlags_Borders
|
||||||
//static inline bool BeginChild(ImGuiID id, const ImVec2& size_arg, bool borders, ImGuiWindowFlags window_flags) { return BeginChild(id, size_arg, borders ? ImGuiChildFlags_Borders : ImGuiChildFlags_None, window_flags); } // Unnecessary as true == ImGuiChildFlags_Borders
|
//inline bool BeginChild(ImGuiID id, const ImVec2& size_arg, bool borders, ImGuiWindowFlags window_flags) { return BeginChild(id, size_arg, borders ? ImGuiChildFlags_Borders : ImGuiChildFlags_None, window_flags); } // Unnecessary as true == ImGuiChildFlags_Borders
|
||||||
static inline void ShowStackToolWindow(bool* p_open = NULL) { ShowIDStackToolWindow(p_open); }
|
inline void ShowStackToolWindow(bool* p_open = NULL) { ShowIDStackToolWindow(p_open); }
|
||||||
IMGUI_API bool Combo(const char* label, int* current_item, bool (*old_callback)(void* user_data, int idx, const char** out_text), void* user_data, int items_count, int popup_max_height_in_items = -1);
|
IMGUI_API bool Combo(const char* label, int* current_item, bool (*old_callback)(void* user_data, int idx, const char** out_text), void* user_data, int items_count, int popup_max_height_in_items = -1);
|
||||||
IMGUI_API bool ListBox(const char* label, int* current_item, bool (*old_callback)(void* user_data, int idx, const char** out_text), void* user_data, int items_count, int height_in_items = -1);
|
IMGUI_API bool ListBox(const char* label, int* current_item, bool (*old_callback)(void* user_data, int idx, const char** out_text), void* user_data, int items_count, int height_in_items = -1);
|
||||||
// OBSOLETED in 1.89.7 (from June 2023)
|
// OBSOLETED in 1.89.7 (from June 2023)
|
||||||
|
|||||||
101
imgui_demo.cpp
101
imgui_demo.cpp
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.92.1
|
// dear imgui, v1.92.3
|
||||||
// (demo code)
|
// (demo code)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@@ -556,6 +556,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the decoration right away).");
|
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::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::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the parenting right away).");
|
||||||
|
ImGui::Checkbox("io.ConfigViewportPlatformFocusSetsImGuiFocus", &io.ConfigViewportPlatformFocusSetsImGuiFocus);
|
||||||
|
ImGui::SameLine(); HelpMarker("When a platform window is focused (e.g. using Alt+Tab, clicking Platform Title Bar), apply corresponding focus on imgui windows (may clear focus/active id from imgui windows location in other platform windows). In principle this is better enabled but we provide an opt-out, because some Linux window managers tend to eagerly focus windows (e.g. on mouse hover, or even a simple window pos/size change).");
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2236,7 +2238,7 @@ static void DemoWindowWidgetsQueryingStatuses()
|
|||||||
);
|
);
|
||||||
ImGui::BulletText(
|
ImGui::BulletText(
|
||||||
"with Hovering Delay or Stationary test:\n"
|
"with Hovering Delay or Stationary test:\n"
|
||||||
"IsItemHovered() = = %d\n"
|
"IsItemHovered() = %d\n"
|
||||||
"IsItemHovered(_Stationary) = %d\n"
|
"IsItemHovered(_Stationary) = %d\n"
|
||||||
"IsItemHovered(_DelayShort) = %d\n"
|
"IsItemHovered(_DelayShort) = %d\n"
|
||||||
"IsItemHovered(_DelayNormal) = %d\n"
|
"IsItemHovered(_DelayNormal) = %d\n"
|
||||||
@@ -3310,7 +3312,7 @@ static void DemoWindowWidgetsSelectionAndMultiSelect(ImGuiDemoWindowData* demo_d
|
|||||||
ImGui::BeginTable("##Split", 2, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_NoPadOuterX);
|
ImGui::BeginTable("##Split", 2, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_NoPadOuterX);
|
||||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, 0.70f);
|
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, 0.70f);
|
||||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, 0.30f);
|
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, 0.30f);
|
||||||
//ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacingY, 0.0f);
|
//ImGui::PushStyleVarY(ImGuiStyleVar_ItemSpacing, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiListClipper clipper;
|
ImGuiListClipper clipper;
|
||||||
@@ -3460,6 +3462,18 @@ static void DemoWindowWidgetsSelectionAndMultiSelect(ImGuiDemoWindowData* demo_d
|
|||||||
// [SECTION] DemoWindowWidgetsTabs()
|
// [SECTION] DemoWindowWidgetsTabs()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void EditTabBarFittingPolicyFlags(ImGuiTabBarFlags* p_flags)
|
||||||
|
{
|
||||||
|
if ((*p_flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
|
||||||
|
*p_flags |= ImGuiTabBarFlags_FittingPolicyDefault_;
|
||||||
|
if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyMixed", p_flags, ImGuiTabBarFlags_FittingPolicyMixed))
|
||||||
|
*p_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyMixed);
|
||||||
|
if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyShrink", p_flags, ImGuiTabBarFlags_FittingPolicyShrink))
|
||||||
|
*p_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyShrink);
|
||||||
|
if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", p_flags, ImGuiTabBarFlags_FittingPolicyScroll))
|
||||||
|
*p_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll);
|
||||||
|
}
|
||||||
|
|
||||||
static void DemoWindowWidgetsTabs()
|
static void DemoWindowWidgetsTabs()
|
||||||
{
|
{
|
||||||
IMGUI_DEMO_MARKER("Widgets/Tabs");
|
IMGUI_DEMO_MARKER("Widgets/Tabs");
|
||||||
@@ -3502,12 +3516,7 @@ static void DemoWindowWidgetsTabs()
|
|||||||
ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
|
ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
|
||||||
ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", &tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton);
|
ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", &tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton);
|
||||||
ImGui::CheckboxFlags("ImGuiTabBarFlags_DrawSelectedOverline", &tab_bar_flags, ImGuiTabBarFlags_DrawSelectedOverline);
|
ImGui::CheckboxFlags("ImGuiTabBarFlags_DrawSelectedOverline", &tab_bar_flags, ImGuiTabBarFlags_DrawSelectedOverline);
|
||||||
if ((tab_bar_flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
|
EditTabBarFittingPolicyFlags(&tab_bar_flags);
|
||||||
tab_bar_flags |= ImGuiTabBarFlags_FittingPolicyDefault_;
|
|
||||||
if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
|
|
||||||
tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown);
|
|
||||||
if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
|
|
||||||
tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll);
|
|
||||||
|
|
||||||
// Tab Bar
|
// Tab Bar
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
@@ -3556,12 +3565,8 @@ static void DemoWindowWidgetsTabs()
|
|||||||
ImGui::Checkbox("Show Trailing TabItemButton()", &show_trailing_button);
|
ImGui::Checkbox("Show Trailing TabItemButton()", &show_trailing_button);
|
||||||
|
|
||||||
// Expose some other flags which are useful to showcase how they interact with Leading/Trailing tabs
|
// Expose some other flags which are useful to showcase how they interact with Leading/Trailing tabs
|
||||||
static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_AutoSelectNewTabs | ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_FittingPolicyResizeDown;
|
static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_AutoSelectNewTabs | ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_FittingPolicyShrink;
|
||||||
ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
|
EditTabBarFittingPolicyFlags(&tab_bar_flags);
|
||||||
if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
|
|
||||||
tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown);
|
|
||||||
if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
|
|
||||||
tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll);
|
|
||||||
|
|
||||||
if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
|
if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
|
||||||
{
|
{
|
||||||
@@ -3786,6 +3791,8 @@ static void DemoWindowWidgetsTextInput()
|
|||||||
static ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput;
|
static ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput;
|
||||||
HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp because we don't want to include <string> in here)");
|
HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp because we don't want to include <string> in here)");
|
||||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", &flags, ImGuiInputTextFlags_ReadOnly);
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", &flags, ImGuiInputTextFlags_ReadOnly);
|
||||||
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_WordWrap", &flags, ImGuiInputTextFlags_WordWrap);
|
||||||
|
ImGui::SameLine(); HelpMarker("Feature is currently in Beta. Please read comments in imgui.h");
|
||||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", &flags, ImGuiInputTextFlags_AllowTabInput);
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", &flags, ImGuiInputTextFlags_AllowTabInput);
|
||||||
ImGui::SameLine(); HelpMarker("When _AllowTabInput is set, passing through the widget with Tabbing doesn't automatically activate it, in order to also cycling through subsequent widgets.");
|
ImGui::SameLine(); HelpMarker("When _AllowTabInput is set, passing through the widget with Tabbing doesn't automatically activate it, in order to also cycling through subsequent widgets.");
|
||||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", &flags, ImGuiInputTextFlags_CtrlEnterForNewLine);
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", &flags, ImGuiInputTextFlags_CtrlEnterForNewLine);
|
||||||
@@ -3933,10 +3940,13 @@ static void DemoWindowWidgetsTextInput()
|
|||||||
// For this demo we are using ImVector as a string container.
|
// For this demo we are using ImVector as a string container.
|
||||||
// Note that because we need to store a terminating zero character, our size/capacity are 1 more
|
// Note that because we need to store a terminating zero character, our size/capacity are 1 more
|
||||||
// than usually reported by a typical string class.
|
// than usually reported by a typical string class.
|
||||||
|
static ImGuiInputTextFlags flags = ImGuiInputTextFlags_None;
|
||||||
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_WordWrap", &flags, ImGuiInputTextFlags_WordWrap);
|
||||||
|
|
||||||
static ImVector<char> my_str;
|
static ImVector<char> my_str;
|
||||||
if (my_str.empty())
|
if (my_str.empty())
|
||||||
my_str.push_back(0);
|
my_str.push_back(0);
|
||||||
Funcs::MyInputTextMultiline("##MyStr", &my_str, ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16));
|
Funcs::MyInputTextMultiline("##MyStr", &my_str, ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16), flags);
|
||||||
ImGui::Text("Data: %p\nSize: %d\nCapacity: %d", (void*)my_str.begin(), my_str.size(), my_str.capacity());
|
ImGui::Text("Data: %p\nSize: %d\nCapacity: %d", (void*)my_str.begin(), my_str.size(), my_str.capacity());
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
@@ -5260,7 +5270,7 @@ static void DemoWindowPopups()
|
|||||||
// Typical use for regular windows:
|
// Typical use for regular windows:
|
||||||
// bool my_tool_is_active = false; if (ImGui::Button("Open")) my_tool_is_active = true; [...] if (my_tool_is_active) Begin("My Tool", &my_tool_is_active) { [...] } End();
|
// bool my_tool_is_active = false; if (ImGui::Button("Open")) my_tool_is_active = true; [...] if (my_tool_is_active) Begin("My Tool", &my_tool_is_active) { [...] } End();
|
||||||
// Typical use for popups:
|
// Typical use for popups:
|
||||||
// if (ImGui::Button("Open")) ImGui::OpenPopup("MyPopup"); if (ImGui::BeginPopup("MyPopup") { [...] EndPopup(); }
|
// if (ImGui::Button("Open")) ImGui::OpenPopup("MyPopup"); if (ImGui::BeginPopup("MyPopup")) { [...] EndPopup(); }
|
||||||
|
|
||||||
// With popups we have to go through a library call (here OpenPopup) to manipulate the visibility state.
|
// With popups we have to go through a library call (here OpenPopup) to manipulate the visibility state.
|
||||||
// This may be a bit confusing at first but it should quickly make sense. Follow on the examples below.
|
// This may be a bit confusing at first but it should quickly make sense. Follow on the examples below.
|
||||||
@@ -5846,7 +5856,7 @@ static void DemoWindowTables()
|
|||||||
ImGui::SameLine(); ImGui::RadioButton("Text", &contents_type, CT_Text);
|
ImGui::SameLine(); ImGui::RadioButton("Text", &contents_type, CT_Text);
|
||||||
ImGui::SameLine(); ImGui::RadioButton("FillButton", &contents_type, CT_FillButton);
|
ImGui::SameLine(); ImGui::RadioButton("FillButton", &contents_type, CT_FillButton);
|
||||||
ImGui::Checkbox("Display headers", &display_headers);
|
ImGui::Checkbox("Display headers", &display_headers);
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appear in Headers");
|
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appear in Headers)");
|
||||||
PopStyleCompact();
|
PopStyleCompact();
|
||||||
|
|
||||||
if (ImGui::BeginTable("table1", 3, flags))
|
if (ImGui::BeginTable("table1", 3, flags))
|
||||||
@@ -7339,7 +7349,7 @@ static void DemoWindowTables()
|
|||||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags, ImGuiTableFlags_BordersH);
|
ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags, ImGuiTableFlags_BordersH);
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", &flags, ImGuiTableFlags_BordersOuterH);
|
ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", &flags, ImGuiTableFlags_BordersOuterH);
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", &flags, ImGuiTableFlags_BordersInnerH);
|
ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", &flags, ImGuiTableFlags_BordersInnerH);
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appear in Headers");
|
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appear in Headers)");
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appear in Headers)");
|
ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appear in Headers)");
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
@@ -8177,6 +8187,9 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVert): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert));
|
ImGui::Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVert): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert));
|
||||||
ImGui::Text("define: __cplusplus=%d", (int)__cplusplus);
|
ImGui::Text("define: __cplusplus=%d", (int)__cplusplus);
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
|
ImGui::Text("define: IMGUI_ENABLE_TEST_ENGINE");
|
||||||
|
#endif
|
||||||
#ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS");
|
ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS");
|
||||||
#endif
|
#endif
|
||||||
@@ -8320,22 +8333,34 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
|
// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
|
||||||
// Here we use the simplified Combo() api that packs items into a single literal string.
|
|
||||||
// Useful for quick combo boxes where the choices are known locally.
|
|
||||||
bool ImGui::ShowStyleSelector(const char* label)
|
bool ImGui::ShowStyleSelector(const char* label)
|
||||||
{
|
{
|
||||||
|
// FIXME: This is a bit tricky to get right as style are functions, they don't register a name nor the fact that one is active.
|
||||||
|
// So we keep track of last active one among our limited selection.
|
||||||
static int style_idx = -1;
|
static int style_idx = -1;
|
||||||
if (ImGui::Combo(label, &style_idx, "Dark\0Light\0Classic\0"))
|
const char* style_names[] = { "Dark", "Light", "Classic" };
|
||||||
|
bool ret = false;
|
||||||
|
if (ImGui::BeginCombo(label, (style_idx >= 0 && style_idx < IM_ARRAYSIZE(style_names)) ? style_names[style_idx] : ""))
|
||||||
{
|
{
|
||||||
switch (style_idx)
|
for (int n = 0; n < IM_ARRAYSIZE(style_names); n++)
|
||||||
{
|
{
|
||||||
case 0: ImGui::StyleColorsDark(); break;
|
if (ImGui::Selectable(style_names[n], style_idx == n, ImGuiSelectableFlags_SelectOnNav))
|
||||||
case 1: ImGui::StyleColorsLight(); break;
|
{
|
||||||
case 2: ImGui::StyleColorsClassic(); break;
|
style_idx = n;
|
||||||
|
ret = true;
|
||||||
|
switch (style_idx)
|
||||||
|
{
|
||||||
|
case 0: ImGui::StyleColorsDark(); break;
|
||||||
|
case 1: ImGui::StyleColorsLight(); break;
|
||||||
|
case 2: ImGui::StyleColorsClassic(); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (style_idx == n)
|
||||||
|
ImGui::SetItemDefaultFocus();
|
||||||
}
|
}
|
||||||
return true;
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
return false;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* GetTreeLinesFlagsName(ImGuiTreeNodeFlags flags)
|
static const char* GetTreeLinesFlagsName(ImGuiTreeNodeFlags flags)
|
||||||
@@ -8421,7 +8446,6 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
|
SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
|
||||||
SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
|
SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
|
||||||
SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
|
SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
|
||||||
SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
|
|
||||||
SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
|
SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
|
||||||
|
|
||||||
SeparatorText("Borders");
|
SeparatorText("Borders");
|
||||||
@@ -8435,16 +8459,22 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f");
|
SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f");
|
||||||
SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f");
|
SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f");
|
||||||
SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f");
|
SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f");
|
||||||
SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f");
|
|
||||||
SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f");
|
SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f");
|
||||||
|
|
||||||
|
SeparatorText("Scrollbar");
|
||||||
|
SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
|
||||||
|
SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f");
|
||||||
|
SliderFloat("ScrollbarPadding", &style.ScrollbarPadding, 0.0f, 10.0f, "%.0f");
|
||||||
|
|
||||||
SeparatorText("Tabs");
|
SeparatorText("Tabs");
|
||||||
SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f");
|
SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f");
|
||||||
SliderFloat("TabBarBorderSize", &style.TabBarBorderSize, 0.0f, 2.0f, "%.0f");
|
SliderFloat("TabBarBorderSize", &style.TabBarBorderSize, 0.0f, 2.0f, "%.0f");
|
||||||
SliderFloat("TabBarOverlineSize", &style.TabBarOverlineSize, 0.0f, 3.0f, "%.0f");
|
SliderFloat("TabBarOverlineSize", &style.TabBarOverlineSize, 0.0f, 3.0f, "%.0f");
|
||||||
SameLine(); HelpMarker("Overline is only drawn over the selected tab when ImGuiTabBarFlags_DrawSelectedOverline is set.");
|
SameLine(); HelpMarker("Overline is only drawn over the selected tab when ImGuiTabBarFlags_DrawSelectedOverline is set.");
|
||||||
DragFloat("TabCloseButtonMinWidthSelected", &style.TabCloseButtonMinWidthSelected, 0.1f, -1.0f, 100.0f, (style.TabCloseButtonMinWidthSelected < 0.0f) ? "%.0f (Always)" : "%.0f");
|
DragFloat("TabMinWidthBase", &style.TabMinWidthBase, 0.5f, 1.0f, 500.0f, "%.0f");
|
||||||
DragFloat("TabCloseButtonMinWidthUnselected", &style.TabCloseButtonMinWidthUnselected, 0.1f, -1.0f, 100.0f, (style.TabCloseButtonMinWidthUnselected < 0.0f) ? "%.0f (Always)" : "%.0f");
|
DragFloat("TabMinWidthShrink", &style.TabMinWidthShrink, 0.5f, 1.0f, 500.0f, "%0.f");
|
||||||
|
DragFloat("TabCloseButtonMinWidthSelected", &style.TabCloseButtonMinWidthSelected, 0.5f, -1.0f, 100.0f, (style.TabCloseButtonMinWidthSelected < 0.0f) ? "%.0f (Always)" : "%.0f");
|
||||||
|
DragFloat("TabCloseButtonMinWidthUnselected", &style.TabCloseButtonMinWidthUnselected, 0.5f, -1.0f, 100.0f, (style.TabCloseButtonMinWidthUnselected < 0.0f) ? "%.0f (Always)" : "%.0f");
|
||||||
SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f");
|
SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f");
|
||||||
|
|
||||||
SeparatorText("Tables");
|
SeparatorText("Tables");
|
||||||
@@ -8487,6 +8517,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
SliderFloat("ImageBorderSize", &style.ImageBorderSize, 0.0f, 1.0f, "%.0f");
|
SliderFloat("ImageBorderSize", &style.ImageBorderSize, 0.0f, 1.0f, "%.0f");
|
||||||
|
|
||||||
SeparatorText("Docking");
|
SeparatorText("Docking");
|
||||||
|
//SetCursorPosX(GetCursorPosX() + CalcItemWidth() - GetFrameHeight());
|
||||||
|
Checkbox("DockingNodeHasCloseButton", &style.DockingNodeHasCloseButton);
|
||||||
SliderFloat("DockingSeparatorSize", &style.DockingSeparatorSize, 0.0f, 12.0f, "%.0f");
|
SliderFloat("DockingSeparatorSize", &style.DockingSeparatorSize, 0.0f, 12.0f, "%.0f");
|
||||||
|
|
||||||
SeparatorText("Tooltips");
|
SeparatorText("Tooltips");
|
||||||
@@ -9382,10 +9414,9 @@ static void ShowExampleAppLayout(bool* p_open)
|
|||||||
ImGui::BeginChild("left pane", ImVec2(150, 0), ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeX);
|
ImGui::BeginChild("left pane", ImVec2(150, 0), ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeX);
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
// FIXME: Good candidate to use ImGuiSelectableFlags_SelectOnNav
|
|
||||||
char label[128];
|
char label[128];
|
||||||
sprintf(label, "MyObject %d", i);
|
sprintf(label, "MyObject %d", i);
|
||||||
if (ImGui::Selectable(label, selected == i))
|
if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SelectOnNav))
|
||||||
selected = i;
|
selected = i;
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
@@ -9737,7 +9768,7 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|||||||
IMGUI_DEMO_MARKER("Examples/Constrained Resizing window");
|
IMGUI_DEMO_MARKER("Examples/Constrained Resizing window");
|
||||||
if (ImGui::GetIO().KeyShift)
|
if (ImGui::GetIO().KeyShift)
|
||||||
{
|
{
|
||||||
// Display a dummy viewport (in your real app you would likely use ImageButton() to display a texture.
|
// Display a dummy viewport (in your real app you would likely use ImageButton() to display a texture)
|
||||||
ImVec2 avail_size = ImGui::GetContentRegionAvail();
|
ImVec2 avail_size = ImGui::GetContentRegionAvail();
|
||||||
ImVec2 pos = ImGui::GetCursorScreenPos();
|
ImVec2 pos = ImGui::GetCursorScreenPos();
|
||||||
ImGui::ColorButton("viewport", ImVec4(0.5f, 0.2f, 0.5f, 1.0f), ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop, avail_size);
|
ImGui::ColorButton("viewport", ImVec4(0.5f, 0.2f, 0.5f, 1.0f), ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop, avail_size);
|
||||||
|
|||||||
190
imgui_draw.cpp
190
imgui_draw.cpp
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.92.1
|
// dear imgui, v1.92.3
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -48,7 +48,7 @@ Index of this file:
|
|||||||
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
|
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
|
||||||
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
||||||
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
|
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
|
||||||
#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer)
|
#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Clang/GCC warnings with -Weverything
|
// Clang/GCC warnings with -Weverything
|
||||||
@@ -484,9 +484,10 @@ void ImDrawList::_ClearFreeMemory()
|
|||||||
_Splitter.ClearFreeMemory();
|
_Splitter.ClearFreeMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: For multi-threaded rendering, consider using `imgui_threaded_rendering` from https://github.com/ocornut/imgui_club
|
||||||
ImDrawList* ImDrawList::CloneOutput() const
|
ImDrawList* ImDrawList::CloneOutput() const
|
||||||
{
|
{
|
||||||
ImDrawList* dst = IM_NEW(ImDrawList(_Data));
|
ImDrawList* dst = IM_NEW(ImDrawList(NULL));
|
||||||
dst->CmdBuffer = CmdBuffer;
|
dst->CmdBuffer = CmdBuffer;
|
||||||
dst->IdxBuffer = IdxBuffer;
|
dst->IdxBuffer = IdxBuffer;
|
||||||
dst->VtxBuffer = VtxBuffer;
|
dst->VtxBuffer = VtxBuffer;
|
||||||
@@ -523,6 +524,7 @@ void ImDrawList::AddCallback(ImDrawCallback callback, void* userdata, size_t use
|
|||||||
{
|
{
|
||||||
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
|
IM_ASSERT(callback != NULL);
|
||||||
IM_ASSERT(curr_cmd->UserCallback == NULL);
|
IM_ASSERT(curr_cmd->UserCallback == NULL);
|
||||||
if (curr_cmd->ElemCount != 0)
|
if (curr_cmd->ElemCount != 0)
|
||||||
{
|
{
|
||||||
@@ -1723,7 +1725,7 @@ void ImDrawList::AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32
|
|||||||
clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z);
|
clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z);
|
||||||
clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w);
|
clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w);
|
||||||
}
|
}
|
||||||
font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip_rect != NULL);
|
font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, (cpu_fine_clip_rect != NULL) ? ImDrawTextFlags_CpuFineClip : ImDrawTextFlags_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
|
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
|
||||||
@@ -2318,17 +2320,16 @@ void ImDrawData::DeIndexAllBuffers()
|
|||||||
{
|
{
|
||||||
ImVector<ImDrawVert> new_vtx_buffer;
|
ImVector<ImDrawVert> new_vtx_buffer;
|
||||||
TotalVtxCount = TotalIdxCount = 0;
|
TotalVtxCount = TotalIdxCount = 0;
|
||||||
for (int i = 0; i < CmdListsCount; i++)
|
for (ImDrawList* draw_list : CmdLists)
|
||||||
{
|
{
|
||||||
ImDrawList* cmd_list = CmdLists[i];
|
if (draw_list->IdxBuffer.empty())
|
||||||
if (cmd_list->IdxBuffer.empty())
|
|
||||||
continue;
|
continue;
|
||||||
new_vtx_buffer.resize(cmd_list->IdxBuffer.Size);
|
new_vtx_buffer.resize(draw_list->IdxBuffer.Size);
|
||||||
for (int j = 0; j < cmd_list->IdxBuffer.Size; j++)
|
for (int j = 0; j < draw_list->IdxBuffer.Size; j++)
|
||||||
new_vtx_buffer[j] = cmd_list->VtxBuffer[cmd_list->IdxBuffer[j]];
|
new_vtx_buffer[j] = draw_list->VtxBuffer[draw_list->IdxBuffer[j]];
|
||||||
cmd_list->VtxBuffer.swap(new_vtx_buffer);
|
draw_list->VtxBuffer.swap(new_vtx_buffer);
|
||||||
cmd_list->IdxBuffer.resize(0);
|
draw_list->IdxBuffer.resize(0);
|
||||||
TotalVtxCount += cmd_list->VtxBuffer.Size;
|
TotalVtxCount += draw_list->VtxBuffer.Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2463,8 +2464,10 @@ const char* ImTextureDataGetFormatName(ImTextureFormat format)
|
|||||||
|
|
||||||
void ImTextureData::Create(ImTextureFormat format, int w, int h)
|
void ImTextureData::Create(ImTextureFormat format, int w, int h)
|
||||||
{
|
{
|
||||||
|
IM_ASSERT(Status == ImTextureStatus_Destroyed);
|
||||||
DestroyPixels();
|
DestroyPixels();
|
||||||
Format = format;
|
Format = format;
|
||||||
|
Status = ImTextureStatus_WantCreate;
|
||||||
Width = w;
|
Width = w;
|
||||||
Height = h;
|
Height = h;
|
||||||
BytesPerPixel = ImTextureDataGetFormatBytesPerPixel(format);
|
BytesPerPixel = ImTextureDataGetFormatBytesPerPixel(format);
|
||||||
@@ -2636,6 +2639,7 @@ ImFontAtlas::ImFontAtlas()
|
|||||||
TexMinHeight = 128;
|
TexMinHeight = 128;
|
||||||
TexMaxWidth = 8192;
|
TexMaxWidth = 8192;
|
||||||
TexMaxHeight = 8192;
|
TexMaxHeight = 8192;
|
||||||
|
TexRef._TexID = ImTextureID_Invalid;
|
||||||
RendererHasTextures = false; // Assumed false by default, as apps can call e.g Atlas::Build() after backend init and before ImGui can update.
|
RendererHasTextures = false; // Assumed false by default, as apps can call e.g Atlas::Build() after backend init and before ImGui can update.
|
||||||
TexNextUniqueID = 1;
|
TexNextUniqueID = 1;
|
||||||
FontNextUniqueID = 1;
|
FontNextUniqueID = 1;
|
||||||
@@ -2745,10 +2749,9 @@ void ImFontAtlasUpdateNewFrame(ImFontAtlas* atlas, int frame_count, bool rendere
|
|||||||
if (atlas->Builder == NULL) // This will only happen if fonts were not already loaded.
|
if (atlas->Builder == NULL) // This will only happen if fonts were not already loaded.
|
||||||
ImFontAtlasBuildMain(atlas);
|
ImFontAtlasBuildMain(atlas);
|
||||||
}
|
}
|
||||||
else // Legacy backend
|
// Legacy backend
|
||||||
{
|
if (!atlas->RendererHasTextures)
|
||||||
IM_ASSERT_USER_ERROR(atlas->TexIsBuilt, "Backend does not support ImGuiBackendFlags_RendererHasTextures, and font atlas is not built! Update backend OR make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8().");
|
IM_ASSERT_USER_ERROR(atlas->TexIsBuilt, "Backend does not support ImGuiBackendFlags_RendererHasTextures, and font atlas is not built! Update backend OR make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8().");
|
||||||
}
|
|
||||||
if (atlas->TexIsBuilt && atlas->Builder->PreloadedAllGlyphsRanges)
|
if (atlas->TexIsBuilt && atlas->Builder->PreloadedAllGlyphsRanges)
|
||||||
IM_ASSERT_USER_ERROR(atlas->RendererHasTextures == false, "Called ImFontAtlas::Build() before ImGuiBackendFlags_RendererHasTextures got set! With new backends: you don't need to call Build().");
|
IM_ASSERT_USER_ERROR(atlas->RendererHasTextures == false, "Called ImFontAtlas::Build() before ImGuiBackendFlags_RendererHasTextures got set! With new backends: you don't need to call Build().");
|
||||||
|
|
||||||
@@ -2803,8 +2806,9 @@ void ImFontAtlasUpdateNewFrame(ImFontAtlas* atlas, int frame_count, bool rendere
|
|||||||
}
|
}
|
||||||
else if (tex->WantDestroyNextFrame && tex->Status != ImTextureStatus_WantDestroy)
|
else if (tex->WantDestroyNextFrame && tex->Status != ImTextureStatus_WantDestroy)
|
||||||
{
|
{
|
||||||
// Request destroy. Keep bool as it allows us to keep track of things.
|
// Request destroy.
|
||||||
// We don't destroy pixels right away, as backend may have an in-flight copy from RAM.
|
// - Keep bool to true in order to differentiate a planned destroy vs a destroy decided by the backend.
|
||||||
|
// - We don't destroy pixels right away, as backend may have an in-flight copy from RAM.
|
||||||
IM_ASSERT(tex->Status == ImTextureStatus_OK || tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates);
|
IM_ASSERT(tex->Status == ImTextureStatus_OK || tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates);
|
||||||
tex->Status = ImTextureStatus_WantDestroy;
|
tex->Status = ImTextureStatus_WantDestroy;
|
||||||
}
|
}
|
||||||
@@ -2960,7 +2964,7 @@ void ImFontAtlasTextureBlockQueueUpload(ImFontAtlas* atlas, ImTextureData* tex,
|
|||||||
tex->UsedRect.h = (unsigned short)(ImMax(tex->UsedRect.y + tex->UsedRect.h, req.y + req.h) - tex->UsedRect.y);
|
tex->UsedRect.h = (unsigned short)(ImMax(tex->UsedRect.y + tex->UsedRect.h, req.y + req.h) - tex->UsedRect.y);
|
||||||
atlas->TexIsBuilt = false;
|
atlas->TexIsBuilt = false;
|
||||||
|
|
||||||
// No need to queue if status is _WantCreate
|
// No need to queue if status is == ImTextureStatus_WantCreate
|
||||||
if (tex->Status == ImTextureStatus_OK || tex->Status == ImTextureStatus_WantUpdates)
|
if (tex->Status == ImTextureStatus_OK || tex->Status == ImTextureStatus_WantUpdates)
|
||||||
{
|
{
|
||||||
tex->Status = ImTextureStatus_WantUpdates;
|
tex->Status = ImTextureStatus_WantUpdates;
|
||||||
@@ -3029,7 +3033,7 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg_in)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
IM_ASSERT(Fonts.Size > 0 && "Cannot use MergeMode for the first font"); // When using MergeMode make sure that a font has already been added before. You can use ImGui::GetIO().Fonts->AddFontDefault() to add the default imgui font.
|
IM_ASSERT(Fonts.Size > 0 && "Cannot use MergeMode for the first font"); // When using MergeMode make sure that a font has already been added before. You can use ImGui::GetIO().Fonts->AddFontDefault() to add the default imgui font.
|
||||||
font = Fonts.back();
|
font = font_cfg_in->DstFont ? font_cfg_in->DstFont : Fonts.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to list
|
// Add to list
|
||||||
@@ -3100,6 +3104,7 @@ static const char* GetDefaultCompressedFontDataTTF(int* out_size);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Load embedded ProggyClean.ttf at size 13, disable oversampling
|
// Load embedded ProggyClean.ttf at size 13, disable oversampling
|
||||||
|
// If you want a similar font which may be better scaled, consider using ProggyVector from the same author!
|
||||||
ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
||||||
{
|
{
|
||||||
#ifndef IMGUI_DISABLE_DEFAULT_FONT
|
#ifndef IMGUI_DISABLE_DEFAULT_FONT
|
||||||
@@ -3118,9 +3123,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
|||||||
|
|
||||||
int ttf_compressed_size = 0;
|
int ttf_compressed_size = 0;
|
||||||
const char* ttf_compressed = GetDefaultCompressedFontDataTTF(&ttf_compressed_size);
|
const char* ttf_compressed = GetDefaultCompressedFontDataTTF(&ttf_compressed_size);
|
||||||
const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault();
|
return AddFontFromMemoryCompressedTTF(ttf_compressed, ttf_compressed_size, font_cfg.SizePixels, &font_cfg);
|
||||||
ImFont* font = AddFontFromMemoryCompressedTTF(ttf_compressed, ttf_compressed_size, font_cfg.SizePixels, &font_cfg, glyph_ranges);
|
|
||||||
return font;
|
|
||||||
#else
|
#else
|
||||||
IM_ASSERT(0 && "AddFontDefault() disabled in this build.");
|
IM_ASSERT(0 && "AddFontDefault() disabled in this build.");
|
||||||
IM_UNUSED(font_cfg_template);
|
IM_UNUSED(font_cfg_template);
|
||||||
@@ -3367,11 +3370,7 @@ void ImFontAtlasBuildMain(ImFontAtlas* atlas)
|
|||||||
{
|
{
|
||||||
IM_ASSERT(!atlas->Locked && "Cannot modify a locked ImFontAtlas!");
|
IM_ASSERT(!atlas->Locked && "Cannot modify a locked ImFontAtlas!");
|
||||||
if (atlas->TexData && atlas->TexData->Format != atlas->TexDesiredFormat)
|
if (atlas->TexData && atlas->TexData->Format != atlas->TexDesiredFormat)
|
||||||
{
|
ImFontAtlasBuildClear(atlas);
|
||||||
ImVec2i new_tex_size = ImFontAtlasTextureGetSizeEstimate(atlas);
|
|
||||||
ImFontAtlasBuildDestroy(atlas);
|
|
||||||
ImFontAtlasTextureAdd(atlas, new_tex_size.x, new_tex_size.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (atlas->Builder == NULL)
|
if (atlas->Builder == NULL)
|
||||||
ImFontAtlasBuildInit(atlas);
|
ImFontAtlasBuildInit(atlas);
|
||||||
@@ -3977,7 +3976,6 @@ ImTextureData* ImFontAtlasTextureAdd(ImFontAtlas* atlas, int w, int h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_tex->Create(atlas->TexDesiredFormat, w, h);
|
new_tex->Create(atlas->TexDesiredFormat, w, h);
|
||||||
new_tex->Status = ImTextureStatus_WantCreate;
|
|
||||||
atlas->TexIsBuilt = false;
|
atlas->TexIsBuilt = false;
|
||||||
|
|
||||||
ImFontAtlasBuildSetTexture(atlas, new_tex);
|
ImFontAtlasBuildSetTexture(atlas, new_tex);
|
||||||
@@ -4302,6 +4300,8 @@ void ImFontAtlasPackDiscardRect(ImFontAtlas* atlas, ImFontAtlasRectId id)
|
|||||||
index_entry->IsUsed = false;
|
index_entry->IsUsed = false;
|
||||||
index_entry->TargetIndex = builder->RectsIndexFreeListStart;
|
index_entry->TargetIndex = builder->RectsIndexFreeListStart;
|
||||||
index_entry->Generation++;
|
index_entry->Generation++;
|
||||||
|
if (index_entry->Generation == 0)
|
||||||
|
index_entry->Generation++; // Keep non-zero on overflow
|
||||||
|
|
||||||
const int pack_padding = atlas->TexGlyphPadding;
|
const int pack_padding = atlas->TexGlyphPadding;
|
||||||
builder->RectsIndexFreeListStart = index_idx;
|
builder->RectsIndexFreeListStart = index_idx;
|
||||||
@@ -4381,6 +4381,7 @@ ImTextureRect* ImFontAtlasPackGetRectSafe(ImFontAtlas* atlas, ImFontAtlasRectId
|
|||||||
if (atlas->Builder == NULL)
|
if (atlas->Builder == NULL)
|
||||||
ImFontAtlasBuildInit(atlas);
|
ImFontAtlasBuildInit(atlas);
|
||||||
ImFontAtlasBuilder* builder = (ImFontAtlasBuilder*)atlas->Builder;
|
ImFontAtlasBuilder* builder = (ImFontAtlasBuilder*)atlas->Builder;
|
||||||
|
IM_MSVC_WARNING_SUPPRESS(28182); // Static Analysis false positive "warning C28182: Dereferencing NULL pointer 'builder'"
|
||||||
if (index_idx >= builder->RectsIndex.Size)
|
if (index_idx >= builder->RectsIndex.Size)
|
||||||
return NULL;
|
return NULL;
|
||||||
ImFontAtlasRectEntry* index_entry = &builder->RectsIndex[index_idx];
|
ImFontAtlasRectEntry* index_entry = &builder->RectsIndex[index_idx];
|
||||||
@@ -4423,7 +4424,7 @@ static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codep
|
|||||||
if (atlas->Locked || (font->Flags & ImFontFlags_NoLoadGlyphs))
|
if (atlas->Locked || (font->Flags & ImFontFlags_NoLoadGlyphs))
|
||||||
{
|
{
|
||||||
// Lazily load fallback glyph
|
// Lazily load fallback glyph
|
||||||
if (baked->FallbackGlyphIndex == -1 && baked->LockLoadingFallback == 0)
|
if (baked->FallbackGlyphIndex == -1 && baked->LoadNoFallback == 0)
|
||||||
ImFontAtlasBuildSetupFontBakedFallback(baked);
|
ImFontAtlasBuildSetupFontBakedFallback(baked);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -4475,7 +4476,7 @@ static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codep
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lazily load fallback glyph
|
// Lazily load fallback glyph
|
||||||
if (baked->LockLoadingFallback)
|
if (baked->LoadNoFallback)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (baked->FallbackGlyphIndex == -1)
|
if (baked->FallbackGlyphIndex == -1)
|
||||||
ImFontAtlasBuildSetupFontBakedFallback(baked);
|
ImFontAtlasBuildSetupFontBakedFallback(baked);
|
||||||
@@ -4489,7 +4490,7 @@ static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codep
|
|||||||
|
|
||||||
static float ImFontBaked_BuildLoadGlyphAdvanceX(ImFontBaked* baked, ImWchar codepoint)
|
static float ImFontBaked_BuildLoadGlyphAdvanceX(ImFontBaked* baked, ImWchar codepoint)
|
||||||
{
|
{
|
||||||
if (baked->Size >= IMGUI_FONT_SIZE_THRESHOLD_FOR_LOADADVANCEXONLYMODE)
|
if (baked->Size >= IMGUI_FONT_SIZE_THRESHOLD_FOR_LOADADVANCEXONLYMODE || baked->LoadNoRenderOnLayout)
|
||||||
{
|
{
|
||||||
// First load AdvanceX value used by CalcTextSize() API then load the rest when loaded by drawing API.
|
// First load AdvanceX value used by CalcTextSize() API then load the rest when loaded by drawing API.
|
||||||
float only_advance_x = 0.0f;
|
float only_advance_x = 0.0f;
|
||||||
@@ -4524,16 +4525,16 @@ void ImFontAtlasDebugLogTextureRequests(ImFontAtlas* atlas)
|
|||||||
if (tex->Status == ImTextureStatus_WantCreate)
|
if (tex->Status == ImTextureStatus_WantCreate)
|
||||||
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: create %dx%d\n", tex->UniqueID, tex->Width, tex->Height);
|
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: create %dx%d\n", tex->UniqueID, tex->Width, tex->Height);
|
||||||
else if (tex->Status == ImTextureStatus_WantDestroy)
|
else if (tex->Status == ImTextureStatus_WantDestroy)
|
||||||
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: destroy %dx%d, texid=0x%" IM_PRIX64 ", backend_data=%p\n", tex->UniqueID, tex->Width, tex->Height, tex->TexID, tex->BackendUserData);
|
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: destroy %dx%d, texid=0x%" IM_PRIX64 ", backend_data=%p\n", tex->UniqueID, tex->Width, tex->Height, IM_TEXTUREID_TO_U64(tex->TexID), tex->BackendUserData);
|
||||||
else if (tex->Status == ImTextureStatus_WantUpdates)
|
else if (tex->Status == ImTextureStatus_WantUpdates)
|
||||||
{
|
{
|
||||||
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: update %d regions, texid=0x%" IM_PRIX64 ", backend_data=0x%" IM_PRIX64 "\n", tex->UniqueID, tex->Updates.Size, tex->TexID, (ImU64)(intptr_t)tex->BackendUserData);
|
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: update %d regions, texid=0x%" IM_PRIX64 ", backend_data=0x%" IM_PRIX64 "\n", tex->UniqueID, tex->Updates.Size, IM_TEXTUREID_TO_U64(tex->TexID), (ImU64)(intptr_t)tex->BackendUserData);
|
||||||
for (const ImTextureRect& r : tex->Updates)
|
for (const ImTextureRect& r : tex->Updates)
|
||||||
{
|
{
|
||||||
IM_UNUSED(r);
|
IM_UNUSED(r);
|
||||||
IM_ASSERT(r.x >= 0 && r.y >= 0);
|
IM_ASSERT(r.x >= 0 && r.y >= 0);
|
||||||
IM_ASSERT(r.x + r.w <= tex->Width && r.y + r.h <= tex->Height); // In theory should subtract PackPadding but it's currently part of atlas and mid-frame change would wreck assert.
|
IM_ASSERT(r.x + r.w <= tex->Width && r.y + r.h <= tex->Height); // In theory should subtract PackPadding but it's currently part of atlas and mid-frame change would wreck assert.
|
||||||
//IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: update (% 4d..%-4d)->(% 4d..%-4d), texid=0x%" IM_PRIX64 ", backend_data=0x%" IM_PRIX64 "\n", tex->UniqueID, r.x, r.y, r.x + r.w, r.y + r.h, tex->TexID, (ImU64)(intptr_t)tex->BackendUserData);
|
//IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: update (% 4d..%-4d)->(% 4d..%-4d), texid=0x%" IM_PRIX64 ", backend_data=0x%" IM_PRIX64 "\n", tex->UniqueID, r.x, r.y, r.x + r.w, r.y + r.h, IM_TEXTUREID_TO_U64(tex->TexID), (ImU64)(intptr_t)tex->BackendUserData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4578,15 +4579,16 @@ static bool ImGui_ImplStbTrueType_FontSrcInit(ImFontAtlas* atlas, ImFontConfig*
|
|||||||
}
|
}
|
||||||
src->FontLoaderData = bd_font_data;
|
src->FontLoaderData = bd_font_data;
|
||||||
|
|
||||||
|
const float ref_size = src->DstFont->Sources[0]->SizePixels;
|
||||||
if (src->MergeMode && src->SizePixels == 0.0f)
|
if (src->MergeMode && src->SizePixels == 0.0f)
|
||||||
src->SizePixels = src->DstFont->Sources[0]->SizePixels;
|
src->SizePixels = ref_size;
|
||||||
|
|
||||||
if (src->SizePixels >= 0.0f)
|
if (src->SizePixels >= 0.0f)
|
||||||
bd_font_data->ScaleFactor = stbtt_ScaleForPixelHeight(&bd_font_data->FontInfo, 1.0f);
|
bd_font_data->ScaleFactor = stbtt_ScaleForPixelHeight(&bd_font_data->FontInfo, 1.0f);
|
||||||
else
|
else
|
||||||
bd_font_data->ScaleFactor = stbtt_ScaleForMappingEmToPixels(&bd_font_data->FontInfo, 1.0f);
|
bd_font_data->ScaleFactor = stbtt_ScaleForMappingEmToPixels(&bd_font_data->FontInfo, 1.0f);
|
||||||
if (src->MergeMode && src->SizePixels != 0.0f)
|
if (src->MergeMode && src->SizePixels != 0.0f && ref_size != 0.0f)
|
||||||
bd_font_data->ScaleFactor *= src->SizePixels / src->DstFont->Sources[0]->SizePixels; // FIXME-NEWATLAS: Should tidy up that a bit
|
bd_font_data->ScaleFactor *= src->SizePixels / ref_size; // FIXME-NEWATLAS: Should tidy up that a bit
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -4685,15 +4687,12 @@ static bool ImGui_ImplStbTrueType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontC
|
|||||||
builder->TempBuffer.resize(w * h * 1);
|
builder->TempBuffer.resize(w * h * 1);
|
||||||
unsigned char* bitmap_pixels = builder->TempBuffer.Data;
|
unsigned char* bitmap_pixels = builder->TempBuffer.Data;
|
||||||
memset(bitmap_pixels, 0, w * h * 1);
|
memset(bitmap_pixels, 0, w * h * 1);
|
||||||
stbtt_MakeGlyphBitmapSubpixel(&bd_font_data->FontInfo, bitmap_pixels, r->w - oversample_h + 1, r->h - oversample_v + 1, w,
|
|
||||||
scale_for_raster_x, scale_for_raster_y, 0, 0, glyph_index);
|
|
||||||
|
|
||||||
// Oversampling
|
// Render with oversampling
|
||||||
// (those functions conveniently assert if pixels are not cleared, which is another safety layer)
|
// (those functions conveniently assert if pixels are not cleared, which is another safety layer)
|
||||||
if (oversample_h > 1)
|
float sub_x, sub_y;
|
||||||
stbtt__h_prefilter(bitmap_pixels, r->w, r->h, r->w, oversample_h);
|
stbtt_MakeGlyphBitmapSubpixelPrefilter(&bd_font_data->FontInfo, bitmap_pixels, w, h, w,
|
||||||
if (oversample_v > 1)
|
scale_for_raster_x, scale_for_raster_y, 0, 0, oversample_h, oversample_v, &sub_x, &sub_y, glyph_index);
|
||||||
stbtt__v_prefilter(bitmap_pixels, r->w, r->h, r->w, oversample_v);
|
|
||||||
|
|
||||||
const float ref_size = baked->ContainerFont->Sources[0]->SizePixels;
|
const float ref_size = baked->ContainerFont->Sources[0]->SizePixels;
|
||||||
const float offsets_scale = (ref_size != 0.0f) ? (baked->Size / ref_size) : 1.0f;
|
const float offsets_scale = (ref_size != 0.0f) ? (baked->Size / ref_size) : 1.0f;
|
||||||
@@ -4703,8 +4702,8 @@ static bool ImGui_ImplStbTrueType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontC
|
|||||||
font_off_x = IM_ROUND(font_off_x);
|
font_off_x = IM_ROUND(font_off_x);
|
||||||
if (src->PixelSnapV)
|
if (src->PixelSnapV)
|
||||||
font_off_y = IM_ROUND(font_off_y);
|
font_off_y = IM_ROUND(font_off_y);
|
||||||
font_off_x += stbtt__oversample_shift(oversample_h);
|
font_off_x += sub_x;
|
||||||
font_off_y += stbtt__oversample_shift(oversample_v) + IM_ROUND(baked->Ascent);
|
font_off_y += sub_y + IM_ROUND(baked->Ascent);
|
||||||
float recip_h = 1.0f / (oversample_h * rasterizer_density);
|
float recip_h = 1.0f / (oversample_h * rasterizer_density);
|
||||||
float recip_v = 1.0f / (oversample_v * rasterizer_density);
|
float recip_v = 1.0f / (oversample_v * rasterizer_density);
|
||||||
|
|
||||||
@@ -5231,9 +5230,9 @@ ImFontGlyph* ImFontBaked::FindGlyphNoFallback(ImWchar c)
|
|||||||
if (i != IM_FONTGLYPH_INDEX_UNUSED)
|
if (i != IM_FONTGLYPH_INDEX_UNUSED)
|
||||||
return &Glyphs.Data[i];
|
return &Glyphs.Data[i];
|
||||||
}
|
}
|
||||||
LockLoadingFallback = true; // This is actually a rare call, not done in hot-loop, so we prioritize not adding extra cruft to ImFontBaked_BuildLoadGlyph() call sites.
|
LoadNoFallback = true; // This is actually a rare call, not done in hot-loop, so we prioritize not adding extra cruft to ImFontBaked_BuildLoadGlyph() call sites.
|
||||||
ImFontGlyph* glyph = ImFontBaked_BuildLoadGlyph(this, c, NULL);
|
ImFontGlyph* glyph = ImFontBaked_BuildLoadGlyph(this, c, NULL);
|
||||||
LockLoadingFallback = false;
|
LoadNoFallback = false;
|
||||||
return glyph;
|
return glyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5348,10 +5347,11 @@ ImFontBaked* ImFontAtlasBakedGetOrAdd(ImFontAtlas* atlas, ImFont* font, float fo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Trim trailing space and find beginning of next line
|
// Trim trailing space and find beginning of next line
|
||||||
static inline const char* CalcWordWrapNextLineStartA(const char* text, const char* text_end)
|
const char* ImTextCalcWordWrapNextLineStart(const char* text, const char* text_end, ImDrawTextFlags flags)
|
||||||
{
|
{
|
||||||
while (text < text_end && ImCharIsBlankA(*text))
|
if ((flags & ImDrawTextFlags_WrapKeepBlanks) == 0)
|
||||||
text++;
|
while (text < text_end && ImCharIsBlankA(*text))
|
||||||
|
text++;
|
||||||
if (*text == '\n')
|
if (*text == '\n')
|
||||||
text++;
|
text++;
|
||||||
return text;
|
return text;
|
||||||
@@ -5360,7 +5360,7 @@ static inline const char* CalcWordWrapNextLineStartA(const char* text, const cha
|
|||||||
// Simple word-wrapping for English, not full-featured. Please submit failing cases!
|
// Simple word-wrapping for English, not full-featured. Please submit failing cases!
|
||||||
// This will return the next location to wrap from. If no wrapping if necessary, this will fast-forward to e.g. text_end.
|
// This will return the next location to wrap from. If no wrapping if necessary, this will fast-forward to e.g. text_end.
|
||||||
// FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.)
|
// FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.)
|
||||||
const char* ImFont::CalcWordWrapPosition(float size, const char* text, const char* text_end, float wrap_width)
|
const char* ImFontCalcWordWrapPositionEx(ImFont* font, float size, const char* text, const char* text_end, float wrap_width, ImDrawTextFlags flags)
|
||||||
{
|
{
|
||||||
// For references, possible wrap point marked with ^
|
// For references, possible wrap point marked with ^
|
||||||
// "aaa bbb, ccc,ddd. eee fff. ggg!"
|
// "aaa bbb, ccc,ddd. eee fff. ggg!"
|
||||||
@@ -5374,7 +5374,7 @@ const char* ImFont::CalcWordWrapPosition(float size, const char* text, const cha
|
|||||||
// Cut words that cannot possibly fit within one line.
|
// Cut words that cannot possibly fit within one line.
|
||||||
// e.g.: "The tropical fish" with ~5 characters worth of width --> "The tr" "opical" "fish"
|
// e.g.: "The tropical fish" with ~5 characters worth of width --> "The tr" "opical" "fish"
|
||||||
|
|
||||||
ImFontBaked* baked = GetFontBaked(size);
|
ImFontBaked* baked = font->GetFontBaked(size);
|
||||||
const float scale = size / baked->Size;
|
const float scale = size / baked->Size;
|
||||||
|
|
||||||
float line_width = 0.0f;
|
float line_width = 0.0f;
|
||||||
@@ -5400,12 +5400,7 @@ const char* ImFont::CalcWordWrapPosition(float size, const char* text, const cha
|
|||||||
if (c < 32)
|
if (c < 32)
|
||||||
{
|
{
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
{
|
return s; // Direct return, skip "Wrap_width is too small to fit anything" path.
|
||||||
line_width = word_width = blank_width = 0.0f;
|
|
||||||
inside_word = true;
|
|
||||||
s = next_s;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c == '\r')
|
if (c == '\r')
|
||||||
{
|
{
|
||||||
s = next_s;
|
s = next_s;
|
||||||
@@ -5440,6 +5435,8 @@ const char* ImFont::CalcWordWrapPosition(float size, const char* text, const cha
|
|||||||
{
|
{
|
||||||
prev_word_end = word_end;
|
prev_word_end = word_end;
|
||||||
line_width += word_width + blank_width;
|
line_width += word_width + blank_width;
|
||||||
|
if ((flags & ImDrawTextFlags_WrapKeepBlanks) && line_width <= wrap_width)
|
||||||
|
prev_word_end = s;
|
||||||
word_width = blank_width = 0.0f;
|
word_width = blank_width = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5466,14 +5463,21 @@ const char* ImFont::CalcWordWrapPosition(float size, const char* text, const cha
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** remaining)
|
const char* ImFont::CalcWordWrapPosition(float size, const char* text, const char* text_end, float wrap_width)
|
||||||
|
{
|
||||||
|
return ImFontCalcWordWrapPositionEx(this, size, text, text_end, wrap_width, ImDrawTextFlags_None);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImVec2 ImFontCalcTextSizeEx(ImFont* font, float size, float max_width, float wrap_width, const char* text_begin, const char* text_end_display, const char* text_end, const char** out_remaining, ImVec2* out_offset, ImDrawTextFlags flags)
|
||||||
{
|
{
|
||||||
if (!text_end)
|
if (!text_end)
|
||||||
text_end = text_begin + ImStrlen(text_begin); // FIXME-OPT: Need to avoid this.
|
text_end = text_begin + ImStrlen(text_begin); // FIXME-OPT: Need to avoid this.
|
||||||
|
if (!text_end_display)
|
||||||
|
text_end_display = text_end;
|
||||||
|
|
||||||
|
ImFontBaked* baked = font->GetFontBaked(size);
|
||||||
const float line_height = size;
|
const float line_height = size;
|
||||||
ImFontBaked* baked = GetFontBaked(size);
|
const float scale = line_height / baked->Size;
|
||||||
const float scale = size / baked->Size;
|
|
||||||
|
|
||||||
ImVec2 text_size = ImVec2(0, 0);
|
ImVec2 text_size = ImVec2(0, 0);
|
||||||
float line_width = 0.0f;
|
float line_width = 0.0f;
|
||||||
@@ -5482,13 +5486,14 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
|||||||
const char* word_wrap_eol = NULL;
|
const char* word_wrap_eol = NULL;
|
||||||
|
|
||||||
const char* s = text_begin;
|
const char* s = text_begin;
|
||||||
while (s < text_end)
|
while (s < text_end_display)
|
||||||
{
|
{
|
||||||
|
// Word-wrapping
|
||||||
if (word_wrap_enabled)
|
if (word_wrap_enabled)
|
||||||
{
|
{
|
||||||
// Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
|
// Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
|
||||||
if (!word_wrap_eol)
|
if (!word_wrap_eol)
|
||||||
word_wrap_eol = CalcWordWrapPosition(size, s, text_end, wrap_width - line_width);
|
word_wrap_eol = ImFontCalcWordWrapPositionEx(font, size, s, text_end, wrap_width - line_width, flags);
|
||||||
|
|
||||||
if (s >= word_wrap_eol)
|
if (s >= word_wrap_eol)
|
||||||
{
|
{
|
||||||
@@ -5496,8 +5501,10 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
|||||||
text_size.x = line_width;
|
text_size.x = line_width;
|
||||||
text_size.y += line_height;
|
text_size.y += line_height;
|
||||||
line_width = 0.0f;
|
line_width = 0.0f;
|
||||||
|
s = ImTextCalcWordWrapNextLineStart(s, text_end, flags); // Wrapping skips upcoming blanks
|
||||||
|
if (flags & ImDrawTextFlags_StopOnNewLine)
|
||||||
|
break;
|
||||||
word_wrap_eol = NULL;
|
word_wrap_eol = NULL;
|
||||||
s = CalcWordWrapNextLineStartA(s, text_end); // Wrapping skips upcoming blanks
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5510,18 +5517,17 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
|||||||
else
|
else
|
||||||
s += ImTextCharFromUtf8(&c, s, text_end);
|
s += ImTextCharFromUtf8(&c, s, text_end);
|
||||||
|
|
||||||
if (c < 32)
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
if (c == '\n')
|
text_size.x = ImMax(text_size.x, line_width);
|
||||||
{
|
text_size.y += line_height;
|
||||||
text_size.x = ImMax(text_size.x, line_width);
|
line_width = 0.0f;
|
||||||
text_size.y += line_height;
|
if (flags & ImDrawTextFlags_StopOnNewLine)
|
||||||
line_width = 0.0f;
|
break;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (c == '\r')
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
if (c == '\r')
|
||||||
|
continue;
|
||||||
|
|
||||||
// Optimized inline version of 'float char_width = GetCharAdvance((ImWchar)c);'
|
// Optimized inline version of 'float char_width = GetCharAdvance((ImWchar)c);'
|
||||||
float char_width = (c < (unsigned int)baked->IndexAdvanceX.Size) ? baked->IndexAdvanceX.Data[c] : -1.0f;
|
float char_width = (c < (unsigned int)baked->IndexAdvanceX.Size) ? baked->IndexAdvanceX.Data[c] : -1.0f;
|
||||||
@@ -5541,15 +5547,23 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
|||||||
if (text_size.x < line_width)
|
if (text_size.x < line_width)
|
||||||
text_size.x = line_width;
|
text_size.x = line_width;
|
||||||
|
|
||||||
if (line_width > 0 || text_size.y == 0.0f)
|
if (out_offset != NULL)
|
||||||
|
*out_offset = ImVec2(line_width, text_size.y + line_height); // offset allow for the possibility of sitting after a trailing \n
|
||||||
|
|
||||||
|
if (line_width > 0 || text_size.y == 0.0f) // whereas size.y will ignore the trailing \n
|
||||||
text_size.y += line_height;
|
text_size.y += line_height;
|
||||||
|
|
||||||
if (remaining)
|
if (out_remaining != NULL)
|
||||||
*remaining = s;
|
*out_remaining = s;
|
||||||
|
|
||||||
return text_size;
|
return text_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** out_remaining)
|
||||||
|
{
|
||||||
|
return ImFontCalcTextSizeEx(this, size, max_width, wrap_width, text_begin, text_end, text_end, out_remaining, NULL, ImDrawTextFlags_None);
|
||||||
|
}
|
||||||
|
|
||||||
// Note: as with every ImDrawList drawing function, this expects that the font atlas texture is bound.
|
// Note: as with every ImDrawList drawing function, this expects that the font atlas texture is bound.
|
||||||
void ImFont::RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, ImWchar c, const ImVec4* cpu_fine_clip)
|
void ImFont::RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, ImWchar c, const ImVec4* cpu_fine_clip)
|
||||||
{
|
{
|
||||||
@@ -5590,7 +5604,8 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, Im
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note: as with every ImDrawList drawing function, this expects that the font atlas texture is bound.
|
// Note: as with every ImDrawList drawing function, this expects that the font atlas texture is bound.
|
||||||
void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip)
|
// DO NOT CALL DIRECTLY THIS WILL CHANGE WIDLY IN 2025-2025. Use ImDrawList::AddText().
|
||||||
|
void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, ImDrawTextFlags flags)
|
||||||
{
|
{
|
||||||
// Align to be pixel perfect
|
// Align to be pixel perfect
|
||||||
begin:
|
begin:
|
||||||
@@ -5620,8 +5635,8 @@ begin:
|
|||||||
// FIXME-OPT: This is not optimal as do first do a search for \n before calling CalcWordWrapPosition().
|
// FIXME-OPT: This is not optimal as do first do a search for \n before calling CalcWordWrapPosition().
|
||||||
// If the specs for CalcWordWrapPosition() were reworked to optionally return on \n we could combine both.
|
// If the specs for CalcWordWrapPosition() were reworked to optionally return on \n we could combine both.
|
||||||
// However it is still better than nothing performing the fast-forward!
|
// However it is still better than nothing performing the fast-forward!
|
||||||
s = CalcWordWrapPosition(size, s, line_end ? line_end : text_end, wrap_width);
|
s = ImFontCalcWordWrapPositionEx(this, size, s, line_end ? line_end : text_end, wrap_width, flags);
|
||||||
s = CalcWordWrapNextLineStartA(s, text_end);
|
s = ImTextCalcWordWrapNextLineStart(s, text_end, flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -5656,6 +5671,7 @@ begin:
|
|||||||
ImDrawIdx* idx_write = draw_list->_IdxWritePtr;
|
ImDrawIdx* idx_write = draw_list->_IdxWritePtr;
|
||||||
unsigned int vtx_index = draw_list->_VtxCurrentIdx;
|
unsigned int vtx_index = draw_list->_VtxCurrentIdx;
|
||||||
const int cmd_count = draw_list->CmdBuffer.Size;
|
const int cmd_count = draw_list->CmdBuffer.Size;
|
||||||
|
const bool cpu_fine_clip = (flags & ImDrawTextFlags_CpuFineClip) != 0;
|
||||||
|
|
||||||
const ImU32 col_untinted = col | ~IM_COL32_A_MASK;
|
const ImU32 col_untinted = col | ~IM_COL32_A_MASK;
|
||||||
const char* word_wrap_eol = NULL;
|
const char* word_wrap_eol = NULL;
|
||||||
@@ -5666,7 +5682,7 @@ begin:
|
|||||||
{
|
{
|
||||||
// Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
|
// Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
|
||||||
if (!word_wrap_eol)
|
if (!word_wrap_eol)
|
||||||
word_wrap_eol = CalcWordWrapPosition(size, s, text_end, wrap_width - (x - origin_x));
|
word_wrap_eol = ImFontCalcWordWrapPositionEx(this, size, s, text_end, wrap_width - (x - origin_x), flags);
|
||||||
|
|
||||||
if (s >= word_wrap_eol)
|
if (s >= word_wrap_eol)
|
||||||
{
|
{
|
||||||
@@ -5675,7 +5691,7 @@ begin:
|
|||||||
if (y > clip_rect.w)
|
if (y > clip_rect.w)
|
||||||
break; // break out of main loop
|
break; // break out of main loop
|
||||||
word_wrap_eol = NULL;
|
word_wrap_eol = NULL;
|
||||||
s = CalcWordWrapNextLineStartA(s, text_end); // Wrapping skips upcoming blanks
|
s = ImTextCalcWordWrapNextLineStart(s, text_end, flags); // Wrapping skips upcoming blanks
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5844,8 +5860,9 @@ void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir d
|
|||||||
|
|
||||||
void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col)
|
void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col)
|
||||||
{
|
{
|
||||||
// FIXME-OPT: This should be baked in font.
|
// FIXME-OPT: This should be baked in font now that it's easier.
|
||||||
draw_list->AddCircleFilled(pos, draw_list->_Data->FontSize * 0.20f, col, 8);
|
float font_size = draw_list->_Data->FontSize;
|
||||||
|
draw_list->AddCircleFilled(pos, font_size * 0.20f, col, (font_size < 22) ? 8 : (font_size < 40) ? 12 : 0); // Hardcode optimal/nice tessellation threshold
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz)
|
void ImGui::RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz)
|
||||||
@@ -6147,6 +6164,7 @@ static unsigned int stb_decompress(unsigned char *output, const unsigned char *i
|
|||||||
// Copyright (c) 2004, 2005 Tristan Grimmer
|
// Copyright (c) 2004, 2005 Tristan Grimmer
|
||||||
// MIT license (see License.txt in http://www.proggyfonts.net/index.php?menu=download)
|
// MIT license (see License.txt in http://www.proggyfonts.net/index.php?menu=download)
|
||||||
// Download and more information at http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php
|
// Download and more information at http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php
|
||||||
|
// If you want a similar font which may be better scaled, consider using ProggyVector from the same author!
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_DEFAULT_FONT
|
#ifndef IMGUI_DISABLE_DEFAULT_FONT
|
||||||
|
|||||||
205
imgui_internal.h
205
imgui_internal.h
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.92.1
|
// dear imgui, v1.92.3
|
||||||
// (internal structures/api)
|
// (internal structures/api)
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
|
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
|
||||||
@@ -77,8 +77,8 @@ Index of this file:
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (push)
|
#pragma warning (push)
|
||||||
#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
|
#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
|
||||||
#pragma warning (disable: 26812) // The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer)
|
|
||||||
#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
|
#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
|
||||||
|
#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
|
#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
|
||||||
#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
|
#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
|
||||||
#endif
|
#endif
|
||||||
@@ -199,6 +199,7 @@ typedef int ImGuiDataAuthority; // -> enum ImGuiDataAuthority_ // E
|
|||||||
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
|
typedef int ImDrawTextFlags; // -> enum ImDrawTextFlags_ // Flags: for ImTextCalcWordWrapPositionEx()
|
||||||
typedef int ImGuiActivateFlags; // -> enum ImGuiActivateFlags_ // Flags: for navigation/focus function (will be for ActivateItem() later)
|
typedef int ImGuiActivateFlags; // -> enum ImGuiActivateFlags_ // Flags: for navigation/focus function (will be for ActivateItem() later)
|
||||||
typedef int ImGuiDebugLogFlags; // -> enum ImGuiDebugLogFlags_ // Flags: for ShowDebugLogWindow(), g.DebugLogFlags
|
typedef int ImGuiDebugLogFlags; // -> enum ImGuiDebugLogFlags_ // Flags: for ShowDebugLogWindow(), g.DebugLogFlags
|
||||||
typedef int ImGuiFocusRequestFlags; // -> enum ImGuiFocusRequestFlags_ // Flags: for FocusWindow()
|
typedef int ImGuiFocusRequestFlags; // -> enum ImGuiFocusRequestFlags_ // Flags: for FocusWindow()
|
||||||
@@ -346,6 +347,7 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
|
|||||||
#define IM_PRIu64 "llu"
|
#define IM_PRIu64 "llu"
|
||||||
#define IM_PRIX64 "llX"
|
#define IM_PRIX64 "llX"
|
||||||
#endif
|
#endif
|
||||||
|
#define IM_TEXTUREID_TO_U64(_TEXID) ((ImU64)(intptr_t)(_TEXID))
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Generic helpers
|
// [SECTION] Generic helpers
|
||||||
@@ -377,20 +379,21 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
|
|||||||
// Helpers: Hashing
|
// Helpers: Hashing
|
||||||
IMGUI_API ImGuiID ImHashData(const void* data, size_t data_size, ImGuiID seed = 0);
|
IMGUI_API ImGuiID ImHashData(const void* data, size_t data_size, ImGuiID seed = 0);
|
||||||
IMGUI_API ImGuiID ImHashStr(const char* data, size_t data_size = 0, ImGuiID seed = 0);
|
IMGUI_API ImGuiID ImHashStr(const char* data, size_t data_size = 0, ImGuiID seed = 0);
|
||||||
|
IMGUI_API const char* ImHashSkipUncontributingPrefix(const char* label);
|
||||||
|
|
||||||
// Helpers: Sorting
|
// Helpers: Sorting
|
||||||
#ifndef ImQsort
|
#ifndef ImQsort
|
||||||
static inline void ImQsort(void* base, size_t count, size_t size_of_element, int(IMGUI_CDECL *compare_func)(void const*, void const*)) { if (count > 1) qsort(base, count, size_of_element, compare_func); }
|
inline void ImQsort(void* base, size_t count, size_t size_of_element, int(IMGUI_CDECL *compare_func)(void const*, void const*)) { if (count > 1) qsort(base, count, size_of_element, compare_func); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helpers: Color Blending
|
// Helpers: Color Blending
|
||||||
IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b);
|
IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b);
|
||||||
|
|
||||||
// Helpers: Bit manipulation
|
// Helpers: Bit manipulation
|
||||||
static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
|
inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
|
||||||
static inline bool ImIsPowerOfTwo(ImU64 v) { return v != 0 && (v & (v - 1)) == 0; }
|
inline bool ImIsPowerOfTwo(ImU64 v) { return v != 0 && (v & (v - 1)) == 0; }
|
||||||
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
|
inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
|
||||||
static inline unsigned int ImCountSetBits(unsigned int v) { unsigned int count = 0; while (v > 0) { v = v & (v - 1); count++; } return count; }
|
inline unsigned int ImCountSetBits(unsigned int v) { unsigned int count = 0; while (v > 0) { v = v & (v - 1); count++; } return count; }
|
||||||
|
|
||||||
// Helpers: String
|
// Helpers: String
|
||||||
#define ImStrlen strlen
|
#define ImStrlen strlen
|
||||||
@@ -409,10 +412,10 @@ IMGUI_API const char* ImStrSkipBlank(const char* str);
|
|||||||
IMGUI_API int ImStrlenW(const ImWchar* str); // Computer string length (ImWchar string)
|
IMGUI_API int ImStrlenW(const ImWchar* str); // Computer string length (ImWchar string)
|
||||||
IMGUI_API const char* ImStrbol(const char* buf_mid_line, const char* buf_begin); // Find beginning-of-line
|
IMGUI_API const char* ImStrbol(const char* buf_mid_line, const char* buf_begin); // Find beginning-of-line
|
||||||
IM_MSVC_RUNTIME_CHECKS_OFF
|
IM_MSVC_RUNTIME_CHECKS_OFF
|
||||||
static inline char ImToUpper(char c) { return (c >= 'a' && c <= 'z') ? c &= ~32 : c; }
|
inline char ImToUpper(char c) { return (c >= 'a' && c <= 'z') ? c &= ~32 : c; }
|
||||||
static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
|
inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
|
||||||
static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
|
inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
|
||||||
static inline bool ImCharIsXdigitA(char c) { return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); }
|
inline bool ImCharIsXdigitA(char c) { return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); }
|
||||||
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||||
|
|
||||||
// Helpers: Formatting
|
// Helpers: Formatting
|
||||||
@@ -428,7 +431,7 @@ IMGUI_API const char* ImParseFormatSanitizeForScanning(const char* fmt_in, cha
|
|||||||
IMGUI_API int ImParseFormatPrecision(const char* format, int default_value);
|
IMGUI_API int ImParseFormatPrecision(const char* format, int default_value);
|
||||||
|
|
||||||
// Helpers: UTF-8 <> wchar conversions
|
// Helpers: UTF-8 <> wchar conversions
|
||||||
IMGUI_API const char* ImTextCharToUtf8(char out_buf[5], unsigned int c); // return out_buf
|
IMGUI_API int ImTextCharToUtf8(char out_buf[5], unsigned int c); // return output UTF-8 bytes count
|
||||||
IMGUI_API int ImTextStrToUtf8(char* out_buf, int out_buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
IMGUI_API int ImTextStrToUtf8(char* out_buf, int out_buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
||||||
IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count
|
IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count
|
||||||
IMGUI_API int ImTextStrFromUtf8(ImWchar* out_buf, int out_buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
|
IMGUI_API int ImTextStrFromUtf8(ImWchar* out_buf, int out_buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
|
||||||
@@ -438,15 +441,27 @@ IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, cons
|
|||||||
IMGUI_API const char* ImTextFindPreviousUtf8Codepoint(const char* in_text_start, const char* in_text_curr); // return previous UTF-8 code-point.
|
IMGUI_API const char* ImTextFindPreviousUtf8Codepoint(const char* in_text_start, const char* in_text_curr); // return previous UTF-8 code-point.
|
||||||
IMGUI_API int ImTextCountLines(const char* in_text, const char* in_text_end); // return number of lines taken by text. trailing carriage return doesn't count as an extra line.
|
IMGUI_API int ImTextCountLines(const char* in_text, const char* in_text_end); // return number of lines taken by text. trailing carriage return doesn't count as an extra line.
|
||||||
|
|
||||||
|
// Helpers: High-level text functions (DO NOT USE!!! THIS IS A MINIMAL SUBSET OF LARGER UPCOMING CHANGES)
|
||||||
|
enum ImDrawTextFlags_
|
||||||
|
{
|
||||||
|
ImDrawTextFlags_None = 0,
|
||||||
|
ImDrawTextFlags_CpuFineClip = 1 << 0, // Must be == 1/true for legacy with 'bool cpu_fine_clip' arg to RenderText()
|
||||||
|
ImDrawTextFlags_WrapKeepBlanks = 1 << 1,
|
||||||
|
ImDrawTextFlags_StopOnNewLine = 1 << 2,
|
||||||
|
};
|
||||||
|
IMGUI_API ImVec2 ImFontCalcTextSizeEx(ImFont* font, float size, float max_width, float wrap_width, const char* text_begin, const char* text_end_display, const char* text_end, const char** out_remaining, ImVec2* out_offset, ImDrawTextFlags flags);
|
||||||
|
IMGUI_API const char* ImFontCalcWordWrapPositionEx(ImFont* font, float size, const char* text, const char* text_end, float wrap_width, ImDrawTextFlags flags = 0);
|
||||||
|
IMGUI_API const char* ImTextCalcWordWrapNextLineStart(const char* text, const char* text_end, ImDrawTextFlags flags = 0); // trim trailing space and find beginning of next line
|
||||||
|
|
||||||
// Helpers: File System
|
// Helpers: File System
|
||||||
#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
|
#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
|
||||||
#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
|
#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
|
||||||
typedef void* ImFileHandle;
|
typedef void* ImFileHandle;
|
||||||
static inline ImFileHandle ImFileOpen(const char*, const char*) { return NULL; }
|
inline ImFileHandle ImFileOpen(const char*, const char*) { return NULL; }
|
||||||
static inline bool ImFileClose(ImFileHandle) { return false; }
|
inline bool ImFileClose(ImFileHandle) { return false; }
|
||||||
static inline ImU64 ImFileGetSize(ImFileHandle) { return (ImU64)-1; }
|
inline ImU64 ImFileGetSize(ImFileHandle) { return (ImU64)-1; }
|
||||||
static inline ImU64 ImFileRead(void*, ImU64, ImU64, ImFileHandle) { return 0; }
|
inline ImU64 ImFileRead(void*, ImU64, ImU64, ImFileHandle) { return 0; }
|
||||||
static inline ImU64 ImFileWrite(const void*, ImU64, ImU64, ImFileHandle) { return 0; }
|
inline ImU64 ImFileWrite(const void*, ImU64, ImU64, ImFileHandle) { return 0; }
|
||||||
#endif
|
#endif
|
||||||
#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
|
||||||
typedef FILE* ImFileHandle;
|
typedef FILE* ImFileHandle;
|
||||||
@@ -473,56 +488,56 @@ IM_MSVC_RUNTIME_CHECKS_OFF
|
|||||||
#define ImAtan2(Y, X) atan2f((Y), (X))
|
#define ImAtan2(Y, X) atan2f((Y), (X))
|
||||||
#define ImAtof(STR) atof(STR)
|
#define ImAtof(STR) atof(STR)
|
||||||
#define ImCeil(X) ceilf(X)
|
#define ImCeil(X) ceilf(X)
|
||||||
static inline float ImPow(float x, float y) { return powf(x, y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision
|
inline float ImPow(float x, float y) { return powf(x, y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision
|
||||||
static inline double ImPow(double x, double y) { return pow(x, y); }
|
inline double ImPow(double x, double y) { return pow(x, y); }
|
||||||
static inline float ImLog(float x) { return logf(x); } // DragBehaviorT/SliderBehaviorT uses ImLog with either float/double and need the precision
|
inline float ImLog(float x) { return logf(x); } // DragBehaviorT/SliderBehaviorT uses ImLog with either float/double and need the precision
|
||||||
static inline double ImLog(double x) { return log(x); }
|
inline double ImLog(double x) { return log(x); }
|
||||||
static inline int ImAbs(int x) { return x < 0 ? -x : x; }
|
inline int ImAbs(int x) { return x < 0 ? -x : x; }
|
||||||
static inline float ImAbs(float x) { return fabsf(x); }
|
inline float ImAbs(float x) { return fabsf(x); }
|
||||||
static inline double ImAbs(double x) { return fabs(x); }
|
inline double ImAbs(double x) { return fabs(x); }
|
||||||
static inline float ImSign(float x) { return (x < 0.0f) ? -1.0f : (x > 0.0f) ? 1.0f : 0.0f; } // Sign operator - returns -1, 0 or 1 based on sign of argument
|
inline float ImSign(float x) { return (x < 0.0f) ? -1.0f : (x > 0.0f) ? 1.0f : 0.0f; } // Sign operator - returns -1, 0 or 1 based on sign of argument
|
||||||
static inline double ImSign(double x) { return (x < 0.0) ? -1.0 : (x > 0.0) ? 1.0 : 0.0; }
|
inline double ImSign(double x) { return (x < 0.0) ? -1.0 : (x > 0.0) ? 1.0 : 0.0; }
|
||||||
#ifdef IMGUI_ENABLE_SSE
|
#ifdef IMGUI_ENABLE_SSE
|
||||||
static inline float ImRsqrt(float x) { return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(x))); }
|
inline float ImRsqrt(float x) { return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(x))); }
|
||||||
#else
|
#else
|
||||||
static inline float ImRsqrt(float x) { return 1.0f / sqrtf(x); }
|
inline float ImRsqrt(float x) { return 1.0f / sqrtf(x); }
|
||||||
#endif
|
#endif
|
||||||
static inline double ImRsqrt(double x) { return 1.0 / sqrt(x); }
|
inline double ImRsqrt(double x) { return 1.0 / sqrt(x); }
|
||||||
#endif
|
#endif
|
||||||
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double
|
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double
|
||||||
// (Exceptionally using templates here but we could also redefine them for those types)
|
// (Exceptionally using templates here but we could also redefine them for those types)
|
||||||
template<typename T> static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
|
template<typename T> T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
|
||||||
template<typename T> static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
|
template<typename T> T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
|
||||||
template<typename T> static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
template<typename T> T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
||||||
template<typename T> static inline T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); }
|
template<typename T> T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); }
|
||||||
template<typename T> static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
template<typename T> void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
||||||
template<typename T> static inline T ImAddClampOverflow(T a, T b, T mn, T mx) { if (b < 0 && (a < mn - b)) return mn; if (b > 0 && (a > mx - b)) return mx; return a + b; }
|
template<typename T> T ImAddClampOverflow(T a, T b, T mn, T mx) { if (b < 0 && (a < mn - b)) return mn; if (b > 0 && (a > mx - b)) return mx; return a + b; }
|
||||||
template<typename T> static inline T ImSubClampOverflow(T a, T b, T mn, T mx) { if (b > 0 && (a < mn + b)) return mn; if (b < 0 && (a > mx + b)) return mx; return a - b; }
|
template<typename T> T ImSubClampOverflow(T a, T b, T mn, T mx) { if (b > 0 && (a < mn + b)) return mn; if (b < 0 && (a > mx + b)) return mx; return a - b; }
|
||||||
// - Misc maths helpers
|
// - Misc maths helpers
|
||||||
static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
|
inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
|
||||||
static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
|
inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
|
||||||
static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2&mn, const ImVec2&mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
|
inline ImVec2 ImClamp(const ImVec2& v, const ImVec2&mn, const ImVec2&mx){ return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
|
||||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
|
inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
|
||||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
||||||
static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
|
inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
|
||||||
static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
||||||
static inline float ImLengthSqr(const ImVec2& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y); }
|
inline float ImLengthSqr(const ImVec2& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y); }
|
||||||
static inline float ImLengthSqr(const ImVec4& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y) + (lhs.z * lhs.z) + (lhs.w * lhs.w); }
|
inline float ImLengthSqr(const ImVec4& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y) + (lhs.z * lhs.z) + (lhs.w * lhs.w); }
|
||||||
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = (lhs.x * lhs.x) + (lhs.y * lhs.y); if (d > 0.0f) return ImRsqrt(d); return fail_value; }
|
inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = (lhs.x * lhs.x) + (lhs.y * lhs.y); if (d > 0.0f) return ImRsqrt(d); return fail_value; }
|
||||||
static inline float ImTrunc(float f) { return (float)(int)(f); }
|
inline float ImTrunc(float f) { return (float)(int)(f); }
|
||||||
static inline ImVec2 ImTrunc(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); }
|
inline ImVec2 ImTrunc(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); }
|
||||||
static inline float ImFloor(float f) { return (float)((f >= 0 || (float)(int)f == f) ? (int)f : (int)f - 1); } // Decent replacement for floorf()
|
inline float ImFloor(float f) { return (float)((f >= 0 || (float)(int)f == f) ? (int)f : (int)f - 1); } // Decent replacement for floorf()
|
||||||
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2(ImFloor(v.x), ImFloor(v.y)); }
|
inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2(ImFloor(v.x), ImFloor(v.y)); }
|
||||||
static inline float ImTrunc64(float f) { return (float)(ImS64)(f); }
|
inline float ImTrunc64(float f) { return (float)(ImS64)(f); }
|
||||||
static inline float ImRound64(float f) { return (float)(ImS64)(f + 0.5f); }
|
inline float ImRound64(float f) { return (float)(ImS64)(f + 0.5f); }
|
||||||
static inline int ImModPositive(int a, int b) { return (a + b) % b; }
|
inline int ImModPositive(int a, int b) { return (a + b) % b; }
|
||||||
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
||||||
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
||||||
static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
||||||
static inline float ImLinearRemapClamp(float s0, float s1, float d0, float d1, float x) { return ImSaturate((x - s0) / (s1 - s0)) * (d1 - d0) + d0; }
|
inline float ImLinearRemapClamp(float s0, float s1, float d0, float d1, float x) { return ImSaturate((x - s0) / (s1 - s0)) * (d1 - d0) + d0; }
|
||||||
static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
|
inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
|
||||||
static inline bool ImIsFloatAboveGuaranteedIntegerPrecision(float f) { return f <= -16777216 || f >= 16777216; }
|
inline bool ImIsFloatAboveGuaranteedIntegerPrecision(float f) { return f <= -16777216 || f >= 16777216; }
|
||||||
static inline float ImExponentialMovingAverage(float avg, float sample, int n) { avg -= avg / n; avg += sample / n; return avg; }
|
inline float ImExponentialMovingAverage(float avg, float sample, int n){ avg -= avg / n; avg += sample / n; return avg; }
|
||||||
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||||
|
|
||||||
// Helpers: Geometry
|
// Helpers: Geometry
|
||||||
@@ -601,6 +616,7 @@ struct IMGUI_API ImRect
|
|||||||
void Floor() { Min.x = IM_TRUNC(Min.x); Min.y = IM_TRUNC(Min.y); Max.x = IM_TRUNC(Max.x); Max.y = IM_TRUNC(Max.y); }
|
void Floor() { Min.x = IM_TRUNC(Min.x); Min.y = IM_TRUNC(Min.y); Max.x = IM_TRUNC(Max.x); Max.y = IM_TRUNC(Max.y); }
|
||||||
bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; }
|
bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; }
|
||||||
ImVec4 ToVec4() const { return ImVec4(Min.x, Min.y, Max.x, Max.y); }
|
ImVec4 ToVec4() const { return ImVec4(Min.x, Min.y, Max.x, Max.y); }
|
||||||
|
const ImVec4& AsVec4() const { return *(const ImVec4*)&Min.x; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper: ImBitArray
|
// Helper: ImBitArray
|
||||||
@@ -799,13 +815,13 @@ struct ImChunkStream
|
|||||||
// Maintain a line index for a text buffer. This is a strong candidate to be moved into the public API.
|
// Maintain a line index for a text buffer. This is a strong candidate to be moved into the public API.
|
||||||
struct ImGuiTextIndex
|
struct ImGuiTextIndex
|
||||||
{
|
{
|
||||||
ImVector<int> LineOffsets;
|
ImVector<int> Offsets;
|
||||||
int EndOffset = 0; // Because we don't own text buffer we need to maintain EndOffset (may bake in LineOffsets?)
|
int EndOffset = 0; // Because we don't own text buffer we need to maintain EndOffset (may bake in LineOffsets?)
|
||||||
|
|
||||||
void clear() { LineOffsets.clear(); EndOffset = 0; }
|
void clear() { Offsets.clear(); EndOffset = 0; }
|
||||||
int size() { return LineOffsets.Size; }
|
int size() { return Offsets.Size; }
|
||||||
const char* get_line_begin(const char* base, int n) { return base + LineOffsets[n]; }
|
const char* get_line_begin(const char* base, int n) { return base + (Offsets.Size != 0 ? Offsets[n] : 0); }
|
||||||
const char* get_line_end(const char* base, int n) { return base + (n + 1 < LineOffsets.Size ? (LineOffsets[n + 1] - 1) : EndOffset); }
|
const char* get_line_end(const char* base, int n) { return base + (n + 1 < Offsets.Size ? (Offsets[n + 1] - 1) : EndOffset); }
|
||||||
void append(const char* base, int old_size, int new_size);
|
void append(const char* base, int old_size, int new_size);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1061,7 +1077,6 @@ enum ImGuiSelectableFlagsPrivate_
|
|||||||
{
|
{
|
||||||
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
||||||
ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
|
ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
|
||||||
ImGuiSelectableFlags_SelectOnNav = 1 << 21, // (WIP) Auto-select when moved into. This is not exposed in public API as to handle multi-select and modifiers we will need user to explicitly control focus scope. May be replaced with a BeginSelection() API.
|
|
||||||
ImGuiSelectableFlags_SelectOnClick = 1 << 22, // Override button behavior to react on Click (default is Click+Release)
|
ImGuiSelectableFlags_SelectOnClick = 1 << 22, // Override button behavior to react on Click (default is Click+Release)
|
||||||
ImGuiSelectableFlags_SelectOnRelease = 1 << 23, // Override button behavior to react on Release (default is Click+Release)
|
ImGuiSelectableFlags_SelectOnRelease = 1 << 23, // Override button behavior to react on Release (default is Click+Release)
|
||||||
ImGuiSelectableFlags_SpanAvailWidth = 1 << 24, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
|
ImGuiSelectableFlags_SpanAvailWidth = 1 << 24, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
|
||||||
@@ -1229,11 +1244,15 @@ struct IMGUI_API ImGuiInputTextState
|
|||||||
ImVector<char> CallbackTextBackup; // temporary storage for callback to support automatic reconcile of undo-stack
|
ImVector<char> CallbackTextBackup; // temporary storage for callback to support automatic reconcile of undo-stack
|
||||||
int BufCapacity; // end-user buffer capacity (include zero terminator)
|
int BufCapacity; // end-user buffer capacity (include zero terminator)
|
||||||
ImVec2 Scroll; // horizontal offset (managed manually) + vertical scrolling (pulled from child window's own Scroll.y)
|
ImVec2 Scroll; // horizontal offset (managed manually) + vertical scrolling (pulled from child window's own Scroll.y)
|
||||||
|
int LineCount; // last line count (solely for debugging)
|
||||||
|
float WrapWidth; // word-wrapping width
|
||||||
float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately
|
float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately
|
||||||
bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!)
|
bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!)
|
||||||
|
bool CursorCenterY; // set when we want scrolling to be centered over the cursor position (while resizing a word-wrapping field)
|
||||||
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
|
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
|
||||||
bool Edited; // edited this frame
|
bool Edited; // edited this frame
|
||||||
bool WantReloadUserBuf; // force a reload of user buf so it may be modified externally. may be automatic in future version.
|
bool WantReloadUserBuf; // force a reload of user buf so it may be modified externally. may be automatic in future version.
|
||||||
|
ImS8 LastMoveDirectionLR; // ImGuiDir_Left or ImGuiDir_Right. track last movement direction so when cursor cross over a word-wrapping boundaries we can display it on either line depending on last move.s
|
||||||
int ReloadSelectionStart;
|
int ReloadSelectionStart;
|
||||||
int ReloadSelectionEnd;
|
int ReloadSelectionEnd;
|
||||||
|
|
||||||
@@ -1243,6 +1262,7 @@ struct IMGUI_API ImGuiInputTextState
|
|||||||
void ClearFreeMemory() { TextA.clear(); TextToRevertTo.clear(); }
|
void ClearFreeMemory() { TextA.clear(); TextToRevertTo.clear(); }
|
||||||
void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation
|
void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation
|
||||||
void OnCharPressed(unsigned int c);
|
void OnCharPressed(unsigned int c);
|
||||||
|
float GetPreferredOffsetX() const;
|
||||||
|
|
||||||
// Cursor & Selection
|
// Cursor & Selection
|
||||||
void CursorAnimReset();
|
void CursorAnimReset();
|
||||||
@@ -1507,7 +1527,7 @@ enum ImGuiInputEventType
|
|||||||
ImGuiInputEventType_COUNT
|
ImGuiInputEventType_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiInputSource
|
enum ImGuiInputSource : int
|
||||||
{
|
{
|
||||||
ImGuiInputSource_None = 0,
|
ImGuiInputSource_None = 0,
|
||||||
ImGuiInputSource_Mouse, // Note: may be Mouse or TouchScreen or Pen. See io.MouseSource to distinguish them.
|
ImGuiInputSource_Mouse, // Note: may be Mouse or TouchScreen or Pen. See io.MouseSource to distinguish them.
|
||||||
@@ -1672,8 +1692,9 @@ enum ImGuiActivateFlags_
|
|||||||
ImGuiActivateFlags_PreferInput = 1 << 0, // Favor activation that requires keyboard text input (e.g. for Slider/Drag). Default for Enter key.
|
ImGuiActivateFlags_PreferInput = 1 << 0, // Favor activation that requires keyboard text input (e.g. for Slider/Drag). Default for Enter key.
|
||||||
ImGuiActivateFlags_PreferTweak = 1 << 1, // Favor activation for tweaking with arrows or gamepad (e.g. for Slider/Drag). Default for Space key and if keyboard is not used.
|
ImGuiActivateFlags_PreferTweak = 1 << 1, // Favor activation for tweaking with arrows or gamepad (e.g. for Slider/Drag). Default for Space key and if keyboard is not used.
|
||||||
ImGuiActivateFlags_TryToPreserveState = 1 << 2, // Request widget to preserve state if it can (e.g. InputText will try to preserve cursor/selection)
|
ImGuiActivateFlags_TryToPreserveState = 1 << 2, // Request widget to preserve state if it can (e.g. InputText will try to preserve cursor/selection)
|
||||||
ImGuiActivateFlags_FromTabbing = 1 << 3, // Activation requested by a tabbing request
|
ImGuiActivateFlags_FromTabbing = 1 << 3, // Activation requested by a tabbing request (ImGuiNavMoveFlags_IsTabbing)
|
||||||
ImGuiActivateFlags_FromShortcut = 1 << 4, // Activation requested by an item shortcut via SetNextItemShortcut() function.
|
ImGuiActivateFlags_FromShortcut = 1 << 4, // Activation requested by an item shortcut via SetNextItemShortcut() function.
|
||||||
|
ImGuiActivateFlags_FromFocusApi = 1 << 5, // Activation requested by an api request (ImGuiNavMoveFlags_FocusApi)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Early work-in-progress API for ScrollToItem()
|
// Early work-in-progress API for ScrollToItem()
|
||||||
@@ -2287,10 +2308,10 @@ struct ImGuiStackLevelInfo
|
|||||||
ImGuiID ID;
|
ImGuiID ID;
|
||||||
ImS8 QueryFrameCount; // >= 1: Query in progress
|
ImS8 QueryFrameCount; // >= 1: Query in progress
|
||||||
bool QuerySuccess; // Obtained result from DebugHookIdInfo()
|
bool QuerySuccess; // Obtained result from DebugHookIdInfo()
|
||||||
ImGuiDataType DataType : 8;
|
ImS8 DataType; // ImGuiDataType
|
||||||
char Desc[57]; // Arbitrarily sized buffer to hold a result (FIXME: could replace Results[] with a chunk stream?) FIXME: Now that we added CTRL+C this should be fixed.
|
int DescOffset; // -1 or offset into parent's ResultPathsBuf
|
||||||
|
|
||||||
ImGuiStackLevelInfo() { memset(this, 0, sizeof(*this)); }
|
ImGuiStackLevelInfo() { memset(this, 0, sizeof(*this)); DescOffset = -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// State for ID Stack tool queries
|
// State for ID Stack tool queries
|
||||||
@@ -2298,13 +2319,16 @@ struct ImGuiIDStackTool
|
|||||||
{
|
{
|
||||||
int LastActiveFrame;
|
int LastActiveFrame;
|
||||||
int StackLevel; // -1: query stack and resize Results, >= 0: individual stack level
|
int StackLevel; // -1: query stack and resize Results, >= 0: individual stack level
|
||||||
ImGuiID QueryId; // ID to query details for
|
ImGuiID QueryMainId; // ID to query details for
|
||||||
ImVector<ImGuiStackLevelInfo> Results;
|
ImVector<ImGuiStackLevelInfo> Results;
|
||||||
bool CopyToClipboardOnCtrlC;
|
bool QueryHookActive; // Used to disambiguate the case where DebugHookIdInfoId == 0 which is valid.
|
||||||
|
bool OptHexEncodeNonAsciiChars;
|
||||||
|
bool OptCopyToClipboardOnCtrlC;
|
||||||
float CopyToClipboardLastTime;
|
float CopyToClipboardLastTime;
|
||||||
ImGuiTextBuffer ResultPathBuf;
|
ImGuiTextBuffer ResultPathsBuf;
|
||||||
|
ImGuiTextBuffer ResultTempBuf;
|
||||||
|
|
||||||
ImGuiIDStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; }
|
ImGuiIDStackTool() { memset(this, 0, sizeof(*this)); LastActiveFrame = -1; OptHexEncodeNonAsciiChars = true; CopyToClipboardLastTime = -FLT_MAX; }
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -2389,7 +2413,7 @@ struct ImGuiContext
|
|||||||
|
|
||||||
// Item/widgets state and tracking information
|
// Item/widgets state and tracking information
|
||||||
ImGuiID DebugDrawIdConflictsId; // Set when we detect multiple items with the same identifier
|
ImGuiID DebugDrawIdConflictsId; // Set when we detect multiple items with the same identifier
|
||||||
ImGuiID DebugHookIdInfo; // Will call core hooks: DebugHookIdInfo() from GetID functions, used by ID Stack Tool [next HoveredId/ActiveId to not pull in an extra cache-line]
|
ImGuiID DebugHookIdInfoId; // Will call core hooks: DebugHookIdInfo() from GetID functions, used by ID Stack Tool [next HoveredId/ActiveId to not pull in an extra cache-line]
|
||||||
ImGuiID HoveredId; // Hovered widget, filled during the frame
|
ImGuiID HoveredId; // Hovered widget, filled during the frame
|
||||||
ImGuiID HoveredIdPreviousFrame;
|
ImGuiID HoveredIdPreviousFrame;
|
||||||
int HoveredIdPreviousFrameItemCount; // Count numbers of items using the same ID as last frame's hovered id
|
int HoveredIdPreviousFrameItemCount; // Count numbers of items using the same ID as last frame's hovered id
|
||||||
@@ -2408,6 +2432,7 @@ struct ImGuiContext
|
|||||||
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
|
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
|
||||||
bool ActiveIdHasBeenEditedThisFrame;
|
bool ActiveIdHasBeenEditedThisFrame;
|
||||||
bool ActiveIdFromShortcut;
|
bool ActiveIdFromShortcut;
|
||||||
|
ImGuiID ActiveIdDisabledId; // When clicking a disabled item we set ActiveId=window->MoveId to avoid interference with widget code. Actual item ID is stored here.
|
||||||
int ActiveIdMouseButton : 8;
|
int ActiveIdMouseButton : 8;
|
||||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||||
ImGuiWindow* ActiveIdWindow;
|
ImGuiWindow* ActiveIdWindow;
|
||||||
@@ -2533,8 +2558,8 @@ struct ImGuiContext
|
|||||||
float NavWindowingTimer;
|
float NavWindowingTimer;
|
||||||
float NavWindowingHighlightAlpha;
|
float NavWindowingHighlightAlpha;
|
||||||
ImGuiInputSource NavWindowingInputSource;
|
ImGuiInputSource NavWindowingInputSource;
|
||||||
bool NavWindowingToggleLayer;
|
bool NavWindowingToggleLayer; // Set while Alt or GamepadMenu is held, may be cleared by other operations, and processed when releasing the key.
|
||||||
ImGuiKey NavWindowingToggleKey;
|
ImGuiKey NavWindowingToggleKey; // Keyboard/gamepad key used when toggling to menu layer.
|
||||||
ImVec2 NavWindowingAccumDeltaPos;
|
ImVec2 NavWindowingAccumDeltaPos;
|
||||||
ImVec2 NavWindowingAccumDeltaSize;
|
ImVec2 NavWindowingAccumDeltaSize;
|
||||||
|
|
||||||
@@ -2602,6 +2627,7 @@ struct ImGuiContext
|
|||||||
|
|
||||||
// Widget state
|
// Widget state
|
||||||
ImGuiInputTextState InputTextState;
|
ImGuiInputTextState InputTextState;
|
||||||
|
ImGuiTextIndex InputTextLineIndex; // Temporary storage
|
||||||
ImGuiInputTextDeactivatedState InputTextDeactivatedState;
|
ImGuiInputTextDeactivatedState InputTextDeactivatedState;
|
||||||
ImFontBaked InputTextPasswordFontBackupBaked;
|
ImFontBaked InputTextPasswordFontBackupBaked;
|
||||||
ImFontFlags InputTextPasswordFontBackupFlags;
|
ImFontFlags InputTextPasswordFontBackupFlags;
|
||||||
@@ -2968,7 +2994,7 @@ struct ImGuiTabItem
|
|||||||
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
|
||||||
float Width; // Width currently displayed
|
float Width; // Width currently displayed
|
||||||
float ContentWidth; // Width of label, stored during BeginTabItem() call
|
float ContentWidth; // Width of label + padding, stored during BeginTabItem() call (misnamed as "Content" would normally imply width of label only)
|
||||||
float RequestedWidth; // Width optionally requested by caller, -1.0f is unused
|
float RequestedWidth; // Width optionally requested by caller, -1.0f is unused
|
||||||
ImS32 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
|
ImS32 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
|
||||||
ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
|
ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
|
||||||
@@ -2991,6 +3017,7 @@ struct IMGUI_API ImGuiTabBar
|
|||||||
int CurrFrameVisible;
|
int CurrFrameVisible;
|
||||||
int PrevFrameVisible;
|
int PrevFrameVisible;
|
||||||
ImRect BarRect;
|
ImRect BarRect;
|
||||||
|
float BarRectPrevWidth; // Backup of previous width. When width change we enforce keep horizontal scroll on focused tab.
|
||||||
float CurrTabsContentsHeight;
|
float CurrTabsContentsHeight;
|
||||||
float PrevTabsContentsHeight; // Record the height of contents submitted below the tab bar
|
float PrevTabsContentsHeight; // Record the height of contents submitted below the tab bar
|
||||||
float WidthAllTabs; // Actual width of all tabs (locked during layout)
|
float WidthAllTabs; // Actual width of all tabs (locked during layout)
|
||||||
@@ -3009,6 +3036,7 @@ struct IMGUI_API ImGuiTabBar
|
|||||||
bool WantLayout;
|
bool WantLayout;
|
||||||
bool VisibleTabWasSubmitted;
|
bool VisibleTabWasSubmitted;
|
||||||
bool TabsAddedNew; // Set to true when a new tab item or button has been added to the tab bar during last frame
|
bool TabsAddedNew; // Set to true when a new tab item or button has been added to the tab bar during last frame
|
||||||
|
bool ScrollButtonEnabled;
|
||||||
ImS16 TabsActiveCount; // Number of tabs submitted this frame.
|
ImS16 TabsActiveCount; // Number of tabs submitted this frame.
|
||||||
ImS16 LastTabItemIdx; // Index of last BeginTabItem() tab for use by EndTabItem()
|
ImS16 LastTabItemIdx; // Index of last BeginTabItem() tab for use by EndTabItem()
|
||||||
float ItemSpacingY;
|
float ItemSpacingY;
|
||||||
@@ -3357,7 +3385,7 @@ namespace ImGui
|
|||||||
IMGUI_API void SetNextWindowRefreshPolicy(ImGuiWindowRefreshFlags flags);
|
IMGUI_API void SetNextWindowRefreshPolicy(ImGuiWindowRefreshFlags flags);
|
||||||
|
|
||||||
// Fonts, drawing
|
// Fonts, drawing
|
||||||
IMGUI_API void RegisterUserTexture(ImTextureData* tex); // Register external texture
|
IMGUI_API void RegisterUserTexture(ImTextureData* tex); // Register external texture. EXPERIMENTAL: DO NOT USE YET.
|
||||||
IMGUI_API void UnregisterUserTexture(ImTextureData* tex);
|
IMGUI_API void UnregisterUserTexture(ImTextureData* tex);
|
||||||
IMGUI_API void RegisterFontAtlas(ImFontAtlas* atlas);
|
IMGUI_API void RegisterFontAtlas(ImFontAtlas* atlas);
|
||||||
IMGUI_API void UnregisterFontAtlas(ImFontAtlas* atlas);
|
IMGUI_API void UnregisterFontAtlas(ImFontAtlas* atlas);
|
||||||
@@ -3382,6 +3410,7 @@ namespace ImGui
|
|||||||
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 StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* node, bool undock);
|
||||||
|
IMGUI_API void StopMouseMovingWindow();
|
||||||
IMGUI_API void UpdateMouseMovingWindowNewFrame();
|
IMGUI_API void UpdateMouseMovingWindowNewFrame();
|
||||||
IMGUI_API void UpdateMouseMovingWindowEndFrame();
|
IMGUI_API void UpdateMouseMovingWindowEndFrame();
|
||||||
|
|
||||||
@@ -3458,7 +3487,8 @@ namespace ImGui
|
|||||||
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h);
|
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h);
|
||||||
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
||||||
IMGUI_API void PushMultiItemsWidths(int components, float width_full);
|
IMGUI_API void PushMultiItemsWidths(int components, float width_full);
|
||||||
IMGUI_API void ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess);
|
IMGUI_API void ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess, float width_min);
|
||||||
|
IMGUI_API void CalcClipRectVisibleItemsY(const ImRect& clip_rect, const ImVec2& pos, float items_height, int* out_visible_start, int* out_visible_end);
|
||||||
|
|
||||||
// Parameter stacks (shared)
|
// Parameter stacks (shared)
|
||||||
IMGUI_API const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx);
|
IMGUI_API const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx);
|
||||||
@@ -3779,6 +3809,8 @@ namespace ImGui
|
|||||||
|
|
||||||
// Tab Bars
|
// Tab Bars
|
||||||
inline ImGuiTabBar* GetCurrentTabBar() { ImGuiContext& g = *GImGui; return g.CurrentTabBar; }
|
inline ImGuiTabBar* GetCurrentTabBar() { ImGuiContext& g = *GImGui; return g.CurrentTabBar; }
|
||||||
|
IMGUI_API ImGuiTabBar* TabBarFindByID(ImGuiID id);
|
||||||
|
IMGUI_API void TabBarRemove(ImGuiTabBar* tab_bar);
|
||||||
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);
|
||||||
@@ -3969,7 +4001,6 @@ namespace ImGui
|
|||||||
//inline bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0) { return TreeNodeUpdateNextOpen(id, flags); } // Renamed in 1.89
|
//inline bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0) { return TreeNodeUpdateNextOpen(id, flags); } // Renamed in 1.89
|
||||||
//inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { IM_ASSERT(IsNamedKey(key)); return IsKeyPressed(key, repeat); } // Removed in 1.87: Mapping from named key is always identity!
|
//inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { IM_ASSERT(IsNamedKey(key)); return IsKeyPressed(key, repeat); } // Removed in 1.87: Mapping from named key is always identity!
|
||||||
|
|
||||||
// Refactored focus/nav/tabbing system in 1.82 and 1.84. If you have old/custom copy-and-pasted widgets which used FocusableItemRegister():
|
|
||||||
// Refactored focus/nav/tabbing system in 1.82 and 1.84. If you have old/custom copy-and-pasted widgets which used FocusableItemRegister():
|
// Refactored focus/nav/tabbing system in 1.82 and 1.84. If you have old/custom copy-and-pasted widgets which used FocusableItemRegister():
|
||||||
// (Old) IMGUI_VERSION_NUM < 18209: using 'ItemAdd(....)' and 'bool tab_focused = FocusableItemRegister(...)'
|
// (Old) IMGUI_VERSION_NUM < 18209: using 'ItemAdd(....)' and 'bool tab_focused = FocusableItemRegister(...)'
|
||||||
// (Old) IMGUI_VERSION_NUM >= 18209: using 'ItemAdd(..., ImGuiItemAddFlags_Focusable)' and 'bool tab_focused = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Focused) != 0'
|
// (Old) IMGUI_VERSION_NUM >= 18209: using 'ItemAdd(..., ImGuiItemAddFlags_Focusable)' and 'bool tab_focused = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Focused) != 0'
|
||||||
@@ -4027,12 +4058,12 @@ inline bool operator==(const ImTextureRef& lhs, const ImTextureRef& rhs) { re
|
|||||||
inline bool operator!=(const ImTextureRef& lhs, const ImTextureRef& rhs) { return lhs._TexID != rhs._TexID || lhs._TexData != rhs._TexData; }
|
inline bool operator!=(const ImTextureRef& lhs, const ImTextureRef& rhs) { return lhs._TexID != rhs._TexID || lhs._TexData != rhs._TexData; }
|
||||||
|
|
||||||
// Refer to ImFontAtlasPackGetRect() to better understand how this works.
|
// Refer to ImFontAtlasPackGetRect() to better understand how this works.
|
||||||
#define ImFontAtlasRectId_IndexMask_ (0x000FFFFF) // 20-bits: index to access builder->RectsIndex[].
|
#define ImFontAtlasRectId_IndexMask_ (0x0007FFFF) // 20-bits signed: index to access builder->RectsIndex[].
|
||||||
#define ImFontAtlasRectId_GenerationMask_ (0x3FF00000) // 10-bits: entry generation, so each ID is unique and get can safely detected old identifiers.
|
#define ImFontAtlasRectId_GenerationMask_ (0x3FF00000) // 10-bits: entry generation, so each ID is unique and get can safely detected old identifiers.
|
||||||
#define ImFontAtlasRectId_GenerationShift_ (20)
|
#define ImFontAtlasRectId_GenerationShift_ (20)
|
||||||
inline int ImFontAtlasRectId_GetIndex(ImFontAtlasRectId id) { return id & ImFontAtlasRectId_IndexMask_; }
|
inline int ImFontAtlasRectId_GetIndex(ImFontAtlasRectId id) { return (id & ImFontAtlasRectId_IndexMask_); }
|
||||||
inline int ImFontAtlasRectId_GetGeneration(ImFontAtlasRectId id) { return (id & ImFontAtlasRectId_GenerationMask_) >> ImFontAtlasRectId_GenerationShift_; }
|
inline unsigned int ImFontAtlasRectId_GetGeneration(ImFontAtlasRectId id) { return (unsigned int)(id & ImFontAtlasRectId_GenerationMask_) >> ImFontAtlasRectId_GenerationShift_; }
|
||||||
inline ImFontAtlasRectId ImFontAtlasRectId_Make(int index_idx, int gen_idx) { IM_ASSERT(index_idx < ImFontAtlasRectId_IndexMask_ && gen_idx < (ImFontAtlasRectId_GenerationMask_ >> ImFontAtlasRectId_GenerationShift_)); return (ImFontAtlasRectId)(index_idx | (gen_idx << ImFontAtlasRectId_GenerationShift_)); }
|
inline ImFontAtlasRectId ImFontAtlasRectId_Make(int index_idx, int gen_idx) { IM_ASSERT(index_idx >= 0 && index_idx <= ImFontAtlasRectId_IndexMask_ && gen_idx <= (ImFontAtlasRectId_GenerationMask_ >> ImFontAtlasRectId_GenerationShift_)); return (ImFontAtlasRectId)(index_idx | (gen_idx << ImFontAtlasRectId_GenerationShift_)); }
|
||||||
|
|
||||||
// Packed rectangle lookup entry (we need an indirection to allow removing/reordering rectangles)
|
// Packed rectangle lookup entry (we need an indirection to allow removing/reordering rectangles)
|
||||||
// User are returned ImFontAtlasRectId values which are meant to be persistent.
|
// User are returned ImFontAtlasRectId values which are meant to be persistent.
|
||||||
@@ -4042,7 +4073,7 @@ inline ImFontAtlasRectId ImFontAtlasRectId_Make(int index_idx, int gen_idx)
|
|||||||
struct ImFontAtlasRectEntry
|
struct ImFontAtlasRectEntry
|
||||||
{
|
{
|
||||||
int TargetIndex : 20; // When Used: ImFontAtlasRectId -> into Rects[]. When unused: index to next unused RectsIndex[] slot to consume free-list.
|
int TargetIndex : 20; // When Used: ImFontAtlasRectId -> into Rects[]. When unused: index to next unused RectsIndex[] slot to consume free-list.
|
||||||
int Generation : 10; // Increased each time the entry is reused for a new rectangle.
|
unsigned int Generation : 10; // Increased each time the entry is reused for a new rectangle.
|
||||||
unsigned int IsUsed : 1;
|
unsigned int IsUsed : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.92.1
|
// dear imgui, v1.92.3
|
||||||
// (tables and columns code)
|
// (tables and columns code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -437,7 +437,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
if (table->InnerWindow->SkipItems && outer_window_is_measuring_size)
|
if (table->InnerWindow->SkipItems && outer_window_is_measuring_size)
|
||||||
table->InnerWindow->SkipItems = false;
|
table->InnerWindow->SkipItems = false;
|
||||||
|
|
||||||
// When using multiple instances, ensure they have the same amount of horizontal decorations (aka vertical scrollbar) so stretched columns can be aligned)
|
// When using multiple instances, ensure they have the same amount of horizontal decorations (aka vertical scrollbar) so stretched columns can be aligned
|
||||||
if (instance_no == 0)
|
if (instance_no == 0)
|
||||||
{
|
{
|
||||||
table->HasScrollbarYPrev = table->HasScrollbarYCurr;
|
table->HasScrollbarYPrev = table->HasScrollbarYCurr;
|
||||||
@@ -542,7 +542,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
|
|
||||||
// Make table current
|
// Make table current
|
||||||
g.CurrentTable = table;
|
g.CurrentTable = table;
|
||||||
outer_window->DC.NavIsScrollPushableX = false; // Shortcut for NavUpdateCurrentWindowIsScrollPushableX();
|
inner_window->DC.NavIsScrollPushableX = false; // Shortcut for NavUpdateCurrentWindowIsScrollPushableX();
|
||||||
outer_window->DC.CurrentTableIdx = table_idx;
|
outer_window->DC.CurrentTableIdx = table_idx;
|
||||||
if (inner_window != outer_window) // So EndChild() within the inner window can restore the table properly.
|
if (inner_window != outer_window) // So EndChild() within the inner window can restore the table properly.
|
||||||
inner_window->DC.CurrentTableIdx = table_idx;
|
inner_window->DC.CurrentTableIdx = table_idx;
|
||||||
@@ -1825,6 +1825,11 @@ void ImGui::TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiTable* table = g.CurrentTable;
|
ImGuiTable* table = g.CurrentTable;
|
||||||
IM_ASSERT(target != ImGuiTableBgTarget_None);
|
IM_ASSERT(target != ImGuiTableBgTarget_None);
|
||||||
|
if (table == NULL)
|
||||||
|
{
|
||||||
|
IM_ASSERT_USER_ERROR(table != NULL, "Call should only be done while in BeginTable() scope!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (color == IM_COL32_DISABLE)
|
if (color == IM_COL32_DISABLE)
|
||||||
color = 0;
|
color = 0;
|
||||||
@@ -2049,10 +2054,11 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// End frozen rows (when we are past the last frozen row line, teleport cursor and alter clipping rectangle)
|
// End frozen rows (when we are past the last frozen row line, teleport cursor and alter clipping rectangle)
|
||||||
// We need to do that in TableEndRow() instead of TableBeginRow() so the list clipper can mark end of row and
|
// - We need to do that in TableEndRow() instead of TableBeginRow() so the list clipper can mark
|
||||||
// get the new cursor position.
|
// end of row and get the new cursor position.
|
||||||
if (unfreeze_rows_request)
|
if (unfreeze_rows_request)
|
||||||
{
|
{
|
||||||
|
IM_ASSERT(table->FreezeRowsRequest > 0);
|
||||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||||
table->Columns[column_n].NavLayerCurrent = table->NavLayer;
|
table->Columns[column_n].NavLayerCurrent = table->NavLayer;
|
||||||
const float y0 = ImMax(table->RowPosY2 + 1, table->InnerClipRect.Min.y);
|
const float y0 = ImMax(table->RowPosY2 + 1, table->InnerClipRect.Min.y);
|
||||||
@@ -2876,9 +2882,7 @@ ImGuiTableSortSpecs* ImGui::TableGetSortSpecs()
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiTable* table = g.CurrentTable;
|
ImGuiTable* table = g.CurrentTable;
|
||||||
IM_ASSERT(table != NULL);
|
if (table == NULL || !(table->Flags & ImGuiTableFlags_Sortable))
|
||||||
|
|
||||||
if (!(table->Flags & ImGuiTableFlags_Sortable))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Require layout (in case TableHeadersRow() hasn't been called) as it may alter IsSortSpecsDirty in some paths.
|
// Require layout (in case TableHeadersRow() hasn't been called) as it may alter IsSortSpecsDirty in some paths.
|
||||||
@@ -3939,7 +3943,7 @@ void ImGui::TableSettingsAddSettingsHandler()
|
|||||||
// - TableGcCompactSettings() [Internal]
|
// - TableGcCompactSettings() [Internal]
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
// Remove Table (currently only used by TestEngine)
|
// Remove Table data (currently only used by TestEngine)
|
||||||
void ImGui::TableRemove(ImGuiTable* table)
|
void ImGui::TableRemove(ImGuiTable* table)
|
||||||
{
|
{
|
||||||
//IMGUI_DEBUG_PRINT("TableRemove() id=0x%08X\n", table->ID);
|
//IMGUI_DEBUG_PRINT("TableRemove() id=0x%08X\n", table->ID);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.92.1
|
// dear imgui, v1.92.3
|
||||||
// (widgets code)
|
// (widgets code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -135,8 +135,7 @@ static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1);
|
|||||||
|
|
||||||
// For InputTextEx()
|
// For InputTextEx()
|
||||||
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, bool input_source_is_clipboard = false);
|
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, bool input_source_is_clipboard = false);
|
||||||
static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end);
|
static ImVec2 InputTextCalcTextSize(ImGuiContext* ctx, const char* text_begin, const char* text_end_display, const char* text_end, const char** out_remaining = NULL, ImVec2* out_offset = NULL, ImDrawTextFlags flags = 0);
|
||||||
static ImVec2 InputTextCalcTextSize(ImGuiContext* ctx, const char* text_begin, const char* text_end, const char** remaining = NULL, ImVec2* out_offset = NULL, bool stop_on_new_line = false);
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// [SECTION] Widgets: Text, etc.
|
// [SECTION] Widgets: Text, etc.
|
||||||
@@ -1032,7 +1031,8 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
|||||||
const bool allow_interaction = (alpha >= 1.0f);
|
const bool allow_interaction = (alpha >= 1.0f);
|
||||||
|
|
||||||
ImRect bb = bb_frame;
|
ImRect bb = bb_frame;
|
||||||
bb.Expand(ImVec2(-ImClamp(IM_TRUNC((bb_frame_width - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp(IM_TRUNC((bb_frame_height - 2.0f) * 0.5f), 0.0f, 3.0f)));
|
float padding = IM_TRUNC(ImMin(style.ScrollbarPadding, ImMin(bb_frame_width, bb_frame_height) * 0.5f));
|
||||||
|
bb.Expand(-padding);
|
||||||
|
|
||||||
// V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar)
|
// V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar)
|
||||||
const float scrollbar_size_v = (axis == ImGuiAxis_X) ? bb.GetWidth() : bb.GetHeight();
|
const float scrollbar_size_v = (axis == ImGuiAxis_X) ? bb.GetWidth() : bb.GetHeight();
|
||||||
@@ -1836,27 +1836,31 @@ static int IMGUI_CDECL ShrinkWidthItemComparer(const void* lhs, const void* rhs)
|
|||||||
|
|
||||||
// Shrink excess width from a set of item, by removing width from the larger items first.
|
// Shrink excess width from a set of item, by removing width from the larger items first.
|
||||||
// Set items Width to -1.0f to disable shrinking this item.
|
// Set items Width to -1.0f to disable shrinking this item.
|
||||||
void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess)
|
void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess, float width_min)
|
||||||
{
|
{
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
{
|
{
|
||||||
if (items[0].Width >= 0.0f)
|
if (items[0].Width >= 0.0f)
|
||||||
items[0].Width = ImMax(items[0].Width - width_excess, 1.0f);
|
items[0].Width = ImMax(items[0].Width - width_excess, width_min);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImQsort(items, (size_t)count, sizeof(ImGuiShrinkWidthItem), ShrinkWidthItemComparer);
|
ImQsort(items, (size_t)count, sizeof(ImGuiShrinkWidthItem), ShrinkWidthItemComparer); // Sort largest first, smallest last.
|
||||||
int count_same_width = 1;
|
int count_same_width = 1;
|
||||||
while (width_excess > 0.0f && count_same_width < count)
|
while (width_excess > 0.001f && count_same_width < count)
|
||||||
{
|
{
|
||||||
while (count_same_width < count && items[0].Width <= items[count_same_width].Width)
|
while (count_same_width < count && items[0].Width <= items[count_same_width].Width)
|
||||||
count_same_width++;
|
count_same_width++;
|
||||||
float max_width_to_remove_per_item = (count_same_width < count && items[count_same_width].Width >= 0.0f) ? (items[0].Width - items[count_same_width].Width) : (items[0].Width - 1.0f);
|
float max_width_to_remove_per_item = (count_same_width < count && items[count_same_width].Width >= 0.0f) ? (items[0].Width - items[count_same_width].Width) : (items[0].Width - 1.0f);
|
||||||
|
max_width_to_remove_per_item = ImMin(items[0].Width - width_min, max_width_to_remove_per_item);
|
||||||
if (max_width_to_remove_per_item <= 0.0f)
|
if (max_width_to_remove_per_item <= 0.0f)
|
||||||
break;
|
break;
|
||||||
float width_to_remove_per_item = ImMin(width_excess / count_same_width, max_width_to_remove_per_item);
|
float base_width_to_remove_per_item = ImMin(width_excess / count_same_width, max_width_to_remove_per_item);
|
||||||
for (int item_n = 0; item_n < count_same_width; item_n++)
|
for (int item_n = 0; item_n < count_same_width; item_n++)
|
||||||
items[item_n].Width -= width_to_remove_per_item;
|
{
|
||||||
width_excess -= width_to_remove_per_item * count_same_width;
|
float width_to_remove_for_this_item = ImMin(base_width_to_remove_per_item, items[item_n].Width - width_min);
|
||||||
|
items[item_n].Width -= width_to_remove_for_this_item;
|
||||||
|
width_excess -= width_to_remove_for_this_item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Round width and redistribute remainder
|
// Round width and redistribute remainder
|
||||||
@@ -2033,7 +2037,8 @@ bool ImGui::BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
EndPopup();
|
EndPopup();
|
||||||
IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above
|
if (!g.IO.ConfigDebugBeginReturnValueOnce && !g.IO.ConfigDebugBeginReturnValueLoop) // Begin may only return false with those debug tools activated.
|
||||||
|
IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
g.BeginComboDepth++;
|
g.BeginComboDepth++;
|
||||||
@@ -3912,9 +3917,6 @@ bool ImGui::InputDouble(const char* label, double* v, double step, double step_f
|
|||||||
// - InputText()
|
// - InputText()
|
||||||
// - InputTextWithHint()
|
// - InputTextWithHint()
|
||||||
// - InputTextMultiline()
|
// - InputTextMultiline()
|
||||||
// - InputTextGetCharInfo() [Internal]
|
|
||||||
// - InputTextReindexLines() [Internal]
|
|
||||||
// - InputTextReindexLinesRange() [Internal]
|
|
||||||
// - InputTextEx() [Internal]
|
// - InputTextEx() [Internal]
|
||||||
// - DebugNodeInputTextState() [Internal]
|
// - DebugNodeInputTextState() [Internal]
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@@ -3941,75 +3943,11 @@ bool ImGui::InputTextWithHint(const char* label, const char* hint, char* buf, si
|
|||||||
return InputTextEx(label, hint, buf, (int)buf_size, ImVec2(0, 0), flags, callback, user_data);
|
return InputTextEx(label, hint, buf, (int)buf_size, ImVec2(0, 0), flags, callback, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is only used in the path where the multiline widget is inactive.
|
static ImVec2 InputTextCalcTextSize(ImGuiContext* ctx, const char* text_begin, const char* text_end_display, const char* text_end, const char** out_remaining, ImVec2* out_offset, ImDrawTextFlags flags)
|
||||||
static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end)
|
|
||||||
{
|
|
||||||
int line_count = 0;
|
|
||||||
const char* s = text_begin;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
const char* s_eol = strchr(s, '\n');
|
|
||||||
line_count++;
|
|
||||||
if (s_eol == NULL)
|
|
||||||
{
|
|
||||||
s = s + ImStrlen(s);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
s = s_eol + 1;
|
|
||||||
}
|
|
||||||
*out_text_end = s;
|
|
||||||
return line_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Ideally we'd share code with ImFont::CalcTextSizeA()
|
|
||||||
static ImVec2 InputTextCalcTextSize(ImGuiContext* ctx, const char* text_begin, const char* text_end, const char** remaining, ImVec2* out_offset, bool stop_on_new_line)
|
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
//ImFont* font = g.Font;
|
ImGuiInputTextState* obj = &g.InputTextState;
|
||||||
ImFontBaked* baked = g.FontBaked;
|
return ImFontCalcTextSizeEx(g.Font, g.FontSize, FLT_MAX, obj->WrapWidth, text_begin, text_end_display, text_end, out_remaining, out_offset, flags);
|
||||||
const float line_height = g.FontSize;
|
|
||||||
const float scale = line_height / baked->Size;
|
|
||||||
|
|
||||||
ImVec2 text_size = ImVec2(0, 0);
|
|
||||||
float line_width = 0.0f;
|
|
||||||
|
|
||||||
const char* s = text_begin;
|
|
||||||
while (s < text_end)
|
|
||||||
{
|
|
||||||
unsigned int c = (unsigned int)*s;
|
|
||||||
if (c < 0x80)
|
|
||||||
s += 1;
|
|
||||||
else
|
|
||||||
s += ImTextCharFromUtf8(&c, s, text_end);
|
|
||||||
|
|
||||||
if (c == '\n')
|
|
||||||
{
|
|
||||||
text_size.x = ImMax(text_size.x, line_width);
|
|
||||||
text_size.y += line_height;
|
|
||||||
line_width = 0.0f;
|
|
||||||
if (stop_on_new_line)
|
|
||||||
break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c == '\r')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
line_width += baked->GetCharAdvance((ImWchar)c) * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text_size.x < line_width)
|
|
||||||
text_size.x = line_width;
|
|
||||||
|
|
||||||
if (out_offset)
|
|
||||||
*out_offset = ImVec2(line_width, text_size.y + line_height); // offset allow for the possibility of sitting after a trailing \n
|
|
||||||
|
|
||||||
if (line_width > 0 || text_size.y == 0.0f) // whereas size.y will ignore the trailing \n
|
|
||||||
text_size.y += line_height;
|
|
||||||
|
|
||||||
if (remaining)
|
|
||||||
*remaining = s;
|
|
||||||
|
|
||||||
return text_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrapper for stb_textedit.h to edit text (our wrapper is for: statically sized buffer, single-line, wchar characters. InputText converts between UTF-8 and wchar)
|
// Wrapper for stb_textedit.h to edit text (our wrapper is for: statically sized buffer, single-line, wchar characters. InputText converts between UTF-8 and wchar)
|
||||||
@@ -4020,14 +3958,14 @@ static ImVec2 InputTextCalcTextSize(ImGuiContext* ctx, const char* text_begin, c
|
|||||||
namespace ImStb
|
namespace ImStb
|
||||||
{
|
{
|
||||||
static int STB_TEXTEDIT_STRINGLEN(const ImGuiInputTextState* obj) { return obj->TextLen; }
|
static int STB_TEXTEDIT_STRINGLEN(const ImGuiInputTextState* obj) { return obj->TextLen; }
|
||||||
static char STB_TEXTEDIT_GETCHAR(const ImGuiInputTextState* obj, int idx) { IM_ASSERT(idx <= obj->TextLen); return obj->TextSrc[idx]; }
|
static char STB_TEXTEDIT_GETCHAR(const ImGuiInputTextState* obj, int idx) { IM_ASSERT(idx >= 0 && idx <= obj->TextLen); return obj->TextSrc[idx]; }
|
||||||
static float STB_TEXTEDIT_GETWIDTH(ImGuiInputTextState* obj, int line_start_idx, int char_idx) { unsigned int c; ImTextCharFromUtf8(&c, obj->TextSrc + line_start_idx + char_idx, obj->TextSrc + obj->TextLen); if ((ImWchar)c == '\n') return IMSTB_TEXTEDIT_GETWIDTH_NEWLINE; ImGuiContext& g = *obj->Ctx; return g.FontBaked->GetCharAdvance((ImWchar)c) * g.FontBakedScale; }
|
static float STB_TEXTEDIT_GETWIDTH(ImGuiInputTextState* obj, int line_start_idx, int char_idx) { unsigned int c; ImTextCharFromUtf8(&c, obj->TextSrc + line_start_idx + char_idx, obj->TextSrc + obj->TextLen); if ((ImWchar)c == '\n') return IMSTB_TEXTEDIT_GETWIDTH_NEWLINE; ImGuiContext& g = *obj->Ctx; return g.FontBaked->GetCharAdvance((ImWchar)c) * g.FontBakedScale; }
|
||||||
static char STB_TEXTEDIT_NEWLINE = '\n';
|
static char STB_TEXTEDIT_NEWLINE = '\n';
|
||||||
static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, ImGuiInputTextState* obj, int line_start_idx)
|
static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, ImGuiInputTextState* obj, int line_start_idx)
|
||||||
{
|
{
|
||||||
const char* text = obj->TextSrc;
|
const char* text = obj->TextSrc;
|
||||||
const char* text_remaining = NULL;
|
const char* text_remaining = NULL;
|
||||||
const ImVec2 size = InputTextCalcTextSize(obj->Ctx, text + line_start_idx, text + obj->TextLen, &text_remaining, NULL, true);
|
const ImVec2 size = InputTextCalcTextSize(obj->Ctx, text + line_start_idx, text + obj->TextLen, text + obj->TextLen, &text_remaining, NULL, ImDrawTextFlags_StopOnNewLine | ImDrawTextFlags_WrapKeepBlanks);
|
||||||
r->x0 = 0.0f;
|
r->x0 = 0.0f;
|
||||||
r->x1 = size.x;
|
r->x1 = size.x;
|
||||||
r->baseline_y_delta = size.y;
|
r->baseline_y_delta = size.y;
|
||||||
@@ -4129,6 +4067,75 @@ static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(ImGuiInputTextState* obj, int idx)
|
|||||||
#define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h
|
#define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h
|
||||||
#define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_IMPL
|
#define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_IMPL
|
||||||
|
|
||||||
|
// Reimplementation of stb_textedit_move_line_start()/stb_textedit_move_line_end() which supports word-wrapping.
|
||||||
|
static int STB_TEXTEDIT_MOVELINESTART_IMPL(ImGuiInputTextState* obj, ImStb::STB_TexteditState* state, int cursor)
|
||||||
|
{
|
||||||
|
if (state->single_line)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (obj->WrapWidth > 0.0f)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *obj->Ctx;
|
||||||
|
const char* p_cursor = obj->TextSrc + cursor;
|
||||||
|
const char* p_bol = ImStrbol(p_cursor, obj->TextSrc);
|
||||||
|
const char* p = p_bol;
|
||||||
|
const char* text_end = obj->TextSrc + obj->TextLen; // End of line would be enough
|
||||||
|
while (p >= p_bol)
|
||||||
|
{
|
||||||
|
const char* p_eol = ImFontCalcWordWrapPositionEx(g.Font, g.FontSize, p, text_end, obj->WrapWidth, ImDrawTextFlags_WrapKeepBlanks);
|
||||||
|
if (p == p_cursor) // If we are already on a visible beginning-of-line, return real beginning-of-line (would be same as regular handler below)
|
||||||
|
return (int)(p_bol - obj->TextSrc);
|
||||||
|
if (p_eol == p_cursor && obj->TextA[cursor] != '\n' && obj->LastMoveDirectionLR == ImGuiDir_Left)
|
||||||
|
return (int)(p_bol - obj->TextSrc);
|
||||||
|
if (p_eol >= p_cursor)
|
||||||
|
return (int)(p - obj->TextSrc);
|
||||||
|
p = (*p_eol == '\n') ? p_eol + 1 : p_eol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regular handler, same as stb_textedit_move_line_start()
|
||||||
|
while (cursor > 0)
|
||||||
|
{
|
||||||
|
int prev_cursor = IMSTB_TEXTEDIT_GETPREVCHARINDEX(obj, cursor);
|
||||||
|
if (STB_TEXTEDIT_GETCHAR(obj, prev_cursor) == STB_TEXTEDIT_NEWLINE)
|
||||||
|
break;
|
||||||
|
cursor = prev_cursor;
|
||||||
|
}
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int STB_TEXTEDIT_MOVELINEEND_IMPL(ImGuiInputTextState* obj, ImStb::STB_TexteditState* state, int cursor)
|
||||||
|
{
|
||||||
|
int n = STB_TEXTEDIT_STRINGLEN(obj);
|
||||||
|
if (state->single_line)
|
||||||
|
return n;
|
||||||
|
|
||||||
|
if (obj->WrapWidth > 0.0f)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *obj->Ctx;
|
||||||
|
const char* p_cursor = obj->TextSrc + cursor;
|
||||||
|
const char* p = ImStrbol(p_cursor, obj->TextSrc);
|
||||||
|
const char* text_end = obj->TextSrc + obj->TextLen; // End of line would be enough
|
||||||
|
while (p < text_end)
|
||||||
|
{
|
||||||
|
const char* p_eol = ImFontCalcWordWrapPositionEx(g.Font, g.FontSize, p, text_end, obj->WrapWidth, ImDrawTextFlags_WrapKeepBlanks);
|
||||||
|
cursor = (int)(p_eol - obj->TextSrc);
|
||||||
|
if (p_eol == p_cursor && obj->LastMoveDirectionLR != ImGuiDir_Left) // If we are already on a visible end-of-line, switch to regular handle
|
||||||
|
break;
|
||||||
|
if (p_eol > p_cursor)
|
||||||
|
return cursor;
|
||||||
|
p = (*p_eol == '\n') ? p_eol + 1 : p_eol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Regular handler, same as stb_textedit_move_line_end()
|
||||||
|
while (cursor < n && STB_TEXTEDIT_GETCHAR(obj, cursor) != STB_TEXTEDIT_NEWLINE)
|
||||||
|
cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(obj, cursor);
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define STB_TEXTEDIT_MOVELINESTART STB_TEXTEDIT_MOVELINESTART_IMPL
|
||||||
|
#define STB_TEXTEDIT_MOVELINEEND STB_TEXTEDIT_MOVELINEEND_IMPL
|
||||||
|
|
||||||
static void STB_TEXTEDIT_DELETECHARS(ImGuiInputTextState* obj, int pos, int n)
|
static void STB_TEXTEDIT_DELETECHARS(ImGuiInputTextState* obj, int pos, int n)
|
||||||
{
|
{
|
||||||
// Offset remaining text (+ copy zero terminator)
|
// Offset remaining text (+ copy zero terminator)
|
||||||
@@ -4232,6 +4239,11 @@ void ImGuiInputTextState::OnKeyPressed(int key)
|
|||||||
stb_textedit_key(this, Stb, key);
|
stb_textedit_key(this, Stb, key);
|
||||||
CursorFollow = true;
|
CursorFollow = true;
|
||||||
CursorAnimReset();
|
CursorAnimReset();
|
||||||
|
const int key_u = (key & ~STB_TEXTEDIT_K_SHIFT);
|
||||||
|
if (key_u == STB_TEXTEDIT_K_LEFT || key_u == STB_TEXTEDIT_K_LINESTART || key_u == STB_TEXTEDIT_K_TEXTSTART || key_u == STB_TEXTEDIT_K_BACKSPACE || key_u == STB_TEXTEDIT_K_WORDLEFT)
|
||||||
|
LastMoveDirectionLR = ImGuiDir_Left;
|
||||||
|
else if (key_u == STB_TEXTEDIT_K_RIGHT || key_u == STB_TEXTEDIT_K_LINEEND || key_u == STB_TEXTEDIT_K_TEXTEND || key_u == STB_TEXTEDIT_K_DELETE || key_u == STB_TEXTEDIT_K_WORDRIGHT)
|
||||||
|
LastMoveDirectionLR = ImGuiDir_Right;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiInputTextState::OnCharPressed(unsigned int c)
|
void ImGuiInputTextState::OnCharPressed(unsigned int c)
|
||||||
@@ -4253,6 +4265,7 @@ void ImGuiInputTextState::ClearSelection() { Stb->select_start
|
|||||||
int ImGuiInputTextState::GetCursorPos() const { return Stb->cursor; }
|
int ImGuiInputTextState::GetCursorPos() const { return Stb->cursor; }
|
||||||
int ImGuiInputTextState::GetSelectionStart() const { return Stb->select_start; }
|
int ImGuiInputTextState::GetSelectionStart() const { return Stb->select_start; }
|
||||||
int ImGuiInputTextState::GetSelectionEnd() const { return Stb->select_end; }
|
int ImGuiInputTextState::GetSelectionEnd() const { return Stb->select_end; }
|
||||||
|
float ImGuiInputTextState::GetPreferredOffsetX() const { return Stb->has_preferred_x ? Stb->preferred_x : -1; }
|
||||||
void ImGuiInputTextState::SelectAll() { Stb->select_start = 0; Stb->cursor = Stb->select_end = TextLen; Stb->has_preferred_x = 0; }
|
void ImGuiInputTextState::SelectAll() { Stb->select_start = 0; Stb->cursor = Stb->select_end = TextLen; Stb->has_preferred_x = 0; }
|
||||||
void ImGuiInputTextState::ReloadUserBufAndSelectAll() { WantReloadUserBuf = true; ReloadSelectionStart = 0; ReloadSelectionEnd = INT_MAX; }
|
void ImGuiInputTextState::ReloadUserBufAndSelectAll() { WantReloadUserBuf = true; ReloadSelectionStart = 0; ReloadSelectionEnd = INT_MAX; }
|
||||||
void ImGuiInputTextState::ReloadUserBufAndKeepSelection() { WantReloadUserBuf = true; ReloadSelectionStart = Stb->select_start; ReloadSelectionEnd = Stb->select_end; }
|
void ImGuiInputTextState::ReloadUserBufAndKeepSelection() { WantReloadUserBuf = true; ReloadSelectionStart = Stb->select_start; ReloadSelectionEnd = Stb->select_end; }
|
||||||
@@ -4402,7 +4415,7 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, Im
|
|||||||
if (c == '.' || c == ',')
|
if (c == '.' || c == ',')
|
||||||
c = c_decimal_point;
|
c = c_decimal_point;
|
||||||
|
|
||||||
// Full-width -> half-width conversion for numeric fields (https://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms_(Unicode_block)
|
// Full-width -> half-width conversion for numeric fields: https://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms_(Unicode_block)
|
||||||
// While this is mostly convenient, this has the side-effect for uninformed users accidentally inputting full-width characters that they may
|
// While this is mostly convenient, this has the side-effect for uninformed users accidentally inputting full-width characters that they may
|
||||||
// scratch their head as to why it works in numerical fields vs in generic text fields it would require support in the font.
|
// scratch their head as to why it works in numerical fields vs in generic text fields it would require support in the font.
|
||||||
if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsScientific | ImGuiInputTextFlags_CharsHexadecimal))
|
if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsScientific | ImGuiInputTextFlags_CharsHexadecimal))
|
||||||
@@ -4507,6 +4520,97 @@ void ImGui::InputTextDeactivateHook(ImGuiID id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int* ImLowerBound(int* in_begin, int* in_end, int v)
|
||||||
|
{
|
||||||
|
int* in_p = in_begin;
|
||||||
|
for (size_t count = (size_t)(in_end - in_p); count > 0; )
|
||||||
|
{
|
||||||
|
size_t count2 = count >> 1;
|
||||||
|
int* mid = in_p + count2;
|
||||||
|
if (*mid < v)
|
||||||
|
{
|
||||||
|
in_p = ++mid;
|
||||||
|
count -= count2 + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count = count2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return in_p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME-WORDWRAP: Bundle some of this into ImGuiTextIndex and/or extract as a different tool?
|
||||||
|
// 'max_output_buffer_size' happens to be a meaningful optimization to avoid writing the full line_index when not necessarily needed (e.g. very large buffer, scrolled up, inactive)
|
||||||
|
static int InputTextLineIndexBuild(ImGuiInputTextFlags flags, ImGuiTextIndex* line_index, const char* buf, const char* buf_end, float wrap_width, int max_output_buffer_size, const char** out_buf_end)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
int size = 0;
|
||||||
|
const char* s;
|
||||||
|
if (flags & ImGuiInputTextFlags_WordWrap)
|
||||||
|
{
|
||||||
|
for (s = buf; s < buf_end; s = (*s == '\n') ? s + 1 : s)
|
||||||
|
{
|
||||||
|
if (size++ <= max_output_buffer_size)
|
||||||
|
line_index->Offsets.push_back((int)(s - buf));
|
||||||
|
s = ImFontCalcWordWrapPositionEx(g.Font, g.FontSize, s, buf_end, wrap_width, ImDrawTextFlags_WrapKeepBlanks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (buf_end != NULL)
|
||||||
|
{
|
||||||
|
for (s = buf; s < buf_end; s = s ? s + 1 : buf_end)
|
||||||
|
{
|
||||||
|
if (size++ <= max_output_buffer_size)
|
||||||
|
line_index->Offsets.push_back((int)(s - buf));
|
||||||
|
s = (const char*)ImMemchr(s, '\n', buf_end - s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char* s_eol;
|
||||||
|
for (s = buf; ; s = s_eol + 1)
|
||||||
|
{
|
||||||
|
if (size++ <= max_output_buffer_size)
|
||||||
|
line_index->Offsets.push_back((int)(s - buf));
|
||||||
|
if ((s_eol = strchr(s, '\n')) != NULL)
|
||||||
|
continue;
|
||||||
|
s += strlen(s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out_buf_end != NULL)
|
||||||
|
*out_buf_end = buf_end = s;
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
line_index->Offsets.push_back(0);
|
||||||
|
size++;
|
||||||
|
}
|
||||||
|
if (buf_end > buf && buf_end[-1] == '\n' && size <= max_output_buffer_size)
|
||||||
|
{
|
||||||
|
line_index->Offsets.push_back((int)(buf_end - buf));
|
||||||
|
size++;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 InputTextLineIndexGetPosOffset(ImGuiContext& g, ImGuiInputTextState* state, ImGuiTextIndex* line_index, const char* buf, const char* buf_end, int cursor_n)
|
||||||
|
{
|
||||||
|
const char* cursor_ptr = buf + cursor_n;
|
||||||
|
int* it_begin = line_index->Offsets.begin();
|
||||||
|
int* it_end = line_index->Offsets.end();
|
||||||
|
const int* it = ImLowerBound(it_begin, it_end, cursor_n);
|
||||||
|
if (it > it_begin)
|
||||||
|
if (it == it_end || *it != cursor_n || (state != NULL && state->WrapWidth > 0.0f && state->LastMoveDirectionLR == ImGuiDir_Right && cursor_ptr[-1] != '\n' && cursor_ptr[-1] != 0))
|
||||||
|
it--;
|
||||||
|
|
||||||
|
const int line_no = (it == it_begin) ? 0 : line_index->Offsets.index_from_ptr(it);
|
||||||
|
const char* line_start = line_index->get_line_begin(buf, line_no);
|
||||||
|
ImVec2 offset;
|
||||||
|
offset.x = InputTextCalcTextSize(&g, line_start, cursor_ptr, buf_end, NULL, NULL, ImDrawTextFlags_WrapKeepBlanks).x;
|
||||||
|
offset.y = (line_no + 1) * g.FontSize;
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
// Edit a string of text
|
// Edit a string of text
|
||||||
// - buf_size account for the zero-terminator, so a buf_size of 6 can hold "Hello" but not "Hello!".
|
// - buf_size account for the zero-terminator, so a buf_size of 6 can hold "Hello" but not "Hello!".
|
||||||
// This is so we can easily call InputText() on static arrays using ARRAYSIZE() and to match
|
// This is so we can easily call InputText() on static arrays using ARRAYSIZE() and to match
|
||||||
@@ -4524,7 +4628,9 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
IM_ASSERT(buf != NULL && buf_size >= 0);
|
IM_ASSERT(buf != NULL && buf_size >= 0);
|
||||||
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys)
|
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys)
|
||||||
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key)
|
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key)
|
||||||
IM_ASSERT(!((flags & ImGuiInputTextFlags_ElideLeft) && (flags & ImGuiInputTextFlags_Multiline))); // Multiline will not work with left-trimming
|
IM_ASSERT(!((flags & ImGuiInputTextFlags_ElideLeft) && (flags & ImGuiInputTextFlags_Multiline))); // Multiline does not not work with left-trimming
|
||||||
|
IM_ASSERT((flags & ImGuiInputTextFlags_WordWrap) == 0 || (flags & ImGuiInputTextFlags_Password) == 0); // WordWrap does not work with Password mode.
|
||||||
|
IM_ASSERT((flags & ImGuiInputTextFlags_WordWrap) == 0 || (flags & ImGuiInputTextFlags_Multiline) != 0); // WordWrap does not work in single-line mode.
|
||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiIO& io = g.IO;
|
ImGuiIO& io = g.IO;
|
||||||
@@ -4558,8 +4664,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
item_data_backup = g.LastItemData;
|
item_data_backup = g.LastItemData;
|
||||||
window->DC.CursorPos = backup_pos;
|
window->DC.CursorPos = backup_pos;
|
||||||
|
|
||||||
// Prevent NavActivation from Tabbing when our widget accepts Tab inputs: this allows cycling through widgets without stopping.
|
// Prevent NavActivation from explicit Tabbing when our widget accepts Tab inputs: this allows cycling through widgets without stopping.
|
||||||
if (g.NavActivateId == id && (g.NavActivateFlags & ImGuiActivateFlags_FromTabbing) && (flags & ImGuiInputTextFlags_AllowTabInput))
|
if (g.NavActivateId == id && (g.NavActivateFlags & ImGuiActivateFlags_FromTabbing) && !(g.NavActivateFlags & ImGuiActivateFlags_FromFocusApi) && (flags & ImGuiInputTextFlags_AllowTabInput))
|
||||||
g.NavActivateId = 0;
|
g.NavActivateId = 0;
|
||||||
|
|
||||||
// Prevent NavActivate reactivating in BeginChild() when we are already active.
|
// Prevent NavActivate reactivating in BeginChild() when we are already active.
|
||||||
@@ -4615,6 +4721,13 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
if (is_resizable)
|
if (is_resizable)
|
||||||
IM_ASSERT(callback != NULL); // Must provide a callback if you set the ImGuiInputTextFlags_CallbackResize flag!
|
IM_ASSERT(callback != NULL); // Must provide a callback if you set the ImGuiInputTextFlags_CallbackResize flag!
|
||||||
|
|
||||||
|
// Word-wrapping: enforcing a fixed width not altered by vertical scrollbar makes things easier, notably to track cursor reliably and avoid one-frame glitches.
|
||||||
|
// Instead of using ImGuiWindowFlags_AlwaysVerticalScrollbar we account for that space if the scrollbar is not visible.
|
||||||
|
const bool is_wordwrap = (flags & ImGuiInputTextFlags_WordWrap) != 0;
|
||||||
|
float wrap_width = 0.0f;
|
||||||
|
if (is_wordwrap)
|
||||||
|
wrap_width = ImMax(1.0f, GetContentRegionAvail().x + (draw_window->ScrollbarY ? 0.0f : -g.Style.ScrollbarSize));
|
||||||
|
|
||||||
const bool input_requested_by_nav = (g.ActiveId != id) && ((g.NavActivateId == id) && ((g.NavActivateFlags & ImGuiActivateFlags_PreferInput) || (g.NavInputSource == ImGuiInputSource_Keyboard)));
|
const bool input_requested_by_nav = (g.ActiveId != id) && ((g.NavActivateId == id) && ((g.NavActivateFlags & ImGuiActivateFlags_PreferInput) || (g.NavInputSource == ImGuiInputSource_Keyboard)));
|
||||||
|
|
||||||
const bool user_clicked = hovered && io.MouseClicked[0];
|
const bool user_clicked = hovered && io.MouseClicked[0];
|
||||||
@@ -4654,7 +4767,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
// Take a copy of the initial buffer value.
|
// Take a copy of the initial buffer value.
|
||||||
// From the moment we focused we are normally ignoring the content of 'buf' (unless we are in read-only mode)
|
// From the moment we focused we are normally ignoring the content of 'buf' (unless we are in read-only mode)
|
||||||
const int buf_len = (int)ImStrlen(buf);
|
const int buf_len = (int)ImStrlen(buf);
|
||||||
IM_ASSERT(buf_len + 1 <= buf_size && "Is your input buffer properly zero-terminated?");
|
IM_ASSERT(((buf_len + 1 <= buf_size) || (buf_len == 0 && buf_size == 0)) && "Is your input buffer properly zero-terminated?");
|
||||||
state->TextToRevertTo.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string.
|
state->TextToRevertTo.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string.
|
||||||
memcpy(state->TextToRevertTo.Data, buf, buf_len + 1);
|
memcpy(state->TextToRevertTo.Data, buf, buf_len + 1);
|
||||||
|
|
||||||
@@ -4767,6 +4880,15 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
if (is_password && !is_displaying_hint)
|
if (is_password && !is_displaying_hint)
|
||||||
PushPasswordFont();
|
PushPasswordFont();
|
||||||
|
|
||||||
|
// Word-wrapping: attempt to keep cursor in view while resizing frame/parent
|
||||||
|
// FIXME-WORDWRAP: It would be better to preserve same relative offset.
|
||||||
|
if (is_wordwrap && state != NULL && state->ID == id && state->WrapWidth != wrap_width)
|
||||||
|
{
|
||||||
|
state->CursorCenterY = true;
|
||||||
|
state->WrapWidth = wrap_width;
|
||||||
|
render_cursor = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Process mouse inputs and character inputs
|
// Process mouse inputs and character inputs
|
||||||
if (g.ActiveId == id)
|
if (g.ActiveId == id)
|
||||||
{
|
{
|
||||||
@@ -4774,6 +4896,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
state->Edited = false;
|
state->Edited = false;
|
||||||
state->BufCapacity = buf_size;
|
state->BufCapacity = buf_size;
|
||||||
state->Flags = flags;
|
state->Flags = flags;
|
||||||
|
state->WrapWidth = wrap_width;
|
||||||
|
|
||||||
// Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget.
|
// Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget.
|
||||||
// Down the line we should have a cleaner library-wide concept of Selected vs Active.
|
// Down the line we should have a cleaner library-wide concept of Selected vs Active.
|
||||||
@@ -4811,9 +4934,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
{
|
{
|
||||||
// Triple-click: Select line
|
// Triple-click: Select line
|
||||||
const bool is_eol = ImStb::STB_TEXTEDIT_GETCHAR(state, state->Stb->cursor) == '\n';
|
const bool is_eol = ImStb::STB_TEXTEDIT_GETCHAR(state, state->Stb->cursor) == '\n';
|
||||||
|
state->WrapWidth = 0.0f; // Temporarily disable wrapping so we use real line start.
|
||||||
state->OnKeyPressed(STB_TEXTEDIT_K_LINESTART);
|
state->OnKeyPressed(STB_TEXTEDIT_K_LINESTART);
|
||||||
state->OnKeyPressed(STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT);
|
state->OnKeyPressed(STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT);
|
||||||
state->OnKeyPressed(STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT);
|
state->OnKeyPressed(STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT);
|
||||||
|
state->WrapWidth = wrap_width;
|
||||||
if (!is_eol && is_multiline)
|
if (!is_eol && is_multiline)
|
||||||
{
|
{
|
||||||
ImSwap(state->Stb->select_start, state->Stb->select_end);
|
ImSwap(state->Stb->select_start, state->Stb->select_end);
|
||||||
@@ -4946,7 +5071,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
{
|
{
|
||||||
// Determine if we turn Enter into a \n character
|
// Determine if we turn Enter into a \n character
|
||||||
bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0;
|
bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0;
|
||||||
if (!is_multiline || is_gamepad_validate || (ctrl_enter_for_new_line && !io.KeyCtrl) || (!ctrl_enter_for_new_line && io.KeyCtrl))
|
if (!is_multiline || is_gamepad_validate || (ctrl_enter_for_new_line != io.KeyCtrl))
|
||||||
{
|
{
|
||||||
validated = true;
|
validated = true;
|
||||||
if (io.ConfigInputTextEnterKeepActive && !is_multiline)
|
if (io.ConfigInputTextEnterKeepActive && !is_multiline)
|
||||||
@@ -4965,7 +5090,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
{
|
{
|
||||||
if (flags & ImGuiInputTextFlags_EscapeClearsAll)
|
if (flags & ImGuiInputTextFlags_EscapeClearsAll)
|
||||||
{
|
{
|
||||||
if (buf[0] != 0)
|
if (state->TextA.Data[0] != 0)
|
||||||
{
|
{
|
||||||
revert_edit = true;
|
revert_edit = true;
|
||||||
}
|
}
|
||||||
@@ -5057,14 +5182,14 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
if (flags & ImGuiInputTextFlags_EscapeClearsAll)
|
if (flags & ImGuiInputTextFlags_EscapeClearsAll)
|
||||||
{
|
{
|
||||||
// Clear input
|
// Clear input
|
||||||
IM_ASSERT(buf[0] != 0);
|
IM_ASSERT(state->TextA.Data[0] != 0);
|
||||||
apply_new_text = "";
|
apply_new_text = "";
|
||||||
apply_new_text_length = 0;
|
apply_new_text_length = 0;
|
||||||
value_changed = true;
|
value_changed = true;
|
||||||
IMSTB_TEXTEDIT_CHARTYPE empty_string;
|
char empty_string = 0;
|
||||||
stb_textedit_replace(state, state->Stb, &empty_string, 0);
|
stb_textedit_replace(state, state->Stb, &empty_string, 0);
|
||||||
}
|
}
|
||||||
else if (strcmp(buf, state->TextToRevertTo.Data) != 0)
|
else if (strcmp(state->TextA.Data, state->TextToRevertTo.Data) != 0)
|
||||||
{
|
{
|
||||||
apply_new_text = state->TextToRevertTo.Data;
|
apply_new_text = state->TextToRevertTo.Data;
|
||||||
apply_new_text_length = state->TextToRevertTo.Size - 1;
|
apply_new_text_length = state->TextToRevertTo.Size - 1;
|
||||||
@@ -5231,9 +5356,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImVec4 clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + inner_size.x, frame_bb.Min.y + inner_size.y); // Not using frame_bb.Max because we have adjusted size
|
|
||||||
ImVec2 draw_pos = is_multiline ? draw_window->DC.CursorPos : frame_bb.Min + style.FramePadding;
|
ImVec2 draw_pos = is_multiline ? draw_window->DC.CursorPos : frame_bb.Min + style.FramePadding;
|
||||||
ImVec2 text_size(0.0f, 0.0f);
|
ImVec2 text_size(0.0f, 0.0f);
|
||||||
|
ImRect clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + inner_size.x, frame_bb.Min.y + inner_size.y); // Not using frame_bb.Max because we have adjusted size
|
||||||
|
if (is_multiline)
|
||||||
|
clip_rect.ClipWith(draw_window->ClipRect);
|
||||||
|
|
||||||
// Set upper limit of single-line InputTextEx() at 2 million characters strings. The current pathological worst case is a long line
|
// Set upper limit of single-line InputTextEx() at 2 million characters strings. The current pathological worst case is a long line
|
||||||
// without any carriage return, which would makes ImFont::RenderText() reserve too many vertices and probably crash. Avoid it altogether.
|
// without any carriage return, which would makes ImFont::RenderText() reserve too many vertices and probably crash. Avoid it altogether.
|
||||||
@@ -5258,15 +5385,42 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
buf_display = hint;
|
buf_display = hint;
|
||||||
buf_display_end = hint + ImStrlen(hint);
|
buf_display_end = hint + ImStrlen(hint);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (render_cursor || render_selection || g.ActiveId == id)
|
||||||
|
buf_display_end = buf_display + state->TextLen; //-V595
|
||||||
|
else if (is_multiline && !is_wordwrap)
|
||||||
|
buf_display_end = NULL; // Inactive multi-line: end of buffer will be output by InputTextLineIndexBuild() special strchr() path.
|
||||||
|
else
|
||||||
|
buf_display_end = buf_display + ImStrlen(buf_display);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate visibility
|
||||||
|
int line_visible_n0 = 0, line_visible_n1 = 1;
|
||||||
|
if (is_multiline)
|
||||||
|
CalcClipRectVisibleItemsY(clip_rect, draw_pos, g.FontSize, &line_visible_n0, &line_visible_n1);
|
||||||
|
|
||||||
|
// Build line index for easy data access (makes code below simpler and faster)
|
||||||
|
ImGuiTextIndex* line_index = &g.InputTextLineIndex;
|
||||||
|
line_index->Offsets.resize(0);
|
||||||
|
int line_count = 1;
|
||||||
|
if (is_multiline)
|
||||||
|
line_count = InputTextLineIndexBuild(flags, line_index, buf_display, buf_display_end, wrap_width, (render_cursor && state && state->CursorFollow) ? INT_MAX : line_visible_n1 + 1, buf_display_end ? NULL : &buf_display_end);
|
||||||
|
line_index->EndOffset = (int)(buf_display_end - buf_display);
|
||||||
|
line_visible_n1 = ImMin(line_visible_n1, line_count);
|
||||||
|
|
||||||
|
// Store text height (we don't need width)
|
||||||
|
text_size = ImVec2(inner_size.x, line_count * g.FontSize);
|
||||||
|
//GetForegroundDrawList()->AddRect(draw_pos + ImVec2(0, line_visible_n0 * g.FontSize), draw_pos + ImVec2(frame_size.x, line_visible_n1 * g.FontSize), IM_COL32(255, 0, 0, 255));
|
||||||
|
|
||||||
|
// Calculate blinking cursor position
|
||||||
|
const ImVec2 cursor_offset = render_cursor && state ? InputTextLineIndexGetPosOffset(g, state, line_index, buf_display, buf_display_end, state->Stb->cursor) : ImVec2(0.0f, 0.0f);
|
||||||
|
ImVec2 draw_scroll;
|
||||||
|
|
||||||
// Render text. We currently only render selection when the widget is active or while scrolling.
|
// Render text. We currently only render selection when the widget is active or while scrolling.
|
||||||
// FIXME: We could remove the '&& render_cursor' to keep rendering selection when inactive.
|
const ImU32 text_col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text);
|
||||||
if (render_cursor || render_selection)
|
if (render_cursor || render_selection)
|
||||||
{
|
{
|
||||||
IM_ASSERT(state != NULL);
|
|
||||||
if (!is_displaying_hint)
|
|
||||||
buf_display_end = buf_display + state->TextLen;
|
|
||||||
|
|
||||||
// Render text (with cursor and selection)
|
// Render text (with cursor and selection)
|
||||||
// This is going to be messy. We need to:
|
// This is going to be messy. We need to:
|
||||||
// - Display the text (this alone can be more easily clipped)
|
// - Display the text (this alone can be more easily clipped)
|
||||||
@@ -5274,48 +5428,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
// - Measure text height (for scrollbar)
|
// - Measure text height (for scrollbar)
|
||||||
// We are attempting to do most of that in **one main pass** to minimize the computation cost (non-negligible for large amount of text) + 2nd pass for selection rendering (we could merge them by an extra refactoring effort)
|
// We are attempting to do most of that in **one main pass** to minimize the computation cost (non-negligible for large amount of text) + 2nd pass for selection rendering (we could merge them by an extra refactoring effort)
|
||||||
// FIXME: This should occur on buf_display but we'd need to maintain cursor/select_start/select_end for UTF-8.
|
// FIXME: This should occur on buf_display but we'd need to maintain cursor/select_start/select_end for UTF-8.
|
||||||
const char* text_begin = buf_display;
|
IM_ASSERT(state != NULL);
|
||||||
const char* text_end = text_begin + state->TextLen;
|
state->LineCount = line_count;
|
||||||
ImVec2 cursor_offset, select_start_offset;
|
|
||||||
|
|
||||||
{
|
|
||||||
// Find lines numbers straddling cursor and selection min position
|
|
||||||
int cursor_line_no = render_cursor ? -1 : -1000;
|
|
||||||
int selmin_line_no = render_selection ? -1 : -1000;
|
|
||||||
const char* cursor_ptr = render_cursor ? text_begin + state->Stb->cursor : NULL;
|
|
||||||
const char* selmin_ptr = render_selection ? text_begin + ImMin(state->Stb->select_start, state->Stb->select_end) : NULL;
|
|
||||||
|
|
||||||
// Count lines and find line number for cursor and selection ends
|
|
||||||
int line_count = 1;
|
|
||||||
if (is_multiline)
|
|
||||||
{
|
|
||||||
for (const char* s = text_begin; (s = (const char*)ImMemchr(s, '\n', (size_t)(text_end - s))) != NULL; s++)
|
|
||||||
{
|
|
||||||
if (cursor_line_no == -1 && s >= cursor_ptr) { cursor_line_no = line_count; }
|
|
||||||
if (selmin_line_no == -1 && s >= selmin_ptr) { selmin_line_no = line_count; }
|
|
||||||
line_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cursor_line_no == -1)
|
|
||||||
cursor_line_no = line_count;
|
|
||||||
if (selmin_line_no == -1)
|
|
||||||
selmin_line_no = line_count;
|
|
||||||
|
|
||||||
// Calculate 2d position by finding the beginning of the line and measuring distance
|
|
||||||
cursor_offset.x = InputTextCalcTextSize(&g, ImStrbol(cursor_ptr, text_begin), cursor_ptr).x;
|
|
||||||
cursor_offset.y = cursor_line_no * g.FontSize;
|
|
||||||
if (selmin_line_no >= 0)
|
|
||||||
{
|
|
||||||
select_start_offset.x = InputTextCalcTextSize(&g, ImStrbol(selmin_ptr, text_begin), selmin_ptr).x;
|
|
||||||
select_start_offset.y = selmin_line_no * g.FontSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store text height (note that we haven't calculated text width at all, see GitHub issues #383, #1224)
|
|
||||||
if (is_multiline)
|
|
||||||
text_size = ImVec2(inner_size.x, line_count * g.FontSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scroll
|
// Scroll
|
||||||
|
float new_scroll_y = scroll_y;
|
||||||
if (render_cursor && state->CursorFollow)
|
if (render_cursor && state->CursorFollow)
|
||||||
{
|
{
|
||||||
// Horizontal scroll in chunks of quarter width
|
// Horizontal scroll in chunks of quarter width
|
||||||
@@ -5330,7 +5447,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state->Scroll.y = 0.0f;
|
state->Scroll.x = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertical scroll
|
// Vertical scroll
|
||||||
@@ -5338,103 +5455,105 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
{
|
{
|
||||||
// Test if cursor is vertically visible
|
// Test if cursor is vertically visible
|
||||||
if (cursor_offset.y - g.FontSize < scroll_y)
|
if (cursor_offset.y - g.FontSize < scroll_y)
|
||||||
scroll_y = ImMax(0.0f, cursor_offset.y - g.FontSize);
|
new_scroll_y = ImMax(0.0f, cursor_offset.y - g.FontSize);
|
||||||
else if (cursor_offset.y - (inner_size.y - style.FramePadding.y * 2.0f) >= scroll_y)
|
else if (cursor_offset.y - (inner_size.y - style.FramePadding.y * 2.0f) >= scroll_y)
|
||||||
scroll_y = cursor_offset.y - inner_size.y + style.FramePadding.y * 2.0f;
|
new_scroll_y = cursor_offset.y - inner_size.y + style.FramePadding.y * 2.0f;
|
||||||
const float scroll_max_y = ImMax((text_size.y + style.FramePadding.y * 2.0f) - inner_size.y, 0.0f);
|
|
||||||
scroll_y = ImClamp(scroll_y, 0.0f, scroll_max_y);
|
|
||||||
draw_pos.y += (draw_window->Scroll.y - scroll_y); // Manipulate cursor pos immediately avoid a frame of lag
|
|
||||||
draw_window->Scroll.y = scroll_y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state->CursorFollow = false;
|
state->CursorFollow = false;
|
||||||
}
|
}
|
||||||
|
if (state->CursorCenterY)
|
||||||
|
{
|
||||||
|
if (is_multiline)
|
||||||
|
new_scroll_y = cursor_offset.y - g.FontSize - (inner_size.y * 0.5f - style.FramePadding.y);
|
||||||
|
state->CursorCenterY = false;
|
||||||
|
render_cursor = false;
|
||||||
|
}
|
||||||
|
if (new_scroll_y != scroll_y)
|
||||||
|
{
|
||||||
|
const float scroll_max_y = ImMax((text_size.y + style.FramePadding.y * 2.0f) - inner_size.y, 0.0f);
|
||||||
|
scroll_y = ImClamp(new_scroll_y, 0.0f, scroll_max_y);
|
||||||
|
draw_pos.y += (draw_window->Scroll.y - scroll_y); // Manipulate cursor pos immediately avoid a frame of lag
|
||||||
|
draw_window->Scroll.y = scroll_y;
|
||||||
|
CalcClipRectVisibleItemsY(clip_rect, draw_pos, g.FontSize, &line_visible_n0, &line_visible_n1);
|
||||||
|
line_visible_n1 = ImMin(line_visible_n1, line_count);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw selection
|
// Draw selection
|
||||||
const ImVec2 draw_scroll = ImVec2(state->Scroll.x, 0.0f);
|
draw_scroll.x = state->Scroll.x;
|
||||||
if (render_selection)
|
if (render_selection)
|
||||||
{
|
{
|
||||||
const char* text_selected_begin = text_begin + ImMin(state->Stb->select_start, state->Stb->select_end);
|
const ImU32 bg_color = GetColorU32(ImGuiCol_TextSelectedBg, render_cursor ? 1.0f : 0.6f); // FIXME: current code flow mandate that render_cursor is always true here, we are leaving the transparent one for tests.
|
||||||
const char* text_selected_end = text_begin + ImMax(state->Stb->select_start, state->Stb->select_end);
|
const float bg_offy_up = is_multiline ? 0.0f : -1.0f; // FIXME: those offsets should be part of the style? they don't play so well with multi-line selection.
|
||||||
|
const float bg_offy_dn = is_multiline ? 0.0f : 2.0f;
|
||||||
|
const float bg_eol_width = IM_TRUNC(g.FontBaked->GetCharAdvance((ImWchar)' ') * 0.50f); // So we can see selected empty lines
|
||||||
|
|
||||||
ImU32 bg_color = GetColorU32(ImGuiCol_TextSelectedBg, render_cursor ? 1.0f : 0.6f); // FIXME: current code flow mandate that render_cursor is always true here, we are leaving the transparent one for tests.
|
const char* text_selected_begin = buf_display + ImMin(state->Stb->select_start, state->Stb->select_end);
|
||||||
float bg_offy_up = is_multiline ? 0.0f : -1.0f; // FIXME: those offsets should be part of the style? they don't play so well with multi-line selection.
|
const char* text_selected_end = buf_display + ImMax(state->Stb->select_start, state->Stb->select_end);
|
||||||
float bg_offy_dn = is_multiline ? 0.0f : 2.0f;
|
for (int line_n = line_visible_n0; line_n < line_visible_n1; line_n++)
|
||||||
ImVec2 rect_pos = draw_pos + select_start_offset - draw_scroll;
|
|
||||||
for (const char* p = text_selected_begin; p < text_selected_end; )
|
|
||||||
{
|
{
|
||||||
if (rect_pos.y > clip_rect.w + g.FontSize)
|
const char* p = line_index->get_line_begin(buf_display, line_n);
|
||||||
break;
|
const char* p_eol = line_index->get_line_end(buf_display, line_n);
|
||||||
if (rect_pos.y < clip_rect.y)
|
const bool p_eol_is_wrap = (p_eol < buf_display_end && *p_eol != '\n');
|
||||||
{
|
if (p_eol_is_wrap)
|
||||||
p = (const char*)ImMemchr((void*)p, '\n', text_selected_end - p);
|
p_eol++;
|
||||||
p = p ? p + 1 : text_selected_end;
|
const char* line_selected_begin = (text_selected_begin > p) ? text_selected_begin : p;
|
||||||
}
|
const char* line_selected_end = (text_selected_end < p_eol) ? text_selected_end : p_eol;
|
||||||
else
|
|
||||||
{
|
|
||||||
ImVec2 rect_size = InputTextCalcTextSize(&g, p, text_selected_end, &p, NULL, true);
|
|
||||||
if (rect_size.x <= 0.0f) rect_size.x = IM_TRUNC(g.FontBaked->GetCharAdvance((ImWchar)' ') * 0.50f); // So we can see selected empty lines
|
|
||||||
ImRect rect(rect_pos + ImVec2(0.0f, bg_offy_up - g.FontSize), rect_pos + ImVec2(rect_size.x, bg_offy_dn));
|
|
||||||
rect.ClipWith(clip_rect);
|
|
||||||
if (rect.Overlaps(clip_rect))
|
|
||||||
draw_window->DrawList->AddRectFilled(rect.Min, rect.Max, bg_color);
|
|
||||||
rect_pos.x = draw_pos.x - draw_scroll.x;
|
|
||||||
}
|
|
||||||
rect_pos.y += g.FontSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We test for 'buf_display_max_length' as a way to avoid some pathological cases (e.g. single-line 1 MB string) which would make ImDrawList crash.
|
float rect_width = 0.0f;
|
||||||
// FIXME-OPT: Multiline could submit a smaller amount of contents to AddText() since we already iterated through it.
|
if (line_selected_begin < line_selected_end)
|
||||||
if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length)
|
rect_width += CalcTextSize(line_selected_begin, line_selected_end).x;
|
||||||
{
|
if (text_selected_begin <= p_eol && text_selected_end > p_eol && !p_eol_is_wrap)
|
||||||
ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text);
|
rect_width += bg_eol_width; // So we can see selected empty lines
|
||||||
draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos - draw_scroll, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect);
|
if (rect_width == 0.0f)
|
||||||
}
|
continue;
|
||||||
|
|
||||||
// Draw blinking cursor
|
ImRect rect;
|
||||||
if (render_cursor)
|
rect.Min.x = draw_pos.x - draw_scroll.x + CalcTextSize(p, line_selected_begin).x;
|
||||||
{
|
rect.Min.y = draw_pos.y - draw_scroll.y + line_n * g.FontSize;
|
||||||
state->CursorAnim += io.DeltaTime;
|
rect.Max.x = rect.Min.x + rect_width;
|
||||||
bool cursor_is_visible = (!g.IO.ConfigInputTextCursorBlink) || (state->CursorAnim <= 0.0f) || ImFmod(state->CursorAnim, 1.20f) <= 0.80f;
|
rect.Max.y = rect.Min.y + bg_offy_dn + g.FontSize;
|
||||||
ImVec2 cursor_screen_pos = ImTrunc(draw_pos + cursor_offset - draw_scroll);
|
rect.Min.y -= bg_offy_up;
|
||||||
ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y - g.FontSize + 0.5f, cursor_screen_pos.x + 1.0f, cursor_screen_pos.y - 1.5f);
|
rect.ClipWith(clip_rect);
|
||||||
if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect))
|
draw_window->DrawList->AddRectFilled(rect.Min, rect.Max, bg_color);
|
||||||
draw_window->DrawList->AddLine(cursor_screen_rect.Min, cursor_screen_rect.GetBL(), GetColorU32(ImGuiCol_InputTextCursor), 1.0f); // FIXME-DPI: Cursor thickness (#7031)
|
|
||||||
|
|
||||||
// Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
|
|
||||||
// This is required for some backends (SDL3) to start emitting character/text inputs.
|
|
||||||
// As per #6341, make sure we don't set that on the deactivating frame.
|
|
||||||
if (!is_readonly && g.ActiveId == id)
|
|
||||||
{
|
|
||||||
ImGuiPlatformImeData* ime_data = &g.PlatformImeData; // (this is a public struct, passed to io.Platform_SetImeDataFn() handler)
|
|
||||||
ime_data->WantVisible = true;
|
|
||||||
ime_data->WantTextInput = true;
|
|
||||||
ime_data->InputPos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize);
|
|
||||||
ime_data->InputLineHeight = g.FontSize;
|
|
||||||
ime_data->ViewportId = window->Viewport->ID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Find render position for right alignment (single-line only)
|
||||||
|
if (g.ActiveId != id && flags & ImGuiInputTextFlags_ElideLeft)
|
||||||
|
draw_pos.x = ImMin(draw_pos.x, frame_bb.Max.x - CalcTextSize(buf_display, NULL).x - style.FramePadding.x);
|
||||||
|
//draw_scroll.x = state->Scroll.x; // Preserve scroll when inactive?
|
||||||
|
|
||||||
|
// Render text
|
||||||
|
if ((is_multiline || (buf_display_end - buf_display) < buf_display_max_length) && (text_col & IM_COL32_A_MASK) && (line_visible_n0 < line_visible_n1))
|
||||||
|
g.Font->RenderText(draw_window->DrawList, g.FontSize,
|
||||||
|
draw_pos - draw_scroll + ImVec2(0.0f, line_visible_n0 * g.FontSize),
|
||||||
|
text_col, clip_rect.AsVec4(),
|
||||||
|
line_index->get_line_begin(buf_display, line_visible_n0),
|
||||||
|
line_index->get_line_end(buf_display, line_visible_n1 - 1),
|
||||||
|
wrap_width, ImDrawTextFlags_WrapKeepBlanks);
|
||||||
|
|
||||||
|
// Render blinking cursor
|
||||||
|
if (render_cursor)
|
||||||
{
|
{
|
||||||
// Render text only (no selection, no cursor)
|
state->CursorAnim += io.DeltaTime;
|
||||||
if (is_multiline)
|
bool cursor_is_visible = (!g.IO.ConfigInputTextCursorBlink) || (state->CursorAnim <= 0.0f) || ImFmod(state->CursorAnim, 1.20f) <= 0.80f;
|
||||||
text_size = ImVec2(inner_size.x, InputTextCalcTextLenAndLineCount(buf_display, &buf_display_end) * g.FontSize); // We don't need width
|
ImVec2 cursor_screen_pos = ImTrunc(draw_pos + cursor_offset - draw_scroll);
|
||||||
else if (!is_displaying_hint && g.ActiveId == id)
|
ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y - g.FontSize + 0.5f, cursor_screen_pos.x + 1.0f, cursor_screen_pos.y - 1.5f);
|
||||||
buf_display_end = buf_display + state->TextLen;
|
if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect))
|
||||||
else if (!is_displaying_hint)
|
draw_window->DrawList->AddLine(cursor_screen_rect.Min, cursor_screen_rect.GetBL(), GetColorU32(ImGuiCol_InputTextCursor), 1.0f); // FIXME-DPI: Cursor thickness (#7031)
|
||||||
buf_display_end = buf_display + ImStrlen(buf_display);
|
|
||||||
|
|
||||||
if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length)
|
// Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
|
||||||
|
// This is required for some backends (SDL3) to start emitting character/text inputs.
|
||||||
|
// As per #6341, make sure we don't set that on the deactivating frame.
|
||||||
|
if (!is_readonly && g.ActiveId == id)
|
||||||
{
|
{
|
||||||
// Find render position for right alignment
|
ImGuiPlatformImeData* ime_data = &g.PlatformImeData; // (this is a public struct, passed to io.Platform_SetImeDataFn() handler)
|
||||||
if (flags & ImGuiInputTextFlags_ElideLeft)
|
ime_data->WantVisible = true;
|
||||||
draw_pos.x = ImMin(draw_pos.x, frame_bb.Max.x - CalcTextSize(buf_display, NULL).x - style.FramePadding.x);
|
ime_data->WantTextInput = true;
|
||||||
|
ime_data->InputPos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize);
|
||||||
const ImVec2 draw_scroll = /*state ? ImVec2(state->Scroll.x, 0.0f) :*/ ImVec2(0.0f, 0.0f); // Preserve scroll when inactive?
|
ime_data->InputLineHeight = g.FontSize;
|
||||||
ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text);
|
ime_data->ViewportId = window->Viewport->ID;
|
||||||
draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos - draw_scroll, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5490,8 +5609,10 @@ void ImGui::DebugNodeInputTextState(ImGuiInputTextState* state)
|
|||||||
ImStb::StbUndoState* undo_state = &stb_state->undostate;
|
ImStb::StbUndoState* undo_state = &stb_state->undostate;
|
||||||
Text("ID: 0x%08X, ActiveID: 0x%08X", state->ID, g.ActiveId);
|
Text("ID: 0x%08X, ActiveID: 0x%08X", state->ID, g.ActiveId);
|
||||||
DebugLocateItemOnHover(state->ID);
|
DebugLocateItemOnHover(state->ID);
|
||||||
Text("CurLenA: %d, Cursor: %d, Selection: %d..%d", state->TextLen, stb_state->cursor, stb_state->select_start, stb_state->select_end);
|
Text("TextLen: %d, Cursor: %d%s, Selection: %d..%d", state->TextLen, stb_state->cursor,
|
||||||
Text("BufCapacity: %d", state->BufCapacity);
|
(state->Flags & ImGuiInputTextFlags_WordWrap) ? (state->LastMoveDirectionLR == ImGuiDir_Left ? " (L)" : " (R)") : "",
|
||||||
|
stb_state->select_start, stb_state->select_end);
|
||||||
|
Text("BufCapacity: %d, LineCount: %d", state->BufCapacity, state->LineCount);
|
||||||
Text("(Internal Buffer: TextA Size: %d, Capacity: %d)", state->TextA.Size, state->TextA.Capacity);
|
Text("(Internal Buffer: TextA Size: %d, Capacity: %d)", state->TextA.Size, state->TextA.Capacity);
|
||||||
Text("has_preferred_x: %d (%.2f)", stb_state->has_preferred_x, stb_state->preferred_x);
|
Text("has_preferred_x: %d (%.2f)", stb_state->has_preferred_x, stb_state->preferred_x);
|
||||||
Text("undo_point: %d, redo_point: %d, undo_char_point: %d, redo_char_point: %d", undo_state->undo_point, undo_state->redo_point, undo_state->undo_char_point, undo_state->redo_char_point);
|
Text("undo_point: %d, redo_point: %d, undo_char_point: %d, redo_char_point: %d", undo_state->undo_point, undo_state->redo_point, undo_state->undo_char_point, undo_state->redo_char_point);
|
||||||
@@ -7219,6 +7340,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|||||||
|
|
||||||
bool hovered, held;
|
bool hovered, held;
|
||||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
|
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
|
||||||
|
bool auto_selected = false;
|
||||||
|
|
||||||
// Multi-selection support (footer)
|
// Multi-selection support (footer)
|
||||||
if (is_multi_select)
|
if (is_multi_select)
|
||||||
@@ -7235,8 +7357,8 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|||||||
// - (2) usage will fail with clipped items
|
// - (2) usage will fail with clipped items
|
||||||
// The multi-select API aim to fix those issues, e.g. may be replaced with a BeginSelection() API.
|
// The multi-select API aim to fix those issues, e.g. may be replaced with a BeginSelection() API.
|
||||||
if ((flags & ImGuiSelectableFlags_SelectOnNav) && g.NavJustMovedToId != 0 && g.NavJustMovedToFocusScopeId == g.CurrentFocusScopeId)
|
if ((flags & ImGuiSelectableFlags_SelectOnNav) && g.NavJustMovedToId != 0 && g.NavJustMovedToFocusScopeId == g.CurrentFocusScopeId)
|
||||||
if (g.NavJustMovedToId == id)
|
if (g.NavJustMovedToId == id && (g.NavJustMovedToKeyMods & ImGuiMod_Ctrl) == 0)
|
||||||
selected = pressed = true;
|
selected = pressed = auto_selected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with keyboard/gamepad
|
// Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with keyboard/gamepad
|
||||||
@@ -7287,7 +7409,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|||||||
RenderTextClipped(pos, ImVec2(ImMin(pos.x + size.x, window->WorkRect.Max.x), pos.y + size.y), label, NULL, &label_size, style.SelectableTextAlign, &bb);
|
RenderTextClipped(pos, ImVec2(ImMin(pos.x + size.x, window->WorkRect.Max.x), pos.y + size.y), label, NULL, &label_size, style.SelectableTextAlign, &bb);
|
||||||
|
|
||||||
// Automatically close popups
|
// Automatically close popups
|
||||||
if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_NoAutoClosePopups) && (g.LastItemData.ItemFlags & ImGuiItemFlags_AutoClosePopups))
|
if (pressed && !auto_selected && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_NoAutoClosePopups) && (g.LastItemData.ItemFlags & ImGuiItemFlags_AutoClosePopups))
|
||||||
CloseCurrentPopup();
|
CloseCurrentPopup();
|
||||||
|
|
||||||
if (disabled_item && !disabled_global)
|
if (disabled_item && !disabled_global)
|
||||||
@@ -8365,7 +8487,7 @@ void ImGuiSelectionBasicStorage::ApplyRequests(ImGuiMultiSelectIO* ms_io)
|
|||||||
// - Optimized select can append unsorted, then sort in a second pass. Optimized unselect can clear in-place then compact in a second pass.
|
// - Optimized select can append unsorted, then sort in a second pass. Optimized unselect can clear in-place then compact in a second pass.
|
||||||
// - A more optimal version wouldn't even use ImGuiStorage but directly a ImVector<ImGuiID> to reduce bandwidth, but this is a reasonable trade off to reuse code.
|
// - A more optimal version wouldn't even use ImGuiStorage but directly a ImVector<ImGuiID> to reduce bandwidth, but this is a reasonable trade off to reuse code.
|
||||||
// - There are many ways this could be better optimized. The worse case scenario being: using BoxSelect2d in a grid, box-select scrolling down while wiggling
|
// - There are many ways this could be better optimized. The worse case scenario being: using BoxSelect2d in a grid, box-select scrolling down while wiggling
|
||||||
// left and right: it affects coarse clipping + can emit multiple SetRange with 1 item each.)
|
// left and right: it affects coarse clipping + can emit multiple SetRange with 1 item each.
|
||||||
// FIXME-OPT: For each block of consecutive SetRange request:
|
// FIXME-OPT: For each block of consecutive SetRange request:
|
||||||
// - add all requests to a sorted list, store ID, selected, offset in ImGuiStorage.
|
// - add all requests to a sorted list, store ID, selected, offset in ImGuiStorage.
|
||||||
// - rewrite sorted storage a single time.
|
// - rewrite sorted storage a single time.
|
||||||
@@ -8886,6 +9008,7 @@ void ImGui::EndMenuBar()
|
|||||||
|
|
||||||
PopClipRect();
|
PopClipRect();
|
||||||
PopID();
|
PopID();
|
||||||
|
IM_MSVC_WARNING_SUPPRESS(6011); // Static Analysis false positive "warning C6011: Dereferencing NULL pointer 'window'"
|
||||||
window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->Pos.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos.
|
window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->Pos.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos.
|
||||||
|
|
||||||
// FIXME: Extremely confusing, cleanup by (a) working on WorkRect stack system (b) not using a Group confusingly here.
|
// FIXME: Extremely confusing, cleanup by (a) working on WorkRect stack system (b) not using a Group confusingly here.
|
||||||
@@ -9084,7 +9207,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
{
|
{
|
||||||
// Menu inside a regular/vertical menu
|
// Menu inside a regular/vertical menu
|
||||||
// (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
|
// (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
|
||||||
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.
|
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.)
|
||||||
popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y);
|
popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y);
|
||||||
float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f;
|
float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f;
|
||||||
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
|
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
|
||||||
@@ -9291,7 +9414,7 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut
|
|||||||
{
|
{
|
||||||
// Menu item inside a vertical menu
|
// Menu item inside a vertical menu
|
||||||
// (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
|
// (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
|
||||||
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.
|
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.)
|
||||||
float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f;
|
float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f;
|
||||||
float shortcut_w = (shortcut && shortcut[0]) ? CalcTextSize(shortcut, NULL).x : 0.0f;
|
float shortcut_w = (shortcut && shortcut[0]) ? CalcTextSize(shortcut, NULL).x : 0.0f;
|
||||||
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
|
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
|
||||||
@@ -9371,6 +9494,7 @@ struct ImGuiTabBarSection
|
|||||||
{
|
{
|
||||||
int TabCount; // Number of tabs in this section.
|
int TabCount; // Number of tabs in this section.
|
||||||
float Width; // Sum of width of tabs in this section (after shrinking down)
|
float Width; // Sum of width of tabs in this section (after shrinking down)
|
||||||
|
float WidthAfterShrinkMinWidth;
|
||||||
float Spacing; // Horizontal spacing at the end of the section.
|
float Spacing; // Horizontal spacing at the end of the section.
|
||||||
|
|
||||||
ImGuiTabBarSection() { memset(this, 0, sizeof(*this)); }
|
ImGuiTabBarSection() { memset(this, 0, sizeof(*this)); }
|
||||||
@@ -9431,6 +9555,19 @@ static ImGuiPtrOrIndex GetTabBarRefFromTabBar(ImGuiTabBar* tab_bar)
|
|||||||
return ImGuiPtrOrIndex(tab_bar);
|
return ImGuiPtrOrIndex(tab_bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGuiTabBar* ImGui::TabBarFindByID(ImGuiID id)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
return g.TabBars.GetByKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove TabBar data (currently only used by TestEngine)
|
||||||
|
void ImGui::TabBarRemove(ImGuiTabBar* tab_bar)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
g.TabBars.Remove(tab_bar->ID, tab_bar);
|
||||||
|
}
|
||||||
|
|
||||||
bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
|
bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@@ -9442,8 +9579,8 @@ bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
|
|||||||
ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id);
|
ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id);
|
||||||
ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
|
ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
|
||||||
tab_bar->ID = id;
|
tab_bar->ID = id;
|
||||||
tab_bar->SeparatorMinX = tab_bar->BarRect.Min.x - IM_TRUNC(window->WindowPadding.x * 0.5f);
|
tab_bar->SeparatorMinX = tab_bar_bb.Min.x - IM_TRUNC(window->WindowPadding.x * 0.5f);
|
||||||
tab_bar->SeparatorMaxX = tab_bar->BarRect.Max.x + IM_TRUNC(window->WindowPadding.x * 0.5f);
|
tab_bar->SeparatorMaxX = tab_bar_bb.Max.x + IM_TRUNC(window->WindowPadding.x * 0.5f);
|
||||||
//if (g.NavWindow && IsWindowChildOf(g.NavWindow, window, false, false))
|
//if (g.NavWindow && IsWindowChildOf(g.NavWindow, window, false, false))
|
||||||
flags |= ImGuiTabBarFlags_IsFocused;
|
flags |= ImGuiTabBarFlags_IsFocused;
|
||||||
return BeginTabBarEx(tab_bar, tab_bar_bb, flags);
|
return BeginTabBarEx(tab_bar, tab_bar_bb, flags);
|
||||||
@@ -9564,6 +9701,10 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
tab_bar->WantLayout = false;
|
tab_bar->WantLayout = false;
|
||||||
|
|
||||||
|
// Track selected tab when resizing our parent down
|
||||||
|
const bool scroll_to_selected_tab = (tab_bar->BarRectPrevWidth > tab_bar->BarRect.GetWidth());
|
||||||
|
tab_bar->BarRectPrevWidth = tab_bar->BarRect.GetWidth();
|
||||||
|
|
||||||
// Garbage collect by compacting list
|
// Garbage collect by compacting list
|
||||||
// Detect if we need to sort out tab list (e.g. in rare case where a tab changed section)
|
// Detect if we need to sort out tab list (e.g. in rare case where a tab changed section)
|
||||||
int tab_dst_n = 0;
|
int tab_dst_n = 0;
|
||||||
@@ -9640,6 +9781,9 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
int shrink_buffer_indexes[3] = { 0, sections[0].TabCount + sections[2].TabCount, sections[0].TabCount };
|
int shrink_buffer_indexes[3] = { 0, sections[0].TabCount + sections[2].TabCount, sections[0].TabCount };
|
||||||
g.ShrinkWidthBuffer.resize(tab_bar->Tabs.Size);
|
g.ShrinkWidthBuffer.resize(tab_bar->Tabs.Size);
|
||||||
|
|
||||||
|
// Minimum shrink width
|
||||||
|
const float shrink_min_width = (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyMixed) ? g.Style.TabMinWidthShrink : 1.0f;
|
||||||
|
|
||||||
// Compute ideal tabs widths + store them into shrink buffer
|
// Compute ideal tabs widths + store them into shrink buffer
|
||||||
ImGuiTabItem* most_recently_selected_tab = NULL;
|
ImGuiTabItem* most_recently_selected_tab = NULL;
|
||||||
int curr_section_n = -1;
|
int curr_section_n = -1;
|
||||||
@@ -9662,10 +9806,13 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
const char* tab_name = TabBarGetTabName(tab_bar, tab);
|
const char* tab_name = TabBarGetTabName(tab_bar, tab);
|
||||||
const bool has_close_button_or_unsaved_marker = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) == 0 || (tab->Flags & ImGuiTabItemFlags_UnsavedDocument);
|
const bool has_close_button_or_unsaved_marker = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) == 0 || (tab->Flags & ImGuiTabItemFlags_UnsavedDocument);
|
||||||
tab->ContentWidth = (tab->RequestedWidth >= 0.0f) ? tab->RequestedWidth : TabItemCalcSize(tab_name, has_close_button_or_unsaved_marker).x;
|
tab->ContentWidth = (tab->RequestedWidth >= 0.0f) ? tab->RequestedWidth : TabItemCalcSize(tab_name, has_close_button_or_unsaved_marker).x;
|
||||||
|
if ((tab->Flags & ImGuiTabItemFlags_Button) == 0)
|
||||||
|
tab->ContentWidth = ImMax(tab->ContentWidth, g.Style.TabMinWidthBase);
|
||||||
|
|
||||||
int section_n = TabItemGetSectionIdx(tab);
|
int section_n = TabItemGetSectionIdx(tab);
|
||||||
ImGuiTabBarSection* section = §ions[section_n];
|
ImGuiTabBarSection* section = §ions[section_n];
|
||||||
section->Width += tab->ContentWidth + (section_n == curr_section_n ? g.Style.ItemInnerSpacing.x : 0.0f);
|
section->Width += tab->ContentWidth + (section_n == curr_section_n ? g.Style.ItemInnerSpacing.x : 0.0f);
|
||||||
|
section->WidthAfterShrinkMinWidth += ImMin(tab->ContentWidth, shrink_min_width) + (section_n == curr_section_n ? g.Style.ItemInnerSpacing.x : 0.0f);
|
||||||
curr_section_n = section_n;
|
curr_section_n = section_n;
|
||||||
|
|
||||||
// Store data so we can build an array sorted by width if we need to shrink tabs down
|
// Store data so we can build an array sorted by width if we need to shrink tabs down
|
||||||
@@ -9677,19 +9824,28 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compute total ideal width (used for e.g. auto-resizing a window)
|
// Compute total ideal width (used for e.g. auto-resizing a window)
|
||||||
|
float width_all_tabs_after_min_width_shrink = 0.0f;
|
||||||
tab_bar->WidthAllTabsIdeal = 0.0f;
|
tab_bar->WidthAllTabsIdeal = 0.0f;
|
||||||
for (int section_n = 0; section_n < 3; section_n++)
|
for (int section_n = 0; section_n < 3; section_n++)
|
||||||
|
{
|
||||||
tab_bar->WidthAllTabsIdeal += sections[section_n].Width + sections[section_n].Spacing;
|
tab_bar->WidthAllTabsIdeal += sections[section_n].Width + sections[section_n].Spacing;
|
||||||
|
width_all_tabs_after_min_width_shrink += sections[section_n].WidthAfterShrinkMinWidth + sections[section_n].Spacing;
|
||||||
|
}
|
||||||
|
|
||||||
// Horizontal scrolling buttons
|
// Horizontal scrolling buttons
|
||||||
// (note that TabBarScrollButtons() will alter BarRect.Max.x)
|
// Important: note that TabBarScrollButtons() will alter BarRect.Max.x.
|
||||||
if ((tab_bar->WidthAllTabsIdeal > tab_bar->BarRect.GetWidth() && tab_bar->Tabs.Size > 1) && !(tab_bar->Flags & ImGuiTabBarFlags_NoTabListScrollingButtons) && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll))
|
const bool can_scroll = (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll) || (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyMixed);
|
||||||
|
const float width_all_tabs_to_use_for_scroll = (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll) ? tab_bar->WidthAllTabs : width_all_tabs_after_min_width_shrink;
|
||||||
|
tab_bar->ScrollButtonEnabled = ((width_all_tabs_to_use_for_scroll > tab_bar->BarRect.GetWidth() && tab_bar->Tabs.Size > 1) && !(tab_bar->Flags & ImGuiTabBarFlags_NoTabListScrollingButtons) && can_scroll);
|
||||||
|
if (tab_bar->ScrollButtonEnabled)
|
||||||
if (ImGuiTabItem* scroll_and_select_tab = TabBarScrollingButtons(tab_bar))
|
if (ImGuiTabItem* scroll_and_select_tab = TabBarScrollingButtons(tab_bar))
|
||||||
{
|
{
|
||||||
scroll_to_tab_id = scroll_and_select_tab->ID;
|
scroll_to_tab_id = scroll_and_select_tab->ID;
|
||||||
if ((scroll_and_select_tab->Flags & ImGuiTabItemFlags_Button) == 0)
|
if ((scroll_and_select_tab->Flags & ImGuiTabItemFlags_Button) == 0)
|
||||||
tab_bar->SelectedTabId = scroll_to_tab_id;
|
tab_bar->SelectedTabId = scroll_to_tab_id;
|
||||||
}
|
}
|
||||||
|
if (scroll_to_tab_id == 0 && scroll_to_selected_tab)
|
||||||
|
scroll_to_tab_id = tab_bar->SelectedTabId;
|
||||||
|
|
||||||
// Shrink widths if full tabs don't fit in their allocated space
|
// Shrink widths if full tabs don't fit in their allocated space
|
||||||
float section_0_w = sections[0].Width + sections[0].Spacing;
|
float section_0_w = sections[0].Width + sections[0].Spacing;
|
||||||
@@ -9703,11 +9859,12 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
width_excess = (section_0_w + section_2_w) - tab_bar->BarRect.GetWidth(); // Excess used to shrink leading/trailing section
|
width_excess = (section_0_w + section_2_w) - tab_bar->BarRect.GetWidth(); // Excess used to shrink leading/trailing section
|
||||||
|
|
||||||
// With ImGuiTabBarFlags_FittingPolicyScroll policy, we will only shrink leading/trailing if the central section is not visible anymore
|
// With ImGuiTabBarFlags_FittingPolicyScroll policy, we will only shrink leading/trailing if the central section is not visible anymore
|
||||||
if (width_excess >= 1.0f && ((tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyResizeDown) || !central_section_is_visible))
|
const bool can_shrink = (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyShrink) || (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyMixed);
|
||||||
|
if (width_excess >= 1.0f && (can_shrink || !central_section_is_visible))
|
||||||
{
|
{
|
||||||
int shrink_data_count = (central_section_is_visible ? sections[1].TabCount : sections[0].TabCount + sections[2].TabCount);
|
int shrink_data_count = (central_section_is_visible ? sections[1].TabCount : sections[0].TabCount + sections[2].TabCount);
|
||||||
int shrink_data_offset = (central_section_is_visible ? sections[0].TabCount + sections[2].TabCount : 0);
|
int shrink_data_offset = (central_section_is_visible ? sections[0].TabCount + sections[2].TabCount : 0);
|
||||||
ShrinkWidths(g.ShrinkWidthBuffer.Data + shrink_data_offset, shrink_data_count, width_excess);
|
ShrinkWidths(g.ShrinkWidthBuffer.Data + shrink_data_offset, shrink_data_count, width_excess, shrink_min_width);
|
||||||
|
|
||||||
// Apply shrunk values into tabs and sections
|
// Apply shrunk values into tabs and sections
|
||||||
for (int tab_n = shrink_data_offset; tab_n < shrink_data_offset + shrink_data_count; tab_n++)
|
for (int tab_n = shrink_data_offset; tab_n < shrink_data_offset + shrink_data_count; tab_n++)
|
||||||
@@ -9750,7 +9907,8 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
tab_bar->TabsNames.Buf.resize(0);
|
tab_bar->TabsNames.Buf.resize(0);
|
||||||
|
|
||||||
// If we have lost the selected tab, select the next most recently active one
|
// If we have lost the selected tab, select the next most recently active one
|
||||||
if (found_selected_tab_id == false)
|
const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount);
|
||||||
|
if (found_selected_tab_id == false && !tab_bar_appearing)
|
||||||
tab_bar->SelectedTabId = 0;
|
tab_bar->SelectedTabId = 0;
|
||||||
if (tab_bar->SelectedTabId == 0 && tab_bar->NextSelectedTabId == 0 && most_recently_selected_tab != NULL)
|
if (tab_bar->SelectedTabId == 0 && tab_bar->NextSelectedTabId == 0 && most_recently_selected_tab != NULL)
|
||||||
scroll_to_tab_id = tab_bar->SelectedTabId = most_recently_selected_tab->ID;
|
scroll_to_tab_id = tab_bar->SelectedTabId = most_recently_selected_tab->ID;
|
||||||
@@ -9766,7 +9924,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
// 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);
|
||||||
else if ((tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll) && IsMouseHoveringRect(tab_bar->BarRect.Min, tab_bar->BarRect.Max, true) && IsWindowContentHoverable(g.CurrentWindow))
|
else if (tab_bar->ScrollButtonEnabled && IsMouseHoveringRect(tab_bar->BarRect.Min, tab_bar->BarRect.Max, true) && IsWindowContentHoverable(g.CurrentWindow))
|
||||||
{
|
{
|
||||||
const float wheel = g.IO.MouseWheelRequestAxisSwap ? g.IO.MouseWheel : g.IO.MouseWheelH;
|
const float wheel = g.IO.MouseWheelRequestAxisSwap ? g.IO.MouseWheel : g.IO.MouseWheelH;
|
||||||
const ImGuiKey wheel_key = g.IO.MouseWheelRequestAxisSwap ? ImGuiKey_MouseWheelY : ImGuiKey_MouseWheelX;
|
const ImGuiKey wheel_key = g.IO.MouseWheelRequestAxisSwap ? ImGuiKey_MouseWheelY : ImGuiKey_MouseWheelX;
|
||||||
@@ -10077,7 +10235,7 @@ static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar)
|
|||||||
|
|
||||||
PushStyleColor(ImGuiCol_Text, arrow_col);
|
PushStyleColor(ImGuiCol_Text, arrow_col);
|
||||||
PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
|
PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
|
||||||
PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
|
PushItemFlag(ImGuiItemFlags_ButtonRepeat | ImGuiItemFlags_NoNav, true);
|
||||||
const float backup_repeat_delay = g.IO.KeyRepeatDelay;
|
const float backup_repeat_delay = g.IO.KeyRepeatDelay;
|
||||||
const float backup_repeat_rate = g.IO.KeyRepeatRate;
|
const float backup_repeat_rate = g.IO.KeyRepeatRate;
|
||||||
g.IO.KeyRepeatDelay = 0.250f;
|
g.IO.KeyRepeatDelay = 0.250f;
|
||||||
|
|||||||
@@ -181,10 +181,10 @@
|
|||||||
//
|
//
|
||||||
// To support UTF-8:
|
// To support UTF-8:
|
||||||
//
|
//
|
||||||
// STB_TEXTEDIT_GETPREVCHARINDEX returns index of previous character
|
// STB_TEXTEDIT_GETPREVCHARINDEX returns index of previous character
|
||||||
// STB_TEXTEDIT_GETNEXTCHARINDEX returns index of next character
|
// STB_TEXTEDIT_GETNEXTCHARINDEX returns index of next character
|
||||||
// Do NOT define STB_TEXTEDIT_KEYTOTEXT.
|
// Do NOT define STB_TEXTEDIT_KEYTOTEXT.
|
||||||
// Instead, call stb_textedit_text() directly for text contents.
|
// Instead, call stb_textedit_text() directly for text contents.
|
||||||
//
|
//
|
||||||
// Keyboard input must be encoded as a single integer value; e.g. a character code
|
// Keyboard input must be encoded as a single integer value; e.g. a character code
|
||||||
// and some bitflags that represent shift states. to simplify the interface, SHIFT must
|
// and some bitflags that represent shift states. to simplify the interface, SHIFT must
|
||||||
@@ -260,7 +260,7 @@
|
|||||||
//
|
//
|
||||||
// text: (added 2025)
|
// text: (added 2025)
|
||||||
// call this to directly send text input the textfield, which is required
|
// call this to directly send text input the textfield, which is required
|
||||||
// for UTF-8 support, because stb_textedit_key() + STB_TEXTEDIT_KEYTOTEXT()
|
// for UTF-8 support, because stb_textedit_key() + STB_TEXTEDIT_KEYTOTEXT()
|
||||||
// cannot infer text length.
|
// cannot infer text length.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -427,7 +427,7 @@ typedef struct
|
|||||||
//
|
//
|
||||||
|
|
||||||
// traverse the layout to locate the nearest character to a display position
|
// traverse the layout to locate the nearest character to a display position
|
||||||
static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y, int* out_side_on_line)
|
||||||
{
|
{
|
||||||
StbTexteditRow r;
|
StbTexteditRow r;
|
||||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||||
@@ -437,6 +437,7 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
|||||||
r.x0 = r.x1 = 0;
|
r.x0 = r.x1 = 0;
|
||||||
r.ymin = r.ymax = 0;
|
r.ymin = r.ymax = 0;
|
||||||
r.num_chars = 0;
|
r.num_chars = 0;
|
||||||
|
*out_side_on_line = 0;
|
||||||
|
|
||||||
// search rows to find one that straddles 'y'
|
// search rows to find one that straddles 'y'
|
||||||
while (i < n) {
|
while (i < n) {
|
||||||
@@ -456,7 +457,10 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
|||||||
|
|
||||||
// below all text, return 'after' last character
|
// below all text, return 'after' last character
|
||||||
if (i >= n)
|
if (i >= n)
|
||||||
|
{
|
||||||
|
*out_side_on_line = 1;
|
||||||
return n;
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
// check if it's before the beginning of the line
|
// check if it's before the beginning of the line
|
||||||
if (x < r.x0)
|
if (x < r.x0)
|
||||||
@@ -469,6 +473,7 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
|||||||
for (k=0; k < r.num_chars; k = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, i + k) - i) {
|
for (k=0; k < r.num_chars; k = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, i + k) - i) {
|
||||||
float w = STB_TEXTEDIT_GETWIDTH(str, i, k);
|
float w = STB_TEXTEDIT_GETWIDTH(str, i, k);
|
||||||
if (x < prev_x+w) {
|
if (x < prev_x+w) {
|
||||||
|
*out_side_on_line = (k == 0) ? 0 : 1;
|
||||||
if (x < prev_x+w/2)
|
if (x < prev_x+w/2)
|
||||||
return k+i;
|
return k+i;
|
||||||
else
|
else
|
||||||
@@ -480,6 +485,7 @@ static int stb_text_locate_coord(IMSTB_TEXTEDIT_STRING *str, float x, float y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if the last character is a newline, return that. otherwise return 'after' the last character
|
// if the last character is a newline, return that. otherwise return 'after' the last character
|
||||||
|
*out_side_on_line = 1;
|
||||||
if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE)
|
if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE)
|
||||||
return i+r.num_chars-1;
|
return i+r.num_chars-1;
|
||||||
else
|
else
|
||||||
@@ -491,6 +497,7 @@ static void stb_textedit_click(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *st
|
|||||||
{
|
{
|
||||||
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
|
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
|
||||||
// goes off the top or bottom of the text
|
// goes off the top or bottom of the text
|
||||||
|
int side_on_line;
|
||||||
if( state->single_line )
|
if( state->single_line )
|
||||||
{
|
{
|
||||||
StbTexteditRow r;
|
StbTexteditRow r;
|
||||||
@@ -498,16 +505,18 @@ static void stb_textedit_click(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *st
|
|||||||
y = r.ymin;
|
y = r.ymin;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->cursor = stb_text_locate_coord(str, x, y);
|
state->cursor = stb_text_locate_coord(str, x, y, &side_on_line);
|
||||||
state->select_start = state->cursor;
|
state->select_start = state->cursor;
|
||||||
state->select_end = state->cursor;
|
state->select_end = state->cursor;
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
|
str->LastMoveDirectionLR = (ImS8)(side_on_line ? ImGuiDir_Right : ImGuiDir_Left);
|
||||||
}
|
}
|
||||||
|
|
||||||
// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location
|
// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location
|
||||||
static void stb_textedit_drag(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
static void stb_textedit_drag(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
|
||||||
{
|
{
|
||||||
int p = 0;
|
int p = 0;
|
||||||
|
int side_on_line;
|
||||||
|
|
||||||
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
|
// In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
|
||||||
// goes off the top or bottom of the text
|
// goes off the top or bottom of the text
|
||||||
@@ -521,8 +530,9 @@ static void stb_textedit_drag(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *sta
|
|||||||
if (state->select_start == state->select_end)
|
if (state->select_start == state->select_end)
|
||||||
state->select_start = state->cursor;
|
state->select_start = state->cursor;
|
||||||
|
|
||||||
p = stb_text_locate_coord(str, x, y);
|
p = stb_text_locate_coord(str, x, y, &side_on_line);
|
||||||
state->cursor = state->select_end = p;
|
state->cursor = state->select_end = p;
|
||||||
|
str->LastMoveDirectionLR = (ImS8)(side_on_line ? ImGuiDir_Right : ImGuiDir_Left);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -572,6 +582,8 @@ static void stb_textedit_find_charpos(StbFindState *find, IMSTB_TEXTEDIT_STRING
|
|||||||
STB_TEXTEDIT_LAYOUTROW(&r, str, i);
|
STB_TEXTEDIT_LAYOUTROW(&r, str, i);
|
||||||
if (n < i + r.num_chars)
|
if (n < i + r.num_chars)
|
||||||
break;
|
break;
|
||||||
|
if (str->LastMoveDirectionLR == ImGuiDir_Right && str->Stb->cursor > 0 && str->Stb->cursor == i + r.num_chars && STB_TEXTEDIT_GETCHAR(str, i + r.num_chars - 1) != STB_TEXTEDIT_NEWLINE) // [DEAR IMGUI] Wrapping point handling
|
||||||
|
break;
|
||||||
if (i + r.num_chars == z && z > 0 && STB_TEXTEDIT_GETCHAR(str, z - 1) != STB_TEXTEDIT_NEWLINE) // [DEAR IMGUI] special handling for last line
|
if (i + r.num_chars == z && z > 0 && STB_TEXTEDIT_GETCHAR(str, z - 1) != STB_TEXTEDIT_NEWLINE) // [DEAR IMGUI] special handling for last line
|
||||||
break; // [DEAR IMGUI]
|
break; // [DEAR IMGUI]
|
||||||
prev_start = i;
|
prev_start = i;
|
||||||
@@ -668,6 +680,35 @@ static void stb_textedit_move_to_last(IMSTB_TEXTEDIT_STRING *str, STB_TexteditSt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [DEAR IMGUI] Extracted this function so we can more easily add support for word-wrapping.
|
||||||
|
#ifndef STB_TEXTEDIT_MOVELINESTART
|
||||||
|
static int stb_textedit_move_line_start(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int cursor)
|
||||||
|
{
|
||||||
|
if (state->single_line)
|
||||||
|
return 0;
|
||||||
|
while (cursor > 0) {
|
||||||
|
int prev = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, cursor);
|
||||||
|
if (STB_TEXTEDIT_GETCHAR(str, prev) == STB_TEXTEDIT_NEWLINE)
|
||||||
|
break;
|
||||||
|
cursor = prev;
|
||||||
|
}
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
#define STB_TEXTEDIT_MOVELINESTART stb_textedit_move_line_start
|
||||||
|
#endif
|
||||||
|
#ifndef STB_TEXTEDIT_MOVELINEEND
|
||||||
|
static int stb_textedit_move_line_end(IMSTB_TEXTEDIT_STRING *str, STB_TexteditState *state, int cursor)
|
||||||
|
{
|
||||||
|
int n = STB_TEXTEDIT_STRINGLEN(str);
|
||||||
|
if (state->single_line)
|
||||||
|
return n;
|
||||||
|
while (cursor < n && STB_TEXTEDIT_GETCHAR(str, cursor) != STB_TEXTEDIT_NEWLINE)
|
||||||
|
cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, cursor);
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
#define STB_TEXTEDIT_MOVELINEEND stb_textedit_move_line_end
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef STB_TEXTEDIT_IS_SPACE
|
#ifdef STB_TEXTEDIT_IS_SPACE
|
||||||
static int is_word_boundary( IMSTB_TEXTEDIT_STRING *str, int idx )
|
static int is_word_boundary( IMSTB_TEXTEDIT_STRING *str, int idx )
|
||||||
{
|
{
|
||||||
@@ -921,8 +962,8 @@ retry:
|
|||||||
|
|
||||||
// [DEAR IMGUI]
|
// [DEAR IMGUI]
|
||||||
// going down while being on the last line shouldn't bring us to that line end
|
// going down while being on the last line shouldn't bring us to that line end
|
||||||
if (STB_TEXTEDIT_GETCHAR(str, find.first_char + find.length - 1) != STB_TEXTEDIT_NEWLINE)
|
//if (STB_TEXTEDIT_GETCHAR(str, find.first_char + find.length - 1) != STB_TEXTEDIT_NEWLINE)
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
// now find character position down a row
|
// now find character position down a row
|
||||||
state->cursor = start;
|
state->cursor = start;
|
||||||
@@ -943,6 +984,8 @@ retry:
|
|||||||
}
|
}
|
||||||
stb_textedit_clamp(str, state);
|
stb_textedit_clamp(str, state);
|
||||||
|
|
||||||
|
if (state->cursor == find.first_char + find.length)
|
||||||
|
str->LastMoveDirectionLR = ImGuiDir_Left;
|
||||||
state->has_preferred_x = 1;
|
state->has_preferred_x = 1;
|
||||||
state->preferred_x = goal_x;
|
state->preferred_x = goal_x;
|
||||||
|
|
||||||
@@ -1007,6 +1050,10 @@ retry:
|
|||||||
}
|
}
|
||||||
stb_textedit_clamp(str, state);
|
stb_textedit_clamp(str, state);
|
||||||
|
|
||||||
|
if (state->cursor == find.first_char)
|
||||||
|
str->LastMoveDirectionLR = ImGuiDir_Right;
|
||||||
|
else if (state->cursor == find.prev_first)
|
||||||
|
str->LastMoveDirectionLR = ImGuiDir_Left;
|
||||||
state->has_preferred_x = 1;
|
state->has_preferred_x = 1;
|
||||||
state->preferred_x = goal_x;
|
state->preferred_x = goal_x;
|
||||||
|
|
||||||
@@ -1024,7 +1071,7 @@ retry:
|
|||||||
prev_scan = prev;
|
prev_scan = prev;
|
||||||
}
|
}
|
||||||
find.first_char = find.prev_first;
|
find.first_char = find.prev_first;
|
||||||
find.prev_first = prev_scan;
|
find.prev_first = STB_TEXTEDIT_MOVELINESTART(str, state, prev_scan);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1098,10 +1145,7 @@ retry:
|
|||||||
case STB_TEXTEDIT_K_LINESTART:
|
case STB_TEXTEDIT_K_LINESTART:
|
||||||
stb_textedit_clamp(str, state);
|
stb_textedit_clamp(str, state);
|
||||||
stb_textedit_move_to_first(state);
|
stb_textedit_move_to_first(state);
|
||||||
if (state->single_line)
|
state->cursor = STB_TEXTEDIT_MOVELINESTART(str, state, state->cursor);
|
||||||
state->cursor = 0;
|
|
||||||
else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
|
|
||||||
state->cursor = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, state->cursor);
|
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1109,13 +1153,9 @@ retry:
|
|||||||
case STB_TEXTEDIT_K_LINEEND2:
|
case STB_TEXTEDIT_K_LINEEND2:
|
||||||
#endif
|
#endif
|
||||||
case STB_TEXTEDIT_K_LINEEND: {
|
case STB_TEXTEDIT_K_LINEEND: {
|
||||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
|
||||||
stb_textedit_clamp(str, state);
|
stb_textedit_clamp(str, state);
|
||||||
stb_textedit_move_to_first(state);
|
stb_textedit_move_to_last(str, state);
|
||||||
if (state->single_line)
|
state->cursor = STB_TEXTEDIT_MOVELINEEND(str, state, state->cursor);
|
||||||
state->cursor = n;
|
|
||||||
else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE)
|
|
||||||
state->cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
|
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1126,10 +1166,7 @@ retry:
|
|||||||
case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT:
|
case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT:
|
||||||
stb_textedit_clamp(str, state);
|
stb_textedit_clamp(str, state);
|
||||||
stb_textedit_prep_selection_at_cursor(state);
|
stb_textedit_prep_selection_at_cursor(state);
|
||||||
if (state->single_line)
|
state->cursor = STB_TEXTEDIT_MOVELINESTART(str, state, state->cursor);
|
||||||
state->cursor = 0;
|
|
||||||
else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
|
|
||||||
state->cursor = IMSTB_TEXTEDIT_GETPREVCHARINDEX(str, state->cursor);
|
|
||||||
state->select_end = state->cursor;
|
state->select_end = state->cursor;
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
break;
|
break;
|
||||||
@@ -1138,13 +1175,9 @@ retry:
|
|||||||
case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT:
|
case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT:
|
||||||
#endif
|
#endif
|
||||||
case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: {
|
case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: {
|
||||||
int n = STB_TEXTEDIT_STRINGLEN(str);
|
|
||||||
stb_textedit_clamp(str, state);
|
stb_textedit_clamp(str, state);
|
||||||
stb_textedit_prep_selection_at_cursor(state);
|
stb_textedit_prep_selection_at_cursor(state);
|
||||||
if (state->single_line)
|
state->cursor = STB_TEXTEDIT_MOVELINEEND(str, state, state->cursor);
|
||||||
state->cursor = n;
|
|
||||||
else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE)
|
|
||||||
state->cursor = IMSTB_TEXTEDIT_GETNEXTCHARINDEX(str, state->cursor);
|
|
||||||
state->select_end = state->cursor;
|
state->select_end = state->cursor;
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ static void* FreeType_Realloc(FT_Memory /*memory*/, long cur_size, long new_size
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplFreeType_LoaderInit(ImFontAtlas* atlas)
|
static bool ImGui_ImplFreeType_LoaderInit(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
IM_ASSERT(atlas->FontLoaderData == nullptr);
|
IM_ASSERT(atlas->FontLoaderData == nullptr);
|
||||||
ImGui_ImplFreeType_Data* bd = IM_NEW(ImGui_ImplFreeType_Data)();
|
ImGui_ImplFreeType_Data* bd = IM_NEW(ImGui_ImplFreeType_Data)();
|
||||||
@@ -384,7 +384,7 @@ bool ImGui_ImplFreeType_LoaderInit(ImFontAtlas* atlas)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeType_LoaderShutdown(ImFontAtlas* atlas)
|
static void ImGui_ImplFreeType_LoaderShutdown(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
ImGui_ImplFreeType_Data* bd = (ImGui_ImplFreeType_Data*)atlas->FontLoaderData;
|
ImGui_ImplFreeType_Data* bd = (ImGui_ImplFreeType_Data*)atlas->FontLoaderData;
|
||||||
IM_ASSERT(bd != nullptr);
|
IM_ASSERT(bd != nullptr);
|
||||||
@@ -393,7 +393,7 @@ void ImGui_ImplFreeType_LoaderShutdown(ImFontAtlas* atlas)
|
|||||||
atlas->FontLoaderData = nullptr;
|
atlas->FontLoaderData = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplFreeType_FontSrcInit(ImFontAtlas* atlas, ImFontConfig* src)
|
static bool ImGui_ImplFreeType_FontSrcInit(ImFontAtlas* atlas, ImFontConfig* src)
|
||||||
{
|
{
|
||||||
ImGui_ImplFreeType_Data* bd = (ImGui_ImplFreeType_Data*)atlas->FontLoaderData;
|
ImGui_ImplFreeType_Data* bd = (ImGui_ImplFreeType_Data*)atlas->FontLoaderData;
|
||||||
ImGui_ImplFreeType_FontSrcData* bd_font_data = IM_NEW(ImGui_ImplFreeType_FontSrcData);
|
ImGui_ImplFreeType_FontSrcData* bd_font_data = IM_NEW(ImGui_ImplFreeType_FontSrcData);
|
||||||
@@ -410,7 +410,7 @@ bool ImGui_ImplFreeType_FontSrcInit(ImFontAtlas* atlas, ImFontConfig* src)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeType_FontSrcDestroy(ImFontAtlas* atlas, ImFontConfig* src)
|
static void ImGui_ImplFreeType_FontSrcDestroy(ImFontAtlas* atlas, ImFontConfig* src)
|
||||||
{
|
{
|
||||||
IM_UNUSED(atlas);
|
IM_UNUSED(atlas);
|
||||||
ImGui_ImplFreeType_FontSrcData* bd_font_data = (ImGui_ImplFreeType_FontSrcData*)src->FontLoaderData;
|
ImGui_ImplFreeType_FontSrcData* bd_font_data = (ImGui_ImplFreeType_FontSrcData*)src->FontLoaderData;
|
||||||
@@ -418,7 +418,7 @@ void ImGui_ImplFreeType_FontSrcDestroy(ImFontAtlas* atlas, ImFontConfig* src)
|
|||||||
src->FontLoaderData = nullptr;
|
src->FontLoaderData = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplFreeType_FontBakedInit(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void* loader_data_for_baked_src)
|
static bool ImGui_ImplFreeType_FontBakedInit(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void* loader_data_for_baked_src)
|
||||||
{
|
{
|
||||||
IM_UNUSED(atlas);
|
IM_UNUSED(atlas);
|
||||||
float size = baked->Size;
|
float size = baked->Size;
|
||||||
@@ -464,7 +464,7 @@ bool ImGui_ImplFreeType_FontBakedInit(ImFontAtlas* atlas, ImFontConfig* src, ImF
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplFreeType_FontBakedDestroy(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void* loader_data_for_baked_src)
|
static void ImGui_ImplFreeType_FontBakedDestroy(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void* loader_data_for_baked_src)
|
||||||
{
|
{
|
||||||
IM_UNUSED(atlas);
|
IM_UNUSED(atlas);
|
||||||
IM_UNUSED(baked);
|
IM_UNUSED(baked);
|
||||||
@@ -475,7 +475,7 @@ void ImGui_ImplFreeType_FontBakedDestroy(ImFontAtlas* atlas, ImFontConfig* src,
|
|||||||
bd_baked_data->~ImGui_ImplFreeType_FontSrcBakedData(); // ~IM_PLACEMENT_DELETE()
|
bd_baked_data->~ImGui_ImplFreeType_FontSrcBakedData(); // ~IM_PLACEMENT_DELETE()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplFreeType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void* loader_data_for_baked_src, ImWchar codepoint, ImFontGlyph* out_glyph, float* out_advance_x)
|
static bool ImGui_ImplFreeType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void* loader_data_for_baked_src, ImWchar codepoint, ImFontGlyph* out_glyph, float* out_advance_x)
|
||||||
{
|
{
|
||||||
ImGui_ImplFreeType_FontSrcData* bd_font_data = (ImGui_ImplFreeType_FontSrcData*)src->FontLoaderData;
|
ImGui_ImplFreeType_FontSrcData* bd_font_data = (ImGui_ImplFreeType_FontSrcData*)src->FontLoaderData;
|
||||||
uint32_t glyph_index = FT_Get_Char_Index(bd_font_data->FtFace, codepoint);
|
uint32_t glyph_index = FT_Get_Char_Index(bd_font_data->FtFace, codepoint);
|
||||||
@@ -566,7 +566,7 @@ bool ImGui_ImplFreeType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontConfig* src
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplFreetype_FontSrcContainsGlyph(ImFontAtlas* atlas, ImFontConfig* src, ImWchar codepoint)
|
static bool ImGui_ImplFreetype_FontSrcContainsGlyph(ImFontAtlas* atlas, ImFontConfig* src, ImWchar codepoint)
|
||||||
{
|
{
|
||||||
IM_UNUSED(atlas);
|
IM_UNUSED(atlas);
|
||||||
ImGui_ImplFreeType_FontSrcData* bd_font_data = (ImGui_ImplFreeType_FontSrcData*)src->FontLoaderData;
|
ImGui_ImplFreeType_FontSrcData* bd_font_data = (ImGui_ImplFreeType_FontSrcData*)src->FontLoaderData;
|
||||||
|
|||||||
Reference in New Issue
Block a user