addups DAB on em

This commit is contained in:
Josh
2018-06-08 15:43:27 -05:00
parent bda84ddf31
commit 8acffbc4b2
4 changed files with 39 additions and 11 deletions

View File

@@ -7,7 +7,7 @@ return {
Frame = require("lib.classes.Frame"),
Label = require("lib.classes.Label"),
Button = require("lib.classes.Button"),
Slider = require("lib.classes.Slider"),
-- Datatypes
Vector2D = require("lib.datatypes.Vector2D"),
@@ -20,6 +20,11 @@ return {
CENTER = "center",
},
Orientation = {
VERTICAL = "vertical",
HORIZONTAL = "horizontal"
},
parent = function(self, parent, child)
parent:addChild(child)
child:setParent(parent)

28
lib/classes/Slider.lua Normal file
View File

@@ -0,0 +1,28 @@
local UIButton = require("lib.classes.UIButton")
local Event = require("lib.classes.Event")
local Slider = UIButton:subclass("Slider")
function Slider:init()
self.super:init()
self.valueRange = {0, 100}
self.valueIncrement = 5
self.defaultValue = 50
self.value = self.defaultValue
self.smooth = false
self.orientation = "vertical"
self.valueChange = Event:new()
end
function Slider:update(delta)
self.super:update(delta)
if self.mouseDown then
self:setPosition()
end
end
return slider

View File

@@ -66,10 +66,8 @@ function UIBase:updateChildren(delta)
end
function UIBase:render()
if not self.parent then return end
end
function UIBase:update(delta)
if not self.parent then return end
self:updateChildren(delta)
end

View File

@@ -12,16 +12,18 @@ local background = JUI.Frame:new()
background:setName("Background")
background:setSize(JUI.Dimension:new(0.6, 0.6))
local emptyColor = JUI.Label:new("EmptyColor")
local emptyColor = JUI.Label:new()
emptyColor:setSize(JUI.Dimension:new(0.3, 0.1))
emptyColor:setPosition(JUI.Dimension:new(0.2, 0.8))
emptyColor:setBorderColor(JUI.Color:new(0.5, 0.5, 0.5))
emptyColor:setTextSize(22)
emptyColor:setBackgroundColor(JUI.Color:fromRGB(200, 69, 128, 128))
emptyColor:setCornerRounding(12)
emptyColor:setBackgroundColor(JUI.Color:fromHex("#FAF"))
emptyColor:setTextAlignment(JUI.TextAlignment.CENTER)
emptyColor:setText("Bottom Text")
emptyColor:setText("Bottom Text")
local button = JUI.Button:new()
button:setName("Button")
button:setSize(JUI.Dimension:new(0.3, 0.5))
button:setPosition(JUI.Dimension:new(0.2, 0.2))
button:setBackgroundColor(JUI.Color:fromHSL(1, 128, 196))
@@ -41,15 +43,10 @@ local button = JUI.Button:new()
button:setText("Outside")
end)
JUI:parent(mainmenu, background)
JUI:parent(mainmenu, emptyColor)
JUI:parent(background, button)
print((JUI.Color:fromHex("#FFF")):out())
print((JUI.Color:fromHex("#ADFAAD")):out())
print((JUI.Color:fromHSL(1, 128, 196)):out())
local function round(number, decimalPlaces)
local placer = 10^(-decimalPlaces)
return (math.floor(number)/placer)*placer