summaryrefslogtreecommitdiff
path: root/xmake/core/ui
diff options
context:
space:
mode:
authorruki <[email protected]>2017-12-23 00:50:31 +0800
committerruki <[email protected]>2017-12-22 23:03:10 +0800
commit34df1cdc819a181872aa987c3ea9f2ba0810127c (patch)
treec67838afb8a9ebc914ebb29407b365d51f037cdc /xmake/core/ui
parent8e249fefd8265911fe4fe8ef72e489cbc8e326eb (diff)
add title label to hello demo
Diffstat (limited to 'xmake/core/ui')
-rw-r--r--xmake/core/ui/desktop.lua43
-rw-r--r--xmake/core/ui/label.lua2
2 files changed, 33 insertions, 12 deletions
diff --git a/xmake/core/ui/desktop.lua b/xmake/core/ui/desktop.lua
index 48bbcbaf6..0b0f3e550 100644
--- a/xmake/core/ui/desktop.lua
+++ b/xmake/core/ui/desktop.lua
@@ -23,8 +23,11 @@
--
-- load modules
-local log = require("ui/log")
-local group = require("ui/group")
+local log = require("ui/log")
+local rect = require("ui/rect")
+local view = require("ui/view")
+local group = require("ui/group")
+local curses = require("ui/curses")
-- define module
local desktop = desktop or group()
@@ -35,8 +38,8 @@ function desktop:init(name, bounds)
-- init group
group.init(self, name, bounds)
- -- init color
- self:attr_set("color", curses.color_pair("white", "blue"))
+ -- add background
+ self:insert(self:background())
end
-- exit desktop
@@ -44,15 +47,33 @@ function desktop:exit()
group.exit(self)
end
--- draw view
-function desktop:draw()
+-- get desktop background
+function desktop:background()
- -- trace
- log:print("%s: draw ..", self)
+ -- init background
+ if not self._BACKGROUND then
- -- draw it
- local c = self:canvas()
- c:attr(self:attr("color")):move(0, 0):write(string.rep(' ', self:width() * self:height()))
+ -- create background view
+ local background = view:new("desktop.background", rect {0, 0, self:width(), self:height()})
+ self._BACKGROUND = background
+
+ -- init background color
+ background:attr_set("color", curses.color_pair("white", "blue"))
+
+ -- draw background
+ function background:draw()
+
+ -- trace
+ log:print("%s: draw ..", self)
+
+ -- draw it
+ local c = self:canvas()
+ c:attr(self:attr("color")):move(0, 0):write(string.rep(' ', self:width() * self:height()))
+ end
+ end
+
+ -- get background
+ return self._BACKGROUND
end
diff --git a/xmake/core/ui/label.lua b/xmake/core/ui/label.lua
index 57a287cb5..505b674da 100644
--- a/xmake/core/ui/label.lua
+++ b/xmake/core/ui/label.lua
@@ -40,7 +40,7 @@ function label:init(name, bounds, text)
self._TEXT = text or ""
-- init color
- self:attr_set("color", curses.color_pair("red", "white"))
+ self:attr_set("color", curses.color_pair("white", "blue"))
end
-- exit label