diff --git a/data/core/init.lua b/data/core/init.lua index 2f41d784..88819478 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -402,6 +402,10 @@ function core.init() local cur_node = core.root_view.root_node cur_node.is_primary_node = true cur_node = cur_node:split("down", core.command_view, true) + local got_toolbar, ToolbarView = core.try(require, "plugins.toolbarview") + if got_toolbar then + cur_node = cur_node:split("up", ToolbarView(), true) + end cur_node = cur_node:split("down", core.status_view, true) core.project_scan_thread_id = core.add_thread(project_scan_thread) diff --git a/data/core/style.lua b/data/core/style.lua index 1084540d..f5030484 100644 --- a/data/core/style.lua +++ b/data/core/style.lua @@ -23,7 +23,8 @@ style.tab_width = common.round(170 * SCALE) -- The antialiasing grayscale with full hinting is interesting for crisp font rendering. style.font = renderer.font.load(DATADIR .. "/fonts/font.ttf", 14 * SCALE) style.big_font = renderer.font.load(DATADIR .. "/fonts/font.ttf", 34 * SCALE) -style.icon_font = renderer.font.load(DATADIR .. "/fonts/icons.ttf", 14 * SCALE, {antialiasing="grayscale", hinting="full"}) +style.icon_font = renderer.font.load(DATADIR .. "/fonts/fontello.ttf", 14 * SCALE, {antialiasing="grayscale", hinting="full"}) +style.icon_big_font = renderer.font.load(DATADIR .. "/fonts/fontello.ttf", 20 * SCALE, {antialiasing="grayscale", hinting="full"}) style.code_font = renderer.font.load(DATADIR .. "/fonts/monospace.ttf", 13.5 * SCALE) style.background = { common.color "#2e2e32" } diff --git a/data/plugins/toolbar.lua b/data/plugins/toolbar.lua deleted file mode 100644 index adc11113..00000000 --- a/data/plugins/toolbar.lua +++ /dev/null @@ -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 - diff --git a/data/plugins/toolbarview.lua b/data/plugins/toolbarview.lua new file mode 100644 index 00000000..bf7574e9 --- /dev/null +++ b/data/plugins/toolbarview.lua @@ -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