mirror of
https://github.com/ocornut/imgui.git
synced 2026-07-08 18:39:40 +00:00
Compare commits
50 Commits
v1.89.7-do
...
v1.89.8-do
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8704cd085 | ||
|
|
f7eea63872 | ||
|
|
30594c37d0 | ||
|
|
ab490dc7b8 | ||
|
|
2ad8c60abc | ||
|
|
19ae142bdd | ||
|
|
dc2b0a2823 | ||
|
|
88a330ebef | ||
|
|
fa2f1bfbb0 | ||
|
|
7c5b0e8292 | ||
|
|
eefc9035f0 | ||
|
|
c87b9fdb15 | ||
|
|
556ce9f543 | ||
|
|
79d6f4e211 | ||
|
|
f1781c20a3 | ||
|
|
f8f805f046 | ||
|
|
1109de3827 | ||
|
|
db66e33e9e | ||
|
|
2bc5d17ac3 | ||
|
|
e5977f05d8 | ||
|
|
d342ec10cc | ||
|
|
52125a54a5 | ||
|
|
77eba4d0d1 | ||
|
|
3dc3aef8a4 | ||
|
|
0e8eb8c48e | ||
|
|
863ac31f01 | ||
|
|
07d1709ca2 | ||
|
|
33e13c85e1 | ||
|
|
023e59a5f2 | ||
|
|
6888e6cdff | ||
|
|
0110f4c8cc | ||
|
|
dbeeeae593 | ||
|
|
1a9ddd2396 | ||
|
|
c649aca20a | ||
|
|
cc4c37dbac | ||
|
|
51b348095c | ||
|
|
b7cdb5a31e | ||
|
|
f4942bca32 | ||
|
|
27c735e3e9 | ||
|
|
f6feddd1ee | ||
|
|
b79751ebad | ||
|
|
a5aff5fd3e | ||
|
|
5ce636b0ba | ||
|
|
140726d23f | ||
|
|
b32ef809c3 | ||
|
|
3349296370 | ||
|
|
6aa408c6af | ||
|
|
9a15730c2a | ||
|
|
3fe4319314 | ||
|
|
8566fec661 |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -479,8 +479,8 @@ jobs:
|
|||||||
wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
|
wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
|
||||||
tar -xvf master.tar.gz
|
tar -xvf master.tar.gz
|
||||||
emsdk-master/emsdk update
|
emsdk-master/emsdk update
|
||||||
emsdk-master/emsdk install 3.1.37
|
emsdk-master/emsdk install latest
|
||||||
emsdk-master/emsdk activate 3.1.37
|
emsdk-master/emsdk activate latest
|
||||||
|
|
||||||
- name: Build example_sdl2_opengl3 with Emscripten
|
- name: Build example_sdl2_opengl3 with Emscripten
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -8,7 +8,6 @@ imgui.ini
|
|||||||
*.o
|
*.o
|
||||||
*.obj
|
*.obj
|
||||||
*.exe
|
*.exe
|
||||||
examples/build/*
|
|
||||||
examples/*/Debug/*
|
examples/*/Debug/*
|
||||||
examples/*/Release/*
|
examples/*/Release/*
|
||||||
examples/*/x64/*
|
examples/*/x64/*
|
||||||
@@ -30,7 +29,7 @@ ipch
|
|||||||
JSON/
|
JSON/
|
||||||
|
|
||||||
## Commonly used CMake directories
|
## Commonly used CMake directories
|
||||||
/build*/
|
build*/
|
||||||
|
|
||||||
## Xcode artifacts
|
## Xcode artifacts
|
||||||
project.xcworkspace
|
project.xcworkspace
|
||||||
|
|||||||
@@ -47,10 +47,11 @@
|
|||||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
#include "imgui_impl_allegro5.h"
|
||||||
#include <stdint.h> // uint64_t
|
#include <stdint.h> // uint64_t
|
||||||
#include <cstring> // memcpy
|
#include <cstring> // memcpy
|
||||||
#include "imgui.h"
|
|
||||||
#include "imgui_impl_allegro5.h"
|
|
||||||
|
|
||||||
// Allegro
|
// Allegro
|
||||||
#include <allegro5/allegro.h>
|
#include <allegro5/allegro.h>
|
||||||
@@ -603,3 +604,7 @@ void ImGui_ImplAllegro5_NewFrame()
|
|||||||
// Setup mouse cursor shape
|
// Setup mouse cursor shape
|
||||||
ImGui_ImplAllegro5_UpdateMouseCursor();
|
ImGui_ImplAllegro5_UpdateMouseCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct ALLEGRO_DISPLAY;
|
struct ALLEGRO_DISPLAY;
|
||||||
union ALLEGRO_EVENT;
|
union ALLEGRO_EVENT;
|
||||||
@@ -30,3 +31,5 @@ IMGUI_IMPL_API bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* event);
|
|||||||
// 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();
|
||||||
IMGUI_IMPL_API void ImGui_ImplAllegro5_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplAllegro5_InvalidateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
// 2021-03-04: Initial version.
|
// 2021-03-04: Initial version.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_android.h"
|
#include "imgui_impl_android.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <android/native_window.h>
|
#include <android/native_window.h>
|
||||||
@@ -294,3 +295,7 @@ void ImGui_ImplAndroid_NewFrame()
|
|||||||
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
|
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct ANativeWindow;
|
struct ANativeWindow;
|
||||||
struct AInputEvent;
|
struct AInputEvent;
|
||||||
@@ -27,3 +29,5 @@ IMGUI_IMPL_API bool ImGui_ImplAndroid_Init(ANativeWindow* window);
|
|||||||
IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event);
|
IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event);
|
||||||
IMGUI_IMPL_API void ImGui_ImplAndroid_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplAndroid_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplAndroid_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplAndroid_NewFrame();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
// 2016-05-07: DirectX10: Disabling depth-write.
|
// 2016-05-07: DirectX10: Disabling depth-write.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_dx10.h"
|
#include "imgui_impl_dx10.h"
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
@@ -713,3 +714,6 @@ void ImGui_ImplDX10_ShutdownPlatformInterface()
|
|||||||
ImGui::DestroyPlatformWindows();
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct ID3D10Device;
|
struct ID3D10Device;
|
||||||
|
|
||||||
@@ -24,3 +25,5 @@ IMGUI_IMPL_API void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data);
|
|||||||
// 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 void ImGui_ImplDX10_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplDX10_InvalidateDeviceObjects();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplDX10_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplDX10_CreateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
// 2016-05-07: DirectX11: Disabling depth-write.
|
// 2016-05-07: DirectX11: Disabling depth-write.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_dx11.h"
|
#include "imgui_impl_dx11.h"
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
@@ -729,3 +730,7 @@ static void ImGui_ImplDX11_ShutdownPlatformInterface()
|
|||||||
{
|
{
|
||||||
ImGui::DestroyPlatformWindows();
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct ID3D11Device;
|
struct ID3D11Device;
|
||||||
struct ID3D11DeviceContext;
|
struct ID3D11DeviceContext;
|
||||||
@@ -25,3 +26,5 @@ IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data);
|
|||||||
// 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 void ImGui_ImplDX11_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
// 2018-02-22: Merged into master with all Win32 code synchronized to other examples.
|
// 2018-02-22: Merged into master with all Win32 code synchronized to other examples.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_dx12.h"
|
#include "imgui_impl_dx12.h"
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
@@ -1074,3 +1075,7 @@ void ImGui_ImplDX12_ShutdownPlatformInterface()
|
|||||||
{
|
{
|
||||||
ImGui::DestroyPlatformWindows();
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include <dxgiformat.h> // DXGI_FORMAT
|
#include <dxgiformat.h> // DXGI_FORMAT
|
||||||
|
|
||||||
struct ID3D12Device;
|
struct ID3D12Device;
|
||||||
@@ -37,3 +38,5 @@ IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3
|
|||||||
// 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 void ImGui_ImplDX12_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_dx9.h"
|
#include "imgui_impl_dx9.h"
|
||||||
|
|
||||||
// DirectX
|
// DirectX
|
||||||
@@ -540,3 +541,7 @@ static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows()
|
|||||||
if (platform_io.Viewports[i]->RendererUserData)
|
if (platform_io.Viewports[i]->RendererUserData)
|
||||||
ImGui_ImplDX9_DestroyWindow(platform_io.Viewports[i]);
|
ImGui_ImplDX9_DestroyWindow(platform_io.Viewports[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct IDirect3DDevice9;
|
struct IDirect3DDevice9;
|
||||||
|
|
||||||
@@ -24,3 +25,5 @@ IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data);
|
|||||||
// 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_ImplDX9_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2023-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2023-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2023-07-18: Inputs: Revert ignoring mouse data on GLFW_CURSOR_DISABLED as it can be used differently. User may set ImGuiConfigFLags_NoMouse if desired. (#5625, #6609)
|
||||||
// 2023-06-12: Accept glfwGetTime() not returning a monotonically increasing value. This seems to happens on some Windows setup when peripherals disconnect, and is likely to also happen on browser + Emscripten. (#6491)
|
// 2023-06-12: Accept glfwGetTime() not returning a monotonically increasing value. This seems to happens on some Windows setup when peripherals disconnect, and is likely to also happen on browser + Emscripten. (#6491)
|
||||||
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen/ImGuiMouseSource_Pen on Windows ONLY, using a custom WndProc hook. (#2702)
|
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen/ImGuiMouseSource_Pen on Windows ONLY, using a custom WndProc hook. (#2702)
|
||||||
// 2023-03-16: Inputs: Fixed key modifiers handling on secondary viewports (docking branch). Broken on 2023/01/04. (#6248, #6034)
|
// 2023-03-16: Inputs: Fixed key modifiers handling on secondary viewports (docking branch). Broken on 2023/01/04. (#6248, #6034)
|
||||||
@@ -33,7 +34,7 @@
|
|||||||
// 2022-10-18: Perform a dummy glfwGetError() read to cancel missing mouse cursors errors. Using GLFW_VERSION_COMBINED directly. (#5785)
|
// 2022-10-18: Perform a dummy glfwGetError() read to cancel missing mouse cursors errors. Using GLFW_VERSION_COMBINED directly. (#5785)
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
||||||
// 2022-09-01: Inputs: Honor GLFW_CURSOR_DISABLED by not setting mouse position.
|
// 2022-09-01: Inputs: Honor GLFW_CURSOR_DISABLED by not setting mouse position *EDIT* Reverted 2023-07-18.
|
||||||
// 2022-04-30: Inputs: Fixed ImGui_ImplGlfw_TranslateUntranslatedKey() for lower case letters on OSX.
|
// 2022-04-30: Inputs: Fixed ImGui_ImplGlfw_TranslateUntranslatedKey() for lower case letters on OSX.
|
||||||
// 2022-03-23: Inputs: Fixed a regression in 1.87 which resulted in keyboard modifiers events being reported incorrectly on Linux/X11.
|
// 2022-03-23: Inputs: Fixed a regression in 1.87 which resulted in keyboard modifiers events being reported incorrectly on Linux/X11.
|
||||||
// 2022-02-07: Added ImGui_ImplGlfw_InstallCallbacks()/ImGui_ImplGlfw_RestoreCallbacks() helpers to facilitate user installing callbacks after initializing backend.
|
// 2022-02-07: Added ImGui_ImplGlfw_InstallCallbacks()/ImGui_ImplGlfw_RestoreCallbacks() helpers to facilitate user installing callbacks after initializing backend.
|
||||||
@@ -70,6 +71,7 @@
|
|||||||
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
|
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_glfw.h"
|
#include "imgui_impl_glfw.h"
|
||||||
|
|
||||||
// Clang warnings with -Weverything
|
// Clang warnings with -Weverything
|
||||||
@@ -419,8 +421,6 @@ void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y)
|
|||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
if (bd->PrevUserCallbackCursorPos != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
|
if (bd->PrevUserCallbackCursorPos != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
|
||||||
bd->PrevUserCallbackCursorPos(window, x, y);
|
bd->PrevUserCallbackCursorPos(window, x, y);
|
||||||
if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
@@ -441,8 +441,6 @@ void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered)
|
|||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
if (bd->PrevUserCallbackCursorEnter != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
|
if (bd->PrevUserCallbackCursorEnter != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
|
||||||
bd->PrevUserCallbackCursorEnter(window, entered);
|
bd->PrevUserCallbackCursorEnter(window, entered);
|
||||||
if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (entered)
|
if (entered)
|
||||||
@@ -728,11 +726,6 @@ static void ImGui_ImplGlfw_UpdateMouseData()
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
|
||||||
if (glfwGetInputMode(bd->Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
|
|
||||||
{
|
|
||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiID mouse_viewport_id = 0;
|
ImGuiID mouse_viewport_id = 0;
|
||||||
const ImVec2 mouse_pos_prev = io.MousePos;
|
const ImVec2 mouse_pos_prev = io.MousePos;
|
||||||
@@ -1289,6 +1282,10 @@ static void ImGui_ImplGlfw_ShutdownPlatformInterface()
|
|||||||
ImGui::DestroyPlatformWindows();
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
struct GLFWmonitor;
|
struct GLFWmonitor;
|
||||||
@@ -50,3 +51,5 @@ IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double
|
|||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event);
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
// 2018-03-22: Added GLUT Platform binding.
|
// 2018-03-22: Added GLUT Platform binding.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_glut.h"
|
#include "imgui_impl_glut.h"
|
||||||
#define GL_SILENCE_DEPRECATION
|
#define GL_SILENCE_DEPRECATION
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@@ -298,3 +299,7 @@ void ImGui_ImplGLUT_MotionFunc(int x, int y)
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.AddMousePosEvent((float)x, (float)y);
|
io.AddMousePosEvent((float)x, (float)y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
|
IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
|
||||||
@@ -29,7 +30,7 @@ IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame();
|
|||||||
|
|
||||||
// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
|
// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
|
||||||
// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
|
// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
|
||||||
//---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
|
//------------------------------------ GLUT name ---------------------------------------------- Decent Name ---------
|
||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
|
||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
|
||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
|
||||||
@@ -38,3 +39,5 @@ IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int
|
|||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
|
||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
|
||||||
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
|
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// ObjC API
|
// ObjC API
|
||||||
@@ -63,3 +64,7 @@ IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
// 2018-07-05: Metal: Added new Metal backend implementation.
|
// 2018-07-05: Metal: Added new Metal backend implementation.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_metal.h"
|
#include "imgui_impl_metal.h"
|
||||||
#import <time.h>
|
#import <time.h>
|
||||||
#import <Metal/Metal.h>
|
#import <Metal/Metal.h>
|
||||||
@@ -740,3 +741,7 @@ static void ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows()
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -39,12 +39,9 @@
|
|||||||
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_opengl2.h"
|
#include "imgui_impl_opengl2.h"
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
|
|
||||||
// Clang/GCC warnings with -Weverything
|
// Clang/GCC warnings with -Weverything
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
@@ -305,6 +302,7 @@ void ImGui_ImplOpenGL2_DestroyDeviceObjects()
|
|||||||
ImGui_ImplOpenGL2_DestroyFontsTexture();
|
ImGui_ImplOpenGL2_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------
|
||||||
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
@@ -333,6 +331,10 @@ static void ImGui_ImplOpenGL2_ShutdownPlatformInterface()
|
|||||||
ImGui::DestroyPlatformWindows();
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init();
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown();
|
||||||
@@ -31,3 +32,5 @@ IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateFontsTexture();
|
|||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyFontsTexture();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyFontsTexture();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -106,13 +106,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_opengl3.h"
|
#include "imgui_impl_opengl3.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -972,9 +969,13 @@ static void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
|
|||||||
ImGui::DestroyPlatformWindows();
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
// Backend API
|
// Backend API
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
|
||||||
@@ -59,3 +60,5 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
|
|
||||||
@@ -44,3 +45,5 @@ IMGUI_IMPL_API void ImGui_ImplOSX_NewFrame(void* _Nullable view);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
#import "imgui.h"
|
#import "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#import "imgui_impl_osx.h"
|
#import "imgui_impl_osx.h"
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
@@ -1109,3 +1110,7 @@ static void ImGui_ImplOSX_ShutdownPlatformInterface()
|
|||||||
main_viewport->PlatformUserData = nullptr;
|
main_viewport->PlatformUserData = nullptr;
|
||||||
ImGui::DestroyPlatformWindows();
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
|
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_sdl2.h"
|
#include "imgui_impl_sdl2.h"
|
||||||
|
|
||||||
// Clang warnings with -Weverything
|
// Clang warnings with -Weverything
|
||||||
@@ -1035,6 +1036,10 @@ static void ImGui_ImplSDL2_ShutdownPlatformInterface()
|
|||||||
ImGui::DestroyPlatformWindows();
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
struct SDL_Renderer;
|
struct SDL_Renderer;
|
||||||
@@ -37,3 +38,5 @@ IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
|||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
static inline void ImGui_ImplSDL2_NewFrame(SDL_Window*) { ImGui_ImplSDL2_NewFrame(); } // 1.84: removed unnecessary parameter
|
static inline void ImGui_ImplSDL2_NewFrame(SDL_Window*) { ImGui_ImplSDL2_NewFrame(); } // 1.84: removed unnecessary parameter
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
// 2023-02-07: Forked "imgui_impl_sdl2" into "imgui_impl_sdl3". Removed version checks for old feature. Refer to imgui_impl_sdl2.cpp for older changelog.
|
// 2023-02-07: Forked "imgui_impl_sdl2" into "imgui_impl_sdl3". Removed version checks for old feature. Refer to imgui_impl_sdl2.cpp for older changelog.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_sdl3.h"
|
#include "imgui_impl_sdl3.h"
|
||||||
|
|
||||||
// Clang warnings with -Weverything
|
// Clang warnings with -Weverything
|
||||||
@@ -752,7 +753,7 @@ static void ImGui_ImplSDL3_CreateWindow(ImGuiViewport* viewport)
|
|||||||
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
// See SDL hack in ImGui_ImplSDL3_ShowWindow().
|
// See SDL hack in ImGui_ImplSDL3_ShowWindow().
|
||||||
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_SKIP_TASKBAR : 0;
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_UTILITY : 0;
|
||||||
#endif
|
#endif
|
||||||
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
|
||||||
vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);
|
vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);
|
||||||
@@ -801,7 +802,7 @@ static void ImGui_ImplSDL3_ShowWindow(ImGuiViewport* viewport)
|
|||||||
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||||
|
|
||||||
// SDL hack: Hide icon from task bar
|
// SDL hack: Hide icon from task bar
|
||||||
// Note: SDL 2.0.6+ has a SDL_WINDOW_SKIP_TASKBAR flag which is supported under Windows but the way it create the window breaks our seamless transition.
|
// Note: SDL 3.0.0+ has a SDL_WINDOW_UTILITY flag which is supported under Windows but the way it create the window breaks our seamless transition.
|
||||||
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
|
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
|
||||||
{
|
{
|
||||||
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||||
@@ -944,6 +945,10 @@ static void ImGui_ImplSDL3_ShutdownPlatformInterface()
|
|||||||
ImGui::DestroyPlatformWindows();
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
struct SDL_Renderer;
|
struct SDL_Renderer;
|
||||||
@@ -34,3 +35,5 @@ IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window, SD
|
|||||||
IMGUI_IMPL_API void ImGui_ImplSDL3_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplSDL3_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL3_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplSDL3_NewFrame();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event);
|
IMGUI_IMPL_API bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event);
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -26,12 +26,9 @@
|
|||||||
// 2021-09-21: Initial version.
|
// 2021-09-21: Initial version.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_sdlrenderer2.h"
|
#include "imgui_impl_sdlrenderer2.h"
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
|
|
||||||
// Clang warnings with -Weverything
|
// Clang warnings with -Weverything
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
@@ -258,6 +255,10 @@ void ImGui_ImplSDLRenderer2_DestroyDeviceObjects()
|
|||||||
ImGui_ImplSDLRenderer2_DestroyFontsTexture();
|
ImGui_ImplSDLRenderer2_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
// [ ] Renderer: Multi-viewport support (multiple windows).
|
// [ ] Renderer: Multi-viewport support (multiple windows).
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
struct SDL_Renderer;
|
struct SDL_Renderer;
|
||||||
@@ -28,3 +29,5 @@ IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateFontsTexture();
|
|||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyFontsTexture();
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyFontsTexture();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -21,12 +21,9 @@
|
|||||||
// 2023-05-30: Initial version.
|
// 2023-05-30: Initial version.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_sdlrenderer3.h"
|
#include "imgui_impl_sdlrenderer3.h"
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
|
|
||||||
// Clang warnings with -Weverything
|
// Clang warnings with -Weverything
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
@@ -253,6 +250,10 @@ void ImGui_ImplSDLRenderer3_DestroyDeviceObjects()
|
|||||||
ImGui_ImplSDLRenderer3_DestroyFontsTexture();
|
ImGui_ImplSDLRenderer3_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
struct SDL_Renderer;
|
struct SDL_Renderer;
|
||||||
|
|
||||||
@@ -28,3 +29,5 @@ IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_CreateFontsTexture();
|
|||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_DestroyFontsTexture();
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_DestroyFontsTexture();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_DestroyDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -68,6 +68,8 @@
|
|||||||
// 2016-10-18: Vulkan: Add location decorators & change to use structs as in/out in glsl, update embedded spv (produced with glslangValidator -x). Null the released resources.
|
// 2016-10-18: Vulkan: Add location decorators & change to use structs as in/out in glsl, update embedded spv (produced with glslangValidator -x). Null the released resources.
|
||||||
// 2016-08-27: Vulkan: Fix Vulkan example for use when a depth buffer is active.
|
// 2016-08-27: Vulkan: Fix Vulkan example for use when a depth buffer is active.
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_vulkan.h"
|
#include "imgui_impl_vulkan.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -1805,3 +1807,7 @@ void ImGui_ImplVulkan_ShutdownPlatformInterface()
|
|||||||
{
|
{
|
||||||
ImGui::DestroyPlatformWindows();
|
ImGui::DestroyPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
// Read comments in imgui_impl_vulkan.h.
|
// Read comments in imgui_impl_vulkan.h.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
// [Configuration] in order to use a custom Vulkan function loader:
|
// [Configuration] in order to use a custom Vulkan function loader:
|
||||||
@@ -163,3 +164,4 @@ struct ImGui_ImplVulkanH_Window
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -13,6 +13,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)
|
||||||
|
// 2023-07-13: Use WGPUShaderModuleWGSLDescriptor's code instead of source. use WGPUMipmapFilterMode_Linear instead of WGPUFilterMode_Linear. (#6602)
|
||||||
// 2023-04-11: Align buffer sizes. Use WGSL shaders instead of precompiled SPIR-V.
|
// 2023-04-11: Align buffer sizes. Use WGSL shaders instead of precompiled SPIR-V.
|
||||||
// 2023-04-11: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2023-04-11: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2023-01-25: Revert automatic pipeline layout generation (see https://github.com/gpuweb/gpuweb/issues/2470)
|
// 2023-01-25: Revert automatic pipeline layout generation (see https://github.com/gpuweb/gpuweb/issues/2470)
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
// 2021-01-28: Initial version.
|
// 2021-01-28: Initial version.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_wgpu.h"
|
#include "imgui_impl_wgpu.h"
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <webgpu/webgpu.h>
|
#include <webgpu/webgpu.h>
|
||||||
@@ -230,7 +232,7 @@ static WGPUProgrammableStageDescriptor ImGui_ImplWGPU_CreateShaderModule(const c
|
|||||||
|
|
||||||
WGPUShaderModuleWGSLDescriptor wgsl_desc = {};
|
WGPUShaderModuleWGSLDescriptor wgsl_desc = {};
|
||||||
wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
|
wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
|
||||||
wgsl_desc.source = wgsl_source;
|
wgsl_desc.code = wgsl_source;
|
||||||
|
|
||||||
WGPUShaderModuleDescriptor desc = {};
|
WGPUShaderModuleDescriptor desc = {};
|
||||||
desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&wgsl_desc);
|
desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&wgsl_desc);
|
||||||
@@ -511,7 +513,7 @@ static void ImGui_ImplWGPU_CreateFontsTexture()
|
|||||||
WGPUSamplerDescriptor sampler_desc = {};
|
WGPUSamplerDescriptor sampler_desc = {};
|
||||||
sampler_desc.minFilter = WGPUFilterMode_Linear;
|
sampler_desc.minFilter = WGPUFilterMode_Linear;
|
||||||
sampler_desc.magFilter = WGPUFilterMode_Linear;
|
sampler_desc.magFilter = WGPUFilterMode_Linear;
|
||||||
sampler_desc.mipmapFilter = WGPUFilterMode_Linear;
|
sampler_desc.mipmapFilter = WGPUMipmapFilterMode_Linear;
|
||||||
sampler_desc.addressModeU = WGPUAddressMode_Repeat;
|
sampler_desc.addressModeU = WGPUAddressMode_Repeat;
|
||||||
sampler_desc.addressModeV = WGPUAddressMode_Repeat;
|
sampler_desc.addressModeV = WGPUAddressMode_Repeat;
|
||||||
sampler_desc.addressModeW = WGPUAddressMode_Repeat;
|
sampler_desc.addressModeW = WGPUAddressMode_Repeat;
|
||||||
@@ -761,3 +763,7 @@ void ImGui_ImplWGPU_NewFrame()
|
|||||||
if (!bd->pipelineState)
|
if (!bd->pipelineState)
|
||||||
ImGui_ImplWGPU_CreateDeviceObjects();
|
ImGui_ImplWGPU_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
#include <webgpu/webgpu.h>
|
#include <webgpu/webgpu.h>
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format, WGPUTextureFormat depth_format = WGPUTextureFormat_Undefined);
|
IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format, WGPUTextureFormat depth_format = WGPUTextureFormat_Undefined);
|
||||||
@@ -23,3 +25,5 @@ IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURen
|
|||||||
// 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 void ImGui_ImplWGPU_InvalidateDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplWGPU_InvalidateDeviceObjects();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplWGPU_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplWGPU_CreateDeviceObjects();
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_impl_win32.h"
|
#include "imgui_impl_win32.h"
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -1283,3 +1284,5 @@ static void ImGui_ImplWin32_ShutdownPlatformInterface()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
|
IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplWin32_InitForOpenGL(void* hwnd);
|
IMGUI_IMPL_API bool ImGui_ImplWin32_InitForOpenGL(void* hwnd);
|
||||||
@@ -45,3 +46,5 @@ IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); //
|
|||||||
// - Use to enable alpha compositing transparency with the desktop.
|
// - Use to enable alpha compositing transparency with the desktop.
|
||||||
// - Use together with e.g. clearing your framebuffer with zero-alpha.
|
// - Use together with e.g. clearing your framebuffer with zero-alpha.
|
||||||
IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd
|
IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -5,96 +5,113 @@ This document holds the user-facing changelog that we also use in release notes.
|
|||||||
We generally fold multiple commits pertaining to the same topic as a single entry.
|
We generally fold multiple commits pertaining to the same topic as a single entry.
|
||||||
Changes to backends are also included within the individual .cpp files of each backend.
|
Changes to backends are also included within the individual .cpp files of each backend.
|
||||||
|
|
||||||
RELEASE NOTES: https://github.com/ocornut/imgui/releases
|
|
||||||
REPORT ISSUES: https://github.com/ocornut/imgui/issues
|
|
||||||
DISCUSS, ASK QUESTIONS: https://github.com/ocornut/imgui/discussions
|
|
||||||
WIKI https://github.com/ocornut/imgui/wiki
|
|
||||||
FAQ https://www.dearimgui.com/faq/
|
FAQ https://www.dearimgui.com/faq/
|
||||||
|
RELEASE NOTES: https://github.com/ocornut/imgui/releases
|
||||||
|
WIKI https://github.com/ocornut/imgui/wiki
|
||||||
|
GETTING STARTED https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||||
|
GLOSSARY https://github.com/ocornut/imgui/wiki/Glossary
|
||||||
|
ISSUES & SUPPORT https://github.com/ocornut/imgui/issues
|
||||||
|
|
||||||
WHEN TO UPDATE?
|
WHEN TO UPDATE?
|
||||||
|
|
||||||
- Keeping your copy of Dear ImGui updated regularly is recommended.
|
- Keeping your copy of Dear ImGui updated regularly is recommended.
|
||||||
- It is generally safe to sync to the latest commit in master or docking branches
|
- It is generally safe and recommended to sync to the latest commit in 'master' or 'docking'
|
||||||
The library is fairly stable and regressions tends to be fixed fast when reported.
|
branches. The library is fairly stable and regressions tends to be fixed fast when reported.
|
||||||
|
|
||||||
HOW TO UPDATE?
|
HOW TO UPDATE?
|
||||||
|
|
||||||
- Overwrite every file except imconfig.h (if you have modified it).
|
- Update submodule or copy/overwrite every file.
|
||||||
- You may also locally branch to modify imconfig.h and merge latest into your branch.
|
- About imconfig.h:
|
||||||
|
- You may modify your copy of imconfig.h, in this case don't overwrite it.
|
||||||
|
- or you may locally branch to modify imconfig.h and merge/rebase latest.
|
||||||
|
- or you may '#define IMGUI_USER_CONFIG "my_config_file.h"' globally from your build system to
|
||||||
|
specify a custom path for your imconfig.h file and instead not have to modify the default one.
|
||||||
- Read the `Breaking Changes` section (in imgui.cpp or here in the Changelog).
|
- Read the `Breaking Changes` section (in imgui.cpp or here in the Changelog).
|
||||||
- If you have a problem with a missing function/symbols, search for its name in the code, there will likely be a comment about it.
|
- If you have a problem with a missing function/symbols, search for its name in the code, there will likely be a comment about it.
|
||||||
- If you are dropping this repository in your codebase, please leave the demo and text files in there, they will be useful.
|
- If you are copying this repository in your codebase, please leave the demo and documentations files in there, they will be useful.
|
||||||
- You may diff your previous Changelog with the one you just copied and read that diff.
|
- You may diff your previous Changelog with the one you just copied and read that diff.
|
||||||
- You may enable `IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in imconfig.h to forcefully disable legacy names and symbols.
|
- You may enable `IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in imconfig.h to forcefully disable legacy names and symbols.
|
||||||
Doing it every once in a while is a good way to make sure you are not using obsolete symbols. Dear ImGui is in active development,
|
Doing it every once in a while is a good way to make sure you are not using obsolete symbols. Dear ImGui is in active development,
|
||||||
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
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!
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
DOCKING+MULTI-VIEWPORT BRANCH (In Progress)
|
VERSION 1.89.8 (Released 2023-08-01)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
DOCKING FEATURES
|
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.89.8
|
||||||
(see https://github.com/ocornut/imgui/wiki/Docking for quick intro)
|
|
||||||
|
|
||||||
- Added Docking system: [BETA] (#2109, #351)
|
Breaking changes:
|
||||||
- Added ImGuiConfigFlags_DockingEnable flag to enable Docking.
|
|
||||||
Set with `io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;`.
|
|
||||||
- Added DockSpace(), DockSpaceOverViewport() API.
|
|
||||||
- Added ImGuiDockNodeFlags flags for DockSpace().
|
|
||||||
- Added SetNextWindowDockID(), SetNextWindowClass() API.
|
|
||||||
- Added GetWindowDockID(), IsWindowDocked() API.
|
|
||||||
- Added ImGuiWindowFlags_NoDocking window flag to disable the possibility for a window to be docked.
|
|
||||||
Popup, Menu and Child windows always have the ImGuiWindowFlags_NoDocking flag set.
|
|
||||||
- Added ImGuiWindowClass to specify advanced docking/viewport related flags via SetNextWindowClass().
|
|
||||||
- Added io.ConfigDockingNoSplit option.
|
|
||||||
- Added io.ConfigDockingWithShift option.
|
|
||||||
- Added io.ConfigDockingAlwaysTabBar option.
|
|
||||||
- Added io.ConfigDockingTransparentPayload option.
|
|
||||||
- Style: Added ImGuiCol_DockingPreview, ImGuiCol_DockingEmptyBg colors.
|
|
||||||
- Demo: Added "DockSpace" example app showcasing use of explicit dockspace nodes.
|
|
||||||
|
|
||||||
MULTI-VIEWPORT FEATURES
|
- IO: Obsoleted io.ClearInputCharacters() (added in 1.47) as it now ambiguous
|
||||||
(see https://github.com/ocornut/imgui/wiki/Multi-Viewports for quick intro)
|
and often incorrect/misleading considering the existence of a higher-level
|
||||||
|
input queue. This is automatically cleared by io.ClearInputsKeys(). (#4921)
|
||||||
Breaking Changes:
|
- ImDrawData: CmdLists[] array is now owned, changed from 'ImDrawList**' to
|
||||||
|
'ImVector<ImDrawList*>'. Majority of users shouldn't be affected, but you
|
||||||
- IMPORTANT: When multi-viewports are enabled (with io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable),
|
cannot compare to NULL nor reassign manually anymore.
|
||||||
all coordinates/positions will be in your natural OS coordinates space. It means that:
|
Instead use AddDrawList(). Allocation count are identical. (#6406, #4879, #1878)
|
||||||
- Reference to hard-coded positions such as in SetNextWindowPos(ImVec2(0,0)) are _probably_ not what you want anymore.
|
|
||||||
Use GetMainViewport()->Pos to offset hard-coded positions, e.g. SetNextWindowPos(GetMainViewport()->Pos).
|
|
||||||
- Likewise io.MousePos and GetMousePos() will use OS coordinates.
|
|
||||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them.
|
|
||||||
e.g. subtract GetWindowViewport()->Pos.
|
|
||||||
- IO: Removed io.DisplayVisibleMin, io.DisplayVisibleMax settings (they were marked obsoleted, used to clip within the (0,0)..(DisplaySize) range).
|
|
||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
(FIXME: This need a fuller explanation!)
|
|
||||||
|
|
||||||
- Added ImGuiPlatformIO structure and GetPlatformIO().
|
- Fonts: ImFontConfig::OversampleH now defaults to 2 instead of 3, since the
|
||||||
- Similarly to ImGuiIO and GetIO(), this structure is the main point of communication for backends supporting multi-viewports.
|
quality increase is largely minimal.
|
||||||
- Backend sets functions in ImGuiPlatformIO to manipulate platform windows.
|
- Fonts, imgui_freetype: Added support to render OpenType SVG fonts using lunasvg.
|
||||||
- ImGuiPlatformIO::Monitors is a list of platform monitors (input from backend)
|
Requires enabling IMGUI_ENABLE_FREETYPE_LUNASVG along with IMGUI_ENABLE_FREETYPE,
|
||||||
- ImGuiPlatformIO::Viewports is a list of viewports (output from dear imgui)
|
and providing headers/libraries for lunasvg. (#6591, #6607) [@sakiodre]
|
||||||
- Added ImGuiPlatformMonitor to feed OS monitor information in the ImGuiPlatformIO::Monitors.
|
- ImDrawData: CmdLists[] array is now an ImVector<> owned by ImDrawData rather
|
||||||
- Added GetWindowViewport(), SetNextWindowViewport().
|
than a pointer to internal state.
|
||||||
- Added GetWindowDpiScale().
|
- This makes it easier for user to create their own or append to an existing draw data.
|
||||||
- Added GetOverlayDrawList(ImGuiViewport* viewport).
|
Added a ImDrawData::AddDrawList() helper function to do that. (#6406, #4879, #1878)
|
||||||
The no-parameter version of GetOverlayDrawList() return the overlay for the current window's viewport.
|
- This makes it easier to perform a deep-swap instead of a deep-copy, as array
|
||||||
- Added UpdatePlatformWindows(), RenderPlatformWindowsDefault(), DestroyPlatformWindows() for usage in application setup.
|
ownership is now clear. (#6597, #6475, #6167, #5776, #5109, #4763, #3515, #1860)
|
||||||
- Added FindViewportByID(), FindViewportByPlatformHandle() for usage by backends.
|
- Syntax and allocation count are otherwise identical.
|
||||||
- Added ImGuiConfigFlags_ViewportsEnable configuration flag and other viewport options.
|
- Fixed CTRL+Tab dimming background assert when target window has a callback
|
||||||
- Added io.ConfigViewportsNoAutoMerge option.
|
in the last ImDrawCmd. (#4857, #5937)
|
||||||
- Added io.ConfigViewportsNoTaskBarIcon option.
|
- IsItemHovered: Fixed ImGuiHoveredFlags_ForTooltip for Keyboard/Gamepad navigation,
|
||||||
- Added io.ConfigViewportsNoDecoration option.
|
got broken prior to 1.89.7 due to an unrelated change making flags conflict. (#6622, #1485)
|
||||||
- Added io.ConfigViewportsNoDefaultParent option.
|
- InputText: Fixed a case where deactivation frame would write to underlying
|
||||||
- Added ImGuiBackendFlags_PlatformHasViewports, ImGuiBackendFlags_RendererHasViewports, ImGuiBackendFlags_HasMouseHoveredViewport backend flags.
|
buffer or call CallbackResize although unnecessary, in a frame where the
|
||||||
- Added io.AddMouseViewportEvent() (optional _even_ for multi-viewport support, tied to ImGuiBackendFlags_HasMouseHoveredViewport flag).
|
return value was false.
|
||||||
- Expanded ImGuiViewport structure, ImGuiViewportFlags flags.
|
- Tables: fixed GetContentRegionAvail().y report not taking account of lower cell
|
||||||
- Added ImGuiWindowClass and SetNextWindowClass() for passing viewport related hints to the OS/platform back-end.
|
padding or of using ImGuiTableFlags_NoHostExtendY. Not taking it into account
|
||||||
- Examples: Renderer: OpenGL2, OpenGL3, DirectX9, DirectX10, DirectX11, DirectX12, Vulkan: Added support for multi-viewports.
|
would make the idiom of creating vertically bottom-aligned content (e.g. a child
|
||||||
- Examples: Platforms: Win32, GLFW, SDL2: Added support for multi-viewports.
|
window) inside a table make the parent window erroneously have a scrollbar. (#6619)
|
||||||
Note that Linux/Mac still have inconsistent support for multi-viewports. If you want to help see https://github.com/ocornut/imgui/issues/2117.
|
- Tables: fixed calculation of multi-instance shared decoration/scrollbar width of
|
||||||
|
scrolling tables, to avoid flickering width variation when resizing down a table
|
||||||
|
hosting a child window. (#5920, #6619)
|
||||||
|
- Scrollbar: layout needs to take account of window border size, so a border size
|
||||||
|
will slightly reduce scrollbar size. Generally we tried to make it that window
|
||||||
|
border size has no incidence on layout but this can't work with thick borders. (#2522)
|
||||||
|
- IO: Added io.ClearEventsQueue() to clear incoming inputs events. (#4921)
|
||||||
|
May be useful in conjunction with io.ClearInputsKeys() if you need to clear
|
||||||
|
both current inputs state and queued events (e.g. when using blocking native
|
||||||
|
dialogs such as Windows's ::MessageBox() or ::GetOpenFileName()).
|
||||||
|
- IO: Changed io.ClearInputsKeys() specs to also clear current frame character buffer
|
||||||
|
(what now obsoleted io.ClearInputCharacters() did), as this is effectively the
|
||||||
|
desirable behavior.
|
||||||
|
- Misc: Added IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION config macro to disable
|
||||||
|
stb_sprintf implementation when using IMGUI_USE_STB_SPRINTF. (#6626) [@septag]
|
||||||
|
- Misc: Avoid stb_textedit.h reincluding string.h while in a namespace, which
|
||||||
|
messes up with building with Clang Modules. (#6653, #4791) [@JohelEGP]
|
||||||
|
- Demo: Better showcase use of SetNextItemAllowOverlap(). (#6574, #6512, #3909, #517)
|
||||||
|
- Demo: Showcase a few more InputText() flags.
|
||||||
|
- Backends: Made all backends sources files support global IMGUI_DISABLE. (#6601)
|
||||||
|
- Backends: GLFW: Revert ignoring mouse data on GLFW_CURSOR_DISABLED as it can be used
|
||||||
|
differently. User may set ImGuiConfigFlags_NoMouse if desired. (#5625, #6609) [@scorpion-26]
|
||||||
|
- Backends: WebGPU: Update for changes in Dawn. (#6602, #6188) [@williamhCode]
|
||||||
|
- Examples: Vulkan: Creating minimal descriptor pools to fit only what is needed by
|
||||||
|
example. (#6642) [@SaschaWillem]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking, Style: resizing separators use same colors as window borders (ImGuiCol_Border)
|
||||||
|
for consistency. With default styles it doesn't make a big difference. (#2522) [@rmitton]
|
||||||
|
In the future if we promote using thick value for inner/outer docking padding we may
|
||||||
|
need to introduce new colors for it.
|
||||||
|
- Docking: added style.DockingSeparatorSize, ImGuiStyleVar_DockingSeparatorSize. Now
|
||||||
|
also scaled by style.ScaleAllSizes(). (#3481, #4721, #2522) [@PossiblyAShrub, @wobbier]
|
||||||
|
- Docking: fixed rendering of docked-window scrollbar above outer border. (#2522)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@@ -115,6 +132,11 @@ Breaking changes:
|
|||||||
legacy 'SetItemAllowOverlap()' call (public API) + ImGuiButtonFlags_AllowOverlap (internal).
|
legacy 'SetItemAllowOverlap()' call (public API) + ImGuiButtonFlags_AllowOverlap (internal).
|
||||||
- Obsoleted 'SetItemAllowOverlap()': it didn't and couldn't work reliably since 1.89 (2022-11-15),
|
- Obsoleted 'SetItemAllowOverlap()': it didn't and couldn't work reliably since 1.89 (2022-11-15),
|
||||||
and relied on ambiguously defined design. Use 'SetNextItemAllowOverlap()' before item instead.
|
and relied on ambiguously defined design. Use 'SetNextItemAllowOverlap()' before item instead.
|
||||||
|
- Selectable, TreeNode: When using ImGuiSelectableFlags_AllowOverlap/ImGuiTreeNodeFlags_AllowOverlap
|
||||||
|
and holding item held, overlapping widgets won't appear as hovered. (#6512, #3909)
|
||||||
|
While this fixes a common small visual issue, it also means that calling IsItemHovered()
|
||||||
|
after a non-reactive elements - e.g. Text() - overlapping an active one may fail if you don't
|
||||||
|
use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem). (#6610)
|
||||||
- Renamed 'ImGuiTreeNodeFlags_AllowItemOverlap' to 'ImGuiTreeNodeFlags_AllowOverlap'.
|
- Renamed 'ImGuiTreeNodeFlags_AllowItemOverlap' to 'ImGuiTreeNodeFlags_AllowOverlap'.
|
||||||
- Renamed 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'
|
- Renamed 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'
|
||||||
- Kept redirecting enums (will obsolete).
|
- Kept redirecting enums (will obsolete).
|
||||||
@@ -150,8 +172,6 @@ Other changes:
|
|||||||
- Fixed first frame of an overlap highlighting underlying item if previous frame didn't hover anything.
|
- Fixed first frame of an overlap highlighting underlying item if previous frame didn't hover anything.
|
||||||
- IsItemHovered: Changed to return false when querying an item using AllowOverlap mode which
|
- IsItemHovered: Changed to return false when querying an item using AllowOverlap mode which
|
||||||
is being overlapped. Added ImGuiHoveredFlags_AllowWhenOverlappedByItem to opt-out. (#6512, #3909, #517)
|
is being overlapped. Added ImGuiHoveredFlags_AllowWhenOverlappedByItem to opt-out. (#6512, #3909, #517)
|
||||||
- Selectable, TreeNode: When using ImGuiSelectableFlags_AllowOverlap/ImGuiTreeNodeFlags_AllowOverlap
|
|
||||||
and holding item held, overlapping widgets won't appear as hovered. (#6512, #3909)
|
|
||||||
- IsWindowHovered: Added support for ImGuiHoveredFlags_Stationary.
|
- IsWindowHovered: Added support for ImGuiHoveredFlags_Stationary.
|
||||||
- IsWindowHovered, IsItemHovered: Assert when passed any unsupported flags.
|
- IsWindowHovered, IsItemHovered: Assert when passed any unsupported flags.
|
||||||
- Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either
|
- Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either
|
||||||
|
|||||||
38
docs/FAQ.md
38
docs/FAQ.md
@@ -91,6 +91,7 @@ Many projects are using this branch and it is kept in sync with master regularly
|
|||||||
|
|
||||||
### Q: How to get started?
|
### Q: How to get started?
|
||||||
|
|
||||||
|
Read [Getting Started](https://github.com/ocornut/imgui/wiki/Getting-Started). <BR>
|
||||||
Read [EXAMPLES.md](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md). <BR>
|
Read [EXAMPLES.md](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md). <BR>
|
||||||
Read [BACKENDS.md](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md). <BR>
|
Read [BACKENDS.md](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md). <BR>
|
||||||
Read `PROGRAMMER GUIDE` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp). <BR>
|
Read `PROGRAMMER GUIDE` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp). <BR>
|
||||||
@@ -164,8 +165,8 @@ Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-lik
|
|||||||
---
|
---
|
||||||
|
|
||||||
### Q: 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...
|
||||||
Your renderer is not using the font texture correctly or it hasn't been uploaded to the GPU.
|
Your renderer backend is not using the font texture correctly or it hasn't been uploaded to the GPU.
|
||||||
- If this happens using the standard backends: A) have you modified the font atlas after `ImGui_ImplXXX_NewFrame()`? B) maybe the texture failed to upload, which could happens if for some reason your texture is too big. Also see [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md).
|
- If this happens using the standard backends: A) have you modified the font atlas after `ImGui_ImplXXX_NewFrame()`? B) maybe the texture failed to upload, which **can if your texture atlas is too big**. Also see [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md).
|
||||||
- If this happens with a custom backend: make sure you have uploaded the font texture to the GPU, that all shaders are rendering states are setup properly (e.g. texture is bound). Compare your code to existing backends and use a graphics debugger such as [RenderDoc](https://renderdoc.org) to debug your rendering states.
|
- If this happens with a custom backend: make sure you have uploaded the font texture to the GPU, that all shaders are rendering states are setup properly (e.g. texture is bound). Compare your code to existing backends and use a graphics debugger such as [RenderDoc](https://renderdoc.org) to debug your rendering states.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
@@ -569,44 +570,15 @@ io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT
|
|||||||
### Q: How can I easily use icons in my application?
|
### Q: How can I easily use icons in my application?
|
||||||
The most convenient and practical way is to merge an icon font such as FontAwesome inside your
|
The most convenient and practical way is to merge an icon font such as FontAwesome inside your
|
||||||
main font. Then you can refer to icons within your strings.
|
main font. Then you can refer to icons within your strings.
|
||||||
You may want to see `ImFontConfig::GlyphMinAdvanceX` to make your icon look monospace to facilitate alignment.
|
Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file for more details about icons font loading.
|
||||||
(Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file for more details about icons font loading.)
|
|
||||||
With some extra effort, you may use colorful icons by registering custom rectangle space inside the font atlas,
|
|
||||||
and copying your own graphics data into it. See docs/FONTS.md about using the AddCustomRectFontGlyph API.
|
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Q: How can I load multiple fonts?
|
### Q: How can I load multiple fonts?
|
||||||
Use the font atlas to pack them into a single texture:
|
|
||||||
(Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file and the code in ImFontAtlas for more details.)
|
|
||||||
|
|
||||||
```cpp
|
Use the font atlas to pack them into a single texture. Read [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) for more details.
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImFont* font0 = io.Fonts->AddFontDefault();
|
|
||||||
ImFont* font1 = io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
|
|
||||||
ImFont* font2 = io.Fonts->AddFontFromFileTTF("myfontfile2.ttf", size_in_pixels);
|
|
||||||
io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
|
|
||||||
// the first loaded font gets used by default
|
|
||||||
// use ImGui::PushFont()/ImGui::PopFont() to change the font at runtime
|
|
||||||
|
|
||||||
// Options
|
|
||||||
ImFontConfig config;
|
|
||||||
config.OversampleH = 2;
|
|
||||||
config.OversampleV = 1;
|
|
||||||
config.GlyphOffset.y -= 1.0f; // Move everything by 1 pixel up
|
|
||||||
config.GlyphExtraSpacing.x = 1.0f; // Increase spacing between characters
|
|
||||||
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, &config);
|
|
||||||
|
|
||||||
// Combine multiple fonts into one (e.g. for icon fonts)
|
|
||||||
static ImWchar ranges[] = { 0xf000, 0xf3ff, 0 };
|
|
||||||
ImFontConfig config;
|
|
||||||
config.MergeMode = true;
|
|
||||||
io.Fonts->AddFontDefault();
|
|
||||||
io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); // Merge icon font
|
|
||||||
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, nullptr, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge japanese glyphs
|
|
||||||
```
|
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
|||||||
224
docs/FONTS.md
224
docs/FONTS.md
@@ -11,10 +11,7 @@ In the [misc/fonts/](https://github.com/ocornut/imgui/tree/master/misc/fonts) fo
|
|||||||
**Also read the FAQ:** https://www.dearimgui.com/faq (there is a Fonts section!)
|
**Also read the FAQ:** https://www.dearimgui.com/faq (there is a Fonts section!)
|
||||||
|
|
||||||
## Index
|
## Index
|
||||||
- [Readme First](#readme-first)
|
- [Troubleshooting](#troubleshooting)
|
||||||
- [About Filenames](#about-filenames)
|
|
||||||
- [About UTF-8 Encoding](#about-utf-8-encoding)
|
|
||||||
- [Debug Tools](#debug-tools)
|
|
||||||
- [How should I handle DPI in my application?](#how-should-i-handle-dpi-in-my-application)
|
- [How should I handle DPI in my application?](#how-should-i-handle-dpi-in-my-application)
|
||||||
- [Fonts Loading Instructions](#fonts-loading-instructions)
|
- [Fonts Loading Instructions](#fonts-loading-instructions)
|
||||||
- [Using Icon Fonts](#using-icon-fonts)
|
- [Using Icon Fonts](#using-icon-fonts)
|
||||||
@@ -23,103 +20,44 @@ In the [misc/fonts/](https://github.com/ocornut/imgui/tree/master/misc/fonts) fo
|
|||||||
- [Using Custom Glyph Ranges](#using-custom-glyph-ranges)
|
- [Using Custom Glyph Ranges](#using-custom-glyph-ranges)
|
||||||
- [Using Custom Colorful Icons](#using-custom-colorful-icons)
|
- [Using Custom Colorful Icons](#using-custom-colorful-icons)
|
||||||
- [Using Font Data Embedded In Source Code](#using-font-data-embedded-in-source-code)
|
- [Using Font Data Embedded In Source Code](#using-font-data-embedded-in-source-code)
|
||||||
|
- [About Filenames](#about-filenames)
|
||||||
|
- [About UTF-8 Encoding](#about-utf-8-encoding)
|
||||||
|
- [Debug Tools](#debug-tools)
|
||||||
- [Credits/Licenses For Fonts Included In Repository](#creditslicenses-for-fonts-included-in-repository)
|
- [Credits/Licenses For Fonts Included In Repository](#creditslicenses-for-fonts-included-in-repository)
|
||||||
- [Font Links](#font-links)
|
- [Font Links](#font-links)
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
## Readme First
|
## Troubleshooting
|
||||||
|
|
||||||
**A vast majority of font and text related issues encountered comes from 3 things:**
|
**A vast majority of font and text related issues encountered comes from 4 things:**
|
||||||
- Invalid filename due to use of `\` or unexpected working directory. See [About Filenames](#about-filenames). AddFontXXX functions should assert if the filename is incorrect.
|
|
||||||
- Invalid UTF-8 encoding of your non-ASCII strings. See [About UTF-8 Encoding](#about-utf-8-encoding). Use the encoding viewer to confirm yours is correct.
|
|
||||||
- You need to load a font with explicit glyph ranges if you want to use non-ASCII characters. See [Fonts Loading Instructions](#fonts-loading-instructions). Use Metrics/Debugger->Fonts to confirm loaded fonts and loaded glyph ranges.
|
|
||||||
|
|
||||||
The third point is a current constraint of Dear ImGui (which we will lift in the future): when loading a font you need to specify which characters glyphs to load.
|
### (1) Invalid filename due to use of `\` or unexpected working directory.
|
||||||
All loaded fonts glyphs are rendered into a single texture atlas ahead of time. Calling either of `io.Fonts->GetTexDataAsAlpha8()`, `io.Fonts->GetTexDataAsRGBA32()` or `io.Fonts->Build()` will build the atlas. This is generally called by the Renderer backend, e.g. `ImGui_ImplDX11_NewFrame()` calls it.
|
|
||||||
|
|
||||||
**If you use custom glyphs ranges, make sure the array is persistent** and available during the calls to `GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build()`.
|
See [About Filenames](#about-filenames). AddFontXXX functions should assert if the filename is incorrect.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
### (2) Invalid UTF-8 encoding of your non-ASCII strings.
|
||||||
|
|
||||||
## About Filenames
|
See [About UTF-8 Encoding](#about-utf-8-encoding). Use the encoding viewer to confirm encoding of string literal in your source code is correct.
|
||||||
|
|
||||||
**Please note that many new C/C++ users have issues loading their files _because the filename they provide is wrong_ due to incorrect assumption of what is the current directory.**
|
### (3) Missing glyph ranges.
|
||||||
|
|
||||||
Two things to watch for:
|
You need to load a font with explicit glyph ranges if you want to use non-ASCII characters. See [Fonts Loading Instructions](#fonts-loading-instructions). Use [Debug Tools](#debug-tools) confirm loaded fonts and loaded glyph ranges.
|
||||||
|
|
||||||
(1) In C/C++ and most programming languages if you want to use a backslash `\` within a string literal, you need to write it double backslash `\\`. At it happens, Windows uses backslashes as a path separator, so be mindful.
|
This is a current constraint of Dear ImGui (which we will lift in the future): when loading a font you need to specify which characters glyphs to load.
|
||||||
```cpp
|
All loaded fonts glyphs are rendered into a single texture atlas ahead of time. Calling either of `io.Fonts->GetTexDataAsAlpha8()`, `io.Fonts->GetTexDataAsRGBA32()` or `io.Fonts->Build()` will build the atlas. This is generally called by the Renderer backend, e.g. `ImGui_ImplDX11_NewFrame()` calls it. **If you use custom glyphs ranges, make sure the array is persistent** and available during the calls to `GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build()`.
|
||||||
io.Fonts->AddFontFromFileTTF("MyFiles\MyImage01.jpg", ...); // This is INCORRECT!!
|
|
||||||
io.Fonts->AddFontFromFileTTF("MyFiles\\MyImage01.jpg", ...); // This is CORRECT
|
|
||||||
```
|
|
||||||
In some situations, you may also use `/` path separator under Windows.
|
|
||||||
|
|
||||||
(2) Make sure your IDE/debugger settings starts your executable from the right working (current) directory. In Visual Studio you can change your working directory in project `Properties > General > Debugging > Working Directory`. People assume that their execution will start from the root folder of the project, where by default it often starts from the folder where object or executable files are stored.
|
### (4) Font atlas texture fails to upload to GPU.
|
||||||
```cpp
|
|
||||||
io.Fonts->AddFontFromFileTTF("MyImage01.jpg", ...); // Relative filename depends on your Working Directory when running your program!
|
|
||||||
io.Fonts->AddFontFromFileTTF("../MyImage01.jpg", ...); // Load from the parent folder of your Working Directory
|
|
||||||
```
|
|
||||||
##### [Return to Index](#index)
|
|
||||||
|
|
||||||
|
This is often of byproduct of point 3. If you have large number of glyphs or multiple fonts, the texture may become too big for your graphics API. **The typical result of failing to upload a texture is if every glyph or everything appears as empty black or white rectangle.** Mind the fact that some graphics drivers have texture size limitation. If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours.
|
||||||
|
|
||||||
## About UTF-8 Encoding
|
Some solutions:
|
||||||
|
- You may reduce oversampling, e.g. `font_config.OversampleH = 1`, this will half your texture size for a quality looss.
|
||||||
**For non-ASCII characters display, a common user issue is not passing correctly UTF-8 encoded strings.**
|
Note that while OversampleH = 2 looks visibly very close to 3 in most situations, with OversampleH = 1 the quality drop will be noticeable. Read about oversampling [here](https://github.com/nothings/stb/blob/master/tests/oversample).
|
||||||
|
- Reduce glyphs ranges by calculating them from source localization data.
|
||||||
(1) We provide a function `ImGui::DebugTextEncoding(const char* text)` which you can call to verify the content of your UTF-8 strings.
|
You can use the `ImFontGlyphRangesBuilder` for this purpose and rebuilding your atlas between frames when new characters are needed. This will be the biggest win!
|
||||||
This is a convenient way to confirm that your encoding is correct.
|
- Set `io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;` to disable rounding the texture height to the next power of two.
|
||||||
|
- Set `io.Fonts.TexDesiredWidth` to specify a texture width to reduce maximum texture height (see comment in `ImFontAtlas::Build()` function).
|
||||||
```cpp
|
|
||||||
ImGui::SeparatorText("CORRECT");
|
|
||||||
ImGui::DebugTextEncoding(u8"こんにちは");
|
|
||||||
|
|
||||||
ImGui::SeparatorText("INCORRECT");
|
|
||||||
ImGui::DebugTextEncoding("こんにちは");
|
|
||||||
```
|
|
||||||

|
|
||||||
|
|
||||||
You can also find this tool under `Metrics/Debuggers->Tools->UTF-8 Encoding viewer` if you want to paste from clipboard, but this won't validate the UTF-8 encoding done by your compiler.
|
|
||||||
|
|
||||||
(2) To encode in UTF-8:
|
|
||||||
|
|
||||||
There are also compiler-specific ways to enforce UTF-8 encoding by default:
|
|
||||||
|
|
||||||
- Visual Studio compiler: `/utf-8` command-line flag.
|
|
||||||
- Visual Studio compiler: `#pragma execution_character_set("utf-8")` inside your code.
|
|
||||||
- Since May 2023 we have changed the Visual Studio projects of all our examples to use `/utf-8` ([see commit](https://github.com/ocornut/imgui/commit/513af1efc9080857bbd10000d98f98f2a0c96803)).
|
|
||||||
|
|
||||||
Or, since C++11, you can use the `u8"my text"` syntax to encode literal strings as UTF-8. e.g.:
|
|
||||||
```cpp
|
|
||||||
ImGui::Text(u8"hello");
|
|
||||||
ImGui::Text(u8"こんにちは"); // this will always be encoded as UTF-8
|
|
||||||
ImGui::Text("こんにちは"); // the encoding of this is depending on compiler settings/flags and may be incorrect.
|
|
||||||
```
|
|
||||||
|
|
||||||
Since C++20, because the C++ committee hate its users, they decided to change the `u8""` syntax to not return `const char*` but a new type `const char_t*` which doesn't cast to `const char*`.
|
|
||||||
Because of type usage of `u8""` in C++20 is a little more tedious:
|
|
||||||
```cpp
|
|
||||||
ImGui::Text((const char*)u8"こんにちは");
|
|
||||||
```
|
|
||||||
We suggest using a macro in your codebase:
|
|
||||||
```cpp
|
|
||||||
#define U8(_S) (const char*)u8##_S
|
|
||||||
ImGui::Text(U8("こんにちは"));
|
|
||||||
```
|
|
||||||
##### [Return to Index](#index)
|
|
||||||
|
|
||||||
|
|
||||||
## Debug Tools
|
|
||||||
|
|
||||||
#### Metrics/Debugger->Fonts
|
|
||||||
You can use the `Metrics/Debugger` window (available in `Demo>Tools`) to browse your fonts and understand what's going on if you have an issue. You can also reach it in `Demo->Tools->Style Editor->Fonts`. The same information are also available in the Style Editor under Fonts.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### UTF-8 Encoding Viewer**
|
|
||||||
You can use the `UTF-8 Encoding viewer` in `Metrics/Debugger` to verify the content of your UTF-8 strings. From C/C++ code, you can call `ImGui::DebugTextEncoding("my string");` function to verify that your UTF-8 encoding is correct.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
@@ -144,7 +82,7 @@ io.Fonts->AddFontDefault();
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
||||||
```
|
```
|
||||||
If you get an assert stating "Could not load font file!", your font filename is likely incorrect. Read "[About filenames](#about-filenames)" carefully.
|
If you get an assert stating "Could not load font file!", your font filename is likely incorrect. Read [About filenames](#about-filenames) carefully.
|
||||||
|
|
||||||
**Load multiple fonts:**
|
**Load multiple fonts:**
|
||||||
```cpp
|
```cpp
|
||||||
@@ -153,8 +91,9 @@ ImGuiIO& io = ImGui::GetIO();
|
|||||||
ImFont* font1 = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
ImFont* font1 = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
|
||||||
ImFont* font2 = io.Fonts->AddFontFromFileTTF("anotherfont.otf", size_pixels);
|
ImFont* font2 = io.Fonts->AddFontFromFileTTF("anotherfont.otf", size_pixels);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In your application loop, select which font to use:
|
||||||
```cpp
|
```cpp
|
||||||
// In application loop: select font at runtime
|
|
||||||
ImGui::Text("Hello"); // use the default font (which is the first loaded font)
|
ImGui::Text("Hello"); // use the default font (which is the first loaded font)
|
||||||
ImGui::PushFont(font2);
|
ImGui::PushFont(font2);
|
||||||
ImGui::Text("Hello with another font");
|
ImGui::Text("Hello with another font");
|
||||||
@@ -220,22 +159,6 @@ ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
|
|||||||

|

|
||||||
<br>_(settings: Dark style (left), Light style (right) / Font: NotoSansCJKjp-Medium, 20px / Rounding: 5)_
|
<br>_(settings: Dark style (left), Light style (right) / Font: NotoSansCJKjp-Medium, 20px / Rounding: 5)_
|
||||||
|
|
||||||
**Font Atlas too large?**
|
|
||||||
|
|
||||||
- If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API. The typical result of failing to upload a texture is if every glyph appears as a white rectangle.
|
|
||||||
- Mind the fact that some graphics drivers have texture size limitation. If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours.
|
|
||||||
|
|
||||||
Some solutions:
|
|
||||||
|
|
||||||
1. Reduce glyphs ranges by calculating them from source localization data.
|
|
||||||
You can use the `ImFontGlyphRangesBuilder` for this purpose and rebuilding your atlas between frames when new characters are needed. This will be the biggest win!
|
|
||||||
2. You may reduce oversampling, e.g. `font_config.OversampleH = 2`, this will largely reduce your texture size.
|
|
||||||
Note that while OversampleH = 2 looks visibly very close to 3 in most situations, with OversampleH = 1 the quality drop will be noticeable.
|
|
||||||
3. Set `io.Fonts.TexDesiredWidth` to specify a texture width to minimize texture height (see comment in `ImFontAtlas::Build()` function).
|
|
||||||
4. Set `io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;` to disable rounding the texture height to the next power of two.
|
|
||||||
5. Read about oversampling [here](https://github.com/nothings/stb/blob/master/tests/oversample).
|
|
||||||
6. To support the extended range of unicode beyond 0xFFFF (e.g. emoticons, dingbats, symbols, shapes, ancient languages, etc...) add `#define IMGUI_USE_WCHAR32`in your `imconfig.h`.
|
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
## Using Icon Fonts
|
## Using Icon Fonts
|
||||||
@@ -270,6 +193,12 @@ ImGui::Button(ICON_FA_SEARCH " Search");
|
|||||||
```
|
```
|
||||||
See Links below for other icons fonts and related tools.
|
See Links below for other icons fonts and related tools.
|
||||||
|
|
||||||
|
**Monospace Icons?**
|
||||||
|
|
||||||
|
To make your icon look more monospace and facilitate alignment, you may want to set the ImFontConfig::GlyphMinAdvanceX value when loading an icon font.
|
||||||
|
|
||||||
|
**Screenshot**
|
||||||
|
|
||||||
Here's an application using icons ("Avoyd", https://www.avoyd.com):
|
Here's an application using icons ("Avoyd", https://www.avoyd.com):
|
||||||

|

|
||||||
|
|
||||||
@@ -287,7 +216,7 @@ Here's an application using icons ("Avoyd", https://www.avoyd.com):
|
|||||||
|
|
||||||
## Using Colorful Glyphs/Emojis
|
## Using Colorful Glyphs/Emojis
|
||||||
|
|
||||||
- Rendering of colored emojis is only supported by imgui_freetype with FreeType 2.10+.
|
- Rendering of colored emojis is supported by imgui_freetype with FreeType 2.10+.
|
||||||
- You will need to load fonts with the `ImGuiFreeTypeBuilderFlags_LoadColor` flag.
|
- You will need to load fonts with the `ImGuiFreeTypeBuilderFlags_LoadColor` flag.
|
||||||
- Emojis are frequently encoded in upper Unicode layers (character codes >0x10000) and will need dear imgui compiled with `IMGUI_USE_WCHAR32`.
|
- Emojis are frequently encoded in upper Unicode layers (character codes >0x10000) and will need dear imgui compiled with `IMGUI_USE_WCHAR32`.
|
||||||
- Not all types of color fonts are supported by FreeType at the moment.
|
- Not all types of color fonts are supported by FreeType at the moment.
|
||||||
@@ -384,6 +313,93 @@ ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_ba
|
|||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
## About Filenames
|
||||||
|
|
||||||
|
**Please note that many new C/C++ users have issues loading their files _because the filename they provide is wrong_ due to incorrect assumption of what is the current directory.**
|
||||||
|
|
||||||
|
Two things to watch for:
|
||||||
|
|
||||||
|
(1) In C/C++ and most programming languages if you want to use a backslash `\` within a string literal, you need to write it double backslash `\\`. At it happens, Windows uses backslashes as a path separator, so be mindful.
|
||||||
|
```cpp
|
||||||
|
io.Fonts->AddFontFromFileTTF("MyFiles\MyImage01.jpg", ...); // This is INCORRECT!!
|
||||||
|
io.Fonts->AddFontFromFileTTF("MyFiles\\MyImage01.jpg", ...); // This is CORRECT
|
||||||
|
```
|
||||||
|
In some situations, you may also use `/` path separator under Windows.
|
||||||
|
|
||||||
|
(2) Make sure your IDE/debugger settings starts your executable from the right working (current) directory. In Visual Studio you can change your working directory in project `Properties > General > Debugging > Working Directory`. People assume that their execution will start from the root folder of the project, where by default it often starts from the folder where object or executable files are stored.
|
||||||
|
```cpp
|
||||||
|
io.Fonts->AddFontFromFileTTF("MyImage01.jpg", ...); // Relative filename depends on your Working Directory when running your program!
|
||||||
|
io.Fonts->AddFontFromFileTTF("../MyImage01.jpg", ...); // Load from the parent folder of your Working Directory
|
||||||
|
```
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
## About UTF-8 Encoding
|
||||||
|
|
||||||
|
**For non-ASCII characters display, a common user issue is not passing correctly UTF-8 encoded strings.**
|
||||||
|
|
||||||
|
(1) We provide a function `ImGui::DebugTextEncoding(const char* text)` which you can call to verify the content of your UTF-8 strings.
|
||||||
|
This is a convenient way to confirm that your encoding is correct.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
ImGui::SeparatorText("CORRECT");
|
||||||
|
ImGui::DebugTextEncoding(u8"こんにちは");
|
||||||
|
|
||||||
|
ImGui::SeparatorText("INCORRECT");
|
||||||
|
ImGui::DebugTextEncoding("こんにちは");
|
||||||
|
```
|
||||||
|

|
||||||
|
|
||||||
|
You can also find this tool under `Metrics/Debuggers->Tools->UTF-8 Encoding viewer` if you want to paste from clipboard, but this won't validate the UTF-8 encoding done by your compiler.
|
||||||
|
|
||||||
|
(2) To encode in UTF-8:
|
||||||
|
|
||||||
|
There are also compiler-specific ways to enforce UTF-8 encoding by default:
|
||||||
|
|
||||||
|
- Visual Studio compiler: `/utf-8` command-line flag.
|
||||||
|
- Visual Studio compiler: `#pragma execution_character_set("utf-8")` inside your code.
|
||||||
|
- Since May 2023 we have changed the Visual Studio projects of all our examples to use `/utf-8` ([see commit](https://github.com/ocornut/imgui/commit/513af1efc9080857bbd10000d98f98f2a0c96803)).
|
||||||
|
|
||||||
|
Or, since C++11, you can use the `u8"my text"` syntax to encode literal strings as UTF-8. e.g.:
|
||||||
|
```cpp
|
||||||
|
ImGui::Text(u8"hello");
|
||||||
|
ImGui::Text(u8"こんにちは"); // this will always be encoded as UTF-8
|
||||||
|
ImGui::Text("こんにちは"); // the encoding of this is depending on compiler settings/flags and may be incorrect.
|
||||||
|
```
|
||||||
|
|
||||||
|
Since C++20, because the C++ committee hate its users, they decided to change the `u8""` syntax to not return `const char*` but a new type `const char_t*` which doesn't cast to `const char*`.
|
||||||
|
Because of type usage of `u8""` in C++20 is a little more tedious:
|
||||||
|
```cpp
|
||||||
|
ImGui::Text((const char*)u8"こんにちは");
|
||||||
|
```
|
||||||
|
We suggest using a macro in your codebase:
|
||||||
|
```cpp
|
||||||
|
#define U8(_S) (const char*)u8##_S
|
||||||
|
ImGui::Text(U8("こんにちは"));
|
||||||
|
```
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
## Debug Tools
|
||||||
|
|
||||||
|
#### Metrics/Debugger->Fonts
|
||||||
|
You can use the `Metrics/Debugger` window (available in `Demo>Tools`) to browse your fonts and understand what's going on if you have an issue. You can also reach it in `Demo->Tools->Style Editor->Fonts`. The same information are also available in the Style Editor under Fonts.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
#### UTF-8 Encoding Viewer**
|
||||||
|
You can use the `UTF-8 Encoding viewer` in `Metrics/Debugger` to verify the content of your UTF-8 strings. From C/C++ code, you can call `ImGui::DebugTextEncoding("my string");` function to verify that your UTF-8 encoding is correct.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
## Credits/Licenses For Fonts Included In Repository
|
## Credits/Licenses For Fonts Included In Repository
|
||||||
|
|
||||||
Some fonts files are available in the `misc/fonts/` folder:
|
Some fonts files are available in the `misc/fonts/` folder:
|
||||||
|
|||||||
@@ -215,25 +215,17 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create Descriptor Pool
|
// Create Descriptor Pool
|
||||||
|
// The example only requires a single combined image sampler descriptor for the font image and only uses one descriptor set (for that)
|
||||||
|
// If you wish to load e.g. additional textures you may need to alter pools sizes.
|
||||||
{
|
{
|
||||||
VkDescriptorPoolSize pool_sizes[] =
|
VkDescriptorPoolSize pool_sizes[] =
|
||||||
{
|
{
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLER, 1000 },
|
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1 },
|
||||||
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 }
|
|
||||||
};
|
};
|
||||||
VkDescriptorPoolCreateInfo pool_info = {};
|
VkDescriptorPoolCreateInfo pool_info = {};
|
||||||
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||||
pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
||||||
pool_info.maxSets = 1000 * IM_ARRAYSIZE(pool_sizes);
|
pool_info.maxSets = 1;
|
||||||
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
|
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
|
||||||
pool_info.pPoolSizes = pool_sizes;
|
pool_info.pPoolSizes = pool_sizes;
|
||||||
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
|
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
|
||||||
|
|||||||
@@ -203,25 +203,17 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create Descriptor Pool
|
// Create Descriptor Pool
|
||||||
|
// The example only requires a single combined image sampler descriptor for the font image and only uses one descriptor set (for that)
|
||||||
|
// If you wish to load e.g. additional textures you may need to alter pools sizes.
|
||||||
{
|
{
|
||||||
VkDescriptorPoolSize pool_sizes[] =
|
VkDescriptorPoolSize pool_sizes[] =
|
||||||
{
|
{
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLER, 1000 },
|
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1 },
|
||||||
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 },
|
|
||||||
{ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 }
|
|
||||||
};
|
};
|
||||||
VkDescriptorPoolCreateInfo pool_info = {};
|
VkDescriptorPoolCreateInfo pool_info = {};
|
||||||
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||||
pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
||||||
pool_info.maxSets = 1000 * IM_ARRAYSIZE(pool_sizes);
|
pool_info.maxSets = 1;
|
||||||
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
|
pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes);
|
||||||
pool_info.pPoolSizes = pool_sizes;
|
pool_info.pPoolSizes = pool_sizes;
|
||||||
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
|
err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool);
|
||||||
|
|||||||
23
imconfig.h
23
imconfig.h
@@ -1,5 +1,5 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// COMPILE-TIME OPTIONS FOR DEAR IMGUI
|
// DEAR IMGUI COMPILE-TIME OPTIONS
|
||||||
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
|
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
|
||||||
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
|
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
|
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
|
||||||
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
||||||
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
|
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
|
||||||
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
// Call IMGUI_CHECKVERSION() from your .cpp file to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
//#define IMGUI_API __declspec( dllexport )
|
//#define IMGUI_API __declspec( dllexport )
|
||||||
//#define IMGUI_API __declspec( dllimport )
|
//#define IMGUI_API __declspec( dllimport )
|
||||||
|
|
||||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
|
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names.
|
||||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.
|
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
|
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
|
||||||
//#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW)
|
//#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW)
|
||||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
|
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
|
||||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
|
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, IME).
|
||||||
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
||||||
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
||||||
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
|
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
|
||||||
@@ -62,9 +62,10 @@
|
|||||||
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
|
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
|
||||||
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
|
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
|
||||||
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
|
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
|
||||||
//#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if enabled
|
//#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if IMGUI_USE_STB_SPRINTF is defined.
|
||||||
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||||
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
||||||
|
//#define IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION // only disabled if IMGUI_USE_STB_SPRINTF is defined.
|
||||||
|
|
||||||
//---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
|
//---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
|
||||||
// Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h.
|
// Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h.
|
||||||
@@ -75,6 +76,12 @@
|
|||||||
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
|
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
|
||||||
//#define IMGUI_ENABLE_FREETYPE
|
//#define IMGUI_ENABLE_FREETYPE
|
||||||
|
|
||||||
|
//---- Use FreeType+lunasvg library to render OpenType SVG fonts (SVGinOT)
|
||||||
|
// Requires lunasvg headers to be available in the include path + program to be linked with the lunasvg library (not provided).
|
||||||
|
// Only works in combination with IMGUI_ENABLE_FREETYPE.
|
||||||
|
// (implementation is based on Freetype's rsvg-port.c which is licensed under CeCILL-C Free Software License Agreement)
|
||||||
|
//#define IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||||
|
|
||||||
//---- Use stb_truetype to build and rasterize the font atlas (default)
|
//---- Use stb_truetype to build and rasterize the font atlas (default)
|
||||||
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
|
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
|
||||||
//#define IMGUI_ENABLE_STB_TRUETYPE
|
//#define IMGUI_ENABLE_STB_TRUETYPE
|
||||||
@@ -105,7 +112,7 @@
|
|||||||
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
|
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
|
||||||
//#define ImDrawCallback MyImDrawCallback
|
//#define ImDrawCallback MyImDrawCallback
|
||||||
|
|
||||||
//---- Debug Tools: Macro to break in Debugger
|
//---- Debug Tools: Macro to break in Debugger (we provide a default implementation of this in the codebase)
|
||||||
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
|
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
|
||||||
//#define IM_DEBUG_BREAK IM_ASSERT(0)
|
//#define IM_DEBUG_BREAK IM_ASSERT(0)
|
||||||
//#define IM_DEBUG_BREAK __debugbreak()
|
//#define IM_DEBUG_BREAK __debugbreak()
|
||||||
@@ -113,10 +120,10 @@
|
|||||||
//---- Debug Tools: Enable slower asserts
|
//---- Debug Tools: Enable slower asserts
|
||||||
//#define IMGUI_DEBUG_PARANOID
|
//#define IMGUI_DEBUG_PARANOID
|
||||||
|
|
||||||
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
|
//---- Tip: You can add extra functions within the ImGui:: namespace from anywhere (e.g. your own sources/header files)
|
||||||
/*
|
/*
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
void MyFunction(const char* name, const MyMatrix44& v);
|
void MyFunction(const char* name, MyMatrix44* mtx);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|||||||
300
imgui.cpp
300
imgui.cpp
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.89.7
|
// dear imgui, v1.89.8
|
||||||
// (main code and documentation)
|
// (main code and documentation)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
// - Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started
|
// - Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||||
|
// - Tests & Automation https://github.com/ocornut/imgui_test_engine
|
||||||
|
|
||||||
// Getting Started?
|
// Getting Started?
|
||||||
// - Read https://github.com/ocornut/imgui/wiki/Getting-Started
|
// - Read https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||||
@@ -25,8 +26,9 @@
|
|||||||
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
|
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
|
||||||
// See LICENSE.txt for copyright and licensing details (standard MIT License).
|
// See LICENSE.txt for copyright and licensing details (standard MIT License).
|
||||||
// This library is free but needs your support to sustain development and maintenance.
|
// This library is free but needs your support to sustain development and maintenance.
|
||||||
// Businesses: you can support continued development via invoiced technical support, maintenance and sponsoring contracts. Please reach out to "contact AT dearimgui.com".
|
// Businesses: you can support continued development via B2B invoiced technical support, maintenance and sponsoring contracts.
|
||||||
// Individuals: you can support continued development via donations. See docs/README or web page.
|
// PLEASE reach out at contact AT dearimgui DOT com. See https://github.com/ocornut/imgui/wiki/Sponsors
|
||||||
|
// Businesses: you can also purchase licenses for the Dear ImGui Automation/Test Engine.
|
||||||
|
|
||||||
// It is recommended that you don't modify imgui.cpp! It will become difficult for you to update the library.
|
// It is recommended that you don't modify imgui.cpp! It will become difficult for you to update the library.
|
||||||
// Note that 'ImGui::' being a namespace, you can add functions into the namespace from your own source files, without
|
// Note that 'ImGui::' being a namespace, you can add functions into the namespace from your own source files, without
|
||||||
@@ -110,9 +112,10 @@ CODE
|
|||||||
- Portable, minimize dependencies, run on target (consoles, phones, etc.).
|
- Portable, minimize dependencies, run on target (consoles, phones, etc.).
|
||||||
- Efficient runtime and memory consumption.
|
- Efficient runtime and memory consumption.
|
||||||
|
|
||||||
Designed for developers and content-creators, not the typical end-user! Some of the current weaknesses includes:
|
Designed primarily for developers and content-creators, not the typical end-user!
|
||||||
|
Some of the current weaknesses (which we aim to address in the future) includes:
|
||||||
|
|
||||||
- Doesn't look fancy, doesn't animate.
|
- Doesn't look fancy.
|
||||||
- Limited layout features, intricate layouts are typically crafted in code.
|
- Limited layout features, intricate layouts are typically crafted in code.
|
||||||
|
|
||||||
|
|
||||||
@@ -191,9 +194,11 @@ CODE
|
|||||||
READ FIRST
|
READ FIRST
|
||||||
----------
|
----------
|
||||||
- Remember to check the wonderful Wiki (https://github.com/ocornut/imgui/wiki)
|
- Remember to check the wonderful Wiki (https://github.com/ocornut/imgui/wiki)
|
||||||
- Your code creates the UI, if your code doesn't run the UI is gone! The UI can be highly dynamic, there are no construction or
|
- Your code creates the UI every frame of your application loop, if your code doesn't run the UI is gone!
|
||||||
destruction steps, less superfluous data retention on your side, less state duplication, less state synchronization, fewer bugs.
|
The UI can be highly dynamic, there are no construction or destruction steps, less superfluous
|
||||||
|
data retention on your side, less state duplication, less state synchronization, fewer bugs.
|
||||||
- Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features.
|
- Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features.
|
||||||
|
Or browse https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html for interactive web version.
|
||||||
- The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build.
|
- The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build.
|
||||||
- Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori).
|
- Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori).
|
||||||
You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links in Wiki.
|
You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links in Wiki.
|
||||||
@@ -201,18 +206,38 @@ CODE
|
|||||||
For every application frame, your UI code will be called only once. This is in contrast to e.g. Unity's implementation of an IMGUI,
|
For every application frame, your UI code will be called only once. This is in contrast to e.g. Unity's implementation of an IMGUI,
|
||||||
where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches.
|
where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches.
|
||||||
- Our origin is on the top-left. In axis aligned bounding boxes, Min = top-left, Max = bottom-right.
|
- Our origin is on the top-left. In axis aligned bounding boxes, Min = top-left, Max = bottom-right.
|
||||||
- This codebase is also optimized to yield decent performances with typical "Debug" builds settings.
|
|
||||||
- Please make sure you have asserts enabled (IM_ASSERT redirects to assert() by default, but can be redirected).
|
- Please make sure you have asserts enabled (IM_ASSERT redirects to assert() by default, but can be redirected).
|
||||||
If you get an assert, read the messages and comments around the assert.
|
If you get an assert, read the messages and comments around the assert.
|
||||||
- C++: this is a very C-ish codebase: we don't rely on C++11, we don't include any C++ headers, and ImGui:: is a namespace.
|
- This codebase aims to be highly optimized:
|
||||||
- C++: ImVec2/ImVec4 do not expose math operators by default, because it is expected that you use your own math types.
|
- A typical idle frame should never call malloc/free.
|
||||||
See FAQ "How can I use my own math types instead of ImVec2/ImVec4?" for details about setting up imconfig.h for that.
|
- We rely on a maximum of constant-time or O(N) algorithms. Limiting searches/scans as much as possible.
|
||||||
However, imgui_internal.h can optionally export math operators for ImVec2/ImVec4, which we use in this codebase.
|
- We put particular energy in making sure performances are decent with typical "Debug" build settings as well.
|
||||||
- C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction (avoid using it in your code!).
|
Which mean we tend to avoid over-relying on "zero-cost abstraction" as they aren't zero-cost at all.
|
||||||
|
- This codebase aims to be both highly opinionated and highly flexible:
|
||||||
|
- This code works because of the things it choose to solve or not solve.
|
||||||
|
- C++: this is a pragmatic C-ish codebase: we don't use fancy C++ features, we don't include C++ headers,
|
||||||
|
and ImGui:: is a namespace. We rarely use member functions (and when we did, I am mostly regretting it now).
|
||||||
|
This is to increase compatibility, increase maintainability and facilitate use from other languages.
|
||||||
|
- C++: ImVec2/ImVec4 do not expose math operators by default, because it is expected that you use your own math types.
|
||||||
|
See FAQ "How can I use my own math types instead of ImVec2/ImVec4?" for details about setting up imconfig.h for that.
|
||||||
|
We can can optionally export math operators for ImVec2/ImVec4 using IMGUI_DEFINE_MATH_OPERATORS, which we use internally.
|
||||||
|
- C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction
|
||||||
|
(so don't use ImVector in your code or at our own risk!).
|
||||||
|
- Building: We don't use nor mandate a build system for the main library.
|
||||||
|
This is in an effort to ensure that it works in the real world aka with any esoteric build setup.
|
||||||
|
This is also because providing a build system for the main library would be of little-value.
|
||||||
|
The build problems are almost never coming from the main library but from specific backends.
|
||||||
|
|
||||||
|
|
||||||
HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI
|
HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
- Update submodule or copy/overwrite every file.
|
||||||
|
- About imconfig.h:
|
||||||
|
- You may modify your copy of imconfig.h, in this case don't overwrite it.
|
||||||
|
- or you may locally branch to modify imconfig.h and merge/rebase latest.
|
||||||
|
- or you may '#define IMGUI_USER_CONFIG "my_config_file.h"' globally from your build system to
|
||||||
|
specify a custom path for your imconfig.h file and instead not have to modify the default one.
|
||||||
|
|
||||||
- Overwrite all the sources files except for imconfig.h (if you have modified your copy of imconfig.h)
|
- Overwrite all the sources files except for imconfig.h (if you have modified your copy of imconfig.h)
|
||||||
- Or maintain your own branch where you have imconfig.h modified as a top-most commit which you can regularly rebase over "master".
|
- Or maintain your own branch where you have imconfig.h modified as a top-most commit which you can regularly rebase over "master".
|
||||||
- You can also use '#define IMGUI_USER_CONFIG "my_config_file.h" to redirect configuration to your own file.
|
- You can also use '#define IMGUI_USER_CONFIG "my_config_file.h" to redirect configuration to your own file.
|
||||||
@@ -221,11 +246,12 @@ CODE
|
|||||||
from the public API. If you have a problem with a missing function/symbols, search for its name in the code, there will
|
from the public API. If you have a problem with a missing function/symbols, search for its name in the code, there will
|
||||||
likely be a comment about it. Please report any issue to the GitHub page!
|
likely be a comment about it. Please report any issue to the GitHub page!
|
||||||
- To find out usage of old API, you can add '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in your configuration file.
|
- To find out usage of old API, you can add '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in your configuration file.
|
||||||
- Try to keep your copy of Dear ImGui reasonably up to date.
|
- Try to keep your copy of Dear ImGui reasonably up to date!
|
||||||
|
|
||||||
|
|
||||||
GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE
|
GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
|
- See https://github.com/ocornut/imgui/wiki/Getting-Started.
|
||||||
- Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library.
|
- Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library.
|
||||||
- In the majority of cases you should be able to use unmodified backends files available in the backends/ folder.
|
- In the majority of cases you should be able to use unmodified backends files available in the backends/ folder.
|
||||||
- Add the Dear ImGui source files + selected backend source files to your projects or using your preferred build system.
|
- Add the Dear ImGui source files + selected backend source files to your projects or using your preferred build system.
|
||||||
@@ -407,9 +433,11 @@ CODE
|
|||||||
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
||||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
||||||
|
|
||||||
|
- 2023/07/12 (1.89.8) - ImDrawData: CmdLists now owned, changed from ImDrawList** to ImVector<ImDrawList*>. Majority of users shouldn't be affected, but you cannot compare to NULL nor reassign manually anymore. Instead use AddDrawList(). (#6406, #4879, #1878)
|
||||||
- 2023/06/28 (1.89.7) - overlapping items: obsoleted 'SetItemAllowOverlap()' (called after item) in favor of calling 'SetNextItemAllowOverlap()' (called before item). 'SetItemAllowOverlap()' didn't and couldn't work reliably since 1.89 (2022-11-15).
|
- 2023/06/28 (1.89.7) - overlapping items: obsoleted 'SetItemAllowOverlap()' (called after item) in favor of calling 'SetNextItemAllowOverlap()' (called before item). 'SetItemAllowOverlap()' didn't and couldn't work reliably since 1.89 (2022-11-15).
|
||||||
- 2023/06/28 (1.89.7) - overlapping items: renamed 'ImGuiTreeNodeFlags_AllowItemOverlap' to 'ImGuiTreeNodeFlags_AllowOverlap', 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'. Kept redirecting enums (will obsolete).
|
- 2023/06/28 (1.89.7) - overlapping items: renamed 'ImGuiTreeNodeFlags_AllowItemOverlap' to 'ImGuiTreeNodeFlags_AllowOverlap', 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'. Kept redirecting enums (will obsolete).
|
||||||
- 2023/06/28 (1.89.7) - overlapping items: IsItemHovered() now by default return false when querying an item using AllowOverlap mode which is being overlapped. Use ImGuiHoveredFlags_AllowWhenOverlappedByItem to revert to old behavior.
|
- 2023/06/28 (1.89.7) - overlapping items: IsItemHovered() now by default return false when querying an item using AllowOverlap mode which is being overlapped. Use ImGuiHoveredFlags_AllowWhenOverlappedByItem to revert to old behavior.
|
||||||
|
- 2023/06/28 (1.89.7) - overlapping items: Selectable and TreeNode don't allow overlap when active so overlapping widgets won't appear as hovered. While this fixes a common small visual issue, it also means that calling IsItemHovered() after a non-reactive elements - e.g. Text() - overlapping an active one may fail if you don't use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem). (#6610)
|
||||||
- 2023/06/20 (1.89.7) - moved io.HoverDelayShort/io.HoverDelayNormal to style.HoverDelayShort/style.HoverDelayNormal. As the fields were added in 1.89 and expected to be left unchanged by most users, or only tweaked once during app initialization, we are exceptionally accepting the breakage.
|
- 2023/06/20 (1.89.7) - moved io.HoverDelayShort/io.HoverDelayNormal to style.HoverDelayShort/style.HoverDelayNormal. As the fields were added in 1.89 and expected to be left unchanged by most users, or only tweaked once during app initialization, we are exceptionally accepting the breakage.
|
||||||
- 2023/05/30 (1.89.6) - backends: renamed "imgui_impl_sdlrenderer.cpp" to "imgui_impl_sdlrenderer2.cpp" and "imgui_impl_sdlrenderer.h" to "imgui_impl_sdlrenderer2.h". This is in prevision for the future release of SDL3.
|
- 2023/05/30 (1.89.6) - backends: renamed "imgui_impl_sdlrenderer.cpp" to "imgui_impl_sdlrenderer2.cpp" and "imgui_impl_sdlrenderer.h" to "imgui_impl_sdlrenderer2.h". This is in prevision for the future release of SDL3.
|
||||||
- 2023/05/22 (1.89.6) - listbox: commented out obsolete/redirecting functions that were marked obsolete more than two years ago:
|
- 2023/05/22 (1.89.6) - listbox: commented out obsolete/redirecting functions that were marked obsolete more than two years ago:
|
||||||
@@ -813,11 +841,12 @@ CODE
|
|||||||
|
|
||||||
Q: Where is the documentation?
|
Q: Where is the documentation?
|
||||||
A: This library is poorly documented at the moment and expects the user to be acquainted with C/C++.
|
A: This library is poorly documented at the moment and expects the user to be acquainted with C/C++.
|
||||||
- Run the examples/ and explore them.
|
- Run the examples/ applications and explore them.
|
||||||
|
- Read Getting Started (https://github.com/ocornut/imgui/wiki/Getting-Started) guide.
|
||||||
- See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function.
|
- See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function.
|
||||||
- The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
- The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
||||||
- See documentation and comments at the top of imgui.cpp + effectively imgui.h.
|
- See documentation and comments at the top of imgui.cpp + effectively imgui.h.
|
||||||
- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the
|
- 20+ standalone example applications using e.g. OpenGL/DirectX are provided in the
|
||||||
examples/ folder to explain how to integrate Dear ImGui with your own engine/application.
|
examples/ folder to explain how to integrate Dear ImGui with your own engine/application.
|
||||||
- The Wiki (https://github.com/ocornut/imgui/wiki) has many resources and links.
|
- The Wiki (https://github.com/ocornut/imgui/wiki) has many resources and links.
|
||||||
- The Glossary (https://github.com/ocornut/imgui/wiki/Glossary) page also may be useful.
|
- The Glossary (https://github.com/ocornut/imgui/wiki/Glossary) page also may be useful.
|
||||||
@@ -833,14 +862,14 @@ CODE
|
|||||||
================
|
================
|
||||||
|
|
||||||
Q: How to get started?
|
Q: How to get started?
|
||||||
A: Read 'PROGRAMMER GUIDE' above. Read examples/README.txt.
|
A: Read https://github.com/ocornut/imgui/wiki/Getting-Started. Read 'PROGRAMMER GUIDE' above. Read examples/README.txt.
|
||||||
|
|
||||||
Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?
|
Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?
|
||||||
A: You should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags!
|
A: You should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags!
|
||||||
>> See https://www.dearimgui.com/faq for a fully detailed answer. You really want to read this.
|
>> See https://www.dearimgui.com/faq for a fully detailed answer. You really want to read this.
|
||||||
|
|
||||||
Q. How can I enable keyboard controls?
|
Q. How can I enable keyboard or gamepad controls?
|
||||||
Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)
|
Q: How can I use this on a machine without mouse, keyboard or screen? (input share, remote display)
|
||||||
Q: 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...
|
||||||
Q: 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...
|
||||||
Q: 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...
|
||||||
@@ -855,7 +884,7 @@ CODE
|
|||||||
- How can I have multiple widgets with the same label?
|
- How can I have multiple widgets with the same label?
|
||||||
- How can I have multiple windows with the same label?
|
- How can I have multiple windows with the same label?
|
||||||
Q: How can I display an image? What is ImTextureID, how does it work?
|
Q: How can I display an image? What is ImTextureID, how does it work?
|
||||||
Q: How can I use my own math types instead of ImVec2/ImVec4?
|
Q: How can I use my own math types instead of ImVec2?
|
||||||
Q: How can I interact with standard C++ types (such as std::string and std::vector)?
|
Q: How can I interact with standard C++ types (such as std::string and std::vector)?
|
||||||
Q: How can I display custom shapes? (using low-level ImDrawList API)
|
Q: How can I display custom shapes? (using low-level ImDrawList API)
|
||||||
>> See https://www.dearimgui.com/faq
|
>> See https://www.dearimgui.com/faq
|
||||||
@@ -885,10 +914,10 @@ CODE
|
|||||||
Q: How can I help?
|
Q: How can I help?
|
||||||
A: - Businesses: please reach out to "contact AT dearimgui.com" if you work in a place using Dear ImGui!
|
A: - Businesses: please reach out to "contact AT dearimgui.com" if you work in a place using Dear ImGui!
|
||||||
We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts.
|
We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts.
|
||||||
This is among the most useful thing you can do for Dear ImGui. With increased funding, we can hire more people working on this project.
|
This is among the most useful thing you can do for Dear ImGui. With increased funding, we sustain and grow work on this project.
|
||||||
- Individuals: you can support continued development via PayPal donations. See README.
|
Also see https://github.com/ocornut/imgui/wiki/Sponsors
|
||||||
- If you are experienced with Dear ImGui and C++, look at the GitHub issues, look at the Wiki, read docs/TODO.txt
|
- Businesses: you can also purchase licenses for the Dear ImGui Automation/Test Engine.
|
||||||
and see how you want to help and can help!
|
- If you are experienced with Dear ImGui and C++, look at the GitHub issues, look at the Wiki, and see how you want to help and can help!
|
||||||
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
|
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
|
||||||
You may post screenshot or links in the gallery threads. Visuals are ideal as they inspire other programmers.
|
You may post screenshot or links in the gallery threads. Visuals are ideal as they inspire other programmers.
|
||||||
But even without visuals, disclosing your use of dear imgui helps the library grow credibility, and help other teams and programmers with taking decisions.
|
But even without visuals, disclosing your use of dear imgui helps the library grow credibility, and help other teams and programmers with taking decisions.
|
||||||
@@ -914,11 +943,7 @@ CODE
|
|||||||
|
|
||||||
// System includes
|
// System includes
|
||||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
|
|
||||||
// [Windows] On non-Visual Studio compilers, we default to IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS unless explicitly enabled
|
// [Windows] On non-Visual Studio compilers, we default to IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS unless explicitly enabled
|
||||||
#if defined(_WIN32) && !defined(_MSC_VER) && !defined(IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
|
#if defined(_WIN32) && !defined(_MSC_VER) && !defined(IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
|
||||||
@@ -1012,7 +1037,6 @@ static const ImVec2 TOOLTIP_DEFAULT_OFFSET = ImVec2(16, 10); // Multi
|
|||||||
|
|
||||||
// Docking
|
// Docking
|
||||||
static const float DOCKING_TRANSPARENT_PAYLOAD_ALPHA = 0.50f; // For use with io.ConfigDockingTransparentPayload. Apply to Viewport _or_ WindowBg in host viewport.
|
static const float DOCKING_TRANSPARENT_PAYLOAD_ALPHA = 0.50f; // For use with io.ConfigDockingTransparentPayload. Apply to Viewport _or_ WindowBg in host viewport.
|
||||||
static const float DOCKING_SPLITTER_SIZE = 2.0f;
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// [SECTION] FORWARD DECLARATIONS
|
// [SECTION] FORWARD DECLARATIONS
|
||||||
@@ -1023,7 +1047,6 @@ static void FindHoveredWindow();
|
|||||||
static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags);
|
static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags);
|
||||||
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window);
|
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window);
|
||||||
|
|
||||||
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
|
||||||
static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window);
|
static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window);
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
@@ -1185,6 +1208,7 @@ ImGuiStyle::ImGuiStyle()
|
|||||||
SeparatorTextPadding = ImVec2(20.0f,3.f);// Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
|
SeparatorTextPadding = ImVec2(20.0f,3.f);// Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
|
||||||
DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
|
DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
|
||||||
DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
|
DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
|
||||||
|
DockingSeparatorSize = 2.0f; // Thickness of resizing border between docked windows
|
||||||
MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
|
MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
|
||||||
AntiAliasedLines = true; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU.
|
AntiAliasedLines = true; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU.
|
||||||
AntiAliasedLinesUseTex = true; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering).
|
AntiAliasedLinesUseTex = true; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering).
|
||||||
@@ -1228,6 +1252,7 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
|
|||||||
TabRounding = ImFloor(TabRounding * scale_factor);
|
TabRounding = ImFloor(TabRounding * scale_factor);
|
||||||
TabMinWidthForCloseButton = (TabMinWidthForCloseButton != FLT_MAX) ? ImFloor(TabMinWidthForCloseButton * scale_factor) : FLT_MAX;
|
TabMinWidthForCloseButton = (TabMinWidthForCloseButton != FLT_MAX) ? ImFloor(TabMinWidthForCloseButton * scale_factor) : FLT_MAX;
|
||||||
SeparatorTextPadding = ImFloor(SeparatorTextPadding * scale_factor);
|
SeparatorTextPadding = ImFloor(SeparatorTextPadding * scale_factor);
|
||||||
|
DockingSeparatorSize = ImFloor(DockingSeparatorSize * scale_factor);
|
||||||
DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor);
|
DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor);
|
||||||
DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor);
|
DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor);
|
||||||
MouseCursorScale = ImFloor(MouseCursorScale * scale_factor);
|
MouseCursorScale = ImFloor(MouseCursorScale * scale_factor);
|
||||||
@@ -1378,13 +1403,15 @@ void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Perhaps we could clear queued events as well?
|
// Clear all incoming events.
|
||||||
void ImGuiIO::ClearInputCharacters()
|
void ImGuiIO::ClearEventsQueue()
|
||||||
{
|
{
|
||||||
InputQueueCharacters.resize(0);
|
IM_ASSERT(Ctx != NULL);
|
||||||
|
ImGuiContext& g = *Ctx;
|
||||||
|
g.InputEventsQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Perhaps we could clear queued events as well?
|
// Clear current keyboard/mouse/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
|
||||||
void ImGuiIO::ClearInputKeys()
|
void ImGuiIO::ClearInputKeys()
|
||||||
{
|
{
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
@@ -1405,8 +1432,18 @@ void ImGuiIO::ClearInputKeys()
|
|||||||
MouseDownDuration[n] = MouseDownDurationPrev[n] = -1.0f;
|
MouseDownDuration[n] = MouseDownDurationPrev[n] = -1.0f;
|
||||||
}
|
}
|
||||||
MouseWheel = MouseWheelH = 0.0f;
|
MouseWheel = MouseWheelH = 0.0f;
|
||||||
|
InputQueueCharacters.resize(0); // Behavior of old ClearInputCharacters().
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Removed this as it is ambiguous/misleading and generally incorrect to use with the existence of a higher-level input queue.
|
||||||
|
// Current frame character buffer is now also cleared by ClearInputKeys().
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
void ImGuiIO::ClearInputCharacters()
|
||||||
|
{
|
||||||
|
InputQueueCharacters.resize(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static ImGuiInputEvent* FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventType type, int arg = -1)
|
static ImGuiInputEvent* FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventType type, int arg = -1)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
@@ -1880,13 +1917,15 @@ const char* ImStrSkipBlank(const char* str)
|
|||||||
// and setup the wrapper yourself. (FIXME-OPT: Some of our high-level operations such as ImGuiTextBuffer::appendfv() are
|
// and setup the wrapper yourself. (FIXME-OPT: Some of our high-level operations such as ImGuiTextBuffer::appendfv() are
|
||||||
// designed using two-passes worst case, which probably could be improved using the stbsp_vsprintfcb() function.)
|
// designed using two-passes worst case, which probably could be improved using the stbsp_vsprintfcb() function.)
|
||||||
#ifdef IMGUI_USE_STB_SPRINTF
|
#ifdef IMGUI_USE_STB_SPRINTF
|
||||||
|
#ifndef IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION
|
||||||
#define STB_SPRINTF_IMPLEMENTATION
|
#define STB_SPRINTF_IMPLEMENTATION
|
||||||
|
#endif
|
||||||
#ifdef IMGUI_STB_SPRINTF_FILENAME
|
#ifdef IMGUI_STB_SPRINTF_FILENAME
|
||||||
#include IMGUI_STB_SPRINTF_FILENAME
|
#include IMGUI_STB_SPRINTF_FILENAME
|
||||||
#else
|
#else
|
||||||
#include "stb_sprintf.h"
|
#include "stb_sprintf.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif // #ifdef IMGUI_USE_STB_SPRINTF
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(vsnprintf)
|
#if defined(_MSC_VER) && !defined(vsnprintf)
|
||||||
#define vsnprintf _vsnprintf
|
#define vsnprintf _vsnprintf
|
||||||
@@ -2964,7 +3003,7 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
|||||||
const bool is_nav_request = (g.NavMoveScoringItems && g.NavWindow && g.NavWindow->RootWindowForNav == window->RootWindowForNav);
|
const bool is_nav_request = (g.NavMoveScoringItems && g.NavWindow && g.NavWindow->RootWindowForNav == window->RootWindowForNav);
|
||||||
if (is_nav_request)
|
if (is_nav_request)
|
||||||
data->Ranges.push_back(ImGuiListClipperRange::FromPositions(g.NavScoringNoClipRect.Min.y, g.NavScoringNoClipRect.Max.y, 0, 0));
|
data->Ranges.push_back(ImGuiListClipperRange::FromPositions(g.NavScoringNoClipRect.Min.y, g.NavScoringNoClipRect.Max.y, 0, 0));
|
||||||
if (is_nav_request && (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && g.NavTabbingDir == -1)
|
if (is_nav_request && (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && g.NavTabbingDir == -1)
|
||||||
data->Ranges.push_back(ImGuiListClipperRange::FromIndices(clipper->ItemsCount - 1, clipper->ItemsCount));
|
data->Ranges.push_back(ImGuiListClipperRange::FromIndices(clipper->ItemsCount - 1, clipper->ItemsCount));
|
||||||
|
|
||||||
// Add focused/active item
|
// Add focused/active item
|
||||||
@@ -3151,6 +3190,7 @@ static const ImGuiDataVarInfo GStyleVarInfo[] =
|
|||||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextBorderSize) },// ImGuiStyleVar_SeparatorTextBorderSize
|
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextBorderSize) },// ImGuiStyleVar_SeparatorTextBorderSize
|
||||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextAlign) }, // ImGuiStyleVar_SeparatorTextAlign
|
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextAlign) }, // ImGuiStyleVar_SeparatorTextAlign
|
||||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextPadding) }, // ImGuiStyleVar_SeparatorTextPadding
|
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextPadding) }, // ImGuiStyleVar_SeparatorTextPadding
|
||||||
|
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, DockingSeparatorSize) }, // ImGuiStyleVar_DockingSeparatorSize
|
||||||
};
|
};
|
||||||
|
|
||||||
const ImGuiDataVarInfo* ImGui::GetStyleVarInfo(ImGuiStyleVar idx)
|
const ImGuiDataVarInfo* ImGui::GetStyleVarInfo(ImGuiStyleVar idx)
|
||||||
@@ -4137,7 +4177,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||||||
// Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered().
|
// Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered().
|
||||||
// (this does not rely on LastItemData it can be called from a ButtonBehavior() call not following an ItemAdd() call)
|
// (this does not rely on LastItemData it can be called from a ButtonBehavior() call not following an ItemAdd() call)
|
||||||
// FIXME-LEGACY: the 'ImGuiItemFlags item_flags' parameter was added on 2023-06-28.
|
// FIXME-LEGACY: the 'ImGuiItemFlags item_flags' parameter was added on 2023-06-28.
|
||||||
// If you used this ii your legacy/custom widgets code:
|
// If you used this in your legacy/custom widgets code:
|
||||||
// - Commonly: if your ItemHoverable() call comes after an ItemAdd() call: pass 'item_flags = g.LastItemData.InFlags'.
|
// - Commonly: if your ItemHoverable() call comes after an ItemAdd() call: pass 'item_flags = g.LastItemData.InFlags'.
|
||||||
// - Rare: otherwise you may pass 'item_flags = 0' (ImGuiItemFlags_None) unless you want to benefit from special behavior handled by ItemHoverable.
|
// - Rare: otherwise you may pass 'item_flags = 0' (ImGuiItemFlags_None) unless you want to benefit from special behavior handled by ItemHoverable.
|
||||||
bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flags)
|
bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flags)
|
||||||
@@ -4964,41 +5004,6 @@ static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, Im
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
|
|
||||||
{
|
|
||||||
if (draw_list->CmdBuffer.Size == 0)
|
|
||||||
return;
|
|
||||||
if (draw_list->CmdBuffer.Size == 1 && draw_list->CmdBuffer[0].ElemCount == 0 && draw_list->CmdBuffer[0].UserCallback == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
|
||||||
// May trigger for you if you are using PrimXXX functions incorrectly.
|
|
||||||
IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
|
|
||||||
IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
|
|
||||||
if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset))
|
|
||||||
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
|
|
||||||
|
|
||||||
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
|
|
||||||
// If this assert triggers because you are drawing lots of stuff manually:
|
|
||||||
// - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds.
|
|
||||||
// Be mindful that the ImDrawList API doesn't filter vertices. Use the Metrics/Debugger window to inspect draw list contents.
|
|
||||||
// - If you want large meshes with more than 64K vertices, you can either:
|
|
||||||
// (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'.
|
|
||||||
// Most example backends already support this from 1.71. Pre-1.71 backends won't.
|
|
||||||
// Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them.
|
|
||||||
// (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
|
|
||||||
// Most example backends already support this. For example, the OpenGL example code detect index size at compile-time:
|
|
||||||
// glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
|
|
||||||
// Your own engine or render API may use different parameters or function calls to specify index sizes.
|
|
||||||
// 2 and 4 bytes indices are generally supported by most graphics API.
|
|
||||||
// - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching
|
|
||||||
// the 64K limit to split your draw commands in multiple draw lists.
|
|
||||||
if (sizeof(ImDrawIdx) == 2)
|
|
||||||
IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
|
|
||||||
|
|
||||||
out_list->push_back(draw_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void AddWindowToDrawData(ImGuiWindow* window, int layer)
|
static void AddWindowToDrawData(ImGuiWindow* window, int layer)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@@ -5007,7 +5012,7 @@ static void AddWindowToDrawData(ImGuiWindow* window, int layer)
|
|||||||
g.IO.MetricsRenderWindows++;
|
g.IO.MetricsRenderWindows++;
|
||||||
if (window->Flags & ImGuiWindowFlags_DockNodeHost)
|
if (window->Flags & ImGuiWindowFlags_DockNodeHost)
|
||||||
window->DrawList->ChannelsMerge();
|
window->DrawList->ChannelsMerge();
|
||||||
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[layer], window->DrawList);
|
ImGui::AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[layer], window->DrawList);
|
||||||
for (int i = 0; i < window->DC.ChildWindows.Size; i++)
|
for (int i = 0; i < window->DC.ChildWindows.Size; i++)
|
||||||
{
|
{
|
||||||
ImGuiWindow* child = window->DC.ChildWindows[i];
|
ImGuiWindow* child = window->DC.ChildWindows[i];
|
||||||
@@ -5027,26 +5032,35 @@ static inline void AddRootWindowToDrawData(ImGuiWindow* window)
|
|||||||
AddWindowToDrawData(window, GetWindowDisplayLayer(window));
|
AddWindowToDrawData(window, GetWindowDisplayLayer(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawDataBuilder::FlattenIntoSingleLayer()
|
static void FlattenDrawDataIntoSingleLayer(ImDrawDataBuilder* builder)
|
||||||
{
|
{
|
||||||
int n = Layers[0].Size;
|
int n = builder->Layers[0]->Size;
|
||||||
int size = n;
|
int full_size = n;
|
||||||
for (int i = 1; i < IM_ARRAYSIZE(Layers); i++)
|
for (int i = 1; i < IM_ARRAYSIZE(builder->Layers); i++)
|
||||||
size += Layers[i].Size;
|
full_size += builder->Layers[i]->Size;
|
||||||
Layers[0].resize(size);
|
builder->Layers[0]->resize(full_size);
|
||||||
for (int layer_n = 1; layer_n < IM_ARRAYSIZE(Layers); layer_n++)
|
for (int layer_n = 1; layer_n < IM_ARRAYSIZE(builder->Layers); layer_n++)
|
||||||
{
|
{
|
||||||
ImVector<ImDrawList*>& layer = Layers[layer_n];
|
ImVector<ImDrawList*>* layer = builder->Layers[layer_n];
|
||||||
if (layer.empty())
|
if (layer->empty())
|
||||||
continue;
|
continue;
|
||||||
memcpy(&Layers[0][n], &layer[0], layer.Size * sizeof(ImDrawList*));
|
memcpy(builder->Layers[0]->Data + n, layer->Data, layer->Size * sizeof(ImDrawList*));
|
||||||
n += layer.Size;
|
n += layer->Size;
|
||||||
layer.resize(0);
|
layer->resize(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector<ImDrawList*>* draw_lists)
|
static void InitViewportDrawData(ImGuiViewportP* viewport)
|
||||||
{
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImDrawData* draw_data = &viewport->DrawDataP;
|
||||||
|
|
||||||
|
viewport->DrawData = draw_data; // Make publicly accessible
|
||||||
|
viewport->DrawDataBuilder.Layers[0] = &draw_data->CmdLists;
|
||||||
|
viewport->DrawDataBuilder.Layers[1] = &viewport->DrawDataBuilder.LayerData1;
|
||||||
|
viewport->DrawDataBuilder.Layers[0]->resize(0);
|
||||||
|
viewport->DrawDataBuilder.Layers[1]->resize(0);
|
||||||
|
|
||||||
// When minimized, we report draw_data->DisplaySize as zero to be consistent with non-viewport mode,
|
// When minimized, we report draw_data->DisplaySize as zero to be consistent with non-viewport mode,
|
||||||
// and to allow applications/backends to easily skip rendering.
|
// and to allow applications/backends to easily skip rendering.
|
||||||
// FIXME: Note that we however do NOT attempt to report "zero drawlist / vertices" into the ImDrawData structure.
|
// FIXME: Note that we however do NOT attempt to report "zero drawlist / vertices" into the ImDrawData structure.
|
||||||
@@ -5054,24 +5068,13 @@ static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector<ImDrawList*
|
|||||||
// it earlier in the pipeline, rather than pretend to hide the data at the end of the pipeline.
|
// it earlier in the pipeline, rather than pretend to hide the data at the end of the pipeline.
|
||||||
const bool is_minimized = (viewport->Flags & ImGuiViewportFlags_IsMinimized) != 0;
|
const bool is_minimized = (viewport->Flags & ImGuiViewportFlags_IsMinimized) != 0;
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
ImDrawData* draw_data = &viewport->DrawDataP;
|
|
||||||
viewport->DrawData = draw_data; // Make publicly accessible
|
|
||||||
draw_data->Valid = true;
|
draw_data->Valid = true;
|
||||||
draw_data->CmdLists = (draw_lists->Size > 0) ? draw_lists->Data : NULL;
|
draw_data->CmdListsCount = 0;
|
||||||
draw_data->CmdListsCount = draw_lists->Size;
|
|
||||||
draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0;
|
draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0;
|
||||||
draw_data->DisplayPos = viewport->Pos;
|
draw_data->DisplayPos = viewport->Pos;
|
||||||
draw_data->DisplaySize = is_minimized ? ImVec2(0.0f, 0.0f) : viewport->Size;
|
draw_data->DisplaySize = is_minimized ? ImVec2(0.0f, 0.0f) : viewport->Size;
|
||||||
draw_data->FramebufferScale = io.DisplayFramebufferScale; // FIXME-VIEWPORT: This may vary on a per-monitor/viewport basis?
|
draw_data->FramebufferScale = io.DisplayFramebufferScale; // FIXME-VIEWPORT: This may vary on a per-monitor/viewport basis?
|
||||||
draw_data->OwnerViewport = viewport;
|
draw_data->OwnerViewport = viewport;
|
||||||
for (int n = 0; n < draw_lists->Size; n++)
|
|
||||||
{
|
|
||||||
ImDrawList* draw_list = draw_lists->Data[n];
|
|
||||||
draw_list->_PopUnusedDrawCmd();
|
|
||||||
draw_data->TotalVtxCount += draw_list->VtxBuffer.Size;
|
|
||||||
draw_data->TotalIdxCount += draw_list->IdxBuffer.Size;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push a clipping rectangle for both ImGui logic (hit-testing etc.) and low-level ImDrawList rendering.
|
// Push a clipping rectangle for both ImGui logic (hit-testing etc.) and low-level ImDrawList rendering.
|
||||||
@@ -5118,14 +5121,14 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32
|
|||||||
ImDrawList* draw_list = window->RootWindowDockTree->DrawList;
|
ImDrawList* draw_list = window->RootWindowDockTree->DrawList;
|
||||||
if (draw_list->CmdBuffer.Size == 0)
|
if (draw_list->CmdBuffer.Size == 0)
|
||||||
draw_list->AddDrawCmd();
|
draw_list->AddDrawCmd();
|
||||||
draw_list->PushClipRect(viewport_rect.Min - ImVec2(1, 1), viewport_rect.Max + ImVec2(1, 1), false); // Ensure ImDrawCmd are not merged
|
draw_list->PushClipRect(viewport_rect.Min - ImVec2(1, 1), viewport_rect.Max + ImVec2(1, 1), false); // FIXME: Need to stricty ensure ImDrawCmd are not merged (ElemCount==6 checks below will verify that)
|
||||||
draw_list->AddRectFilled(viewport_rect.Min, viewport_rect.Max, col);
|
draw_list->AddRectFilled(viewport_rect.Min, viewport_rect.Max, col);
|
||||||
ImDrawCmd cmd = draw_list->CmdBuffer.back();
|
ImDrawCmd cmd = draw_list->CmdBuffer.back();
|
||||||
IM_ASSERT(cmd.ElemCount == 6);
|
IM_ASSERT(cmd.ElemCount == 6);
|
||||||
draw_list->CmdBuffer.pop_back();
|
draw_list->CmdBuffer.pop_back();
|
||||||
draw_list->CmdBuffer.push_front(cmd);
|
draw_list->CmdBuffer.push_front(cmd);
|
||||||
draw_list->PopClipRect();
|
|
||||||
draw_list->AddDrawCmd(); // We need to create a command as CmdBuffer.back().IdxOffset won't be correct if we append to same command.
|
draw_list->AddDrawCmd(); // We need to create a command as CmdBuffer.back().IdxOffset won't be correct if we append to same command.
|
||||||
|
draw_list->PopClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw over sibling docking nodes in a same docking tree
|
// Draw over sibling docking nodes in a same docking tree
|
||||||
@@ -5340,9 +5343,9 @@ void ImGui::Render()
|
|||||||
for (int n = 0; n != g.Viewports.Size; n++)
|
for (int n = 0; n != g.Viewports.Size; n++)
|
||||||
{
|
{
|
||||||
ImGuiViewportP* viewport = g.Viewports[n];
|
ImGuiViewportP* viewport = g.Viewports[n];
|
||||||
viewport->DrawDataBuilder.Clear();
|
InitViewportDrawData(viewport);
|
||||||
if (viewport->DrawLists[0] != NULL)
|
if (viewport->DrawLists[0] != NULL)
|
||||||
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
|
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add ImDrawList to render
|
// Add ImDrawList to render
|
||||||
@@ -5373,14 +5376,18 @@ void ImGui::Render()
|
|||||||
for (int n = 0; n < g.Viewports.Size; n++)
|
for (int n = 0; n < g.Viewports.Size; n++)
|
||||||
{
|
{
|
||||||
ImGuiViewportP* viewport = g.Viewports[n];
|
ImGuiViewportP* viewport = g.Viewports[n];
|
||||||
viewport->DrawDataBuilder.FlattenIntoSingleLayer();
|
FlattenDrawDataIntoSingleLayer(&viewport->DrawDataBuilder);
|
||||||
|
|
||||||
// Add foreground ImDrawList (for each active viewport)
|
// Add foreground ImDrawList (for each active viewport)
|
||||||
if (viewport->DrawLists[1] != NULL)
|
if (viewport->DrawLists[1] != NULL)
|
||||||
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
|
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
|
||||||
|
|
||||||
|
// We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch).
|
||||||
|
ImDrawData* draw_data = &viewport->DrawDataP;
|
||||||
|
IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount);
|
||||||
|
for (int draw_list_n = 0; draw_list_n < draw_data->CmdLists.Size; draw_list_n++)
|
||||||
|
draw_data->CmdLists[draw_list_n]->_PopUnusedDrawCmd();
|
||||||
|
|
||||||
SetupViewportDrawData(viewport, &viewport->DrawDataBuilder.Layers[0]);
|
|
||||||
ImDrawData* draw_data = viewport->DrawData;
|
|
||||||
g.IO.MetricsRenderVertices += draw_data->TotalVtxCount;
|
g.IO.MetricsRenderVertices += draw_data->TotalVtxCount;
|
||||||
g.IO.MetricsRenderIndices += draw_data->TotalIdxCount;
|
g.IO.MetricsRenderIndices += draw_data->TotalIdxCount;
|
||||||
}
|
}
|
||||||
@@ -6846,7 +6853,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// LOCK BORDER SIZE AND PADDING FOR THE FRAME (so that altering them doesn't cause inconsistencies)
|
// LOCK BORDER SIZE AND PADDING FOR THE FRAME (so that altering them doesn't cause inconsistencies)
|
||||||
// We read Style data after the call to UpdateSelectWindowViewport() which might be swapping the style.
|
// We read Style data after the call to UpdateSelectWindowViewport() which might be swapping the style.
|
||||||
|
|
||||||
if (flags & ImGuiWindowFlags_ChildWindow)
|
if (!window->DockIsActive && (flags & ImGuiWindowFlags_ChildWindow))
|
||||||
window->WindowBorderSize = style.ChildBorderSize;
|
window->WindowBorderSize = style.ChildBorderSize;
|
||||||
else
|
else
|
||||||
window->WindowBorderSize = ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize;
|
window->WindowBorderSize = ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize;
|
||||||
@@ -7209,6 +7216,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
|
|
||||||
// [LEGACY] Content Region
|
// [LEGACY] Content Region
|
||||||
// FIXME-OBSOLETE: window->ContentRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it.
|
// FIXME-OBSOLETE: window->ContentRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it.
|
||||||
|
// Unless explicit content size is specified by user, this currently represent the region leading to no scrolling.
|
||||||
// Used by:
|
// Used by:
|
||||||
// - Mouse wheel scrolling + many other things
|
// - Mouse wheel scrolling + many other things
|
||||||
window->ContentRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x + window->DecoOuterSizeX1;
|
window->ContentRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x + window->DecoOuterSizeX1;
|
||||||
@@ -8254,7 +8262,7 @@ void ImGui::FocusItem()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_FocusApi | ImGuiNavMoveFlags_NoSelect;
|
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_FocusApi | ImGuiNavMoveFlags_NoSelect;
|
||||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||||
SetNavWindow(window);
|
SetNavWindow(window);
|
||||||
NavMoveRequestSubmit(ImGuiDir_None, ImGuiDir_Up, move_flags, scroll_flags);
|
NavMoveRequestSubmit(ImGuiDir_None, ImGuiDir_Up, move_flags, scroll_flags);
|
||||||
@@ -8289,7 +8297,7 @@ void ImGui::SetKeyboardFocusHere(int offset)
|
|||||||
|
|
||||||
SetNavWindow(window);
|
SetNavWindow(window);
|
||||||
|
|
||||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_Activate | ImGuiNavMoveFlags_FocusApi;
|
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_Activate | ImGuiNavMoveFlags_FocusApi;
|
||||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||||
NavMoveRequestSubmit(ImGuiDir_None, offset < 0 ? ImGuiDir_Up : ImGuiDir_Down, move_flags, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
NavMoveRequestSubmit(ImGuiDir_None, offset < 0 ? ImGuiDir_Up : ImGuiDir_Down, move_flags, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
||||||
if (offset == -1)
|
if (offset == -1)
|
||||||
@@ -10420,10 +10428,8 @@ ImVec2 ImGui::GetContentRegionMax()
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
ImVec2 mx = window->ContentRegionRect.Max - window->Pos;
|
ImVec2 mx = (window->DC.CurrentColumns || g.CurrentTable) ? window->WorkRect.Max : window->ContentRegionRect.Max;
|
||||||
if (window->DC.CurrentColumns || g.CurrentTable)
|
return mx - window->Pos;
|
||||||
mx.x = window->WorkRect.Max.x - window->Pos.x;
|
|
||||||
return mx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
|
// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
|
||||||
@@ -10431,9 +10437,7 @@ ImVec2 ImGui::GetContentRegionMaxAbs()
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
ImVec2 mx = window->ContentRegionRect.Max;
|
ImVec2 mx = (window->DC.CurrentColumns || g.CurrentTable) ? window->WorkRect.Max : window->ContentRegionRect.Max;
|
||||||
if (window->DC.CurrentColumns || g.CurrentTable)
|
|
||||||
mx.x = window->WorkRect.Max.x;
|
|
||||||
return mx;
|
return mx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11720,7 +11724,7 @@ static void ImGui::NavProcessItem()
|
|||||||
// FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRect + scoring from a rect wrapped according to current wrapping policy)
|
// FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRect + scoring from a rect wrapped according to current wrapping policy)
|
||||||
if (g.NavMoveScoringItems && (item_flags & ImGuiItemFlags_Disabled) == 0)
|
if (g.NavMoveScoringItems && (item_flags & ImGuiItemFlags_Disabled) == 0)
|
||||||
{
|
{
|
||||||
const bool is_tabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) != 0;
|
const bool is_tabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) != 0;
|
||||||
if (is_tabbing)
|
if (is_tabbing)
|
||||||
{
|
{
|
||||||
NavProcessItemForTabbingRequest(id, item_flags, g.NavMoveFlags);
|
NavProcessItemForTabbingRequest(id, item_flags, g.NavMoveFlags);
|
||||||
@@ -11826,7 +11830,7 @@ void ImGui::NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavM
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(g.NavWindow != NULL);
|
IM_ASSERT(g.NavWindow != NULL);
|
||||||
|
|
||||||
if (move_flags & ImGuiNavMoveFlags_Tabbing)
|
if (move_flags & ImGuiNavMoveFlags_IsTabbing)
|
||||||
move_flags |= ImGuiNavMoveFlags_AllowCurrentNavId;
|
move_flags |= ImGuiNavMoveFlags_AllowCurrentNavId;
|
||||||
|
|
||||||
g.NavMoveSubmitted = g.NavMoveScoringItems = true;
|
g.NavMoveSubmitted = g.NavMoveScoringItems = true;
|
||||||
@@ -12378,7 +12382,7 @@ void ImGui::NavUpdateCreateTabbingRequest()
|
|||||||
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.NavDisableHighlight == true && g.ActiveId == 0) ? 0 : +1;
|
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.NavDisableHighlight == true && g.ActiveId == 0) ? 0 : +1;
|
||||||
else
|
else
|
||||||
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.ActiveId == 0) ? 0 : +1;
|
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.ActiveId == 0) ? 0 : +1;
|
||||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_Activate;
|
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_Activate;
|
||||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||||
ImGuiDir clip_dir = (g.NavTabbingDir < 0) ? ImGuiDir_Up : ImGuiDir_Down;
|
ImGuiDir clip_dir = (g.NavTabbingDir < 0) ? ImGuiDir_Up : ImGuiDir_Down;
|
||||||
NavMoveRequestSubmit(ImGuiDir_None, clip_dir, move_flags, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
NavMoveRequestSubmit(ImGuiDir_None, clip_dir, move_flags, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
||||||
@@ -12398,7 +12402,7 @@ void ImGui::NavMoveRequestApplyResult()
|
|||||||
ImGuiNavItemData* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : (g.NavMoveResultOther.ID != 0) ? &g.NavMoveResultOther : NULL;
|
ImGuiNavItemData* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : (g.NavMoveResultOther.ID != 0) ? &g.NavMoveResultOther : NULL;
|
||||||
|
|
||||||
// Tabbing forward wrap
|
// Tabbing forward wrap
|
||||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && result == NULL)
|
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && result == NULL)
|
||||||
if ((g.NavTabbingCounter == 1 || g.NavTabbingDir == 0) && g.NavTabbingResultFirst.ID)
|
if ((g.NavTabbingCounter == 1 || g.NavTabbingDir == 0) && g.NavTabbingResultFirst.ID)
|
||||||
result = &g.NavTabbingResultFirst;
|
result = &g.NavTabbingResultFirst;
|
||||||
|
|
||||||
@@ -12406,7 +12410,7 @@ void ImGui::NavMoveRequestApplyResult()
|
|||||||
const ImGuiAxis axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
const ImGuiAxis axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
{
|
{
|
||||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
if (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing)
|
||||||
g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavHighlight;
|
g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavHighlight;
|
||||||
if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavHighlight) == 0)
|
if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavHighlight) == 0)
|
||||||
NavRestoreHighlightAfterMove();
|
NavRestoreHighlightAfterMove();
|
||||||
@@ -12447,9 +12451,11 @@ void ImGui::NavMoveRequestApplyResult()
|
|||||||
}
|
}
|
||||||
if (g.ActiveId != result->ID)
|
if (g.ActiveId != result->ID)
|
||||||
ClearActiveID();
|
ClearActiveID();
|
||||||
if (g.NavId != result->ID && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSelect) == 0)
|
|
||||||
|
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
||||||
|
// PageUp/PageDown however sets always set NavJustMovedTo (vs Home/End which doesn't) mimicking Windows behavior.
|
||||||
|
if ((g.NavId != result->ID || (g.NavMoveFlags & ImGuiNavMoveFlags_IsPageMove)) && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSelect) == 0)
|
||||||
{
|
{
|
||||||
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
|
||||||
g.NavJustMovedToId = result->ID;
|
g.NavJustMovedToId = result->ID;
|
||||||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||||
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
||||||
@@ -12462,14 +12468,14 @@ void ImGui::NavMoveRequestApplyResult()
|
|||||||
|
|
||||||
// Restore last preferred position for current axis
|
// Restore last preferred position for current axis
|
||||||
// (storing in RootWindowForNav-> as the info is desirable at the beginning of a Move Request. In theory all storage should use RootWindowForNav..)
|
// (storing in RootWindowForNav-> as the info is desirable at the beginning of a Move Request. In theory all storage should use RootWindowForNav..)
|
||||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) == 0)
|
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) == 0)
|
||||||
{
|
{
|
||||||
preferred_scoring_pos_rel[axis] = result->RectRel.GetCenter()[axis];
|
preferred_scoring_pos_rel[axis] = result->RectRel.GetCenter()[axis];
|
||||||
g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer] = preferred_scoring_pos_rel;
|
g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer] = preferred_scoring_pos_rel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tabbing: Activates Inputable, otherwise only Focus
|
// Tabbing: Activates Inputable, otherwise only Focus
|
||||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && (result->InFlags & ImGuiItemFlags_Inputable) == 0)
|
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && (result->InFlags & ImGuiItemFlags_Inputable) == 0)
|
||||||
g.NavMoveFlags &= ~ImGuiNavMoveFlags_Activate;
|
g.NavMoveFlags &= ~ImGuiNavMoveFlags_Activate;
|
||||||
|
|
||||||
// Activate
|
// Activate
|
||||||
@@ -12478,7 +12484,7 @@ void ImGui::NavMoveRequestApplyResult()
|
|||||||
g.NavNextActivateId = result->ID;
|
g.NavNextActivateId = result->ID;
|
||||||
g.NavNextActivateFlags = ImGuiActivateFlags_None;
|
g.NavNextActivateFlags = ImGuiActivateFlags_None;
|
||||||
g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavHighlight;
|
g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavHighlight;
|
||||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
if (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing)
|
||||||
g.NavNextActivateFlags |= ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_TryToPreserveState;
|
g.NavNextActivateFlags |= ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_TryToPreserveState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12578,14 +12584,14 @@ static float ImGui::NavUpdatePageUpPageDown()
|
|||||||
nav_scoring_rect_offset_y = -page_offset_y;
|
nav_scoring_rect_offset_y = -page_offset_y;
|
||||||
g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item)
|
g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item)
|
||||||
g.NavMoveClipDir = ImGuiDir_Up;
|
g.NavMoveClipDir = ImGuiDir_Up;
|
||||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet | ImGuiNavMoveFlags_IsPageMove;
|
||||||
}
|
}
|
||||||
else if (IsKeyPressed(ImGuiKey_PageDown, true))
|
else if (IsKeyPressed(ImGuiKey_PageDown, true))
|
||||||
{
|
{
|
||||||
nav_scoring_rect_offset_y = +page_offset_y;
|
nav_scoring_rect_offset_y = +page_offset_y;
|
||||||
g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item)
|
g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item)
|
||||||
g.NavMoveClipDir = ImGuiDir_Down;
|
g.NavMoveClipDir = ImGuiDir_Down;
|
||||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet | ImGuiNavMoveFlags_IsPageMove;
|
||||||
}
|
}
|
||||||
else if (home_pressed)
|
else if (home_pressed)
|
||||||
{
|
{
|
||||||
@@ -15294,7 +15300,7 @@ void ImGui::DockContextEndFrame(ImGuiContext* ctx)
|
|||||||
if (node->LastFrameActive == g.FrameCount && node->IsVisible && node->HostWindow && node->IsLeafNode() && !node->IsBgDrawnThisFrame)
|
if (node->LastFrameActive == g.FrameCount && node->IsVisible && node->HostWindow && node->IsLeafNode() && !node->IsBgDrawnThisFrame)
|
||||||
{
|
{
|
||||||
ImRect bg_rect(node->Pos + ImVec2(0.0f, GetFrameHeight()), node->Pos + node->Size);
|
ImRect bg_rect(node->Pos + ImVec2(0.0f, GetFrameHeight()), node->Pos + node->Size);
|
||||||
ImDrawFlags bg_rounding_flags = CalcRoundingFlagsForRectInRect(bg_rect, node->HostWindow->Rect(), DOCKING_SPLITTER_SIZE);
|
ImDrawFlags bg_rounding_flags = CalcRoundingFlagsForRectInRect(bg_rect, node->HostWindow->Rect(), g.Style.DockingSeparatorSize);
|
||||||
node->HostWindow->DrawList->ChannelsSetCurrent(DOCKING_HOST_DRAW_CHANNEL_BG);
|
node->HostWindow->DrawList->ChannelsSetCurrent(DOCKING_HOST_DRAW_CHANNEL_BG);
|
||||||
node->HostWindow->DrawList->AddRectFilled(bg_rect.Min, bg_rect.Max, node->LastBgColor, node->HostWindow->WindowRounding, bg_rounding_flags);
|
node->HostWindow->DrawList->AddRectFilled(bg_rect.Min, bg_rect.Max, node->LastBgColor, node->HostWindow->WindowRounding, bg_rounding_flags);
|
||||||
}
|
}
|
||||||
@@ -16505,7 +16511,11 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
|
|||||||
if (node->IsRootNode() && host_window)
|
if (node->IsRootNode() && host_window)
|
||||||
{
|
{
|
||||||
DockNodeTreeUpdatePosSize(node, host_window->Pos, host_window->Size);
|
DockNodeTreeUpdatePosSize(node, host_window->Pos, host_window->Size);
|
||||||
|
PushStyleColor(ImGuiCol_Separator, g.Style.Colors[ImGuiCol_Border]);
|
||||||
|
PushStyleColor(ImGuiCol_SeparatorActive, g.Style.Colors[ImGuiCol_ResizeGripActive]);
|
||||||
|
PushStyleColor(ImGuiCol_SeparatorHovered, g.Style.Colors[ImGuiCol_ResizeGripHovered]);
|
||||||
DockNodeTreeUpdateSplitter(node);
|
DockNodeTreeUpdateSplitter(node);
|
||||||
|
PopStyleColor(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw empty node background (currently can only be the Central Node)
|
// Draw empty node background (currently can only be the Central Node)
|
||||||
@@ -16767,7 +16777,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
|
|||||||
if (is_focused)
|
if (is_focused)
|
||||||
node->LastFrameFocused = g.FrameCount;
|
node->LastFrameFocused = g.FrameCount;
|
||||||
ImU32 title_bar_col = GetColorU32(host_window->Collapsed ? ImGuiCol_TitleBgCollapsed : is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
|
ImU32 title_bar_col = GetColorU32(host_window->Collapsed ? ImGuiCol_TitleBgCollapsed : is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
|
||||||
ImDrawFlags rounding_flags = CalcRoundingFlagsForRectInRect(title_bar_rect, host_window->Rect(), DOCKING_SPLITTER_SIZE);
|
ImDrawFlags rounding_flags = CalcRoundingFlagsForRectInRect(title_bar_rect, host_window->Rect(), g.Style.DockingSeparatorSize);
|
||||||
host_window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, host_window->WindowRounding, rounding_flags);
|
host_window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, host_window->WindowRounding, rounding_flags);
|
||||||
|
|
||||||
// Docking/Collapse button
|
// Docking/Collapse button
|
||||||
@@ -17249,7 +17259,7 @@ static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDock
|
|||||||
overlay_rect.Min.y += GetFrameHeight();
|
overlay_rect.Min.y += GetFrameHeight();
|
||||||
if (data->SplitDir != ImGuiDir_None || data->IsCenterAvailable)
|
if (data->SplitDir != ImGuiDir_None || data->IsCenterAvailable)
|
||||||
for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++)
|
for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++)
|
||||||
overlay_draw_lists[overlay_n]->AddRectFilled(overlay_rect.Min, overlay_rect.Max, overlay_col_main, host_window->WindowRounding, CalcRoundingFlagsForRectInRect(overlay_rect, host_window->Rect(), DOCKING_SPLITTER_SIZE));
|
overlay_draw_lists[overlay_n]->AddRectFilled(overlay_rect.Min, overlay_rect.Max, overlay_col_main, host_window->WindowRounding, CalcRoundingFlagsForRectInRect(overlay_rect, host_window->Rect(), g.Style.DockingSeparatorSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display tab shape/label preview unless we are splitting node (it generally makes the situation harder to read)
|
// Display tab shape/label preview unless we are splitting node (it generally makes the situation harder to read)
|
||||||
@@ -17366,7 +17376,7 @@ void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImG
|
|||||||
parent_node->VisibleWindow = NULL;
|
parent_node->VisibleWindow = NULL;
|
||||||
parent_node->AuthorityForPos = parent_node->AuthorityForSize = ImGuiDataAuthority_DockNode;
|
parent_node->AuthorityForPos = parent_node->AuthorityForSize = ImGuiDataAuthority_DockNode;
|
||||||
|
|
||||||
float size_avail = (parent_node->Size[split_axis] - DOCKING_SPLITTER_SIZE);
|
float size_avail = (parent_node->Size[split_axis] - g.Style.DockingSeparatorSize);
|
||||||
size_avail = ImMax(size_avail, g.Style.WindowMinSize[split_axis] * 2.0f);
|
size_avail = ImMax(size_avail, g.Style.WindowMinSize[split_axis] * 2.0f);
|
||||||
IM_ASSERT(size_avail > 0.0f); // If you created a node manually with DockBuilderAddNode(), you need to also call DockBuilderSetNodeSize() before splitting.
|
IM_ASSERT(size_avail > 0.0f); // If you created a node manually with DockBuilderAddNode(), you need to also call DockBuilderSetNodeSize() before splitting.
|
||||||
child_0->SizeRef = child_1->SizeRef = parent_node->Size;
|
child_0->SizeRef = child_1->SizeRef = parent_node->Size;
|
||||||
@@ -17447,6 +17457,7 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si
|
|||||||
{
|
{
|
||||||
// During the regular dock node update we write to all nodes.
|
// During the regular dock node update we write to all nodes.
|
||||||
// 'only_write_to_single_node' is only set when turning a node visible mid-frame and we need its size right-away.
|
// 'only_write_to_single_node' is only set when turning a node visible mid-frame and we need its size right-away.
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
const bool write_to_node = only_write_to_single_node == NULL || only_write_to_single_node == node;
|
const bool write_to_node = only_write_to_single_node == NULL || only_write_to_single_node == node;
|
||||||
if (write_to_node)
|
if (write_to_node)
|
||||||
{
|
{
|
||||||
@@ -17469,8 +17480,7 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si
|
|||||||
|
|
||||||
if (child_0_is_or_will_be_visible && child_1_is_or_will_be_visible)
|
if (child_0_is_or_will_be_visible && child_1_is_or_will_be_visible)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
const float spacing = g.Style.DockingSeparatorSize;
|
||||||
const float spacing = DOCKING_SPLITTER_SIZE;
|
|
||||||
const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis;
|
const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis;
|
||||||
const float size_avail = ImMax(size[axis] - spacing, 0.0f);
|
const float size_avail = ImMax(size[axis] - spacing, 0.0f);
|
||||||
|
|
||||||
@@ -19423,7 +19433,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
// DrawLists
|
// DrawLists
|
||||||
int drawlist_count = 0;
|
int drawlist_count = 0;
|
||||||
for (int viewport_i = 0; viewport_i < g.Viewports.Size; viewport_i++)
|
for (int viewport_i = 0; viewport_i < g.Viewports.Size; viewport_i++)
|
||||||
drawlist_count += g.Viewports[viewport_i]->DrawDataBuilder.GetDrawListCount();
|
drawlist_count += g.Viewports[viewport_i]->DrawDataP.CmdLists.Size;
|
||||||
if (TreeNode("DrawLists", "DrawLists (%d)", drawlist_count))
|
if (TreeNode("DrawLists", "DrawLists (%d)", drawlist_count))
|
||||||
{
|
{
|
||||||
Checkbox("Show ImDrawCmd mesh when hovering", &cfg->ShowDrawCmdMesh);
|
Checkbox("Show ImDrawCmd mesh when hovering", &cfg->ShowDrawCmdMesh);
|
||||||
@@ -19432,14 +19442,13 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
{
|
{
|
||||||
ImGuiViewportP* viewport = g.Viewports[viewport_i];
|
ImGuiViewportP* viewport = g.Viewports[viewport_i];
|
||||||
bool viewport_has_drawlist = false;
|
bool viewport_has_drawlist = false;
|
||||||
for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++)
|
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataP.CmdLists.Size; draw_list_i++)
|
||||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++)
|
{
|
||||||
{
|
if (!viewport_has_drawlist)
|
||||||
if (!viewport_has_drawlist)
|
Text("Active DrawLists in Viewport #%d, ID: 0x%08X", viewport->Idx, viewport->ID);
|
||||||
Text("Active DrawLists in Viewport #%d, ID: 0x%08X", viewport->Idx, viewport->ID);
|
viewport_has_drawlist = true;
|
||||||
viewport_has_drawlist = true;
|
DebugNodeDrawList(NULL, viewport, viewport->DrawDataP.CmdLists[draw_list_i], "DrawList");
|
||||||
DebugNodeDrawList(NULL, viewport, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList");
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
@@ -20243,9 +20252,8 @@ void ImGui::DebugNodeViewport(ImGuiViewportP* viewport)
|
|||||||
(flags & ImGuiViewportFlags_NoAutoMerge) ? " NoAutoMerge" : "",
|
(flags & ImGuiViewportFlags_NoAutoMerge) ? " NoAutoMerge" : "",
|
||||||
(flags & ImGuiViewportFlags_TopMost) ? " TopMost" : "",
|
(flags & ImGuiViewportFlags_TopMost) ? " TopMost" : "",
|
||||||
(flags & ImGuiViewportFlags_CanHostOtherWindows) ? " CanHostOtherWindows" : "");
|
(flags & ImGuiViewportFlags_CanHostOtherWindows) ? " CanHostOtherWindows" : "");
|
||||||
for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++)
|
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataP.CmdLists.Size; draw_list_i++)
|
||||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++)
|
DebugNodeDrawList(NULL, viewport, viewport->DrawDataP.CmdLists[draw_list_i], "DrawList");
|
||||||
DebugNodeDrawList(NULL, viewport, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList");
|
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
68
imgui.h
68
imgui.h
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.89.7
|
// dear imgui, v1.89.8
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
// - Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started
|
// - Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||||
|
// - Tests & Automation https://github.com/ocornut/imgui_test_engine
|
||||||
|
|
||||||
// Getting Started?
|
// Getting Started?
|
||||||
// - Read https://github.com/ocornut/imgui/wiki/Getting-Started
|
// - Read https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||||
@@ -24,8 +25,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.89.7"
|
#define IMGUI_VERSION "1.89.8"
|
||||||
#define IMGUI_VERSION_NUM 18971
|
#define IMGUI_VERSION_NUM 18980
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
||||||
#define IMGUI_HAS_DOCK // Docking WIP branch
|
#define IMGUI_HAS_DOCK // Docking WIP branch
|
||||||
@@ -119,10 +120,13 @@ Index of this file:
|
|||||||
#endif
|
#endif
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wold-style-cast"
|
#if __has_warning("-Wunknown-warning-option")
|
||||||
#if __has_warning("-Wzero-as-null-pointer-constant")
|
#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx'
|
||||||
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
|
||||||
#endif
|
#endif
|
||||||
|
#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx'
|
||||||
|
#pragma clang diagnostic ignored "-Wold-style-cast"
|
||||||
|
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||||
|
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
@@ -819,9 +823,9 @@ namespace ImGui
|
|||||||
// - Drag from window menu button (upper-left button) to undock an entire node (all windows).
|
// - Drag from window menu button (upper-left button) to undock an entire node (all windows).
|
||||||
// - When io.ConfigDockingWithShift == true, you instead need to hold SHIFT to _enable_ docking/undocking.
|
// - When io.ConfigDockingWithShift == true, you instead need to hold SHIFT to _enable_ docking/undocking.
|
||||||
// About dockspaces:
|
// About dockspaces:
|
||||||
// - Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
|
|
||||||
// - Use DockSpaceOverViewport() to create an explicit dock node covering the screen or a specific viewport.
|
// - Use DockSpaceOverViewport() to create an explicit dock node covering the screen or a specific viewport.
|
||||||
// This is often used with ImGuiDockNodeFlags_PassthruCentralNode.
|
// This is often used with ImGuiDockNodeFlags_PassthruCentralNode to make it transparent.
|
||||||
|
// - Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
|
||||||
// - Important: Dockspaces need to be submitted _before_ any window they can host. Submit it early in your frame!
|
// - Important: Dockspaces need to be submitted _before_ any window they can host. Submit it early in your frame!
|
||||||
// - Important: Dockspaces need to be kept alive if hidden, otherwise windows docked into it will be undocked.
|
// - Important: Dockspaces need to be kept alive if hidden, otherwise windows docked into it will be undocked.
|
||||||
// e.g. if you have multiple tabs with a dockspace inside each tab: submit the non-visible dockspaces with ImGuiDockNodeFlags_KeepAliveOnly.
|
// e.g. if you have multiple tabs with a dockspace inside each tab: submit the non-visible dockspaces with ImGuiDockNodeFlags_KeepAliveOnly.
|
||||||
@@ -1358,16 +1362,16 @@ enum ImGuiHoveredFlags_
|
|||||||
// e.g. 'TooltipHoveredFlagsForMouse' defaults to 'ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort'.
|
// e.g. 'TooltipHoveredFlagsForMouse' defaults to 'ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort'.
|
||||||
// - for frequently actioned or hovered items providing a tooltip, you want may to use ImGuiHoveredFlags_ForTooltip (stationary + delay) so the tooltip doesn't show too often.
|
// - for frequently actioned or hovered items providing a tooltip, you want may to use ImGuiHoveredFlags_ForTooltip (stationary + delay) so the tooltip doesn't show too often.
|
||||||
// - for items which main purpose is to be hovered, or items with low affordance, or in less consistent apps, prefer no delay or shorter delay.
|
// - for items which main purpose is to be hovered, or items with low affordance, or in less consistent apps, prefer no delay or shorter delay.
|
||||||
ImGuiHoveredFlags_ForTooltip = 1 << 11, // Shortcut for standard flags when using IsItemHovered() + SetTooltip() sequence.
|
ImGuiHoveredFlags_ForTooltip = 1 << 12, // Shortcut for standard flags when using IsItemHovered() + SetTooltip() sequence.
|
||||||
|
|
||||||
// (Advanced) Mouse Hovering delays.
|
// (Advanced) Mouse Hovering delays.
|
||||||
// - generally you can use ImGuiHoveredFlags_ForTooltip to use application-standardized flags.
|
// - generally you can use ImGuiHoveredFlags_ForTooltip to use application-standardized flags.
|
||||||
// - use those if you need specific overrides.
|
// - use those if you need specific overrides.
|
||||||
ImGuiHoveredFlags_Stationary = 1 << 12, // Require mouse to be stationary for style.HoverStationaryDelay (~0.15 sec) _at least one time_. After this, can move on same item/window. Using the stationary test tends to reduces the need for a long delay.
|
ImGuiHoveredFlags_Stationary = 1 << 13, // Require mouse to be stationary for style.HoverStationaryDelay (~0.15 sec) _at least one time_. After this, can move on same item/window. Using the stationary test tends to reduces the need for a long delay.
|
||||||
ImGuiHoveredFlags_DelayNone = 1 << 13, // IsItemHovered() only: Return true immediately (default). As this is the default you generally ignore this.
|
ImGuiHoveredFlags_DelayNone = 1 << 14, // IsItemHovered() only: Return true immediately (default). As this is the default you generally ignore this.
|
||||||
ImGuiHoveredFlags_DelayShort = 1 << 14, // IsItemHovered() only: Return true after style.HoverDelayShort elapsed (~0.15 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item).
|
ImGuiHoveredFlags_DelayShort = 1 << 15, // IsItemHovered() only: Return true after style.HoverDelayShort elapsed (~0.15 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item).
|
||||||
ImGuiHoveredFlags_DelayNormal = 1 << 15, // IsItemHovered() only: Return true after style.HoverDelayNormal elapsed (~0.40 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item).
|
ImGuiHoveredFlags_DelayNormal = 1 << 16, // IsItemHovered() only: Return true after style.HoverDelayNormal elapsed (~0.40 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item).
|
||||||
ImGuiHoveredFlags_NoSharedDelay = 1 << 16, // IsItemHovered() only: Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays)
|
ImGuiHoveredFlags_NoSharedDelay = 1 << 17, // IsItemHovered() only: Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::DockSpace(), shared/inherited by child nodes.
|
// Flags for ImGui::DockSpace(), shared/inherited by child nodes.
|
||||||
@@ -1723,6 +1727,7 @@ enum ImGuiStyleVar_
|
|||||||
ImGuiStyleVar_SeparatorTextBorderSize,// float SeparatorTextBorderSize
|
ImGuiStyleVar_SeparatorTextBorderSize,// float SeparatorTextBorderSize
|
||||||
ImGuiStyleVar_SeparatorTextAlign, // ImVec2 SeparatorTextAlign
|
ImGuiStyleVar_SeparatorTextAlign, // ImVec2 SeparatorTextAlign
|
||||||
ImGuiStyleVar_SeparatorTextPadding,// ImVec2 SeparatorTextPadding
|
ImGuiStyleVar_SeparatorTextPadding,// ImVec2 SeparatorTextPadding
|
||||||
|
ImGuiStyleVar_DockingSeparatorSize,// float DockingSeparatorSize
|
||||||
ImGuiStyleVar_COUNT
|
ImGuiStyleVar_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1992,6 +1997,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; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
|
ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
|
||||||
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
|
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
|
||||||
|
float DockingSeparatorSize; // Thickness of resizing border between docked windows
|
||||||
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later.
|
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later.
|
||||||
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||||
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList).
|
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList).
|
||||||
@@ -2146,8 +2152,11 @@ struct ImGuiIO
|
|||||||
|
|
||||||
IMGUI_API void SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native_scancode, int native_legacy_index = -1); // [Optional] Specify index for legacy <1.87 IsKeyXXX() functions with native indices + specify native keycode, scancode.
|
IMGUI_API void SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native_scancode, int native_legacy_index = -1); // [Optional] Specify index for legacy <1.87 IsKeyXXX() functions with native indices + specify native keycode, scancode.
|
||||||
IMGUI_API void SetAppAcceptingEvents(bool accepting_events); // Set master flag for accepting key/mouse/text events (default to true). Useful if you have native dialog boxes that are interrupting your application loop/refresh, and you want to disable events being queued while your app is frozen.
|
IMGUI_API void SetAppAcceptingEvents(bool accepting_events); // Set master flag for accepting key/mouse/text events (default to true). Useful if you have native dialog boxes that are interrupting your application loop/refresh, and you want to disable events being queued while your app is frozen.
|
||||||
IMGUI_API void ClearInputCharacters(); // [Internal] Clear the text input buffer manually
|
IMGUI_API void ClearEventsQueue(); // Clear all incoming events.
|
||||||
IMGUI_API void ClearInputKeys(); // [Internal] Release all keys
|
IMGUI_API void ClearInputKeys(); // Clear current keyboard/mouse/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
IMGUI_API void ClearInputCharacters(); // [Obsolete] Clear the current frame text input buffer. Now included within ClearInputKeys().
|
||||||
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Output - Updated by NewFrame() or EndFrame()/Render()
|
// Output - Updated by NewFrame() or EndFrame()/Render()
|
||||||
@@ -2575,8 +2584,8 @@ struct ImColor
|
|||||||
constexpr ImColor() { }
|
constexpr ImColor() { }
|
||||||
constexpr ImColor(float r, float g, float b, float a = 1.0f) : Value(r, g, b, a) { }
|
constexpr ImColor(float r, float g, float b, float a = 1.0f) : Value(r, g, b, a) { }
|
||||||
constexpr ImColor(const ImVec4& col) : Value(col) {}
|
constexpr ImColor(const ImVec4& col) : Value(col) {}
|
||||||
ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f / 255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
|
constexpr ImColor(int r, int g, int b, int a = 255) : Value((float)r * (1.0f / 255.0f), (float)g * (1.0f / 255.0f), (float)b * (1.0f / 255.0f), (float)a* (1.0f / 255.0f)) {}
|
||||||
ImColor(ImU32 rgba) { float sc = 1.0f / 255.0f; Value.x = (float)((rgba >> IM_COL32_R_SHIFT) & 0xFF) * sc; Value.y = (float)((rgba >> IM_COL32_G_SHIFT) & 0xFF) * sc; Value.z = (float)((rgba >> IM_COL32_B_SHIFT) & 0xFF) * sc; Value.w = (float)((rgba >> IM_COL32_A_SHIFT) & 0xFF) * sc; }
|
constexpr ImColor(ImU32 rgba) : Value((float)((rgba >> IM_COL32_R_SHIFT) & 0xFF) * (1.0f / 255.0f), (float)((rgba >> IM_COL32_G_SHIFT) & 0xFF) * (1.0f / 255.0f), (float)((rgba >> IM_COL32_B_SHIFT) & 0xFF) * (1.0f / 255.0f), (float)((rgba >> IM_COL32_A_SHIFT) & 0xFF) * (1.0f / 255.0f)) {}
|
||||||
inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
||||||
inline operator ImVec4() const { return Value; }
|
inline operator ImVec4() const { return Value; }
|
||||||
|
|
||||||
@@ -2851,19 +2860,20 @@ struct ImDrawList
|
|||||||
// as this is one of the oldest structure exposed by the library! Basically, ImDrawList == CmdList)
|
// as this is one of the oldest structure exposed by the library! Basically, ImDrawList == CmdList)
|
||||||
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
|
int CmdListsCount; // Number of ImDrawList* to render
|
||||||
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
|
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
|
||||||
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
||||||
ImDrawList** CmdLists; // Array of ImDrawList* to render. The ImDrawList 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.
|
||||||
ImVec2 DisplayPos; // Top-left position of the viewport to render (== top-left of the orthogonal projection matrix to use) (== GetMainViewport()->Pos for the main viewport, == (0.0) in most single-viewport applications)
|
ImVec2 DisplayPos; // Top-left position of the viewport to render (== top-left of the orthogonal projection matrix to use) (== GetMainViewport()->Pos for the main viewport, == (0.0) in most single-viewport applications)
|
||||||
ImVec2 DisplaySize; // Size of the viewport to render (== GetMainViewport()->Size for the main viewport, == io.DisplaySize in most single-viewport applications)
|
ImVec2 DisplaySize; // Size of the viewport to render (== GetMainViewport()->Size for the main viewport, == io.DisplaySize in most single-viewport applications)
|
||||||
ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
|
ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
|
||||||
ImGuiViewport* OwnerViewport; // Viewport carrying the ImDrawData instance, might be of use to the renderer (generally not).
|
ImGuiViewport* OwnerViewport; // Viewport carrying the ImDrawData instance, might be of use to the renderer (generally not).
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
ImDrawData() { Clear(); }
|
ImDrawData() { Clear(); }
|
||||||
void Clear() { memset(this, 0, sizeof(*this)); } // The ImDrawList are owned by ImGuiContext!
|
IMGUI_API void Clear();
|
||||||
|
IMGUI_API void AddDrawList(ImDrawList* draw_list); // Helper to add an external draw list into an existing ImDrawData.
|
||||||
IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
||||||
IMGUI_API void ScaleClipRects(const ImVec2& fb_scale); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
IMGUI_API void ScaleClipRects(const ImVec2& fb_scale); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
||||||
};
|
};
|
||||||
@@ -2879,7 +2889,7 @@ struct ImFontConfig
|
|||||||
bool FontDataOwnedByAtlas; // true // TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself).
|
bool FontDataOwnedByAtlas; // true // TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself).
|
||||||
int FontNo; // 0 // Index of font within TTF/OTF file
|
int FontNo; // 0 // Index of font within TTF/OTF file
|
||||||
float SizePixels; // // Size in pixels for rasterizer (more or less maps to the resulting font height).
|
float SizePixels; // // Size in pixels for rasterizer (more or less maps to the resulting font height).
|
||||||
int OversampleH; // 3 // Rasterize at higher quality for sub-pixel positioning. Note the difference between 2 and 3 is minimal so you can reduce this to 2 to save memory. Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details.
|
int OversampleH; // 2 // Rasterize at higher quality for sub-pixel positioning. Note the difference between 2 and 3 is minimal. You can reduce this to 1 for large glyphs save memory. Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details.
|
||||||
int OversampleV; // 1 // Rasterize at higher quality for sub-pixel positioning. This is not really useful as we don't use sub-pixel positions on the Y axis.
|
int OversampleV; // 1 // Rasterize at higher quality for sub-pixel positioning. This is not really useful as we don't use sub-pixel positions on the Y axis.
|
||||||
bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1.
|
bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1.
|
||||||
ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
|
ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
|
||||||
|
|||||||
100
imgui_demo.cpp
100
imgui_demo.cpp
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.89.7
|
// dear imgui, v1.89.8
|
||||||
// (demo code)
|
// (demo code)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@@ -94,11 +94,7 @@ Index of this file:
|
|||||||
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
|
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
|
||||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||||
#include <stdlib.h> // NULL, malloc, free, atoi
|
#include <stdlib.h> // NULL, malloc, free, atoi
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
|
|
||||||
// Visual Studio warnings
|
// Visual Studio warnings
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -1321,16 +1317,16 @@ static void ShowDemoWindowWidgets()
|
|||||||
IMGUI_DEMO_MARKER("Widgets/Selectables/Basic");
|
IMGUI_DEMO_MARKER("Widgets/Selectables/Basic");
|
||||||
if (ImGui::TreeNode("Basic"))
|
if (ImGui::TreeNode("Basic"))
|
||||||
{
|
{
|
||||||
static bool selection[5] = { false, true, false, false, false };
|
static bool selection[5] = { false, true, false, false };
|
||||||
ImGui::Selectable("1. I am selectable", &selection[0]);
|
ImGui::Selectable("1. I am selectable", &selection[0]);
|
||||||
ImGui::Selectable("2. I am selectable", &selection[1]);
|
ImGui::Selectable("2. I am selectable", &selection[1]);
|
||||||
ImGui::Text("(I am not selectable)");
|
ImGui::Selectable("3. I am selectable", &selection[2]);
|
||||||
ImGui::Selectable("4. I am selectable", &selection[3]);
|
if (ImGui::Selectable("4. I am double clickable", selection[3], ImGuiSelectableFlags_AllowDoubleClick))
|
||||||
if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick))
|
|
||||||
if (ImGui::IsMouseDoubleClicked(0))
|
if (ImGui::IsMouseDoubleClicked(0))
|
||||||
selection[4] = !selection[4];
|
selection[3] = !selection[3];
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
IMGUI_DEMO_MARKER("Widgets/Selectables/Single Selection");
|
IMGUI_DEMO_MARKER("Widgets/Selectables/Single Selection");
|
||||||
if (ImGui::TreeNode("Selection State: Single Selection"))
|
if (ImGui::TreeNode("Selection State: Single Selection"))
|
||||||
{
|
{
|
||||||
@@ -1362,17 +1358,18 @@ static void ShowDemoWindowWidgets()
|
|||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
IMGUI_DEMO_MARKER("Widgets/Selectables/Rendering more text into the same line");
|
IMGUI_DEMO_MARKER("Widgets/Selectables/Rendering more items on the same line");
|
||||||
if (ImGui::TreeNode("Rendering more text into the same line"))
|
if (ImGui::TreeNode("Rendering more items on the same line"))
|
||||||
{
|
{
|
||||||
// Using the Selectable() override that takes "bool* p_selected" parameter,
|
// (1) Using SetNextItemAllowOverlap()
|
||||||
// this function toggle your bool value automatically.
|
// (2) Using the Selectable() override that takes "bool* p_selected" parameter, the bool value is toggled automatically.
|
||||||
static bool selected[3] = { false, false, false };
|
static bool selected[3] = { false, false, false };
|
||||||
ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
|
ImGui::SetNextItemAllowOverlap(); ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(); ImGui::SmallButton("Link 1");
|
||||||
ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 bytes");
|
ImGui::SetNextItemAllowOverlap(); ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(); ImGui::SmallButton("Link 2");
|
||||||
ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
|
ImGui::SetNextItemAllowOverlap(); ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(); ImGui::SmallButton("Link 3");
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
IMGUI_DEMO_MARKER("Widgets/Selectables/In columns");
|
IMGUI_DEMO_MARKER("Widgets/Selectables/In columns");
|
||||||
if (ImGui::TreeNode("In columns"))
|
if (ImGui::TreeNode("In columns"))
|
||||||
{
|
{
|
||||||
@@ -1408,6 +1405,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
IMGUI_DEMO_MARKER("Widgets/Selectables/Grid");
|
IMGUI_DEMO_MARKER("Widgets/Selectables/Grid");
|
||||||
if (ImGui::TreeNode("Grid"))
|
if (ImGui::TreeNode("Grid"))
|
||||||
{
|
{
|
||||||
@@ -1541,6 +1539,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IMGUI_DEMO_MARKER("Widgets/Text Input/Completion, History, Edit Callbacks");
|
||||||
if (ImGui::TreeNode("Completion, History, Edit Callbacks"))
|
if (ImGui::TreeNode("Completion, History, Edit Callbacks"))
|
||||||
{
|
{
|
||||||
struct Funcs
|
struct Funcs
|
||||||
@@ -1640,6 +1639,18 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IMGUI_DEMO_MARKER("Widgets/Text Input/Miscellaneous");
|
||||||
|
if (ImGui::TreeNode("Miscellaneous"))
|
||||||
|
{
|
||||||
|
static char buf1[16];
|
||||||
|
static ImGuiInputTextFlags flags = ImGuiInputTextFlags_EscapeClearsAll;
|
||||||
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_EscapeClearsAll", &flags, ImGuiInputTextFlags_EscapeClearsAll);
|
||||||
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", &flags, ImGuiInputTextFlags_ReadOnly);
|
||||||
|
ImGui::CheckboxFlags("ImGuiInputTextFlags_NoUndoRedo", &flags, ImGuiInputTextFlags_NoUndoRedo);
|
||||||
|
ImGui::InputText("Hello", buf1, IM_ARRAYSIZE(buf1), flags);
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2869,11 +2880,11 @@ static void ShowDemoWindowLayout()
|
|||||||
// Text
|
// Text
|
||||||
IMGUI_DEMO_MARKER("Layout/Basic Horizontal Layout/SameLine");
|
IMGUI_DEMO_MARKER("Layout/Basic Horizontal Layout/SameLine");
|
||||||
ImGui::Text("Two items: Hello"); ImGui::SameLine();
|
ImGui::Text("Two items: Hello"); ImGui::SameLine();
|
||||||
ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
|
ImGui::TextColored(ImVec4(1, 1, 0, 1), "Sailor");
|
||||||
|
|
||||||
// Adjust spacing
|
// Adjust spacing
|
||||||
ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20);
|
ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20);
|
||||||
ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
|
ImGui::TextColored(ImVec4(1, 1, 0, 1), "Sailor");
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
@@ -3471,6 +3482,36 @@ static void ShowDemoWindowLayout()
|
|||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IMGUI_DEMO_MARKER("Layout/Overlap Mode");
|
||||||
|
if (ImGui::TreeNode("Overlap Mode"))
|
||||||
|
{
|
||||||
|
static bool enable_allow_overlap = true;
|
||||||
|
|
||||||
|
HelpMarker(
|
||||||
|
"Hit-testing is by default performed in item submission order, which generally is perceived as 'back-to-front'.\n\n"
|
||||||
|
"By using SetNextItemAllowOverlap() you can notify that an item may be overlapped by another. Doing so alters the hovering logic: items using AllowOverlap mode requires an extra frame to accept hovered state.");
|
||||||
|
ImGui::Checkbox("Enable AllowOverlap", &enable_allow_overlap);
|
||||||
|
|
||||||
|
ImVec2 button1_pos = ImGui::GetCursorScreenPos();
|
||||||
|
ImVec2 button2_pos = ImVec2(button1_pos.x + 50.0f, button1_pos.y + 50.0f);
|
||||||
|
if (enable_allow_overlap)
|
||||||
|
ImGui::SetNextItemAllowOverlap();
|
||||||
|
ImGui::Button("Button 1", ImVec2(80, 80));
|
||||||
|
ImGui::SetCursorScreenPos(button2_pos);
|
||||||
|
ImGui::Button("Button 2", ImVec2(80, 80));
|
||||||
|
|
||||||
|
// This is typically used with width-spanning items.
|
||||||
|
// (note that Selectable() has a dedicated flag ImGuiSelectableFlags_AllowOverlap, which is a shortcut
|
||||||
|
// for using SetNextItemAllowOverlap(). For demo purpose we use SetNextItemAllowOverlap() here.)
|
||||||
|
if (enable_allow_overlap)
|
||||||
|
ImGui::SetNextItemAllowOverlap();
|
||||||
|
ImGui::Selectable("Some Selectable", false);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::SmallButton("++");
|
||||||
|
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowDemoWindowPopups()
|
static void ShowDemoWindowPopups()
|
||||||
@@ -6378,6 +6419,9 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
ImGui::SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f");
|
ImGui::SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f");
|
||||||
ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
|
ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
|
||||||
|
|
||||||
|
ImGui::SeparatorText("Docking");
|
||||||
|
ImGui::SliderFloat("DockingSplitterSize", &style.DockingSeparatorSize, 0.0f, 12.0f, "%.0f");
|
||||||
|
|
||||||
ImGui::SeparatorText("Tooltips");
|
ImGui::SeparatorText("Tooltips");
|
||||||
for (int n = 0; n < 2; n++)
|
for (int n = 0; n < 2; n++)
|
||||||
if (ImGui::TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse" : "HoverFlagsForTooltipNav"))
|
if (ImGui::TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse" : "HoverFlagsForTooltipNav"))
|
||||||
@@ -7950,18 +7994,20 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
// your own implicit "Debug##2" window after calling DockSpace() and leave it in the window stack for anyone to use.
|
// your own implicit "Debug##2" window after calling DockSpace() and leave it in the window stack for anyone to use.
|
||||||
void ShowExampleAppDockSpace(bool* p_open)
|
void ShowExampleAppDockSpace(bool* p_open)
|
||||||
{
|
{
|
||||||
// If you strip some features of, this demo is pretty much equivalent to calling DockSpaceOverViewport()!
|
// READ THIS !!!
|
||||||
// In most cases you should be able to just call DockSpaceOverViewport() and ignore all the code below!
|
// TL;DR; this demo is more complicated than what most users you would normally use.
|
||||||
// In this specific demo, we are not using DockSpaceOverViewport() because:
|
// If we remove all options we are showcasing, this demo would become:
|
||||||
// - we allow the host window to be floating/moveable instead of filling the viewport (when opt_fullscreen == false)
|
|
||||||
// - we allow the host window to have padding (when opt_padding == true)
|
|
||||||
// - we have a local menu bar in the host window (vs. you could use BeginMainMenuBar() + DockSpaceOverViewport() in your code!)
|
|
||||||
// TL;DR; this demo is more complicated than what you would normally use.
|
|
||||||
// If we removed all the options we are showcasing, this demo would become:
|
|
||||||
// void ShowExampleAppDockSpace()
|
// void ShowExampleAppDockSpace()
|
||||||
// {
|
// {
|
||||||
// ImGui::DockSpaceOverViewport(ImGui::GetMainViewport());
|
// ImGui::DockSpaceOverViewport(ImGui::GetMainViewport());
|
||||||
// }
|
// }
|
||||||
|
// In most cases you should be able to just call DockSpaceOverViewport() and ignore all the code below!
|
||||||
|
// In this specific demo, we are not using DockSpaceOverViewport() because:
|
||||||
|
// - (1) we allow the host window to be floating/moveable instead of filling the viewport (when opt_fullscreen == false)
|
||||||
|
// - (2) we allow the host window to have padding (when opt_padding == true)
|
||||||
|
// - (3) we expose many flags and need a way to have them visible.
|
||||||
|
// - (4) we have a local menu bar in the host window (vs. you could use BeginMainMenuBar() + DockSpaceOverViewport()
|
||||||
|
// in your code, but we don't here because we allow the window to be floating)
|
||||||
|
|
||||||
static bool opt_fullscreen = true;
|
static bool opt_fullscreen = true;
|
||||||
static bool opt_padding = false;
|
static bool opt_padding = false;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.89.7
|
// dear imgui, v1.89.8
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -63,6 +63,7 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier
|
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier
|
||||||
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
|
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
||||||
@@ -1814,6 +1815,63 @@ void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
|
|||||||
// [SECTION] ImDrawData
|
// [SECTION] ImDrawData
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void ImDrawData::Clear()
|
||||||
|
{
|
||||||
|
Valid = false;
|
||||||
|
CmdListsCount = TotalIdxCount = TotalVtxCount = 0;
|
||||||
|
CmdLists.resize(0); // The ImDrawList are NOT owned by ImDrawData but e.g. by ImGuiContext, so we don't clear them.
|
||||||
|
DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.0f, 0.0f);
|
||||||
|
OwnerViewport = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Important: 'out_list' is generally going to be draw_data->CmdLists, but may be another temporary list
|
||||||
|
// as long at it is expected that the result will be later merged into draw_data->CmdLists[].
|
||||||
|
void ImGui::AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
|
||||||
|
{
|
||||||
|
if (draw_list->CmdBuffer.Size == 0)
|
||||||
|
return;
|
||||||
|
if (draw_list->CmdBuffer.Size == 1 && draw_list->CmdBuffer[0].ElemCount == 0 && draw_list->CmdBuffer[0].UserCallback == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
||||||
|
// May trigger for you if you are using PrimXXX functions incorrectly.
|
||||||
|
IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
|
||||||
|
IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
|
||||||
|
if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset))
|
||||||
|
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
|
||||||
|
|
||||||
|
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
|
||||||
|
// If this assert triggers because you are drawing lots of stuff manually:
|
||||||
|
// - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds.
|
||||||
|
// Be mindful that the lower-level ImDrawList API doesn't filter vertices. Use the Metrics/Debugger window to inspect draw list contents.
|
||||||
|
// - If you want large meshes with more than 64K vertices, you can either:
|
||||||
|
// (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'.
|
||||||
|
// Most example backends already support this from 1.71. Pre-1.71 backends won't.
|
||||||
|
// Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them.
|
||||||
|
// (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
|
||||||
|
// Most example backends already support this. For example, the OpenGL example code detect index size at compile-time:
|
||||||
|
// glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
|
||||||
|
// Your own engine or render API may use different parameters or function calls to specify index sizes.
|
||||||
|
// 2 and 4 bytes indices are generally supported by most graphics API.
|
||||||
|
// - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching
|
||||||
|
// the 64K limit to split your draw commands in multiple draw lists.
|
||||||
|
if (sizeof(ImDrawIdx) == 2)
|
||||||
|
IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
|
||||||
|
|
||||||
|
// Add to output list + records state in ImDrawData
|
||||||
|
out_list->push_back(draw_list);
|
||||||
|
draw_data->CmdListsCount++;
|
||||||
|
draw_data->TotalVtxCount += draw_list->VtxBuffer.Size;
|
||||||
|
draw_data->TotalIdxCount += draw_list->IdxBuffer.Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImDrawData::AddDrawList(ImDrawList* draw_list)
|
||||||
|
{
|
||||||
|
IM_ASSERT(CmdLists.Size == CmdListsCount);
|
||||||
|
draw_list->_PopUnusedDrawCmd();
|
||||||
|
ImGui::AddDrawListToDrawDataEx(this, &CmdLists, draw_list);
|
||||||
|
}
|
||||||
|
|
||||||
// For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
// For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
||||||
void ImDrawData::DeIndexAllBuffers()
|
void ImDrawData::DeIndexAllBuffers()
|
||||||
{
|
{
|
||||||
@@ -1910,7 +1968,7 @@ ImFontConfig::ImFontConfig()
|
|||||||
{
|
{
|
||||||
memset(this, 0, sizeof(*this));
|
memset(this, 0, sizeof(*this));
|
||||||
FontDataOwnedByAtlas = true;
|
FontDataOwnedByAtlas = true;
|
||||||
OversampleH = 3; // FIXME: 2 may be a better default?
|
OversampleH = 2;
|
||||||
OversampleV = 1;
|
OversampleV = 1;
|
||||||
GlyphMaxAdvanceX = FLT_MAX;
|
GlyphMaxAdvanceX = FLT_MAX;
|
||||||
RasterizerMultiply = 1.0f;
|
RasterizerMultiply = 1.0f;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.89.7
|
// dear imgui, v1.89.8
|
||||||
// (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.
|
||||||
@@ -782,12 +782,10 @@ struct IMGUI_API ImDrawListSharedData
|
|||||||
|
|
||||||
struct ImDrawDataBuilder
|
struct ImDrawDataBuilder
|
||||||
{
|
{
|
||||||
ImVector<ImDrawList*> Layers[2]; // Global layers for: regular, tooltip
|
ImVector<ImDrawList*>* Layers[2]; // Pointers to global layers for: regular, tooltip. LayersP[0] is owned by DrawData.
|
||||||
|
ImVector<ImDrawList*> LayerData1;
|
||||||
|
|
||||||
void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); }
|
ImDrawDataBuilder() { memset(this, 0, sizeof(*this)); }
|
||||||
void ClearFreeMemory() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); }
|
|
||||||
int GetDrawListCount() const { int count = 0; for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) count += Layers[n].Size; return count; }
|
|
||||||
IMGUI_API void FlattenIntoSingleLayer();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -1514,10 +1512,11 @@ enum ImGuiNavMoveFlags_
|
|||||||
ImGuiNavMoveFlags_Forwarded = 1 << 7,
|
ImGuiNavMoveFlags_Forwarded = 1 << 7,
|
||||||
ImGuiNavMoveFlags_DebugNoResult = 1 << 8, // Dummy scoring for debug purpose, don't apply result
|
ImGuiNavMoveFlags_DebugNoResult = 1 << 8, // Dummy scoring for debug purpose, don't apply result
|
||||||
ImGuiNavMoveFlags_FocusApi = 1 << 9, // Requests from focus API can land/focus/activate items even if they are marked with _NoTabStop (see NavProcessItemForTabbingRequest() for details)
|
ImGuiNavMoveFlags_FocusApi = 1 << 9, // Requests from focus API can land/focus/activate items even if they are marked with _NoTabStop (see NavProcessItemForTabbingRequest() for details)
|
||||||
ImGuiNavMoveFlags_Tabbing = 1 << 10, // == Focus + Activate if item is Inputable + DontChangeNavHighlight
|
ImGuiNavMoveFlags_IsTabbing = 1 << 10, // == Focus + Activate if item is Inputable + DontChangeNavHighlight
|
||||||
ImGuiNavMoveFlags_Activate = 1 << 11, // Activate/select target item.
|
ImGuiNavMoveFlags_IsPageMove = 1 << 11, // Identify a PageDown/PageUp request.
|
||||||
ImGuiNavMoveFlags_NoSelect = 1 << 12, // Don't trigger selection by not setting g.NavJustMovedTo
|
ImGuiNavMoveFlags_Activate = 1 << 12, // Activate/select target item.
|
||||||
ImGuiNavMoveFlags_NoSetNavHighlight = 1 << 13, // Do not alter the visible state of keyboard vs mouse nav highlight
|
ImGuiNavMoveFlags_NoSelect = 1 << 13, // Don't trigger selection by not setting g.NavJustMovedTo
|
||||||
|
ImGuiNavMoveFlags_NoSetNavHighlight = 1 << 14, // Do not alter the visible state of keyboard vs mouse nav highlight
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiNavLayer
|
enum ImGuiNavLayer
|
||||||
@@ -1772,7 +1771,7 @@ struct ImGuiViewportP : public ImGuiViewport
|
|||||||
int DrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
|
int DrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
|
||||||
ImDrawList* DrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
|
ImDrawList* DrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
|
||||||
ImDrawData DrawDataP;
|
ImDrawData DrawDataP;
|
||||||
ImDrawDataBuilder DrawDataBuilder;
|
ImDrawDataBuilder DrawDataBuilder; // Temporary data while building final ImDrawData
|
||||||
ImVec2 LastPlatformPos;
|
ImVec2 LastPlatformPos;
|
||||||
ImVec2 LastPlatformSize;
|
ImVec2 LastPlatformSize;
|
||||||
ImVec2 LastRendererSize;
|
ImVec2 LastRendererSize;
|
||||||
@@ -2813,8 +2812,10 @@ struct ImGuiTableInstanceData
|
|||||||
float LastOuterHeight; // Outer height from last frame
|
float LastOuterHeight; // Outer height from last frame
|
||||||
float LastFirstRowHeight; // Height of first row from last frame (FIXME: this is used as "header height" and may be reworked)
|
float LastFirstRowHeight; // Height of first row from last frame (FIXME: this is used as "header height" and may be reworked)
|
||||||
float LastFrozenHeight; // Height of frozen section from last frame
|
float LastFrozenHeight; // Height of frozen section from last frame
|
||||||
|
int HoveredRowLast; // Index of row which was hovered last frame.
|
||||||
|
int HoveredRowNext; // Index of row hovered this frame, set after encountering it.
|
||||||
|
|
||||||
ImGuiTableInstanceData() { TableInstanceID = 0; LastOuterHeight = LastFirstRowHeight = LastFrozenHeight = 0.0f; }
|
ImGuiTableInstanceData() { TableInstanceID = 0; LastOuterHeight = LastFirstRowHeight = LastFrozenHeight = 0.0f; HoveredRowLast = HoveredRowNext = -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME-TABLE: more transient data could be stored in a stacked ImGuiTableTempData: e.g. SortSpecs, incoming RowData
|
// FIXME-TABLE: more transient data could be stored in a stacked ImGuiTableTempData: e.g. SortSpecs, incoming RowData
|
||||||
@@ -3038,6 +3039,7 @@ namespace ImGui
|
|||||||
IMGUI_API void SetCurrentFont(ImFont* font);
|
IMGUI_API void SetCurrentFont(ImFont* font);
|
||||||
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
|
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
|
||||||
inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { return GetForegroundDrawList(window->Viewport); }
|
inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { return GetForegroundDrawList(window->Viewport); }
|
||||||
|
IMGUI_API void AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
IMGUI_API void Initialize();
|
IMGUI_API void Initialize();
|
||||||
@@ -3355,7 +3357,8 @@ namespace ImGui
|
|||||||
IMGUI_API void TableOpenContextMenu(int column_n = -1);
|
IMGUI_API void TableOpenContextMenu(int column_n = -1);
|
||||||
IMGUI_API void TableSetColumnWidth(int column_n, float width);
|
IMGUI_API void TableSetColumnWidth(int column_n, float width);
|
||||||
IMGUI_API void TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs);
|
IMGUI_API void TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs);
|
||||||
IMGUI_API int TableGetHoveredColumn(); // May use (TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered) instead. Return hovered column. return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered.
|
IMGUI_API int TableGetHoveredColumn(); // May use (TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered) instead. Return hovered column. return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered.
|
||||||
|
IMGUI_API int TableGetHoveredRow(); // Retrieve *PREVIOUS FRAME* hovered row. This difference with TableGetHoveredColumn() is the reason why this is not public yet.
|
||||||
IMGUI_API float TableGetHeaderRowHeight();
|
IMGUI_API float TableGetHeaderRowHeight();
|
||||||
IMGUI_API void TablePushBackgroundChannel();
|
IMGUI_API void TablePushBackgroundChannel();
|
||||||
IMGUI_API void TablePopBackgroundChannel();
|
IMGUI_API void TablePopBackgroundChannel();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.89.7
|
// dear imgui, v1.89.8
|
||||||
// (tables and columns code)
|
// (tables and columns code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -198,11 +198,7 @@ Index of this file:
|
|||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
|
|
||||||
// System includes
|
// System includes
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
|
|
||||||
// Visual Studio warnings
|
// Visual Studio warnings
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -414,7 +410,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
table->HasScrollbarYPrev = table->HasScrollbarYCurr;
|
table->HasScrollbarYPrev = table->HasScrollbarYCurr;
|
||||||
table->HasScrollbarYCurr = false;
|
table->HasScrollbarYCurr = false;
|
||||||
}
|
}
|
||||||
table->HasScrollbarYCurr |= (table->InnerWindow->ScrollMax.y > 0.0f);
|
table->HasScrollbarYCurr |= table->InnerWindow->ScrollbarY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -971,6 +967,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
// clear ActiveId, which is equivalent to the change provided by _AllowWhenBLockedByActiveItem).
|
// clear ActiveId, which is equivalent to the change provided by _AllowWhenBLockedByActiveItem).
|
||||||
// - This allows columns to be marked as hovered when e.g. clicking a button inside the column, or using drag and drop.
|
// - This allows columns to be marked as hovered when e.g. clicking a button inside the column, or using drag and drop.
|
||||||
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
||||||
|
table_instance->HoveredRowLast = table_instance->HoveredRowNext;
|
||||||
|
table_instance->HoveredRowNext = -1;
|
||||||
table->HoveredColumnBody = -1;
|
table->HoveredColumnBody = -1;
|
||||||
table->HoveredColumnBorder = -1;
|
table->HoveredColumnBorder = -1;
|
||||||
const ImRect mouse_hit_rect(table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.Max.x, ImMax(table->OuterRect.Max.y, table->OuterRect.Min.y + table_instance->LastOuterHeight));
|
const ImRect mouse_hit_rect(table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.Max.x, ImMax(table->OuterRect.Max.y, table->OuterRect.Min.y + table_instance->LastOuterHeight));
|
||||||
@@ -1128,6 +1126,14 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
table->BorderX1 = table->InnerClipRect.Min.x;// +((table->Flags & ImGuiTableFlags_BordersOuter) ? 0.0f : -1.0f);
|
table->BorderX1 = table->InnerClipRect.Min.x;// +((table->Flags & ImGuiTableFlags_BordersOuter) ? 0.0f : -1.0f);
|
||||||
table->BorderX2 = table->InnerClipRect.Max.x;// +((table->Flags & ImGuiTableFlags_BordersOuter) ? 0.0f : +1.0f);
|
table->BorderX2 = table->InnerClipRect.Max.x;// +((table->Flags & ImGuiTableFlags_BordersOuter) ? 0.0f : +1.0f);
|
||||||
|
|
||||||
|
// Setup window's WorkRect.Max.y for GetContentRegionAvail(). Other values will be updated in each TableBeginCell() call.
|
||||||
|
float window_content_max_y;
|
||||||
|
if (table->Flags & ImGuiTableFlags_NoHostExtendY)
|
||||||
|
window_content_max_y = table->OuterRect.Max.y;
|
||||||
|
else
|
||||||
|
window_content_max_y = ImMax(table->InnerWindow->ContentRegionRect.Max.y, (table->Flags & ImGuiTableFlags_ScrollY) ? 0.0f : table->OuterRect.Max.y);
|
||||||
|
table->InnerWindow->WorkRect.Max.y = ImClamp(window_content_max_y - g.Style.CellPadding.y, table->InnerWindow->WorkRect.Min.y, table->InnerWindow->WorkRect.Max.y);
|
||||||
|
|
||||||
// [Part 9] Allocate draw channels and setup background cliprect
|
// [Part 9] Allocate draw channels and setup background cliprect
|
||||||
TableSetupDrawChannels(table);
|
TableSetupDrawChannels(table);
|
||||||
|
|
||||||
@@ -1547,6 +1553,7 @@ void ImGui::TableSetupScrollFreeze(int columns, int rows)
|
|||||||
// - TableGetCellBgRect() [Internal]
|
// - TableGetCellBgRect() [Internal]
|
||||||
// - TableGetColumnResizeID() [Internal]
|
// - TableGetColumnResizeID() [Internal]
|
||||||
// - TableGetHoveredColumn() [Internal]
|
// - TableGetHoveredColumn() [Internal]
|
||||||
|
// - TableGetHoveredRow() [Internal]
|
||||||
// - TableSetBgColor()
|
// - TableSetBgColor()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -1651,6 +1658,19 @@ int ImGui::TableGetHoveredColumn()
|
|||||||
return (int)table->HoveredColumnBody;
|
return (int)table->HoveredColumnBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return -1 when table is not hovered. Return maxrow+1 if in table but below last submitted row.
|
||||||
|
// *IMPORTANT* Unlike TableGetHoveredColumn(), this has a one frame latency in updating the value.
|
||||||
|
// This difference with is the reason why this is not public yet.
|
||||||
|
int ImGui::TableGetHoveredRow()
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
ImGuiTable* table = g.CurrentTable;
|
||||||
|
if (!table)
|
||||||
|
return -1;
|
||||||
|
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
||||||
|
return (int)table_instance->HoveredRowLast;
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui::TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n)
|
void ImGui::TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@@ -1802,6 +1822,10 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
|||||||
const bool is_visible = (bg_y2 >= table->InnerClipRect.Min.y && bg_y1 <= table->InnerClipRect.Max.y);
|
const bool is_visible = (bg_y2 >= table->InnerClipRect.Min.y && bg_y1 <= table->InnerClipRect.Max.y);
|
||||||
if (is_visible)
|
if (is_visible)
|
||||||
{
|
{
|
||||||
|
// Update data for TableGetHoveredRow()
|
||||||
|
if (table->HoveredColumnBody != -1 && g.IO.MousePos.y >= bg_y1 && g.IO.MousePos.y < bg_y2)
|
||||||
|
TableGetInstanceData(table, table->InstanceCurrent)->HoveredRowNext = table->CurrentRow;
|
||||||
|
|
||||||
// Decide of background color for the row
|
// Decide of background color for the row
|
||||||
ImU32 bg_col0 = 0;
|
ImU32 bg_col0 = 0;
|
||||||
ImU32 bg_col1 = 0;
|
ImU32 bg_col1 = 0;
|
||||||
@@ -1995,6 +2019,7 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
|
|||||||
window->DC.CurrLineTextBaseOffset = table->RowTextBaseline;
|
window->DC.CurrLineTextBaseOffset = table->RowTextBaseline;
|
||||||
window->DC.NavLayerCurrent = (ImGuiNavLayer)column->NavLayerCurrent;
|
window->DC.NavLayerCurrent = (ImGuiNavLayer)column->NavLayerCurrent;
|
||||||
|
|
||||||
|
// Note how WorkRect.Max.y is only set once during layout
|
||||||
window->WorkRect.Min.y = window->DC.CursorPos.y;
|
window->WorkRect.Min.y = window->DC.CursorPos.y;
|
||||||
window->WorkRect.Min.x = column->WorkMinX;
|
window->WorkRect.Min.x = column->WorkMinX;
|
||||||
window->WorkRect.Max.x = column->WorkMaxX;
|
window->WorkRect.Max.x = column->WorkMaxX;
|
||||||
@@ -3595,6 +3620,11 @@ void ImGui::DebugNodeTable(ImGuiTable* table)
|
|||||||
BulletText("CellPaddingX: %.1f, CellSpacingX: %.1f/%.1f, OuterPaddingX: %.1f", table->CellPaddingX, table->CellSpacingX1, table->CellSpacingX2, table->OuterPaddingX);
|
BulletText("CellPaddingX: %.1f, CellSpacingX: %.1f/%.1f, OuterPaddingX: %.1f", table->CellPaddingX, table->CellSpacingX1, table->CellSpacingX2, table->OuterPaddingX);
|
||||||
BulletText("HoveredColumnBody: %d, HoveredColumnBorder: %d", table->HoveredColumnBody, table->HoveredColumnBorder);
|
BulletText("HoveredColumnBody: %d, HoveredColumnBorder: %d", table->HoveredColumnBody, table->HoveredColumnBorder);
|
||||||
BulletText("ResizedColumn: %d, ReorderColumn: %d, HeldHeaderColumn: %d", table->ResizedColumn, table->ReorderColumn, table->HeldHeaderColumn);
|
BulletText("ResizedColumn: %d, ReorderColumn: %d, HeldHeaderColumn: %d", table->ResizedColumn, table->ReorderColumn, table->HeldHeaderColumn);
|
||||||
|
for (int n = 0; n < table->InstanceCurrent + 1; n++)
|
||||||
|
{
|
||||||
|
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, n);
|
||||||
|
BulletText("Instance %d: HoveredRow: %d, LastOuterHeight: %.2f", n, table_instance->HoveredRowLast, table_instance->LastOuterHeight);
|
||||||
|
}
|
||||||
//BulletText("BgDrawChannels: %d/%d", 0, table->BgDrawChannelUnfrozen);
|
//BulletText("BgDrawChannels: %d/%d", 0, table->BgDrawChannelUnfrozen);
|
||||||
float sum_weights = 0.0f;
|
float sum_weights = 0.0f;
|
||||||
for (int n = 0; n < table->ColumnsCount; n++)
|
for (int n = 0; n < table->ColumnsCount; n++)
|
||||||
@@ -3953,6 +3983,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiOldColumnFl
|
|||||||
window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f);
|
window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f);
|
||||||
window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
||||||
window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding;
|
window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding;
|
||||||
|
window->WorkRect.Max.y = window->ContentRegionRect.Max.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::NextColumn()
|
void ImGui::NextColumn()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.89.7
|
// dear imgui, v1.89.8
|
||||||
// (widgets code)
|
// (widgets code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -41,11 +41,7 @@ Index of this file:
|
|||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
|
|
||||||
// System includes
|
// System includes
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
|
||||||
#include <stddef.h> // intptr_t
|
|
||||||
#else
|
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Warnings
|
// Warnings
|
||||||
@@ -881,9 +877,9 @@ ImRect ImGui::GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis)
|
|||||||
const float scrollbar_size = window->ScrollbarSizes[axis ^ 1]; // (ScrollbarSizes.x = width of Y scrollbar; ScrollbarSizes.y = height of X scrollbar)
|
const float scrollbar_size = window->ScrollbarSizes[axis ^ 1]; // (ScrollbarSizes.x = width of Y scrollbar; ScrollbarSizes.y = height of X scrollbar)
|
||||||
IM_ASSERT(scrollbar_size > 0.0f);
|
IM_ASSERT(scrollbar_size > 0.0f);
|
||||||
if (axis == ImGuiAxis_X)
|
if (axis == ImGuiAxis_X)
|
||||||
return ImRect(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size), inner_rect.Max.x, outer_rect.Max.y);
|
return ImRect(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size), inner_rect.Max.x - border_size, outer_rect.Max.y - border_size);
|
||||||
else
|
else
|
||||||
return ImRect(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y, outer_rect.Max.x, inner_rect.Max.y);
|
return ImRect(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y, outer_rect.Max.x - border_size, inner_rect.Max.y - border_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::Scrollbar(ImGuiAxis axis)
|
void ImGui::Scrollbar(ImGuiAxis axis)
|
||||||
@@ -3822,6 +3818,7 @@ static bool STB_TEXTEDIT_INSERTCHARS(ImGuiInputTextState* obj, int pos, const Im
|
|||||||
#define STB_TEXTEDIT_K_SHIFT 0x400000
|
#define STB_TEXTEDIT_K_SHIFT 0x400000
|
||||||
|
|
||||||
#define STB_TEXTEDIT_IMPLEMENTATION
|
#define STB_TEXTEDIT_IMPLEMENTATION
|
||||||
|
#define STB_TEXTEDIT_memmove memmove
|
||||||
#include "imstb_textedit.h"
|
#include "imstb_textedit.h"
|
||||||
|
|
||||||
// stb_textedit internally allows for a single undo record to do addition and deletion, but somehow, calling
|
// stb_textedit internally allows for a single undo record to do addition and deletion, but somehow, calling
|
||||||
@@ -4499,7 +4496,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
{
|
{
|
||||||
if (flags & ImGuiInputTextFlags_EscapeClearsAll)
|
if (flags & ImGuiInputTextFlags_EscapeClearsAll)
|
||||||
{
|
{
|
||||||
if (state->CurLenA > 0)
|
if (buf[0] != 0)
|
||||||
{
|
{
|
||||||
revert_edit = true;
|
revert_edit = true;
|
||||||
}
|
}
|
||||||
@@ -4587,9 +4584,10 @@ 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);
|
||||||
apply_new_text = "";
|
apply_new_text = "";
|
||||||
apply_new_text_length = 0;
|
apply_new_text_length = 0;
|
||||||
value_changed |= (buf[0] != 0);
|
value_changed = true;
|
||||||
STB_TEXTEDIT_CHARTYPE empty_string;
|
STB_TEXTEDIT_CHARTYPE empty_string;
|
||||||
stb_textedit_replace(state, &state->Stb, &empty_string, 0);
|
stb_textedit_replace(state, &state->Stb, &empty_string, 0);
|
||||||
}
|
}
|
||||||
@@ -4618,9 +4616,12 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
ImTextStrToUtf8(state->TextA.Data, state->TextA.Size, state->TextW.Data, NULL);
|
ImTextStrToUtf8(state->TextA.Data, state->TextA.Size, state->TextW.Data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When using 'ImGuiInputTextFlags_EnterReturnsTrue' as a special case we reapply the live buffer back to the input buffer before clearing ActiveId, even though strictly speaking it wasn't modified on this frame.
|
// When using 'ImGuiInputTextFlags_EnterReturnsTrue' as a special case we reapply the live buffer back to the input buffer
|
||||||
|
// before clearing ActiveId, even though strictly speaking it wasn't modified on this frame.
|
||||||
// If we didn't do that, code like InputInt() with ImGuiInputTextFlags_EnterReturnsTrue would fail.
|
// If we didn't do that, code like InputInt() with ImGuiInputTextFlags_EnterReturnsTrue would fail.
|
||||||
// This also allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage (please note that if you use this property along ImGuiInputTextFlags_CallbackResize you can end up with your temporary string object unnecessarily allocating once a frame, either store your string data, either if you don't then don't use ImGuiInputTextFlags_CallbackResize).
|
// This also allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage
|
||||||
|
// (please note that if you use this property along ImGuiInputTextFlags_CallbackResize you can end up with your temporary string object
|
||||||
|
// unnecessarily allocating once a frame, either store your string data, either if you don't then don't use ImGuiInputTextFlags_CallbackResize).
|
||||||
const bool apply_edit_back_to_user_buffer = !revert_edit || (validated && (flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0);
|
const bool apply_edit_back_to_user_buffer = !revert_edit || (validated && (flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0);
|
||||||
if (apply_edit_back_to_user_buffer)
|
if (apply_edit_back_to_user_buffer)
|
||||||
{
|
{
|
||||||
@@ -4721,11 +4722,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
// Handle reapplying final data on deactivation (see InputTextDeactivateHook() for details)
|
// Handle reapplying final data on deactivation (see InputTextDeactivateHook() for details)
|
||||||
if (g.InputTextDeactivatedState.ID == id)
|
if (g.InputTextDeactivatedState.ID == id)
|
||||||
{
|
{
|
||||||
if (g.ActiveId != id && IsItemDeactivatedAfterEdit() && !is_readonly)
|
if (g.ActiveId != id && IsItemDeactivatedAfterEdit() && !is_readonly && strcmp(g.InputTextDeactivatedState.TextA.Data, buf) != 0)
|
||||||
{
|
{
|
||||||
apply_new_text = g.InputTextDeactivatedState.TextA.Data;
|
apply_new_text = g.InputTextDeactivatedState.TextA.Data;
|
||||||
apply_new_text_length = g.InputTextDeactivatedState.TextA.Size - 1;
|
apply_new_text_length = g.InputTextDeactivatedState.TextA.Size - 1;
|
||||||
value_changed |= (strcmp(g.InputTextDeactivatedState.TextA.Data, buf) != 0);
|
value_changed = true;
|
||||||
//IMGUI_DEBUG_LOG("InputText(): apply Deactivated data for 0x%08X: \"%.*s\".\n", id, apply_new_text_length, apply_new_text);
|
//IMGUI_DEBUG_LOG("InputText(): apply Deactivated data for 0x%08X: \"%.*s\".\n", id, apply_new_text_length, apply_new_text);
|
||||||
}
|
}
|
||||||
g.InputTextDeactivatedState.ID = 0;
|
g.InputTextDeactivatedState.ID = 0;
|
||||||
|
|||||||
@@ -10,6 +10,12 @@
|
|||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_stdlib.h"
|
#include "imgui_stdlib.h"
|
||||||
|
|
||||||
|
// Clang warnings with -Weverything
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
|
||||||
|
#endif
|
||||||
|
|
||||||
struct InputTextCallback_UserData
|
struct InputTextCallback_UserData
|
||||||
{
|
{
|
||||||
std::string* Str;
|
std::string* Str;
|
||||||
@@ -73,3 +79,7 @@ bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string*
|
|||||||
cb_user_data.ChainCallbackUserData = user_data;
|
cb_user_data.ChainCallbackUserData = user_data;
|
||||||
return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
|
return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ See https://gist.github.com/ocornut/b3a9ecf13502fd818799a452969649ad
|
|||||||
|
|
||||||
### Known issues
|
### Known issues
|
||||||
|
|
||||||
- Oversampling settins are ignored but also not so much necessary with the higher quality rendering.
|
- Oversampling settings are ignored but also not so much necessary with the higher quality rendering.
|
||||||
|
|
||||||
### Comparison
|
### Comparison
|
||||||
|
|
||||||
@@ -35,3 +35,10 @@ You can use the `ImGuiFreeTypeBuilderFlags_LoadColor` flag to load certain color
|
|||||||
["Using Colorful Glyphs/Emojis"](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#using-colorful-glyphsemojis) section of FONTS.md.
|
["Using Colorful Glyphs/Emojis"](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#using-colorful-glyphsemojis) section of FONTS.md.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
### Using OpenType SVG fonts (SVGinOT)
|
||||||
|
- *SVG in Open Type* is a standard by Adobe and Mozilla for color OpenType and Open Font Format fonts. It allows font creators to embed complete SVG files within a font enabling full color and even animations.
|
||||||
|
- Popular fonts such as [twemoji](https://github.com/13rac1/twemoji-color-font) and fonts made with [scfbuild](https://github.com/13rac1/scfbuild) is SVGinOT
|
||||||
|
- Requires: [lunasvg](https://github.com/sammycage/lunasvg) v2.3.2 and above
|
||||||
|
1. Add `#define IMGUI_ENABLE_FREETYPE_LUNASVG` in your `imconfig.h`.
|
||||||
|
2. Get latest lunasvg binaries or build yourself. Under Windows you may use vcpkg with: `vcpkg install lunasvg --triplet=x64-windows`.
|
||||||
|
|||||||
@@ -6,13 +6,13 @@
|
|||||||
|
|
||||||
// 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)
|
||||||
|
// 2023/08/01: added support for SVG fonts, enable by using '#define IMGUI_ENABLE_FREETYPE_LUNASVG' (#6591)
|
||||||
// 2023/01/04: fixed a packing issue which in some occurrences would prevent large amount of glyphs from being packed correctly.
|
// 2023/01/04: fixed a packing issue which in some occurrences would prevent large amount of glyphs from being packed correctly.
|
||||||
// 2021/08/23: fixed crash when FT_Render_Glyph() fails to render a glyph and returns NULL.
|
// 2021/08/23: fixed crash when FT_Render_Glyph() fails to render a glyph and returns NULL.
|
||||||
// 2021/03/05: added ImGuiFreeTypeBuilderFlags_Bitmap to load bitmap glyphs.
|
// 2021/03/05: added ImGuiFreeTypeBuilderFlags_Bitmap to load bitmap glyphs.
|
||||||
// 2021/03/02: set 'atlas->TexPixelsUseColors = true' to help some backends with deciding of a prefered texture format.
|
// 2021/03/02: set 'atlas->TexPixelsUseColors = true' to help some backends with deciding of a prefered texture format.
|
||||||
// 2021/01/28: added support for color-layered glyphs via ImGuiFreeTypeBuilderFlags_LoadColor (require Freetype 2.10+).
|
// 2021/01/28: added support for color-layered glyphs via ImGuiFreeTypeBuilderFlags_LoadColor (require Freetype 2.10+).
|
||||||
// 2021/01/26: simplified integration by using '#define IMGUI_ENABLE_FREETYPE'.
|
// 2021/01/26: simplified integration by using '#define IMGUI_ENABLE_FREETYPE'. renamed ImGuiFreeType::XXX flags to ImGuiFreeTypeBuilderFlags_XXX for consistency with other API. removed ImGuiFreeType::BuildFontAtlas().
|
||||||
// renamed ImGuiFreeType::XXX flags to ImGuiFreeTypeBuilderFlags_XXX for consistency with other API. removed ImGuiFreeType::BuildFontAtlas().
|
|
||||||
// 2020/06/04: fix for rare case where FT_Get_Char_Index() succeed but FT_Load_Glyph() fails.
|
// 2020/06/04: fix for rare case where FT_Get_Char_Index() succeed but FT_Load_Glyph() fails.
|
||||||
// 2019/02/09: added RasterizerFlags::Monochrome flag to disable font anti-aliasing (combine with ::MonoHinting for best results!)
|
// 2019/02/09: added RasterizerFlags::Monochrome flag to disable font anti-aliasing (combine with ::MonoHinting for best results!)
|
||||||
// 2019/01/15: added support for imgui allocators + added FreeType only override function SetAllocatorFunctions().
|
// 2019/01/15: added support for imgui allocators + added FreeType only override function SetAllocatorFunctions().
|
||||||
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
// FIXME: cfg.OversampleH, OversampleV are not supported (but perhaps not so necessary with this rasterizer).
|
// FIXME: cfg.OversampleH, OversampleV are not supported (but perhaps not so necessary with this rasterizer).
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui_freetype.h"
|
#include "imgui_freetype.h"
|
||||||
#include "imgui_internal.h" // ImMin,ImMax,ImFontAtlasBuild*,
|
#include "imgui_internal.h" // ImMin,ImMax,ImFontAtlasBuild*,
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -42,6 +44,15 @@
|
|||||||
#include FT_GLYPH_H // <freetype/ftglyph.h>
|
#include FT_GLYPH_H // <freetype/ftglyph.h>
|
||||||
#include FT_SYNTHESIS_H // <freetype/ftsynth.h>
|
#include FT_SYNTHESIS_H // <freetype/ftsynth.h>
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||||
|
#include FT_OTSVG_H // <freetype/otsvg.h>
|
||||||
|
#include FT_BBOX_H // <freetype/ftbbox.h>
|
||||||
|
#include <lunasvg.h>
|
||||||
|
#if !((FREETYPE_MAJOR >= 2) && (FREETYPE_MINOR >= 12))
|
||||||
|
#error IMGUI_ENABLE_FREETYPE_LUNASVG requires FreeType version >= 2.12
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (push)
|
#pragma warning (push)
|
||||||
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
|
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
|
||||||
@@ -68,6 +79,14 @@ static void* (*GImGuiFreeTypeAllocFunc)(size_t size, void* user_data) = ImGuiFre
|
|||||||
static void (*GImGuiFreeTypeFreeFunc)(void* ptr, void* user_data) = ImGuiFreeTypeDefaultFreeFunc;
|
static void (*GImGuiFreeTypeFreeFunc)(void* ptr, void* user_data) = ImGuiFreeTypeDefaultFreeFunc;
|
||||||
static void* GImGuiFreeTypeAllocatorUserData = nullptr;
|
static void* GImGuiFreeTypeAllocatorUserData = nullptr;
|
||||||
|
|
||||||
|
// Lunasvg support
|
||||||
|
#ifdef IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||||
|
static FT_Error ImGuiLunasvgPortInit(FT_Pointer* state);
|
||||||
|
static void ImGuiLunasvgPortFree(FT_Pointer* state);
|
||||||
|
static FT_Error ImGuiLunasvgPortRender(FT_GlyphSlot slot, FT_Pointer* _state);
|
||||||
|
static FT_Error ImGuiLunasvgPortPresetSlot(FT_GlyphSlot slot, FT_Bool cache, FT_Pointer* _state);
|
||||||
|
#endif
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Code
|
// Code
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@@ -242,7 +261,14 @@ namespace
|
|||||||
|
|
||||||
// Need an outline for this to work
|
// Need an outline for this to work
|
||||||
FT_GlyphSlot slot = Face->glyph;
|
FT_GlyphSlot slot = Face->glyph;
|
||||||
|
#ifdef IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||||
|
IM_ASSERT(slot->format == FT_GLYPH_FORMAT_OUTLINE || slot->format == FT_GLYPH_FORMAT_BITMAP || slot->format == FT_GLYPH_FORMAT_SVG);
|
||||||
|
#else
|
||||||
|
#if ((FREETYPE_MAJOR >= 2) && (FREETYPE_MINOR >= 12))
|
||||||
|
IM_ASSERT(slot->format != FT_GLYPH_FORMAT_SVG && "The font contains SVG glyphs, you'll need to enable IMGUI_ENABLE_FREETYPE_LUNASVG in imconfig.h and install required libraries in order to use this font");
|
||||||
|
#endif
|
||||||
IM_ASSERT(slot->format == FT_GLYPH_FORMAT_OUTLINE || slot->format == FT_GLYPH_FORMAT_BITMAP);
|
IM_ASSERT(slot->format == FT_GLYPH_FORMAT_OUTLINE || slot->format == FT_GLYPH_FORMAT_BITMAP);
|
||||||
|
#endif // IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||||
|
|
||||||
// Apply convenience transform (this is not picking from real "Bold"/"Italic" fonts! Merely applying FreeType helper transform. Oblique == Slanting)
|
// Apply convenience transform (this is not picking from real "Bold"/"Italic" fonts! Merely applying FreeType helper transform. Oblique == Slanting)
|
||||||
if (UserFlags & ImGuiFreeTypeBuilderFlags_Bold)
|
if (UserFlags & ImGuiFreeTypeBuilderFlags_Bold)
|
||||||
@@ -768,6 +794,14 @@ static bool ImFontAtlasBuildWithFreeType(ImFontAtlas* atlas)
|
|||||||
// If you don't call FT_Add_Default_Modules() the rest of code may work, but FreeType won't use our custom allocator.
|
// If you don't call FT_Add_Default_Modules() the rest of code may work, but FreeType won't use our custom allocator.
|
||||||
FT_Add_Default_Modules(ft_library);
|
FT_Add_Default_Modules(ft_library);
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||||
|
// Install svg hooks for FreeType
|
||||||
|
// https://freetype.org/freetype2/docs/reference/ft2-properties.html#svg-hooks
|
||||||
|
// https://freetype.org/freetype2/docs/reference/ft2-svg_fonts.html#svg_fonts
|
||||||
|
SVG_RendererHooks hooks = { ImGuiLunasvgPortInit, ImGuiLunasvgPortFree, ImGuiLunasvgPortRender, ImGuiLunasvgPortPresetSlot };
|
||||||
|
FT_Property_Set(ft_library, "ot-svg", "svg-hooks", &hooks);
|
||||||
|
#endif // IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||||
|
|
||||||
bool ret = ImFontAtlasBuildWithFreeTypeEx(ft_library, atlas, atlas->FontBuilderFlags);
|
bool ret = ImFontAtlasBuildWithFreeTypeEx(ft_library, atlas, atlas->FontBuilderFlags);
|
||||||
FT_Done_Library(ft_library);
|
FT_Done_Library(ft_library);
|
||||||
|
|
||||||
@@ -788,6 +822,115 @@ void ImGuiFreeType::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* u
|
|||||||
GImGuiFreeTypeAllocatorUserData = user_data;
|
GImGuiFreeTypeAllocatorUserData = user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||||
|
// For more details, see https://gitlab.freedesktop.org/freetype/freetype-demos/-/blob/master/src/rsvg-port.c
|
||||||
|
// The original code from the demo is licensed under CeCILL-C Free Software License Agreement (https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/LICENSE.TXT)
|
||||||
|
struct LunasvgPortState
|
||||||
|
{
|
||||||
|
FT_Error err = FT_Err_Ok;
|
||||||
|
lunasvg::Matrix matrix;
|
||||||
|
std::unique_ptr<lunasvg::Document> svg = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
static FT_Error ImGuiLunasvgPortInit(FT_Pointer* _state)
|
||||||
|
{
|
||||||
|
*_state = IM_NEW(LunasvgPortState)();
|
||||||
|
return FT_Err_Ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGuiLunasvgPortFree(FT_Pointer* _state)
|
||||||
|
{
|
||||||
|
IM_DELETE(*_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FT_Error ImGuiLunasvgPortRender(FT_GlyphSlot slot, FT_Pointer* _state)
|
||||||
|
{
|
||||||
|
LunasvgPortState* state = *(LunasvgPortState**)_state;
|
||||||
|
|
||||||
|
// If there was an error while loading the svg in ImGuiLunasvgPortPresetSlot(), the renderer hook still get called, so just returns the error.
|
||||||
|
if (state->err != FT_Err_Ok)
|
||||||
|
return state->err;
|
||||||
|
|
||||||
|
// rows is height, pitch (or stride) equals to width * sizeof(int32)
|
||||||
|
lunasvg::Bitmap bitmap((uint8_t*)slot->bitmap.buffer, slot->bitmap.width, slot->bitmap.rows, slot->bitmap.pitch);
|
||||||
|
state->svg->setMatrix(state->svg->matrix().identity()); // Reset the svg matrix to the default value
|
||||||
|
state->svg->render(bitmap, state->matrix); // state->matrix is already scaled and translated
|
||||||
|
state->err = FT_Err_Ok;
|
||||||
|
return state->err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FT_Error ImGuiLunasvgPortPresetSlot(FT_GlyphSlot slot, FT_Bool cache, FT_Pointer* _state)
|
||||||
|
{
|
||||||
|
FT_SVG_Document document = (FT_SVG_Document)slot->other;
|
||||||
|
LunasvgPortState* state = *(LunasvgPortState**)_state;
|
||||||
|
FT_Size_Metrics& metrics = document->metrics;
|
||||||
|
|
||||||
|
// This function is called twice, once in the FT_Load_Glyph() and another right before ImGuiLunasvgPortRender().
|
||||||
|
// If it's the latter, don't do anything because it's // already done in the former.
|
||||||
|
if (cache)
|
||||||
|
return state->err;
|
||||||
|
|
||||||
|
state->svg = lunasvg::Document::loadFromData((const char*)document->svg_document, document->svg_document_length);
|
||||||
|
if (state->svg == nullptr)
|
||||||
|
{
|
||||||
|
state->err = FT_Err_Invalid_SVG_Document;
|
||||||
|
return state->err;
|
||||||
|
}
|
||||||
|
|
||||||
|
lunasvg::Box box = state->svg->box();
|
||||||
|
double scale = std::min(metrics.x_ppem / box.w, metrics.y_ppem / box.h);
|
||||||
|
double xx = (double)document->transform.xx / (1 << 16);
|
||||||
|
double xy = -(double)document->transform.xy / (1 << 16);
|
||||||
|
double yx = -(double)document->transform.yx / (1 << 16);
|
||||||
|
double yy = (double)document->transform.yy / (1 << 16);
|
||||||
|
double x0 = (double)document->delta.x / 64 * box.w / metrics.x_ppem;
|
||||||
|
double y0 = -(double)document->delta.y / 64 * box.h / metrics.y_ppem;
|
||||||
|
|
||||||
|
// Scale and transform, we don't translate the svg yet
|
||||||
|
state->matrix.identity();
|
||||||
|
state->matrix.scale(scale, scale);
|
||||||
|
state->matrix.transform(xx, xy, yx, yy, x0, y0);
|
||||||
|
state->svg->setMatrix(state->matrix);
|
||||||
|
|
||||||
|
// Pre-translate the matrix for the rendering step
|
||||||
|
state->matrix.translate(-box.x, -box.y);
|
||||||
|
|
||||||
|
// Get the box again after the transformation
|
||||||
|
box = state->svg->box();
|
||||||
|
|
||||||
|
// Calculate the bitmap size
|
||||||
|
slot->bitmap_left = FT_Int(box.x);
|
||||||
|
slot->bitmap_top = FT_Int(-box.y);
|
||||||
|
slot->bitmap.rows = (unsigned int)(ImCeil((float)box.h));
|
||||||
|
slot->bitmap.width = (unsigned int)(ImCeil((float)box.w));
|
||||||
|
slot->bitmap.pitch = slot->bitmap.width * 4;
|
||||||
|
slot->bitmap.pixel_mode = FT_PIXEL_MODE_BGRA;
|
||||||
|
|
||||||
|
// Compute all the bearings and set them correctly. The outline is scaled already, we just need to use the bounding box.
|
||||||
|
double metrics_width = box.w;
|
||||||
|
double metrics_height = box.h;
|
||||||
|
double horiBearingX = box.x;
|
||||||
|
double horiBearingY = -box.y;
|
||||||
|
double vertBearingX = slot->metrics.horiBearingX / 64.0 - slot->metrics.horiAdvance / 64.0 / 2.0;
|
||||||
|
double vertBearingY = (slot->metrics.vertAdvance / 64.0 - slot->metrics.height / 64.0) / 2.0;
|
||||||
|
slot->metrics.width = FT_Pos(IM_ROUND(metrics_width * 64.0)); // Using IM_ROUND() assume width and height are positive
|
||||||
|
slot->metrics.height = FT_Pos(IM_ROUND(metrics_height * 64.0));
|
||||||
|
slot->metrics.horiBearingX = FT_Pos(horiBearingX * 64);
|
||||||
|
slot->metrics.horiBearingY = FT_Pos(horiBearingY * 64);
|
||||||
|
slot->metrics.vertBearingX = FT_Pos(vertBearingX * 64);
|
||||||
|
slot->metrics.vertBearingY = FT_Pos(vertBearingY * 64);
|
||||||
|
|
||||||
|
if (slot->metrics.vertAdvance == 0)
|
||||||
|
slot->metrics.vertAdvance = FT_Pos(metrics_height * 1.2 * 64.0);
|
||||||
|
|
||||||
|
state->err = FT_Err_Ok;
|
||||||
|
return state->err;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #ifdef IMGUI_ENABLE_FREETYPE_LUNASVG
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
@@ -795,3 +938,5 @@ void ImGuiFreeType::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* u
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "imgui.h" // IMGUI_API
|
#include "imgui.h" // IMGUI_API
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
struct ImFontAtlas;
|
struct ImFontAtlas;
|
||||||
@@ -48,3 +48,5 @@ namespace ImGuiFreeType
|
|||||||
static inline bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int flags = 0) { atlas->FontBuilderIO = GetBuilderForFreeType(); atlas->FontBuilderFlags = flags; return atlas->Build(); }
|
static inline bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int flags = 0) { atlas->FontBuilderIO = GetBuilderForFreeType(); atlas->FontBuilderFlags = flags; return atlas->Build(); }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
|||||||
Reference in New Issue
Block a user