From 301376706fff9b9eb020c75d6aeb3972c61a9ff8 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 16 Jun 2018 19:40:06 -0400 Subject: [PATCH] And made indeterminate progressbars work. Now to theme them. --- windows/table.cpp | 15 +++++++++------ windows/tabledispinfo.cpp | 2 +- windows/tabledraw.cpp | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/windows/table.cpp b/windows/table.cpp index 5fcd7c6b..9dba46b7 100644 --- a/windows/table.cpp +++ b/windows/table.cpp @@ -76,6 +76,7 @@ void uiTableModelRowDeleted(uiTableModel *m, int oldIndex) } } +// TODO explain all this static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIDSubclass, DWORD_PTR dwRefData) { uiTable *t = (uiTable *) dwRefData; @@ -84,10 +85,11 @@ static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM case WM_TIMER: if (wParam != (WPARAM) t) break; - for (auto &i : t->indeterminatePositions) { - i->second++; + // TODO only increment and update if visible? + for (auto &i : *(t->indeterminatePositions)) { + i.second++; // TODO check errors - SendMessageW(hwnd, LVM_UPDATE, (WPARAM) (i->first.first), 0); + SendMessageW(hwnd, LVM_UPDATE, (WPARAM) (i.first.first), 0); } return 0; case WM_NCDESTROY: @@ -108,7 +110,7 @@ int uiprivTableProgress(uiTable *t, int item, int subitem, int modelColumn, LONG bool stopTimer = false; data = (*(t->model->mh->CellValue))(t->model->mh, t->model, item, modelColumn); - progress = uiTableModelInt(data); + progress = uiTableDataInt(data); uiFreeTableData(data); p.first = item; @@ -131,11 +133,13 @@ int uiprivTableProgress(uiTable *t, int item, int subitem, int modelColumn, LONG if (startTimer) // the interval shown here is PBM_SETMARQUEE's default // TODO should we pass a function here instead? it seems to be called by DispatchMessage(), not DefWindowProc(), but I'm still unsure - if (SetTimer(t->hwnd, (UINT_PTR) (&t), 30, NULL) == 0) + if (SetTimer(t->hwnd, (UINT_PTR) t, 30, NULL) == 0) logLastError(L"SetTimer()"); if (stopTimer) if (KillTimer(t->hwnd, (UINT_PTR) (&t)) == 0) logLastError(L"KillTimer()"); + + return progress; } static BOOL onWM_NOTIFY(uiControl *c, HWND hwnd, NMHDR *nmhdr, LRESULT *lResult) @@ -315,7 +319,6 @@ uiTable *uiNewTable(uiTableModel *model) { uiTable *t; int n; - int i; HRESULT hr; uiWindowsNewControl(uiTable, t); diff --git a/windows/tabledispinfo.cpp b/windows/tabledispinfo.cpp index 33559bb3..2e3ae4b9 100644 --- a/windows/tabledispinfo.cpp +++ b/windows/tabledispinfo.cpp @@ -32,7 +32,7 @@ static HRESULT handleLVIF_TEXT(uiTable *t, NMLVDISPINFOW *nm, uiprivTableColumnP } if (p->progressBarModelColumn != -1) { - progress = uiprivTableProgress(t, nm->item.iItem, p->progressBarModelColumn, NULL); + progress = uiprivTableProgress(t, nm->item.iItem, nm->item.iSubItem, p->progressBarModelColumn, NULL); if (progress == -1) { // TODO either localize this or replace it with something that's language-neutral diff --git a/windows/tabledraw.cpp b/windows/tabledraw.cpp index 59b9d90c..bc2e76d9 100644 --- a/windows/tabledraw.cpp +++ b/windows/tabledraw.cpp @@ -327,7 +327,7 @@ static HRESULT drawProgressBarPart(struct drawState *s) if (s->p->progressBarModelColumn == -1) return S_OK; - progress = uiprivTableProgress(s->t, s->iItem, s->p->progressBarModelColumn, &indeterminatePos); + progress = uiprivTableProgress(s->t, s->iItem, s->iSubItem, s->p->progressBarModelColumn, &indeterminatePos); theme = OpenThemeData(s->t->hwnd, L"TODO"); @@ -376,6 +376,7 @@ static HRESULT drawProgressBarPart(struct drawState *s) LONG pieceWidth; // TODO explain all this + // TODO this should really start the progressbar scrolling into view instead of already on screen when first set rFill[1] = rFill[0]; // save in case we need it barWidth = rFill[0].right - rFill[0].left; pieceWidth = barWidth / indeterminateSegments;