And made indeterminate progressbars work. Now to theme them.

This commit is contained in:
Pietro Gagliardi 2018-06-16 19:40:06 -04:00
parent c7555dcfd3
commit 301376706f
3 changed files with 12 additions and 8 deletions

View File

@ -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);

View File

@ -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

View File

@ -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;