From 8be908eb8776a8976159ff4471edf74ce134a959 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 3 May 2020 19:17:52 +0300 Subject: NewStory: drawing optimization --- plugins/NewStory/src/history_control.cpp | 33 ++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'plugins/NewStory/src') diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 419161855f..e8b3dae293 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -15,8 +15,11 @@ static LRESULT CALLBACK HistoryEditWndProc(HWND, UINT, WPARAM, LPARAM); struct NewstoryListData : public MZeroedObject { NewstoryListData(HWND _1) : - hwnd(_1) - {} + hwnd(_1), + redrawTimer(Miranda_GetSystemWindow(), (LPARAM)this) + { + redrawTimer.OnEvent = Callback(this, &NewstoryListData::OnTimer); + } HistoryArray items; @@ -33,11 +36,23 @@ struct NewstoryListData : public MZeroedObject HWND hwnd; HWND hwndEditBox; + CTimer redrawTimer; + void OnContextMenu(int index) { ItemData* item = items.get(index, ItemData::ELM_DATA); } + void OnTimer(CTimer *pTimer) + { + pTimer->Stop(); + + RecalcScrollBar(); + scrollTopItem = items.getCount(); + FixScrollPosition(); + InvalidateRect(hwnd, 0, FALSE); + } + void BeginEditItem(int index) { if (hwndEditBox) @@ -460,18 +475,16 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM p->hFirstEVent = db_event_first(p->hContact); data->items.addEvent(p->hContact, p->hFirstEVent, p->eventCount); } - data->RecalcScrollBar(); - data->scrollTopItem = data->items.getCount(); - data->FixScrollPosition(); - InvalidateRect(hwnd, 0, FALSE); + + data->redrawTimer.Stop(); + data->redrawTimer.Start(100); break; case NSM_ADDCHATEVENT: data->items.addChatEvent((SESSION_INFO *)wParam, (LOGINFO*)lParam); - data->RecalcScrollBar(); - data->scrollTopItem = data->items.getCount(); - data->FixScrollPosition(); - InvalidateRect(hwnd, 0, FALSE); + + data->redrawTimer.Stop(); + data->redrawTimer.Start(100); break; case NSM_GETCOUNT: -- cgit v1.2.3