1.6.0@Dev

1.6.0 Version on dev branch
This commit is contained in:
Robert Jelic
2022-08-25 22:21:16 +02:00
parent e150737d32
commit 4857753c08
9 changed files with 81 additions and 82 deletions

View File

@@ -456,7 +456,6 @@ return function(name, parent, pTerm, basalt)
end; end;
setCursor = function(self, _blink, _xCursor, _yCursor, color) setCursor = function(self, _blink, _xCursor, _yCursor, color)
--if(_blink==cursorBlink)and(xCursor==_xCursor)and(yCursor==_yCursor)and(cursorColor==color)then return self end
if(self.parent~=nil)then if(self.parent~=nil)then
local obx, oby = self:getAnchorPosition() local obx, oby = self:getAnchorPosition()
self.parent:setCursor(_blink or false, (_xCursor or 0)+obx-1, (_yCursor or 0)+oby-1, color or cursorColor) self.parent:setCursor(_blink or false, (_xCursor or 0)+obx-1, (_yCursor or 0)+oby-1, color or cursorColor)
@@ -601,13 +600,13 @@ return function(name, parent, pTerm, basalt)
return self return self
end, end,
showBar = function(self, showIt) showBar = function(self, showIt) -- deprecated
self.barActive = showIt or not self.barActive self.barActive = showIt or not self.barActive
self:updateDraw() self:updateDraw()
return self return self
end; end;
setBar = function(self, text, bgCol, fgCol) setBar = function(self, text, bgCol, fgCol) -- deprecated
self.barText = text or "" self.barText = text or ""
self.barBackground = bgCol or self.barBackground self.barBackground = bgCol or self.barBackground
self.barTextcolor = fgCol or self.barTextcolor self.barTextcolor = fgCol or self.barTextcolor
@@ -615,7 +614,7 @@ return function(name, parent, pTerm, basalt)
return self return self
end; end;
setBarTextAlign = function(self, align) setBarTextAlign = function(self, align) -- deprecated
self.barTextAlign = align or "left" self.barTextAlign = align or "left"
self:updateDraw() self:updateDraw()
return self return self

View File

