Fix #1538 log scrolls automatically (the real PR) (#1546)

* fix #1538 log scrolls automatically

adds:
- when user scrolls, position is kept no matter how many new entries
arrive
- when user scrolls up to last entry, autoscroll is enabled again

does not add buttons to jump up/down
see #1538

* move scroll-test out of on_mouse_wheel

* determine diff_index with loop

* remove check at move_towards yoffset

* use while loop instead of repeat loop

* remove meaningless setter

* remove stray var
This commit is contained in:
Luke aka SwissalpS 2023-06-28 03:05:03 +02:00 committed by takase1121
parent bd53bc3718
commit b5617a3eef
No known key found for this signature in database
GPG Key ID: 60EEFFC68EB3031B
1 changed files with 12 additions and 2 deletions

View File

@ -125,9 +125,19 @@ end
function LogView:update()
local item = core.log_items[#core.log_items]
if self.last_item ~= item then
local lh = style.font:get_height() + style.padding.y
if 0 < self.scroll.to.y then
local index = #core.log_items
while index > 1 and self.last_item ~= core.log_items[index] do
index = index - 1
end
local diff_index = #core.log_items - index
self.scroll.to.y = self.scroll.to.y + diff_index * lh
self.scroll.y = self.scroll.to.y
else
self.yoffset = -lh
end
self.last_item = item
self.scroll.to.y = 0
self.yoffset = -(style.font:get_height() + style.padding.y)
end
local expanding = self.expanding[1]