diff options
| author | ruki <[email protected]> | 2018-01-02 00:43:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-01 22:21:14 +0800 |
| commit | 827f07629755347bed82cb51bc1735b2984e284c (patch) | |
| tree | 7a69d659d67281211df0da854d60c3d53e253b71 /tests/ui | |
| parent | 1bf42f883ad6c68ebc48c2b574233fb0fb27aecf (diff) | |
add window
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/desktop.lua (renamed from tests/ui/hello.lua) | 21 | ||||
| -rw-r--r-- | tests/ui/window.lua | 53 |
2 files changed, 66 insertions, 8 deletions
diff --git a/tests/ui/hello.lua b/tests/ui/desktop.lua index 223ab8094..48539a14f 100644 --- a/tests/ui/hello.lua +++ b/tests/ui/desktop.lua @@ -19,7 +19,7 @@ -- Copyright (C) 2015 - 2018, TBOOX Open Source Group. -- -- @author ruki --- @file hello.lua +-- @file desktop.lua -- -- imports @@ -31,14 +31,19 @@ import("core.ui.event") import("core.ui.button") import("core.ui.application") --- the hello application -local hello = application() +-- the demo application +local demo = application() --- init hello -function hello:init() +-- init demo +function demo:init() -- init name - application.init(self, "hello") + application.init(self, "demo") + + -- show desktop, menubar and statusbar + self:insert(self:desktop()) + self:insert(self:menubar()) + self:insert(self:statusbar()) -- init title self:menubar():title():text_set("Menu Bar (Hello)") @@ -54,7 +59,7 @@ function hello:init() end -- on event -function hello:event_on(e) +function demo:event_on(e) if view.event_on(self, e) then return true end @@ -74,5 +79,5 @@ end -- main entry function main(...) - hello:run(...) + demo:run(...) end diff --git a/tests/ui/window.lua b/tests/ui/window.lua new file mode 100644 index 000000000..9eabd5cd6 --- /dev/null +++ b/tests/ui/window.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 window.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.window") +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 window + self:insert(window:new("window.main", rect {1, 1, self:width() - 1, self:height() - 1}, "main window")) +end + +-- main entry +function main(...) + demo:run(...) +end |
