getProperty() and setProperty() (#80)

* Fuck

* Add getProperty() and setProperty()

* Add getters and setters to VisualObject

* Update Frame and BaseFrame

* Update Flexbox

* Update Button and Label

* Update Input

* Update Image

* Update Checkbox

* Update Program

* Update Progressbar

* Update Slider

* Update Scrollbar

* Update Switch

* Update Textfield

* Update Timer

* Update List

* Update Dropdown

* Update Radio

* Update Menubar

* Update Graph

* Update Treeview
This commit is contained in:
Sabine Lim
2023-05-16 03:24:16 +10:00
committed by GitHub
parent 015666ad14
commit bdc241575b
24 changed files with 436 additions and 361 deletions

View File

@@ -41,6 +41,22 @@ return function(name, basalt)
return self
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, ...)
if(self==basalt.getActiveFrame())then
if(type(col)=="string")then

View File

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

View File

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

View File

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

View File

@@ -76,6 +76,10 @@ return function(name, basalt)
return spacing
end,
getFlexDirection = function(self)
return flexDirection
end,
setFlexDirection = function(self, direction)
if direction == "row" or direction == "column" then
flexDirection = direction
@@ -84,6 +88,10 @@ return function(name, basalt)
return self
end,
getJustifyContent = function(self)
return justifyContent
end,
setJustifyContent = function(self, alignment)
if alignment == "flex-start" or alignment == "flex-end" or alignment == "center" or alignment == "space-between" or alignment == "space-around" then
justifyContent = alignment
@@ -92,6 +100,10 @@ return function(name, basalt)
return self
end,
getAlignItems = function(self)
return alignItems
end,
setAlignItems = function(self, alignment)
if alignment == "flex-start" or alignment == "flex-end" or alignment == "center" or alignment == "space-between" or alignment == "space-around" then
alignItems = alignment

View File

@@ -38,6 +38,22 @@ return function(name, basalt)
return self
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, ...)
base.setParent(self, p, ...)
parent = p

View File

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

View File

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

View File

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

View File

@@ -151,10 +151,26 @@ return function(name, basalt)
return self
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)
return itemSelectedBG, itemSelectedFG
end,
getSelectionBG = function(self)
return itemSelectedBG
end,
getSelectionFG = function(self)
return itemSelectedFG
end,
isSelectionColorActive = function(self)
return selectionColorActive
end,
@@ -166,6 +182,10 @@ return function(name, basalt)
return self
end,
getScrollable = function(self)
return scrollable
end,
scrollHandler = function(self, dir, x, y)
if(base.scrollHandler(self, dir, x, y))then
if(scrollable)then

View File

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

View File

@@ -33,7 +33,21 @@ return function(name, basalt)
isType = function(self, t)
return objectType==t
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)
return name
end,

View File

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

View File

@@ -25,6 +25,10 @@ return function(name, basalt)
return self
end,
getDirection = function(self)
return direction
end,
setProgressBar = function(self, color, symbol, symbolcolor)
activeBarColor = color or activeBarColor
activeBarSymbol = symbol or activeBarSymbol
@@ -37,12 +41,40 @@ return function(name, basalt)
return activeBarColor, activeBarSymbol, activeBarSymbolCol
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)
bgBarSymbol = symbol:sub(1, 1)
self:updateDraw()
return self
end,
getBackgroundSymbol = function(self)
return bgBarSymbol
end,
setProgress = function(self, value)
if (value >= 0) and (value <= 100) and (progress ~= value) then
progress = value

View File

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

View File

@@ -62,6 +62,26 @@ return function(name, basalt)
return self
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)
index = _index
if (index < 1) then
@@ -81,6 +101,10 @@ return function(name, basalt)
return self
end,
getScrollAmount = function(self)
return scrollAmount
end,
getIndex = function(self)
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
@@ -94,6 +118,10 @@ return function(name, basalt)
return self
end,
getSymbolSize = function(self)
return symbolSize
end,
setBarType = function(self, _typ)
barType = _typ:lower()
updateSymbolSize()
@@ -101,6 +129,10 @@ return function(name, basalt)
return self
end,
getBarType = function(self)
return barType
end,
mouseHandler = function(self, button, x, y, ...)
if (base.mouseHandler(self, button, x, y, ...)) then
mouseEvent(self, button, x, y)

View File

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

View File

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

View File

@@ -161,10 +161,26 @@ return function(name, basalt)
return self
end,
setSelectionFG = function(self, fg)
return self:setSelection(fg, nil)
end,
setSelectionBG = function(self, bg)
return self:setSelection(nil, bg)
end,
getSelection = function(self)
return selectionFG, selectionBG
end,
getSelectionFG = function(self)
return selectionFG
end,
getSelectionBG = function(self)
return selectionBG
end,
getLines = function(self)
return lines
end,
@@ -289,6 +305,22 @@ return function(name, basalt)
return self
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)
base.getFocusHandler(self)
local obx, oby = self:getPosition()

View File

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

View File

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

View File

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