diff options
author | George Hazan <george.hazan@gmail.com> | 2023-12-16 12:49:25 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-12-16 12:49:25 +0300 |
commit | cebe4050e6cd6415f6480f407077a3a3778ad205 (patch) | |
tree | 1d761fa1364b2cef8d231b496d578dcbf2cbec0a | |
parent | 5ab6d9ae15f81fe1784ae34f0eab3e611e4330c7 (diff) |
fixes #4059 (NewStory: жесткие тормоза, вторая часть марлезонского балета)
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 28 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 2 |
2 files changed, 17 insertions, 13 deletions
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index f0fd1d29b0..b495a3ac06 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -515,11 +515,18 @@ bool NewstoryListData::HasSelection() const return false; } -void NewstoryListData::HitTotal(int y) +void NewstoryListData::HitTotal(int yCurr, int yTotal) { - int i = 0; - while (i < totalCount && y > 0) - y -= GetItemHeight(i++); + int i = 0, y = yCurr; + while (i < totalCount && y > 0) { + auto *pItem = GetItem(i++); + if (!pItem->m_bLoaded) { + i = (totalCount * yCurr) / yTotal; + y = 0; + break; + } + else y -= GetItemHeight(pItem); + } scrollTopItem = i; scrollTopPixel = y; @@ -685,13 +692,10 @@ void NewstoryListData::RecalcScrollBar() } if (numRec != totalCount) { - yTotal = (yTotal * totalCount) / numRec; - for (int i = 0; i < totalCount; i++) - if (i == scrollTopItem) { - yTop = yTotal - scrollTopPixel; - break; - } - } + double averageH = double(yTotal) / double(numRec); + yTotal = totalCount * averageH; + yTop = scrollTopItem * averageH; + } SCROLLINFO si = {}; si.cbSize = sizeof(si); @@ -1400,7 +1404,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM si.cbSize = sizeof(si); si.fMask = SIF_ALL; GetScrollInfo(hwnd, SB_VERT, &si); - data->HitTotal(si.nTrackPos); + data->HitTotal(si.nTrackPos, si.nMax); break; default: diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 2f9cd9ac56..463bfe15c2 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -63,7 +63,7 @@ struct NewstoryListData : public MZeroedObject int GetItemHeight(int index); int GetItemHeight(ItemData *pItem); bool HasSelection() const; - void HitTotal(int y); + void HitTotal(int yCurr, int yTotal); void LineUp(); void LineDown(); ItemData* LoadItem(int idx); |