-
Notifications
You must be signed in to change notification settings - Fork 239
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
treeview: add horizontal scrolling #1717
base: master
Are you sure you want to change the base?
Conversation
This is taken from Pragtical but I wasn't able to cherry pick the commit, so I ended up recreating it. Co-authored-by: Jefferson González <jgmdev@gmail.com>
A few issues:
Edit:
|
Prevent resetting h scrollbar position when not needed, always allow clicking an item to its right: diff --git a/data/plugins/treeview.lua b/data/plugins/treeview.lua
index fb0aee30..20d30768 100644
--- a/data/plugins/treeview.lua
+++ b/data/plugins/treeview.lua
@@ -254,7 +254,7 @@ function TreeView:on_mouse_moved(px, py, ...)
local item_changed, tooltip_changed
for item, x,y,w,h in self:each_item() do
- if px > x and py > y and px <= x + w and py <= y + h then
+ if px > x and py > y and px <= self.size.x and py <= y + h then
item_changed = true
self.hovered_item = item
@@ -445,7 +445,7 @@ function TreeView:draw()
local doc = core.active_view.doc
local active_filename = doc and core.project_absolute_path(doc.abs_filename or "")
- local ox = math.abs(self:get_content_offset())
+ local sw, ox = 0, math.abs(self:get_content_offset())
for item, x,y,w,h in self:each_item() do
if y + h >= _y and y < _y + _h then
local w = self:draw_item(
@@ -454,9 +454,10 @@ function TreeView:draw()
item == self.hovered_item,
x, y, w, h
) + ox
- self.scroll_width = math.max(w, self.scroll_width)
+ sw = math.max(w, sw)
end
end
+ self.scroll_width = sw
self:draw_scrollbar()
if self.hovered_item and self.tooltip.x and self.tooltip.alpha > 0 then
@@ -515,7 +516,6 @@ function TreeView:toggle_expand(toggle, item)
if not item then return end
if item.type == "dir" then
- self.scroll_width = 0
if type(toggle) == "boolean" then
item.expanded = toggle
else |
Only remaining issue is that the horizontal scroll position changes while scrolling vertically, when the maximum scrollable size becomes smaller than the current position. If we want to keep the behavior that limits the maximum scroll size to the visible items, we should avoid setting it to a value lower than the current scroll position, and only adjust it when the user actually horizontally scrolls to below the max. |
Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
About waiting until the user releases the scrollbar to reduce the scrollable size: Without waiting: Video.del.2024-02-28.04-35-41.webmWaiting: Video.del.2024-02-28.04-36-19.webmWhat do you think? and not self.h_scrollbar.dragging here lite-xl/data/plugins/treeview.lua Line 474 in a68a456
|
I think waiting is the way to go, not waiting is just a bit weird. |
Mmm, it looks like we need a Video.del.2024-02-29.03-59-30.webm |
This is taken from Pragtical but I wasn't able to cherry pick the commit, so I ended up recreating it.