bigbutton.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. -- BIG BUTTON
  2. goo.bigbutton = class('goo big button', goo.object)
  3. goo.bigbutton.image = {}
  4. goo.bigbutton.image.right = love.graphics.newImage(goo.skin..'bigbutton_left.png')
  5. goo.bigbutton.image.middle = love.graphics.newImage(goo.skin..'bigbutton_middle.png')
  6. goo.bigbutton.image.left = love.graphics.newImage(goo.skin..'bigbutton_right.png')
  7. function goo.bigbutton:initialize(parent)
  8. super.initialize(self,parent)
  9. self.checkState = 'unchecked'
  10. self:exitHover()
  11. end
  12. function goo.bigbutton:enterHover()
  13. self.buttonColor = self.style.buttonColorHover
  14. self.textColor = self.style.textColorHover
  15. end
  16. function goo.bigbutton:exitHover()
  17. self.buttonColor = self.style.buttonColor
  18. self.textColor = self.style.textColor
  19. end
  20. function goo.bigbutton:draw(x,y)
  21. local w = self.image.left:getWidth() - 5
  22. love.graphics.setColor( unpack(self.buttonColor) )
  23. love.graphics.draw( self.image.right, x, y )
  24. love.graphics.draw( self.image.middle, x+w, y, 0, self.w, 1)
  25. love.graphics.draw( self.image.left, x+self.w+w, y )
  26. love.graphics.setColor( unpack(self.textColor) )
  27. love.graphics.setFont( unpack(self.style.font) )
  28. love.graphics.printf( self.text, x+(self.w/2)-250+17, y+30, 500, "center" )
  29. end
  30. function goo.bigbutton:updateBounds()
  31. local imgH = goo.bigbutton.image.left:getHeight()
  32. local imgW = goo.bigbutton.image.left:getWidth()
  33. local x, y = self:getAbsolutePos()
  34. self.bounds.x1 = x
  35. self.bounds.y1 = y
  36. self.bounds.x2 = x + self.w + (imgW*2)
  37. self.bounds.y2 = y + imgH
  38. end
  39. return goo.bigbutton