diff options
| author | ruki <[email protected]> | 2018-01-12 22:29:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-12 08:59:54 +0800 |
| commit | c1ab5da128236923242317a445c8830b50e7451c (patch) | |
| tree | 33509445dcee4c9373585cbfc859c4446c547b6b | |
| parent | 2faa7ee11ebce0e797aa71554d7eac80f0a679d2 (diff) | |
add text to dialog
| -rw-r--r-- | tests/ui/dialog.lua | 4 | ||||
| -rw-r--r-- | xmake/core/ui/dialog.lua | 16 |
2 files changed, 14 insertions, 6 deletions
diff --git a/tests/ui/dialog.lua b/tests/ui/dialog.lua index bf4f0ca0a..d0e88f801 100644 --- a/tests/ui/dialog.lua +++ b/tests/ui/dialog.lua @@ -45,6 +45,9 @@ function demo:init() -- init main dialog local dialog_main = dialog:new("dialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "main dialog") + dialog_main:text():text_set([[xmake is a cross-platform build utility based on lua. + +The project focuses on making development and building easier and provides many features (.e.g package, install, plugin, macro, action, option, task ...), so that any developer can quickly pick it up and enjoy the productivity boost when developing and building project.]]) dialog_main:button_add("ok", "< OK >", "cm_ok") dialog_main:button_add("cancel", "< Cancel >", "cm_cancel") dialog_main:button_add("help", "< Help >", "cm_help") @@ -54,6 +57,7 @@ function demo:init() -- init hello dialog local dialog_hello = dialog:new("dialog.hello", rect {0, 0, self:width() / 2, self:height() / 4}):background_set(dialog_main:frame():background()) dialog_hello:frame():background_set("green") + dialog_hello:text():text_set("hello xmake! (http://xmake.io)\nA cross-platform build utility based on Lua"):textattr_set("red") dialog_hello:button_add("yes", "< Yes >", "cm_yes") dialog_hello:button_add("no", "< No >", "cm_no") self:insert(dialog_hello, {centerx = true, centery = true}) diff --git a/xmake/core/ui/dialog.lua b/xmake/core/ui/dialog.lua index f978bc56f..26de856dd 100644 --- a/xmake/core/ui/dialog.lua +++ b/xmake/core/ui/dialog.lua @@ -40,15 +40,19 @@ function dialog:init(name, bounds, title) -- init window window.init(self, name, bounds, title, true) + -- insert text + self:panel():insert(self:text()) + -- insert buttons self:panel():insert(self:buttons()) +end - -- init buttons --- local button_yes = button:new("dialog.button.yes", rect:new(0, self:panel():height() - 1, 7, 1), "< Yes >") --- self:panel():insert(button_yes, {centerx = true}) - --- local button_no = button:new("dialog.button.no", rect:new(0, self:panel():height() - 1, 7, 1), "< No >") --- self:panel():insert(button_no, {centerx = true}) +-- get text +function dialog:text() + if not self._TEXT then + self._TEXT = label:new("dialog.text", rect:new(0, 0, self:panel():width(), self:panel():height() - 1)) + end + return self._TEXT end -- get buttons |
