summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-01-23 00:42:05 +0800
committerruki <[email protected]>2018-01-22 22:12:32 +0800
commit6d116a4bc1b58f660a60ff206c6c57ee9c939805 (patch)
tree710e77bafaff1b35198e9f960558986f6ef9402b
parent9e9946b8744cec7941cc9a0fd244a517231155a9 (diff)
add menuconf and mconfdialog
-rw-r--r--tests/ui/mconfdialog.lua54
-rw-r--r--xmake/core/sandbox/modules/import/core/ui/mconfdialog.lua26
-rw-r--r--xmake/core/sandbox/modules/import/core/ui/menuconf.lua26
-rw-r--r--xmake/core/ui/mconfdialog.lua68
-rw-r--r--xmake/core/ui/menuconf.lua53
5 files changed, 227 insertions, 0 deletions
diff --git a/tests/ui/mconfdialog.lua b/tests/ui/mconfdialog.lua
new file mode 100644
index 000000000..2eca8dc2f
--- /dev/null
+++ b/tests/ui/mconfdialog.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 mconfdialog.lua
+--
+
+-- imports
+import("core.ui.log")
+import("core.ui.rect")
+import("core.ui.view")
+import("core.ui.label")
+import("core.ui.event")
+import("core.ui.mconfdialog")
+import("core.ui.application")
+
+-- the demo application
+local demo = application()
+
+-- init demo
+function demo:init()
+
+ -- init name
+ application.init(self, "demo")
+
+ -- init background
+ self:background_set("blue")
+
+ -- init menu config dialog
+ local mconfdialog = mconfdialog:new("mconfdialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "menu config")
+ self:insert(mconfdialog)
+end
+
+-- main entry
+function main(...)
+ demo:run(...)
+end
diff --git a/xmake/core/sandbox/modules/import/core/ui/mconfdialog.lua b/xmake/core/sandbox/modules/import/core/ui/mconfdialog.lua
new file mode 100644
index 000000000..851aeb8db
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/core/ui/mconfdialog.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 mconfdialog.lua
+--
+
+-- return module: mconfdialog
+return require("ui/mconfdialog")
diff --git a/xmake/core/sandbox/modules/import/core/ui/menuconf.lua b/xmake/core/sandbox/modules/import/core/ui/menuconf.lua
new file mode 100644
index 000000000..6c33905be
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/core/ui/menuconf.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 menuconf.lua
+--
+
+-- return module: menuconf
+return require("ui/menuconf")
diff --git a/xmake/core/ui/mconfdialog.lua b/xmake/core/ui/mconfdialog.lua
new file mode 100644
index 000000000..8c9e4b108
--- /dev/null
+++ b/xmake/core/ui/mconfdialog.lua
@@ -0,0 +1,68 @@
+--!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 mconfdialog.lua
+--
+
+-- load modules
+local log = require("ui/log")
+local rect = require("ui/rect")
+local curses = require("ui/curses")
+local window = require("ui/window")
+local menuconf = require("ui/menuconf")
+local boxdialog = require("ui/boxdialog")
+
+-- define module
+local mconfdialog = mconfdialog or boxdialog()
+
+-- init dialog
+function mconfdialog:init(name, bounds, title)
+
+ -- init window
+ boxdialog.init(self, name, bounds, title)
+
+ -- init text
+ self:text():text_set([[Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----).
+Pressing <Y> includes, <N> excludes. Enter <Esc> to go back or exit, <?> for Help, </> for Search. Legend: [*] built-in [ ] excluded
+]])
+
+ -- init buttons
+ self:button_add("select", "< Select >", function (v, e) end)
+ self:button_add("exit", "< Exit >", function (v, e) end)
+ self:button_add("help", "< Help >", function (v, e) end)
+ self:button_add("save", "< Save >", function (v, e) end)
+ self:button_add("load", "< Load >", function (v, e) end)
+ self:buttons():select(self:button("select"))
+
+ -- insert menu config
+ self:box():panel():insert(self:menuconf())
+end
+
+-- get menu config
+function mconfdialog:menuconf()
+ if not self._MENUCONF then
+ self._MENUCONF = menuconf:new("mconfdialog.menuconf", self:box():bounds())
+ end
+ return self._MENUCONF
+end
+
+-- return module
+return mconfdialog
diff --git a/xmake/core/ui/menuconf.lua b/xmake/core/ui/menuconf.lua
new file mode 100644
index 000000000..132360e53
--- /dev/null
+++ b/xmake/core/ui/menuconf.lua
@@ -0,0 +1,53 @@
+--!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 menuconf.lua
+--
+
+-- load modules
+local log = require("ui/log")
+local view = require("ui/view")
+local label = require("ui/label")
+local panel = require("ui/panel")
+local event = require("ui/event")
+local curses = require("ui/curses")
+
+-- define module
+local menuconf = menuconf or panel()
+
+-- init menuconf
+function menuconf:init(name, bounds)
+
+ -- init panel
+ panel.init(self, name, bounds)
+
+end
+
+-- draw menuconf
+function menuconf:draw(transparent)
+
+ -- draw background
+ panel.draw(self, transparent)
+
+end
+
+-- return module
+return menuconf