+20
-9
data/core/rootview.lua
+20
-9
data/core/rootview.lua
···
9
9
10
10
local EmptyView = View:extend()
11
11
12
-
function EmptyView:draw()
13
-
self:draw_background(style.background)
14
-
local pos = self.position
15
-
local x, y, w, h = pos.x, pos.y, self.size.x, self.size.y
16
-
local _, y = common.draw_text(style.big_font, style.dim, "lite", "center", x, y, w, h)
12
+
local function draw_text(x, y, color)
13
+
local th = style.big_font:get_height()
14
+
local dh = th + style.padding.y * 2
15
+
x = renderer.draw_text(style.big_font, "lite", x, y + (dh - th) / 2, color)
16
+
x = x + style.padding.x
17
+
renderer.draw_rect(x, y, math.ceil(1 * SCALE), dh, color)
17
18
local lines = {
18
19
{ fmt = "%s to run a command", cmd = "core:find-command" },
19
20
{ fmt = "%s to open a file from the project", cmd = "core:find-file" },
20
21
}
21
-
local th = style.font:get_height()
22
+
th = style.font:get_height()
23
+
y = y + (dh - th * 2 - style.padding.y) / 2
24
+
local w = 0
22
25
for _, line in ipairs(lines) do
23
26
local text = string.format(line.fmt, keymap.get_binding(line.cmd))
24
-
y = y + style.padding.y
25
-
common.draw_text(style.font, style.dim, text, "center", x, y, w, th)
26
-
y = y + th
27
+
w = math.max(w, renderer.draw_text(style.font, text, x + style.padding.x, y, color))
28
+
y = y + th + style.padding.y
27
29
end
30
+
return w, dh
31
+
end
32
+
33
+
function EmptyView:draw()
34
+
self:draw_background(style.background)
35
+
local w, h = draw_text(0, 0, { 0, 0, 0, 0 })
36
+
local x = self.position.x + math.max(style.padding.x, (self.size.x - w) / 2)
37
+
local y = self.position.y + (self.size.y - h) / 2
38
+
draw_text(x, y, style.dim)
28
39
end
29
40
30
41