`LogView`: Show scrollbar

This commit is contained in:
Guldoman 2022-07-01 05:28:56 +02:00
parent b84a510d42
commit 7888bf08e9
No known key found for this signature in database
GPG Key ID: EA928C8BDA1A8825
1 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,6 @@
local core = require "core" local core = require "core"
local common = require "core.common" local common = require "core.common"
local config = require "core.config"
local keymap = require "core.keymap" local keymap = require "core.keymap"
local style = require "core.style" local style = require "core.style"
local View = require "core.view" local View = require "core.view"
@ -81,6 +82,19 @@ function LogView:each_item()
end end
function LogView:get_scrollable_size()
local _, y_off = self:get_content_offset()
local last_y, last_h = 0, 0
for i, item, x, y, w, h in self:each_item() do
last_y, last_h = y, h
end
if not config.scroll_past_end then
return last_y + last_h - y_off + style.padding.y
end
return last_y + self.size.y - y_off
end
function LogView:on_mouse_pressed(button, px, py, clicks) function LogView:on_mouse_pressed(button, px, py, clicks)
if LogView.super.on_mouse_pressed(self, button, px, py, clicks) then if LogView.super.on_mouse_pressed(self, button, px, py, clicks) then
return true return true
@ -195,6 +209,7 @@ function LogView:draw()
core.pop_clip_rect() core.pop_clip_rect()
end end
end end
LogView.super.draw_scrollbar(self)
end end