summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-01-12 22:38:33 +0800
committerruki <[email protected]>2018-01-12 09:51:23 +0800
commit5d8d758fa2fb4a8e9691dae010b97725c6b736c0 (patch)
treef35203ae41c4fd6fac4ac82e7c1c142480f749a9
parent31f736c3440041b3ac060cd4519807d82a4d0e19 (diff)
add text dialog
-rw-r--r--tests/ui/dialog.lua6
-rw-r--r--xmake/core/sandbox/modules/import/core/ui/textdialog.lua26
-rw-r--r--xmake/core/ui/dialog.lua11
-rw-r--r--xmake/core/ui/textdialog.lua54
4 files changed, 83 insertions, 14 deletions
diff --git a/tests/ui/dialog.lua b/tests/ui/dialog.lua
index d0e88f801..14552d1cb 100644
--- a/tests/ui/dialog.lua
+++ b/tests/ui/dialog.lua
@@ -28,7 +28,7 @@ import("core.ui.rect")
import("core.ui.view")
import("core.ui.label")
import("core.ui.event")
-import("core.ui.dialog")
+import("core.ui.textdialog")
import("core.ui.application")
-- the demo application
@@ -44,7 +44,7 @@ function demo:init()
self:background_set("blue")
-- init main dialog
- local dialog_main = dialog:new("dialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "main dialog")
+ local dialog_main = textdialog: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.]])
@@ -55,7 +55,7 @@ The project focuses on making development and building easier and provides many
self:insert(dialog_main)
-- 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())
+ local dialog_hello = textdialog: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")
diff --git a/xmake/core/sandbox/modules/import/core/ui/textdialog.lua b/xmake/core/sandbox/modules/import/core/ui/textdialog.lua
new file mode 100644
index 000000000..2fe1f94f2
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/core/ui/textdialog.lua
@@ -0,0 +1,26 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2018, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file textdialog.lua
+--
+
+-- return module: textdialog
+return require("ui/textdialog")
diff --git a/xmake/core/ui/dialog.lua b/xmake/core/ui/dialog.lua
index 26de856dd..4ab34b322 100644
--- a/xmake/core/ui/dialog.lua
+++ b/xmake/core/ui/dialog.lua
@@ -40,21 +40,10 @@ 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
--- 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
function dialog:buttons()
if not self._BUTTONS then
diff --git a/xmake/core/ui/textdialog.lua b/xmake/core/ui/textdialog.lua
new file mode 100644
index 000000000..84ccae63c
--- /dev/null
+++ b/xmake/core/ui/textdialog.lua
@@ -0,0 +1,54 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2018, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file textdialog.lua
+--
+
+-- load modules
+local log = require("ui/log")
+local rect = require("ui/rect")
+local label = require("ui/label")
+local dialog = require("ui/dialog")
+local curses = require("ui/curses")
+
+-- define module
+local textdialog = textdialog or dialog()
+
+-- init dialog
+function textdialog:init(name, bounds, title)
+
+ -- init window
+ dialog.init(self, name, bounds, title)
+
+ -- insert text
+ self:panel():insert(self:text())
+end
+
+-- get text
+function textdialog:text()
+ if not self._TEXT then
+ self._TEXT = label:new("textdialog.text", rect:new(0, 0, self:panel():width(), self:panel():height() - 1))
+ end
+ return self._TEXT
+end
+
+-- return module
+return textdialog