Merge pull request #1065 from Guldoman/PR_log_size

Increase `config.max_log_items`, add a scrollbar and optimize `LogView`
This commit is contained in:
Jefferson González 2022-07-05 18:07:33 -04:00 committed by GitHub
commit e646f2fb28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 31 deletions

View File

@ -1,7 +1,7 @@
local config = {}
config.fps = 60
config.max_log_items = 80
config.max_log_items = 800
config.message_timeout = 5
config.mouse_wheel_scroll = 50 * SCALE
config.animate_drag_scroll = false

View File

@ -1,5 +1,6 @@
local core = require "core"
local common = require "core.common"
local config = require "core.config"
local keymap = require "core.keymap"
local style = require "core.style"
local View = require "core.view"
@ -81,6 +82,19 @@ function LogView:each_item()
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)
if LogView.super.on_mouse_pressed(self, button, px, py, clicks) then
return true
@ -154,6 +168,7 @@ function LogView:draw()
local tw = style.font:get_width(datestr)
for _, item, x, y, w, h in self:each_item() do
if y + h >= self.position.y and y <= self.position.y + self.size.y then
core.push_clip_rect(x, y, w, h)
x = x + style.padding.x
@ -193,6 +208,8 @@ function LogView:draw()
core.pop_clip_rect()
end
end
LogView.super.draw_scrollbar(self)
end