diff options
Diffstat (limited to 'xmake/core/ui/panel.lua')
| -rw-r--r-- | xmake/core/ui/panel.lua | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/xmake/core/ui/panel.lua b/xmake/core/ui/panel.lua index 43c71315e..a43bf864b 100644 --- a/xmake/core/ui/panel.lua +++ b/xmake/core/ui/panel.lua @@ -107,15 +107,20 @@ function panel:insert(v, opt) -- center this view if centerx or centery are set local bounds = v:bounds() + local center = false local org = point {bounds.sx, bounds.sy} if opt and opt.centerx then org.x = math.floor((self:width() - v:width()) / 2) + center = true end if opt and opt.centery then org.y = math.floor((self:height() - v:height()) / 2) + center = true + end + if center then + bounds:move(org.x - bounds.sx, org.y - bounds.sy) + v:invalidate(true) end - bounds:move(org.x - bounds.sx, org.y - bounds.sy) - v:bounds_set(bounds) -- insert this view self._VIEWS:push(v) @@ -145,6 +150,9 @@ function panel:remove(v) self._VIEWS:remove(v) self._VIEWS_CACHE[v:name()] = nil + -- clear parent + v:parent_set(nil) + -- select next view if self:current() == v then self:select_next(nil, true) |
