From 8c750cef9cdad542f1539e67bf69ec3f263e3e0f Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 23 Nov 2019 15:06:36 +0000 Subject: [PATCH] Freeze the scrollbar while editor is open in property browser. Before this commit, the scrollbar would move freely, without changing the position of the viewport. It would be reset after editing is finished. --- src/platform/guimac.mm | 5 +++-- src/platform/guiwin.cpp | 6 +++++- src/textwin.cpp | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/platform/guimac.mm b/src/platform/guimac.mm index ad4871a..33901ff 100644 --- a/src/platform/guimac.mm +++ b/src/platform/guimac.mm @@ -952,9 +952,10 @@ public: } void SetScrollbarPosition(double pos) override { - if(pos > ssView.scrollerMax) { + if(pos > ssView.scrollerMax) pos = ssView.scrollerMax; - } + if(GetScrollbarPosition() == pos) + return; [nsScroller setDoubleValue:(pos / (ssView.scrollerMax - ssView.scrollerMin))]; if(onScrollbarAdjusted) { onScrollbarAdjusted(pos); diff --git a/src/platform/guiwin.cpp b/src/platform/guiwin.cpp index b2ae810..bd1b42e 100644 --- a/src/platform/guiwin.cpp +++ b/src/platform/guiwin.cpp @@ -1354,7 +1354,11 @@ public: SCROLLINFO si = {}; si.cbSize = sizeof(si); si.fMask = SIF_POS; - si.nPos = (UINT)(pos * SCROLLBAR_UNIT); + sscheck(GetScrollInfo(hWindow, SB_VERT, &si)); + if(si.nPos == (int)(pos * SCROLLBAR_UNIT)) + return; + + si.nPos = (int)(pos * SCROLLBAR_UNIT); sscheck(SetScrollInfo(hWindow, SB_VERT, &si, /*redraw=*/TRUE)); // Windows won't synthesize a WM_VSCROLL for us here. diff --git a/src/textwin.cpp b/src/textwin.cpp index 11d3048..131e12e 100644 --- a/src/textwin.cpp +++ b/src/textwin.cpp @@ -1129,8 +1129,10 @@ void TextWindow::MouseLeave() { } void TextWindow::ScrollbarEvent(double newPos) { - if(window->IsEditorVisible()) + if(window->IsEditorVisible()) { + window->SetScrollbarPosition(scrollPos); return; + } int bottom = top[rows-1] + 2; newPos = min((int)newPos, bottom - halfRows);