Drawsystem update
- changed the draw system to only draw when something really changes - added stopUpdate - changed focusSystem a bit
This commit is contained in:
249
Basalt/Frame.lua
249
Basalt/Frame.lua
@@ -307,7 +307,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function recalculateDynamicValues()
|
local function recalculateDynamicValues(self)
|
||||||
if(#dynamicValues>0)then
|
if(#dynamicValues>0)then
|
||||||
for n=1,dynValueId do
|
for n=1,dynValueId do
|
||||||
if(dynamicValues[n]~=nil)then
|
if(dynamicValues[n]~=nil)then
|
||||||
@@ -320,6 +320,15 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for _, index in pairs(objZIndex) do
|
||||||
|
if (objects[index] ~= nil) then
|
||||||
|
for _, value in pairs(objects[index]) do
|
||||||
|
if (value.eventHandler ~= nil) then
|
||||||
|
value:eventHandler("dynamicValueEvent", self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -340,6 +349,18 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function focusSystem(self)
|
||||||
|
if(focusedObject~=focusedOBjectCache)then
|
||||||
|
if(focusedObject~=nil)then
|
||||||
|
focusedObject:loseFocusHandler()
|
||||||
|
end
|
||||||
|
if(focusedOBjectCache~=nil)then
|
||||||
|
focusedOBjectCache:getFocusHandler()
|
||||||
|
end
|
||||||
|
focusedObject = focusedOBjectCache
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
object = {
|
object = {
|
||||||
barActive = false,
|
barActive = false,
|
||||||
barBackground = colors.gray,
|
barBackground = colors.gray,
|
||||||
@@ -383,13 +404,14 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
recalculateDynamicValues()
|
self:recalculateDynamicValues()
|
||||||
autoSize = false
|
autoSize = false
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setTheme = function(self, _theme)
|
setTheme = function(self, _theme)
|
||||||
theme = _theme
|
theme = _theme
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -408,6 +430,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:recalculateDynamicValues()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -418,6 +441,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
setOffset = function(self, xO, yO)
|
setOffset = function(self, xO, yO)
|
||||||
xOffset = xO ~= nil and math.floor(xO < 0 and math.abs(xO) or -xO) or xOffset
|
xOffset = xO ~= nil and math.floor(xO < 0 and math.abs(xO) or -xO) or xOffset
|
||||||
yOffset = yO ~= nil and math.floor(yO < 0 and math.abs(yO) or -yO) or yOffset
|
yOffset = yO ~= nil and math.floor(yO < 0 and math.abs(yO) or -yO) or yOffset
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -439,10 +463,12 @@ 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)
|
||||||
else
|
else
|
||||||
|
log(_blink)
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition(self:getX(), self:getY(), true))
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition(self:getX(), self:getY(), true))
|
||||||
cursorBlink = _blink or false
|
cursorBlink = _blink or false
|
||||||
if (_xCursor ~= nil) then
|
if (_xCursor ~= nil) then
|
||||||
@@ -452,7 +478,13 @@ return function(name, parent, pTerm, basalt)
|
|||||||
yCursor = oby + _yCursor - 1
|
yCursor = oby + _yCursor - 1
|
||||||
end
|
end
|
||||||
cursorColor = color or cursorColor
|
cursorColor = color or cursorColor
|
||||||
self:setVisualChanged()
|
if (cursorBlink) then
|
||||||
|
termObject.setTextColor(cursorColor)
|
||||||
|
termObject.setCursorPos(xCursor, yCursor)
|
||||||
|
termObject.setCursorBlink(cursorBlink)
|
||||||
|
else
|
||||||
|
termObject.setCursorBlink(false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
@@ -547,7 +579,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
|
|
||||||
setValuesByXMLData = function(self, data)
|
setValuesByXMLData = function(self, data)
|
||||||
base.setValuesByXMLData(self, data)
|
base.setValuesByXMLData(self, data)
|
||||||
if(xmlValue("moveable", data)~=nil)then if(xmlValue("moveable", data))then self:setMovable(true) end end
|
if(xmlValue("movable", data)~=nil)then if(xmlValue("movable", data))then self:setMovable(true) end end
|
||||||
if(xmlValue("scrollable", data)~=nil)then if(xmlValue("scrollable", data))then self:setScrollable(true) end end
|
if(xmlValue("scrollable", data)~=nil)then if(xmlValue("scrollable", data))then self:setScrollable(true) end end
|
||||||
if(xmlValue("monitor", data)~=nil)then self:setMonitor(xmlValue("monitor", data)):show() end
|
if(xmlValue("monitor", data)~=nil)then self:setMonitor(xmlValue("monitor", data)):show() end
|
||||||
if(xmlValue("mirror", data)~=nil)then self:setMirror(xmlValue("mirror", data)) end
|
if(xmlValue("mirror", data)~=nil)then self:setMirror(xmlValue("mirror", data)) end
|
||||||
@@ -579,7 +611,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
|
|
||||||
showBar = function(self, showIt)
|
showBar = function(self, showIt)
|
||||||
self.barActive = showIt or not self.barActive
|
self.barActive = showIt or not self.barActive
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -587,13 +619,13 @@ return function(name, parent, pTerm, basalt)
|
|||||||
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
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setBarTextAlign = function(self, align)
|
setBarTextAlign = function(self, align)
|
||||||
self.barTextAlign = align or "left"
|
self.barTextAlign = align or "left"
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -634,35 +666,19 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
basaltDraw = BasaltDraw(termObject)
|
basaltDraw = BasaltDraw(termObject)
|
||||||
monSide = side or nil
|
monSide = side or nil
|
||||||
|
self:updateDraw()
|
||||||
return self;
|
return self;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getVisualChanged = function(self)
|
|
||||||
local changed = base.getVisualChanged(self)
|
|
||||||
for _, index in pairs(objZIndex) do
|
|
||||||
if (objects[index] ~= nil) then
|
|
||||||
for _, value in pairs(objects[index]) do
|
|
||||||
if (value.getVisualChanged ~= nil and value:getVisualChanged()) then
|
|
||||||
changed = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return changed
|
|
||||||
end;
|
|
||||||
|
|
||||||
loseFocusHandler = function(self)
|
loseFocusHandler = function(self)
|
||||||
base.loseFocusHandler(self)
|
base.loseFocusHandler(self)
|
||||||
if(focusedOBjectCache~=nil)then
|
if(focusedObject~=nil)then focusedObject:loseFocusHandler() end
|
||||||
focusedOBjectCache:loseFocusHandler()
|
|
||||||
focusedOBjectCache = nil
|
|
||||||
end
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getFocusHandler = function(self)
|
getFocusHandler = function(self)
|
||||||
base.getFocusHandler(self)
|
base.getFocusHandler(self)
|
||||||
if(isMovable)then
|
if (self.parent ~= nil) then
|
||||||
if (self.parent ~= nil) then
|
if(isMovable)then
|
||||||
self.parent:removeEvents(self)
|
self.parent:removeEvents(self)
|
||||||
self.parent:removeObject(self)
|
self.parent:removeObject(self)
|
||||||
self.parent:addObject(self)
|
self.parent:addObject(self)
|
||||||
@@ -671,8 +687,10 @@ return function(name, parent, pTerm, basalt)
|
|||||||
self.parent:addEvent(k, self)
|
self.parent:addEvent(k, self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if(focusedObject~=nil)then focusedObject:getFocusHandler() end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
eventHandler = function(self, event, p1, p2, p3, p4)
|
eventHandler = function(self, event, p1, p2, p3, p4)
|
||||||
@@ -704,6 +722,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
monitorAttached = true
|
monitorAttached = true
|
||||||
termObject = peripheral.wrap(monSide)
|
termObject = peripheral.wrap(monSide)
|
||||||
basaltDraw = BasaltDraw(termObject)
|
basaltDraw = BasaltDraw(termObject)
|
||||||
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if(event == "peripheral_detach")and(p1==monSide)then
|
if(event == "peripheral_detach")and(p1==monSide)then
|
||||||
@@ -719,7 +738,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
monitorAttached = false
|
monitorAttached = false
|
||||||
end
|
end
|
||||||
if(event=="monitor_touch")then
|
if(event=="monitor_touch")then
|
||||||
self:mouseHandler(event, p1, p2, p3, p4)
|
self:mouseHandler(1, p1, p2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (event == "terminate") then
|
if (event == "terminate") then
|
||||||
@@ -732,11 +751,13 @@ return function(name, parent, pTerm, basalt)
|
|||||||
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(events["mouse_click"]~=nil)then
|
if(events["mouse_click"]~=nil)then
|
||||||
|
self:setCursor(false)
|
||||||
for _, index in ipairs(eventZIndex["mouse_click"]) do
|
for _, index in ipairs(eventZIndex["mouse_click"]) do
|
||||||
if (events["mouse_click"][index] ~= nil) then
|
if (events["mouse_click"][index] ~= nil) then
|
||||||
for _, value in rpairs(events["mouse_click"][index]) do
|
for _, value in rpairs(events["mouse_click"][index]) do
|
||||||
if (value.mouseHandler ~= nil) then
|
if (value.mouseHandler ~= nil) then
|
||||||
if (value:mouseHandler(button, x, y)) then
|
if (value:mouseHandler(button, x, y)) then
|
||||||
|
focusSystem(self)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -753,6 +774,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:removeFocusedObject()
|
self:removeFocusedObject()
|
||||||
|
focusSystem(self)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -769,6 +791,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
for _, value in rpairs(events["mouse_up"][index]) do
|
for _, value in rpairs(events["mouse_up"][index]) do
|
||||||
if (value.mouseUpHandler ~= nil) then
|
if (value.mouseUpHandler ~= nil) then
|
||||||
if (value:mouseUpHandler(button, x, y)) then
|
if (value:mouseUpHandler(button, x, y)) then
|
||||||
|
focusSystem(self)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -776,7 +799,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--self:removeFocusedObject()
|
focusSystem(self)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -790,6 +813,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
for _, value in rpairs(events["mouse_scroll"][index]) do
|
for _, value in rpairs(events["mouse_scroll"][index]) do
|
||||||
if (value.scrollHandler ~= nil) then
|
if (value.scrollHandler ~= nil) then
|
||||||
if (value:scrollHandler(dir, x, y)) then
|
if (value:scrollHandler(dir, x, y)) then
|
||||||
|
focusSystem(self)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -802,8 +826,11 @@ return function(name, parent, pTerm, basalt)
|
|||||||
calculateMaxScroll(self)
|
calculateMaxScroll(self)
|
||||||
if(dir>0)or(dir<0)then
|
if(dir>0)or(dir<0)then
|
||||||
yOffset = max(min(yOffset-dir, 0),-scrollAmount)
|
yOffset = max(min(yOffset-dir, 0),-scrollAmount)
|
||||||
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:removeFocusedObject()
|
||||||
|
focusSystem(self)
|
||||||
if(yOffset==cache)then return false end
|
if(yOffset==cache)then return false end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -821,6 +848,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
parentX, parentY = self.parent:getAbsolutePosition(self.parent:getAnchorPosition())
|
parentX, parentY = self.parent:getAbsolutePosition(self.parent:getAnchorPosition())
|
||||||
end
|
end
|
||||||
self:setPosition(x + dragXOffset - (parentX - 1) + xO, y + dragYOffset - (parentY - 1) + yO)
|
self:setPosition(x + dragXOffset - (parentX - 1) + xO, y + dragYOffset - (parentY - 1) + yO)
|
||||||
|
self:updateDraw()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if(base.dragHandler(self, button, x, y))then
|
if(base.dragHandler(self, button, x, y))then
|
||||||
@@ -830,6 +858,7 @@ return function(name, parent, pTerm, basalt)
|
|||||||
for _, value in rpairs(events["mouse_drag"][index]) do
|
for _, value in rpairs(events["mouse_drag"][index]) do
|
||||||
if (value.dragHandler ~= nil) then
|
if (value.dragHandler ~= nil) then
|
||||||
if (value:dragHandler(button, x, y)) then
|
if (value:dragHandler(button, x, y)) then
|
||||||
|
focusSystem(self)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -837,21 +866,24 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
focusSystem(self)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
|
|
||||||
keyHandler = function(self, key)
|
keyHandler = function(self, key)
|
||||||
local val = self:getEventSystem():sendEvent("key", self, "key", key)
|
if (self:isFocused())or(self.parent==nil)then
|
||||||
if(val==false)then return false end
|
local val = self:getEventSystem():sendEvent("key", self, "key", key)
|
||||||
if(events["key"]~=nil)then
|
if(val==false)then return false end
|
||||||
for _, index in pairs(eventZIndex["key"]) do
|
if(events["key"]~=nil)then
|
||||||
if (events["key"][index] ~= nil) then
|
for _, index in pairs(eventZIndex["key"]) do
|
||||||
for _, value in rpairs(events["key"][index]) do
|
if (events["key"][index] ~= nil) then
|
||||||
if (value.keyHandler ~= nil) then
|
for _, value in rpairs(events["key"][index]) do
|
||||||
if (value:keyHandler(key)) then
|
if (value.keyHandler ~= nil) then
|
||||||
return true
|
if (value:keyHandler(key)) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -862,15 +894,17 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
keyUpHandler = function(self, key)
|
keyUpHandler = function(self, key)
|
||||||
local val = self:getEventSystem():sendEvent("key_up", self, "key_up", key)
|
if (self:isFocused())or(self.parent==nil)then
|
||||||
if(val==false)then return false end
|
local val = self:getEventSystem():sendEvent("key_up", self, "key_up", key)
|
||||||
if(events["key_up"]~=nil)then
|
if(val==false)then return false end
|
||||||
for _, index in pairs(eventZIndex["key_up"]) do
|
if(events["key_up"]~=nil)then
|
||||||
if (events["key_up"][index] ~= nil) then
|
for _, index in pairs(eventZIndex["key_up"]) do
|
||||||
for _, value in rpairs(events["key_up"][index]) do
|
if (events["key_up"][index] ~= nil) then
|
||||||
if (value.keyUpHandler ~= nil) then
|
for _, value in rpairs(events["key_up"][index]) do
|
||||||
if (value:keyUpHandler(key)) then
|
if (value.keyUpHandler ~= nil) then
|
||||||
return true
|
if (value:keyUpHandler(key)) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -881,15 +915,17 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
charHandler = function(self, char)
|
charHandler = function(self, char)
|
||||||
local val = self:getEventSystem():sendEvent("char", self, "char", char)
|
if (self:isFocused())or(self.parent==nil)then
|
||||||
if(val==false)then return false end
|
local val = self:getEventSystem():sendEvent("char", self, "char", char)
|
||||||
if(events["char"]~=nil)then
|
if(val==false)then return false end
|
||||||
for _, index in pairs(eventZIndex["char"]) do
|
if(events["char"]~=nil)then
|
||||||
if (events["char"][index] ~= nil) then
|
for _, index in pairs(eventZIndex["char"]) do
|
||||||
for _, value in rpairs(events["char"][index]) do
|
if (events["char"][index] ~= nil) then
|
||||||
if (value.charHandler ~= nil) then
|
for _, value in rpairs(events["char"][index]) do
|
||||||
if (value:charHandler(char)) then
|
if (value.charHandler ~= nil) then
|
||||||
return true
|
if (value:charHandler(char)) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -977,84 +1013,61 @@ return function(name, parent, pTerm, basalt)
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self, force)
|
||||||
if(isMonitor)and not(monitorAttached)then return false end;
|
if(isMonitor)and not(monitorAttached)then return false end;
|
||||||
if (self:getVisualChanged()) then
|
if(self.parent==nil)then if(self:getDraw()==false)then return false end end
|
||||||
if (base.draw(self)) then
|
if (base.draw(self))then
|
||||||
|
--if(self.parent==nil)then log("DRAW") end
|
||||||
if(focusedObject~=focusedOBjectCache)then
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if(focusedObject~=nil)then
|
local anchx, anchy = self:getAnchorPosition()
|
||||||
focusedObject:loseFocusHandler()
|
local w,h = self:getSize()
|
||||||
end
|
if (self.parent ~= nil) then
|
||||||
if(focusedOBjectCache~=nil)then
|
if(self.bgColor~=false)then
|
||||||
focusedOBjectCache:getFocusHandler()
|
self.parent:drawBackgroundBox(anchx, anchy, w, h, self.bgColor)
|
||||||
end
|
self.parent:drawTextBox(anchx, anchy, w, h, " ")
|
||||||
focusedObject = focusedOBjectCache
|
|
||||||
end
|
end
|
||||||
|
if(self.bgColor~=false)then self.parent:drawForegroundBox(anchx, anchy, w, h, self.fgColor) end
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
else
|
||||||
local anchx, anchy = self:getAnchorPosition()
|
if(self.bgColor~=false)then
|
||||||
local w,h = self:getSize()
|
basaltDraw.drawBackgroundBox(anchx, anchy, w, h, self.bgColor)
|
||||||
|
basaltDraw.drawTextBox(anchx, anchy, w, h, " ")
|
||||||
|
end
|
||||||
|
if(self.fgColor~=false)then basaltDraw.drawForegroundBox(anchx, anchy, w, h, self.fgColor) end
|
||||||
|
end
|
||||||
|
if (self.barActive) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
if(self.bgColor~=false)then
|
self.parent:writeText(anchx, anchy, utils.getTextHorizontalAlign(self.barText, w, self.barTextAlign), self.barBackground, self.barTextcolor)
|
||||||
self.parent:drawBackgroundBox(anchx, anchy, w, h, self.bgColor)
|
|
||||||
self.parent:drawTextBox(anchx, anchy, w, h, " ")
|
|
||||||
end
|
|
||||||
if(self.bgColor~=false)then self.parent:drawForegroundBox(anchx, anchy, w, h, self.fgColor) end
|
|
||||||
else
|
else
|
||||||
if(self.bgColor~=false)then
|
basaltDraw.writeText(anchx, anchy, utils.getTextHorizontalAlign(self.barText, w, self.barTextAlign), self.barBackground, self.barTextcolor)
|
||||||
basaltDraw.drawBackgroundBox(anchx, anchy, w, h, self.bgColor)
|
|
||||||
basaltDraw.drawTextBox(anchx, anchy, w, h, " ")
|
|
||||||
end
|
|
||||||
if(self.fgColor~=false)then basaltDraw.drawForegroundBox(anchx, anchy, w, h, self.fgColor) end
|
|
||||||
end
|
end
|
||||||
termObject.setCursorBlink(false)
|
if(self:getBorder("left"))then
|
||||||
if (self.barActive) then
|
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:writeText(anchx, anchy, utils.getTextHorizontalAlign(self.barText, w, self.barTextAlign), self.barBackground, self.barTextcolor)
|
self.parent:drawBackgroundBox(anchx-1, anchy, 1, 1, self.barBackground)
|
||||||
else
|
if(self.bgColor~=false)then
|
||||||
basaltDraw.writeText(anchx, anchy, utils.getTextHorizontalAlign(self.barText, w, self.barTextAlign), self.barBackground, self.barTextcolor)
|
self.parent:drawBackgroundBox(anchx-1, anchy+1, 1, h-1, self.bgColor)
|
||||||
end
|
|
||||||
if(self:getBorder("left"))then
|
|
||||||
if (self.parent ~= nil) then
|
|
||||||
self.parent:drawBackgroundBox(anchx-1, anchy, 1, 1, self.barBackground)
|
|
||||||
if(self.bgColor~=false)then
|
|
||||||
self.parent:drawBackgroundBox(anchx-1, anchy+1, 1, h-1, self.bgColor)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if(self:getBorder("top"))then
|
|
||||||
if (self.parent ~= nil) then
|
|
||||||
self.parent:drawBackgroundBox(anchx-1, anchy-1, w+1, 1, self.barBackground)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if(self:getBorder("top"))then
|
||||||
for _, index in rpairs(objZIndex) do
|
|
||||||
if (objects[index] ~= nil) then
|
|
||||||
for _, value in pairs(objects[index]) do
|
|
||||||
if (value.draw ~= nil) then
|
|
||||||
value:draw()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if (cursorBlink) then
|
|
||||||
termObject.setTextColor(cursorColor)
|
|
||||||
termObject.setCursorPos(xCursor, yCursor)
|
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
termObject.setCursorBlink(self:isFocused())
|
self.parent:drawBackgroundBox(anchx-1, anchy-1, w+1, 1, self.barBackground)
|
||||||
else
|
end
|
||||||
termObject.setCursorBlink(cursorBlink)
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, index in rpairs(objZIndex) do
|
||||||
|
if (objects[index] ~= nil) then
|
||||||
|
for _, value in pairs(objects[index]) do
|
||||||
|
if (value.draw ~= nil) then
|
||||||
|
value:draw()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
drawUpdate = function(self)
|
updateTerm = function(self)
|
||||||
if(isMonitor)and not(monitorAttached)then return false end;
|
if(isMonitor)and not(monitorAttached)then return false end;
|
||||||
basaltDraw.update()
|
basaltDraw.update()
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ return function(name)
|
|||||||
local isDragging = false
|
local isDragging = false
|
||||||
local dragStartX, dragStartY, dragXOffset, dragYOffset = 0, 0, 0, 0
|
local dragStartX, dragStartY, dragXOffset, dragYOffset = 0, 0, 0, 0
|
||||||
|
|
||||||
local visualsChanged = true
|
local draw = true
|
||||||
local activeEvents = {}
|
local activeEvents = {}
|
||||||
|
|
||||||
local eventSystem = basaltEvent()
|
local eventSystem = basaltEvent()
|
||||||
@@ -43,13 +43,13 @@ return function(name)
|
|||||||
|
|
||||||
show = function(self)
|
show = function(self)
|
||||||
isVisible = true
|
isVisible = true
|
||||||
visualsChanged = true
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
hide = function(self)
|
hide = function(self)
|
||||||
isVisible = false
|
isVisible = false
|
||||||
visualsChanged = true
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ return function(name)
|
|||||||
if(xmlValue("onEvent", data)~=nil)then self:generateXMLEventFunction(self.onEvent, xmlValue("onEvent", data)) end
|
if(xmlValue("onEvent", data)~=nil)then self:generateXMLEventFunction(self.onEvent, xmlValue("onEvent", data)) end
|
||||||
if(xmlValue("onGetFocus", data)~=nil)then self:generateXMLEventFunction(self.onGetFocus, xmlValue("onGetFocus", data)) end
|
if(xmlValue("onGetFocus", data)~=nil)then self:generateXMLEventFunction(self.onGetFocus, xmlValue("onGetFocus", data)) end
|
||||||
if(xmlValue("onLoseFocus", data)~=nil)then self:generateXMLEventFunction(self.onLoseFocus, xmlValue("onLoseFocus", data)) end
|
if(xmlValue("onLoseFocus", data)~=nil)then self:generateXMLEventFunction(self.onLoseFocus, xmlValue("onLoseFocus", data)) end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -140,6 +140,7 @@ return function(name)
|
|||||||
self.parent:addObject(self)
|
self.parent:addObject(self)
|
||||||
self:updateEventHandlers()
|
self:updateEventHandlers()
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -184,7 +185,7 @@ return function(name)
|
|||||||
setValue = function(self, _value)
|
setValue = function(self, _value)
|
||||||
if (value ~= _value) then
|
if (value ~= _value) then
|
||||||
value = _value
|
value = _value
|
||||||
visualsChanged = true
|
self:updateDraw()
|
||||||
self:valueChangedHandler()
|
self:valueChangedHandler()
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -194,13 +195,14 @@ return function(name)
|
|||||||
return value
|
return value
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getVisualChanged = function(self)
|
getDraw = function(self)
|
||||||
return visualsChanged
|
return draw
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setVisualChanged = function(self, change)
|
updateDraw = function(self, change)
|
||||||
visualsChanged = change or true
|
draw = change
|
||||||
if(change == nil)then visualsChanged = true end
|
if(change == nil)then draw = true end
|
||||||
|
if(draw)then if(self.parent~=nil)then self.parent:updateDraw() end end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -231,7 +233,7 @@ return function(name)
|
|||||||
self.parent:recalculateDynamicValues()
|
self.parent:recalculateDynamicValues()
|
||||||
end
|
end
|
||||||
eventSystem:sendEvent("basalt_reposition", self)
|
eventSystem:sendEvent("basalt_reposition", self)
|
||||||
visualsChanged = true
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -253,7 +255,7 @@ return function(name)
|
|||||||
|
|
||||||
setVisibility = function(self, _isVisible)
|
setVisibility = function(self, _isVisible)
|
||||||
isVisible = _isVisible or not isVisible
|
isVisible = _isVisible or not isVisible
|
||||||
visualsChanged = true
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -274,7 +276,7 @@ return function(name)
|
|||||||
self.parent:recalculateDynamicValues()
|
self.parent:recalculateDynamicValues()
|
||||||
end
|
end
|
||||||
eventSystem:sendEvent("basalt_resize", self)
|
eventSystem:sendEvent("basalt_resize", self)
|
||||||
visualsChanged = true
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -295,12 +297,13 @@ return function(name)
|
|||||||
if(type(self.height)=="table")then self.height:calculate() end
|
if(type(self.height)=="table")then self.height:calculate() end
|
||||||
if(type(self.x)=="table")then self.x:calculate() end
|
if(type(self.x)=="table")then self.x:calculate() end
|
||||||
if(type(self.y)=="table")then self.y:calculate() end
|
if(type(self.y)=="table")then self.y:calculate() end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
setBackground = function(self, color)
|
setBackground = function(self, color)
|
||||||
self.bgColor = color or false
|
self.bgColor = color or false
|
||||||
visualsChanged = true
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -310,7 +313,7 @@ return function(name)
|
|||||||
|
|
||||||
setForeground = function(self, color)
|
setForeground = function(self, color)
|
||||||
self.fgColor = color or false
|
self.fgColor = color or false
|
||||||
visualsChanged = true
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -320,11 +323,13 @@ return function(name)
|
|||||||
|
|
||||||
showShadow = function(self, show)
|
showShadow = function(self, show)
|
||||||
shadow = show or (not shadow)
|
shadow = show or (not shadow)
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setShadow = function(self, color)
|
setShadow = function(self, color)
|
||||||
shadowColor = color
|
shadowColor = color
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -347,11 +352,13 @@ return function(name)
|
|||||||
borderBottom = true
|
borderBottom = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setBorder = function(self, color)
|
setBorder = function(self, color)
|
||||||
borderColor = color
|
borderColor = color
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -371,7 +378,7 @@ return function(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
if (isVisible) then
|
if (isVisible)then
|
||||||
if(self.parent~=nil)then
|
if(self.parent~=nil)then
|
||||||
local x, y = self:getAnchorPosition()
|
local x, y = self:getAnchorPosition()
|
||||||
local w,h = self:getSize()
|
local w,h = self:getSize()
|
||||||
@@ -417,6 +424,7 @@ return function(name)
|
|||||||
self.parent:drawForegroundBox(x-1, y+h, 1, 1, borderColor)
|
self.parent:drawForegroundBox(x-1, y+h, 1, 1, borderColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
draw = false
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -491,7 +499,7 @@ return function(name)
|
|||||||
|
|
||||||
setAnchor = function(self, newAnchor)
|
setAnchor = function(self, newAnchor)
|
||||||
anchor = newAnchor
|
anchor = newAnchor
|
||||||
visualsChanged = true
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -766,7 +774,7 @@ return function(name)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
keyHandler = function(self, key)
|
keyHandler = function(self, key)
|
||||||
if(isEnabled)then
|
if(isEnabled)and(isVisible)then
|
||||||
if (self:isFocused()) then
|
if (self:isFocused()) then
|
||||||
local val = eventSystem:sendEvent("key", self, "key", key)
|
local val = eventSystem:sendEvent("key", self, "key", key)
|
||||||
if(val==false)then return false end
|
if(val==false)then return false end
|
||||||
@@ -777,7 +785,7 @@ return function(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
keyUpHandler = function(self, key)
|
keyUpHandler = function(self, key)
|
||||||
if(isEnabled)then
|
if(isEnabled)and(isVisible)then
|
||||||
if (self:isFocused()) then
|
if (self:isFocused()) then
|
||||||
local val = eventSystem:sendEvent("key_up", self, "key_up", key)
|
local val = eventSystem:sendEvent("key_up", self, "key_up", key)
|
||||||
if(val==false)then return false end
|
if(val==false)then return false end
|
||||||
@@ -788,7 +796,7 @@ return function(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
charHandler = function(self, char)
|
charHandler = function(self, char)
|
||||||
if(isEnabled)then
|
if(isEnabled)and(isVisible)then
|
||||||
if (self:isFocused()) then
|
if (self:isFocused()) then
|
||||||
local val = eventSystem:sendEvent("char", self, "char", char)
|
local val = eventSystem:sendEvent("char", self, "char", char)
|
||||||
if(val==false)then return false end
|
if(val==false)then return false end
|
||||||
|
|||||||
@@ -146,11 +146,11 @@ end
|
|||||||
local function drawFrames()
|
local function drawFrames()
|
||||||
if(mainFrame~=nil)then
|
if(mainFrame~=nil)then
|
||||||
mainFrame:draw()
|
mainFrame:draw()
|
||||||
mainFrame:drawUpdate()
|
mainFrame:updateTerm()
|
||||||
end
|
end
|
||||||
for _,v in pairs(monFrames)do
|
for _,v in pairs(monFrames)do
|
||||||
v:draw()
|
v:draw()
|
||||||
v:drawUpdate()
|
v:updateTerm()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -246,6 +246,7 @@ basalt = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
stop = stop,
|
stop = stop,
|
||||||
|
stopUpdate = stop,
|
||||||
|
|
||||||
isKeyDown = function(key)
|
isKeyDown = function(key)
|
||||||
if(activeKey[key]==nil)then return false end
|
if(activeKey[key]==nil)then return false end
|
||||||
|
|||||||
@@ -24,14 +24,19 @@ return function(name)
|
|||||||
end;
|
end;
|
||||||
setHorizontalAlign = function(self, pos)
|
setHorizontalAlign = function(self, pos)
|
||||||
textHorizontalAlign = pos
|
textHorizontalAlign = pos
|
||||||
|
self:updateDraw()
|
||||||
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setVerticalAlign = function(self, pos)
|
setVerticalAlign = function(self, pos)
|
||||||
textVerticalAlign = pos
|
textVerticalAlign = pos
|
||||||
|
self:updateDraw()
|
||||||
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setText = function(self, text)
|
setText = function(self, text)
|
||||||
base:setValue(text)
|
base:setValue(text)
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -61,9 +66,8 @@ return function(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end;
|
end,
|
||||||
|
|
||||||
}
|
}
|
||||||
return setmetatable(object, base)
|
return setmetatable(object, base)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ return function(name)
|
|||||||
|
|
||||||
setSymbol = function(self, sym)
|
setSymbol = function(self, sym)
|
||||||
symbol = sym
|
symbol = sym
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ return function(name)
|
|||||||
else
|
else
|
||||||
self:setValue(not self:getValue())
|
self:setValue(not self:getValue())
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -66,9 +68,9 @@ return function(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end;
|
end,
|
||||||
|
|
||||||
init = function(self)
|
init = function(self)
|
||||||
base.init(self)
|
base.init(self)
|
||||||
self.bgColor = self.parent:getTheme("CheckboxBG")
|
self.bgColor = self.parent:getTheme("CheckboxBG")
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ return function(name)
|
|||||||
|
|
||||||
setOffset = function(self, yOff)
|
setOffset = function(self, yOff)
|
||||||
yOffset = yOff
|
yOffset = yOff
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ return function(name)
|
|||||||
|
|
||||||
addItem = function(self, text, bgCol, fgCol, ...)
|
addItem = function(self, text, bgCol, fgCol, ...)
|
||||||
table.insert(list, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } })
|
table.insert(list, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } })
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ return function(name)
|
|||||||
|
|
||||||
removeItem = function(self, index)
|
removeItem = function(self, index)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ return function(name)
|
|||||||
clear = function(self)
|
clear = function(self)
|
||||||
list = {}
|
list = {}
|
||||||
self:setValue({})
|
self:setValue({})
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -96,13 +96,13 @@ return function(name)
|
|||||||
editItem = function(self, index, text, bgCol, fgCol, ...)
|
editItem = function(self, index, text, bgCol, fgCol, ...)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
table.insert(list, index, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } })
|
table.insert(list, index, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } })
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
selectItem = function(self, index)
|
selectItem = function(self, index)
|
||||||
self:setValue(list[index] or {})
|
self:setValue(list[index] or {})
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -110,13 +110,13 @@ return function(name)
|
|||||||
itemSelectedBG = bgCol or self.bgColor
|
itemSelectedBG = bgCol or self.bgColor
|
||||||
itemSelectedFG = fgCol or self.fgColor
|
itemSelectedFG = fgCol or self.fgColor
|
||||||
selectionColorActive = active
|
selectionColorActive = active
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setDropdownSize = function(self, width, height)
|
setDropdownSize = function(self, width, height)
|
||||||
dropdownW, dropdownH = width, height
|
dropdownW, dropdownH = width, height
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ return function(name)
|
|||||||
if (list[n + yOffset] ~= nil) then
|
if (list[n + yOffset] ~= nil) then
|
||||||
if (obx <= x) and (obx + dropdownW > x) and (oby + n == y) then
|
if (obx <= x) and (obx + dropdownW > x) and (oby + n == y) then
|
||||||
self:setValue(list[n + yOffset])
|
self:setValue(list[n + yOffset])
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
local val = self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", dir, x, y)
|
local val = self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", dir, x, y)
|
||||||
if(val==false)then return val end
|
if(val==false)then return val end
|
||||||
return true
|
return true
|
||||||
@@ -141,11 +141,11 @@ return function(name)
|
|||||||
end
|
end
|
||||||
if (base.mouseHandler(self, button, x, y)) then
|
if (base.mouseHandler(self, button, x, y)) then
|
||||||
isOpened = (not isOpened)
|
isOpened = (not isOpened)
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
if(isOpened)then
|
if(isOpened)then
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
isOpened = false
|
isOpened = false
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -161,7 +161,7 @@ return function(name)
|
|||||||
if (list[n + yOffset] ~= nil) then
|
if (list[n + yOffset] ~= nil) then
|
||||||
if (obx <= x) and (obx + dropdownW > x) and (oby + n == y) then
|
if (obx <= x) and (obx + dropdownW > x) and (oby + n == y) then
|
||||||
isOpened = false
|
isOpened = false
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
local val = self:getEventSystem():sendEvent("mouse_up", self, "mouse_up", dir, x, y)
|
local val = self:getEventSystem():sendEvent("mouse_up", self, "mouse_up", dir, x, y)
|
||||||
if(val==false)then return val end
|
if(val==false)then return val end
|
||||||
return true
|
return true
|
||||||
@@ -190,7 +190,7 @@ return function(name)
|
|||||||
end
|
end
|
||||||
local val = self:getEventSystem():sendEvent("mouse_scroll", self, "mouse_scroll", dir, x, y)
|
local val = self:getEventSystem():sendEvent("mouse_scroll", self, "mouse_scroll", dir, x, y)
|
||||||
if(val==false)then return val end
|
if(val==false)then return val end
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ return function(name)
|
|||||||
loadImage = function(self, path)
|
loadImage = function(self, path)
|
||||||
image = paintutils.loadImage(path)
|
image = paintutils.loadImage(path)
|
||||||
imageGotShrinked = false
|
imageGotShrinked = false
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -149,6 +150,7 @@ return function(name)
|
|||||||
shrink = function(self)
|
shrink = function(self)
|
||||||
shrink()
|
shrink()
|
||||||
imageGotShrinked = true
|
imageGotShrinked = true
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -192,9 +194,8 @@ return function(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end;
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmetatable(object, base)
|
return setmetatable(object, base)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local Object = require("Object")
|
local Object = require("Object")
|
||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
|
local log = require("basaltLogs")
|
||||||
local xmlValue = utils.getValueFromXML
|
local xmlValue = utils.getValueFromXML
|
||||||
|
|
||||||
return function(name)
|
return function(name)
|
||||||
@@ -32,6 +33,7 @@ return function(name)
|
|||||||
if (iType == "password") or (iType == "number") or (iType == "text") then
|
if (iType == "password") or (iType == "number") or (iType == "text") then
|
||||||
inputType = iType
|
inputType = iType
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -44,6 +46,7 @@ return function(name)
|
|||||||
else
|
else
|
||||||
showingText = defaultText
|
showingText = defaultText
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -59,6 +62,7 @@ return function(name)
|
|||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
self.parent:setCursor(true, obx + textX - wIndex, oby+math.floor(self.height/2), self.fgColor)
|
self.parent:setCursor(true, obx + textX - wIndex, oby+math.floor(self.height/2), self.fgColor)
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -69,6 +73,7 @@ return function(name)
|
|||||||
|
|
||||||
setInputLimit = function(self, limit)
|
setInputLimit = function(self, limit)
|
||||||
inputLimit = tonumber(limit) or inputLimit
|
inputLimit = tonumber(limit) or inputLimit
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -92,17 +97,21 @@ return function(name)
|
|||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
showingText = ""
|
showingText = ""
|
||||||
if (self.parent ~= nil) then
|
if(defaultText~="")then
|
||||||
self.parent:setCursor(true, obx + textX - wIndex, oby+math.floor(self.height/2), self.fgColor)
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
|
self.parent:setCursor(true, obx + textX - wIndex, oby+math.floor(self:getHeight()/2), self.fgColor)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
loseFocusHandler = function(self)
|
loseFocusHandler = function(self)
|
||||||
base.loseFocusHandler(self)
|
base.loseFocusHandler(self)
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setCursor(false)
|
|
||||||
showingText = defaultText
|
showingText = defaultText
|
||||||
|
if(defaultText~="")then
|
||||||
|
self:updateDraw()
|
||||||
|
end
|
||||||
|
self.parent:setCursor(false)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -216,6 +225,7 @@ return function(name)
|
|||||||
self.parent:setCursor(true, obx + cursorX, oby+math.floor(h/2), self.fgColor)
|
self.parent:setCursor(true, obx + cursorX, oby+math.floor(h/2), self.fgColor)
|
||||||
end
|
end
|
||||||
internalValueChange = false
|
internalValueChange = false
|
||||||
|
self:updateDraw()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -223,7 +233,8 @@ return function(name)
|
|||||||
|
|
||||||
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
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local ax, ay = self:getAnchorPosition()
|
||||||
|
local obx, oby = self:getAbsolutePosition(ax, ay)
|
||||||
local w, h = self:getSize()
|
local w, h = self:getSize()
|
||||||
textX = x - obx + wIndex
|
textX = x - obx + wIndex
|
||||||
local text = base.getValue()
|
local text = base.getValue()
|
||||||
@@ -236,10 +247,6 @@ return function(name)
|
|||||||
wIndex = 1
|
wIndex = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local cursorX = (textX <= text:len() and textX - 1 or text:len()) - (wIndex - 1)
|
|
||||||
if (self.parent ~= nil) then
|
|
||||||
self.parent:setCursor(true, obx + cursorX, oby+math.floor(h/2), self.fgColor)
|
|
||||||
end
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -279,6 +286,7 @@ return function(name)
|
|||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setCursor(true, obx + cursorX, oby+math.floor(h/2), self.fgColor)
|
self.parent:setCursor(true, obx + cursorX, oby+math.floor(h/2), self.fgColor)
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
internalValueChange = false
|
internalValueChange = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,25 +35,28 @@ return function(name)
|
|||||||
end
|
end
|
||||||
if not(fgColChanged)then self.fgColor = self.parent:getForeground() or colors.white end
|
if not(fgColChanged)then self.fgColor = self.parent:getForeground() or colors.white end
|
||||||
if not(bgColChanged)then self.bgColor = self.parent:getBackground() or colors.black end
|
if not(bgColChanged)then self.bgColor = self.parent:getBackground() or colors.black end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setBackground = function(self, col)
|
setBackground = function(self, col)
|
||||||
base.setBackground(self, col)
|
base.setBackground(self, col)
|
||||||
bgColChanged = true
|
bgColChanged = true
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
setForeground = function(self, col)
|
setForeground = function(self, col)
|
||||||
base.setForeground(self, col)
|
base.setForeground(self, col)
|
||||||
fgColChanged = true
|
fgColChanged = true
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
setTextAlign = function(self, hor, vert)
|
setTextAlign = function(self, hor, vert)
|
||||||
textHorizontalAlign = hor or textHorizontalAlign
|
textHorizontalAlign = hor or textHorizontalAlign
|
||||||
textVerticalAlign = vert or textVerticalAlign
|
textVerticalAlign = vert or textVerticalAlign
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -61,6 +64,7 @@ return function(name)
|
|||||||
if(size>0)and(size<=4)then
|
if(size>0)and(size<=4)then
|
||||||
fontsize = size-1 or 0
|
fontsize = size-1 or 0
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -80,7 +84,7 @@ return function(name)
|
|||||||
setSize = function(self, width, height)
|
setSize = function(self, width, height)
|
||||||
base.setSize(self, width, height)
|
base.setSize(self, width, height)
|
||||||
autoSize = false
|
autoSize = false
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -128,9 +132,8 @@ return function(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end;
|
end,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,11 +27,13 @@ return function(name)
|
|||||||
if (#list == 1) then
|
if (#list == 1) then
|
||||||
self:setValue(list[1])
|
self:setValue(list[1])
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setOffset = function(self, yOff)
|
setOffset = function(self, yOff)
|
||||||
yOffset = yOff
|
yOffset = yOff
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@ return function(name)
|
|||||||
|
|
||||||
removeItem = function(self, index)
|
removeItem = function(self, index)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -64,6 +67,7 @@ return function(name)
|
|||||||
clear = function(self)
|
clear = function(self)
|
||||||
list = {}
|
list = {}
|
||||||
self:setValue({})
|
self:setValue({})
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -74,11 +78,13 @@ return function(name)
|
|||||||
editItem = function(self, index, text, bgCol, fgCol, ...)
|
editItem = function(self, index, text, bgCol, fgCol, ...)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
table.insert(list, index, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } })
|
table.insert(list, index, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } })
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
selectItem = function(self, index)
|
selectItem = function(self, index)
|
||||||
self:setValue(list[index] or {})
|
self:setValue(list[index] or {})
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -86,12 +92,14 @@ return function(name)
|
|||||||
itemSelectedBG = bgCol or self.bgColor
|
itemSelectedBG = bgCol or self.bgColor
|
||||||
itemSelectedFG = fgCol or self.fgColor
|
itemSelectedFG = fgCol or self.fgColor
|
||||||
selectionColorActive = active
|
selectionColorActive = active
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
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
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -131,6 +139,7 @@ return function(name)
|
|||||||
yOffset = yOffset - 1
|
yOffset = yOffset - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -146,7 +155,7 @@ return function(name)
|
|||||||
if (list[n + yOffset] ~= nil) then
|
if (list[n + yOffset] ~= nil) then
|
||||||
if (obx <= x) and (obx + w > x) and (oby + n - 1 == y) then
|
if (obx <= x) and (obx + w > x) and (oby + n - 1 == y) then
|
||||||
self:setValue(list[n + yOffset])
|
self:setValue(list[n + yOffset])
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -186,20 +195,17 @@ return function(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end;
|
end,
|
||||||
|
|
||||||
init = function(self)
|
init = function(self)
|
||||||
self.bgColor = self.parent:getTheme("ListBG")
|
self.bgColor = self.parent:getTheme("ListBG")
|
||||||
self.fgColor = self.parent:getTheme("ListText")
|
self.fgColor = self.parent:getTheme("ListText")
|
||||||
itemSelectedBG = self.parent:getTheme("SelectionBG")
|
itemSelectedBG = self.parent:getTheme("SelectionBG")
|
||||||
itemSelectedFG = self.parent:getTheme("SelectionText")
|
itemSelectedFG = self.parent:getTheme("SelectionText")
|
||||||
if(self.parent~=nil)then
|
self.parent:addEvent("mouse_click", self)
|
||||||
self.parent:addEvent("mouse_click", self)
|
self.parent:addEvent("mouse_drag", self)
|
||||||
self.parent:addEvent("mouse_drag", self)
|
self.parent:addEvent("mouse_scroll", self)
|
||||||
self.parent:addEvent("mouse_scroll", self)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ return function(name)
|
|||||||
if (#list == 1) then
|
if (#list == 1) then
|
||||||
self:setValue(list[1])
|
self:setValue(list[1])
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -68,11 +69,13 @@ return function(name)
|
|||||||
clear = function(self)
|
clear = function(self)
|
||||||
list = {}
|
list = {}
|
||||||
self:setValue({})
|
self:setValue({})
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setSpace = function(self, _space)
|
setSpace = function(self, _space)
|
||||||
space = _space or space
|
space = _space or space
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -86,6 +89,7 @@ return function(name)
|
|||||||
if (itemOffset > mScroll) then
|
if (itemOffset > mScroll) then
|
||||||
itemOffset = mScroll
|
itemOffset = mScroll
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -118,6 +122,7 @@ return function(name)
|
|||||||
|
|
||||||
removeItem = function(self, index)
|
removeItem = function(self, index)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -132,11 +137,13 @@ return function(name)
|
|||||||
editItem = function(self, index, text, bgCol, fgCol, ...)
|
editItem = function(self, index, text, bgCol, fgCol, ...)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
table.insert(list, index, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } })
|
table.insert(list, index, { text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } })
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
selectItem = function(self, index)
|
selectItem = function(self, index)
|
||||||
self:setValue(list[index] or {})
|
self:setValue(list[index] or {})
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -144,6 +151,7 @@ return function(name)
|
|||||||
itemSelectedBG = bgCol or self.bgColor
|
itemSelectedBG = bgCol or self.bgColor
|
||||||
itemSelectedFG = fgCol or self.fgColor
|
itemSelectedFG = fgCol or self.fgColor
|
||||||
selectionColorActive = active
|
selectionColorActive = active
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -161,7 +169,7 @@ return function(name)
|
|||||||
xPos = xPos + list[n].text:len() + space * 2
|
xPos = xPos + list[n].text:len() + space * 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -180,7 +188,7 @@ return function(name)
|
|||||||
if (itemOffset > mScroll) then
|
if (itemOffset > mScroll) then
|
||||||
itemOffset = mScroll
|
itemOffset = mScroll
|
||||||
end
|
end
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -214,7 +222,6 @@ return function(name)
|
|||||||
self.parent:setBG(obx, oby, textBGCol:sub(itemOffset+1, w+itemOffset))
|
self.parent:setBG(obx, oby, textBGCol:sub(itemOffset+1, w+itemOffset))
|
||||||
self.parent:setFG(obx, oby, textFGCol:sub(itemOffset+1, w+itemOffset))
|
self.parent:setFG(obx, oby, textFGCol:sub(itemOffset+1, w+itemOffset))
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -224,10 +231,9 @@ return function(name)
|
|||||||
itemSelectedBG = self.parent:getTheme("SelectionBG")
|
itemSelectedBG = self.parent:getTheme("SelectionBG")
|
||||||
itemSelectedFG = self.parent:getTheme("SelectionText")
|
itemSelectedFG = self.parent:getTheme("SelectionText")
|
||||||
|
|
||||||
if(self.parent~=nil)then
|
self.parent:addEvent("mouse_click", self)
|
||||||
self.parent:addEvent("mouse_click", self)
|
self.parent:addEvent("mouse_scroll", self)
|
||||||
self.parent:addEvent("mouse_scroll", self)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,8 @@ return function(name)
|
|||||||
self.parent:drawBackgroundBox(obx, oby, w, h, self.bgColor)
|
self.parent:drawBackgroundBox(obx, oby, w, h, self.bgColor)
|
||||||
self.parent:drawForegroundBox(obx, oby, w, h, self.fgColor)
|
self.parent:drawForegroundBox(obx, oby, w, h, self.fgColor)
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end;
|
end,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local Object = require("Object")
|
|||||||
local tHex = require("tHex")
|
local tHex = require("tHex")
|
||||||
local process = require("process")
|
local process = require("process")
|
||||||
local xmlValue = require("utils").getValueFromXML
|
local xmlValue = require("utils").getValueFromXML
|
||||||
|
local log = require("basaltLogs")
|
||||||
|
|
||||||
local sub = string.sub
|
local sub = string.sub
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ return function(name, parent)
|
|||||||
local object
|
local object
|
||||||
local cachedPath
|
local cachedPath
|
||||||
|
|
||||||
local function createBasaltWindow(x, y, width, height)
|
local function createBasaltWindow(x, y, width, height, self)
|
||||||
local xCursor, yCursor = 1, 1
|
local xCursor, yCursor = 1, 1
|
||||||
local bgColor, fgColor = colors.black, colors.white
|
local bgColor, fgColor = colors.black, colors.white
|
||||||
local cursorBlink = false
|
local cursorBlink = false
|
||||||
@@ -51,6 +52,7 @@ return function(name, parent)
|
|||||||
cacheFG[n] = sub(cacheFG[n] == nil and emptyFG or cacheFG[n] .. emptyFG:sub(1, width - cacheFG[n]:len()), 1, width)
|
cacheFG[n] = sub(cacheFG[n] == nil and emptyFG or cacheFG[n] .. emptyFG:sub(1, width - cacheFG[n]:len()), 1, width)
|
||||||
cacheBG[n] = sub(cacheBG[n] == nil and emptyBG or cacheBG[n] .. emptyBG:sub(1, width - cacheBG[n]:len()), 1, width)
|
cacheBG[n] = sub(cacheBG[n] == nil and emptyBG or cacheBG[n] .. emptyBG:sub(1, width - cacheBG[n]:len()), 1, width)
|
||||||
end
|
end
|
||||||
|
base.updateDraw(base)
|
||||||
end
|
end
|
||||||
recreateWindowArray()
|
recreateWindowArray()
|
||||||
|
|
||||||
@@ -118,6 +120,7 @@ return function(name, parent)
|
|||||||
cacheFG[yCursor] = sNewTextColor
|
cacheFG[yCursor] = sNewTextColor
|
||||||
cacheBG[yCursor] = sNewBackgroundColor
|
cacheBG[yCursor] = sNewBackgroundColor
|
||||||
end
|
end
|
||||||
|
object:updateDraw()
|
||||||
end
|
end
|
||||||
xCursor = nEnd + 1
|
xCursor = nEnd + 1
|
||||||
if (visible) then
|
if (visible) then
|
||||||
@@ -133,6 +136,7 @@ return function(name, parent)
|
|||||||
cacheT[_y] = sub(gText:sub(1, _x - 1) .. text .. gText:sub(_x + (text:len()), width), 1, width)
|
cacheT[_y] = sub(gText:sub(1, _x - 1) .. text .. gText:sub(_x + (text:len()), width), 1, width)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object:updateDraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setBG(_x, _y, colorStr)
|
local function setBG(_x, _y, colorStr)
|
||||||
@@ -142,6 +146,7 @@ return function(name, parent)
|
|||||||
cacheBG[_y] = sub(gBG:sub(1, _x - 1) .. colorStr .. gBG:sub(_x + (colorStr:len()), width), 1, width)
|
cacheBG[_y] = sub(gBG:sub(1, _x - 1) .. colorStr .. gBG:sub(_x + (colorStr:len()), width), 1, width)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object:updateDraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setFG(_x, _y, colorStr)
|
local function setFG(_x, _y, colorStr)
|
||||||
@@ -151,6 +156,7 @@ return function(name, parent)
|
|||||||
cacheFG[_y] = sub(gFG:sub(1, _x - 1) .. colorStr .. gFG:sub(_x + (colorStr:len()), width), 1, width)
|
cacheFG[_y] = sub(gFG:sub(1, _x - 1) .. colorStr .. gFG:sub(_x + (colorStr:len()), width), 1, width)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object:updateDraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
local setTextColor = function(color)
|
local setTextColor = function(color)
|
||||||
@@ -494,7 +500,7 @@ return function(name, parent)
|
|||||||
|
|
||||||
setSize = function(self, width, height, rel)
|
setSize = function(self, width, height, rel)
|
||||||
base.setSize(self, width, height, rel)
|
base.setSize(self, width, height, rel)
|
||||||
pWindow.basalt_resize(self:getSize())
|
pWindow.basalt_resize(self:getWidth(), self:getHeight())
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -687,6 +693,18 @@ return function(name, parent)
|
|||||||
if (curProcess == nil) then
|
if (curProcess == nil) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if(event=="dynamicValueEvent")then
|
||||||
|
local w, h = pWindow.getSize()
|
||||||
|
local pW, pH = self:getSize()
|
||||||
|
if(w~=pW)or(h~=pH)then
|
||||||
|
pWindow.basalt_resize(pW, pH)
|
||||||
|
if not (curProcess:isDead()) then
|
||||||
|
curProcess:resume("term_resize")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
pWindow.basalt_reposition(self:getAnchorPosition())
|
||||||
|
|
||||||
|
end
|
||||||
if not (curProcess:isDead()) then
|
if not (curProcess:isDead()) then
|
||||||
if not (paused) then
|
if not (paused) then
|
||||||
if(event ~= "terminate") then
|
if(event ~= "terminate") then
|
||||||
@@ -724,13 +742,11 @@ return function(name, parent)
|
|||||||
end
|
end
|
||||||
pWindow.basalt_update()
|
pWindow.basalt_update()
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
init = function(self)
|
init = function(self)
|
||||||
self.bgColor = self.parent:getTheme("ProgramBG")
|
self.bgColor = self.parent:getTheme("ProgramBG")
|
||||||
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ return function(name)
|
|||||||
|
|
||||||
setDirection = function(self, dir)
|
setDirection = function(self, dir)
|
||||||
direction = dir
|
direction = dir
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -49,11 +50,13 @@ return function(name)
|
|||||||
activeBarColor = color or activeBarColor
|
activeBarColor = color or activeBarColor
|
||||||
activeBarSymbol = symbol or activeBarSymbol
|
activeBarSymbol = symbol or activeBarSymbol
|
||||||
activeBarSymbolCol = symbolcolor or activeBarSymbolCol
|
activeBarSymbolCol = symbolcolor or activeBarSymbolCol
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setBackgroundSymbol = function(self, symbol)
|
setBackgroundSymbol = function(self, symbol)
|
||||||
bgBarSymbol = symbol:sub(1, 1)
|
bgBarSymbol = symbol:sub(1, 1)
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -65,6 +68,7 @@ return function(name)
|
|||||||
self:progressDoneHandler()
|
self:progressDoneHandler()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -107,9 +111,8 @@ return function(name)
|
|||||||
self.parent:drawTextBox(obx, oby, w / 100 * progress, h, activeBarSymbol)
|
self.parent:drawTextBox(obx, oby, w / 100 * progress, h, activeBarSymbol)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end;
|
end,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ return function(name)
|
|||||||
if (#list == 1) then
|
if (#list == 1) then
|
||||||
self:setValue(list[1])
|
self:setValue(list[1])
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ return function(name)
|
|||||||
|
|
||||||
removeItem = function(self, index)
|
removeItem = function(self, index)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -76,6 +78,7 @@ return function(name)
|
|||||||
clear = function(self)
|
clear = function(self)
|
||||||
list = {}
|
list = {}
|
||||||
self:setValue({})
|
self:setValue({})
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -86,16 +89,19 @@ return function(name)
|
|||||||
editItem = function(self, index, text, x, y, bgCol, fgCol, ...)
|
editItem = function(self, index, text, x, y, bgCol, fgCol, ...)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
table.insert(list, index, { x = x or 1, y = y or 1, text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } })
|
table.insert(list, index, { x = x or 1, y = y or 1, text = text, bgCol = bgCol or self.bgColor, fgCol = fgCol or self.fgColor, args = { ... } })
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
selectItem = function(self, index)
|
selectItem = function(self, index)
|
||||||
self:setValue(list[index] or {})
|
self:setValue(list[index] or {})
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setActiveSymbol = function(self, sym)
|
setActiveSymbol = function(self, sym)
|
||||||
symbol = sym:sub(1,1)
|
symbol = sym:sub(1,1)
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -105,6 +111,7 @@ return function(name)
|
|||||||
boxSelectedBG = boxBG or boxSelectedBG
|
boxSelectedBG = boxBG or boxSelectedBG
|
||||||
boxSelectedFG = boxFG or boxSelectedFG
|
boxSelectedFG = boxFG or boxSelectedFG
|
||||||
selectionColorActive = active~=nil and active or true
|
selectionColorActive = active~=nil and active or true
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -119,7 +126,7 @@ return function(name)
|
|||||||
if(self.parent~=nil)then
|
if(self.parent~=nil)then
|
||||||
self.parent:setFocusedObject(self)
|
self.parent:setFocusedObject(self)
|
||||||
end
|
end
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -143,9 +150,8 @@ return function(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end;
|
end,
|
||||||
|
|
||||||
init = function(self)
|
init = function(self)
|
||||||
self.bgColor = self.parent:getTheme("MenubarBG")
|
self.bgColor = self.parent:getTheme("MenubarBG")
|
||||||
@@ -154,9 +160,7 @@ return function(name)
|
|||||||
itemSelectedFG = self.parent:getTheme("SelectionText")
|
itemSelectedFG = self.parent:getTheme("SelectionText")
|
||||||
boxSelectedBG = self.parent:getTheme("MenubarBG")
|
boxSelectedBG = self.parent:getTheme("MenubarBG")
|
||||||
boxSelectedFG = self.parent:getTheme("MenubarText")
|
boxSelectedFG = self.parent:getTheme("MenubarText")
|
||||||
if(self.parent~=nil)then
|
self.parent:addEvent("mouse_click", self)
|
||||||
self.parent:addEvent("mouse_click", self)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ return function(name)
|
|||||||
if (obx + _index == x) and (oby <= y) and (oby + h > y) then
|
if (obx + _index == x) and (oby <= y) and (oby + h > y) then
|
||||||
index = math.min(_index + 1, w - (symbolSize - 1))
|
index = math.min(_index + 1, w - (symbolSize - 1))
|
||||||
self:setValue(maxValue / w * (index))
|
self:setValue(maxValue / w * (index))
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -35,7 +35,7 @@ return function(name)
|
|||||||
if (oby + _index == y) and (obx <= x) and (obx + w > x) then
|
if (oby + _index == y) and (obx <= x) and (obx + w > x) then
|
||||||
index = math.min(_index + 1, h - (symbolSize - 1))
|
index = math.min(_index + 1, h - (symbolSize - 1))
|
||||||
self:setValue(maxValue / h * (index))
|
self:setValue(maxValue / h * (index))
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -48,7 +48,7 @@ return function(name)
|
|||||||
|
|
||||||
setSymbol = function(self, _symbol)
|
setSymbol = function(self, _symbol)
|
||||||
symbol = _symbol:sub(1, 1)
|
symbol = _symbol:sub(1, 1)
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -71,6 +71,7 @@ return function(name)
|
|||||||
local w,h = self:getSize()
|
local w,h = self:getSize()
|
||||||
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()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -86,29 +87,31 @@ return function(name)
|
|||||||
elseif (barType == "horizontal") then
|
elseif (barType == "horizontal") then
|
||||||
self:setValue(index - 1 * (maxValue / (w - (symbolSize - 1))) - (maxValue / (w - (symbolSize - 1))))
|
self:setValue(index - 1 * (maxValue / (w - (symbolSize - 1))) - (maxValue / (w - (symbolSize - 1))))
|
||||||
end
|
end
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setMaxValue = function(self, val)
|
setMaxValue = function(self, val)
|
||||||
maxValue = val
|
maxValue = val
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setBackgroundSymbol = function(self, _bgSymbol)
|
setBackgroundSymbol = function(self, _bgSymbol)
|
||||||
bgSymbol = string.sub(_bgSymbol, 1, 1)
|
bgSymbol = string.sub(_bgSymbol, 1, 1)
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setSymbolColor = function(self, col)
|
setSymbolColor = function(self, col)
|
||||||
symbolColor = col
|
symbolColor = col
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setBarType = function(self, _typ)
|
setBarType = function(self, _typ)
|
||||||
barType = _typ:lower()
|
barType = _typ:lower()
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -137,6 +140,7 @@ return function(name)
|
|||||||
end
|
end
|
||||||
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()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -172,11 +176,9 @@ return function(name)
|
|||||||
self.bgColor = self.parent:getTheme("ScrollbarBG")
|
self.bgColor = self.parent:getTheme("ScrollbarBG")
|
||||||
self.fgColor = self.parent:getTheme("ScrollbarText")
|
self.fgColor = self.parent:getTheme("ScrollbarText")
|
||||||
symbolColor = self.parent:getTheme("ScrollbarSymbolColor")
|
symbolColor = self.parent:getTheme("ScrollbarSymbolColor")
|
||||||
if(self.parent~=nil)then
|
self.parent:addEvent("mouse_click", self)
|
||||||
self.parent:addEvent("mouse_click", self)
|
self.parent:addEvent("mouse_drag", self)
|
||||||
self.parent:addEvent("mouse_drag", self)
|
self.parent:addEvent("mouse_scroll", self)
|
||||||
self.parent:addEvent("mouse_scroll", self)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ return function(name)
|
|||||||
if (obx + _index == x) and (oby <= y) and (oby + h > y) then
|
if (obx + _index == x) and (oby <= y) and (oby + h > y) then
|
||||||
index = math.min(_index + 1, w - (symbolSize - 1))
|
index = math.min(_index + 1, w - (symbolSize - 1))
|
||||||
self:setValue(maxValue / w * (index))
|
self:setValue(maxValue / w * (index))
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -34,7 +34,7 @@ return function(name)
|
|||||||
if (oby + _index == y) and (obx <= x) and (obx + w > x) then
|
if (oby + _index == y) and (obx <= x) and (obx + w > x) then
|
||||||
index = math.min(_index + 1, h - (symbolSize - 1))
|
index = math.min(_index + 1, h - (symbolSize - 1))
|
||||||
self:setValue(maxValue / h * (index))
|
self:setValue(maxValue / h * (index))
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -47,7 +47,7 @@ return function(name)
|
|||||||
|
|
||||||
setSymbol = function(self, _symbol)
|
setSymbol = function(self, _symbol)
|
||||||
symbol = _symbol:sub(1, 1)
|
symbol = _symbol:sub(1, 1)
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -70,6 +70,7 @@ return function(name)
|
|||||||
local w,h = self:getSize()
|
local w,h = self:getSize()
|
||||||
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()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ return function(name)
|
|||||||
elseif (barType == "horizontal") then
|
elseif (barType == "horizontal") then
|
||||||
self:setValue(index - 1 * (maxValue / (w - (symbolSize - 1))) - (maxValue / (w - (symbolSize - 1))))
|
self:setValue(index - 1 * (maxValue / (w - (symbolSize - 1))) - (maxValue / (w - (symbolSize - 1))))
|
||||||
end
|
end
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -95,18 +96,19 @@ return function(name)
|
|||||||
|
|
||||||
setBackgroundSymbol = function(self, _bgSymbol)
|
setBackgroundSymbol = function(self, _bgSymbol)
|
||||||
bgSymbol = string.sub(_bgSymbol, 1, 1)
|
bgSymbol = string.sub(_bgSymbol, 1, 1)
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setSymbolColor = function(self, col)
|
setSymbolColor = function(self, col)
|
||||||
symbolColor = col
|
symbolColor = col
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setBarType = function(self, _typ)
|
setBarType = function(self, _typ)
|
||||||
barType = _typ:lower()
|
barType = _typ:lower()
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -135,6 +137,7 @@ return function(name)
|
|||||||
end
|
end
|
||||||
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()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -171,11 +174,9 @@ return function(name)
|
|||||||
self.bgColor = self.parent:getTheme("SliderBG")
|
self.bgColor = self.parent:getTheme("SliderBG")
|
||||||
self.fgColor = self.parent:getTheme("SliderText")
|
self.fgColor = self.parent:getTheme("SliderText")
|
||||||
symbolColor = self.parent:getTheme("SliderSymbolColor")
|
symbolColor = self.parent:getTheme("SliderSymbolColor")
|
||||||
if(self.parent~=nil)then
|
self.parent:addEvent("mouse_click", self)
|
||||||
self.parent:addEvent("mouse_click", self)
|
self.parent:addEvent("mouse_drag", self)
|
||||||
self.parent:addEvent("mouse_drag", self)
|
self.parent:addEvent("mouse_scroll", self)
|
||||||
self.parent:addEvent("mouse_scroll", self)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,19 +23,19 @@ return function(name)
|
|||||||
|
|
||||||
setSymbolColor = function(self, symbolColor)
|
setSymbolColor = function(self, symbolColor)
|
||||||
bgSymbol = symbolColor
|
bgSymbol = symbolColor
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setActiveBackground = function(self, bgcol)
|
setActiveBackground = function(self, bgcol)
|
||||||
activeBG = bgcol
|
activeBG = bgcol
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setInactiveBackground = function(self, bgcol)
|
setInactiveBackground = function(self, bgcol)
|
||||||
inactiveBG = bgcol
|
inactiveBG = bgcol
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -51,6 +51,7 @@ return function(name)
|
|||||||
if (base.mouseHandler(self, button, x, y)) then
|
if (base.mouseHandler(self, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
self:setValue(not self:getValue())
|
self:setValue(not self:getValue())
|
||||||
|
self:updateDraw()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
@@ -69,7 +70,6 @@ return function(name)
|
|||||||
self.parent:drawBackgroundBox(obx+1, oby, 1, h, inactiveBG)
|
self.parent:drawBackgroundBox(obx+1, oby, 1, h, inactiveBG)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local Object = require("Object")
|
local Object = require("Object")
|
||||||
local tHex = require("tHex")
|
local tHex = require("tHex")
|
||||||
|
local log = require("basaltLogs")
|
||||||
local xmlValue = require("utils").getValueFromXML
|
local xmlValue = require("utils").getValueFromXML
|
||||||
|
|
||||||
return function(name)
|
return function(name)
|
||||||
@@ -65,6 +66,7 @@ return function(name)
|
|||||||
end
|
end
|
||||||
fgLines[l] = fgLine
|
fgLines[l] = fgLine
|
||||||
bgLines[l] = bgLine
|
bgLines[l] = bgLine
|
||||||
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function updateAllColors(self)
|
local function updateAllColors(self)
|
||||||
@@ -140,6 +142,7 @@ return function(name)
|
|||||||
|
|
||||||
editLine = function(self, index, text)
|
editLine = function(self, index, text)
|
||||||
lines[index] = text or lines[index]
|
lines[index] = text or lines[index]
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -148,6 +151,7 @@ return function(name)
|
|||||||
bgLines = {""}
|
bgLines = {""}
|
||||||
fgLines = {""}
|
fgLines = {""}
|
||||||
hIndex, wIndex, textX, textY = 1, 1, 1, 1
|
hIndex, wIndex, textX, textY = 1, 1, 1, 1
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -169,6 +173,7 @@ return function(name)
|
|||||||
table.insert(fgLines, tHex[self.fgColor]:rep(text:len()))
|
table.insert(fgLines, tHex[self.fgColor]:rep(text:len()))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -179,11 +184,13 @@ return function(name)
|
|||||||
for k,v in pairs(tab)do
|
for k,v in pairs(tab)do
|
||||||
table.insert(keyWords[color], v)
|
table.insert(keyWords[color], v)
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addRule = function(self, rule, fg, bg)
|
addRule = function(self, rule, fg, bg)
|
||||||
table.insert(rules, {rule, fg, bg})
|
table.insert(rules, {rule, fg, bg})
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -194,6 +201,7 @@ return function(name)
|
|||||||
rules[k][3] = bg
|
rules[k][3] = bg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -203,11 +211,13 @@ return function(name)
|
|||||||
table.remove(rules, k)
|
table.remove(rules, k)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setKeywords = function(self, color, tab)
|
setKeywords = function(self, color, tab)
|
||||||
keyWords[color] = tab
|
keyWords[color] = tab
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -216,6 +226,7 @@ return function(name)
|
|||||||
if (#lines <= 0) then
|
if (#lines <= 0) then
|
||||||
table.insert(lines, "")
|
table.insert(lines, "")
|
||||||
end
|
end
|
||||||
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -450,6 +461,7 @@ return function(name)
|
|||||||
cursorX = 0
|
cursorX = 0
|
||||||
end
|
end
|
||||||
self.parent:setCursor(true, obx + cursorX, oby + cursorY, self.fgColor)
|
self.parent:setCursor(true, obx + cursorX, oby + cursorY, self.fgColor)
|
||||||
|
self:updateDraw()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -474,7 +486,6 @@ return function(name)
|
|||||||
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged()
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -500,7 +511,7 @@ return function(name)
|
|||||||
self.parent:setCursor(false)
|
self.parent:setCursor(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged()
|
self:updateDraw()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -521,11 +532,10 @@ return function(name)
|
|||||||
wIndex = 1
|
wIndex = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (self.parent ~= nil) then
|
|
||||||
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
self:setVisualChanged()
|
if (self.parent ~= nil) then
|
||||||
|
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -545,6 +555,7 @@ return function(name)
|
|||||||
local anchx, anchy = self:getAnchorPosition()
|
local anchx, anchy = self:getAnchorPosition()
|
||||||
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
||||||
updateColors(self)
|
updateColors(self)
|
||||||
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -585,7 +596,6 @@ return function(name)
|
|||||||
self.parent:setFG(obx, oby + n - 1, fg)
|
self.parent:setFG(obx, oby + n - 1, fg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user