diff options
| author | ruki <[email protected]> | 2018-01-12 00:39:22 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-11 21:56:13 +0800 |
| commit | b8276d35af753721b99e893d92485c99e2de111f (patch) | |
| tree | 26f3228f129e671622e10e784aaa00ce85239dde /xmake/core/ui/panel.lua | |
| parent | 3d4fcf847c7a7f365f84d4c4064597c66e124d4c (diff) | |
add buttons to dialog
Diffstat (limited to 'xmake/core/ui/panel.lua')
| -rw-r--r-- | xmake/core/ui/panel.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/xmake/core/ui/panel.lua b/xmake/core/ui/panel.lua index d9a6f8c4c..6576c0b24 100644 --- a/xmake/core/ui/panel.lua +++ b/xmake/core/ui/panel.lua @@ -48,6 +48,9 @@ function panel:init(name, bounds) -- init child views self._VIEWS = dlist() + + -- init views cache + self._VIEWS_CACHE = {} end -- get all child views @@ -85,11 +88,17 @@ function panel:current() return self._CURRENT end +-- get view from the given name +function panel:view(name) + return self._VIEWS_CACHE[name] +end + -- insert view function panel:insert(v, opt) -- check assert(not v:parent() or v:parent() == self) + assert(not self:view(v:name()), "%s has been in this panel!", v) -- this view has been inserted into this panel? remove it first if v:parent() == self then @@ -111,6 +120,9 @@ function panel:insert(v, opt) -- insert this view self._VIEWS:push(v) + -- cache this view + self._VIEWS_CACHE[v:name()] = v + -- set it's parent view v:parent_set(self) @@ -131,6 +143,7 @@ function panel:remove(v) -- remove view self._VIEWS:remove(v) + self._VIEWS_CACHE[v:name()] = nil -- select next view if self:current() == v then |
