Merge branch 'master' into docking

# Conflicts:
#	backends/imgui_impl_glfw.cpp
#	backends/imgui_impl_osx.mm
#	backends/imgui_impl_sdl2.cpp
#	backends/imgui_impl_sdl3.cpp
#	backends/imgui_impl_win32.cpp
#	imgui.h
This commit is contained in:
ocornut
2024-06-26 14:54:01 +02:00
9 changed files with 47 additions and 15 deletions

View File

@@ -26,6 +26,10 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface. // 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2024-06-26: Update for SDL3 api changes: SDL_StartTextInput()/SDL_StopTextInput()/SDL_SetTextInputRect() functions signatures.
// 2024-06-24: Update for SDL3 api changes: SDL_EVENT_KEY_DOWN/SDL_EVENT_KEY_UP contents.
// 2024-06-03; Update for SDL3 api changes: SDL_SYSTEM_CURSOR_ renames.
// 2024-05-15: Update for SDL3 api changes: SDLK_ renames.
// 2024-04-15: Inputs: Re-enable calling SDL_StartTextInput()/SDL_StopTextInput() as SDL3 no longer enables it by default and should play nicer with IME. // 2024-04-15: Inputs: Re-enable calling SDL_StartTextInput()/SDL_StopTextInput() as SDL3 no longer enables it by default and should play nicer with IME.
// 2024-02-13: Inputs: Fixed gamepad support. Handle gamepad disconnection. Added ImGui_ImplSDL3_SetGamepadMode(). // 2024-02-13: Inputs: Fixed gamepad support. Handle gamepad disconnection. Added ImGui_ImplSDL3_SetGamepadMode().
// 2023-11-13: Updated for recent SDL3 API changes. // 2023-11-13: Updated for recent SDL3 API changes.
@@ -82,6 +86,9 @@ struct ImGui_ImplSDL3_Data
bool UseVulkan; bool UseVulkan;
bool WantUpdateMonitors; bool WantUpdateMonitors;
// IME handling
SDL_Window* ImeWindow;
// Mouse handling // Mouse handling
Uint32 MouseWindowID; Uint32 MouseWindowID;
int MouseButtonsDown; int MouseButtonsDown;
@@ -130,6 +137,13 @@ static void ImGui_ImplSDL3_SetClipboardText(void*, const char* text)
static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlatformImeData* data) static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
{ {
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
SDL_Window* window = (SDL_Window*)viewport->PlatformHandle;
if ((data->WantVisible == false || bd->ImeWindow != window) && bd->ImeWindow != NULL)
{
SDL_StopTextInput(bd->ImeWindow);
bd->ImeWindow = nullptr;
}
if (data->WantVisible) if (data->WantVisible)
{ {
SDL_Rect r; SDL_Rect r;
@@ -137,12 +151,9 @@ static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlat
r.y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight); r.y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight);
r.w = 1; r.w = 1;
r.h = (int)data->InputLineHeight; r.h = (int)data->InputLineHeight;
SDL_SetTextInputRect(&r); SDL_SetTextInputRect(window, &r);
SDL_StartTextInput(); SDL_StartTextInput(window);
} bd->ImeWindow = window;
else
{
SDL_StopTextInput();
} }
} }
@@ -345,10 +356,10 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
case SDL_EVENT_KEY_DOWN: case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP: case SDL_EVENT_KEY_UP:
{ {
ImGui_ImplSDL3_UpdateKeyModifiers((SDL_Keymod)event->key.keysym.mod); ImGui_ImplSDL3_UpdateKeyModifiers((SDL_Keymod)event->key.mod);
ImGuiKey key = ImGui_ImplSDL3_KeycodeToImGuiKey(event->key.keysym.sym); ImGuiKey key = ImGui_ImplSDL3_KeycodeToImGuiKey(event->key.key);
io.AddKeyEvent(key, (event->type == SDL_EVENT_KEY_DOWN)); io.AddKeyEvent(key, (event->type == SDL_EVENT_KEY_DOWN));
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions. io.SetKeyEventNativeData(key, event->key.key, event->key.scancode, event->key.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
return true; return true;
} }
case SDL_EVENT_DISPLAY_ORIENTATION: case SDL_EVENT_DISPLAY_ORIENTATION:

View File

@@ -56,7 +56,7 @@
// Vulkan includes // Vulkan includes
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK #ifdef IMGUI_IMPL_VULKAN_USE_VOLK
#include <Volk/volk.h> #include <volk.h>
#else #else
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#endif #endif

View File

@@ -80,6 +80,13 @@ Other changes:
- Drag and Drop: Fixes an issue when elapsing payload would be based on last payload - Drag and Drop: Fixes an issue when elapsing payload would be based on last payload
frame instead of last drag source frame, which makes a difference if not resubmitting frame instead of last drag source frame, which makes a difference if not resubmitting
payload every frame. (#143) payload every frame. (#143)
- Debug Tools: Metrics/Debugger: Browsing a Storage perform hover lookup on identifier.
- Viewports: Backported 'void* ImGuiViewport::PlatformHandle' from docking branch for
use by backends.
- Backends: SDL3: Update for API removal of keysym field in SDL_KeyboardEvent. (#7728)
- Backends: SDL3: Update for SDL_StartTextInput()/SDL_StopTextInput() API changes. (#7735)
- Backends: Vulkan: Remove Volk/ from volk.h #include directives. (#7722, #6582, #4854)
[@martin-ejdestig]
- Examples: GLFW+Vulkan, SDL+Vulkan: handle swap chain resize even without Vulkan - Examples: GLFW+Vulkan, SDL+Vulkan: handle swap chain resize even without Vulkan
returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671) returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671)
[@AndreiNego, @ocornut] [@AndreiNego, @ocornut]

View File

@@ -25,7 +25,7 @@
// Volk headers // Volk headers
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK #ifdef IMGUI_IMPL_VULKAN_USE_VOLK
#define VOLK_IMPLEMENTATION #define VOLK_IMPLEMENTATION
#include <Volk/volk.h> #include <volk.h>
#endif #endif
// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers. // [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.

View File

@@ -24,7 +24,7 @@
// Volk headers // Volk headers
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK #ifdef IMGUI_IMPL_VULKAN_USE_VOLK
#define VOLK_IMPLEMENTATION #define VOLK_IMPLEMENTATION
#include <Volk/volk.h> #include <volk.h>
#endif #endif
//#define APP_USE_UNLIMITED_FRAME_RATE //#define APP_USE_UNLIMITED_FRAME_RATE

View File

@@ -29,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_opengl3", "ex
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_sdl2_sdlrenderer2", "example_sdl2_sdlrenderer2\example_sdl2_sdlrenderer2.vcxproj", "{0C0B2BEA-311F-473C-9652-87923EF639E3}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_sdl2_sdlrenderer2", "example_sdl2_sdlrenderer2\example_sdl2_sdlrenderer2.vcxproj", "{0C0B2BEA-311F-473C-9652-87923EF639E3}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_sdl3_sdlrenderer3", "example_sdl3_sdlrenderer3\example_sdl3_sdlrenderer3.vcxproj", "{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
@@ -141,6 +143,14 @@ Global
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|Win32.Build.0 = Release|Win32 {0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|Win32.Build.0 = Release|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|x64.ActiveCfg = Release|x64 {0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|x64.ActiveCfg = Release|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|x64.Build.0 = Release|x64 {0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|x64.Build.0 = Release|x64
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Debug|Win32.ActiveCfg = Debug|Win32
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Debug|Win32.Build.0 = Debug|Win32
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Debug|x64.ActiveCfg = Debug|x64
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Debug|x64.Build.0 = Debug|x64
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Release|Win32.ActiveCfg = Release|Win32
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Release|Win32.Build.0 = Release|Win32
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Release|x64.ActiveCfg = Release|x64
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -21292,7 +21292,10 @@ void ImGui::DebugNodeStorage(ImGuiStorage* storage, const char* label)
if (!TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes())) if (!TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes()))
return; return;
for (const ImGuiStoragePair& p : storage->Data) for (const ImGuiStoragePair& p : storage->Data)
{
BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer. BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer.
DebugLocateItemOnHover(p.key);
}
TreePop(); TreePop();
} }

View File

@@ -3381,7 +3381,7 @@ struct ImGuiViewport
// The library never uses those fields, they are merely storage to facilitate backend implementation. // The library never uses those fields, they are merely storage to facilitate backend implementation.
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function. void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function.
void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function. void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function.
void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GLFWWindow*, SDL_Window*) void* PlatformHandle; // void* to hold higher-level, platform window handle (e.g. HWND, GLFWWindow*, SDL_Window*), for FindViewportByPlatformHandle().
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (under Win32 this is expected to be a HWND, unused for other platforms), when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*) void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (under Win32 this is expected to be a HWND, unused for other platforms), when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
bool PlatformWindowCreated; // Platform window has been created (Platform_CreateWindow() has been called). This is false during the first frame where a viewport is being created. bool PlatformWindowCreated; // Platform window has been created (Platform_CreateWindow() has been called). This is false during the first frame where a viewport is being created.
bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position) bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position)

