StanfordLegion / prof-viewer

Legion Prof Viewer
Apache License 2.0
0 stars 5 forks source link

Arrows for vertical scroll #33

Closed bryevdv closed 10 months ago

bryevdv commented 1 year ago

@lightsighter has requested that up/down arrows also be usable, in order to scroll the panel of plots up and down.

lightsighter commented 1 year ago

Not a high priority, but since we have horizontal movement with the arrows, I found myself wanting to do the same thing with the vertical arrows.

bryevdv commented 1 year ago

This seems achievable using config.scroll_to_item by searching for any next / previous item to assign, but I was going to look into whether the UI viewport could just be generically scrolled programatically.

elliottslaughter commented 1 year ago

I would not use the scroll_to_item code directly, but I think it's an illustrative example of how to accomplish a programmatic vertical scroll. Here's the relevant code:

https://github.com/StanfordLegion/prof-viewer/blob/6417711efc2e5de90879037d19561fa5e88c169c/src/app.rs#L1372-L1380

The relevant API is ui.scroll_to_rect which can be given any rectangle, not just ones concerning a specific item. So all we need to do is calculate the appropriate rectangle to scroll to (whether an item is there or not) and figure out the most elegant way to thread that information through the system.