mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Scrolling: Tweak mouse-wheel locked window timer so it is shorter but also gets reset whenever scrolling again (#2604) + small refactor
Somehow interesting for (#3795, #4559). sorry this will break PR for 3795 but we got the info.
This commit is contained in:
parent
282b2b5afb
commit
80a870a3e5
@ -103,6 +103,8 @@ Other Changes:
|
||||
- Popups & Modals: fixed nested Begin() being erroneously input-inhibited. While it is
|
||||
unusual, you can nest a Begin() inside a popup or modal, it is occasionally useful to
|
||||
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).
|
||||
- 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)
|
||||
|
20
imgui.cpp
20
imgui.cpp
@ -953,7 +953,7 @@ static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time
|
||||
// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by backend)
|
||||
static const float WINDOWS_HOVER_PADDING = 4.0f; // Extend outside window for hovering/resizing (maxxed with TouchPadding) and inside windows for borders. Affect FindHoveredWindow().
|
||||
static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time.
|
||||
static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved.
|
||||
static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 1.50f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved.
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// [SECTION] FORWARD DECLARATIONS
|
||||
@ -4265,15 +4265,15 @@ static void ImGui::UpdateMouseInputs()
|
||||
}
|
||||
}
|
||||
|
||||
static void StartLockWheelingWindow(ImGuiWindow* window)
|
||||
static void LockWheelingWindow(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.WheelingWindowTimer = window ? WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER : 0.0f;
|
||||
if (g.WheelingWindow == window)
|
||||
return;
|
||||
IMGUI_DEBUG_LOG_IO("StartLockWheelingWindow() \"%s\"\n", window ? window->Name : "NULL");
|
||||
IMGUI_DEBUG_LOG_IO("LockWheelingWindow() \"%s\"\n", window ? window->Name : "NULL");
|
||||
g.WheelingWindow = window;
|
||||
g.WheelingWindowRefMousePos = g.IO.MousePos;
|
||||
g.WheelingWindowTimer = WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER;
|
||||
}
|
||||
|
||||
void ImGui::UpdateMouseWheel()
|
||||
@ -4287,11 +4287,7 @@ void ImGui::UpdateMouseWheel()
|
||||
if (IsMousePosValid() && ImLengthSqr(g.IO.MousePos - g.WheelingWindowRefMousePos) > g.IO.MouseDragThreshold * g.IO.MouseDragThreshold)
|
||||
g.WheelingWindowTimer = 0.0f;
|
||||
if (g.WheelingWindowTimer <= 0.0f)
|
||||
{
|
||||
IMGUI_DEBUG_LOG_IO("UpdateMouseWheel() release WheelingWindow lock \"%s\"\n", g.WheelingWindow->Name);
|
||||
g.WheelingWindow = NULL;
|
||||
g.WheelingWindowTimer = 0.0f;
|
||||
}
|
||||
LockWheelingWindow(NULL);
|
||||
}
|
||||
|
||||
const bool hovered_id_using_mouse_wheel = (g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrameUsingMouseWheel);
|
||||
@ -4311,7 +4307,7 @@ void ImGui::UpdateMouseWheel()
|
||||
// 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)
|
||||
{
|
||||
StartLockWheelingWindow(window);
|
||||
LockWheelingWindow(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;
|
||||
@ -4342,7 +4338,7 @@ void ImGui::UpdateMouseWheel()
|
||||
// Vertical Mouse Wheel scrolling
|
||||
if (wheel_y != 0.0f)
|
||||
{
|
||||
StartLockWheelingWindow(window);
|
||||
LockWheelingWindow(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))
|
||||
@ -4356,7 +4352,7 @@ void ImGui::UpdateMouseWheel()
|
||||
// Horizontal Mouse Wheel scrolling, or Vertical Mouse Wheel w/ Shift held
|
||||
if (wheel_x != 0.0f)
|
||||
{
|
||||
StartLockWheelingWindow(window);
|
||||
LockWheelingWindow(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))
|
||||
|
Loading…
Reference in New Issue
Block a user