summaryrefslogtreecommitdiff
path: root/xmake/core/ui/view.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-12-14 22:56:39 +0800
committerruki <[email protected]>2017-12-14 11:40:00 +0800
commitb4c46182afdf442505f22bbf864ef2811933da49 (patch)
tree92c899970035ac4a40477267c1256e9c032fc9fe /xmake/core/ui/view.lua
parent54a0bf3c8688589708af4cc22bd7bbe8a83365d1 (diff)
improve compiler version
Diffstat (limited to 'xmake/core/ui/view.lua')
-rw-r--r--xmake/core/ui/view.lua42
1 files changed, 38 insertions, 4 deletions
diff --git a/xmake/core/ui/view.lua b/xmake/core/ui/view.lua
index 1e7ef2a71..cc2edce01 100644
--- a/xmake/core/ui/view.lua
+++ b/xmake/core/ui/view.lua
@@ -65,6 +65,17 @@ function view:init(name, bounds)
state.modal = false -- is modal view?
self._STATE = state
+ -- init options
+ local options = object()
+ options.selectable = false -- true if window can be selected
+ options.top_select = false -- if true, selecting window will bring it to front
+ options.pre_event = false -- receive event before focused window
+ options.post_event = false -- receive event after focused window
+ options.centerx = false -- center horizontaly when inserting in parent
+ options.centery = false -- center verticaly when inserting in parent
+ options.validate = false -- validate
+ self._OPTIONS = options
+
-- init name
self._NAME = name
@@ -132,6 +143,11 @@ function view:parent()
return self._PARENT
end
+-- set the parent view
+function view:parent_set(parent)
+ self._PARENT = parent
+end
+
-- get the view window
function view:window()
return self._WINDOW
@@ -145,14 +161,14 @@ function view:canvas()
return self._CANVAS
end
--- on draw window
-function view:on_draw()
+-- draw view
+function view:draw()
self:canvas():clear()
end
-- refresh view in parent window
function view:refresh()
- self:on_draw()
+ self:draw()
self:redraw(true)
end
@@ -164,7 +180,7 @@ function view:redraw(on_parent)
self:lock()
local v = self
while v:parent() do
- v:parent():draw_child(v)
+ v:parent():_draw_overlap(v)
v = v:parent()
end
self:unlock()
@@ -209,6 +225,24 @@ function view:state_set(name, enable)
end
end
+-- get option
+function view:option(name)
+ return self._OPTIONS[name]
+end
+
+-- set option
+function view:option_set(name, enable)
+
+ -- state is not changed?
+ enable = enable or false
+ if self:option(name) == enable then
+ return
+ end
+
+ -- set option
+ self._OPTIONS[name] = enable
+end
+
-- tostring(view)
function view:__tostring()
return string.format("<%s %s>", self:name(), tostring(self:bounds()))