This commit is contained in:
Robert Jelic
2023-05-15 20:38:53 +02:00
26 changed files with 458 additions and 373 deletions

View File

@@ -70,6 +70,18 @@ local getVariable = function(name)
return variables[name] return variables[name]
end end
local getObjects = function()
return moddedObjects
end
local getObject = function(id)
return getObjects()[id]
end
local createObject = function(self, objectName, id)
return getObject(objectName)(id, self)
end
local bInstance = { local bInstance = {
getDynamicValueEventSetting = function() getDynamicValueEventSetting = function()
return basalt.dynamicValueEvents return basalt.dynamicValueEvents
@@ -127,14 +139,12 @@ local bInstance = {
stop = stop, stop = stop,
debug = basalt.debug, debug = basalt.debug,
log = basalt.log, log = basalt.log,
getObjects = getObjects,
getObjects = function() getObject = getObject,
return moddedObjects
end,
getObject = function(id) createObject = createObject,
return moddedObjects[id]
end,
getDirectory = function() getDirectory = function()
return projectDirectory return projectDirectory

View File

@@ -41,6 +41,22 @@ return function(name, basalt)
return self return self
end, end,
getXOffset = function(self)
return xOffset
end,
setXOffset = function(self, newXOffset)
return self:setOffset(newXOffset, nil)
end,
getYOffset = function(self)
return yOffset
end,
setYOffset = function(self, newYOffset)
return self:setOffset(nil, newYOffset)
end,
setPalette = function(self, col, ...) setPalette = function(self, col, ...)
if(self==basalt.getActiveFrame())then if(self==basalt.getActiveFrame())then
if(type(col)=="string")then if(type(col)=="string")then

View File

@@ -23,7 +23,11 @@ return function(name, basalt)
getBase = function(self) getBase = function(self)
return base return base
end, end,
getHorizontalAlign = function(self)
return textHorizontalAlign
end,
setHorizontalAlign = function(self, pos) setHorizontalAlign = function(self, pos)
textHorizontalAlign = pos textHorizontalAlign = pos
@@ -31,12 +35,20 @@ return function(name, basalt)
return self return self
end, end,
getVerticalAlign = function(self)
return textVerticalAlign
end,
setVerticalAlign = function(self, pos) setVerticalAlign = function(self, pos)
textVerticalAlign = pos textVerticalAlign = pos
self:updateDraw() self:updateDraw()
return self return self
end, end,
getText = function(self)
return text
end,
setText = function(self, newText) setText = function(self, newText)
text = newText text = newText
self:updateDraw() self:updateDraw()

View File

@@ -32,22 +32,48 @@ return function(name, basalt)
return self return self
end, end,
setActiveSymbol = function(self, sym)
return self:setSymbol(sym, nil)
end,
setInactiveSymbol = function(self, inactive)
return self:setSymbol(nil, inactive)
end,
getSymbol = function(self) getSymbol = function(self)
return symbol, inactiveSymbol return symbol, inactiveSymbol
end, end,
getActiveSymbol = function(self)
return symbol
end,
getInactiveSymbol = function(self)
return inactiveSymbol
end,
setText = function(self, _text) setText = function(self, _text)
text = _text text = _text
return self return self
end, end,
getText = function(self)
return text
end,
setTextPosition = function(self, pos) setTextPosition = function(self, pos)
textPos = pos or textPos textPos = pos or textPos
return self return self
end, end,
getTextPosition = function(self)
return textPos
end,
setChecked = base.setValue, setChecked = base.setValue,
getChecked = base.getValue,
mouseHandler = function(self, button, x, y) mouseHandler = function(self, button, x, y)
if (base.mouseHandler(self, button, x, y)) then if (base.mouseHandler(self, button, x, y)) then
if(button == 1)then if(button == 1)then

View File

@@ -384,9 +384,9 @@ return function(name, basalt)
end end
end end
for k,v in pairs(basalt.getObjects())do for objectName, _ in pairs(basalt.getObjects()) do
container["add"..k] = function(self, name) container["add" .. objectName] = function(self, id)
return addObject(self, v(name, basalt)) return addObject(self, basalt:createObject(objectName, id))
end end
end end

View File

@@ -83,10 +83,26 @@ return function(name, basalt)
return self return self
end, end,
setDropdownWidth = function(self, width)
return self:setDropdownSize(width, dropdownH)
end,
setDropdownHeight = function(self, height)
return self:setDropdownSize(dropdownW, height)
end,
getDropdownSize = function(self) getDropdownSize = function(self)
return dropdownW, dropdownH return dropdownW, dropdownH
end, end,
getDropdownWidth = function(self)
return dropdownW
end,
getDropdownHeight = function(self)
return dropdownH
end,
mouseHandler = function(self, button, x, y, isMon) mouseHandler = function(self, button, x, y, isMon)
if (isOpened) then if (isOpened) then
local obx, oby = self:getAbsolutePosition() local obx, oby = self:getAbsolutePosition()

View File

@@ -76,6 +76,10 @@ return function(name, basalt)
return spacing return spacing
end, end,
getFlexDirection = function(self)
return flexDirection
end,
setFlexDirection = function(self, direction) setFlexDirection = function(self, direction)
if direction == "row" or direction == "column" then if direction == "row" or direction == "column" then
flexDirection = direction flexDirection = direction
@@ -84,6 +88,10 @@ return function(name, basalt)
return self return self
end, end,
getJustifyContent = function(self)
return justifyContent
end,
setJustifyContent = function(self, alignment) setJustifyContent = function(self, alignment)
if alignment == "flex-start" or alignment == "flex-end" or alignment == "center" or alignment == "space-between" or alignment == "space-around" then if alignment == "flex-start" or alignment == "flex-end" or alignment == "center" or alignment == "space-between" or alignment == "space-around" then
justifyContent = alignment justifyContent = alignment
@@ -92,6 +100,10 @@ return function(name, basalt)
return self return self
end, end,
getAlignItems = function(self)
return alignItems
end,
setAlignItems = function(self, alignment) setAlignItems = function(self, alignment)
if alignment == "flex-start" or alignment == "flex-end" or alignment == "center" or alignment == "space-between" or alignment == "space-around" then if alignment == "flex-start" or alignment == "flex-end" or alignment == "center" or alignment == "space-between" or alignment == "space-around" then
alignItems = alignment alignItems = alignment
@@ -101,9 +113,9 @@ return function(name, basalt)
end, end,
} }
for k,v in pairs(basalt.getObjects())do for objectName, _ in pairs(basalt.getObjects()) do
object["add"..k] = function(self, name) object["add" .. objectName] = function(self, id)
local obj = base["add"..k](self, name) local obj = base["add" .. objectName](self, id)
applyLayout(base) applyLayout(base)
return obj return obj
end end

View File

@@ -38,6 +38,22 @@ return function(name, basalt)
return self return self
end, end,
getXOffset = function(self)
return xOffset
end,
setXOffset = function(self, newXOffset)
return self:setOffset(newXOffset, nil)
end,
getYOffset = function(self)
return yOffset
end,
setYOffset = function(self, newYOffset)
return self:setOffset(nil, newYOffset)
end,
setParent = function(self, p, ...) setParent = function(self, p, ...)
base.setParent(self, p, ...) base.setParent(self, p, ...)
parent = p parent = p

View File

@@ -32,10 +32,18 @@ return function(name, basalt)
return self return self
end, end,
setGraphSymbolColor = function(self, symbolColor)
return self:setGraphSymbolColor(nil, symbolColor)
end,
getGraphSymbol = function(self) getGraphSymbol = function(self)
return graphSymbol, graphSymbolCol return graphSymbol, graphSymbolCol
end, end,
getGraphSymbolColor = function(self)
return graphSymbolCol
end,
addDataPoint = function(self, value) addDataPoint = function(self, value)
if value >= minValue and value <= maxValue then if value >= minValue and value <= maxValue then
table.insert(graphData, value) table.insert(graphData, value)
@@ -75,6 +83,10 @@ return function(name, basalt)
return self return self
end, end,
getGraphType = function(self)
return graphType
end,
setMaxEntries = function(self, value) setMaxEntries = function(self, value)
maxEntries = value maxEntries = value
self:updateDraw() self:updateDraw()

View File

@@ -73,6 +73,14 @@ return function(name, basalt)
return self return self
end, end,
setXOffset = function(self, _x)
return self:setOffset(self, _x, nil)
end,
setYOffset = function(self, _y)
return self:setOffset(self, nil, _y)
end,
setSize = function(self, _x, _y) setSize = function(self, _x, _y)
base:setSize(_x, _y) base:setSize(_x, _y)
autoSize = false autoSize = false
@@ -83,6 +91,14 @@ return function(name, basalt)
return xOffset, yOffset return xOffset, yOffset
end, end,
getXOffset = function(self)
return xOffset
end,
getYOffset = function(self)
return yOffset
end,
selectFrame = function(self, id) selectFrame = function(self, id)
if(bimgLibrary.getFrameObject(id)==nil)then if(bimgLibrary.getFrameObject(id)==nil)then
bimgLibrary.addFrame(id) bimgLibrary.addFrame(id)
@@ -142,6 +158,10 @@ return function(name, basalt)
return self return self
end, end,
setPath = function(self, path)
return self:loadImage(path)
end,
setImage = function(self, t) setImage = function(self, t)
if(type(t)=="table")then if(type(t)=="table")then
bimgLibrary = bimg(t) bimgLibrary = bimg(t)
@@ -176,6 +196,14 @@ return function(name, basalt)
return self return self
end, end,
getUsePalette = function(self)
return usePalette
end,
setUsePalette = function(self, use)
return self:usePalette(use)
end,
play = function(self, inf) play = function(self, inf)
if(bimgLibrary.getMetadata("animated"))then if(bimgLibrary.getMetadata("animated"))then
local t = bimgLibrary.getMetadata("duration") or bimgLibrary.getMetadata("secondsPerFrame") or 0.2 local t = bimgLibrary.getMetadata("duration") or bimgLibrary.getMetadata("secondsPerFrame") or 0.2
@@ -186,6 +214,10 @@ return function(name, basalt)
return self return self
end, end,
setPlay = function(self, inf)
return self:play(inf)
end,
stop = function(self) stop = function(self)
os.cancelTimer(animTimer) os.cancelTimer(animTimer)
animTimer = nil animTimer = nil

View File

@@ -37,6 +37,14 @@ return function(name, basalt)
return objectType==t or base.isType~=nil and base.isType(t) or false return objectType==t or base.isType~=nil and base.isType(t) or false
end, end,
setDefaultFG = function(self, fCol)
return self:setDefaultText(self, defaultText, fCol, nil)
end,
setDefaultBG = function(self, bCol)
return self:setDefaultText(self, defaultText, nil, bCol)
end,
setDefaultText = function(self, text, fCol, bCol) setDefaultText = function(self, text, fCol, bCol)
defaultText = text defaultText = text
defaultFGCol = fCol or defaultFGCol defaultFGCol = fCol or defaultFGCol

View File

@@ -77,6 +77,12 @@ return function(name, basalt)
return self return self
end, end,
--- Gets the text alignment of the label.
--- @return string
getTextAlign = function(self)
return textAlign
end,
--- Sets the text alignment of the label. --- Sets the text alignment of the label.
--- @param align string The alignment of the text. Can be "left", "center", or "right". --- @param align string The alignment of the text. Can be "left", "center", or "right".
--- @return object --- @return object

View File

@@ -151,10 +151,26 @@ return function(name, basalt)
return self return self
end, end,
setSelectionBG = function(self, bgCol)
return self:setSelectionColor(bgCol, nil, selectionColorActive)
end,
setSelectionFG = function(self, fgCol)
return self:setSelectionColor(nil, fgCol, selectionColorActive)
end,
getSelectionColor = function(self) getSelectionColor = function(self)
return itemSelectedBG, itemSelectedFG return itemSelectedBG, itemSelectedFG
end, end,
getSelectionBG = function(self)
return itemSelectedBG
end,
getSelectionFG = function(self)
return itemSelectedFG
end,
isSelectionColorActive = function(self) isSelectionColorActive = function(self)
return selectionColorActive return selectionColorActive
end, end,
@@ -166,6 +182,10 @@ return function(name, basalt)
return self return self
end, end,
getScrollable = function(self)
return scrollable
end,
scrollHandler = function(self, dir, x, y) scrollHandler = function(self, dir, x, y)
if(base.scrollHandler(self, dir, x, y))then if(base.scrollHandler(self, dir, x, y))then
if(scrollable)then if(scrollable)then

View File

@@ -46,12 +46,19 @@ return function(name, basalt)
return self return self
end, end,
getSpace = function(self)
return space
end,
setScrollable = function(self, scroll) setScrollable = function(self, scroll)
scrollable = scroll scrollable = scroll
if(scroll==nil)then scrollable = true end if(scroll==nil)then scrollable = true end
return self return self
end, end,
getScrollable = function(self)
return scrollable
end,
mouseHandler = function(self, button, x, y) mouseHandler = function(self, button, x, y)
if(base:getBase().mouseHandler(self, button, x, y))then if(base:getBase().mouseHandler(self, button, x, y))then

View File

@@ -33,7 +33,21 @@ return function(name, basalt)
isType = function(self, t) isType = function(self, t)
return objectType==t return objectType==t
end, end,
getProperty = function(self, name)
local get = self["get" .. name:gsub("^%l", string.upper)]
if (get ~= nil) then
return get(self)
end
end,
setProperty = function(self, name, ...)
local set = self["set" .. name:gsub("^%l", string.upper)]
if (set ~= nil) then
return set(self, ...)
end
end,
getName = function(self) getName = function(self)
return name return name
end, end,

View File

@@ -479,6 +479,10 @@ return function(name, basalt)
return self return self
end; end;
setExecute = function(self, path, ...)
return self:execute(path, ...)
end,
stop = function(self) stop = function(self)
local parent = self:getParent() local parent = self:getParent()
if (curProcess ~= nil) then if (curProcess ~= nil) then

View File

@@ -25,6 +25,10 @@ return function(name, basalt)
return self return self
end, end,
getDirection = function(self)
return direction
end,
setProgressBar = function(self, color, symbol, symbolcolor) setProgressBar = function(self, color, symbol, symbolcolor)
activeBarColor = color or activeBarColor activeBarColor = color or activeBarColor
activeBarSymbol = symbol or activeBarSymbol activeBarSymbol = symbol or activeBarSymbol
@@ -37,12 +41,40 @@ return function(name, basalt)
return activeBarColor, activeBarSymbol, activeBarSymbolCol return activeBarColor, activeBarSymbol, activeBarSymbolCol
end, end,
setActiveBarColor = function(self, color)
return self:setProgressBar(color, nil, nil)
end,
getActiveBarColor = function(self)
return activeBarColor
end,
setActiveBarSymbol = function(self, symbol)
return self:setProgressBar(nil, symbol, nil)
end,
getActiveBarSymbol = function(self)
return activeBarSymbol
end,
setActiveBarSymbolColor = function(self, symbolColor)
return self:setProgressBar(nil, nil, symbolColor)
end,
getActiveBarSymbolColor = function(self)
return activeBarSymbolCol
end,
setBackgroundSymbol = function(self, symbol) setBackgroundSymbol = function(self, symbol)
bgBarSymbol = symbol:sub(1, 1) bgBarSymbol = symbol:sub(1, 1)
self:updateDraw() self:updateDraw()
return self return self
end, end,
getBackgroundSymbol = function(self)
return bgBarSymbol
end,
setProgress = function(self, value) setProgress = function(self, value)
if (value >= 0) and (value <= 100) and (progress ~= value) then if (value >= 0) and (value <= 100) and (progress ~= value) then
progress = value progress = value

View File

@@ -53,20 +53,52 @@ return function(name, basalt)
return self return self
end, end,
setBoxSelectionBG = function(self, bg)
return self:setBoxSelectionColor(bg, boxSelectedFG)
end,
setBoxSelectionFG = function(self, fg)
return self:setBoxSelectionColor(boxSelectedBG, fg)
end,
getBoxSelectionColor = function(self) getBoxSelectionColor = function(self)
return boxSelectedBG, boxSelectedFG return boxSelectedBG, boxSelectedFG
end, end,
getBoxSelectionBG = function(self)
return boxSelectedBG
end,
getBoxSelectionFG = function(self)
return boxSelectedFG
end,
setBoxDefaultColor = function(self, bg, fg) setBoxDefaultColor = function(self, bg, fg)
boxNotSelectedBG = bg boxNotSelectedBG = bg
boxNotSelectedFG = fg boxNotSelectedFG = fg
return self return self
end, end,
setBoxDefaultBG = function(self, bg)
return self:setBoxDefaultColor(bg, boxNotSelectedFG)
end,
setBoxDefaultFG = function(self, fg)
return self:setBoxDefaultColor(boxNotSelectedBG, fg)
end,
getBoxDefaultColor = function(self) getBoxDefaultColor = function(self)
return boxNotSelectedBG, boxNotSelectedFG return boxNotSelectedBG, boxNotSelectedFG
end, end,
getBoxDefaultBG = function(self)
return boxNotSelectedBG
end,
getBoxDefaultFG = function(self)
return boxNotSelectedFG
end,
mouseHandler = function(self, button, x, y, ...) mouseHandler = function(self, button, x, y, ...)
if (#list > 0) then if (#list > 0) then
local obx, oby = self:getAbsolutePosition() local obx, oby = self:getAbsolutePosition()

View File

@@ -62,6 +62,26 @@ return function(name, basalt)
return self return self
end, end,
setSymbolBG = function(self, bg)
return self:setSymbol(symbol, bg, nil)
end,
setSymbolFG = function(self, fg)
return self:setSymbol(symbol, nil, fg)
end,
getSymbol = function(self)
return symbol
end,
getSymbolBG = function(self)
return symbolBG
end,
getSymbolFG = function(self)
return symbolFG
end,
setIndex = function(self, _index) setIndex = function(self, _index)
index = _index index = _index
if (index < 1) then if (index < 1) then
@@ -81,6 +101,10 @@ return function(name, basalt)
return self return self
end, end,
getScrollAmount = function(self)
return scrollAmount
end,
getIndex = function(self) getIndex = function(self)
local w,h = self:getSize() local w,h = self:getSize()
return scrollAmount > (barType=="vertical" and h or w) and math.floor(scrollAmount/(barType=="vertical" and h or w) * index) or index return scrollAmount > (barType=="vertical" and h or w) and math.floor(scrollAmount/(barType=="vertical" and h or w) * index) or index
@@ -94,6 +118,10 @@ return function(name, basalt)
return self return self
end, end,
getSymbolSize = function(self)
return symbolSize
end,
setBarType = function(self, _typ) setBarType = function(self, _typ)
barType = _typ:lower() barType = _typ:lower()
updateSymbolSize() updateSymbolSize()
@@ -101,6 +129,10 @@ return function(name, basalt)
return self return self
end, end,
getBarType = function(self)
return barType
end,
mouseHandler = function(self, button, x, y, ...) mouseHandler = function(self, button, x, y, ...)
if (base.mouseHandler(self, button, x, y, ...)) then if (base.mouseHandler(self, button, x, y, ...)) then
mouseEvent(self, button, x, y) mouseEvent(self, button, x, y)

View File

@@ -46,6 +46,10 @@ return function(name, basalt)
return self return self
end, end,
getSymbol = function(self)
return symbol
end,
setIndex = function(self, _index) setIndex = function(self, _index)
index = _index index = _index
if (index < 1) then if (index < 1) then
@@ -67,18 +71,30 @@ return function(name, basalt)
return self return self
end, end,
getMaxValue = function(self)
return maxValue
end,
setSymbolColor = function(self, col) setSymbolColor = function(self, col)
symbolColor = col symbolColor = col
self:updateDraw() self:updateDraw()
return self return self
end, end,
getSymbolColor = function(self)
return symbolColor
end,
setBarType = function(self, _typ) setBarType = function(self, _typ)
barType = _typ:lower() barType = _typ:lower()
self:updateDraw() self:updateDraw()
return self return self
end, end,
getBarType = function(self)
return barType
end,
mouseHandler = function(self, button, x, y) mouseHandler = function(self, button, x, y)
if (base.mouseHandler(self, button, x, y)) then if (base.mouseHandler(self, button, x, y)) then
mouseEvent(self, button, x, y) mouseEvent(self, button, x, y)

View File

@@ -20,16 +20,28 @@ return function(name, basalt)
return self return self
end, end,
getSymbol = function(self)
return bgSymbol
end,
setActiveBackground = function(self, col) setActiveBackground = function(self, col)
activeBG = col activeBG = col
return self return self
end, end,
getActiveBackground = function(self)
return activeBG
end,
setInactiveBackground = function(self, col) setInactiveBackground = function(self, col)
inactiveBG = col inactiveBG = col
return self return self
end, end,
getInactiveBackground = function(self)
return inactiveBG
end,
load = function(self) load = function(self)
self:listenEvent("mouse_click") self:listenEvent("mouse_click")

View File

@@ -161,10 +161,26 @@ return function(name, basalt)
return self return self
end, end,
setSelectionFG = function(self, fg)
return self:setSelection(fg, nil)
end,
setSelectionBG = function(self, bg)
return self:setSelection(nil, bg)
end,
getSelection = function(self) getSelection = function(self)
return selectionFG, selectionBG return selectionFG, selectionBG
end, end,
getSelectionFG = function(self)
return selectionFG
end,
getSelectionBG = function(self)
return selectionBG
end,
getLines = function(self) getLines = function(self)
return lines return lines
end, end,
@@ -289,6 +305,22 @@ return function(name, basalt)
return self return self
end, end,
getXOffset = function(self, xOff)
return wIndex
end,
setXOffset = function(self, xOff)
return self:setOffset(xOff, nil)
end,
getYOffset = function(self, xOff)
return hIndex
end,
setYOffset = function(self, yOff)
return self:setOffset(nil, yOff)
end,
getFocusHandler = function(self) getFocusHandler = function(self)
base.getFocusHandler(self) base.getFocusHandler(self)
local obx, oby = self:getPosition() local obx, oby = self:getPosition()

View File

@@ -19,6 +19,10 @@ return function(name, basalt)
return self return self
end, end,
getTime = function(self)
return timer
end,
start = function(self) start = function(self)
if(timerIsActive)then if(timerIsActive)then
os.cancelTimer(timerObj) os.cancelTimer(timerObj)
@@ -43,6 +47,14 @@ return function(name, basalt)
return self return self
end, end,
setStart = function(self, start)
if (start == true) then
return self:start()
else
return self:cancel()
end
end,
onCall = function(self, func) onCall = function(self, func)
self:registerEvent("timed_event", func) self:registerEvent("timed_event", func)
return self return self

View File

@@ -157,15 +157,35 @@ return function(name, basalt)
return self return self
end, end,
setXOffset = function(self, x)
return self:setOffset(x, yOffset)
end,
setYOffset = function(self, y)
return self:setOffset(xOffset, y)
end,
getOffset = function(self) getOffset = function(self)
return xOffset, yOffset return xOffset, yOffset
end, end,
getXOffset = function(self)
return xOffset
end,
getYOffset = function(self)
return yOffset
end,
setScrollable = function(self, scroll) setScrollable = function(self, scroll)
scrollable = scroll scrollable = scroll
return self return self
end, end,
getScrollable = function(self, scroll)
return scrollable
end,
setSelectionColor = function(self, bgCol, fgCol, active) setSelectionColor = function(self, bgCol, fgCol, active)
itemSelectedBG = bgCol or self:getBackground() itemSelectedBG = bgCol or self:getBackground()
itemSelectedFG = fgCol or self:getForeground() itemSelectedFG = fgCol or self:getForeground()
@@ -174,10 +194,26 @@ return function(name, basalt)
return self return self
end, end,
setSelectionBG = function(self, bgCol)
return self:setSelectionColor(bgCol, nil, selectionColorActive)
end,
setSelectionFG = function(self, fgCol)
return self:setSelectionColor(nil, fgCol, selectionColorActive)
end,
getSelectionColor = function(self) getSelectionColor = function(self)
return itemSelectedBG, itemSelectedFG return itemSelectedBG, itemSelectedFG
end, end,
getSelectionBG = function(self)
return itemSelectedBG
end,
getSelectionFG = function(self)
return itemSelectedFG
end,
isSelectionColorActive = function(self) isSelectionColorActive = function(self)
return selectionColorActive return selectionColorActive
end, end,

View File

@@ -138,10 +138,18 @@ return function(name, basalt)
return x return x
end, end,
setX = function(self, newX)
return self:setPosition(newX, y)
end,
getY = function(self) getY = function(self)
return y return y
end, end,
setY = function(self, newY)
return self:setPosition(x, newY)
end,
getPosition = function(self) getPosition = function(self)
return x, y return x, y
end, end,
@@ -167,10 +175,18 @@ return function(name, basalt)
return height return height
end, end,
setHeight = function(self, newHeight)
return self:setSize(width, newHeight)
end,
getWidth = function(self) getWidth = function(self)
return width return width
end, end,
setWidth = function(self, newWidth)
return self:setSize(newWidth, height)
end,
getSize = function(self) getSize = function(self)
return width, height return width, height
end, end,

View File

@@ -256,30 +256,11 @@ return {
VisualObject = function(base, basalt) VisualObject = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
local x, y = self:getPosition()
local w, h = self:getSize()
if (name == "x") then
self:setPosition(value, y)
elseif (name == "y") then
self:setPosition(x, value)
elseif (name == "width") then
self:setSize(value, h)
elseif (name == "height") then
self:setSize(w, value)
elseif (name == "background") then
self:setBackground(colors[value])
elseif (name == "foreground") then
self:setForeground(colors[value])
end
end,
updateSpecifiedValuesByXMLData = function(self, data, valueNames) updateSpecifiedValuesByXMLData = function(self, data, valueNames)
for _, name in ipairs(valueNames) do for _, name in ipairs(valueNames) do
local value = xmlValue(name, data) local value = xmlValue(name, data)
if (value ~= nil) then if (value ~= nil) then
self:updateValue(name, value) self:setProperty(name, value)
end end
end end
end, end,
@@ -289,7 +270,7 @@ return {
for prop, expression in pairs(data:reactiveProperties()) do for prop, expression in pairs(data:reactiveProperties()) do
local update = function() local update = function()
local value = load("return " .. expression, nil, "t", renderContext.env)() local value = load("return " .. expression, nil, "t", renderContext.env)()
self:updateValue(prop, value) self:setProperty(prop, value)
end end
basalt.effect(update) basalt.effect(update)
end end
@@ -326,14 +307,6 @@ return {
ChangeableObject = function(base, basalt) ChangeableObject = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "value") then
self:setValue(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -439,22 +412,11 @@ return {
BaseFrame = function(base, basalt) BaseFrame = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local _, yOffset = self:getOffset()
if (name == "layout") then
self:setLayout(value)
elseif (name == "xOffset") then
self:setOffset(value, yOffset)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
"layout", "xOffset",
"xOffset" "yOffset"
}) })
return self return self
end, end,
@@ -464,23 +426,9 @@ return {
Frame = function(base, basalt) Frame = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local xOffset, yOffset = self:getOffset()
if (name == "layout") then
self:setLayout(value)
elseif (name == "xOffset") then
self:setOffset(value, yOffset)
elseif (name == "yOffset") then
self:setOffset(xOffset, value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
"layout",
"xOffset", "xOffset",
"yOffset" "yOffset"
}) })
@@ -492,20 +440,6 @@ return {
Flexbox = function(base, basalt) Flexbox = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "flexDirection") then
self:setFlexDirection(value)
elseif (name == "justifyContent") then
self:setJustifyContent(value)
elseif (name == "alignItems") then
self:setAlignItems(value)
elseif (name == "spacing") then
self:setSpacing(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -522,18 +456,6 @@ return {
Button = function(base, basalt) Button = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "text") then
self:setText(value)
elseif (name == "horizontalAlign") then
self:setHorizontalAlign(value)
elseif (name == "verticalAlign") then
self:setVerticalAlign(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -549,21 +471,11 @@ return {
Label = function(base, basalt) Label = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "text") then
self:setText(value)
elseif (name == "align") then
self:setAlign(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
"text", "text",
"align" "textAlign"
}) })
return self return self
end, end,
@@ -573,27 +485,6 @@ return {
Input = function(base, basalt) Input = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local defaultText, defaultFG, defaultBG = self:getDefaultText()
if (name == "defaultText") then
self:setDefaultText(value, defaultFG, defaultBG)
elseif (name == "defaultFG") then
self:setDefaultText(defaultText, value, defaultBG)
elseif (name == "defaultBG") then
self:setDefaultText(defaultText, defaultFG, value)
elseif (name == "offset") then
self:setOffset(value)
elseif (name == "textOffset") then
self:setTextOffset(value)
elseif (name == "text") then
self:setText(value)
elseif (name == "inputLimit") then
self:setInputLimit(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -613,23 +504,6 @@ return {
Image = function(base, basalt) Image = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local xOffset, yOffset = self:getOffset()
if (name == "xOffset") then
self:setOffset(value, yOffset)
elseif (name == "yOffset") then
self:setOffset(xOffset, value)
elseif (name == "path") then
self:loadImage(value)
elseif (name == "usePalette") then
self:usePalette(value)
elseif (name == "play") then
self:play(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -647,23 +521,6 @@ return {
Checkbox = function(base, basalt) Checkbox = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local activeSymbol, inactiveSymbol = self:getSymbol()
if (name == "text") then
self:setText(value)
elseif (name == "checked") then
self:setChecked(value)
elseif (name == "textPosition") then
self:setTextPosition(value)
elseif (name == "activeSymbol") then
self:setSymbol(value, inactiveSymbol)
elseif (name == "inactiveSymbol") then
self:setSymbol(activeSymbol, value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -681,14 +538,6 @@ return {
Program = function(base, basalt) Program = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "execute") then
self:execute(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -702,25 +551,6 @@ return {
Progressbar = function(base, basalt) Progressbar = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local activeBarColor, activeBarSymbol, activeBarSymbolCol = self:getProgressBar()
if (name == "direction") then
self:setDirection(value)
elseif (name == "activeBarColor") then
self:setProgressBar(value, activeBarSymbol, activeBarSymbolCol)
elseif (name == "activeBarSymbol") then
self:setProgressBar(activeBarColor, value, activeBarSymbolCol)
elseif (name == "activeBarSymbolColor") then
self:setProgressBar(activeBarColor, activeBarSymbol, value)
elseif (name == "backgroundSymbol") then
self:setBackgroundSymbol(value)
elseif (name == "progress") then
self:setProgress(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -739,22 +569,6 @@ return {
Slider = function(base, basalt) Slider = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "symbol") then
self:setSymbol(value)
elseif (name == "symbolColor") then
self:setSymbolColor(value)
elseif (name == "index") then
self:setIndex(value)
elseif (name == "maxValue") then
self:setMaxValue(value)
elseif (name == "barType") then
self:setBarType(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -772,35 +586,15 @@ return {
Scrollbar = function(base, basalt) Scrollbar = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "symbol") then
self:setSymbol(value)
elseif (name == "symbolColor") then
self:setSymbolColor(value)
elseif (name == "symbolSize") then
self:setSymbolSize(value)
elseif (name == "scrollAmount") then
self:setScrollAmount(value)
elseif (name == "index") then
self:setIndex(value)
elseif (name == "maxValue") then
self:setMaxValue(value)
elseif (name == "barType") then
self:setBarType(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
"symbol", "symbol",
"symbolColor", "symbolBG",
"symbolFG",
"symbolSize", "symbolSize",
"scrollAmount", "scrollAmount",
"index", "index",
"maxValue",
"barType" "barType"
}) })
return self return self
@@ -811,14 +605,6 @@ return {
MonitorFrame = function(base, basalt) MonitorFrame = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "monitor") then
self:setMonitor(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -832,18 +618,6 @@ return {
Switch = function(base, basalt) Switch = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "symbol") then
self:setSymbol(value)
elseif (name == "activeBackground") then
self:setActiveBackground(value)
elseif (name == "inactiveBackground") then
self:setInactiveBackground(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -859,27 +633,11 @@ return {
Textfield = function(base, basalt) Textfield = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local fgSel, bgSel = self:getSelection()
local xOffset, yOffset = self:getOffset()
if (name == "bgSelection") then
self:setSelection(fgSel, value)
elseif (name == "fgSelection") then
self:setSelection(value, bgSel)
elseif (name == "xOffset") then
self:setOffset(value, yOffset)
elseif (name == "yOffset") then
self:setOffset(xOffset, value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
"bgSelection", "selectionBG",
"fgSelection", "selectionFG",
"xOffset", "xOffset",
"yOffset" "yOffset"
}) })
@@ -943,16 +701,6 @@ return {
Timer = function(base, basalt) Timer = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "start") then
self:start(value)
elseif (name == "time") then
self:setTime(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -970,27 +718,10 @@ return {
List = function(base, basalt) List = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local selBg, selFg = self:getSelectionColor()
if (name == "align") then
self:setTextAlign(value)
elseif (name == "offset") then
self:setOffset(value)
elseif (name == "selectionBg") then
self:setSelectionColor(value, selFg)
elseif (name == "selectionFg") then
self:setSelectionColor(selBg, value)
elseif (name == "scrollable") then
self:setScrollable(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
"align", "textAlign",
"offset", "offset",
"selectionBg", "selectionBg",
"selectionFg", "selectionFg",
@@ -1014,17 +745,6 @@ return {
Dropdown = function(base, basalt) Dropdown = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local w, h = self:getDropdownSize()
if (name == "dropdownWidth") then
self:setDropdownSize(value, h)
elseif (name == "dropdownHeight") then
self:setDropdownSize(w, value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -1039,22 +759,6 @@ return {
Radio = function(base, basalt) Radio = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local selBg, selFg = self:getBoxSelectionColor()
local defBg, defFg = self:setBoxDefaultColor()
if (name == "selectionBg") then
self:setBoxSelectionColor(value, selFg)
elseif (name == "selectionFg") then
self:setBoxSelectionColor(selBg, value)
elseif (name == "defaultBg") then
self:setBoxDefaultColor(value, defFg)
elseif (name == "defaultFg") then
self:setBoxDefaultColor(defBg, value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -1079,16 +783,6 @@ return {
Menubar = function(base, basalt) Menubar = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
if (name == "space") then
self:setSpace(value)
elseif (name == "scrollable") then
self:setScrollable(value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
@@ -1103,34 +797,15 @@ return {
Graph = function(base, basalt) Graph = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local symbol, symbolCol = self:getGraphSymbol()
if (name == "maxEntries") then
self:setMaxEntries(value)
elseif (name == "type") then
self:setType(value)
elseif (name == "minValue") then
self:setMinValue(value)
elseif (name == "maxValue") then
self:setMaxValue(value)
elseif (name == "symbol") then
self:setGraphSymbol(value, symbolCol)
elseif (name == "symbolColor") then
self:setGraphSymbol(symbol, value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
"maxEntries", "maxEntries",
"type", "graphType",
"minValue", "minValue",
"maxValue", "maxValue",
"symbol", "graphSymbol",
"symbolColor" "graphSymbolColor"
}) })
if(data["item"]~=nil)then if(data["item"]~=nil)then
local tab = data["item"] local tab = data["item"]
@@ -1147,30 +822,9 @@ return {
Treeview = function(base, basalt) Treeview = function(base, basalt)
local object = { local object = {
updateValue = function(self, name, value)
if (value == nil) then return end
base.updateValue(self, name, value)
local selBg, selFg = self:getSelectionColor()
local xOffset, yOffset = self:getOffset()
if (name == "space") then
self:setSpace(value)
elseif (name == "scrollable") then
self:setScrollable(value)
elseif (name == "selectionBg") then
self:setSelectionColor(value, selFg)
elseif (name == "selectionFg") then
self:setSelectionColor(selBg, value)
elseif (name == "xOffset") then
self:setOffset(value, yOffset)
elseif (name == "yOffset") then
self:setOffset(xOffset, value)
end
end,
setValuesByXMLData = function(self, data, renderContext) setValuesByXMLData = function(self, data, renderContext)
base.setValuesByXMLData(self, data, renderContext) base.setValuesByXMLData(self, data, renderContext)
self:updateSpecifiedValuesByXMLData(data, { self:updateSpecifiedValuesByXMLData(data, {
"space",
"scrollable", "scrollable",
"selectionBg", "selectionBg",
"selectionFg", "selectionFg",