fix: stop self.dimen polution for inputcontainers

Without this fix, self.dimen is shared among all inputcontainers
intances, which breaks some of the UI rendering. All widget should
set/initialize their own self.dimen in self:init() method.
pull/1635/head
Qingping Hou 9 years ago
parent cdd17906f6
commit 63e88baf33

@ -13,6 +13,7 @@ local ReaderConfig = InputContainer:new{
}
function ReaderConfig:init()
if not self.dimen then self.dimen = Geom:new{} end
if Device:hasKeyboard() then
self.key_events = {
ShowConfigMenu = { { "AA" }, doc = "show config dialog" },

@ -48,13 +48,12 @@ function InputContainer:_init()
end
end
self.ges_events = new_ges_events
if not self.dimen then
self.dimen = Geom:new{}
end
end
function InputContainer:paintTo(bb, x, y)
if not self.dimen then
self.dimen = self[1]:getSize()
end
self.dimen.x = x
self.dimen.y = y
if self[1] then

@ -7,14 +7,13 @@ WidgetContainer is a container for another Widget
local WidgetContainer = Widget:new()
function WidgetContainer:init()
if not self.dimen then
self.dimen = Geom:new{}
end
if not self.dimen.w then
self.dimen.w = self[1].getSize().w
end
if not self.dimen.h then
self.dimen.h = self[1].getSize().h
if self.dimen then
if not self.dimen.w then
self.dimen.w = self[1].getSize().w
end
if not self.dimen.h then
self.dimen.h = self[1].getSize().h
end
end
end

@ -274,6 +274,7 @@ local TouchMenu = InputContainer:new{
}
function TouchMenu:init()
if not self.dimen then self.dimen = Geom:new{} end
self.show_parent = self.show_parent or self
if not self.close_callback then
self.close_callback = function()

@ -31,8 +31,8 @@ definition.
--]]
function Widget:new(o)
o = self:extend(o)
-- Both o._init and o.init are called on object create. But o._init is used
-- for base widget initialization (basic component used to build other
-- Both o._init and o.init are called on object creation. But o._init is
-- used for base widget initialization (basic component used to build other
-- widgets). While o.init is for higher level widgets, for example Menu
-- Widget
if o._init then o:_init() end

Loading…
Cancel
Save