Backends: OSX: Fixed scroll wheel scaling for devices emitting events with hasPreciseScrollingDeltas==false (e.g. non-Apple mices).

Ref #4019 for details provided in .XLS sheet, although not strictly related to main issue topic.
+ Rename Emscripten demo titles to make SDL visible.
This commit is contained in:
ocornut 2023-02-01 19:42:22 +01:00
parent 2efebe3315
commit 8d29665ae1
7 changed files with 13 additions and 8 deletions

View File

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

View File

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

View File

@ -24,6 +24,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2023-02-01: Fixed scroll wheel scaling for devices emitting events with hasPreciseScrollingDeltas==false (e.g. non-Apple mices).
// 2022-11-02: Fixed mouse coordinates before clicking the host window. // 2022-11-02: Fixed mouse coordinates before clicking the host window.
// 2022-10-06: Fixed mouse inputs on flipped views. // 2022-10-06: Fixed mouse inputs on flipped views.
// 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).
@ -671,18 +672,18 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
wheel_dy = [event scrollingDeltaY]; wheel_dy = [event scrollingDeltaY];
if ([event hasPreciseScrollingDeltas]) if ([event hasPreciseScrollingDeltas])
{ {
wheel_dx *= 0.1; wheel_dx *= 0.01;
wheel_dy *= 0.1; wheel_dy *= 0.01;
} }
} }
else else
#endif // MAC_OS_X_VERSION_MAX_ALLOWED #endif // MAC_OS_X_VERSION_MAX_ALLOWED
{ {
wheel_dx = [event deltaX]; wheel_dx = [event deltaX] * 0.1;
wheel_dy = [event deltaY]; wheel_dy = [event deltaY] * 0.1;
} }
if (wheel_dx != 0.0 || wheel_dy != 0.0) if (wheel_dx != 0.0 || wheel_dy != 0.0)
io.AddMouseWheelEvent((float)wheel_dx * 0.1f, (float)wheel_dy * 0.1f); io.AddMouseWheelEvent((float)wheel_dx, (float)wheel_dy);
return io.WantCaptureMouse; return io.WantCaptureMouse;
} }

View File

@ -59,6 +59,8 @@ All changes:
- Misc: Tolerate zero delta-time under Emscripten as backends are imprecise in their - Misc: Tolerate zero delta-time under Emscripten as backends are imprecise in their
values for io.DeltaTime, and browser features such as "privacy.resistFingerprinting=true" values for io.DeltaTime, and browser features such as "privacy.resistFingerprinting=true"
can exacerbate that. (#6114, #3644) can exacerbate that. (#6114, #3644)
- Backends: OSX: Fixed scroll/wheel scaling for devices emitting events with
hasPreciseScrollingDeltas==false (e.g. non-Apple mices).
- Backend: WebGPU: Fix building for latest WebGPU specs (remove implicit layout generation). - Backend: WebGPU: Fix building for latest WebGPU specs (remove implicit layout generation).
(#6117, #4116, #3632) [@tonygrue, @bfierz] (#6117, #4116, #3632) [@tonygrue, @bfierz]
- Examples: Win32: Fixed examples using RegisterClassW() since 1.89 to also call - Examples: Win32: Fixed examples using RegisterClassW() since 1.89 to also call

View File

@ -1,5 +1,5 @@
# #
# Makefile to use with emscripten # Makefile to use with SDL+emscripten
# See https://emscripten.org/docs/getting_started/downloads.html # See https://emscripten.org/docs/getting_started/downloads.html
# for installation instructions. # for installation instructions.
# #

View File

@ -49,7 +49,7 @@ int main(int, char**)
SDL_DisplayMode current; SDL_DisplayMode current;
SDL_GetCurrentDisplayMode(0, &current); SDL_GetCurrentDisplayMode(0, &current);
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
g_Window = SDL_CreateWindow("Dear ImGui Emscripten example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); g_Window = SDL_CreateWindow("Dear ImGui SDL+Emscripten example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
g_GLContext = SDL_GL_CreateContext(g_Window); g_GLContext = SDL_GL_CreateContext(g_Window);
if (!g_GLContext) if (!g_GLContext)
{ {

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
<title>Dear ImGui Emscripten example</title> <title>Dear ImGui SDL+Emscripten example</title>
<style> <style>
body { margin: 0; background-color: black } body { margin: 0; background-color: black }
.emscripten { .emscripten {