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

Refactor scrollbar into its own file #1124

Merged
merged 12 commits into from
Oct 16, 2022

Conversation

Guldoman
Copy link
Member

@Guldoman Guldoman commented Sep 22, 2022

This PR moves the scrollbar code to its own file.
The scrollbar can be arranged vertically or horizontally, at the start or the end of a View.
This PR also makes the DocView infinitely scrollable horizontally. Actual accurate scrolling will come in the future.

To test how the scrollbar would behave in the DocView, change the return value of DocView:get_h_scrollable_size to something like 5000.

Plugins that touch the scrollbar will likely need to be updated.

Fixes #950.

Edit:
This also slightly changes how the scrollbars behave in regards to click+drag on the track, as well as how the offset to the initial drag position is kept when going over the position limits (try dragging the thumb all the way to the top and over, then going back to the middle of the view, compare between master and this PR).

@jgmdev
Copy link
Member

jgmdev commented Sep 23, 2022

Gave it a test run and so far:

  • Pressing End on long lines no longer scrolls the document to right.
  • Clicking and dragging on long line no longer scrolls to right
  • Shift + Scroll (aka root:horizontal-scroll) doesn't scrolls
  • Breaks minimap (for future reference)
  • Doing the suggested function DocView:get_h_scrollable_size() return 5000 end doesn't seems to have any effect, no scrollbar is drawn.

@Guldoman Guldoman force-pushed the PR_scrollbar_refactor branch from b02df8b to 5f26836 Compare September 23, 2022 18:09
@Guldoman
Copy link
Member Author

Fixed copy-paste mistake. Please test again.

@jgmdev
Copy link
Member

jgmdev commented Sep 25, 2022

Tested again, looking and working pretty good now :), also pretty interesting feature the new alignment, looks pretty handy for languages written from right to left on a future that lite-xl could support that, for reference here is how it looks the opposite alignment for those peeking at this PR:

scrollbar-alignment

With latest correction I haven't found any faults. I tested plugins which the projectsearch told me do scrollbar stuff and this is what I have found:

  • dragdropselected (works but highlights lines while dragging which doesn't seems to be related to this PR)
  • extend_selection_line (works)
  • markers (works)
  • minimap (scrolling is broken, also shouldn't hide horizontal scrollbar)
  • regexreplacepreview (works)
  • settings (needs adjustments on widgets library but works mostly)
  • smoothcaret (works)
  • unboundscroll (seems to do what it should?)

@Guldoman Guldoman force-pushed the PR_scrollbar_refactor branch from 35776ab to 1666bab Compare October 16, 2022 00:04
@jgmdev
Copy link
Member

jgmdev commented Oct 16, 2022

This implementation looks nice and clean and I have already added support to https://github.com/lite-xl/lite-xl-widgets on a local branch without any major issues. Now only minimap needs to be fixed which may be done over the course of the week by @adamdharrison or @Guldoman (whoever does it first) and as Guldo pointed add support for new horizontal scrollbar on the treeview by whoever wants to tackle it first. Merging this and slowly retiring to watch from the distance 🏃

@jgmdev jgmdev merged commit 6b754eb into lite-xl:master Oct 16, 2022
takase1121 pushed a commit to takase1121/lite-xl that referenced this pull request Nov 14, 2022
* Move scrollbar to its own file
* Don't call `Scrollbar` functions if `View` is not scrollable
* Allow horizontal scrolling in `Scrollbar`
* Add horizontal scrollbar to `View`
* Add `root:horizontal-scroll` command with `shift+wheel` keymap
* Prioritize vertical scrollbar hover
* Don't send mouse movement to vertical scrollbar when dragging horizontal one
* Fix clicking on horizontal scrollbar track
* Implement `start` scrollbar alignment
* Add documentation to `Scrollbar`
* Make `DocView` infinitely scrollable horizontally
* Handle horizontal scroll SDL event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: allow sideways scroll
2 participants