diff options
| author | Pietro Gagliardi <[email protected]> | 2014-12-14 17:24:30 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-12-14 17:24:30 -0500 |
| commit | 8fba540a1c4f2f9e52858b79c0ab985697bc0696 (patch) | |
| tree | 98ed1b0bc707af3b13606c8203d7e9bd71cbddf4 | |
| parent | c58920dadd89141e24e24746984f37574135e068 (diff) | |
Mostly fixed up the horizontal scrolling implementation in doselect().
| -rw-r--r-- | wintable/new/select.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/wintable/new/select.h b/wintable/new/select.h index c6f1c1d..58cd1f5 100644 --- a/wintable/new/select.h +++ b/wintable/new/select.h @@ -43,15 +43,16 @@ static void doselect(struct table *t, intptr_t row, intptr_t column) xpos += columnWidth(t, i); if (xpos < t->hscrollpos) hscrollto(t, xpos); - else while(1){break; + else { // if the full cell is not visible, scroll to the right just enough to make it fully visible (or as visible as possible) width = columnWidth(t, t->selectedColumn); clientWidth = client.right - client.left; - if (xpos + width < t->hscrollpos + clientWidth) + if (xpos + width > t->hscrollpos + clientWidth) // > because both sides deal with the first pixel outside // if the column is too wide, then just make it occupy the whole visible area (left-aligned) if (width > clientWidth) hscrollto(t, xpos); else + // TODO this formula is wrong hscrollby(t, clientWidth - width); } |
