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.basaltProgram=true
|
||||
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))
|
||||
if(fs.exists(pPath))then
|
||||
local file = fs.open(pPath, "r")
|
||||
|
||||
@@ -653,6 +653,30 @@ return function(name, basalt)
|
||||
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)
|
||||
base.draw(self)
|
||||
self:addDraw("program", function()
|
||||
@@ -660,7 +684,6 @@ return function(name, basalt)
|
||||
local obx, oby = self:getPosition()
|
||||
local xCur, yCur = pWindow.getCursorPos()
|
||||
local w,h = self:getSize()
|
||||
pWindow.basalt_reposition(obx, oby)
|
||||
pWindow.basalt_update()
|
||||
end)
|
||||
end,
|
||||
|
||||
@@ -120,7 +120,7 @@ return function(name, basalt)
|
||||
end,
|
||||
|
||||
setPosition = function(self, xPos, yPos, rel)
|
||||
local curX, curY
|
||||
local curX, curY = x, y
|
||||
if(type(xPos)=="number")then
|
||||
x = rel and x+xPos or xPos
|
||||
end
|
||||
@@ -130,6 +130,7 @@ return function(name, basalt)
|
||||
if(parent~=nil)then parent:customEventHandler("basalt_FrameReposition", self) end
|
||||
if(self:getType()=="Container")then parent:customEventHandler("basalt_FrameReposition", self) end
|
||||
self:updateDraw()
|
||||
self:repositionHandler(curX, curY)
|
||||
return self
|
||||
end,
|
||||
|
||||
@@ -146,6 +147,7 @@ return function(name, basalt)
|
||||
end,
|
||||
|
||||
setSize = function(self, newWidth, newHeight, rel)
|
||||
local oldW, oldH = width, height
|
||||
if(type(newWidth)=="number")then
|
||||
width = rel and width+newWidth or newWidth
|
||||
end
|
||||
@@ -156,6 +158,7 @@ return function(name, basalt)
|
||||
parent:customEventHandler("basalt_FrameResize", self)
|
||||
if(self:getType()=="Container")then parent:customEventHandler("basalt_FrameResize", self) end
|
||||
end
|
||||
self:resizeHandler(oldW, oldH)
|
||||
self:updateDraw()
|
||||
return self
|
||||
end,
|
||||
@@ -253,6 +256,22 @@ return function(name, basalt)
|
||||
return true
|
||||
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, ...)
|
||||
for _,v in pairs(table.pack(...))do
|
||||
if(type(v)=="function")then
|
||||
|
||||
Reference in New Issue
Block a user