View File

@@ -7031,10 +7031,10 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos()); ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos());
if (show_samples && ImGui::BeginTooltip()) if (show_samples && ImGui::BeginTooltip())
{ {
ImGui::TextUnformatted("(R = radius, N = number of segments)"); ImGui::TextUnformatted("(R = radius, N = approx number of segments)");
ImGui::Spacing(); ImGui::Spacing();
ImDrawList* draw_list = ImGui::GetWindowDrawList(); ImDrawList* draw_list = ImGui::GetWindowDrawList();
const float min_widget_width = ImGui::CalcTextSize("N: MMM\nR: MMM").x; const float min_widget_width = ImGui::CalcTextSize("R: MMM\nN: MMM").x;
for (int n = 0; n < 8; n++) for (int n = 0; n < 8; n++)
{ {
const float RAD_MIN = 5.0f; const float RAD_MIN = 5.0f;
@@ -7043,6 +7043,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::BeginGroup(); ImGui::BeginGroup();
// N is not always exact here due to how PathArcTo() function work internally
ImGui::Text("R: %.f\nN: %d", rad, draw_list->_CalcCircleAutoSegmentCount(rad)); ImGui::Text("R: %.f\nN: %d", rad, draw_list->_CalcCircleAutoSegmentCount(rad));
const float canvas_width = IM_MAX(min_widget_width, rad * 2.0f); const float canvas_width = IM_MAX(min_widget_width, rad * 2.0f);