Version 0.9.1.3 - Alpha (see changelog.txt)

This commit is contained in:
Kenny Shields 2012-05-14 22:47:38 -04:00
parent 3829532d5b
commit fd92ff0f12
10 changed files with 341 additions and 27 deletions

View File

@ -1,3 +1,19 @@
================================================
Version 0.9.1.3 - Alpha (May 14 - 2012)
================================================
[ADDED] modal system for frames
[ADDED] a new frame method: SetModal(bool)
[ADDED] a new frame method: GetModal()
[ADDED] a new frame method: SetVisible(bool) - this override is part of a frame bug fix
[ADDED] "showclose" property for the frame object
[ADDED] a new internal object: modal background
[ADDED] a new base method: IsActive()
[ADDED] a new base method: CenterX()
[ADDED] a new base method: CenterY()
[ADDED] a new skin function: DrawOverColumList()
[FIXED] a bug that made the frame's close button become visisble when the frame was made visible and show close button was set to false
================================================
Version 0.9.1.2 - Alpha (May 12 - 2012)
================================================

View File

@ -237,9 +237,29 @@ function loveframes.debug.ExamplesMenu()
local text1 = loveframes.Create("text", frame1)
text1:SetText("This is an example frame.")
text1.Update = function(object2, dt)
object2:Center()
object2:CenterX()
object2:SetY(40)
end
local button1 = loveframes.Create("button", frame1)
button1:SetText("Modal")
button1:SetWidth(100)
button1:Center()
button1.Update = function(object2, dt)
local modal = object2:GetParent():GetModal()
if modal == true then
object2:SetText("Remove Modal")
object2.OnClick = function()
object2:GetParent():SetModal(false)
end
else
object2:SetText("Set Modal")
object2.OnClick = function()
object2:GetParent():SetModal(true)
end
end
end
end
exampleslist:AddItem(frameexample)

View File

