From 041c99df078f07f8720bc0a7f395ec5b28465da9 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 16 Dec 2014 20:19:06 -0500 Subject: [PATCH] Fixed deselection redraw. --- wintable/new/select.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wintable/new/select.h b/wintable/new/select.h index 00b1d8d..11d7ce9 100644 --- a/wintable/new/select.h +++ b/wintable/new/select.h @@ -36,15 +36,16 @@ static void doselect(struct table *t, intptr_t row, intptr_t column) if (t->selectedColumn >= t->nColumns) panic("sanity check failure: new Table selection invalid (column out of range)"); - // only scroll if we selected something - if (t->selectedRow == -1 || t->selectedColumn == -1) - goto noScroll; - + // do this even if we don't scroll before; noScroll depends on it if (GetClientRect(t->hwnd, &client) == 0) panic("error getting Table client rect in doselect()"); client.top += t->headerHeight; height = rowht(t); + // only scroll if we selected something + if (t->selectedRow == -1 || t->selectedColumn == -1) + goto noScroll; + // first vertically scroll to the new row to make it fully visible (or as visible as possible) if (t->selectedRow < t->vscrollpos) vscrollto(t, t->selectedRow); @@ -83,7 +84,6 @@ static void doselect(struct table *t, intptr_t row, intptr_t column) noScroll: // now redraw the old and new /rows/ // we do this after scrolling so the rectangles to be invalidated make sense - // TODO this doesn't work correctly if we're deselecting r.left = client.left; r.right = client.right; if (oldrow != -1 && oldrow >= t->vscrollpos) {