Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve scrolling in icon views #711

Closed
inexorabletash opened this issue Aug 27, 2022 · 1 comment
Closed

Improve scrolling in icon views #711

inexorabletash opened this issue Aug 27, 2022 · 1 comment
Labels
bug DeskTop DeskTop bugs or feature requests root-cause-identified
Milestone

Comments

@inexorabletash
Copy link
Collaborator

In DeskTop, the scrollbars always have a thumbmax of 20 (see desktop/main.s CreateIconsForWindow) and the scroll bar arrows scroll by 1/20th of the range at a time. This means if the icon bounds are only e.g. 40 pixels larger than the viewport, each scroll tick is 2 pixels, which is really slow.

To improve this, the max should be dynamic and based on comparing the icon bbox and viewport, and then each scroll tick should be a fixed number of pixels instead.

Beware of edge cases when the icon bbox is offset from the view (e.g. potentially even smaller); the effective bounds probably need to be the bounding rect containing both the icon bbox and the viewport.

@inexorabletash inexorabletash added bug DeskTop DeskTop bugs or feature requests root-cause-identified labels Aug 27, 2022
@inexorabletash inexorabletash added this to the 1.3 milestone Aug 27, 2022
@inexorabletash
Copy link
Collaborator Author

inexorabletash commented Sep 4, 2022

Psuedocode for the algorithm I think we want:

Inputs:

  • icon bbox (lo/hi in window space)
  • viewport (lo/hi in window space)
  • ubox (union of icon bbox / viewport) - necessary for edge cases
  • tick (pixels, different in x and y coords, maybe 32 / 16)
  • thumb.pos
  • thumb.max (can be anything... use 255 for full precision?)

Preamble:

  • w = vp.hi - vp.lo
  • old = vp.lo

Switch on action:

  • arrow inc:
    1. vp.hi += tick
    2. goto clamp_hi
  • arrow dec:
    1. vp.lo -= tick;
    2. goto clamp_lo
  • page inc:
    1. vp.hi += w (maybe w - tick?)
    2. goto clamp_hi
  • page dec:
    1. vp.lo -= w (maybe w - tick?)
    2. goto clamp_lo
  • thumb:
    1. vp.lo = ubox.lo + (ubox.hi - ubox.lo - w) * (newpos / thumb.max)
    2. vp.hi = vp.lo + w
    3. goto update
  • resize or content change:
    1. newpos = (vp.lo - ubox.lo) / (ubox.hi - ubox.lo - w) * thumb.max
    2. if newpos != thumb.pos: update thumb

clamp_hi:

  1. if vp.hi > ubox.hi
    1. vp.hi = ubox.hi
  2. vp.lo = vp.hi - w
  3. goto update

clamp_lo:

  1. if vp.lo < ubox.lo
    1. vp.lo = ubox.lo
  2. vp.hi = vp.lo + w
  3. goto update

update:

  1. if vp.lo != old:
    1. newpos = (vp.lo - ubox.lo) / (ubox.hi - ubox.lo - w) * thumb.max
    2. if newpos != thumb.pos: update thumb
  2. redraw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug DeskTop DeskTop bugs or feature requests root-cause-identified
Projects
None yet
Development

No branches or pull requests

1 participant