diff options
author | George Hazan <ghazan@miranda.im> | 2020-05-03 19:17:52 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-05-03 19:17:58 +0300 |
commit | 8be908eb8776a8976159ff4471edf74ce134a959 (patch) | |
tree | 028abb8ecceedad1e2d882cf985fd044480e50ee | |
parent | 13f2cfae91d3e7b8ca6472c3e69bbf88d95e2186 (diff) |
NewStory: drawing optimization
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
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: |