did some fixes, moved transparency into Color

This commit is contained in:
Josh
2018-06-07 13:20:21 -05:00
parent ffa8604802
commit f35aaad599
2 changed files with 6 additions and 23 deletions

View File

@@ -38,11 +38,9 @@ function UIButton:update(delta)
if self.mouseDown == true then
if not love.mouse.isDown(1) then
self.mouseDown = false
if self.mouseOver then
self.mouseClickUp:call()
else
self.mouseClickUpOutside:call()
self.mouseClickUp:call()
if not self.mouseOver then
self.cancelled:call()
end
end
end

View File

@@ -50,8 +50,6 @@ function UIRect:init()
self.backgroundColor = Color:new(1, 1, 1)
self.borderColor = Color:new(0, 0, 0)
self.borderWidth = 2
self.backgroundTransparency = 0
self.borderTransparency = 0
self.cornerRounding = 0
self.size = Dimension:new(0.2, 0.12)
self.position = Dimension:new(0, 0)
@@ -91,22 +89,10 @@ function UIRect:getCornerRounding()
return self.cornerRounding
end
function UIRect:getBorderTransparency()
return self.borderTransparency
end
function UIRect:getBackgroundTransparency()
return self.backgroundTransparency
end
function UIRect:isMouseInside()
return self.mouseOver
end
function UIRect:setBackgroundTransparency(alpha)
self.backgroundTransparency = alpha
end
function UIRect:setCornerRounding(rounding)
self.cornerRounding = rounding
end
@@ -204,14 +190,13 @@ function UIRect:render()
local pos = self:getAbsolutePosition()
local size = self:getAbsoluteSize()
love.graphics.setColor(self.backgroundColor:out(), self.backgroundTransparency)
love.graphics.setColor(self.backgroundColor:out())
-- background
love.graphics.rectangle("fill", pos.x, pos.y, size.x, size.y, self.cornerRounding, self.cornerRounding, 25)
love.graphics.setColor(self.borderColor:out())
love.graphics.setLineWidth(self.borderWidth, self.borderTransparency)
love.graphics.setLineWidth(self.borderWidth)
-- border
love.graphics.rectangle("line", pos.x-(self.borderWidth/2), pos.y-(self.borderWidth/2), size.x+self.borderWidth, size.y+self.borderWidth, self.cornerRounding, self.cornerRounding)
end