First preliminary implementation of treeview resize
Works but only cover resize along x.
This commit is contained in:
parent
a8c810d801
commit
e69d201e1b
|
@ -108,8 +108,9 @@ function Node:split(dir, view, locked)
|
|||
end
|
||||
if dir == "up" or dir == "left" then
|
||||
self.a, self.b = self.b, self.a
|
||||
return self.a
|
||||
end
|
||||
return child
|
||||
return self.b
|
||||
end
|
||||
|
||||
|
||||
|
@ -520,6 +521,13 @@ function RootView:on_mouse_moved(x, y, dx, dy)
|
|||
if self.dragged_divider then
|
||||
local node = self.dragged_divider
|
||||
if node.type == "hsplit" then
|
||||
if node.a.resizable then
|
||||
local size = node.a.active_view.size
|
||||
size.x = size.x + dx
|
||||
elseif node.b.resizable then
|
||||
local size = node.b.active_view.size
|
||||
size.x = size.x + dx
|
||||
end
|
||||
node.divider = node.divider + dx / node.size.x
|
||||
else
|
||||
node.divider = node.divider + dy / node.size.y
|
||||
|
|
|
@ -188,8 +188,6 @@ function TreeView:update()
|
|||
if self.init_size then
|
||||
self.size.x = dest
|
||||
self.init_size = false
|
||||
else
|
||||
self:move_towards(self.size, "x", dest)
|
||||
end
|
||||
|
||||
TreeView.super.update(self)
|
||||
|
@ -251,7 +249,9 @@ end
|
|||
-- init
|
||||
local view = TreeView()
|
||||
local node = core.root_view:get_active_node()
|
||||
node:split("left", view, true)
|
||||
local treeview_node = node:split("left", view, true)
|
||||
treeview_node.resizable = true
|
||||
|
||||
|
||||
-- register commands and keymap
|
||||
command.add(nil, {
|
||||
|
|
Loading…
Reference in New Issue