mirror of
https://github.com/CCLeonOS/LeonOS.git
synced 2026-03-03 15:17:01 +00:00
feat(appgui): 添加应用GUI界面支持及包类型管理
新增appgui API用于绘制顶部和底部状态栏,提供一致的UI界面 在package.json中添加type字段区分应用和API包类型 更新安装程序以使用新的appgui界面 修改pkg程序以支持根据包类型安装到不同目录 添加appgui使用文档和演示程序
This commit is contained in:
64
data/computercraft/lua/rom/programs/appgui_demo.lua
Normal file
64
data/computercraft/lua/rom/programs/appgui_demo.lua
Normal file
@@ -0,0 +1,64 @@
|
||||
-- appgui_demo.lua
|
||||
-- Demonstration of the appgui API for drawing top and bottom bars
|
||||
|
||||
local appgui = require("appgui")
|
||||
local term = require("term")
|
||||
local colors = require("colors")
|
||||
|
||||
-- Clear the screen before starting
|
||||
term.clear()
|
||||
|
||||
-- Draw the top bar with default colors (white text on blue background)
|
||||
appgui.topbar("LeonOS App GUI Demo")
|
||||
|
||||
-- Add some content in the middle
|
||||
print()
|
||||
print("This is a demonstration of the appgui API.")
|
||||
print()
|
||||
print("The top bar shows the application title.")
|
||||
print("The bottom bar shows the status information.")
|
||||
print()
|
||||
print("Press any key to see custom colors...")
|
||||
|
||||
-- Wait for a key press
|
||||
os.pullEvent("key")
|
||||
|
||||
-- Clear the screen and redraw with custom colors
|
||||
term.clear()
|
||||
appgui.topbar("Custom Colored Top Bar", colors.yellow, colors.red)
|
||||
|
||||
-- Add some content
|
||||
print()
|
||||
print("Now with custom colors!")
|
||||
print()
|
||||
print("Top bar: Yellow text on Red background")
|
||||
print()
|
||||
print("Press any key to continue...")
|
||||
|
||||
-- Wait for a key press
|
||||
os.pullEvent("key")
|
||||
|
||||
-- Clear the screen and draw both top and bottom bars
|
||||
term.clear()
|
||||
appgui.topbar("Complete GUI Demo")
|
||||
appgui.downbar("Status: Running - Press Q to quit")
|
||||
|
||||
-- Add some content in the middle
|
||||
print()
|
||||
print("Now you can see both top and bottom bars.")
|
||||
print()
|
||||
print("Try resizing the terminal window to see how the text stays centered.")
|
||||
print()
|
||||
print("Press Q to exit this demo.")
|
||||
|
||||
-- Main loop to handle key presses
|
||||
while true do
|
||||
local event, key = os.pullEvent("key")
|
||||
if key == 16 then -- Q key
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- Clear the screen before exiting
|
||||
term.clear()
|
||||
print("AppGUI Demo has ended.")
|
||||
Reference in New Issue
Block a user