fix: center title and version in emptyview (#1311)
* fix: divide by amount of lines
This commit is contained in:
parent
f5a224999a
commit
1984573214
|
@ -7,9 +7,15 @@ local View = require "core.view"
|
||||||
local EmptyView = View:extend()
|
local EmptyView = View:extend()
|
||||||
|
|
||||||
local function draw_text(x, y, color)
|
local function draw_text(x, y, color)
|
||||||
|
local lines = {
|
||||||
|
{ fmt = "%s to run a command", cmd = "core:find-command" },
|
||||||
|
{ fmt = "%s to open a file from the project", cmd = "core:find-file" },
|
||||||
|
{ fmt = "%s to change project folder", cmd = "core:change-project-folder" },
|
||||||
|
{ fmt = "%s to open a project folder", cmd = "core:open-project-folder" },
|
||||||
|
}
|
||||||
local th = style.big_font:get_height()
|
local th = style.big_font:get_height()
|
||||||
local dh = 2 * th + style.padding.y * 2
|
local dh = 2 * th + style.padding.y * 2
|
||||||
local x1, y1 = x, y + (dh - th) / 2
|
local x1, y1 = x, y + ((dh - th) / #lines)
|
||||||
local xv = x1
|
local xv = x1
|
||||||
local title = "Lite XL"
|
local title = "Lite XL"
|
||||||
local version = "version " .. VERSION
|
local version = "version " .. VERSION
|
||||||
|
@ -24,12 +30,6 @@ local function draw_text(x, y, color)
|
||||||
renderer.draw_text(style.font, version, xv, y1 + th, color)
|
renderer.draw_text(style.font, version, xv, y1 + th, color)
|
||||||
x = x + style.padding.x
|
x = x + style.padding.x
|
||||||
renderer.draw_rect(x, y, math.ceil(1 * SCALE), dh, color)
|
renderer.draw_rect(x, y, math.ceil(1 * SCALE), dh, color)
|
||||||
local lines = {
|
|
||||||
{ fmt = "%s to run a command", cmd = "core:find-command" },
|
|
||||||
{ fmt = "%s to open a file from the project", cmd = "core:find-file" },
|
|
||||||
{ fmt = "%s to change project folder", cmd = "core:change-project-folder" },
|
|
||||||
{ fmt = "%s to open a project folder", cmd = "core:open-project-folder" },
|
|
||||||
}
|
|
||||||
th = style.font:get_height()
|
th = style.font:get_height()
|
||||||
y = y + (dh - (th + style.padding.y) * #lines) / 2
|
y = y + (dh - (th + style.padding.y) * #lines) / 2
|
||||||
local w = 0
|
local w = 0
|
||||||
|
|
Loading…
Reference in New Issue