mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 15:50:25 +01:00
Scrolling: Mitigated issue where multi-axis mouse-wheel inputs (usually from touch pad events) are incorrectly locking scrolling in a parent window. (#4559, #3795, #2604)
This commit is contained in:
parent
80a870a3e5
commit
c7d3d22ae1
@ -105,6 +105,8 @@ Other Changes:
|
||||
achieve certains things (e.g. some ways to implement suggestion popup #718, #4461).
|
||||
- Scrolling: Tweak mouse-wheel locked window timer so it is shorter but also gets reset
|
||||
whenever scrolling again (#2604).
|
||||
- Scrolling: Mitigated issue where multi-axis mouse-wheel inputs (usually from touch pad
|
||||
events) are incorrectly locking scrolling in a parent window. (#4559, #3795, #2604)
|
||||
- InputText: added experimental io.ConfigInputTextEnterKeepActive feature to make pressing
|
||||
Enter keep the input active and select all text.
|
||||
- InputText: numerical fields automatically accept full-width characters (U+FF01..U+FF5E)
|
||||
|
14
imgui.cpp
14
imgui.cpp
@ -4299,15 +4299,17 @@ void ImGui::UpdateMouseWheel()
|
||||
if (wheel_x == 0.0f && wheel_y == 0.0f)
|
||||
return;
|
||||
|
||||
ImGuiWindow* window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow;
|
||||
if (!window || window->Collapsed)
|
||||
//IMGUI_DEBUG_LOG("MouseWheel X:%.3f Y:%.3f\n", wheel_x, wheel_y);
|
||||
ImGuiWindow* mouse_window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow;
|
||||
if (!mouse_window || mouse_window->Collapsed)
|
||||
return;
|
||||
|
||||
// Zoom / Scale window
|
||||
// FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned.
|
||||
if (wheel_y != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling)
|
||||
{
|
||||
LockWheelingWindow(window);
|
||||
LockWheelingWindow(mouse_window);
|
||||
ImGuiWindow* window = mouse_window;
|
||||
const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
|
||||
const float scale = new_font_scale / window->FontWindowScale;
|
||||
window->FontWindowScale = new_font_scale;
|
||||
@ -4338,11 +4340,12 @@ void ImGui::UpdateMouseWheel()
|
||||
// Vertical Mouse Wheel scrolling
|
||||
if (wheel_y != 0.0f)
|
||||
{
|
||||
LockWheelingWindow(window);
|
||||
ImGuiWindow* window = mouse_window;
|
||||
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
|
||||
window = window->ParentWindow;
|
||||
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
|
||||
{
|
||||
LockWheelingWindow(mouse_window);
|
||||
float max_step = window->InnerRect.GetHeight() * 0.67f;
|
||||
float scroll_step = ImFloor(ImMin(5 * window->CalcFontSize(), max_step));
|
||||
SetScrollY(window, window->Scroll.y - wheel_y * scroll_step);
|
||||
@ -4352,11 +4355,12 @@ void ImGui::UpdateMouseWheel()
|
||||
// Horizontal Mouse Wheel scrolling, or Vertical Mouse Wheel w/ Shift held
|
||||
if (wheel_x != 0.0f)
|
||||
{
|
||||
LockWheelingWindow(window);
|
||||
ImGuiWindow* window = mouse_window;
|
||||
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.x == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
|
||||
window = window->ParentWindow;
|
||||
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
|
||||
{
|
||||
LockWheelingWindow(mouse_window);
|
||||
float max_step = window->InnerRect.GetWidth() * 0.67f;
|
||||
float scroll_step = ImFloor(ImMin(2 * window->CalcFontSize(), max_step));
|
||||
SetScrollX(window, window->Scroll.x - wheel_x * scroll_step);
|
||||
|
Loading…
Reference in New Issue
Block a user