Fix save of MiniWindow positions, issue #163
This commit is contained in:
parent
67c5b31225
commit
8b14a91ed9
|
@ -1,10 +1,35 @@
|
||||||
-- @docclass math
|
-- @docclass math
|
||||||
|
|
||||||
|
local U8 = 2^8
|
||||||
|
local U16 = 2^16
|
||||||
|
local U32 = 2^32
|
||||||
|
local U64 = 2^64
|
||||||
|
|
||||||
function math.round(num, idp)
|
function math.round(num, idp)
|
||||||
local mult = 10^(idp or 0)
|
local mult = 10^(idp or 0)
|
||||||
if num >= 0 then
|
if num >= 0 then
|
||||||
return math.floor(num * mult + 0.5) / mult
|
return math.floor(num * mult + 0.5) / mult
|
||||||
else
|
else
|
||||||
return math.ceil(num * mult - 0.5) / mult
|
return math.ceil(num * mult - 0.5) / mult
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function math.isu8(num)
|
||||||
|
return math.isinteger(num) and num >= 0 and num < U8
|
||||||
|
end
|
||||||
|
|
||||||
|
function math.isu16(num)
|
||||||
|
return math.isinteger(num) and num >= U8 and num < U16
|
||||||
|
end
|
||||||
|
|
||||||
|
function math.isu32(num)
|
||||||
|
return math.isinteger(num) and num >= U16 and num < U32
|
||||||
|
end
|
||||||
|
|
||||||
|
function math.isu64(num)
|
||||||
|
return math.isinteger(num) and num >= U32 and num < U64
|
||||||
|
end
|
||||||
|
|
||||||
|
function math.isinteger(num)
|
||||||
|
return ((type(num) == 'number') and (num == math.floor(num)))
|
||||||
|
end
|
||||||
|
|
|
@ -104,9 +104,8 @@ function UIMiniWindow:setup()
|
||||||
self.miniIndex = selfSettings.index
|
self.miniIndex = selfSettings.index
|
||||||
parent:scheduleInsert(self, selfSettings.index)
|
parent:scheduleInsert(self, selfSettings.index)
|
||||||
elseif selfSettings.position then
|
elseif selfSettings.position then
|
||||||
|
self:setParent(parent, true)
|
||||||
self:setPosition(topoint(selfSettings.position))
|
self:setPosition(topoint(selfSettings.position))
|
||||||
self:setParent(parent)
|
|
||||||
addEvent(function() self:bindRectToParent() end)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -334,9 +333,11 @@ function UIMiniWindow:fitOnParent()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIMiniWindow:setParent(parent)
|
function UIMiniWindow:setParent(parent, dontsave)
|
||||||
UIWidget.setParent(self, parent)
|
UIWidget.setParent(self, parent)
|
||||||
self:saveParent(parent)
|
if not dontsave then
|
||||||
|
self:saveParent(parent)
|
||||||
|
end
|
||||||
self:fitOnParent()
|
self:fitOnParent()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue