mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-12-11 07:24:24 +00:00
Version 0.9.5.12 - Alpha (see changelog.txt)
This commit is contained in:
parent
76c6846201
commit
0b5cdb6697
@ -1,3 +1,25 @@
|
||||
================================================
|
||||
Version 0.9.5.12 - Alpha (June 10 - 2013)
|
||||
================================================
|
||||
[ADDED] a new columnlist method: SelectRow(row, ctrl)
|
||||
[ADDED] a new columnlist method: DeselectRow(row)
|
||||
[ADDED] a new columnlist method: GetSelectedRows()
|
||||
[ADDED] a new columnlist method: SetSelectionEnabled(bool)
|
||||
[ADDED] a new columnlist method: GetSelectionEnabled()
|
||||
[ADDED] a new columnlist method: SetMultiselectEnabled(bool)
|
||||
[ADDED] a new columnlist method: GetMultiselectEnabled()
|
||||
[ADDED] a new columnlistrow method: SetSelected(bool)
|
||||
[ADDED] a new columnlistrow method: GetSelected()
|
||||
[ADDED] a new columnlistrow method: SetColumnData(data)
|
||||
[ADDED] a new columnlist event callback: OnRowRightClicked(parent, row, data)
|
||||
[ADDED] a new columnlist event callback: OnRowSelected(parent, row, data)
|
||||
[ADDED] a new util library function: GetCollisionCount()
|
||||
[ADDED] a new util library function: GetHover()
|
||||
|
||||
[CHANGED] the default mousewheel scroll-amount value for the list object
|
||||
[CHANGED] the list object no longer uses delta time for scrolling by default
|
||||
[CHANGED] some of the columnlistrow object's colors in the default skins
|
||||
|
||||
================================================
|
||||
Version 0.9.5.11 - Alpha (May 15 - 2013)
|
||||
================================================
|
||||
|
10
init.lua
10
init.lua
@ -3,7 +3,6 @@
|
||||
-- Copyright (c) 2013 Kenny Shields --
|
||||
--]]------------------------------------------------
|
||||
|
||||
--
|
||||
local path = ...
|
||||
|
||||
-- central library table
|
||||
@ -12,7 +11,7 @@ loveframes = {}
|
||||
-- library info
|
||||
loveframes.info = {}
|
||||
loveframes.info.author = "Kenny Shields"
|
||||
loveframes.info.version = "0.9.5.11"
|
||||
loveframes.info.version = "0.9.5.12"
|
||||
loveframes.info.stage = "Alpha"
|
||||
|
||||
-- library configurations
|
||||
@ -26,9 +25,11 @@ loveframes.config["DEBUG"] = false
|
||||
-- misc library vars
|
||||
loveframes.state = "none"
|
||||
loveframes.drawcount = 0
|
||||
loveframes.collisioncount = 0
|
||||
loveframes.hoverobject = false
|
||||
loveframes.modalobject = false
|
||||
loveframes.inputobject = false
|
||||
loveframes.hover = false
|
||||
loveframes.basicfont = love.graphics.newFont(12)
|
||||
loveframes.basicfontsmall = love.graphics.newFont(10)
|
||||
loveframes.objects = {}
|
||||
@ -92,6 +93,9 @@ end
|
||||
function loveframes.update(dt)
|
||||
|
||||
local base = loveframes.base
|
||||
|
||||
loveframes.collisioncount = 0
|
||||
loveframes.hover = false
|
||||
base:update(dt)
|
||||
|
||||
end
|
||||
@ -239,7 +243,7 @@ function loveframes.Create(data, parent)
|
||||
-- to the current object
|
||||
for i, j in pairs(v) do
|
||||
if i ~= "children" and i ~= "func" then
|
||||
if child == true then
|
||||
if child then
|
||||
if i == "x" then
|
||||
object["staticx"] = j
|
||||
elseif i == "y" then
|
||||
|
@ -732,10 +732,12 @@ function newobject:CheckHover()
|
||||
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
|
||||
local hoverobject = loveframes.hoverobject
|
||||
local modalobject = loveframes.modalobject
|
||||
local collisioncount = loveframes.collisioncount
|
||||
local clickbounds = self.clickbounds
|
||||
|
||||
-- is the mouse inside the object?
|
||||
if selfcol then
|
||||
loveframes.collisioncount = collisioncount + 1
|
||||
local top = self:IsTopCollision()
|
||||
if top then
|
||||
if not hoverobject then
|
||||
@ -773,6 +775,7 @@ function newobject:CheckHover()
|
||||
|
||||
-- this chunk of code handles mouse enter and exit
|
||||
if self.hover then
|
||||
loveframes.hover = true
|
||||
if not self.calledmousefunc then
|
||||
if self.OnMouseEnter then
|
||||
self.OnMouseEnter(self)
|
||||
|
@ -21,9 +21,13 @@ function newobject:initialize()
|
||||
self.autoscroll = false
|
||||
self.dtscrolling = true
|
||||
self.internal = false
|
||||
self.selectionenabled = true
|
||||
self.multiselect = false
|
||||
self.children = {}
|
||||
self.internals = {}
|
||||
self.OnRowClicked = nil
|
||||
self.OnRowRightClicked = nil
|
||||
self.OnRowSelected = nil
|
||||
self.OnScroll = nil
|
||||
|
||||
local list = loveframes.objects["columnlistarea"]:new(self)
|
||||
@ -479,3 +483,113 @@ function newobject:GetDTScrolling()
|
||||
return self.dtscrolling
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SelectRow(row, ctrl)
|
||||
- desc: selects the specfied row in the object's list
|
||||
of rows
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SelectRow(row, ctrl)
|
||||
|
||||
local selectionenabled = self.selectionenabled
|
||||
|
||||
if not selectionenabled then
|
||||
return
|
||||
end
|
||||
|
||||
local list = self.internals[1]
|
||||
local children = list.children
|
||||
local multiselect = self.multiselect
|
||||
local onrowselected = self.OnRowSelected
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
if v == row then
|
||||
if v.selected and ctrl then
|
||||
v.selected = false
|
||||
else
|
||||
v.selected = true
|
||||
if onrowselected then
|
||||
onrowselected(self, row, row:GetColumnData())
|
||||
end
|
||||
end
|
||||
elseif v ~= row and not multiselect and not ctrl then
|
||||
v.selected = false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: DeselectRow(row)
|
||||
- desc: deselects the specfied row in the object's list
|
||||
of rows
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:DeselectRow(row)
|
||||
|
||||
row.selected = false
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetSelectedRows()
|
||||
- desc: gets the object's selected rows
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetSelectedRows()
|
||||
|
||||
local rows = {}
|
||||
local list = self.internals[1]
|
||||
local children = list.children
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
if v.selected then
|
||||
table.insert(rows, v)
|
||||
end
|
||||
end
|
||||
|
||||
return v
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetSelectionEnabled(bool)
|
||||
- desc: sets whether or not the object's rows can be
|
||||
selected
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetSelectionEnabled(bool)
|
||||
|
||||
self.selectionenabled = bool
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetSelectionEnabled()
|
||||
- desc: gets whether or not the object's rows can be
|
||||
selected
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetSelectionEnabled()
|
||||
|
||||
return self.selectionenabled
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetMultiselectEnabled(bool)
|
||||
- desc: sets whether or not the object can have more
|
||||
than one row selected
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetMultiselectEnabled(bool)
|
||||
|
||||
self.multiselect = bool
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetMultiselectEnabled()
|
||||
- desc: gets whether or not the object can have more
|
||||
than one row selected
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetMultiselectEnabled()
|
||||
|
||||
return self.multiselect
|
||||
|
||||
end
|
@ -20,6 +20,7 @@ function newobject:initialize(parent, data)
|
||||
self.height = 25
|
||||
self.textx = 5
|
||||
self.texty = 5
|
||||
self.selected = false
|
||||
self.internal = true
|
||||
self.columndata = data
|
||||
|
||||
@ -69,7 +70,7 @@ function newobject:draw()
|
||||
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
if not visible then
|
||||
return
|
||||
end
|
||||
|
||||
@ -103,11 +104,17 @@ function newobject:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover and button == "l" then
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
local baseparent = self:GetBaseParent()
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
local parent1 = self:GetParent()
|
||||
local parent2 = parent1:GetParent()
|
||||
local ctrldown = love.keyboard.isDown("lctrl")
|
||||
parent2:SelectRow(self, ctrldown)
|
||||
end
|
||||
|
||||
end
|
||||
@ -122,13 +129,20 @@ function newobject:mousereleased(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover and button == "l" then
|
||||
if self.hover then
|
||||
local parent1 = self:GetParent()
|
||||
local parent2 = parent1:GetParent()
|
||||
if button == "l" then
|
||||
local onrowclicked = parent2.OnRowClicked
|
||||
if onrowclicked then
|
||||
onrowclicked(parent2, self, self.columndata)
|
||||
end
|
||||
elseif button == "r" then
|
||||
local onrowrightclicked = parent2.OnRowRightClicked
|
||||
if onrowrightclicked then
|
||||
onrowrightclicked(parent2, self, self.columndata)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@ -194,6 +208,16 @@ function newobject:GetColorIndex()
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetColumnData(data)
|
||||
- desc: sets the object's column data
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetColumnData(data)
|
||||
|
||||
self.columndata = data
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetColumnData()
|
||||
- desc: gets the object's column data
|
||||
@ -203,3 +227,23 @@ function newobject:GetColumnData()
|
||||
return self.columndata
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetSelected(selected)
|
||||
- desc: sets whether or not the object is selected
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetSelected(selected)
|
||||
|
||||
self.selected = true
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetSelected()
|
||||
- desc: gets whether or not the object is selected
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetSelected()
|
||||
|
||||
return self.selected
|
||||
|
||||
end
|
@ -24,14 +24,14 @@ function newobject:initialize()
|
||||
self.offsetx = 0
|
||||
self.extrawidth = 0
|
||||
self.extraheight = 0
|
||||
self.buttonscrollamount = 200
|
||||
self.mousewheelscrollamount = 1500
|
||||
self.buttonscrollamount = 0.10
|
||||
self.mousewheelscrollamount = 10
|
||||
self.internal = false
|
||||
self.hbar = false
|
||||
self.vbar = false
|
||||
self.autoscroll = false
|
||||
self.horizontalstacking = false
|
||||
self.dtscrolling = true
|
||||
self.dtscrolling = false
|
||||
self.internals = {}
|
||||
self.children = {}
|
||||
self.OnScroll = nil
|
||||
|
@ -115,9 +115,13 @@ skin.controls.columnlistheader_text_hover_color = {255, 255, 255, 255}
|
||||
skin.controls.columnlistheader_text_font = smallfont
|
||||
|
||||
-- columnlistrow
|
||||
skin.controls.columnlistrow_body1_color = {232, 232, 232, 255}
|
||||
skin.controls.columnlistrow_body2_color = {200, 200, 200, 255}
|
||||
skin.controls.columnlistrow_body1_color = {245, 245, 245, 255}
|
||||
skin.controls.columnlistrow_body2_color = {255, 255, 255, 255}
|
||||
skin.controls.columnlistrow_body_selected_color = {26, 198, 255, 255}
|
||||
skin.controls.columnlistrow_body_hover_color = {102, 217, 255, 255}
|
||||
skin.controls.columnlistrow_text_color = {100, 100, 100, 255}
|
||||
skin.controls.columnlistrow_text_hover_color = {255, 255, 255, 255}
|
||||
skin.controls.columnlistrow_text_selected_color = {255, 255, 255, 255}
|
||||
|
||||
-- modalbackground
|
||||
skin.controls.modalbackground_body_color = {255, 255, 255, 100}
|
||||
@ -1395,13 +1399,29 @@ function skin.DrawColumnListRow(object)
|
||||
local parent = object:GetParent()
|
||||
local cwidth, cheight = parent:GetParent():GetColumnSize()
|
||||
local theight = font:getHeight("a")
|
||||
local hover = object:GetHover()
|
||||
local selected = object:GetSelected()
|
||||
local body1color = skin.controls.columnlistrow_body1_color
|
||||
local body2color = skin.controls.columnlistrow_body2_color
|
||||
local bodyhovercolor = skin.controls.columnlistrow_body_hover_color
|
||||
local bodyselectedcolor = skin.controls.columnlistrow_body_selected_color
|
||||
local textcolor = skin.controls.columnlistrow_text_color
|
||||
local texthovercolor = skin.controls.columnlistrow_text_hover_color
|
||||
local textselectedcolor = skin.controls.columnlistrow_text_selected_color
|
||||
|
||||
object:SetTextPos(5, height/2 - theight/2)
|
||||
|
||||
if colorindex == 1 then
|
||||
if selected then
|
||||
love.graphics.setColor(bodyselectedcolor)
|
||||
love.graphics.rectangle("fill", x, y, width, height)
|
||||
love.graphics.setColor(bordercolor)
|
||||
skin.OutlinedRectangle(x, y, width, height, true, false, true, true)
|
||||
elseif hover then
|
||||
love.graphics.setColor(bodyhovercolor)
|
||||
love.graphics.rectangle("fill", x, y, width, height)
|
||||
love.graphics.setColor(bordercolor)
|
||||
skin.OutlinedRectangle(x, y, width, height, true, false, true, true)
|
||||
elseif colorindex == 1 then
|
||||
love.graphics.setColor(body1color)
|
||||
love.graphics.rectangle("fill", x + 1, y + 1, width - 2, height - 2)
|
||||
love.graphics.setColor(bordercolor)
|
||||
@ -1415,7 +1435,13 @@ function skin.DrawColumnListRow(object)
|
||||
|
||||
for k, v in ipairs(columndata) do
|
||||
love.graphics.setFont(font)
|
||||
if selected then
|
||||
love.graphics.setColor(textselectedcolor)
|
||||
elseif hover then
|
||||
love.graphics.setColor(texthovercolor)
|
||||
else
|
||||
love.graphics.setColor(textcolor)
|
||||
end
|
||||
love.graphics.print(v, x + textx, y + texty)
|
||||
x = x + cwidth
|
||||
end
|
||||
|
@ -115,9 +115,13 @@ skin.controls.columnlistheader_text_hover_color = {255, 255, 255, 255}
|
||||
skin.controls.columnlistheader_text_font = smallfont
|
||||
|
||||
-- columnlistrow
|
||||
skin.controls.columnlistrow_body1_color = {232, 232, 232, 255}
|
||||
skin.controls.columnlistrow_body2_color = {200, 200, 200, 255}
|
||||
skin.controls.columnlistrow_body1_color = {245, 245, 245, 255}
|
||||
skin.controls.columnlistrow_body2_color = {255, 255, 255, 255}
|
||||
skin.controls.columnlistrow_body_selected_color = {255, 153, 0, 255}
|
||||
skin.controls.columnlistrow_body_hover_color = {255, 173, 51, 255}
|
||||
skin.controls.columnlistrow_text_color = {100, 100, 100, 255}
|
||||
skin.controls.columnlistrow_text_hover_color = {255, 255, 255, 255}
|
||||
skin.controls.columnlistrow_text_selected_color = {255, 255, 255, 255}
|
||||
|
||||
-- modalbackground
|
||||
skin.controls.modalbackground_body_color = {255, 255, 255, 100}
|
||||
@ -1395,13 +1399,29 @@ function skin.DrawColumnListRow(object)
|
||||
local parent = object:GetParent()
|
||||
local cwidth, cheight = parent:GetParent():GetColumnSize()
|
||||
local theight = font:getHeight("a")
|
||||
local hover = object:GetHover()
|
||||
local selected = object:GetSelected()
|
||||
local body1color = skin.controls.columnlistrow_body1_color
|
||||
local body2color = skin.controls.columnlistrow_body2_color
|
||||
local bodyhovercolor = skin.controls.columnlistrow_body_hover_color
|
||||
local bodyselectedcolor = skin.controls.columnlistrow_body_selected_color
|
||||
local textcolor = skin.controls.columnlistrow_text_color
|
||||
local texthovercolor = skin.controls.columnlistrow_text_hover_color
|
||||
local textselectedcolor = skin.controls.columnlistrow_text_selected_color
|
||||
|
||||
object:SetTextPos(5, height/2 - theight/2)
|
||||
|
||||
if colorindex == 1 then
|
||||
if selected then
|
||||
love.graphics.setColor(bodyselectedcolor)
|
||||
love.graphics.rectangle("fill", x, y, width, height)
|
||||
love.graphics.setColor(bordercolor)
|
||||
skin.OutlinedRectangle(x, y, width, height, true, false, true, true)
|
||||
elseif hover then
|
||||
love.graphics.setColor(bodyhovercolor)
|
||||
love.graphics.rectangle("fill", x, y, width, height)
|
||||
love.graphics.setColor(bordercolor)
|
||||
skin.OutlinedRectangle(x, y, width, height, true, false, true, true)
|
||||
elseif colorindex == 1 then
|
||||
love.graphics.setColor(body1color)
|
||||
love.graphics.rectangle("fill", x + 1, y + 1, width - 2, height - 2)
|
||||
love.graphics.setColor(bordercolor)
|
||||
@ -1415,7 +1435,13 @@ function skin.DrawColumnListRow(object)
|
||||
|
||||
for k, v in ipairs(columndata) do
|
||||
love.graphics.setFont(font)
|
||||
if selected then
|
||||
love.graphics.setColor(textselectedcolor)
|
||||
elseif hover then
|
||||
love.graphics.setColor(texthovercolor)
|
||||
else
|
||||
love.graphics.setColor(textcolor)
|
||||
end
|
||||
love.graphics.print(v, x + textx, y + texty)
|
||||
x = x + cwidth
|
||||
end
|
||||
|
25
util.lua
25
util.lua
@ -269,3 +269,28 @@ function loveframes.util.Error(message)
|
||||
error("[Love Frames] " ..message)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: loveframes.util.GetCollisionCount()
|
||||
- desc: gets the total number of objects colliding with
|
||||
the mouse
|
||||
--]]---------------------------------------------------------
|
||||
function loveframes.util.GetCollisionCount()
|
||||
|
||||
local collisioncount = loveframes.collisioncount
|
||||
return collisioncount
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: loveframes.util.GetHover()
|
||||
- desc: returns loveframes.hover, can be used to check
|
||||
if the mouse is colliding with a visible
|
||||
Love Frames object
|
||||
--]]---------------------------------------------------------
|
||||
function loveframes.util.GetHover()
|
||||
|
||||
return loveframes.hover
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user