@@ -1,6 +1,5 @@
local basaltEvent = require("basaltEvent") local basaltEvent = require("basaltEvent")
local utils = require("utils") local utils = require("utils")
local log = require("basaltLogs")
local split = utils.splitString local split = utils.splitString
local numberFromString = utils.numberFromString local numberFromString = utils.numberFromString
local xmlValue = utils.getValueFromXML local xmlValue = utils.getValueFromXML
@@ -17,13 +16,14 @@ return function(name)
local initialized = false local initialized = false
local shadow = false local shadow = false
local borderLeft = false local borderColors = {
local borderTop = false left = false,
local borderRight = false right = false,
local borderBottom = false top = false,
bottom = false
}
local shadowColor = colors.black local shadowColor = colors.black
local borderColor = colors.black
local isEnabled = true local isEnabled = true
local isDragging = false local isDragging = false
local dragStartX, dragStartY, dragXOffset, dragYOffset = 0, 0, 0, 0 local dragStartX, dragStartY, dragXOffset, dragYOffset = 0, 0, 0, 0
@@ -102,13 +102,12 @@ return function(name)
if(xmlValue("enabled", data)~=nil)then if(xmlValue("enabled", data))then self:enable() else self:disable() end end if(xmlValue("enabled", data)~=nil)then if(xmlValue("enabled", data))then self:enable() else self:disable() end end
if(xmlValue("zIndex", data)~=nil)then self:setZIndex(xmlValue("zIndex", data)) end if(xmlValue("zIndex", data)~=nil)then self:setZIndex(xmlValue("zIndex", data)) end
if(xmlValue("anchor", data)~=nil)then self:setAnchor(xmlValue("anchor", data)) end if(xmlValue("anchor", data)~=nil)then self:setAnchor(xmlValue("anchor", data)) end
if(xmlValue("shadow", data)~=nil)then if(xmlValue("shadow", data))then self:showShadow(true) end end
if(xmlValue("shadowColor", data)~=nil)then self:setShadow(colors[xmlValue("shadowColor", data)]) end if(xmlValue("shadowColor", data)~=nil)then self:setShadow(colors[xmlValue("shadowColor", data)]) end
if(xmlValue("border", data)~=nil)then if(xmlValue("border", data))then borderLeft,borderTop,borderRight,borderBottom = true,true,true,true end end if(xmlValue("border", data)~=nil)then self:setBorder(colors[xmlValue("border", data)]) end
if(xmlValue("borderLeft", data)~=nil)then if(xmlValue("borderLeft", data))then borderLeft = true else borderLeft = false end end if(xmlValue("borderLeft", data)~=nil)then borderColors["left"] = xmlValue("borderLeft", data) end
if(xmlValue("borderTop", data)~=nil)then if(xmlValue("borderTop", data))then borderTop = true else borderTop = false end end if(xmlValue("borderTop", data)~=nil)then borderColors["top"] = xmlValue("borderTop", data) end
if(xmlValue("borderRight", data)~=nil)then if(xmlValue("borderRight", data))then borderRight = true else borderRight = false end end if(xmlValue("borderRight", data)~=nil)then borderColors["right"] = xmlValue("borderRight", data) end
if(xmlValue("borderBottom", data)~=nil)then if(xmlValue("borderBottom", data))then borderBottom = true else borderBottom = false end end if(xmlValue("borderBottom", data)~=nil)then borderColors["bottom"] = xmlValue("borderBottom", data) end
if(xmlValue("borderColor", data)~=nil)then self:setBorder(colors[xmlValue("borderColor", data)]) end if(xmlValue("borderColor", data)~=nil)then self:setBorder(colors[xmlValue("borderColor", data)]) end
if(xmlValue("ignoreOffset", data)~=nil)then if(xmlValue("ignoreOffset", data))then self:ignoreOffset(true) end end if(xmlValue("ignoreOffset", data)~=nil)then if(xmlValue("ignoreOffset", data))then self:ignoreOffset(true) end end
if(xmlValue("onClick", data)~=nil)then self:generateXMLEventFunction(self.onClick, xmlValue("onClick", data)) end if(xmlValue("onClick", data)~=nil)then self:generateXMLEventFunction(self.onClick, xmlValue("onClick", data)) end
@@ -337,14 +336,13 @@ return function(name)
return self.fgColor return self.fgColor
end; end;
showShadow = function(self, show)
shadow = show or (not shadow)
self:updateDraw()
return self
end;
setShadow = function(self, color) setShadow = function(self, color)
shadowColor = color if(color==false)then
shadow = false
else
shadowColor = color
shadow = true
end
self:updateDraw() self:updateDraw()
return self return self
end; end;
@@ -353,30 +351,27 @@ return function(name)
return shadow; return shadow;
end; end;
showBorder = function(self, ...) setBorder = function(self, ...)
for _,v in pairs(table.pack(...))do if(...~=nil)then
if(v=="left")or(...==nil)then local t = {...}
borderLeft = true for k,v in pairs(t)do
end if(v=="left")or(#t==1)then
if(v=="top")or(...==nil)then borderColors["left"] = t[1]
borderTop = true end
end if(v=="top")or(#t==1)then
if(v=="right")or(...==nil)then borderColors["top"] = t[1]
borderRight = true end
end if(v=="right")or(#t==1)then
if(v=="bottom")or(...==nil)then borderColors["right"] = t[1]
borderBottom = true end
if(v=="bottom")or(#t==1)then
borderColors["bottom"] = t[1]
end
end end
end end
self:updateDraw() self:updateDraw()
return self return self
end; end;
setBorder = function(self, color)
borderColor = color
self:updateDraw()
return self
end;
getBorder = function(self, side) getBorder = function(self, side)
if(side=="left")then if(side=="left")then
@@ -418,40 +413,41 @@ return function(name)
self.parent:drawForegroundBox(x+1, y+h, w, 1, shadowColor) self.parent:drawForegroundBox(x+1, y+h, w, 1, shadowColor)
self.parent:drawForegroundBox(x+w, y+1, 1, h, shadowColor) self.parent:drawForegroundBox(x+w, y+1, 1, h, shadowColor)
end end
if(borderLeft)then if(borderColors["left"]~=false)then
self.parent:drawTextBox(x-1, y, 1, h, "\149") self.parent:drawTextBox(x-1, y, 1, h, "\149")
self.parent:drawForegroundBox(x-1, y, 1, h, borderColor) self.parent:drawBackgroundBox(x-1, y, 1, h, borderColors["left"])
if(self.bgColor~=false)then self.parent:drawBackgroundBox(x-1, y, 1, h, self.bgColor) end self.parent:drawForegroundBox(x-1, y, 1, h, self.parent.bgColor)
end end
if(borderLeft)and(borderTop)then if(borderColors["left"]~=false)and(borderColors["top"]~=false)then
self.parent:drawTextBox(x-1, y-1, 1, 1, "\151") self.parent:drawTextBox(x-1, y-1, 1, 1, "\151")
self.parent:drawForegroundBox(x-1, y-1, 1, 1, borderColor) self.parent:drawBackgroundBox(x-1, y-1, 1, 1, borderColors["left"])
if(self.bgColor~=false)then self.parent:drawBackgroundBox(x-1, y-1, 1, 1, self.bgColor) end self.parent:drawForegroundBox(x-1, y-1, 1, 1, self.parent.bgColor)
end end
if(borderTop)then if(borderColors["top"]~=false)then
self.parent:drawTextBox(x, y-1, w, 1, "\131") self.parent:drawTextBox(x, y-1, w, 1, "\131")
self.parent:drawForegroundBox(x, y-1, w, 1, borderColor) self.parent:drawBackgroundBox(x, y-1, w, 1, borderColors["top"])
if(self.bgColor~=false)then self.parent:drawBackgroundBox(x, y-1, w, 1, self.bgColor) end self.parent:drawForegroundBox(x, y-1, w, 1, self.parent.bgColor)
end end
if(borderTop)and(borderRight)then if(borderColors["top"]~=false)and(borderColors["right"]~=false)then
self.parent:drawTextBox(x+w, y-1, 1, 1, "\149") self.parent:drawTextBox(x+w, y-1, 1, 1, "\148")
self.parent:drawForegroundBox(x+w, y-1, 1, 1, borderColor) self.parent:drawForegroundBox(x+w, y-1, 1, 1, borderColors["right"])
end end
if(borderRight)then if(borderColors["right"]~=false)then
self.parent:drawTextBox(x+w, y, 1, h, "\149") self.parent:drawTextBox(x+w, y, 1, h, "\149")
self.parent:drawForegroundBox(x+w, y, 1, h, borderColor) self.parent:drawForegroundBox(x+w, y, 1, h, borderColors["right"])
end end
if(borderRight)and(borderBottom)then if(borderColors["right"]~=false)and(borderColors["bottom"]~=false)then
self.parent:drawTextBox(x+w, y+h, 1, 1, "\129") self.parent:drawTextBox(x+w, y+h, 1, 1, "\129")
self.parent:drawForegroundBox(x+w, y+h, 1, 1, borderColor) self.parent:drawForegroundBox(x+w, y+h, 1, 1, borderColors["right"])
end end
if(borderBottom)then if(borderColors["bottom"]~=false)then
self.parent:drawTextBox(x, y+h, w, 1, "\131") self.parent:drawTextBox(x, y+h, w, 1, "\131")
self.parent:drawForegroundBox(x, y+h, w, 1, borderColor) self.parent:drawForegroundBox(x, y+h, w, 1, borderColors["bottom"])
end end
if(borderBottom)and(borderLeft)then if(borderColors["bottom"]~=false)and(borderColors["left"]~=false)then
self.parent:drawTextBox(x-1, y+h, 1, 1, "\131") self.parent:drawTextBox(x-1, y+h, 1, 1, "\130")
self.parent:drawForegroundBox(x-1, y+h, 1, 1, borderColor) self.parent:drawForegroundBox(x-1, y+h, 1, 1, borderColors["left"])
end end
end end
draw = false draw = false

View File

@@ -1,4 +1,3 @@
local xmlValue = require("utils").getValueFromXML local xmlValue = require("utils").getValueFromXML
local basaltEvent = require("basaltEvent") local basaltEvent = require("basaltEvent")
@@ -134,9 +133,19 @@ return function(name)
end end
local function predefinedLerp(v1,v2,d,t,get,set) local function predefinedLerp(v1,v2,d,t,get,set,typ,self)
local x,y local x,y
local name = ""
if(_OBJ.parent~=nil)then name = _OBJ.parent:getName() end
name = name.._OBJ:getName()
addAnimationPart(t+0.05, function() addAnimationPart(t+0.05, function()
if(typ~=nil)then
if(activeAnimations[typ]==nil)then activeAnimations[typ] = {} end
if(activeAnimations[typ][name]~=nil)then
activeAnimations[typ][name]:cancel()
end
activeAnimations[typ][name] = self
end
x,y = get(_OBJ) x,y = get(_OBJ)
end) end)
for n=0.05,d+0.01,0.05 do for n=0.05,d+0.01,0.05 do
@@ -144,6 +153,13 @@ return function(name)
local _x = math.floor(lerp.lerp(x, v1, lerp[mode](n / d))+0.5) local _x = math.floor(lerp.lerp(x, v1, lerp[mode](n / d))+0.5)
local _y = math.floor(lerp.lerp(y, v2, lerp[mode](n / d))+0.5) local _y = math.floor(lerp.lerp(y, v2, lerp[mode](n / d))+0.5)
set(_OBJ, _x,_y) set(_OBJ, _x,_y)
if(typ~=nil)then
if(n>=d-0.01)then
if(activeAnimations[typ][name]==self)then
activeAnimations[typ][name] = nil
end
end
end
end) end)
end end
end; end;
@@ -291,19 +307,19 @@ return function(name)
move = function(self, x, y, duration, timer, obj) move = function(self, x, y, duration, timer, obj)
_OBJ = obj or _OBJ _OBJ = obj or _OBJ
predefinedLerp(x,y,duration,timer or 0,_OBJ.getPosition,_OBJ.setPosition) predefinedLerp(x,y,duration,timer or 0,_OBJ.getPosition,_OBJ.setPosition, "position", self)
return self return self
end, end,
offset = function(self, x, y, duration, timer, obj) offset = function(self, x, y, duration, timer, obj)
_OBJ = obj or _OBJ _OBJ = obj or _OBJ
predefinedLerp(x,y,duration,timer or 0,_OBJ.getOffset,_OBJ.setOffset) predefinedLerp(x,y,duration,timer or 0,_OBJ.getOffset,_OBJ.setOffset, "offset", self)
return self return self
end, end,
size = function(self, w, h, duration, timer, obj) size = function(self, w, h, duration, timer, obj)
_OBJ = obj or _OBJ _OBJ = obj or _OBJ
predefinedLerp(w,h,duration,timer or 0,_OBJ.getSize,_OBJ.setSize) predefinedLerp(w,h,duration,timer or 0,_OBJ.getSize,_OBJ.setSize, "size", self)
return self return self
end, end,
@@ -403,12 +419,6 @@ return function(name)
play = function(self, infinite) play = function(self, infinite)
self:cancel() self:cancel()
if(_OBJ~=nil)then
if(activeAnimations[_OBJ:getName()]~=nil)then
activeAnimations[_OBJ:getName()]:cancel()
end
activeAnimations[_OBJ:getName()] = self
end
animationActive = true animationActive = true
infinitePlay = infinite and true or false infinitePlay = infinite and true or false
index = 1 index = 1
@@ -427,13 +437,6 @@ return function(name)
end; end;
cancel = function(self) cancel = function(self)
if(_OBJ~=nil)then
if(activeAnimations[_OBJ:getName()]~=nil)then
if(activeAnimations[_OBJ:getName()]==self)then
activeAnimations[_OBJ:getName()] = nil
end
end
end
if(timerObj~=nil)then if(timerObj~=nil)then
os.cancelTimer(timerObj) os.cancelTimer(timerObj)
infinitePlay = false infinitePlay = false

View File

@@ -91,7 +91,7 @@ return function(name)
setSelectedItem = function(self, bgCol, fgCol, active) setSelectedItem = function(self, bgCol, fgCol, active)
itemSelectedBG = bgCol or self.bgColor itemSelectedBG = bgCol or self.bgColor
itemSelectedFG = fgCol or self.fgColor itemSelectedFG = fgCol or self.fgColor
selectionColorActive = active selectionColorActive = active~=nil and active or true
self:updateDraw() self:updateDraw()
return self return self
end; end;

View File

@@ -1,4 +1,5 @@
local Object = require("Object") local Object = require("Object")
local log = require("basaltLogs")
return function(name) return function(name)
-- Pane -- Pane