Skip to content

Commit

Permalink
Consider scrollbars overlapping the scrolled window at its edges
Browse files Browse the repository at this point in the history
This assumes that the scrollbar are at the right and bottom edge.
Hopefully no platform will change this.

This commit should avoid the situation where the selection to scroll to
is hidden behind the scrollbar.
  • Loading branch information
tobiolo committed Sep 15, 2023
1 parent 63bcae5 commit 6ddf93b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,17 @@ struct Document {
sw->GetClientSize(&canvasw, &canvash);
if ((layoutys > canvash || layoutxs > canvasw) && s.g) {
wxRect r = s.g->GetRect(this, s, true);
if (r.y < originy || r.y + r.height > maxy || r.x < originx ||
r.x + r.width > maxx) {
if (r.y < originy || r.y + r.height > maxy - wxSYS_HSCROLL_Y || r.x < originx ||
r.x + r.width > maxx - wxSYS_VSCROLL_X) {
int curx, cury;
sw->GetViewStart(&curx, &cury);
sw->SetScrollbars(1, 1, layoutxs, layoutys,
r.width > canvasw || r.x < originx
r.width > canvasw - wxSYS_VSCROLL_X || r.x < originx
? r.x
: r.x + r.width > maxx ? r.x + r.width - canvasw : curx,
r.height > canvash || r.y < originy
: r.x + r.width > maxx - wxSYS_VSCROLL_X ? r.x + r.width - canvasw + wxSYS_VSCROLL_X: curx,
r.height > canvash - wxSYS_HSCROLL_Y || r.y < originy
? r.y
: r.y + r.height > maxy ? r.y + r.height - canvash : cury,
: r.y + r.height > maxy - wxSYS_HSCROLL_Y ? r.y + r.height - canvash + wxSYS_HSCROLL_Y : cury,
true);
RefreshReset();
return true;
Expand Down

0 comments on commit 6ddf93b

Please sign in to comment.