mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
corrected element, added background/color to scrollbox
This commit is contained in:
parent
5c35892fb6
commit
a0e5fdb465
@ -6,7 +6,7 @@ do
|
|||||||
floor, max = _obj_0.floor, _obj_0.max
|
floor, max = _obj_0.floor, _obj_0.max
|
||||||
end
|
end
|
||||||
local inheritsFromElement
|
local inheritsFromElement
|
||||||
inheritsFromElement = require(tostring((...):sub(1, -19)) .. "/util").inheritsFromElement
|
inheritsFromElement = require(tostring((...):sub(1, -18)) .. "/util").inheritsFromElement
|
||||||
local element
|
local element
|
||||||
do
|
do
|
||||||
local _class_0
|
local _class_0
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import graphics from love
|
import graphics from love
|
||||||
import floor, max from math
|
import floor, max from math
|
||||||
import inheritsFromElement from require "#{(...)\sub 1, -19}/util"
|
import inheritsFromElement from require "#{(...)\sub 1, -18}/util"
|
||||||
|
|
||||||
class element
|
class element
|
||||||
--- Constructor expects nothing, or a data table describing it.
|
--- Constructor expects nothing, or a data table describing it.
|
||||||
|
@ -5,7 +5,24 @@ local scrollbox
|
|||||||
do
|
do
|
||||||
local _class_0
|
local _class_0
|
||||||
local _parent_0 = element
|
local _parent_0 = element
|
||||||
local _base_0 = { }
|
local _base_0 = {
|
||||||
|
draw = function(self)
|
||||||
|
graphics.setColor(self.data.color)
|
||||||
|
graphics.rectangle("fill", self.data.x, self.data.y, self.data.w, self.data.h)
|
||||||
|
return self
|
||||||
|
end,
|
||||||
|
setBackground = function(self, r, g, b, a)
|
||||||
|
if a == nil then
|
||||||
|
a = 255
|
||||||
|
end
|
||||||
|
if "table" == type(r) then
|
||||||
|
self.data.color = r
|
||||||
|
else
|
||||||
|
self.data.color = r, g, b, a
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
}
|
||||||
_base_0.__index = _base_0
|
_base_0.__index = _base_0
|
||||||
setmetatable(_base_0, _parent_0.__base)
|
setmetatable(_base_0, _parent_0.__base)
|
||||||
_class_0 = setmetatable({
|
_class_0 = setmetatable({
|
||||||
@ -18,6 +35,12 @@ do
|
|||||||
if self.data.type == "element" then
|
if self.data.type == "element" then
|
||||||
self.data.type = "scrollbox"
|
self.data.type = "scrollbox"
|
||||||
end
|
end
|
||||||
|
self.data.color = {
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
255
|
||||||
|
}
|
||||||
end,
|
end,
|
||||||
__base = _base_0,
|
__base = _base_0,
|
||||||
__name = "scrollbox",
|
__name = "scrollbox",
|
||||||
|
@ -1,9 +1,43 @@
|
|||||||
|
local pop
|
||||||
import graphics from love
|
import graphics from love
|
||||||
|
|
||||||
element = require "#{(...)\sub 1, -10}/element"
|
element = require "#{(...)\sub 1, -10}/element"
|
||||||
|
|
||||||
class scrollbox extends element
|
class scrollbox extends element
|
||||||
|
load: (pop_lib) ->
|
||||||
|
pop = pop_lib
|
||||||
|
|
||||||
new: (@parent, @data={}) =>
|
new: (@parent, @data={}) =>
|
||||||
super @parent, @data
|
super @parent, @data
|
||||||
|
|
||||||
@data.type = "scrollbox" if @data.type == "element"
|
@data.type = "scrollbox" if @data.type == "element"
|
||||||
|
@data.color = {255, 255, 255, 255}
|
||||||
|
@data.background = {0, 0, 0, 255}
|
||||||
|
|
||||||
|
draw: =>
|
||||||
|
graphics.setColor @data.background
|
||||||
|
graphics.rectangle "fill", @data.x, @data.y, @data.w, @data.h
|
||||||
|
|
||||||
|
--TODO do stuff to set up for drawing
|
||||||
|
for i=1, #@data.child
|
||||||
|
pop.draw @data.child[i]
|
||||||
|
--TODO undo for regular drawing
|
||||||
|
--TODO return something to cancel drawing children
|
||||||
|
|
||||||
|
return @
|
||||||
|
|
||||||
|
setColor: (r, g, b, a=255) =>
|
||||||
|
if "table" == type r
|
||||||
|
@data.color = r
|
||||||
|
else
|
||||||
|
@data.color = r, g, b, a
|
||||||
|
|
||||||
|
return @
|
||||||
|
|
||||||
|
setBackground: (r, g, b, a=255) =>
|
||||||
|
if "table" == type r
|
||||||
|
@data.background = r
|
||||||
|
else
|
||||||
|
@data.background = r, g, b, a
|
||||||
|
|
||||||
|
return @
|
||||||
|
Loading…
Reference in New Issue
Block a user