diff options
| author | ruki <[email protected]> | 2018-01-05 22:36:07 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-05 09:36:47 +0800 |
| commit | 7858a7121d9499a27f92caa2df8bda66c36a3f0e (patch) | |
| tree | f519af523fbf50737e6b1375c394cb0ded0981ee | |
| parent | acfd73c79e9c406161ed022b40fe4d0ac7b2ad42 (diff) | |
add dialog
| -rw-r--r-- | tests/ui/dialog.lua | 56 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/ui/dialog.lua | 26 | ||||
| -rw-r--r-- | xmake/core/ui/dialog.lua | 44 | ||||
| -rw-r--r-- | xmake/core/ui/window.lua | 4 |
4 files changed, 129 insertions, 1 deletions
diff --git a/tests/ui/dialog.lua b/tests/ui/dialog.lua new file mode 100644 index 000000000..7700eae8c --- /dev/null +++ b/tests/ui/dialog.lua @@ -0,0 +1,56 @@ +--!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 dialog.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.dialog") +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 main dialog +-- self:insert(dialog:new("dialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "main dialog")) + + -- init hello dialog + self:insert(dialog:new("dialog.hello", rect {0, 0, self:width() / 2, self:height() / 4}), {centerx = true, centery = true}) +end + +-- main entry +function main(...) + demo:run(...) +end diff --git a/xmake/core/sandbox/modules/import/core/ui/dialog.lua b/xmake/core/sandbox/modules/import/core/ui/dialog.lua new file mode 100644 index 000000000..c91db260b --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/ui/dialog.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 dialog.lua +-- + +-- return module: dialog +return require("ui/dialog") diff --git a/xmake/core/ui/dialog.lua b/xmake/core/ui/dialog.lua new file mode 100644 index 000000000..28292c300 --- /dev/null +++ b/xmake/core/ui/dialog.lua @@ -0,0 +1,44 @@ +--!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 dialog.lua +-- + +-- load modules +local log = require("ui/log") +local rect = require("ui/rect") +local label = require("ui/label") +local panel = require("ui/panel") +local window = require("ui/window") +local curses = require("ui/curses") + +-- define module +local dialog = dialog or window() + +-- init dialog +function dialog:init(name, bounds, title) + + -- init window + window.init(self, name, bounds, title) +end + +-- return module +return dialog diff --git a/xmake/core/ui/window.lua b/xmake/core/ui/window.lua index 83720f205..c74de5914 100644 --- a/xmake/core/ui/window.lua +++ b/xmake/core/ui/window.lua @@ -90,7 +90,9 @@ function window:frame() if not self._FRAME then self._FRAME = panel:new("window.panel", rect{0, 0, self:width(), self:height()}) self._FRAME:background_set("white") - self._FRAME:insert(self:title(), {centerx = true}) + if self:title() then + self._FRAME:insert(self:title(), {centerx = true}) + end end return self._FRAME end |
