mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 17:10:57 +01:00
Backends: GLFW+Emscripten: (Breaking) Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to ImGui_ImplGlfw_InstallEmscriptenCallbacks(), added GLFWwindow* parameter. (#7647, #7600)
+ Fixed Emscripten warning when using mouse wheel on some setups.
This commit is contained in:
parent
9504068f66
commit
6816789a6b
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-07-08: *BREAKING* Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback to ImGui_ImplGlfw_InstallEmscriptenCallbacks(), added GLFWWindow* parameter.
|
||||||
// 2024-07-02: Emscripten: Added io.PlatformOpenInShellFn() handler for Emscripten versions.
|
// 2024-07-02: Emscripten: Added io.PlatformOpenInShellFn() handler for Emscripten versions.
|
||||||
// 2023-12-19: Emscripten: Added ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to register canvas selector and auto-resize GLFW window.
|
// 2023-12-19: Emscripten: Added ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to register canvas selector and auto-resize GLFW window.
|
||||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys.
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys.
|
||||||
@ -611,12 +612,6 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
||||||
if (install_callbacks)
|
if (install_callbacks)
|
||||||
ImGui_ImplGlfw_InstallCallbacks(window);
|
ImGui_ImplGlfw_InstallCallbacks(window);
|
||||||
// Register Emscripten Wheel callback to workaround issue in Emscripten GLFW Emulation (#6096)
|
|
||||||
// We intentionally do not check 'if (install_callbacks)' here, as some users may set it to false and call GLFW callback themselves.
|
|
||||||
// FIXME: May break chaining in case user registered their own Emscripten callback?
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, nullptr, false, ImGui_ImplEmscripten_WheelCallback);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set platform dependent data in viewport
|
// Set platform dependent data in viewport
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
@ -664,7 +659,8 @@ void ImGui_ImplGlfw_Shutdown()
|
|||||||
if (bd->InstalledCallbacks)
|
if (bd->InstalledCallbacks)
|
||||||
ImGui_ImplGlfw_RestoreCallbacks(bd->Window);
|
ImGui_ImplGlfw_RestoreCallbacks(bd->Window);
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, nullptr, false, nullptr);
|
if (bd->CanvasSelector)
|
||||||
|
emscripten_set_wheel_callback(bd->CanvasSelector, nullptr, false, nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||||
@ -844,7 +840,7 @@ static EM_BOOL ImGui_ImplEmscripten_FullscreenChangeCallback(int event_type, con
|
|||||||
|
|
||||||
// 'canvas_selector' is a CSS selector. The event listener is applied to the first element that matches the query.
|
// 'canvas_selector' is a CSS selector. The event listener is applied to the first element that matches the query.
|
||||||
// STRING MUST PERSIST FOR THE APPLICATION DURATION. PLEASE USE A STRING LITERAL OR ENSURE POINTER WILL STAY VALID.
|
// STRING MUST PERSIST FOR THE APPLICATION DURATION. PLEASE USE A STRING LITERAL OR ENSURE POINTER WILL STAY VALID.
|
||||||
void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector)
|
void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow*, const char* canvas_selector)
|
||||||
{
|
{
|
||||||
IM_ASSERT(canvas_selector != nullptr);
|
IM_ASSERT(canvas_selector != nullptr);
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
@ -856,6 +852,11 @@ void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_sel
|
|||||||
|
|
||||||
// Change the size of the GLFW window according to the size of the canvas
|
// Change the size of the GLFW window according to the size of the canvas
|
||||||
ImGui_ImplGlfw_OnCanvasSizeChange(EMSCRIPTEN_EVENT_RESIZE, {}, bd);
|
ImGui_ImplGlfw_OnCanvasSizeChange(EMSCRIPTEN_EVENT_RESIZE, {}, bd);
|
||||||
|
|
||||||
|
// Register Emscripten Wheel callback to workaround issue in Emscripten GLFW Emulation (#6096)
|
||||||
|
// We intentionally do not check 'if (install_callbacks)' here, as some users may set it to false and call GLFW callback themselves.
|
||||||
|
// FIXME: May break chaining in case user registered their own Emscripten callback?
|
||||||
|
emscripten_set_wheel_callback(bd->CanvasSelector, nullptr, false, ImGui_ImplEmscripten_WheelCallback);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,9 +30,10 @@ IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool ins
|
|||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
|
||||||
|
|
||||||
// Emscripten related initialization phase methods
|
// Emscripten related initialization phase methods (call after ImGui_ImplGlfw_InitForOpenGL)
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector);
|
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow* window, const char* canvas_selector);
|
||||||
|
//static inline void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector) { ImGui_ImplGlfw_InstallEmscriptenCallbacks(nullptr, canvas_selector); } } // Renamed in 1.91.0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GLFW callbacks install
|
// GLFW callbacks install
|
||||||
|
@ -49,6 +49,8 @@ Breaking changes:
|
|||||||
- Commented out obsolete ImGuiModFlags (renamed to ImGuiKeyChord in 1.89). (#4921, #456)
|
- Commented out obsolete ImGuiModFlags (renamed to ImGuiKeyChord in 1.89). (#4921, #456)
|
||||||
- Commented out obsolete ImGuiModFlags_XXX values (renamed to ImGuiMod_XXX in 1.89). (#4921, #456)
|
- Commented out obsolete ImGuiModFlags_XXX values (renamed to ImGuiMod_XXX in 1.89). (#4921, #456)
|
||||||
- ImGuiModFlags_Ctrl -> ImGuiMod_Ctrl, ImGuiModFlags_Shift -> ImGuiMod_Shift etc.
|
- ImGuiModFlags_Ctrl -> ImGuiMod_Ctrl, ImGuiModFlags_Shift -> ImGuiMod_Shift etc.
|
||||||
|
- Backends: GLFW+Emscripten: Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to
|
||||||
|
ImGui_ImplGlfw_InstallEmscriptenCallbacks(), with additional GLFWWindow* parameter. (#7647) [@ypujante]
|
||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
|
|
||||||
@ -66,6 +68,8 @@ Other changes:
|
|||||||
- Backends: SDL2,SDL3,OSX: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() rename.
|
- Backends: SDL2,SDL3,OSX: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() rename.
|
||||||
- Backends: GLFW,SDL2: Added io.PlatformOpenInShellFn handler for web/Emscripten versions. (#7660)
|
- Backends: GLFW,SDL2: Added io.PlatformOpenInShellFn handler for web/Emscripten versions. (#7660)
|
||||||
[@ypujante, @ocornut]
|
[@ypujante, @ocornut]
|
||||||
|
- Backends: GLFW+Emscripten: Fixed Emscripten warning when using mouse wheel on some setups
|
||||||
|
"Unable to preventDefault inside passive event listener". (#7647, #7600) [@ypujante]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
@ -85,7 +85,7 @@ int main(int, char**)
|
|||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback("#canvas");
|
ImGui_ImplGlfw_InstallEmscriptenCallbacks(window, "#canvas");
|
||||||
#endif
|
#endif
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ int main(int, char**)
|
|||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForOther(window, true);
|
ImGui_ImplGlfw_InitForOther(window, true);
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback("#canvas");
|
ImGui_ImplGlfw_InstallEmscriptenCallbacks(window, "#canvas");
|
||||||
#endif
|
#endif
|
||||||
ImGui_ImplWGPU_InitInfo init_info;
|
ImGui_ImplWGPU_InitInfo init_info;
|
||||||
init_info.Device = wgpu_device;
|
init_info.Device = wgpu_device;
|
||||||
|
Loading…
Reference in New Issue
Block a user