From 170221b29bd7326bfb1f0bdd1e95f0f9f3c6b11c Mon Sep 17 00:00:00 2001 From: ketmar Date: Wed, 14 Jun 2023 11:43:32 +0000 Subject: [PATCH] some fixes in mouse scrolling FossilOrigin-Name: 4e106d0aef0144cd747103c321b329f9e8793d2e8bb8c806235d5e48af23ff53 --- chiroptera.d | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/chiroptera.d b/chiroptera.d index 493dccd..0782186 100644 --- a/chiroptera.d +++ b/chiroptera.d @@ -2017,6 +2017,36 @@ final class MainPaneWindow : SubWindow { if (!foundCurr) folderCurrTag.clear(); } + void normTopIndex () { + if (folderList.length) { + if (folderTopIndex >= folderList.length) folderTopIndex = cast(uint)folderList.length-1; + int hgt = screenHeight/(gxTextHeightUtf+2)-1; + if (hgt < 1) hgt = 1; + if (folderList.length > hgt && folderTopIndex > folderList.length-hgt-1) { + folderTopIndex = folderList.length-hgt-1; + } + if (folderTopTag != folderList[folderTopIndex].name) folderTopTag = folderList[folderTopIndex].name; + } + } + + bool folderScrollUp () { + int oldidx = folderTopIndex; + if (folderTopIndex > 0) { + --folderTopIndex; + normTopIndex(); + } + return (folderTopIndex != oldidx); + } + + bool folderScrollDown () { + int oldidx = folderTopIndex; + if (folderList.length > 1) { + ++folderTopIndex; + normTopIndex(); + } + return (folderTopIndex != oldidx); + } + void folderMakeCurVisible () { rescanFolders(); if (folderList.length) { @@ -3290,28 +3320,38 @@ final class MainPaneWindow : SubWindow { } } // wheel - if (event.type == MouseEventType.buttonPressed && (event.button == MouseButton.wheelUp || event.button == MouseButton.wheelDown)) { + if (event.type == MouseEventType.buttonPressed && + (event.button == MouseButton.wheelUp || event.button == MouseButton.wheelDown)) + { // folder if (mx >= 0 && mx < guiGroupListWidth && my >= 0 && my < screenHeight) { if (event.button == MouseButton.wheelUp) { + if (folderScrollUp()) postScreenRebuild(); + /* if (folderCurrIndex > 0) { --folderCurrIndex; postScreenRebuild(); } + */ } else { + if (folderScrollDown()) postScreenRebuild(); + /* if (folderCurrIndex+1 < folderList.length) { ++folderCurrIndex; postScreenRebuild(); } + */ } return false; } // post if (mx > guiGroupListWidth && mx < screenWidth && my >= 0 && my < guiThreadListHeight) { if (event.button == MouseButton.wheelUp) { - if (threadListUp()) postScreenRebuild(); + //if (threadListUp()) postScreenRebuild(); + if (threadListScrollUp(movecurrent:false)) postScreenRebuild(); } else { - if (threadListDown()) postScreenRebuild(); + //if (threadListDown()) postScreenRebuild(); + if (threadListScrollDown(movecurrent:false)) postScreenRebuild(); } return false; } -- 2.11.4.GIT