Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -7,7 +7,7 @@ Basalt is still under developement and you may find bugs!
|
|||||||
|
|
||||||
## Information
|
## Information
|
||||||
|
|
||||||
Check out the [wiki](https://github.com/Pyroxenium/Basalt/wiki) for information<br>
|
Check out the [wiki](https://basalt.madefor.cc/) for information<br>
|
||||||
If you have questions, feel free to join the discord server: [https://discord.gg/yM7kndJdJJ](https://discord.gg/yM7kndJdJJ)
|
If you have questions, feel free to join the discord server: [https://discord.gg/yM7kndJdJJ](https://discord.gg/yM7kndJdJJ)
|
||||||
|
|
||||||
Todo:<br>
|
Todo:<br>
|
||||||
|
|||||||
@@ -144,7 +144,6 @@ generateFontSize(3,false)
|
|||||||
|
|
||||||
local function makeText(nSize, sString, nFC, nBC, bBlit)
|
local function makeText(nSize, sString, nFC, nBC, bBlit)
|
||||||
if not type(sString) == "string" then error("Not a String",3) end --this should never happend with expects in place.
|
if not type(sString) == "string" then error("Not a String",3) end --this should never happend with expects in place.
|
||||||
print(tHex, nFC)
|
|
||||||
local cFC = type(nFC) == "string" and nFC:sub(1, 1) or tHex[nFC] or error("Wrong Front Color",3)
|
local cFC = type(nFC) == "string" and nFC:sub(1, 1) or tHex[nFC] or error("Wrong Front Color",3)
|
||||||
local cBC = type(nBC) == "string" and nBC:sub(1, 1) or tHex[nBC] or error("Wrong Back Color",3)
|
local cBC = type(nBC) == "string" and nBC:sub(1, 1) or tHex[nBC] or error("Wrong Back Color",3)
|
||||||
local font = fonts[nSize] or error("Wrong font size selected",3)
|
local font = fonts[nSize] or error("Wrong font size selected",3)
|
||||||
@@ -184,8 +183,8 @@ local function makeText(nSize, sString, nFC, nBC, bBlit)
|
|||||||
|
|
||||||
return {tText, tFront, tBack}
|
return {tText, tFront, tBack}
|
||||||
end
|
end
|
||||||
local function basaltDrawHelper()
|
local function basaltDrawHelper(drawTerm)
|
||||||
local terminal = parentTerminal
|
local terminal = drawTerm
|
||||||
local width, height = terminal.getSize()
|
local width, height = terminal.getSize()
|
||||||
local cacheT = {}
|
local cacheT = {}
|
||||||
local cacheBG = {}
|
local cacheBG = {}
|
||||||
@@ -365,7 +364,6 @@ local function basaltDrawHelper()
|
|||||||
}
|
}
|
||||||
return drawHelper
|
return drawHelper
|
||||||
end
|
end
|
||||||
local drawHelper = basaltDrawHelper()
|
|
||||||
local function BasaltEvents()
|
local function BasaltEvents()
|
||||||
|
|
||||||
local events = {}
|
local events = {}
|
||||||
@@ -731,9 +729,9 @@ local function Object(name)
|
|||||||
|
|
||||||
setPosition = function(self, xPos, yPos, rel)
|
setPosition = function(self, xPos, yPos, rel)
|
||||||
if (rel) then
|
if (rel) then
|
||||||
self.x, self.y = self.x + xPos, self.y + yPos
|
self.x, self.y = math.floor(self.x + xPos), math.floor(self.y + yPos)
|
||||||
else
|
else
|
||||||
self.x, self.y = xPos, yPos
|
self.x, self.y = math.floor(xPos), math.floor(yPos)
|
||||||
end
|
end
|
||||||
visualsChanged = true
|
visualsChanged = true
|
||||||
return self
|
return self
|
||||||
@@ -872,6 +870,7 @@ local function Object(name)
|
|||||||
|
|
||||||
onClick = function(self, func)
|
onClick = function(self, func)
|
||||||
self:registerEvent("mouse_click", func)
|
self:registerEvent("mouse_click", func)
|
||||||
|
self:registerEvent("monitor_touch", func)
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -1150,7 +1149,7 @@ local function Checkbox(name)
|
|||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(self, event, button, x, y)) then
|
||||||
if (event == "mouse_click") and (button == 1) 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)
|
||||||
else
|
else
|
||||||
@@ -1227,6 +1226,10 @@ local function Dropdown(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getAll = function(self)
|
||||||
|
return list
|
||||||
|
end;
|
||||||
|
|
||||||
removeItem = function(self, index)
|
removeItem = function(self, index)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
return self
|
return self
|
||||||
@@ -1281,16 +1284,14 @@ local function Dropdown(name)
|
|||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (state == 2) then
|
if (state == 2) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (event == "mouse_click") then
|
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
||||||
-- remove mouse_drag if i want to make objects moveable uwuwuwuw
|
|
||||||
if (button == 1) then
|
if (#list > 0) then
|
||||||
if (#list > 0) then
|
for n = 1, dropdownH do
|
||||||
for n = 1, dropdownH do
|
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])
|
return true
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1938,6 +1939,10 @@ local function List(name)
|
|||||||
return list[index]
|
return list[index]
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getAll = function(self)
|
||||||
|
return list
|
||||||
|
end;
|
||||||
|
|
||||||
getItemIndex = function(self)
|
getItemIndex = function(self)
|
||||||
local selected = self:getValue()
|
local selected = self:getValue()
|
||||||
for key, value in pairs(list) do
|
for key, value in pairs(list) do
|
||||||
@@ -1983,16 +1988,13 @@ local function List(name)
|
|||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = 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") then
|
if (((event == "mouse_click") or (event == "mouse_drag"))and(button==1))or(event=="monitor_touch") then
|
||||||
-- remove mouse_drag if i want to make objects moveable uwuwuwuw
|
if (#list > 0) then
|
||||||
if (button == 1) then
|
for n = 1, self.height do
|
||||||
if (#list > 0) then
|
if (list[n + yOffset] ~= nil) then
|
||||||
for n = 1, self.height do
|
if (obx <= x) and (obx + self.width > x) and (oby + n - 1 == y) then
|
||||||
if (list[n + yOffset] ~= nil) then
|
self:setValue(list[n + yOffset])
|
||||||
if (obx <= x) and (obx + self.width > x) and (oby + n - 1 == y) then
|
self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", 0, x, y, list[n + yOffset])
|
||||||
self:setValue(list[n + yOffset])
|
|
||||||
self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", 0, x, y, list[n + yOffset])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2093,6 +2095,10 @@ local function Menubar(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getAll = function(self)
|
||||||
|
return list
|
||||||
|
end;
|
||||||
|
|
||||||
getItemIndex = function(self)
|
getItemIndex = function(self)
|
||||||
local selected = self:getValue()
|
local selected = self:getValue()
|
||||||
for key, value in pairs(list) do
|
for key, value in pairs(list) do
|
||||||
@@ -2168,7 +2174,7 @@ local function Menubar(name)
|
|||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setFocusedObject(self)
|
self.parent:setFocusedObject(self)
|
||||||
end
|
end
|
||||||
if (event == "mouse_click") then
|
if (event == "mouse_click") or (event == "monitor_touch") then
|
||||||
local xPos = 1
|
local xPos = 1
|
||||||
for n = 1 + itemOffset, #list do
|
for n = 1 + itemOffset, #list do
|
||||||
if (list[n] ~= nil) then
|
if (list[n] ~= nil) then
|
||||||
@@ -2861,7 +2867,7 @@ local function Program(name)
|
|||||||
end
|
end
|
||||||
if not (curProcess:isDead()) then
|
if not (curProcess:isDead()) then
|
||||||
if not (paused) then
|
if not (paused) then
|
||||||
if (event ~= "mouse_click") and (event ~= "mouse_up") and (event ~= "mouse_scroll") and (event ~= "mouse_drag") and (event ~= "key_up") and (event ~= "key") and (event ~= "char") and (event ~= "terminate") then
|
if (event ~= "mouse_click") and (event ~= "monitor_touch") and (event ~= "mouse_up") and (event ~= "mouse_scroll") and (event ~= "mouse_drag") and (event ~= "key_up") and (event ~= "key") and (event ~= "char") and (event ~= "terminate") then
|
||||||
curProcess:resume(event, p1, p2, p3, p4)
|
curProcess:resume(event, p1, p2, p3, p4)
|
||||||
end
|
end
|
||||||
if (self:isFocused()) then
|
if (self:isFocused()) then
|
||||||
@@ -2878,7 +2884,7 @@ local function Program(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (event ~= "mouse_click") and (event ~= "mouse_up") and (event ~= "mouse_scroll") and (event ~= "mouse_drag") and (event ~= "key_up") and (event ~= "key") and (event ~= "char") and (event ~= "terminate") then
|
if (event ~= "mouse_click") and (event ~= "monitor_touch") and (event ~= "mouse_up") and (event ~= "mouse_scroll") and (event ~= "mouse_drag") and (event ~= "key_up") and (event ~= "key") and (event ~= "char") and (event ~= "terminate") then
|
||||||
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } })
|
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3029,6 +3035,10 @@ local function Radio(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getAll = function(self)
|
||||||
|
return list
|
||||||
|
end;
|
||||||
|
|
||||||
removeItem = function(self, index)
|
removeItem = function(self, index)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
return self
|
return self
|
||||||
@@ -3079,20 +3089,17 @@ local function Radio(name)
|
|||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (event == "mouse_click") then
|
if ((event == "mouse_click")and(button==1))or(event=="monitor_touch") then
|
||||||
-- remove mouse_drag if i want to make objects moveable uwuwuwuw
|
if (#list > 0) then
|
||||||
if (button == 1) then
|
for _, value in pairs(list) do
|
||||||
if (#list > 0) then
|
if (obx + value.x - 1 <= x) and (obx + value.x - 1 + value.text:len() + 2 >= x) and (oby + value.y - 1 == y) then
|
||||||
for _, value in pairs(list) do
|
self:setValue(value)
|
||||||
if (obx + value.x - 1 <= x) and (obx + value.x - 1 + value.text:len() + 2 >= x) and (oby + value.y - 1 == y) then
|
if (self.parent ~= nil) then
|
||||||
self:setValue(value)
|
self.parent:setFocusedObject(self)
|
||||||
if (self.parent ~= nil) then
|
|
||||||
self.parent:setFocusedObject(self)
|
|
||||||
end
|
|
||||||
--eventSystem:sendEvent(event, self, event, button, x, y)
|
|
||||||
self:setVisualChanged()
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
--eventSystem:sendEvent(event, self, event, button, x, y)
|
||||||
|
self:setVisualChanged()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3188,7 +3195,7 @@ local function Scrollbar(name)
|
|||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(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) 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
|
||||||
for _index = 0, self.width do
|
for _index = 0, self.width do
|
||||||
if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then
|
if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then
|
||||||
@@ -3373,7 +3380,7 @@ local function Switch(name)
|
|||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(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) then
|
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -3643,7 +3650,7 @@ local function Textfield(name)
|
|||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(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") then
|
if (event == "mouse_click")or(event=="monitor_touch") then
|
||||||
if (lines[y - oby + hIndex] ~= nil) then
|
if (lines[y - oby + hIndex] ~= nil) then
|
||||||
textX = x - obx + wIndex
|
textX = x - obx + wIndex
|
||||||
textY = y - oby + hIndex
|
textY = y - oby + hIndex
|
||||||
@@ -3871,8 +3878,15 @@ local function Frame(name, parent)
|
|||||||
local objZIndex = {}
|
local objZIndex = {}
|
||||||
local object = {}
|
local object = {}
|
||||||
local focusedObject
|
local focusedObject
|
||||||
|
local termObject = parentTerminal
|
||||||
|
|
||||||
|
local monitors = {}
|
||||||
|
local isMonitor = false
|
||||||
|
|
||||||
base:setZIndex(10)
|
base:setZIndex(10)
|
||||||
|
|
||||||
|
local drawHelper = basaltDrawHelper(termObject)
|
||||||
|
|
||||||
local cursorBlink = false
|
local cursorBlink = false
|
||||||
local xCursor = 1
|
local xCursor = 1
|
||||||
local yCursor = 1
|
local yCursor = 1
|
||||||
@@ -3886,8 +3900,7 @@ local function Frame(name, parent)
|
|||||||
base.bgColor = theme.FrameBG
|
base.bgColor = theme.FrameBG
|
||||||
base.fgColor = theme.FrameFG
|
base.fgColor = theme.FrameFG
|
||||||
else
|
else
|
||||||
local termW, termH = parentTerminal.getSize()
|
base.width, base.height = termObject.getSize()
|
||||||
base.width, base.height = termW, termH
|
|
||||||
base.bgColor = theme.basaltBG
|
base.bgColor = theme.basaltBG
|
||||||
base.fgColor = theme.basaltFG
|
base.fgColor = theme.basaltFG
|
||||||
end
|
end
|
||||||
@@ -3994,7 +4007,7 @@ local function Frame(name, parent)
|
|||||||
|
|
||||||
show = function(self)
|
show = function(self)
|
||||||
base:show()
|
base:show()
|
||||||
if (self.parent == nil) then
|
if (self.parent == nil)and not(isMonitor) then
|
||||||
activeFrame = self
|
activeFrame = self
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -4021,6 +4034,29 @@ local function Frame(name, parent)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
addMonitor = function(self, mon)
|
||||||
|
local screen = peripheral.wrap(mon)
|
||||||
|
monitors[mon] = {monitor=mon, frame=basalt.createFrame(self:getName().."_monitor_"..mon)}
|
||||||
|
monitors[mon].frame:setDisplay(screen):setFrameAsMonitor()
|
||||||
|
monitors[mon].frame:setSize(screen:getSize())
|
||||||
|
return monitors[mon].frame
|
||||||
|
end;
|
||||||
|
|
||||||
|
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
|
||||||
|
return self, isMonitor
|
||||||
|
end;
|
||||||
|
|
||||||
|
setFrameAsMonitor = function(self, isMon)
|
||||||
|
isMonitor = isMon or true
|
||||||
|
return self
|
||||||
|
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()
|
||||||
@@ -4041,6 +4077,16 @@ local function Frame(name, parent)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
setDisplay = function(self, drawTerm)
|
||||||
|
termObject = drawTerm
|
||||||
|
drawHelper = basaltDrawHelper(termObject)
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
|
getDisplay = function(self)
|
||||||
|
return termObject
|
||||||
|
end;
|
||||||
|
|
||||||
getVisualChanged = function(self)
|
getVisualChanged = function(self)
|
||||||
local changed = base.getVisualChanged(self)
|
local changed = base.getVisualChanged(self)
|
||||||
for _, index in pairs(objZIndex) do
|
for _, index in pairs(objZIndex) do
|
||||||
@@ -4103,8 +4149,8 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (event == "terminate") then
|
if (event == "terminate") then
|
||||||
parentTerminal.clear()
|
termObject.clear()
|
||||||
parentTerminal.setCursorPos(1, 1)
|
termObject.setCursorPos(1, 1)
|
||||||
basalt.stop()
|
basalt.stop()
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
@@ -4130,16 +4176,24 @@ local function Frame(name, parent)
|
|||||||
|
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(self, event, button, x, y)) then
|
||||||
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
for _, index in pairs(objZIndex) do
|
if(event~="monitor_touch") or (isMonitor)then
|
||||||
if (objects[index] ~= nil) then
|
for _, index in pairs(objZIndex) do
|
||||||
for _, value in rpairs(objects[index]) do
|
if (objects[index] ~= nil) then
|
||||||
if (value.mouseClickHandler ~= nil) then
|
for _, value in rpairs(objects[index]) do
|
||||||
if (value:mouseClickHandler(event, button, x + xO, y + yO)) then
|
if (value.mouseClickHandler ~= nil) then
|
||||||
return true
|
if (value:mouseClickHandler(event, button, x + xO, y + yO)) then
|
||||||
|
return true
|
||||||
|
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
|
end
|
||||||
|
|
||||||
if (self.isMoveable) then
|
if (self.isMoveable) then
|
||||||
@@ -4268,16 +4322,20 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (cursorBlink) then
|
if (cursorBlink) then
|
||||||
parentTerminal.setTextColor(cursorColor)
|
termObject.setTextColor(cursorColor)
|
||||||
parentTerminal.setCursorPos(xCursor, yCursor)
|
termObject.setCursorPos(xCursor, yCursor)
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
parentTerminal.setCursorBlink(self:isFocused())
|
termObject.setCursorBlink(self:isFocused())
|
||||||
else
|
else
|
||||||
parentTerminal.setCursorBlink(cursorBlink)
|
termObject.setCursorBlink(cursorBlink)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
|
for _,v in pairs(monitors)do
|
||||||
|
v.frame:draw()
|
||||||
|
end
|
||||||
|
drawHelper.update()
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -4419,26 +4477,24 @@ 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 (event == "mouse_click") then
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
||||||
end
|
elseif (event == "mouse_drag") then
|
||||||
if (event == "mouse_drag") then
|
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
||||||
end
|
elseif (event == "mouse_up") then
|
||||||
if (event == "mouse_up") then
|
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
||||||
end
|
elseif (event == "mouse_scroll") then
|
||||||
if (event == "mouse_scroll") then
|
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
||||||
end
|
elseif (event == "monitor_touch") then
|
||||||
if (event == "key") or (event == "char") then
|
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
||||||
|
elseif (event == "key") or (event == "char") then
|
||||||
activeFrame:keyHandler(event, p1)
|
activeFrame:keyHandler(event, p1)
|
||||||
activeFrame:backgroundKeyHandler(event, p1)
|
activeFrame:backgroundKeyHandler(event, p1)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, value in pairs(frames) do
|
for _, value in pairs(frames) do
|
||||||
value:eventHandler(event, p1, p2, p3, p4)
|
value:eventHandler(event, p1, p2, p3, p4)
|
||||||
end
|
end
|
||||||
if (updaterActive) then
|
if (updaterActive) then
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
drawHelper.update()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4446,7 +4502,6 @@ function basalt.autoUpdate(isActive)
|
|||||||
parentTerminal.clear()
|
parentTerminal.clear()
|
||||||
updaterActive = isActive or true
|
updaterActive = isActive or true
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
drawHelper.update()
|
|
||||||
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)
|
||||||
@@ -4458,7 +4513,6 @@ function basalt.update(event, p1, p2, p3, p4)
|
|||||||
basaltUpdateEvent(event, p1, p2, p3, p4)
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
else
|
else
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
drawHelper.update()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4487,8 +4541,7 @@ function basalt.setActiveFrame(frame)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function basalt.createFrame(name)
|
function basalt.createFrame(name)
|
||||||
local frame = Frame(name)
|
return Frame(name)
|
||||||
return frame
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function basalt.removeFrame(name)
|
function basalt.removeFrame(name)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -88,6 +88,36 @@ Toggles the frame's upper bar
|
|||||||
local mainFrame = myFrame:setBar("Hello World!"):showBar()
|
local mainFrame = myFrame:setBar("Hello World!"):showBar()
|
||||||
````
|
````
|
||||||
|
|
||||||
|
## addMonitor
|
||||||
|
adds a monitor to the active main frame.
|
||||||
|
#### Parameters:
|
||||||
|
1. `string` The monitor name ("right", "left",... "monitor_1", "monitor_2",...)
|
||||||
|
#### Returns:
|
||||||
|
1. `frame` returns a frame which you can use like normal frames
|
||||||
|
#### Usage:
|
||||||
|
* Adds a monitor to the mainFrame. Only as long as this frame is also the active Frame, the monitor will be shown.
|
||||||
|
````lua
|
||||||
|
local mainFrame = basalt.createFrame("mainFrame"):show()
|
||||||
|
local monitor1 = mainFrame:addMonitor("right"):show()
|
||||||
|
|
||||||
|
monitor1:setBar("Monitor 1"):showBar()
|
||||||
|
````
|
||||||
|
|
||||||
|
## setMonitorScale
|
||||||
|
changes the monitor scale (almost the same as setTextScale())
|
||||||
|
#### Parameters:
|
||||||
|
1. `number` Possible values are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 (1 is the same as 0.5 by setTextScale, and 10 is the same as 5)
|
||||||
|
#### Returns:
|
||||||
|
1. `monitor` The monitor being used
|
||||||
|
#### Usage:
|
||||||
|
* Changes the monitor scale to 2
|
||||||
|
````lua
|
||||||
|
local mainFrame = basalt.createFrame("mainFrame"):show()
|
||||||
|
local monitor1 = mainFrame:addMonitor("right"):setMonitorScale(2):show()
|
||||||
|
|
||||||
|
monitor1:setBar("Monitor 1"):showBar()
|
||||||
|
````
|
||||||
|
|
||||||
## ~~isModifierActive~~
|
## ~~isModifierActive~~
|
||||||
### _Disabled, this function is a WIP_
|
### _Disabled, this function is a WIP_
|
||||||
Returns true if the user is currently holding the respective key down
|
Returns true if the user is currently holding the respective key down
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local basaltFileName = "basalt.lua"
|
local basaltFileName = "basalt-source.lua"
|
||||||
local absolutePath = "source"
|
local absolutePath = "source"
|
||||||
local basalt = dofile(fs.combine(absolutePath, "packager.lua")) -- path to packager
|
local basalt = dofile(fs.combine(absolutePath, "packager.lua")) -- path to packager
|
||||||
|
|
||||||
local b = fs.open(fs.combine(absolutePath, "basalt.lua"), "w")
|
local b = fs.open(fs.combine(absolutePath, basaltFileName), "w")
|
||||||
b.write(basalt)
|
b.write(basalt)
|
||||||
b.close()
|
b.close()
|
||||||
@@ -6,8 +6,15 @@ local function Frame(name, parent)
|
|||||||
local objZIndex = {}
|
local objZIndex = {}
|
||||||
local object = {}
|
local object = {}
|
||||||
local focusedObject
|
local focusedObject
|
||||||
|
local termObject = parentTerminal
|
||||||
|
|
||||||
|
local monitors = {}
|
||||||
|
local isMonitor = false
|
||||||
|
|
||||||
base:setZIndex(10)
|
base:setZIndex(10)
|
||||||
|
|
||||||
|
local drawHelper = basaltDrawHelper(termObject)
|
||||||
|
|
||||||
local cursorBlink = false
|
local cursorBlink = false
|
||||||
local xCursor = 1
|
local xCursor = 1
|
||||||
local yCursor = 1
|
local yCursor = 1
|
||||||
@@ -21,8 +28,7 @@ local function Frame(name, parent)
|
|||||||
base.bgColor = theme.FrameBG
|
base.bgColor = theme.FrameBG
|
||||||
base.fgColor = theme.FrameFG
|
base.fgColor = theme.FrameFG
|
||||||
else
|
else
|
||||||
local termW, termH = parentTerminal.getSize()
|
base.width, base.height = termObject.getSize()
|
||||||
base.width, base.height = termW, termH
|
|
||||||
base.bgColor = theme.basaltBG
|
base.bgColor = theme.basaltBG
|
||||||
base.fgColor = theme.basaltFG
|
base.fgColor = theme.basaltFG
|
||||||
end
|
end
|
||||||
@@ -129,7 +135,7 @@ local function Frame(name, parent)
|
|||||||
|
|
||||||
show = function(self)
|
show = function(self)
|
||||||
base:show()
|
base:show()
|
||||||
if (self.parent == nil) then
|
if (self.parent == nil)and not(isMonitor) then
|
||||||
activeFrame = self
|
activeFrame = self
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -156,6 +162,29 @@ local function Frame(name, parent)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
addMonitor = function(self, mon)
|
||||||
|
local screen = peripheral.wrap(mon)
|
||||||
|
monitors[mon] = {monitor=mon, frame=basalt.createFrame(self:getName().."_monitor_"..mon)}
|
||||||
|
monitors[mon].frame:setDisplay(screen):setFrameAsMonitor()
|
||||||
|
monitors[mon].frame:setSize(screen:getSize())
|
||||||
|
return monitors[mon].frame
|
||||||
|
end;
|
||||||
|
|
||||||
|
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
|
||||||
|
return self, isMonitor
|
||||||
|
end;
|
||||||
|
|
||||||
|
setFrameAsMonitor = function(self, isMon)
|
||||||
|
isMonitor = isMon or true
|
||||||
|
return self
|
||||||
|
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()
|
||||||
@@ -176,6 +205,16 @@ local function Frame(name, parent)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
setDisplay = function(self, drawTerm)
|
||||||
|
termObject = drawTerm
|
||||||
|
drawHelper = basaltDrawHelper(termObject)
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
|
getDisplay = function(self)
|
||||||
|
return termObject
|
||||||
|
end;
|
||||||
|
|
||||||
getVisualChanged = function(self)
|
getVisualChanged = function(self)
|
||||||
local changed = base.getVisualChanged(self)
|
local changed = base.getVisualChanged(self)
|
||||||
for _, index in pairs(objZIndex) do
|
for _, index in pairs(objZIndex) do
|
||||||
@@ -238,8 +277,8 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (event == "terminate") then
|
if (event == "terminate") then
|
||||||
parentTerminal.clear()
|
termObject.clear()
|
||||||
parentTerminal.setCursorPos(1, 1)
|
termObject.setCursorPos(1, 1)
|
||||||
basalt.stop()
|
basalt.stop()
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
@@ -265,16 +304,24 @@ local function Frame(name, parent)
|
|||||||
|
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(self, event, button, x, y)) then
|
||||||
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
local fx, fy = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
for _, index in pairs(objZIndex) do
|
if(event~="monitor_touch") or (isMonitor)then
|
||||||
if (objects[index] ~= nil) then
|
for _, index in pairs(objZIndex) do
|
||||||
for _, value in rpairs(objects[index]) do
|
if (objects[index] ~= nil) then
|
||||||
if (value.mouseClickHandler ~= nil) then
|
for _, value in rpairs(objects[index]) do
|
||||||
if (value:mouseClickHandler(event, button, x + xO, y + yO)) then
|
if (value.mouseClickHandler ~= nil) then
|
||||||
return true
|
if (value:mouseClickHandler(event, button, x + xO, y + yO)) then
|
||||||
|
return true
|
||||||
|
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
|
end
|
||||||
|
|
||||||
if (self.isMoveable) then
|
if (self.isMoveable) then
|
||||||
@@ -403,16 +450,20 @@ local function Frame(name, parent)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (cursorBlink) then
|
if (cursorBlink) then
|
||||||
parentTerminal.setTextColor(cursorColor)
|
termObject.setTextColor(cursorColor)
|
||||||
parentTerminal.setCursorPos(xCursor, yCursor)
|
termObject.setCursorPos(xCursor, yCursor)
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
parentTerminal.setCursorBlink(self:isFocused())
|
termObject.setCursorBlink(self:isFocused())
|
||||||
else
|
else
|
||||||
parentTerminal.setCursorBlink(cursorBlink)
|
termObject.setCursorBlink(cursorBlink)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:setVisualChanged(false)
|
self:setVisualChanged(false)
|
||||||
end
|
end
|
||||||
|
for _,v in pairs(monitors)do
|
||||||
|
v.frame:draw()
|
||||||
|
end
|
||||||
|
drawHelper.update()
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -123,9 +123,9 @@ local function Object(name)
|
|||||||
|
|
||||||
setPosition = function(self, xPos, yPos, rel)
|
setPosition = function(self, xPos, yPos, rel)
|
||||||
if (rel) then
|
if (rel) then
|
||||||
self.x, self.y = self.x + xPos, self.y + yPos
|
self.x, self.y = math.floor(self.x + xPos), math.floor(self.y + yPos)
|
||||||
else
|
else
|
||||||
self.x, self.y = xPos, yPos
|
self.x, self.y = math.floor(xPos), math.floor(yPos)
|
||||||
end
|
end
|
||||||
visualsChanged = true
|
visualsChanged = true
|
||||||
return self
|
return self
|
||||||
@@ -264,6 +264,7 @@ local function Object(name)
|
|||||||
|
|
||||||
onClick = function(self, func)
|
onClick = function(self, func)
|
||||||
self:registerEvent("mouse_click", func)
|
self:registerEvent("mouse_click", func)
|
||||||
|
self:registerEvent("monitor_touch", func)
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ generateFontSize(3,false)
|
|||||||
|
|
||||||
local function makeText(nSize, sString, nFC, nBC, bBlit)
|
local function makeText(nSize, sString, nFC, nBC, bBlit)
|
||||||
if not type(sString) == "string" then error("Not a String",3) end --this should never happend with expects in place.
|
if not type(sString) == "string" then error("Not a String",3) end --this should never happend with expects in place.
|
||||||
print(tHex, nFC)
|
|
||||||
local cFC = type(nFC) == "string" and nFC:sub(1, 1) or tHex[nFC] or error("Wrong Front Color",3)
|
local cFC = type(nFC) == "string" and nFC:sub(1, 1) or tHex[nFC] or error("Wrong Front Color",3)
|
||||||
local cBC = type(nBC) == "string" and nBC:sub(1, 1) or tHex[nBC] or error("Wrong Back Color",3)
|
local cBC = type(nBC) == "string" and nBC:sub(1, 1) or tHex[nBC] or error("Wrong Back Color",3)
|
||||||
local font = fonts[nSize] or error("Wrong font size selected",3)
|
local font = fonts[nSize] or error("Wrong font size selected",3)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local function basaltDrawHelper()
|
local function basaltDrawHelper(drawTerm)
|
||||||
local terminal = parentTerminal
|
local terminal = drawTerm
|
||||||
local width, height = terminal.getSize()
|
local width, height = terminal.getSize()
|
||||||
local cacheT = {}
|
local cacheT = {}
|
||||||
local cacheBG = {}
|
local cacheBG = {}
|
||||||
@@ -179,4 +179,3 @@ local function basaltDrawHelper()
|
|||||||
}
|
}
|
||||||
return drawHelper
|
return drawHelper
|
||||||
end
|
end
|
||||||
local drawHelper = basaltDrawHelper()
|
|
||||||
@@ -2,26 +2,24 @@ 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 (event == "mouse_click") then
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
||||||
end
|
elseif (event == "mouse_drag") then
|
||||||
if (event == "mouse_drag") then
|
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
||||||
end
|
elseif (event == "mouse_up") then
|
||||||
if (event == "mouse_up") then
|
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
||||||
end
|
elseif (event == "mouse_scroll") then
|
||||||
if (event == "mouse_scroll") then
|
|
||||||
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
||||||
end
|
elseif (event == "monitor_touch") then
|
||||||
if (event == "key") or (event == "char") then
|
activeFrame:mouseClickHandler(event, p1, p2, p3, p4)
|
||||||
|
elseif (event == "key") or (event == "char") then
|
||||||
activeFrame:keyHandler(event, p1)
|
activeFrame:keyHandler(event, p1)
|
||||||
activeFrame:backgroundKeyHandler(event, p1)
|
activeFrame:backgroundKeyHandler(event, p1)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, value in pairs(frames) do
|
for _, value in pairs(frames) do
|
||||||
value:eventHandler(event, p1, p2, p3, p4)
|
value:eventHandler(event, p1, p2, p3, p4)
|
||||||
end
|
end
|
||||||
if (updaterActive) then
|
if (updaterActive) then
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
drawHelper.update()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -29,7 +27,6 @@ function basalt.autoUpdate(isActive)
|
|||||||
parentTerminal.clear()
|
parentTerminal.clear()
|
||||||
updaterActive = isActive or true
|
updaterActive = isActive or true
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
drawHelper.update()
|
|
||||||
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)
|
||||||
@@ -41,7 +38,6 @@ function basalt.update(event, p1, p2, p3, p4)
|
|||||||
basaltUpdateEvent(event, p1, p2, p3, p4)
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
else
|
else
|
||||||
activeFrame:draw()
|
activeFrame:draw()
|
||||||
drawHelper.update()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -70,8 +66,7 @@ function basalt.setActiveFrame(frame)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function basalt.createFrame(name)
|
function basalt.createFrame(name)
|
||||||
local frame = Frame(name)
|
return Frame(name)
|
||||||
return frame
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function basalt.removeFrame(name)
|
function basalt.removeFrame(name)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ local function Checkbox(name)
|
|||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(self, event, button, x, y)) then
|
||||||
if (event == "mouse_click") and (button == 1) 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)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ local function Dropdown(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getAll = function(self)
|
||||||
|
return list
|
||||||
|
end;
|
||||||
|
|
||||||
removeItem = function(self, index)
|
removeItem = function(self, index)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
return self
|
return self
|
||||||
@@ -93,16 +97,14 @@ local function Dropdown(name)
|
|||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (state == 2) then
|
if (state == 2) then
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (event == "mouse_click") then
|
if ((event == "mouse_click") and (button == 1)) or (event == "monitor_touch") then
|
||||||
-- remove mouse_drag if i want to make objects moveable uwuwuwuw
|
|
||||||
if (button == 1) then
|
if (#list > 0) then
|
||||||
if (#list > 0) then
|
for n = 1, dropdownH do
|
||||||
for n = 1, dropdownH do
|
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])
|
return true
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ local function Label(name)
|
|||||||
base.fgColor = colors.white
|
base.fgColor = colors.white
|
||||||
base.bgcolor = colors.black
|
base.bgcolor = colors.black
|
||||||
|
|
||||||
local autoWidth = true
|
local autoSize = true
|
||||||
base:setValue("")
|
base:setValue("")
|
||||||
|
|
||||||
local textHorizontalAlign = "left"
|
local textHorizontalAlign = "left"
|
||||||
@@ -21,7 +21,7 @@ local function Label(name)
|
|||||||
setText = function(self, text)
|
setText = function(self, text)
|
||||||
text = tostring(text)
|
text = tostring(text)
|
||||||
base:setValue(text)
|
base:setValue(text)
|
||||||
if (autoWidth) then
|
if (autoSize) then
|
||||||
self.width = text:len()
|
self.width = text:len()
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
@@ -47,7 +47,7 @@ local function Label(name)
|
|||||||
|
|
||||||
setSize = function(self, width, height)
|
setSize = function(self, width, height)
|
||||||
base.setSize(self, width, height)
|
base.setSize(self, width, height)
|
||||||
autoWidth = false
|
autoSize = false
|
||||||
self:setVisualChanged()
|
self:setVisualChanged()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
@@ -68,6 +68,10 @@ local function Label(name)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
local tData = makeText(fontsize, self:getValue(), self.fgColor, self.bgColor)
|
local tData = makeText(fontsize, self:getValue(), self.fgColor, self.bgColor)
|
||||||
|
if(autoSize)then
|
||||||
|
self.height = #tData[1]-1
|
||||||
|
self.width = #tData[1][1]
|
||||||
|
end
|
||||||
for n = 1, self.height do
|
for n = 1, self.height do
|
||||||
if (n == verticalAlign) then
|
if (n == verticalAlign) then
|
||||||
local oX, oY = self.parent:getSize()
|
local oX, oY = self.parent:getSize()
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ local function List(name)
|
|||||||
return list[index]
|
return list[index]
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getAll = function(self)
|
||||||
|
return list
|
||||||
|
end;
|
||||||
|
|
||||||
getItemIndex = function(self)
|
getItemIndex = function(self)
|
||||||
local selected = self:getValue()
|
local selected = self:getValue()
|
||||||
for key, value in pairs(list) do
|
for key, value in pairs(list) do
|
||||||
@@ -91,16 +95,13 @@ local function List(name)
|
|||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = 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") then
|
if (((event == "mouse_click") or (event == "mouse_drag"))and(button==1))or(event=="monitor_touch") then
|
||||||
-- remove mouse_drag if i want to make objects moveable uwuwuwuw
|
if (#list > 0) then
|
||||||
if (button == 1) then
|
for n = 1, self.height do
|
||||||
if (#list > 0) then
|
if (list[n + yOffset] ~= nil) then
|
||||||
for n = 1, self.height do
|
if (obx <= x) and (obx + self.width > x) and (oby + n - 1 == y) then
|
||||||
if (list[n + yOffset] ~= nil) then
|
self:setValue(list[n + yOffset])
|
||||||
if (obx <= x) and (obx + self.width > x) and (oby + n - 1 == y) then
|
self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", 0, x, y, list[n + yOffset])
|
||||||
self:setValue(list[n + yOffset])
|
|
||||||
self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", 0, x, y, list[n + yOffset])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ local function Menubar(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getAll = function(self)
|
||||||
|
return list
|
||||||
|
end;
|
||||||
|
|
||||||
getItemIndex = function(self)
|
getItemIndex = function(self)
|
||||||
local selected = self:getValue()
|
local selected = self:getValue()
|
||||||
for key, value in pairs(list) do
|
for key, value in pairs(list) do
|
||||||
@@ -119,7 +123,7 @@ local function Menubar(name)
|
|||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
self.parent:setFocusedObject(self)
|
self.parent:setFocusedObject(self)
|
||||||
end
|
end
|
||||||
if (event == "mouse_click") then
|
if (event == "mouse_click") or (event == "monitor_touch") then
|
||||||
local xPos = 1
|
local xPos = 1
|
||||||
for n = 1 + itemOffset, #list do
|
for n = 1 + itemOffset, #list do
|
||||||
if (list[n] ~= nil) then
|
if (list[n] ~= nil) then
|
||||||
|
|||||||
@@ -601,7 +601,7 @@ local function Program(name)
|
|||||||
end
|
end
|
||||||
if not (curProcess:isDead()) then
|
if not (curProcess:isDead()) then
|
||||||
if not (paused) then
|
if not (paused) then
|
||||||
if (event ~= "mouse_click") and (event ~= "mouse_up") and (event ~= "mouse_scroll") and (event ~= "mouse_drag") and (event ~= "key_up") and (event ~= "key") and (event ~= "char") and (event ~= "terminate") then
|
if (event ~= "mouse_click") and (event ~= "monitor_touch") and (event ~= "mouse_up") and (event ~= "mouse_scroll") and (event ~= "mouse_drag") and (event ~= "key_up") and (event ~= "key") and (event ~= "char") and (event ~= "terminate") then
|
||||||
curProcess:resume(event, p1, p2, p3, p4)
|
curProcess:resume(event, p1, p2, p3, p4)
|
||||||
end
|
end
|
||||||
if (self:isFocused()) then
|
if (self:isFocused()) then
|
||||||
@@ -618,7 +618,7 @@ local function Program(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (event ~= "mouse_click") and (event ~= "mouse_up") and (event ~= "mouse_scroll") and (event ~= "mouse_drag") and (event ~= "key_up") and (event ~= "key") and (event ~= "char") and (event ~= "terminate") then
|
if (event ~= "mouse_click") and (event ~= "monitor_touch") and (event ~= "mouse_up") and (event ~= "mouse_scroll") and (event ~= "mouse_drag") and (event ~= "key_up") and (event ~= "key") and (event ~= "char") and (event ~= "terminate") then
|
||||||
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } })
|
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ local function Radio(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
getAll = function(self)
|
||||||
|
return list
|
||||||
|
end;
|
||||||
|
|
||||||
removeItem = function(self, index)
|
removeItem = function(self, index)
|
||||||
table.remove(list, index)
|
table.remove(list, index)
|
||||||
return self
|
return self
|
||||||
@@ -78,20 +82,17 @@ local function Radio(name)
|
|||||||
|
|
||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
|
||||||
if (event == "mouse_click") then
|
if ((event == "mouse_click")and(button==1))or(event=="monitor_touch") then
|
||||||
-- remove mouse_drag if i want to make objects moveable uwuwuwuw
|
if (#list > 0) then
|
||||||
if (button == 1) then
|
for _, value in pairs(list) do
|
||||||
if (#list > 0) then
|
if (obx + value.x - 1 <= x) and (obx + value.x - 1 + value.text:len() + 2 >= x) and (oby + value.y - 1 == y) then
|
||||||
for _, value in pairs(list) do
|
self:setValue(value)
|
||||||
if (obx + value.x - 1 <= x) and (obx + value.x - 1 + value.text:len() + 2 >= x) and (oby + value.y - 1 == y) then
|
if (self.parent ~= nil) then
|
||||||
self:setValue(value)
|
self.parent:setFocusedObject(self)
|
||||||
if (self.parent ~= nil) then
|
|
||||||
self.parent:setFocusedObject(self)
|
|
||||||
end
|
|
||||||
--eventSystem:sendEvent(event, self, event, button, x, y)
|
|
||||||
self:setVisualChanged()
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
--eventSystem:sendEvent(event, self, event, button, x, y)
|
||||||
|
self:setVisualChanged()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ local function Scrollbar(name)
|
|||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(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) 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
|
||||||
for _index = 0, self.width do
|
for _index = 0, self.width do
|
||||||
if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then
|
if (obx + _index == x) and (oby <= y) and (oby + self.height > y) then
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ local function Switch(name)
|
|||||||
mouseClickHandler = function(self, event, button, x, y)
|
mouseClickHandler = function(self, event, button, x, y)
|
||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(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) then
|
if (((event == "mouse_click") or (event == "mouse_drag")) and (button == 1))or(event=="monitor_touch") then
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ local function Textfield(name)
|
|||||||
if (base.mouseClickHandler(self, event, button, x, y)) then
|
if (base.mouseClickHandler(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") then
|
if (event == "mouse_click")or(event=="monitor_touch") then
|
||||||
if (lines[y - oby + hIndex] ~= nil) then
|
if (lines[y - oby + hIndex] ~= nil) then
|
||||||
textX = x - obx + wIndex
|
textX = x - obx + wIndex
|
||||||
textY = y - oby + hIndex
|
textY = y - oby + hIndex
|
||||||
|
|||||||
Reference in New Issue
Block a user