small monitor/offsetbugfix update
-reworked monitor support (you are able to write on monitors through computer) -fixed offset bugs -couple of smaller bugfixes
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
local basalt = { debugger = true, version = 1 }
|
local basalt = { debugger = true, version = 1 }
|
||||||
local activeFrame
|
|
||||||
local frames = {}
|
|
||||||
local keyActive = {}
|
local keyActive = {}
|
||||||
|
local focusedObject
|
||||||
|
local frames = {}
|
||||||
|
local activeFrame
|
||||||
|
|
||||||
|
local mainFrame
|
||||||
|
local monFrames = {}
|
||||||
|
|
||||||
local parentTerminal = term.current()
|
local parentTerminal = term.current()
|
||||||
|
|
||||||
local sub = string.sub
|
local sub = string.sub
|
||||||
@@ -606,11 +611,6 @@ end
|
|||||||
local function Object(name)
|
local function Object(name)
|
||||||
-- Base object
|
-- Base object
|
||||||
local objectType = "Object" -- not changeable
|
local objectType = "Object" -- not changeable
|
||||||
--[[
|
|
||||||
local horizontalAnchor = "left"
|
|
||||||
local verticalAnchor = "top"
|
|
||||||
local ignYOffset = false
|
|
||||||
local ignXOffset = false ]]
|
|
||||||
local value
|
local value
|
||||||
local zIndex = 1
|
local zIndex = 1
|
||||||
local hanchor = "left"
|
local hanchor = "left"
|
||||||
@@ -799,11 +799,8 @@ local function Object(name)
|
|||||||
|
|
||||||
getAbsolutePosition = function(self, x, y)
|
getAbsolutePosition = function(self, x, y)
|
||||||
-- relative position to absolute position
|
-- relative position to absolute position
|
||||||
if (x == nil) then
|
if (x == nil) or (y == nil) then
|
||||||
x = self.x
|
x, y = self:getAnchorPosition()
|
||||||
end
|
|
||||||
if (y == nil) then
|
|
||||||
y = self.y
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
@@ -828,21 +825,29 @@ local function Object(name)
|
|||||||
y = self.parent.height - y - self.height + 2
|
y = self.parent.height - y - self.height + 2
|
||||||
end
|
end
|
||||||
local xO, yO = self:getOffset()
|
local xO, yO = self:getOffset()
|
||||||
if (ignOffset or ignOff) then
|
if not(ignOffset or ignOff) then
|
||||||
return x, y
|
return x+xO, y+yO
|
||||||
end
|
end
|
||||||
return x + xO, y + yO
|
return x, y
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getOffset = function(self)
|
getOffset = function(self)
|
||||||
if (self.parent ~= nil) and (ignOffset == false) then
|
if (self.parent ~= nil) then
|
||||||
return self.parent:getFrameOffset()
|
return self.parent:getFrameOffset()
|
||||||
end
|
end
|
||||||
return 0, 0
|
return 0, 0
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ignoreOffset = function(self, ignore)
|
ignoreOffset = function(self, ignore)
|
||||||
ignOffset = ignore or true
|
ignOffset = ignore
|
||||||
|
if(ignore==nil)then ignOffset = true end
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
|
getBaseFrame = function(self)
|
||||||
|
if(self.parent~=nil)then
|
||||||
|
return self.parent:getBaseFrame()
|
||||||
|
end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -874,13 +879,24 @@ local function Object(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
onEvent = function(self, func)
|
onClickUp = function(self, func)
|
||||||
self:registerEvent("custom_event_handler", func)
|
self:registerEvent("mouse_up", func)
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
onClickUp = function(self, func)
|
|
||||||
self:registerEvent("mouse_up", func)
|
onScroll = function(self, func)
|
||||||
|
self:registerEvent("mouse_scroll", func)
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
|
onDrag = function(self, func)
|
||||||
|
self:registerEvent("mouse_drag", func)
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
|
onEvent = function(self, func)
|
||||||
|
self:registerEvent("custom_event_handler", func)
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -935,7 +951,7 @@ local function Object(name)
|
|||||||
return eventSystem:sendEvent(event, self, ...)
|
return eventSystem:sendEvent(event, self, ...)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (isVisible) then
|
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (isVisible) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
@@ -1148,8 +1164,8 @@ local function Checkbox(name)
|
|||||||
return objectType
|
return objectType
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
||||||
if (self:getValue() ~= true) and (self:getValue() ~= false) then
|
if (self:getValue() ~= true) and (self:getValue() ~= false) then
|
||||||
self:setValue(false)
|
self:setValue(false)
|
||||||
@@ -1283,7 +1299,7 @@ local function Dropdown(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (isOpened) then
|
if (isOpened) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
||||||
@@ -1318,7 +1334,7 @@ local function Dropdown(name)
|
|||||||
end
|
end
|
||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
end
|
end
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
isOpened = true
|
isOpened = true
|
||||||
else
|
else
|
||||||
isOpened = false
|
isOpened = false
|
||||||
@@ -1739,8 +1755,8 @@ local function Input(name)
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
if (event == "mouse_click") and (button == 1) then
|
if (event == "mouse_click") and (button == 1) then
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1984,7 +2000,7 @@ local function List(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (obx <= x) and (obx + self.width > x) and (oby <= y) and (oby + self.height > y) and (self:isVisible()) then
|
if (obx <= x) and (obx + self.width > x) and (oby <= y) and (oby + self.height > y) and (self:isVisible()) then
|
||||||
if (((event == "mouse_click") or (event == "mouse_drag"))and(button==1))or(event=="monitor_touch") then
|
if (((event == "mouse_click") or (event == "mouse_drag"))and(button==1))or(event=="monitor_touch") then
|
||||||
@@ -2177,8 +2193,8 @@ local function Menubar(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if(base.mouseClickHandler(self, event, button, x, y))then
|
if(base.mouseHandler(self, event, button, x, y))then
|
||||||
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then
|
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
@@ -2809,15 +2825,15 @@ local function Program(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
if (curProcess == nil) then
|
if (curProcess == nil) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if not (curProcess:isDead()) then
|
if not (curProcess:isDead()) then
|
||||||
if not (paused) then
|
if not (paused) then
|
||||||
local absX, absY = self:getAbsolutePosition(self:getAnchorPosition(nil, nil, true))
|
local absX, absY = self:getAbsolutePosition(self:getAnchorPosition(nil, nil, true))
|
||||||
curProcess:resume(event, button, x - absX + 1, y - absY + 1)
|
curProcess:resume(event, button, x - (absX - 1), y - (absY - 1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@@ -3098,7 +3114,7 @@ local function Radio(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if ((event == "mouse_click")and(button==1))or(event=="monitor_touch") then
|
if ((event == "mouse_click")and(button==1))or(event=="monitor_touch") then
|
||||||
if (#list > 0) then
|
if (#list > 0) then
|
||||||
@@ -3204,8 +3220,8 @@ local function Scrollbar(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
||||||
if (barType == "horizontal") then
|
if (barType == "horizontal") then
|
||||||
@@ -3333,8 +3349,8 @@ local function Slider(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
||||||
if (barType == "horizontal") then
|
if (barType == "horizontal") then
|
||||||
@@ -3438,8 +3454,8 @@ local function Switch(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if ((event == "mouse_click") and (button == 1))or(event=="monitor_touch") then
|
if ((event == "mouse_click") and (button == 1))or(event=="monitor_touch") then
|
||||||
self:setValue(not self:getValue())
|
self:setValue(not self:getValue())
|
||||||
@@ -3714,8 +3730,8 @@ local function Textfield(name)
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
local anchx, anchy = self:getAnchorPosition()
|
local anchx, anchy = self:getAnchorPosition()
|
||||||
if (event == "mouse_click")or(event=="monitor_touch") then
|
if (event == "mouse_click")or(event=="monitor_touch") then
|
||||||
@@ -3732,7 +3748,7 @@ local function Textfield(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex)
|
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3750,7 +3766,7 @@ local function Textfield(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex)
|
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3767,7 +3783,7 @@ local function Textfield(name)
|
|||||||
|
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
if (obx + textX - wIndex >= obx and obx + textX - wIndex <= obx + self.width) and (oby + textY - hIndex >= oby and oby + textY - hIndex <= oby + self.height) then
|
if (obx + textX - wIndex >= obx and obx + textX - wIndex <= obx + self.width) and (oby + textY - hIndex >= oby and oby + textY - hIndex <= oby + self.height) then
|
||||||
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex)
|
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
||||||
else
|
else
|
||||||
self.parent:setCursor(false)
|
self.parent:setCursor(false)
|
||||||
end
|
end
|
||||||
@@ -3956,11 +3972,12 @@ local function Frame(name, parent)
|
|||||||
local objects = {}
|
local objects = {}
|
||||||
local objZIndex = {}
|
local objZIndex = {}
|
||||||
local object = {}
|
local object = {}
|
||||||
local focusedObject
|
|
||||||
local termObject = parentTerminal
|
local termObject = parentTerminal
|
||||||
|
|
||||||
local monitors = {}
|
local monSide = ""
|
||||||
local isMonitor = false
|
local isMonitor = false
|
||||||
|
local monitorAttached = false
|
||||||
|
local dragOffset = 0
|
||||||
|
|
||||||
base:setZIndex(10)
|
base:setZIndex(10)
|
||||||
|
|
||||||
@@ -4048,16 +4065,13 @@ local function Frame(name, parent)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
setFocusedObject = function(self, obj)
|
setFocusedObject = function(self, obj)
|
||||||
for _, index in pairs(objZIndex) do
|
if (focusedObject ~= nil) then
|
||||||
for _, value in pairs(objects[index]) do
|
focusedObject:loseFocusHandler()
|
||||||
if (value == obj) then
|
focusedObject = nil
|
||||||
if (focusedObject ~= nil) then
|
end
|
||||||
focusedObject:loseFocusHandler()
|
if(obj~=nil)then
|
||||||
end
|
focusedObject = obj
|
||||||
focusedObject = obj
|
obj:getFocusHandler()
|
||||||
focusedObject:getFocusHandler()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
@@ -4068,7 +4082,7 @@ local function Frame(name, parent)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getFrameOffset = function(self)
|
getFrameOffset = function(self) -- internal
|
||||||
return xOffset, yOffset
|
return xOffset, yOffset
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -4084,25 +4098,22 @@ local function Frame(name, parent)
|
|||||||
return focusedObject
|
return focusedObject
|
||||||
end;
|
end;
|
||||||
|
|
||||||
show = function(self)
|
|
||||||
base:show()
|
|
||||||
if (self.parent == nil)and not(isMonitor) then
|
|
||||||
activeFrame = self
|
|
||||||
end
|
|
||||||
return self
|
|
||||||
end;
|
|
||||||
|
|
||||||
setCursor = function(self, _blink, _xCursor, _yCursor, color)
|
setCursor = function(self, _blink, _xCursor, _yCursor, color)
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
if(self.parent~=nil)then
|
||||||
cursorBlink = _blink or false
|
local obx, oby = self:getAnchorPosition()
|
||||||
if (_xCursor ~= nil) then
|
self.parent:setCursor(_blink or false, (_xCursor or 0)+obx-1, (_yCursor or 0)+oby-1, color or cursorColor)
|
||||||
xCursor = obx + _xCursor - 1
|
else
|
||||||
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
|
cursorBlink = _blink or false
|
||||||
|
if (_xCursor ~= nil) then
|
||||||
|
xCursor = obx + _xCursor - 1
|
||||||
|
end
|
||||||
|
if (_yCursor ~= nil) then
|
||||||
|
yCursor = oby + _yCursor - 1
|
||||||
|
end
|
||||||
|
cursorColor = color or cursorColor
|
||||||
|
self:setVisualChanged()
|
||||||
end
|
end
|
||||||
if (_yCursor ~= nil) then
|
|
||||||
yCursor = oby + _yCursor - 1
|
|
||||||
end
|
|
||||||
cursorColor = color or cursorColor
|
|
||||||
self:setVisualChanged()
|
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -4112,31 +4123,37 @@ local function Frame(name, parent)
|
|||||||
return self;
|
return self;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
show = function(self)
|
||||||
addMonitor = function(self, mon)
|
base.show(self)
|
||||||
local screen = peripheral.wrap(mon)
|
if(self.parent==nil)then
|
||||||
monitors[mon] = {monitor=mon, frame=basalt.createFrame(self:getName().."_monitor_"..mon)}
|
activeFrame = self;
|
||||||
monitors[mon].frame:setDisplay(screen):setFrameAsMonitor()
|
if(isMonitor)then
|
||||||
monitors[mon].frame:setSize(screen:getSize())
|
monFrames[monSide] = self;
|
||||||
return monitors[mon].frame
|
else
|
||||||
end;
|
mainFrame = self;
|
||||||
|
|
||||||
setMonitorScale = function(self, scale, fullSize) -- 1,2,3,4,5,6,7,8,9,10
|
|
||||||
if(isMonitor)then
|
|
||||||
termObject.setTextScale(scale*0.5)
|
|
||||||
if(fullSize)then
|
|
||||||
self:setSize(termObject:getSize())
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self, isMonitor
|
return self;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setFrameAsMonitor = function(self, isMon)
|
hide = function (self)
|
||||||
isMonitor = isMon
|
base.hide(self)
|
||||||
if(isMon==nil)then isMonitor = true end
|
if(self.parent==nil)then
|
||||||
|
if(activeFrame == self)then activeFrame = nil end
|
||||||
|
if(isMonitor)then
|
||||||
|
if(monFrames[monSide] == self)then
|
||||||
|
monFrames[monSide] = nil;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if(mainFrame == self)then
|
||||||
|
mainFrame = nil;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
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:setVisualChanged()
|
||||||
@@ -4157,14 +4174,23 @@ local function Frame(name, parent)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setDisplay = function(self, drawTerm)
|
setMonitor = function(self, side)
|
||||||
termObject = drawTerm
|
if(side~=nil)or(side~=false)then
|
||||||
|
if(peripheral.getType(side)=="monitor")then
|
||||||
|
termObject = peripheral.wrap(side)
|
||||||
|
monitorAttached = true
|
||||||
|
end
|
||||||
|
isMonitor = true
|
||||||
|
else
|
||||||
|
termObject = parentTerminal
|
||||||
|
isMonitor = false
|
||||||
|
if(monFrames[monSide]==self)then
|
||||||
|
monFrames[monSide] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
drawHelper = basaltDrawHelper(termObject)
|
drawHelper = basaltDrawHelper(termObject)
|
||||||
return self
|
monSide = side or nil
|
||||||
end;
|
return self;
|
||||||
|
|
||||||
getDisplay = function(self)
|
|
||||||
return termObject
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getVisualChanged = function(self)
|
getVisualChanged = function(self)
|
||||||
@@ -4195,10 +4221,14 @@ local function Frame(name, parent)
|
|||||||
|
|
||||||
keyHandler = function(self, event, key)
|
keyHandler = function(self, event, key)
|
||||||
if (focusedObject ~= nil) then
|
if (focusedObject ~= nil) then
|
||||||
if (focusedObject.keyHandler ~= nil) then
|
if(focusedObject~=self)then
|
||||||
if (focusedObject:keyHandler(event, key)) then
|
if (focusedObject.keyHandler ~= nil) then
|
||||||
return true
|
if (focusedObject:keyHandler(event, key)) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
base.keyHandler(self, event, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -4228,6 +4258,18 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if(isMonitor)then
|
||||||
|
if(event == "peripheral")and(p1==monSide)then
|
||||||
|
if(peripheral.getType(monSide)=="monitor")then
|
||||||
|
monitorAttached = true
|
||||||
|
termObject = peripheral.wrap(monSide)
|
||||||
|
drawHelper = basaltDrawHelper(termObject)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(event == "peripheral_detach")and(p1==monSide)then
|
||||||
|
monitorAttached = false
|
||||||
|
end
|
||||||
|
end
|
||||||
if (event == "terminate") then
|
if (event == "terminate") then
|
||||||
termObject.clear()
|
termObject.clear()
|
||||||
termObject.setCursorPos(1, 1)
|
termObject.setCursorPos(1, 1)
|
||||||
@@ -4235,7 +4277,7 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
local xO, yO = self:getOffset()
|
local xO, yO = self:getOffset()
|
||||||
xO = xO < 0 and math.abs(xO) or -xO
|
xO = xO < 0 and math.abs(xO) or -xO
|
||||||
yO = yO < 0 and math.abs(yO) or -yO
|
yO = yO < 0 and math.abs(yO) or -yO
|
||||||
@@ -4246,7 +4288,7 @@ local function Frame(name, parent)
|
|||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
parentX, parentY = self.parent:getAbsolutePosition(self.parent:getAnchorPosition())
|
parentX, parentY = self.parent:getAbsolutePosition(self.parent:getAnchorPosition())
|
||||||
end
|
end
|
||||||
self:setPosition(x + self.xToRem - (parentX - 1) + xO, y - (parentY - 1) + yO)
|
self:setPosition(x + dragOffset - (parentX - 1) + xO, y - (parentY - 1) + yO)
|
||||||
end
|
end
|
||||||
if (event == "mouse_up") then
|
if (event == "mouse_up") then
|
||||||
self.drag = false
|
self.drag = false
|
||||||
@@ -4254,32 +4296,25 @@ local function Frame(name, parent)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if(event~="monitor_touch") or (isMonitor)then
|
fx = fx + xOffset;fy = fy + yOffset;
|
||||||
for _, index in pairs(objZIndex) do
|
for _, index in pairs(objZIndex) do
|
||||||
if (objects[index] ~= nil) then
|
if (objects[index] ~= nil) then
|
||||||
for _, value in rpairs(objects[index]) do
|
for _, value in rpairs(objects[index]) do
|
||||||
if (value.mouseClickHandler ~= nil) then
|
if (value.mouseHandler ~= nil) then
|
||||||
if (value:mouseClickHandler(event, button, x + xO, y + yO)) then
|
if (value:mouseHandler(event, button, x, y)) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif not(isMonitor)then
|
|
||||||
for _,v in pairs(monitors)do
|
|
||||||
if(button==v.monitor)then
|
|
||||||
v.frame:mouseClickHandler(event, button, x, y)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if (self.isMoveable) then
|
if (self.isMoveable) then
|
||||||
if (x >= fx) and (x <= fx + self.width - 1) and (y == fy) and (event == "mouse_click") then
|
if (x >= fx) and (x <= fx + self.width - 1) and (y == fy) and (event == "mouse_click") then
|
||||||
self.drag = true
|
self.drag = true
|
||||||
self.xToRem = fx - x
|
dragOffset = fx - x
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (focusedObject ~= nil) then
|
if (focusedObject ~= nil) then
|
||||||
@@ -4295,7 +4330,8 @@ local function Frame(name, parent)
|
|||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (y >= 1) and (y <= self.height) then
|
if (y >= 1) and (y <= self.height) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1))
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:setText(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
else
|
else
|
||||||
drawHelper.setText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1))
|
drawHelper.setText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
end
|
end
|
||||||
@@ -4306,7 +4342,8 @@ local function Frame(name, parent)
|
|||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (y >= 1) and (y <= self.height) then
|
if (y >= 1) and (y <= self.height) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setBG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:setBG(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
else
|
else
|
||||||
drawHelper.setBG(math.max(x + (obx - 1), obx), oby + y - 1, sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
drawHelper.setBG(math.max(x + (obx - 1), obx), oby + y - 1, sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
end
|
end
|
||||||
@@ -4317,7 +4354,8 @@ local function Frame(name, parent)
|
|||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (y >= 1) and (y <= self.height) then
|
if (y >= 1) and (y <= self.height) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setFG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:setFG(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
else
|
else
|
||||||
drawHelper.setFG(math.max(x + (obx - 1), obx), oby + y - 1, sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
drawHelper.setFG(math.max(x + (obx - 1), obx), oby + y - 1, sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
end
|
end
|
||||||
@@ -4328,7 +4366,8 @@ local function Frame(name, parent)
|
|||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (y >= 1) and (y <= self.height) then
|
if (y >= 1) and (y <= self.height) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:writeText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol)
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:writeText(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol)
|
||||||
else
|
else
|
||||||
drawHelper.writeText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol)
|
drawHelper.writeText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol)
|
||||||
end
|
end
|
||||||
@@ -4340,7 +4379,8 @@ local function Frame(name, parent)
|
|||||||
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
||||||
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:drawBackgroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, bgCol)
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:drawBackgroundBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, bgCol)
|
||||||
else
|
else
|
||||||
drawHelper.drawBackgroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, bgCol)
|
drawHelper.drawBackgroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, bgCol)
|
||||||
end
|
end
|
||||||
@@ -4351,7 +4391,8 @@ local function Frame(name, parent)
|
|||||||
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
||||||
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:drawTextBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, symbol:sub(1, 1))
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:drawTextBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, symbol:sub(1, 1))
|
||||||
else
|
else
|
||||||
drawHelper.drawTextBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, symbol:sub(1, 1))
|
drawHelper.drawTextBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, symbol:sub(1, 1))
|
||||||
end
|
end
|
||||||
@@ -4362,16 +4403,15 @@ local function Frame(name, parent)
|
|||||||
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
||||||
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:drawForegroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, fgCol)
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:drawForegroundBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, fgCol)
|
||||||
else
|
else
|
||||||
drawHelper.drawForegroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, fgCol)
|
drawHelper.drawForegroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, fgCol)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
for _,v in pairs(monitors)do
|
if(isMonitor)and not(monitorAttached)then return false end;
|
||||||
v.frame:draw()
|
|
||||||
end
|
|
||||||
if (self:getVisualChanged()) then
|
if (self:getVisualChanged()) then
|
||||||
if (base.draw(self)) then
|
if (base.draw(self)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
@@ -4418,11 +4458,9 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
drawUpdate = function (self)
|
drawUpdate = function(self)
|
||||||
|
if(isMonitor)and not(monitorAttached)then return false end;
|
||||||
drawHelper.update()
|
drawHelper.update()
|
||||||
for k,v in pairs(monitors)do
|
|
||||||
v.frame:drawUpdate()
|
|
||||||
end
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addObject = function(self, obj)
|
addObject = function(self, obj)
|
||||||
@@ -4542,24 +4580,41 @@ local function Frame(name, parent)
|
|||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
setmetatable(object, base)
|
setmetatable(object, base)
|
||||||
if (parent == nil) then
|
|
||||||
table.insert(frames, object)
|
|
||||||
end
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
local function drawFrames()
|
||||||
|
mainFrame:draw()
|
||||||
|
mainFrame:drawUpdate()
|
||||||
|
for _,v in pairs(monFrames)do
|
||||||
|
v:draw()
|
||||||
|
v:drawUpdate()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local updaterActive = false
|
local updaterActive = false
|
||||||
local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
if (event == "mouse_click") then
|
if(mainFrame~=nil)then
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
if (event == "mouse_click") then
|
||||||
elseif (event == "mouse_drag") then
|
mainFrame:mouseHandler(event, p1, p2, p3, p4)
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame = mainFrame
|
||||||
elseif (event == "mouse_up") then
|
elseif (event == "mouse_drag") then
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
mainFrame:mouseHandler(event, p1, p2, p3, p4)
|
||||||
elseif (event == "mouse_scroll") then
|
activeFrame = mainFrame
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
elseif (event == "mouse_up") then
|
||||||
elseif (event == "monitor_touch") then
|
mainFrame:mouseHandler(event, p1, p2, p3, p4)
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame = mainFrame
|
||||||
elseif (event == "key") or (event == "char") then
|
elseif (event == "mouse_scroll") then
|
||||||
|
mainFrame:mouseHandler(event, p1, p2, p3, p4)
|
||||||
|
activeFrame = mainFrame
|
||||||
|
elseif (event == "monitor_touch") then
|
||||||
|
if(monFrames[p1]~=nil)then
|
||||||
|
monFrames[p1]:mouseHandler(event, p1, p2, p3, p4)
|
||||||
|
activeFrame = monFrames[p1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if(event == "key") or (event == "char") then
|
||||||
activeFrame:keyHandler(event, p1)
|
activeFrame:keyHandler(event, p1)
|
||||||
activeFrame:backgroundKeyHandler(event, p1)
|
activeFrame:backgroundKeyHandler(event, p1)
|
||||||
end
|
end
|
||||||
@@ -4572,20 +4627,18 @@ local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
|||||||
keyActive[p1] = false
|
keyActive[p1] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, value in pairs(frames) do
|
for _, v in pairs(frames) do
|
||||||
value:eventHandler(event, p1, p2, p3, p4)
|
v:eventHandler(event, p1, p2, p3, p4)
|
||||||
end
|
end
|
||||||
if (updaterActive) then
|
if (updaterActive) then
|
||||||
activeFrame:draw()
|
drawFrames()
|
||||||
activeFrame:drawUpdate()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function basalt.autoUpdate(isActive)
|
function basalt.autoUpdate(isActive)
|
||||||
parentTerminal.clear()
|
updaterActive = isActive
|
||||||
updaterActive = isActive or true
|
if(isActive==nil)then updaterActive = true end
|
||||||
activeFrame:draw()
|
drawFrames()
|
||||||
activeFrame:drawUpdate()
|
|
||||||
while updaterActive do
|
while updaterActive do
|
||||||
local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later
|
local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later
|
||||||
basaltUpdateEvent(event, p1, p2, p3, p4)
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
@@ -4596,8 +4649,7 @@ function basalt.update(event, p1, p2, p3, p4)
|
|||||||
if (event ~= nil) then
|
if (event ~= nil) then
|
||||||
basaltUpdateEvent(event, p1, p2, p3, p4)
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
else
|
else
|
||||||
activeFrame:draw()
|
drawFrames()
|
||||||
activeFrame:drawUpdate()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4631,32 +4683,34 @@ function basalt.setActiveFrame(frame)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function basalt.createFrame(name)
|
function basalt.createFrame(name)
|
||||||
return Frame(name)
|
for _, v in pairs(frames) do
|
||||||
|
if (v.name == name) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local newFrame = Frame(name)
|
||||||
|
table.insert(frames, newFrame)
|
||||||
|
return newFrame
|
||||||
end
|
end
|
||||||
|
|
||||||
function basalt.removeFrame(name)
|
function basalt.removeFrame(name)
|
||||||
for key, value in pairs(frames) do
|
frames[name] = nil
|
||||||
if (value.name == name) then
|
|
||||||
frames[key] = nil
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if (basalt.debugger) then
|
if (basalt.debugger) then
|
||||||
basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug", colors.black, colors.gray)
|
basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug", colors.black, colors.gray)
|
||||||
basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.width - 2, basalt.debugFrame.height - 3):setPosition(2, 3):setScrollable(true):show()
|
basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.width - 2, basalt.debugFrame.height - 3):setPosition(2, 3):setScrollable(true):show()
|
||||||
basalt.debugFrame:addButton("back"):setAnchor("right"):setSize(1, 1):setText("\22"):onClick(function() basalt.oldFrame:show() end):setBackground(colors.red):show()
|
basalt.debugFrame:addButton("back"):setAnchor("right"):setSize(1, 1):setText("\22"):onClick(function() basalt.oldFrame:show() end):setBackground(colors.red):show()
|
||||||
basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = activeFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()
|
basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = mainFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):ignoreOffset():setZIndex(20):show()
|
||||||
end
|
end
|
||||||
|
|
||||||
if (basalt.debugger) then
|
if (basalt.debugger) then
|
||||||
function basalt.debug(...)
|
function basalt.debug(...)
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
if (activeFrame.name ~= "basaltDebuggingFrame") then
|
if (mainFrame.name ~= "basaltDebuggingFrame") then
|
||||||
if (activeFrame ~= basalt.debugLabel.frame) then
|
if (mainFrame ~= basalt.debugFrame) then
|
||||||
basalt.debugLabel:setParent(activeFrame)
|
basalt.debugLabel:setParent(mainFrame)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local str = ""
|
local str = ""
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
oldVersions/v1.1/basalt.lua
Normal file
1
oldVersions/v1.1/basalt.lua
Normal file
File diff suppressed because one or more lines are too long
@@ -5,11 +5,12 @@ local function Frame(name, parent)
|
|||||||
local objects = {}
|
local objects = {}
|
||||||
local objZIndex = {}
|
local objZIndex = {}
|
||||||
local object = {}
|
local object = {}
|
||||||
local focusedObject
|
|
||||||
local termObject = parentTerminal
|
local termObject = parentTerminal
|
||||||
|
|
||||||
local monitors = {}
|
local monSide = ""
|
||||||
local isMonitor = false
|
local isMonitor = false
|
||||||
|
local monitorAttached = false
|
||||||
|
local dragOffset = 0
|
||||||
|
|
||||||
base:setZIndex(10)
|
base:setZIndex(10)
|
||||||
|
|
||||||
@@ -97,16 +98,13 @@ local function Frame(name, parent)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
setFocusedObject = function(self, obj)
|
setFocusedObject = function(self, obj)
|
||||||
for _, index in pairs(objZIndex) do
|
if (focusedObject ~= nil) then
|
||||||
for _, value in pairs(objects[index]) do
|
focusedObject:loseFocusHandler()
|
||||||
if (value == obj) then
|
focusedObject = nil
|
||||||
if (focusedObject ~= nil) then
|
end
|
||||||
focusedObject:loseFocusHandler()
|
if(obj~=nil)then
|
||||||
end
|
focusedObject = obj
|
||||||
focusedObject = obj
|
obj:getFocusHandler()
|
||||||
focusedObject:getFocusHandler()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
@@ -117,7 +115,7 @@ local function Frame(name, parent)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getFrameOffset = function(self)
|
getFrameOffset = function(self) -- internal
|
||||||
return xOffset, yOffset
|
return xOffset, yOffset
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -133,25 +131,22 @@ local function Frame(name, parent)
|
|||||||
return focusedObject
|
return focusedObject
|
||||||
end;
|
end;
|
||||||
|
|
||||||
show = function(self)
|
|
||||||
base:show()
|
|
||||||
if (self.parent == nil)and not(isMonitor) then
|
|
||||||
activeFrame = self
|
|
||||||
end
|
|
||||||
return self
|
|
||||||
end;
|
|
||||||
|
|
||||||
setCursor = function(self, _blink, _xCursor, _yCursor, color)
|
setCursor = function(self, _blink, _xCursor, _yCursor, color)
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
if(self.parent~=nil)then
|
||||||
cursorBlink = _blink or false
|
local obx, oby = self:getAnchorPosition()
|
||||||
if (_xCursor ~= nil) then
|
self.parent:setCursor(_blink or false, (_xCursor or 0)+obx-1, (_yCursor or 0)+oby-1, color or cursorColor)
|
||||||
xCursor = obx + _xCursor - 1
|
else
|
||||||
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
|
cursorBlink = _blink or false
|
||||||
|
if (_xCursor ~= nil) then
|
||||||
|
xCursor = obx + _xCursor - 1
|
||||||
|
end
|
||||||
|
if (_yCursor ~= nil) then
|
||||||
|
yCursor = oby + _yCursor - 1
|
||||||
|
end
|
||||||
|
cursorColor = color or cursorColor
|
||||||
|
self:setVisualChanged()
|
||||||
end
|
end
|
||||||
if (_yCursor ~= nil) then
|
|
||||||
yCursor = oby + _yCursor - 1
|
|
||||||
end
|
|
||||||
cursorColor = color or cursorColor
|
|
||||||
self:setVisualChanged()
|
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -161,31 +156,37 @@ local function Frame(name, parent)
|
|||||||
return self;
|
return self;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
show = function(self)
|
||||||
addMonitor = function(self, mon)
|
base.show(self)
|
||||||
local screen = peripheral.wrap(mon)
|
if(self.parent==nil)then
|
||||||
monitors[mon] = {monitor=mon, frame=basalt.createFrame(self:getName().."_monitor_"..mon)}
|
activeFrame = self;
|
||||||
monitors[mon].frame:setDisplay(screen):setFrameAsMonitor()
|
if(isMonitor)then
|
||||||
monitors[mon].frame:setSize(screen:getSize())
|
monFrames[monSide] = self;
|
||||||
return monitors[mon].frame
|
else
|
||||||
end;
|
mainFrame = self;
|
||||||
|
|
||||||
setMonitorScale = function(self, scale, fullSize) -- 1,2,3,4,5,6,7,8,9,10
|
|
||||||
if(isMonitor)then
|
|
||||||
termObject.setTextScale(scale*0.5)
|
|
||||||
if(fullSize)then
|
|
||||||
self:setSize(termObject:getSize())
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self, isMonitor
|
return self;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setFrameAsMonitor = function(self, isMon)
|
hide = function (self)
|
||||||
isMonitor = isMon
|
base.hide(self)
|
||||||
if(isMon==nil)then isMonitor = true end
|
if(self.parent==nil)then
|
||||||
|
if(activeFrame == self)then activeFrame = nil end
|
||||||
|
if(isMonitor)then
|
||||||
|
if(monFrames[monSide] == self)then
|
||||||
|
monFrames[monSide] = nil;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if(mainFrame == self)then
|
||||||
|
mainFrame = nil;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
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:setVisualChanged()
|
||||||
@@ -206,14 +207,23 @@ local function Frame(name, parent)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
setDisplay = function(self, drawTerm)
|
setMonitor = function(self, side)
|
||||||
termObject = drawTerm
|
if(side~=nil)or(side~=false)then
|
||||||
|
if(peripheral.getType(side)=="monitor")then
|
||||||
|
termObject = peripheral.wrap(side)
|
||||||
|
monitorAttached = true
|
||||||
|
end
|
||||||
|
isMonitor = true
|
||||||
|
else
|
||||||
|
termObject = parentTerminal
|
||||||
|
isMonitor = false
|
||||||
|
if(monFrames[monSide]==self)then
|
||||||
|
monFrames[monSide] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
drawHelper = basaltDrawHelper(termObject)
|
drawHelper = basaltDrawHelper(termObject)
|
||||||
return self
|
monSide = side or nil
|
||||||
end;
|
return self;
|
||||||
|
|
||||||
getDisplay = function(self)
|
|
||||||
return termObject
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getVisualChanged = function(self)
|
getVisualChanged = function(self)
|
||||||
@@ -244,10 +254,14 @@ local function Frame(name, parent)
|
|||||||
|
|
||||||
keyHandler = function(self, event, key)
|
keyHandler = function(self, event, key)
|
||||||
if (focusedObject ~= nil) then
|
if (focusedObject ~= nil) then
|
||||||
if (focusedObject.keyHandler ~= nil) then
|
if(focusedObject~=self)then
|
||||||
if (focusedObject:keyHandler(event, key)) then
|
if (focusedObject.keyHandler ~= nil) then
|
||||||
return true
|
if (focusedObject:keyHandler(event, key)) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
base.keyHandler(self, event, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@@ -277,6 +291,18 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if(isMonitor)then
|
||||||
|
if(event == "peripheral")and(p1==monSide)then
|
||||||
|
if(peripheral.getType(monSide)=="monitor")then
|
||||||
|
monitorAttached = true
|
||||||
|
termObject = peripheral.wrap(monSide)
|
||||||
|
drawHelper = basaltDrawHelper(termObject)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(event == "peripheral_detach")and(p1==monSide)then
|
||||||
|
monitorAttached = false
|
||||||
|
end
|
||||||
|
end
|
||||||
if (event == "terminate") then
|
if (event == "terminate") then
|
||||||
termObject.clear()
|
termObject.clear()
|
||||||
termObject.setCursorPos(1, 1)
|
termObject.setCursorPos(1, 1)
|
||||||
@@ -284,7 +310,7 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
local xO, yO = self:getOffset()
|
local xO, yO = self:getOffset()
|
||||||
xO = xO < 0 and math.abs(xO) or -xO
|
xO = xO < 0 and math.abs(xO) or -xO
|
||||||
yO = yO < 0 and math.abs(yO) or -yO
|
yO = yO < 0 and math.abs(yO) or -yO
|
||||||
@@ -295,7 +321,7 @@ local function Frame(name, parent)
|
|||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
parentX, parentY = self.parent:getAbsolutePosition(self.parent:getAnchorPosition())
|
parentX, parentY = self.parent:getAbsolutePosition(self.parent:getAnchorPosition())
|
||||||
end
|
end
|
||||||
self:setPosition(x + self.xToRem - (parentX - 1) + xO, y - (parentY - 1) + yO)
|
self:setPosition(x + dragOffset - (parentX - 1) + xO, y - (parentY - 1) + yO)
|
||||||
end
|
end
|
||||||
if (event == "mouse_up") then
|
if (event == "mouse_up") then
|
||||||
self.drag = false
|
self.drag = false
|
||||||
@@ -303,32 +329,25 @@ local function Frame(name, parent)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if(event~="monitor_touch") or (isMonitor)then
|
fx = fx + xOffset;fy = fy + yOffset;
|
||||||
for _, index in pairs(objZIndex) do
|
for _, index in pairs(objZIndex) do
|
||||||
if (objects[index] ~= nil) then
|
if (objects[index] ~= nil) then
|
||||||
for _, value in rpairs(objects[index]) do
|
for _, value in rpairs(objects[index]) do
|
||||||
if (value.mouseClickHandler ~= nil) then
|
if (value.mouseHandler ~= nil) then
|
||||||
if (value:mouseClickHandler(event, button, x + xO, y + yO)) then
|
if (value:mouseHandler(event, button, x, y)) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif not(isMonitor)then
|
|
||||||
for _,v in pairs(monitors)do
|
|
||||||
if(button==v.monitor)then
|
|
||||||
v.frame:mouseClickHandler(event, button, x, y)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if (self.isMoveable) then
|
if (self.isMoveable) then
|
||||||
if (x >= fx) and (x <= fx + self.width - 1) and (y == fy) and (event == "mouse_click") then
|
if (x >= fx) and (x <= fx + self.width - 1) and (y == fy) and (event == "mouse_click") then
|
||||||
self.drag = true
|
self.drag = true
|
||||||
self.xToRem = fx - x
|
dragOffset = fx - x
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (focusedObject ~= nil) then
|
if (focusedObject ~= nil) then
|
||||||
@@ -344,7 +363,8 @@ local function Frame(name, parent)
|
|||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (y >= 1) and (y <= self.height) then
|
if (y >= 1) and (y <= self.height) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1))
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:setText(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
else
|
else
|
||||||
drawHelper.setText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1))
|
drawHelper.setText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
end
|
end
|
||||||
@@ -355,7 +375,8 @@ local function Frame(name, parent)
|
|||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (y >= 1) and (y <= self.height) then
|
if (y >= 1) and (y <= self.height) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setBG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:setBG(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
else
|
else
|
||||||
drawHelper.setBG(math.max(x + (obx - 1), obx), oby + y - 1, sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
drawHelper.setBG(math.max(x + (obx - 1), obx), oby + y - 1, sub(bgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
end
|
end
|
||||||
@@ -366,7 +387,8 @@ local function Frame(name, parent)
|
|||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (y >= 1) and (y <= self.height) then
|
if (y >= 1) and (y <= self.height) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setFG(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:setFG(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
else
|
else
|
||||||
drawHelper.setFG(math.max(x + (obx - 1), obx), oby + y - 1, sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
drawHelper.setFG(math.max(x + (obx - 1), obx), oby + y - 1, sub(fgCol, math.max(1 - x + 1, 1), self.width - x + 1))
|
||||||
end
|
end
|
||||||
@@ -377,7 +399,8 @@ local function Frame(name, parent)
|
|||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (y >= 1) and (y <= self.height) then
|
if (y >= 1) and (y <= self.height) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:writeText(math.max(x + (obx - 1), obx) - (self.parent.x - 1), oby + y - 1 - (self.parent.y - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol)
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:writeText(math.max(x + (obx - 1), obx) - (parentX - 1), oby + y - 1 - (parentY - 1), sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol)
|
||||||
else
|
else
|
||||||
drawHelper.writeText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol)
|
drawHelper.writeText(math.max(x + (obx - 1), obx), oby + y - 1, sub(text, math.max(1 - x + 1, 1), self.width - x + 1), bgCol, fgCol)
|
||||||
end
|
end
|
||||||
@@ -389,7 +412,8 @@ local function Frame(name, parent)
|
|||||||
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
||||||
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:drawBackgroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, bgCol)
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:drawBackgroundBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, bgCol)
|
||||||
else
|
else
|
||||||
drawHelper.drawBackgroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, bgCol)
|
drawHelper.drawBackgroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, bgCol)
|
||||||
end
|
end
|
||||||
@@ -400,7 +424,8 @@ local function Frame(name, parent)
|
|||||||
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
||||||
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:drawTextBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, symbol:sub(1, 1))
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:drawTextBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, symbol:sub(1, 1))
|
||||||
else
|
else
|
||||||
drawHelper.drawTextBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, symbol:sub(1, 1))
|
drawHelper.drawTextBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, symbol:sub(1, 1))
|
||||||
end
|
end
|
||||||
@@ -411,16 +436,15 @@ local function Frame(name, parent)
|
|||||||
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
height = (y < 1 and (height + y > self.height and self.height or height + y - 1) or (height + y > self.height and self.height - y + 1 or height))
|
||||||
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
width = (x < 1 and (width + x > self.width and self.width or width + x - 1) or (width + x > self.width and self.width - x + 1 or width))
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:drawForegroundBox(math.max(x + (obx - 1), obx) - (self.parent.x - 1), math.max(y + (oby - 1), oby) - (self.parent.y - 1), width, height, fgCol)
|
local parentX, parentY = self.parent:getAnchorPosition()
|
||||||
|
self.parent:drawForegroundBox(math.max(x + (obx - 1), obx) - (parentX - 1), math.max(y + (oby - 1), oby) - (parentY - 1), width, height, fgCol)
|
||||||
else
|
else
|
||||||
drawHelper.drawForegroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, fgCol)
|
drawHelper.drawForegroundBox(math.max(x + (obx - 1), obx), math.max(y + (oby - 1), oby), width, height, fgCol)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
for _,v in pairs(monitors)do
|
if(isMonitor)and not(monitorAttached)then return false end;
|
||||||
v.frame:draw()
|
|
||||||
end
|
|
||||||
if (self:getVisualChanged()) then
|
if (self:getVisualChanged()) then
|
||||||
if (base.draw(self)) then
|
if (base.draw(self)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
@@ -467,11 +491,9 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
drawUpdate = function (self)
|
drawUpdate = function(self)
|
||||||
|
if(isMonitor)and not(monitorAttached)then return false end;
|
||||||
drawHelper.update()
|
drawHelper.update()
|
||||||
for k,v in pairs(monitors)do
|
|
||||||
v.frame:drawUpdate()
|
|
||||||
end
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
addObject = function(self, obj)
|
addObject = function(self, obj)
|
||||||
@@ -591,8 +613,5 @@ local function Frame(name, parent)
|
|||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
setmetatable(object, base)
|
setmetatable(object, base)
|
||||||
if (parent == nil) then
|
|
||||||
table.insert(frames, object)
|
|
||||||
end
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
@@ -1,11 +1,6 @@
|
|||||||
local function Object(name)
|
local function Object(name)
|
||||||
-- Base object
|
-- Base object
|
||||||
local objectType = "Object" -- not changeable
|
local objectType = "Object" -- not changeable
|
||||||
--[[
|
|
||||||
local horizontalAnchor = "left"
|
|
||||||
local verticalAnchor = "top"
|
|
||||||
local ignYOffset = false
|
|
||||||
local ignXOffset = false ]]
|
|
||||||
local value
|
local value
|
||||||
local zIndex = 1
|
local zIndex = 1
|
||||||
local hanchor = "left"
|
local hanchor = "left"
|
||||||
@@ -194,11 +189,8 @@ local function Object(name)
|
|||||||
|
|
||||||
getAbsolutePosition = function(self, x, y)
|
getAbsolutePosition = function(self, x, y)
|
||||||
-- relative position to absolute position
|
-- relative position to absolute position
|
||||||
if (x == nil) then
|
if (x == nil) or (y == nil) then
|
||||||
x = self.x
|
x, y = self:getAnchorPosition()
|
||||||
end
|
|
||||||
if (y == nil) then
|
|
||||||
y = self.y
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
@@ -223,21 +215,29 @@ local function Object(name)
|
|||||||
y = self.parent.height - y - self.height + 2
|
y = self.parent.height - y - self.height + 2
|
||||||
end
|
end
|
||||||
local xO, yO = self:getOffset()
|
local xO, yO = self:getOffset()
|
||||||
if (ignOffset or ignOff) then
|
if not(ignOffset or ignOff) then
|
||||||
return x, y
|
return x+xO, y+yO
|
||||||
end
|
end
|
||||||
return x + xO, y + yO
|
return x, y
|
||||||
end;
|
end;
|
||||||
|
|
||||||
getOffset = function(self)
|
getOffset = function(self)
|
||||||
if (self.parent ~= nil) and (ignOffset == false) then
|
if (self.parent ~= nil) then
|
||||||
return self.parent:getFrameOffset()
|
return self.parent:getFrameOffset()
|
||||||
end
|
end
|
||||||
return 0, 0
|
return 0, 0
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ignoreOffset = function(self, ignore)
|
ignoreOffset = function(self, ignore)
|
||||||
ignOffset = ignore or true
|
ignOffset = ignore
|
||||||
|
if(ignore==nil)then ignOffset = true end
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
|
getBaseFrame = function(self)
|
||||||
|
if(self.parent~=nil)then
|
||||||
|
return self.parent:getBaseFrame()
|
||||||
|
end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -269,13 +269,24 @@ local function Object(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
onEvent = function(self, func)
|
onClickUp = function(self, func)
|
||||||
self:registerEvent("custom_event_handler", func)
|
self:registerEvent("mouse_up", func)
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
onClickUp = function(self, func)
|
|
||||||
self:registerEvent("mouse_up", func)
|
onScroll = function(self, func)
|
||||||
|
self:registerEvent("mouse_scroll", func)
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
|
onDrag = function(self, func)
|
||||||
|
self:registerEvent("mouse_drag", func)
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
|
onEvent = function(self, func)
|
||||||
|
self:registerEvent("custom_event_handler", func)
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -330,7 +341,7 @@ local function Object(name)
|
|||||||
return eventSystem:sendEvent(event, self, ...)
|
return eventSystem:sendEvent(event, self, ...)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (isVisible) then
|
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (isVisible) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
|
|||||||
@@ -1,16 +1,36 @@
|
|||||||
|
local function drawFrames()
|
||||||
|
mainFrame:draw()
|
||||||
|
mainFrame:drawUpdate()
|
||||||
|
for _,v in pairs(monFrames)do
|
||||||
|
v:draw()
|
||||||
|
v:drawUpdate()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local updaterActive = false
|
local updaterActive = false
|
||||||
local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
if (event == "mouse_click") then
|
if(mainFrame~=nil)then
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
if (event == "mouse_click") then
|
||||||
elseif (event == "mouse_drag") then
|
mainFrame:mouseHandler(event, p1, p2, p3, p4)
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame = mainFrame
|
||||||
elseif (event == "mouse_up") then
|
elseif (event == "mouse_drag") then
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
mainFrame:mouseHandler(event, p1, p2, p3, p4)
|
||||||
elseif (event == "mouse_scroll") then
|
activeFrame = mainFrame
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
elseif (event == "mouse_up") then
|
||||||
elseif (event == "monitor_touch") then
|
mainFrame:mouseHandler(event, p1, p2, p3, p4)
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame = mainFrame
|
||||||
elseif (event == "key") or (event == "char") then
|
elseif (event == "mouse_scroll") then
|
||||||
|
mainFrame:mouseHandler(event, p1, p2, p3, p4)
|
||||||
|
activeFrame = mainFrame
|
||||||
|
elseif (event == "monitor_touch") then
|
||||||
|
if(monFrames[p1]~=nil)then
|
||||||
|
monFrames[p1]:mouseHandler(event, p1, p2, p3, p4)
|
||||||
|
activeFrame = monFrames[p1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if(event == "key") or (event == "char") then
|
||||||
activeFrame:keyHandler(event, p1)
|
activeFrame:keyHandler(event, p1)
|
||||||
activeFrame:backgroundKeyHandler(event, p1)
|
activeFrame:backgroundKeyHandler(event, p1)
|
||||||
end
|
end
|
||||||
@@ -23,20 +43,18 @@ local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
|||||||
keyActive[p1] = false
|
keyActive[p1] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, value in pairs(frames) do
|
for _, v in pairs(frames) do
|
||||||
value:eventHandler(event, p1, p2, p3, p4)
|
v:eventHandler(event, p1, p2, p3, p4)
|
||||||
end
|
end
|
||||||
if (updaterActive) then
|
if (updaterActive) then
|
||||||
activeFrame:draw()
|
drawFrames()
|
||||||
activeFrame:drawUpdate()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function basalt.autoUpdate(isActive)
|
function basalt.autoUpdate(isActive)
|
||||||
parentTerminal.clear()
|
updaterActive = isActive
|
||||||
updaterActive = isActive or true
|
if(isActive==nil)then updaterActive = true end
|
||||||
activeFrame:draw()
|
drawFrames()
|
||||||
activeFrame:drawUpdate()
|
|
||||||
while updaterActive do
|
while updaterActive do
|
||||||
local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later
|
local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later
|
||||||
basaltUpdateEvent(event, p1, p2, p3, p4)
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
@@ -47,8 +65,7 @@ function basalt.update(event, p1, p2, p3, p4)
|
|||||||
if (event ~= nil) then
|
if (event ~= nil) then
|
||||||
basaltUpdateEvent(event, p1, p2, p3, p4)
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
else
|
else
|
||||||
activeFrame:draw()
|
drawFrames()
|
||||||
activeFrame:drawUpdate()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -82,32 +99,34 @@ function basalt.setActiveFrame(frame)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function basalt.createFrame(name)
|
function basalt.createFrame(name)
|
||||||
return Frame(name)
|
for _, v in pairs(frames) do
|
||||||
|
if (v.name == name) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local newFrame = Frame(name)
|
||||||
|
table.insert(frames, newFrame)
|
||||||
|
return newFrame
|
||||||
end
|
end
|
||||||
|
|
||||||
function basalt.removeFrame(name)
|
function basalt.removeFrame(name)
|
||||||
for key, value in pairs(frames) do
|
frames[name] = nil
|
||||||
if (value.name == name) then
|
|
||||||
frames[key] = nil
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if (basalt.debugger) then
|
if (basalt.debugger) then
|
||||||
basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug", colors.black, colors.gray)
|
basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug", colors.black, colors.gray)
|
||||||
basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.width - 2, basalt.debugFrame.height - 3):setPosition(2, 3):setScrollable(true):show()
|
basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.width - 2, basalt.debugFrame.height - 3):setPosition(2, 3):setScrollable(true):show()
|
||||||
basalt.debugFrame:addButton("back"):setAnchor("right"):setSize(1, 1):setText("\22"):onClick(function() basalt.oldFrame:show() end):setBackground(colors.red):show()
|
basalt.debugFrame:addButton("back"):setAnchor("right"):setSize(1, 1):setText("\22"):onClick(function() basalt.oldFrame:show() end):setBackground(colors.red):show()
|
||||||
basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = activeFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()
|
basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = mainFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):ignoreOffset():setZIndex(20):show()
|
||||||
end
|
end
|
||||||
|
|
||||||
if (basalt.debugger) then
|
if (basalt.debugger) then
|
||||||
function basalt.debug(...)
|
function basalt.debug(...)
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
if (activeFrame.name ~= "basaltDebuggingFrame") then
|
if (mainFrame.name ~= "basaltDebuggingFrame") then
|
||||||
if (activeFrame ~= basalt.debugLabel.frame) then
|
if (mainFrame ~= basalt.debugFrame) then
|
||||||
basalt.debugLabel:setParent(activeFrame)
|
basalt.debugLabel:setParent(mainFrame)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local str = ""
|
local str = ""
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
local basalt = { debugger = true, version = 1 }
|
local basalt = { debugger = true, version = 1 }
|
||||||
local activeFrame
|
|
||||||
local frames = {}
|
|
||||||
local keyActive = {}
|
local keyActive = {}
|
||||||
|
local focusedObject
|
||||||
|
local frames = {}
|
||||||
|
local activeFrame
|
||||||
|
|
||||||
|
local mainFrame
|
||||||
|
local monFrames = {}
|
||||||
|
|
||||||
local parentTerminal = term.current()
|
local parentTerminal = term.current()
|
||||||
|
|
||||||
local sub = string.sub
|
local sub = string.sub
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ local function Checkbox(name)
|
|||||||
return objectType
|
return objectType
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
||||||
if (self:getValue() ~= true) and (self:getValue() ~= false) then
|
if (self:getValue() ~= true) and (self:getValue() ~= false) then
|
||||||
self:setValue(false)
|
self:setValue(false)
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ local function Dropdown(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (isOpened) then
|
if (isOpened) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
||||||
@@ -129,7 +129,7 @@ local function Dropdown(name)
|
|||||||
end
|
end
|
||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
end
|
end
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
isOpened = true
|
isOpened = true
|
||||||
else
|
else
|
||||||
isOpened = false
|
isOpened = false
|
||||||
|
|||||||
@@ -187,8 +187,8 @@ local function Input(name)
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
if (event == "mouse_click") and (button == 1) then
|
if (event == "mouse_click") and (button == 1) then
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ local function List(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (obx <= x) and (obx + self.width > x) and (oby <= y) and (oby + self.height > y) and (self:isVisible()) then
|
if (obx <= x) and (obx + self.width > x) and (oby <= y) and (oby + self.height > y) and (self:isVisible()) then
|
||||||
if (((event == "mouse_click") or (event == "mouse_drag"))and(button==1))or(event=="monitor_touch") then
|
if (((event == "mouse_click") or (event == "mouse_drag"))and(button==1))or(event=="monitor_touch") then
|
||||||
|
|||||||
@@ -126,8 +126,8 @@ local function Menubar(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if(base.mouseClickHandler(self, event, button, x, y))then
|
if(base.mouseHandler(self, event, button, x, y))then
|
||||||
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
local objX, objY = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then
|
if (objX <= x) and (objX + self.width > x) and (objY <= y) and (objY + self.height > y) and (self:isVisible()) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
|
|||||||
@@ -534,15 +534,15 @@ local function Program(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
if (curProcess == nil) then
|
if (curProcess == nil) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if not (curProcess:isDead()) then
|
if not (curProcess:isDead()) then
|
||||||
if not (paused) then
|
if not (paused) then
|
||||||
local absX, absY = self:getAbsolutePosition(self:getAnchorPosition(nil, nil, true))
|
local absX, absY = self:getAbsolutePosition(self:getAnchorPosition(nil, nil, true))
|
||||||
curProcess:resume(event, button, x - absX + 1, y - absY + 1)
|
curProcess:resume(event, button, x - (absX - 1), y - (absY - 1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ local function Radio(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if ((event == "mouse_click")and(button==1))or(event=="monitor_touch") then
|
if ((event == "mouse_click")and(button==1))or(event=="monitor_touch") then
|
||||||
if (#list > 0) then
|
if (#list > 0) then
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ local function Scrollbar(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
||||||
if (barType == "horizontal") then
|
if (barType == "horizontal") then
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ local function Slider(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
||||||
if (barType == "horizontal") then
|
if (barType == "horizontal") then
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ local function Switch(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if ((event == "mouse_click") and (button == 1))or(event=="monitor_touch") then
|
if ((event == "mouse_click") and (button == 1))or(event=="monitor_touch") then
|
||||||
self:setValue(not self:getValue())
|
self:setValue(not self:getValue())
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ local function Textfield(name)
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseHandler(self, event, button, x, y)) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
local anchx, anchy = self:getAnchorPosition()
|
local anchx, anchy = self:getAnchorPosition()
|
||||||
if (event == "mouse_click")or(event=="monitor_touch") then
|
if (event == "mouse_click")or(event=="monitor_touch") then
|
||||||
@@ -262,7 +262,7 @@ local function Textfield(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex)
|
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -280,7 +280,7 @@ local function Textfield(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex)
|
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -297,7 +297,7 @@ local function Textfield(name)
|
|||||||
|
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
if (obx + textX - wIndex >= obx and obx + textX - wIndex <= obx + self.width) and (oby + textY - hIndex >= oby and oby + textY - hIndex <= oby + self.height) then
|
if (obx + textX - wIndex >= obx and obx + textX - wIndex <= obx + self.width) and (oby + textY - hIndex >= oby and oby + textY - hIndex <= oby + self.height) then
|
||||||
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex)
|
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
|
||||||
else
|
else
|
||||||
self.parent:setCursor(false)
|
self.parent:setCursor(false)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user