mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +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,16 +1783,26 @@ 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()
|
||||||
width = width + iconwidth + loveframes.basicfont:getWidth(object.text) + leftpadding
|
|
||||||
love.graphics.setColor(255, 255, 255, 255)
|
|
||||||
love.graphics.draw(icon, x + leftpadding, object.y)
|
|
||||||
love.graphics.setFont(loveframes.basicfont)
|
|
||||||
love.graphics.setColor(0, 0, 0, 255)
|
|
||||||
love.graphics.print(object.text, x + leftpadding + 2 + iconwidth, object.y + 2)
|
|
||||||
end
|
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
|
||||||
|
love.graphics.setColor(255, 255, 255, 255)
|
||||||
|
love.graphics.draw(icon, x + leftpadding, object.y)
|
||||||
|
love.graphics.setFont(loveframes.basicfont)
|
||||||
|
love.graphics.setColor(0, 0, 0, 255)
|
||||||
|
love.graphics.print(object.text, x + leftpadding + 2 + iconwidth, object.y + 2)
|
||||||
|
|
||||||
object:SetWidth(width + 5)
|
object:SetWidth(width + 5)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user