Small cleanup of `scale` plugin

This commit is contained in:
Guldoman 2021-10-02 03:24:35 +02:00
parent ab0ca031fa
commit 3b280401e4
No known key found for this signature in database
GPG Key ID: C08A498EC7F1AFDD
1 changed files with 3 additions and 12 deletions

View File

@ -13,9 +13,6 @@ config.plugins.scale = {
use_mousewheel = true use_mousewheel = true
} }
local MINIMUM_SCALE = 0.25;
local scale_level = 0
local scale_steps = 0.05 local scale_steps = 0.05
local current_scale = SCALE local current_scale = SCALE
@ -36,9 +33,6 @@ local function set_scale(scale)
local s = scale / current_scale local s = scale / current_scale
current_scale = scale current_scale = scale
-- we set scale_level in case this was called by user
scale_level = (scale - default_scale) / scale_steps
if config.plugins.scale.mode == "ui" then if config.plugins.scale.mode == "ui" then
SCALE = scale SCALE = scale
@ -85,18 +79,15 @@ function RootView:on_mouse_wheel(d, ...)
end end
local function res_scale() local function res_scale()
scale_level = 0
set_scale(default_scale) set_scale(default_scale)
end end
local function inc_scale() local function inc_scale()
scale_level = scale_level + 1 set_scale(current_scale + scale_steps)
set_scale(default_scale + scale_level * scale_steps)
end end
local function dec_scale() local function dec_scale()
scale_level = scale_level - 1 set_scale(current_scale - scale_steps)
set_scale(math.max(default_scale + scale_level * scale_steps), MINIMUM_SCALE)
end end