Show a dummy toolbar

Does not do anything for the moment
This commit is contained in:
Francesco Abbate
2021-02-12 15:54:11 +01:00
parent 7137f88b4c
commit 2765cbd92b
4 changed files with 66 additions and 34 deletions
-33
View File
@@ -1,33 +0,0 @@
local core = require "core"
local common = require "core.common"
local command = require "core.command"
-- local config = require "core.config"
local style = require "core.style"
-- local DocView = require "core.docview"
local View = require "core.view"
local ToolbarView = View:extend()
local toolbar_commands = {
{"f", "core:open-file"},
{"S", "doc:save"},
{"L", "core:find-file"},
}
function ToolbarView:new()
ToolbarView.super.new(self)
end
function ToolbarView:update()
self.size.y = style.icon_font:get_height() + style.padding.y * 2
if system.get_time() < self.message_timeout then
self.scroll.to.y = self.size.y
else
self.scroll.to.y = 0
end
ToolbarView.super.update(self)
end
+60
View File
@@ -0,0 +1,60 @@
local core = require "core"
local common = require "core.common"
local command = require "core.command"
local style = require "core.style"
local View = require "core.view"
local icon_h, icon_w = style.icon_big_font:get_height(), style.icon_big_font:get_width("D")
local spacing = {
margin = {x = icon_w / 2, y = icon_h / 3},
padding = {x = icon_w / 2, y = 0},
}
local ToolbarView = View:extend()
local toolbar_commands = {
{"f", "core:open-file"},
{"S", "doc:save"},
{"L", "core:find-file"},
}
function ToolbarView:new()
ToolbarView.super.new(self)
end
function ToolbarView:update()
self.size.x = (icon_w + spacing.padding.x) * #toolbar_commands - spacing.padding.x + 2 * spacing.margin.x
self.size.y = style.icon_big_font:get_height() + style.padding.y * 2
ToolbarView.super.update(self)
end
function ToolbarView:draw()
self:draw_background(style.background2)
local x, y = self:get_content_offset()
x = x + spacing.margin.x
for i, item in ipairs(toolbar_commands) do
x = common.draw_text(style.icon_big_font, style.text, item[1], nil, x, y, 0, self.size.y)
x = x + spacing.padding.x
end
end
-- init
if false then
local view = ToolbarView()
local node = core.root_view:get_active_node()
node:split("up", view, true)
end
-- register commands and keymap
--[[command.add(nil, {
["toolbar:toggle"] = function()
view.visible = not view.visible
end,
})
keymap.add { ["ctrl+\\"] = "treeview:toggle" }
]]
return ToolbarView