Avoid drawing hidden `TreeView` items

This commit is contained in:
Guldoman 2021-12-07 21:45:20 +01:00
parent fdb29f28cf
commit c16d6b3d8d
No known key found for this signature in database
GPG Key ID: C08A498EC7F1AFDD
1 changed files with 7 additions and 4 deletions

View File

@ -366,15 +366,18 @@ end
function TreeView:draw()
self:draw_background(style.background2)
local _y, _h = self.position.y, self.size.y
local doc = core.active_view.doc
local active_filename = doc and system.absolute_path(doc.filename or "")
for item, x,y,w,h in self:each_item() do
self:draw_item(item,
item.abs_filename == active_filename,
item == self.hovered_item,
x, y, w, h)
if y + h >= _y and y < _y + _h then
self:draw_item(item,
item.abs_filename == active_filename,
item == self.hovered_item,
x, y, w, h)
end
end
self:draw_scrollbar()