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