mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-12-11 07:24:24 +00:00
Add functionality for selecting tree nodes
This commit is contained in:
parent
4710c44bb7
commit
53894a743c
@ -152,6 +152,10 @@ function newobject:mousepressed(x, y, button)
|
|||||||
v:mousepressed(x, y, button)
|
v:mousepressed(x, y, button)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.hover and button == "l" then
|
||||||
|
self.tree.selectednode = self
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
|
@ -25,6 +25,7 @@ function newobject:initialize()
|
|||||||
self.vbar = false
|
self.vbar = false
|
||||||
self.hbar = false
|
self.hbar = false
|
||||||
self.internal = false
|
self.internal = false
|
||||||
|
self.selectednode = false
|
||||||
self.children = {}
|
self.children = {}
|
||||||
self.internals = {}
|
self.internals = {}
|
||||||
|
|
||||||
|
@ -1783,15 +1783,25 @@ function skin.DrawTreeNode(object)
|
|||||||
leftpadding = buttonimage:getWidth() + 5
|
leftpadding = buttonimage:getWidth() + 5
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local iconwidth
|
||||||
if icon then
|
if icon then
|
||||||
local iconwidth = icon:getWidth()
|
iconwidth = icon:getWidth()
|
||||||
|
end
|
||||||
|
|
||||||
|
local twidth = loveframes.basicfont:getWidth(object.text)
|
||||||
|
local theight = loveframes.basicfont:getHeight(object.text)
|
||||||
|
|
||||||
|
if object.tree.selectednode == object then
|
||||||
|
love.graphics.setColor(102, 140, 255, 255)
|
||||||
|
love.graphics.rectangle("fill", x + leftpadding + 2 + iconwidth, object.y + 2, twidth, theight)
|
||||||
|
end
|
||||||
|
|
||||||
width = width + iconwidth + loveframes.basicfont:getWidth(object.text) + leftpadding
|
width = width + iconwidth + loveframes.basicfont:getWidth(object.text) + leftpadding
|
||||||
love.graphics.setColor(255, 255, 255, 255)
|
love.graphics.setColor(255, 255, 255, 255)
|
||||||
love.graphics.draw(icon, x + leftpadding, object.y)
|
love.graphics.draw(icon, x + leftpadding, object.y)
|
||||||
love.graphics.setFont(loveframes.basicfont)
|
love.graphics.setFont(loveframes.basicfont)
|
||||||
love.graphics.setColor(0, 0, 0, 255)
|
love.graphics.setColor(0, 0, 0, 255)
|
||||||
love.graphics.print(object.text, x + leftpadding + 2 + iconwidth, object.y + 2)
|
love.graphics.print(object.text, x + leftpadding + 2 + iconwidth, object.y + 2)
|
||||||
end
|
|
||||||
|
|
||||||
object:SetWidth(width + 5)
|
object:SetWidth(width + 5)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user