diff options
| author | ruki <[email protected]> | 2020-05-07 22:45:25 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-07 10:32:31 +0800 |
| commit | ca238c29d3e14b0c72787b47588b979356dd9410 (patch) | |
| tree | accec9b30f7b057b9bfbf9cf9e5985d5060232db /xmake/core/ui/window.lua | |
| parent | 5d22635894f2b19f49441e0671ac0eb1b1da9c17 (diff) | |
update ui
Diffstat (limited to 'xmake/core/ui/window.lua')
| -rw-r--r-- | xmake/core/ui/window.lua | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/xmake/core/ui/window.lua b/xmake/core/ui/window.lua index 7b30a15d2..81aac83c0 100644 --- a/xmake/core/ui/window.lua +++ b/xmake/core/ui/window.lua @@ -43,6 +43,7 @@ function window:init(name, bounds, title, shadow) -- insert shadow if shadow then + self._SHADOW = view:new("window.shadow", rect{2, 1, self:width(), self:height()}):background_set("black") self:insert(self:shadow()) self:frame():bounds():movee(-2, -1) self:frame():invalidate(true) @@ -98,9 +99,6 @@ end -- get shadow function window:shadow() - if not self._SHADOW then - self._SHADOW = view:new("window.shadow", rect{2, 1, self:width(), self:height()}):background_set("black") - end return self._SHADOW end @@ -113,7 +111,7 @@ function window:border() end -- on event -function window:event_on(e) +function window:on_event(e) -- select panel? if e.type == event.ev_keyboard then @@ -123,5 +121,21 @@ function window:event_on(e) end end +-- on resize +function window:on_resize() + self:frame():bounds_set(rect{0, 0, self:width(), self:height()}) + if self:shadow() then + self:shadow():bounds_set(rect{2, 1, self:width(), self:height()}) + self:frame():bounds():movee(-2, -1) + end + self:border():bounds_set(self:frame():bounds()) + if self:title() then + self:frame():center(self:title(), {centerx = true}) + end + self:panel():bounds_set(self:frame():bounds()) + self:panel():bounds():grow(-1, -1) + panel.on_resize(self) +end + -- return module return window |
