겁나 멍청했던 extend 버그를 고쳤습니다
This commit is contained in:
parent
0c5831286e
commit
6110938d1e
2 changed files with 37 additions and 19 deletions
|
|
@ -225,7 +225,7 @@ function module.init(shared)
|
||||||
elseif classOfClassName == "table" then -- if classname is a calss what is included new function, call it for making new object (object)
|
elseif classOfClassName == "table" then -- if classname is a calss what is included new function, call it for making new object (object)
|
||||||
local func = ClassName.new or ClassName.New or ClassName.__new
|
local func = ClassName.new or ClassName.New or ClassName.__new
|
||||||
if ClassName.__noSetup then -- if is support initing props
|
if ClassName.__noSetup then -- if is support initing props
|
||||||
local childs,props,parsed,binds,links,processed = {},pack(...),{},{},{},{}
|
local childs,props,parsed,binds,links,processed,styles = {},pack(...),{},{},{},{},{}
|
||||||
for iprop = props.n,1,-1 do
|
for iprop = props.n,1,-1 do
|
||||||
local prop = props[iprop]
|
local prop = props[iprop]
|
||||||
if prop then
|
if prop then
|
||||||
|
|
@ -236,14 +236,7 @@ function module.init(shared)
|
||||||
elseif quadType == "quad_linker" then
|
elseif quadType == "quad_linker" then
|
||||||
links[i] = v
|
links[i] = v
|
||||||
elseif quadType == "quad_style" then
|
elseif quadType == "quad_style" then
|
||||||
for _,thisStyle in ipairs(parseStyles(v)) do
|
insert(styles,v)
|
||||||
for styleIndex,styleValue in pairs(thisStyle) do
|
|
||||||
if not processed[styleIndex] then
|
|
||||||
processed[styleIndex] = true
|
|
||||||
parsed[styleIndex] = styleValue
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif type(i) == "number" then
|
elseif type(i) == "number" then
|
||||||
insert(childs,(iprop == 1) and v or v:Clone())
|
insert(childs,(iprop == 1) and v or v:Clone())
|
||||||
else
|
else
|
||||||
|
|
@ -253,6 +246,16 @@ function module.init(shared)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for _,v in ipairs(styles) do
|
||||||
|
for _,thisStyle in ipairs(parseStyles(v)) do
|
||||||
|
for styleIndex,styleValue in pairs(thisStyle) do
|
||||||
|
if not processed[styleIndex] then
|
||||||
|
processed[styleIndex] = true
|
||||||
|
parsed[styleIndex] = styleValue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
item = func(parsed)
|
item = func(parsed)
|
||||||
local holder = getHolder(item)
|
local holder = getHolder(item)
|
||||||
for _,v in ipairs(childs) do
|
for _,v in ipairs(childs) do
|
||||||
|
|
@ -366,7 +369,6 @@ function module.init(shared)
|
||||||
local self = {
|
local self = {
|
||||||
__prop = prop;
|
__prop = prop;
|
||||||
__parent = parent;
|
__parent = parent;
|
||||||
__propertyChangedSignals = {};
|
|
||||||
ChildAdded = signal.Bindable.New();
|
ChildAdded = signal.Bindable.New();
|
||||||
}
|
}
|
||||||
local init = this.Init
|
local init = this.Init
|
||||||
|
|
@ -374,7 +376,7 @@ function module.init(shared)
|
||||||
init(self,prop)
|
init(self,prop)
|
||||||
end
|
end
|
||||||
setmetatable(self,this)
|
setmetatable(self,this)
|
||||||
initStoreRegisterBinding(prop,this)
|
initStoreRegisterBinding(prop,self,self)
|
||||||
|
|
||||||
-- render that
|
-- render that
|
||||||
local object = self:Render(prop)
|
local object = self:Render(prop)
|
||||||
|
|
@ -399,17 +401,28 @@ function module.init(shared)
|
||||||
end
|
end
|
||||||
|
|
||||||
function this:GetPropertyChangedSignal(propertyName)
|
function this:GetPropertyChangedSignal(propertyName)
|
||||||
local thisSignal = self.__propertyChangedSignals[propertyName]
|
local propertySignalList = rawget(self,"__propertyChangedSignals")
|
||||||
|
if not propertySignalList then
|
||||||
|
propertySignalList = {}
|
||||||
|
rawset(self,"__propertyChangedSignals",propertySignalList)
|
||||||
|
end
|
||||||
|
|
||||||
|
local thisSignal = propertySignalList[propertyName]
|
||||||
if thisSignal then
|
if thisSignal then
|
||||||
return thisSignal
|
return thisSignal
|
||||||
end
|
end
|
||||||
thisSignal = bindable.New()
|
thisSignal = bindable.New()
|
||||||
self.__propertyChangedSignals[propertyName] = thisSignal
|
propertySignalList[propertyName] = thisSignal
|
||||||
return thisSignal
|
return thisSignal
|
||||||
end
|
end
|
||||||
|
|
||||||
function this:EmitPropertyChangedSignal(propertyName,value)
|
function this:EmitPropertyChangedSignal(propertyName,value)
|
||||||
local thisSignal = self.__propertyChangedSignals[propertyName]
|
local propertySignalList = rawget(self,"__propertyChangedSignals")
|
||||||
|
if not propertySignalList then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local thisSignal = propertySignalList[propertyName]
|
||||||
if not thisSignal then
|
if not thisSignal then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -531,18 +544,19 @@ function module.init(shared)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- is private (self value)
|
-- is private (self value)
|
||||||
if k == "holder" or k:sub(1,1) == "_" then
|
if k:sub(1,1) == "_" then
|
||||||
return rawset(self,k,v)
|
return rawset(self,k,v)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- prop update
|
-- prop update
|
||||||
|
local lastValue = self[k]
|
||||||
self.__prop[k] = v
|
self.__prop[k] = v
|
||||||
if this.UpdateTriggers[k] then
|
if this.UpdateTriggers[k] then
|
||||||
self:Update()
|
self:Update()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- call PropertyChangedSignal
|
-- call PropertyChangedSignal
|
||||||
if self.__propertyChangedSignals[k] and self[k] ~= v then
|
if lastValue ~= v then
|
||||||
self:EmitPropertyChangedSignal(k,v)
|
self:EmitPropertyChangedSignal(k,v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -356,12 +356,12 @@ function module.init(shared)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- init bindings (reflect all changes into class or other store, just wrapping it)
|
-- init bindings (reflect all changes into class or other store, just wrapping it)
|
||||||
function new.__initStoreRegisterBinding(self,withItem)
|
function new.__initStoreRegisterBinding(self,withItem,extend)
|
||||||
local selfTweens = self.__tweens
|
local selfTweens = self.__tweens
|
||||||
local selfValues = self.__self
|
local selfValues = self.__self
|
||||||
local selfKeep = self.__keep
|
local selfKeep = self.__keep
|
||||||
for key,item in pairs(selfValues) do
|
for key,item in pairs(selfValues) do
|
||||||
if type(item) == "table" and item.__type == "quad_register" then
|
if PcallGetProperty(item,"__type") == "quad_register" then
|
||||||
-- fetch data from origin
|
-- fetch data from origin
|
||||||
-- do
|
-- do
|
||||||
-- local tstore = item.store
|
-- local tstore = item.store
|
||||||
|
|
@ -383,8 +383,12 @@ function module.init(shared)
|
||||||
local function regFn(_,newValue,eventKey)
|
local function regFn(_,newValue,eventKey)
|
||||||
-- !HOLD IT SELF TO PREVENT THIS REGISTER BEGIN REMOVED FROM MEMORY
|
-- !HOLD IT SELF TO PREVENT THIS REGISTER BEGIN REMOVED FROM MEMORY
|
||||||
local setValue = item:CalcWithNewValue(withItem,newValue,eventKey)
|
local setValue = item:CalcWithNewValue(withItem,newValue,eventKey)
|
||||||
|
if extend then
|
||||||
|
extend[key] = setValue
|
||||||
|
else
|
||||||
self[key] = setValue
|
self[key] = setValue
|
||||||
end
|
end
|
||||||
|
end
|
||||||
item:Register(regFn)
|
item:Register(regFn)
|
||||||
insert(selfKeep,{func=regFn,register=item,key=key})
|
insert(selfKeep,{func=regFn,register=item,key=key})
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue