diff options
| author | ruki <[email protected]> | 2018-01-18 22:35:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-18 09:31:31 +0800 |
| commit | afdb22dcfeb898e051ed360fce04152b861aa3ad (patch) | |
| tree | 5a8f56a1a527b86b282a1bb726fe1c497c6ef04e /xmake/core/ui/panel.lua | |
| parent | 921a48f8332381d30c814419bfa05230155d342c (diff) | |
improve bounds for view
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) |
