very small bugfixes
- basalt_resize and basalt_reposition events fix - Animations now automatically cancel other animations on same object - some smaller fixxes
This commit is contained in:
@@ -347,7 +347,6 @@ return function(name, parent, pTerm, basalt)
|
|||||||
focusedObjectCache:getFocusHandler()
|
focusedObjectCache:getFocusHandler()
|
||||||
end
|
end
|
||||||
focusedObject = focusedObjectCache
|
focusedObject = focusedObjectCache
|
||||||
focusedObjectCache = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -389,7 +388,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
if (objects[index] ~= nil) then
|
if (objects[index] ~= nil) then
|
||||||
for _, value in pairs(objects[index]) do
|
for _, value in pairs(objects[index]) do
|
||||||
if (value.eventHandler ~= nil) then
|
if (value.eventHandler ~= nil) then
|
||||||
value:sendEvent("basalt_resize", value, self)
|
value:eventHandler("basalt_resize", value, self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -419,7 +418,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
if (objects[index] ~= nil) then
|
if (objects[index] ~= nil) then
|
||||||
for _, value in pairs(objects[index]) do
|
for _, value in pairs(objects[index]) do
|
||||||
if (value.eventHandler ~= nil) then
|
if (value.eventHandler ~= nil) then
|
||||||
value:sendEvent("basalt_reposition", value, self)
|
value:eventHandler("basalt_reposition", value, self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ return function(name)
|
|||||||
local anchor = "topLeft"
|
local anchor = "topLeft"
|
||||||
local ignOffset = false
|
local ignOffset = false
|
||||||
local isVisible = true
|
local isVisible = true
|
||||||
|
local initialized = false
|
||||||
|
|
||||||
local shadow = false
|
local shadow = false
|
||||||
local borderLeft = false
|
local borderLeft = false
|
||||||
@@ -308,7 +309,7 @@ return function(name)
|
|||||||
|
|
||||||
setBackground = function(self, color, symbol, symbolCol)
|
setBackground = function(self, color, symbol, symbolCol)
|
||||||
self.bgColor = color or false
|
self.bgColor = color or false
|
||||||
self.bgSymbol = symbol or (color~=false and self.bgSymbol or false)
|
self.bgSymbol = symbol or (self.bgColor~=false and self.bgSymbol or false)
|
||||||
self.bgSymbolColor = symbolCol or self.bgSymbolColor
|
self.bgSymbolColor = symbolCol or self.bgSymbolColor
|
||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
@@ -406,8 +407,10 @@ return function(name)
|
|||||||
self.parent:drawBackgroundBox(x, y, w, h, self.bgColor)
|
self.parent:drawBackgroundBox(x, y, w, h, self.bgColor)
|
||||||
end
|
end
|
||||||
if(self.bgSymbol~=false)then
|
if(self.bgSymbol~=false)then
|
||||||
self.parent:drawForegroundBox(x, y, w, h, self.bgSymbolColor)
|
|
||||||
self.parent:drawTextBox(x, y, w, h, self.bgSymbol)
|
self.parent:drawTextBox(x, y, w, h, self.bgSymbol)
|
||||||
|
if(self.bgSymbol~=" ")then
|
||||||
|
self.parent:drawForegroundBox(x, y, w, h, self.bgSymbolColor)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if(shadow)then
|
if(shadow)then
|
||||||
self.parent:drawBackgroundBox(x+1, y+h, w, 1, shadowColor)
|
self.parent:drawBackgroundBox(x+1, y+h, w, 1, shadowColor)
|
||||||
@@ -735,9 +738,6 @@ return function(name)
|
|||||||
if(self:isCoordsInObject(x, y))then
|
if(self:isCoordsInObject(x, y))then
|
||||||
local val = eventSystem:sendEvent("mouse_up", self, "mouse_up", button, x, y)
|
local val = eventSystem:sendEvent("mouse_up", self, "mouse_up", button, x, y)
|
||||||
if(val==false)then return false end
|
if(val==false)then return false end
|
||||||
if(self.parent~=nil)then
|
|
||||||
self.parent:setFocusedObject(self)
|
|
||||||
end
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -829,7 +829,6 @@ return function(name)
|
|||||||
getFocusHandler = function(self)
|
getFocusHandler = function(self)
|
||||||
local val = eventSystem:sendEvent("get_focus", self)
|
local val = eventSystem:sendEvent("get_focus", self)
|
||||||
if(val~=nil)then return val end
|
if(val~=nil)then return val end
|
||||||
log("Focus "..self:getName())
|
|
||||||
return true
|
return true
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -837,7 +836,6 @@ return function(name)
|
|||||||
isDragging = false
|
isDragging = false
|
||||||
local val = eventSystem:sendEvent("lose_focus", self)
|
local val = eventSystem:sendEvent("lose_focus", self)
|
||||||
if(val~=nil)then return val end
|
if(val~=nil)then return val end
|
||||||
log("Losefocus "..self:getName())
|
|
||||||
return true
|
return true
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -849,6 +847,10 @@ return function(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if not(initialized)then
|
||||||
|
initialized = true
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ local createText = utils.createText
|
|||||||
|
|
||||||
|
|
||||||
local baseTerm = term.current()
|
local baseTerm = term.current()
|
||||||
local version = 5
|
local version = "1.6.0"
|
||||||
local debugger = true
|
local debugger = true
|
||||||
|
|
||||||
local projectDirectory = fs.getDir(table.pack(...)[2] or "")
|
local projectDirectory = fs.getDir(table.pack(...)[2] or "")
|
||||||
|
|||||||
@@ -403,6 +403,12 @@ 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
|
||||||
@@ -421,6 +427,13 @@ 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
|
||||||
|
|||||||
@@ -57,10 +57,12 @@ return function(name)
|
|||||||
setValue = function(self, val)
|
setValue = function(self, val)
|
||||||
base.setValue(self, tostring(val))
|
base.setValue(self, tostring(val))
|
||||||
if not (internalValueChange) then
|
if not (internalValueChange) then
|
||||||
textX = tostring(val):len() + 1
|
if(self:isFocused())then
|
||||||
wIndex = math.max(1, textX-self:getWidth()+1)
|
textX = tostring(val):len() + 1
|
||||||
local obx, oby = self:getAnchorPosition()
|
wIndex = math.max(1, textX-self:getWidth()+1)
|
||||||
self.parent:setCursor(true, obx + textX - wIndex, oby+math.floor(self.height/2), self.fgColor)
|
local obx, oby = self:getAnchorPosition()
|
||||||
|
self.parent:setCursor(true, obx + textX - wIndex, oby+math.floor(self.height/2), self.fgColor)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ return function(name)
|
|||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
setSize = function(self, width, height)
|
setSize = function(self, width, height, rel)
|
||||||
base.setSize(self, width, height)
|
base.setSize(self, width, height, rel)
|
||||||
autoSize = false
|
autoSize = false
|
||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
@@ -96,40 +96,38 @@ return function(name)
|
|||||||
if not(autoSize)then
|
if not(autoSize)then
|
||||||
local text = createText(self:getValue(), self:getWidth())
|
local text = createText(self:getValue(), self:getWidth())
|
||||||
for k,v in pairs(text)do
|
for k,v in pairs(text)do
|
||||||
self.parent:setText(obx, oby+k-1, v)
|
self.parent:writeText(obx, oby+k-1, v, self.bgColor, self.fgColor)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for n = 1, h do
|
self.parent:writeText(obx, oby, self:getValue(), self.bgColor, self.fgColor)
|
||||||
if (n == verticalAlign) then
|
|
||||||
self.parent:setText(obx, oby + (n - 1), utils.getTextHorizontalAlign(self:getValue(), w, textHorizontalAlign))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local tData = bigFont(fontsize, self:getValue(), self.fgColor, self.bgColor or colors.black)
|
local tData = bigFont(fontsize, self:getValue(), self.fgColor, self.bgColor or colors.lightGray)
|
||||||
if(autoSize)then
|
if(autoSize)then
|
||||||
self:setSize(#tData[1][1], #tData[1]-1)
|
self:setSize(#tData[1][1], #tData[1]-1)
|
||||||
end
|
end
|
||||||
for n = 1, h do
|
local oX, oY = self.parent:getSize()
|
||||||
if (n == verticalAlign) then
|
local cX, cY = #tData[1][1], #tData[1]
|
||||||
local oX, oY = self.parent:getSize()
|
obx = obx or math.floor((oX - cX) / 2) + 1
|
||||||
local cX, cY = #tData[1][1], #tData[1]
|
oby = oby or math.floor((oY - cY) / 2) + 1
|
||||||
obx = obx or math.floor((oX - cX) / 2) + 1
|
|
||||||
oby = oby or math.floor((oY - cY) / 2) + 1
|
|
||||||
|
|
||||||
for i = 1, cY do
|
for i = 1, cY do
|
||||||
self.parent:setFG(obx, oby + i + n - 2, utils.getTextHorizontalAlign(tData[2][i], w, textHorizontalAlign))
|
self.parent:setFG(obx, oby + i - 2, tData[2][i])
|
||||||
self.parent:setText(obx, oby + i + n - 2, utils.getTextHorizontalAlign(tData[1][i], w, textHorizontalAlign))
|
self.parent:setBG(obx, oby + i - 2, tData[3][i])
|
||||||
end
|
self.parent:setText(obx, oby + i - 2, tData[1][i])
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
init = function(self)
|
init = function(self)
|
||||||
self.bgColor = self.parent:getTheme("LabelBG")
|
if(base.init(self))then
|
||||||
self.fgColor = self.parent:getTheme("LabelText")
|
self.bgColor = self.parent:getTheme("LabelBG")
|
||||||
|
self.fgColor = self.parent:getTheme("LabelText")
|
||||||
|
if(self.parent.bgColor==colors.black)and(self.fgColor==colors.black)then
|
||||||
|
self.fgColor = colors.lightGray
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,21 @@ return function(name)
|
|||||||
local objectType = "Pane"
|
local objectType = "Pane"
|
||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
init = function(self)
|
|
||||||
self.bgColor = self.parent:getTheme("PaneBG")
|
|
||||||
self.fgColor = self.parent:getTheme("PaneBG")
|
|
||||||
end,
|
|
||||||
getType = function(self)
|
getType = function(self)
|
||||||
return objectType
|
return objectType
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
setBackground = function(self, col, sym, symC)
|
||||||
|
base.setBackground(self, col, sym, symC)
|
||||||
|
return self
|
||||||
|
end,
|
||||||
|
|
||||||
|
init = function(self)
|
||||||
|
if(base.init(self))then
|
||||||
|
self.bgColor = self.parent:getTheme("PaneBG")
|
||||||
|
self.fgColor = self.parent:getTheme("PaneBG")
|
||||||
|
end
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmetatable(object, base)
|
return setmetatable(object, base)
|
||||||
|
|||||||
@@ -135,21 +135,20 @@ return function(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
if (base.draw(self)) then
|
if (self.parent ~= nil) then
|
||||||
if (self.parent ~= nil) then
|
local obx, oby = self:getAnchorPosition()
|
||||||
local obx, oby = self:getAnchorPosition()
|
for _, value in pairs(list) do
|
||||||
for _, value in pairs(list) do
|
if (value == self:getValue()) then
|
||||||
if (value == self:getValue()) then
|
if (align == "left") then
|
||||||
if (align == "left") then
|
self.parent:writeText(value.x + obx - 1, value.y + oby - 1, symbol, boxSelectedBG, boxSelectedFG)
|
||||||
self.parent:writeText(value.x + obx - 1, value.y + oby - 1, symbol, boxSelectedBG, boxSelectedFG)
|
self.parent:writeText(value.x + 2 + obx - 1, value.y + oby - 1, value.text, itemSelectedBG, itemSelectedFG)
|
||||||
self.parent:writeText(value.x + 2 + obx - 1, value.y + oby - 1, value.text, itemSelectedBG, itemSelectedFG)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.parent:drawBackgroundBox(value.x + obx - 1, value.y + oby - 1, 1, 1, boxNotSelectedBG or self.bgColor)
|
|
||||||
self.parent:writeText(value.x + 2 + obx - 1, value.y + oby - 1, value.text, value.bgCol, value.fgCol)
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
self.parent:drawBackgroundBox(value.x + obx - 1, value.y + oby - 1, 1, 1, boxNotSelectedBG or self.bgColor)
|
||||||
|
self.parent:writeText(value.x + 2 + obx - 1, value.y + oby - 1, value.text, value.bgCol, value.fgCol)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,9 @@ return function(name)
|
|||||||
index = math.min(index, (barType == "vertical" and h or w) - (symbolSize - 1))
|
index = math.min(index, (barType == "vertical" and h or w) - (symbolSize - 1))
|
||||||
self:setValue(maxValue / (barType == "vertical" and h or w) * index)
|
self:setValue(maxValue / (barType == "vertical" and h or w) * index)
|
||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
end,
|
end,
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
|
|||||||
Reference in New Issue
Block a user