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
|
end
|
||||||
if dir == "up" or dir == "left" then
|
if dir == "up" or dir == "left" then
|
||||||
self.a, self.b = self.b, self.a
|
self.a, self.b = self.b, self.a
|
||||||
|
return self.a
|
||||||
end
|
end
|
||||||
return child
|
return self.b
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -520,6 +521,13 @@ function RootView:on_mouse_moved(x, y, dx, dy)
|
||||||
if self.dragged_divider then
|
if self.dragged_divider then
|
||||||
local node = self.dragged_divider
|
local node = self.dragged_divider
|
||||||
if node.type == "hsplit" then
|
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
|
node.divider = node.divider + dx / node.size.x
|
||||||
else
|
else
|
||||||
node.divider = node.divider + dy / node.size.y
|
node.divider = node.divider + dy / node.size.y
|
||||||
|
|
|
@ -188,8 +188,6 @@ function TreeView:update()
|
||||||
if self.init_size then
|
if self.init_size then
|
||||||
self.size.x = dest
|
self.size.x = dest
|
||||||
self.init_size = false
|
self.init_size = false
|
||||||
else
|
|
||||||
self:move_towards(self.size, "x", dest)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
TreeView.super.update(self)
|
TreeView.super.update(self)
|
||||||
|
@ -251,7 +249,9 @@ end
|
||||||
-- init
|
-- init
|
||||||
local view = TreeView()
|
local view = TreeView()
|
||||||
local node = core.root_view:get_active_node()
|
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
|
-- register commands and keymap
|
||||||
command.add(nil, {
|
command.add(nil, {
|
||||||
|
|
Loading…
Reference in New Issue