Implemented vertical scrolling on selection changes.
This commit is contained in:
parent
cb7404cf8b
commit
f56ae488f0
|
@ -71,11 +71,11 @@ struct table {
|
|||
|
||||
#include "util.h"
|
||||
#include "coord.h"
|
||||
#include "select.h"
|
||||
#include "events.h"
|
||||
#include "scroll.h"
|
||||
#include "hscroll.h"
|
||||
#include "vscroll.h"
|
||||
#include "select.h"
|
||||
#include "events.h"
|
||||
#include "header.h"
|
||||
#include "children.h"
|
||||
#include "resize.h"
|
||||
|
|
|
@ -6,18 +6,38 @@ static void doselect(struct table *t, intptr_t row, intptr_t column)
|
|||
RECT r, client;
|
||||
intptr_t oldrow;
|
||||
LONG height;
|
||||
struct rowcol rc;
|
||||
BOOL dovscroll;
|
||||
|
||||
oldrow = t->selectedRow;
|
||||
t->selectedRow = row;
|
||||
t->selectedColumn = column;
|
||||
|
||||
// TODO scroll to ensure the full cell is visible
|
||||
|
||||
// now redraw the old and new /rows/
|
||||
if (GetClientRect(t->hwnd, &client) == 0)
|
||||
panic("error getting Table client rect in doselect()");
|
||||
client.top += t->headerHeight;
|
||||
height = rowht(t);
|
||||
|
||||
// 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);
|
||||
else {
|
||||
rc.row = t->selectedRow;
|
||||
rc.column = t->selectedColumn;
|
||||
// first assume entirely outside the client area
|
||||
dovscroll = TRUE;
|
||||
if (rowColumnToClientRect(t, rc, &r))
|
||||
// partially outside the client area?
|
||||
if (r.bottom <= client.bottom) // <= here since we are comparing bottoms (which are the first pixels outside the rectangle)
|
||||
dovscroll = FALSE;
|
||||
if (dovscroll)
|
||||
vscrollto(t, t->selectedRow - t->vpagesize + 1); // + 1 because apparently just t->selectedRow - t->vpagesize results in no scrolling (t->selectedRow - t->vpagesize == t->vscrollpos)...
|
||||
}
|
||||
|
||||
// TODO horizontal scroll
|
||||
|
||||
// now redraw the old and new /rows/
|
||||
// we do this after scrolling so the rectangles to be invalidated make sense
|
||||
r.left = client.left;
|
||||
r.right = client.right;
|
||||
if (oldrow != -1 && oldrow >= t->vscrollpos) {
|
||||
|
|
Loading…
Reference in New Issue