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

treeview: add horizontal scrolling #1717

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
treeview: Fix broken click/hover when scrolled
  • Loading branch information
takase1121 committed Feb 4, 2024
commit 892bd6a5f885b646b0c844b1852088330d46952a
7 changes: 4 additions & 3 deletions data/plugins/treeview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,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

Expand Down Expand Up @@ -455,6 +455,7 @@ function TreeView:draw()
local active_filename = doc and system.absolute_path(doc.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(
Expand All @@ -463,9 +464,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
Expand Down Expand Up @@ -524,7 +526,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
Expand Down
Loading