diff --git a/extern/imgui_patched/imgui.cpp b/extern/imgui_patched/imgui.cpp index a0298a3fb..742127d6b 100644 --- a/extern/imgui_patched/imgui.cpp +++ b/extern/imgui_patched/imgui.cpp @@ -3449,13 +3449,10 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) g.ActiveIdSource = (g.NavActivateId == id || g.NavActivateInputId == id || g.NavJustMovedToId == id) ? (ImGuiInputSource)ImGuiInputSource_Nav : ImGuiInputSource_Mouse; // TODO: check whether this works if (g.LastItemData.InFlags & ImGuiItemFlags_NoInertialScroll) { - if (window) { - window->InertialScrollInhibited=true; - printf("inhibiting scroll\n"); - } + g.InertialScrollInhibited=true; } } else { - if (window) window->InertialScrollInhibited=false; + g.InertialScrollInhibited=false; } // Clear declaration of inputs claimed by the widget @@ -5104,6 +5101,11 @@ void ImGui::EndFrame() g.DragDropWithinSource = false; } + // Check for inertial scroll inhibit status + if (g.IO.MouseReleased[ImGuiMouseButton_Left]) { + g.InertialScrollInhibited=false; + } + // End frame g.WithinFrameScope = false; g.FrameCountEnded = g.FrameCount; @@ -6934,7 +6936,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) if ((g.IO.MouseDown[ImGuiMouseButton_Left] || g.IO.MouseReleased[ImGuiMouseButton_Left]) && g.ActiveId!=GetWindowScrollbarID(window,ImGuiAxis_X) && g.ActiveId!=GetWindowScrollbarID(window,ImGuiAxis_Y) && - !window->InertialScrollInhibited) { + !g.InertialScrollInhibited) { // launch inertial scroll if (g.IO.MouseClicked[ImGuiMouseButton_Left]) { window->InertialScrollSpeed=ImVec2(0.0f,0.0f); @@ -6955,6 +6957,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) window->InertialScroll=false; } } + } else if (g.InertialScrollInhibited) { + window->InertialScrollSpeed=ImVec2(0.0f,0.0f); + window->InertialScroll=false; } } @@ -6983,9 +6988,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) window->InertialScrollSpeed.x=0.0f; window->InertialScrollSpeed.y=0.0f; } - if (g.IO.MouseReleased[ImGuiMouseButton_Left]) { - window->InertialScrollInhibited=false; - } } // Apply scrolling @@ -7554,10 +7556,8 @@ void ImGui::EndDisabled() void ImGui::InhibitInertialScroll() { - ImGuiWindow* window = GetCurrentWindow(); - if (window!=NULL) { - window->InertialScrollInhibited=true; - } + ImGuiContext& g = *GImGui; + g.InertialScrollInhibited=true; } // FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system. diff --git a/extern/imgui_patched/imgui_internal.h b/extern/imgui_patched/imgui_internal.h index 83faaf6e9..e4b014219 100644 --- a/extern/imgui_patched/imgui_internal.h +++ b/extern/imgui_patched/imgui_internal.h @@ -1936,6 +1936,9 @@ struct ImGuiContext float NavWindowingHighlightAlpha; bool NavWindowingToggleLayer; + // Inertial scroll + bool InertialScrollInhibited; // Is inertial scroll inhibited? (e.g. by ImGuiItemFlags_NoInertialScroll) + // Render float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list) ImGuiMouseCursor MouseCursor; @@ -2145,6 +2148,8 @@ struct ImGuiContext NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f; NavWindowingToggleLayer = false; + InertialScrollInhibited = false; + DimBgRatio = 0.0f; MouseCursor = ImGuiMouseCursor_Arrow; @@ -2295,7 +2300,6 @@ struct IMGUI_API ImGuiWindow ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar. ImVec2 InertialScrollSpeed; // current speed of inertial scroll (AKA "swipe") - bool InertialScrollInhibited; // Is inertial scroll inhibited? (e.g. by ImGuiItemFlags_NoInertialScroll) bool ScrollbarX, ScrollbarY; // Are scrollbars visible? bool ViewportOwned; bool Active; // Set to true on Begin(), unless Collapsed diff --git a/extern/imgui_patched/imgui_widgets.cpp b/extern/imgui_patched/imgui_widgets.cpp index 744ef29c5..d95ed1a3a 100644 --- a/extern/imgui_patched/imgui_widgets.cpp +++ b/extern/imgui_patched/imgui_widgets.cpp @@ -3113,7 +3113,7 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d const ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); ItemSize(bb, style.FramePadding.y); - if (!ItemAdd(frame_bb, id)) + if (!ItemAdd(frame_bb, id, NULL, ImGuiItemFlags_NoInertialScroll)) return false; // Default format string when passing NULL diff --git a/src/gui/piano.cpp b/src/gui/piano.cpp index 98e83f351..9688b51d3 100644 --- a/src/gui/piano.cpp +++ b/src/gui/piano.cpp @@ -222,6 +222,7 @@ void FurnaceGUI::drawPiano() { bool canInput=false; if (ImGui::ItemHoverable(rect,ImGui::GetID("pianoDisplay"))) { canInput=true; + ImGui::InhibitInertialScroll(); } if (view) { int notes=oct*12;