Small fixes
- Fixed basalt_resize and basalt_reposition event - Fixed program not changing the size of the internal window object
This commit is contained in:
@@ -18,6 +18,9 @@ function process:new(path, window, newEnv, ...)
|
|||||||
env.shell = shell
|
env.shell = shell
|
||||||
env.basaltProgram=true
|
env.basaltProgram=true
|
||||||
env.arg = {[0]=path, table.unpack(args)}
|
env.arg = {[0]=path, table.unpack(args)}
|
||||||
|
if(pPath==nil)then
|
||||||
|
error("The path "..path.." does not exist!")
|
||||||
|
end
|
||||||
env.require, env.package = newPackage(env, fs.getDir(pPath))
|
env.require, env.package = newPackage(env, fs.getDir(pPath))
|
||||||
if(fs.exists(pPath))then
|
if(fs.exists(pPath))then
|
||||||
local file = fs.open(pPath, "r")
|
local file = fs.open(pPath, "r")
|
||||||
|
|||||||
@@ -653,6 +653,30 @@ return function(name, basalt)
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
resizeHandler = function(self, ...)
|
||||||
|
base.resizeHandler(self, ...)
|
||||||
|
if (curProcess ~= nil) then
|
||||||
|
if not (curProcess:isDead()) then
|
||||||
|
if not (paused) then
|
||||||
|
pWindow.basalt_resize(self:getSize())
|
||||||
|
resumeProcess(self, "term_resize", self:getSize())
|
||||||
|
else
|
||||||
|
pWindow.basalt_resize(self:getSize())
|
||||||
|
table.insert(queuedEvent, { event = "term_resize", args = { self:getSize() } })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
repositionHandler = function(self, ...)
|
||||||
|
base.repositionHandler(self, ...)
|
||||||
|
if (curProcess ~= nil) then
|
||||||
|
if not (curProcess:isDead()) then
|
||||||
|
pWindow.basalt_reposition(self:getPosition())
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
base.draw(self)
|
base.draw(self)
|
||||||
self:addDraw("program", function()
|
self:addDraw("program", function()
|
||||||
@@ -660,7 +684,6 @@ return function(name, basalt)
|
|||||||
local obx, oby = self:getPosition()
|
local obx, oby = self:getPosition()
|
||||||
local xCur, yCur = pWindow.getCursorPos()
|
local xCur, yCur = pWindow.getCursorPos()
|
||||||
local w,h = self:getSize()
|
local w,h = self:getSize()
|
||||||
pWindow.basalt_reposition(obx, oby)
|
|
||||||
pWindow.basalt_update()
|
pWindow.basalt_update()
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ return function(name, basalt)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
setPosition = function(self, xPos, yPos, rel)
|
setPosition = function(self, xPos, yPos, rel)
|
||||||
local curX, curY
|
local curX, curY = x, y
|
||||||
if(type(xPos)=="number")then
|
if(type(xPos)=="number")then
|
||||||
x = rel and x+xPos or xPos
|
x = rel and x+xPos or xPos
|
||||||
end
|
end
|
||||||
@@ -130,6 +130,7 @@ return function(name, basalt)
|
|||||||
if(parent~=nil)then parent:customEventHandler("basalt_FrameReposition", self) end
|
if(parent~=nil)then parent:customEventHandler("basalt_FrameReposition", self) end
|
||||||
if(self:getType()=="Container")then parent:customEventHandler("basalt_FrameReposition", self) end
|
if(self:getType()=="Container")then parent:customEventHandler("basalt_FrameReposition", self) end
|
||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
|
self:repositionHandler(curX, curY)
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -146,6 +147,7 @@ return function(name, basalt)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
setSize = function(self, newWidth, newHeight, rel)
|
setSize = function(self, newWidth, newHeight, rel)
|
||||||
|
local oldW, oldH = width, height
|
||||||
if(type(newWidth)=="number")then
|
if(type(newWidth)=="number")then
|
||||||
width = rel and width+newWidth or newWidth
|
width = rel and width+newWidth or newWidth
|
||||||
end
|
end
|
||||||
@@ -156,6 +158,7 @@ return function(name, basalt)
|
|||||||
parent:customEventHandler("basalt_FrameResize", self)
|
parent:customEventHandler("basalt_FrameResize", self)
|
||||||
if(self:getType()=="Container")then parent:customEventHandler("basalt_FrameResize", self) end
|
if(self:getType()=="Container")then parent:customEventHandler("basalt_FrameResize", self) end
|
||||||
end
|
end
|
||||||
|
self:resizeHandler(oldW, oldH)
|
||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
@@ -253,6 +256,22 @@ return function(name, basalt)
|
|||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
resizeHandler = function(self, ...)
|
||||||
|
if(self:isEnabled())then
|
||||||
|
local val = self:sendEvent("basalt_resize", ...)
|
||||||
|
if(val==false)then return false end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
|
||||||
|
repositionHandler = function(self, ...)
|
||||||
|
if(self:isEnabled())then
|
||||||
|
local val = self:sendEvent("basalt_reposition", ...)
|
||||||
|
if(val==false)then return false end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
|
||||||
onResize = function(self, ...)
|
onResize = function(self, ...)
|
||||||
for _,v in pairs(table.pack(...))do
|
for _,v in pairs(table.pack(...))do
|
||||||
if(type(v)=="function")then
|
if(type(v)=="function")then
|
||||||
|
|||||||
Reference in New Issue
Block a user