@ -9,7 +9,7 @@ loveframes = {}
-- library info
loveframes.info = {}
loveframes.info.author = "Nikolai Resokav"
loveframes.info.version = "0.9.1.2"
loveframes.info.version = "0.9.1.3"
loveframes.info.stage = "Alpha"
-- library configurations
@ -22,6 +22,7 @@ loveframes.config["DEBUG"] = true
loveframes.drawcount = 0
loveframes.hoverobject = false
loveframes.modalobject = false
--[[---------------------------------------------------------
- func: load()

View File

@ -284,6 +284,42 @@ function base:Center()
end
--[[---------------------------------------------------------
- func: CenterX()
- desc: centers the object by it's x value
--]]---------------------------------------------------------
function base:CenterX()
local parent = self.parent
if parent == loveframes.base then
local width = love.graphics.getWidth()
self.x = width/2 - self.width/2
else
local width = parent.width
self.staticx = width/2 - self.width/2
end
end
--[[---------------------------------------------------------
- func: CenterY()
- desc: centers the object by it's y value
--]]---------------------------------------------------------
function base:CenterY()
local parent = self.parent
if parent == loveframes.base then
local height = love.graphics.getHeight()
self.y = height/2 - self.height/2
else
local height = parent.height
self.staticy = height/2 - self.height/2
end
end
--[[---------------------------------------------------------
- func: SetSize(width, height)
- desc: sets the object's size
@ -578,6 +614,7 @@ function base:CheckHover()
local x, y = love.mouse.getPosition()
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
-- is the mouse inside the object?
if selfcol == true then
@ -610,6 +647,26 @@ function base:CheckHover()
end
if modalobject ~= false then
if modalobject ~= self then
local baseparent = self:GetBaseParent()
if baseparent ~= modalobject then
self.hover = false
if self.focus then
self.focus = false
end
end
end
end
-- this chunk of code handles mouse enter and exit
if self.hover == true then
@ -815,3 +872,23 @@ function base:GetRetainSize()
return self.retainsize
end
--[[---------------------------------------------------------
- func: IsActive()
- desc: gets whether or not the object is active within
it's parent's child table
--]]---------------------------------------------------------
function base:IsActive()
local parent = self.parent
local valid = false
for k, v in ipairs(parent.children) do
if v == self then
valid = true
end
end
return valid
end

View File

@ -23,6 +23,9 @@ function frame:initialize()
self.draggable = true
self.screenlocked = false
self.dragging = false
self.modal = false
self.modalbackground = false
self.showclose = true
self.internals = {}
self.children = {}
self.OnClose = nil
@ -90,6 +93,23 @@ function frame:update(dt)
end
if self.modal == true then
local numtooltips = 0
for k, v in ipairs(loveframes.base.children) do
if v.type == "tooltip" then
numtooltips = numtooltips + 1
end
end
if self.draworder ~= #loveframes.base.children - numtooltips then
self.modalbackground:MoveToTop()
self:MoveToTop()
end
end
for k, v in ipairs(self.internals) do
v:update(dt)
end
@ -280,6 +300,7 @@ function frame:ShowCloseButton(bool)
local close = self.internals[1]
close.visible = bool
self.showclose = bool
end
@ -316,3 +337,72 @@ function frame:MakeTop()
loveframes.base.children[key]:mousepressed(x, y, "l")
end
--[[---------------------------------------------------------
- func: SetModal(bool)
- desc: makes the object the top object in the drawing
order
--]]---------------------------------------------------------
function frame:SetModal(bool)
self.modal = bool
if bool == true then
if loveframes.modalobject ~= false then
loveframes.modalobject:SetModal(false)
end
loveframes.modalobject = self
if self.modalbackground == false then
self.modalbackground = modalbackground:new(self)
self.modal = true
end
else
if loveframes.modalobject == self then
loveframes.modalobject = false
if self.modalbackground ~= false then
self.modalbackground:Remove()
self.modalbackground = false
self.modal = false
end
end
end
end
--[[---------------------------------------------------------
- func: GetModal()
- desc: gets whether or not the object is in a modal
state
--]]---------------------------------------------------------
function frame:GetModal()
return self.modal
end
--[[---------------------------------------------------------
- func: SetVisible(bool)
- desc: set's whether the object is visible or not
--]]---------------------------------------------------------
function frame:SetVisible(bool)
self.visible = bool
for k, v in ipairs(self.children) do
v:SetVisible(bool)
end
if self.showclose == true then
self.internals[1].visible = bool
end
end

View File

@ -116,7 +116,7 @@ function columnlistarea:draw()
love.graphics.setStencil()
if self.Draw == nil then
skin.DrawColumnListArea(self)
skin.DrawOverColumnListArea(self)
end
end

View File

@ -0,0 +1,81 @@
--[[------------------------------------------------
-- LÖVE Frames --
-- By Nikolai Resokav --
--]]------------------------------------------------
-- panel class
modalbackground = class("modalbackground", base)
modalbackground:include(loveframes.templates.default)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function modalbackground:initialize(object)
self.type = "modalbackground"
self.width = love.graphics.getWidth()
self.height = love.graphics.getHeight()
self.x = 0
self.y = 0
self.internal = true
self.parent = loveframes.base
self.object = object
table.insert(loveframes.base.children, self)
if self.object.type ~= "frame" then
self:Remove()
end
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the element
--]]---------------------------------------------------------
function modalbackground:update(dt)
if self.visible == false then
if self.alwaysupdate == false then
return
end
end
if self.object:IsActive() == false then
self:Remove()
loveframes.modalobject = false
end
if self.Update then
self.Update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function modalbackground:draw()
if self.visible == false then
return
end
-- skin variables
local index = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin
local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin]
loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount
if self.Draw ~= nil then
self.Draw(self)
else
skin.DrawModalBackground(self)
end
end

View File

@ -28,6 +28,7 @@ function tabbutton:initialize(parent, text, tabnumber, tip, image)
if tip then
self.tooltip = tooltip:new(self, tip)
self.tooltip:SetFollowCursor(false)
self.tooltip:SetOffsets(0, -5)
end
if image then

View File

@ -164,6 +164,9 @@ skin.controls.columnlistrow_body1_color = {232, 232, 232, 255}
skin.controls.columnlistrow_border2_color = bordercolor
skin.controls.columnlistrow_body2_color = {200, 200, 200, 255}
-- modalbackground
skin.controls.modalbackground_body_color = {255, 255, 255, 100}
--[[---------------------------------------------------------
- func: OutlinedRectangle(object)
- desc: creates and outlined rectangle
@ -1162,12 +1165,12 @@ end
--[[---------------------------------------------------------
- func: skin.DrawOverColumnListArea(object)
- desc: draws the column list area object
- desc: draws over the column list area object
--]]---------------------------------------------------------
function skin.DrawColumnListArea(object)
function skin.DrawOverColumnListArea(object)
love.graphics.setColor(unpack(skin.controls.columnlistarea_border_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
love.graphics.setColor(unpack(skin.controls.columnlist_border_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), true, false, true, true)
end
@ -1204,5 +1207,16 @@ function skin.DrawColumnListRow(object)
end
--[[---------------------------------------------------------
- func: skin.DrawModalBackground(object)
- desc: draws the modal background object
--]]---------------------------------------------------------
function skin.DrawModalBackground(object)
love.graphics.setColor(unpack(skin.controls.modalbackground_body_color))
love.graphics.rectangle("fill", object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
end
-- register the skin
loveframes.skins.Register(skin)

View File

@ -164,6 +164,9 @@ skin.controls.columnlistrow_body1_color = {232, 232, 232, 255}
skin.controls.columnlistrow_border2_color = bordercolor
skin.controls.columnlistrow_body2_color = {200, 200, 200, 255}
-- modalbackground
skin.controls.modalbackground_body_color = {255, 255, 255, 100}
--[[---------------------------------------------------------
- func: OutlinedRectangle(object)
- desc: creates and outlined rectangle
@ -1163,12 +1166,12 @@ end
--[[---------------------------------------------------------
- func: skin.DrawOverColumnListArea(object)
- desc: draws the column list area object
- desc: draws over the column list area object
--]]---------------------------------------------------------
function skin.DrawColumnListArea(object)
function skin.DrawOverColumnListArea(object)
love.graphics.setColor(unpack(skin.controls.columnlistarea_border_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
love.graphics.setColor(unpack(skin.controls.columnlist_border_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), true, false, true, true)
end
@ -1205,5 +1208,16 @@ function skin.DrawColumnListRow(object)
end
--[[---------------------------------------------------------
- func: skin.DrawModalBackground(object)
- desc: draws the modal background object
--]]---------------------------------------------------------
function skin.DrawModalBackground(object)
love.graphics.setColor(unpack(skin.controls.modalbackground_body_color))
love.graphics.rectangle("fill", object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
end
-- register the skin
loveframes.skins.Register(skin)