Fix resize behavior of treeview and toolbar
Now toolbarview always compute up-to-date sizes and spacing to adapt to changes in icon big font. For treeview and toolbarview revert the goto_size approach to use the original approach of rxi/lite. In order to make it work when user resizes dragging the divider we use the view optional method set_target_size(). This latter changes the view's target size instead of changing its size right away. The size is only changed by the lite's layout and animation system. Remove the config.treeview_size variable that was no longer working because plugins are loaded before the user's config.
This commit is contained in:
@@ -4,10 +4,6 @@ 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 toolbar_spacing = icon_w / 2
|
||||
local toolbar_height = icon_h + style.padding.y * 2
|
||||
|
||||
local ToolbarView = View:extend()
|
||||
|
||||
local toolbar_commands = {
|
||||
@@ -20,36 +16,39 @@ local toolbar_commands = {
|
||||
}
|
||||
|
||||
|
||||
local function toolbar_height()
|
||||
return style.icon_big_font:get_height() + style.padding.y * 2
|
||||
end
|
||||
|
||||
|
||||
function ToolbarView:new()
|
||||
ToolbarView.super.new(self)
|
||||
self.visible = true
|
||||
self.init_size = toolbar_height
|
||||
self.init_size = true
|
||||
self.tooltip = false
|
||||
end
|
||||
|
||||
|
||||
function ToolbarView:update()
|
||||
local dest_size = self.visible and toolbar_height() or 0
|
||||
if self.init_size then
|
||||
self.size.y = self.init_size
|
||||
self.size.y = dest_size
|
||||
self.init_size = nil
|
||||
elseif self.goto_size then
|
||||
if self.goto_size ~= self.size.y then
|
||||
self:move_towards(self.size, "y", self.goto_size)
|
||||
else
|
||||
self.goto_size = nil
|
||||
end
|
||||
else
|
||||
self:move_towards(self.size, "y", dest_size)
|
||||
end
|
||||
ToolbarView.super.update(self)
|
||||
end
|
||||
|
||||
|
||||
function ToolbarView:toggle_visible()
|
||||
self.goto_size = self.visible and 0 or toolbar_height
|
||||
self.visible = not self.visible
|
||||
end
|
||||
|
||||
|
||||
function ToolbarView:each_item()
|
||||
local icon_h, icon_w = style.icon_big_font:get_height(), style.icon_big_font:get_width("D")
|
||||
local toolbar_spacing = icon_w / 2
|
||||
local ox, oy = self:get_content_offset()
|
||||
local index = 0
|
||||
local iter = function()
|
||||
@@ -68,9 +67,9 @@ end
|
||||
function ToolbarView:draw()
|
||||
self:draw_background(style.background2)
|
||||
|
||||
for item, x, y in self:each_item() do
|
||||
for item, x, y, w, h in self:each_item() do
|
||||
local color = item == self.hovered_item and style.text or style.dim
|
||||
common.draw_text(style.icon_big_font, color, item.symbol, nil, x, y, 0, icon_h)
|
||||
common.draw_text(style.icon_big_font, color, item.symbol, nil, x, y, 0, h)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user