mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-09-25 10:58:18 +02:00
Improve document list display performance
Reduce number of document list redraws on reload. Force redraw on activating item. Fix #13479, fix #12632, close #14142
This commit is contained in:
parent
b068aa9033
commit
dca3f682fd
@ -169,12 +169,23 @@ void VerticalFileSwitcherListView::initList()
|
|||||||
|
|
||||||
void VerticalFileSwitcherListView::reload()
|
void VerticalFileSwitcherListView::reload()
|
||||||
{
|
{
|
||||||
|
// Suppress redraws for performance. We target _hParent to prevent scroll bar flickering.
|
||||||
|
::SendMessage(_hParent, WM_SETREDRAW, false, 0);
|
||||||
removeAll();
|
removeAll();
|
||||||
initList();
|
initList();
|
||||||
|
|
||||||
RECT rc{};
|
RECT rc{};
|
||||||
::GetClientRect(_hParent, &rc);
|
::GetClientRect(_hParent, &rc);
|
||||||
resizeColumns(rc.right - rc.left);
|
resizeColumns(rc.right - rc.left);
|
||||||
|
::SendMessage(_hParent, WM_SETREDRAW, true, 0);
|
||||||
|
redrawItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerticalFileSwitcherListView::redrawItems()
|
||||||
|
{
|
||||||
|
int nbItem = ListView_GetItemCount(_hSelf);
|
||||||
|
::SendMessage(_hSelf, WM_PAINT, 0, 0);
|
||||||
|
ListView_RedrawItems(_hSelf, 0, nbItem - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferID VerticalFileSwitcherListView::getBufferInfoFromIndex(int index, int & view) const
|
BufferID VerticalFileSwitcherListView::getBufferInfoFromIndex(int index, int & view) const
|
||||||
@ -298,6 +309,9 @@ int VerticalFileSwitcherListView::closeItem(BufferID bufferID, int iView)
|
|||||||
|
|
||||||
void VerticalFileSwitcherListView::activateItem(BufferID bufferID, int iView)
|
void VerticalFileSwitcherListView::activateItem(BufferID bufferID, int iView)
|
||||||
{
|
{
|
||||||
|
// Suppress redraws while we're resetting states
|
||||||
|
::SendMessage(_hSelf, WM_SETREDRAW, false, 0);
|
||||||
|
|
||||||
// Clean all selection
|
// Clean all selection
|
||||||
int nbItem = ListView_GetItemCount(_hSelf);
|
int nbItem = ListView_GetItemCount(_hSelf);
|
||||||
for (int i = 0; i < nbItem; ++i)
|
for (int i = 0; i < nbItem; ++i)
|
||||||
@ -305,7 +319,10 @@ void VerticalFileSwitcherListView::activateItem(BufferID bufferID, int iView)
|
|||||||
|
|
||||||
_currentIndex = newItem(bufferID, iView);
|
_currentIndex = newItem(bufferID, iView);
|
||||||
selectCurrentItem();
|
selectCurrentItem();
|
||||||
|
// Have to enable redraw to be able to move selection to the current item
|
||||||
|
::SendMessage(_hSelf, WM_SETREDRAW, true, 0);
|
||||||
ensureVisibleCurrentItem();
|
ensureVisibleCurrentItem();
|
||||||
|
redrawItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
int VerticalFileSwitcherListView::add(BufferID bufferID, int iView)
|
int VerticalFileSwitcherListView::add(BufferID bufferID, int iView)
|
||||||
|
@ -63,6 +63,7 @@ public:
|
|||||||
|
|
||||||
std::vector<BufferViewInfo> getSelectedFiles(bool reverse = false) const;
|
std::vector<BufferViewInfo> getSelectedFiles(bool reverse = false) const;
|
||||||
void reload();
|
void reload();
|
||||||
|
void redrawItems();
|
||||||
void ensureVisibleCurrentItem() const {
|
void ensureVisibleCurrentItem() const {
|
||||||
ListView_EnsureVisible(_hSelf, _currentIndex, false);
|
ListView_EnsureVisible(_hSelf, _currentIndex, false);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user