Improved RootView's EmptyView
This commit is contained in:
parent
db8c5ea2aa
commit
508b6fb73a
|
@ -9,22 +9,33 @@ local DocView = require "core.docview"
|
||||||
|
|
||||||
local EmptyView = View:extend()
|
local EmptyView = View:extend()
|
||||||
|
|
||||||
function EmptyView:draw()
|
local function draw_text(x, y, color)
|
||||||
self:draw_background(style.background)
|
local th = style.big_font:get_height()
|
||||||
local pos = self.position
|
local dh = th + style.padding.y * 2
|
||||||
local x, y, w, h = pos.x, pos.y, self.size.x, self.size.y
|
x = renderer.draw_text(style.big_font, "lite", x, y + (dh - th) / 2, color)
|
||||||
local _, y = common.draw_text(style.big_font, style.dim, "lite", "center", x, y, w, h)
|
x = x + style.padding.x
|
||||||
|
renderer.draw_rect(x, y, math.ceil(1 * SCALE), dh, color)
|
||||||
local lines = {
|
local lines = {
|
||||||
{ fmt = "%s to run a command", cmd = "core:find-command" },
|
{ 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 open a file from the project", cmd = "core:find-file" },
|
||||||
}
|
}
|
||||||
local th = style.font:get_height()
|
th = style.font:get_height()
|
||||||
|
y = y + (dh - th * 2 - style.padding.y) / 2
|
||||||
|
local w = 0
|
||||||
for _, line in ipairs(lines) do
|
for _, line in ipairs(lines) do
|
||||||
local text = string.format(line.fmt, keymap.get_binding(line.cmd))
|
local text = string.format(line.fmt, keymap.get_binding(line.cmd))
|
||||||
y = y + style.padding.y
|
w = math.max(w, renderer.draw_text(style.font, text, x + style.padding.x, y, color))
|
||||||
common.draw_text(style.font, style.dim, text, "center", x, y, w, th)
|
y = y + th + style.padding.y
|
||||||
y = y + th
|
|
||||||
end
|
end
|
||||||
|
return w, dh
|
||||||
|
end
|
||||||
|
|
||||||
|
function EmptyView:draw()
|
||||||
|
self:draw_background(style.background)
|
||||||
|
local w, h = draw_text(0, 0, { 0, 0, 0, 0 })
|
||||||
|
local x = self.position.x + math.max(style.padding.x, (self.size.x - w) / 2)
|
||||||
|
local y = self.position.y + (self.size.y - h) / 2
|
||||||
|
draw_text(x, y, style.dim)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue