cc-mek-scada/pocket/ui/pages/home_page.lua

67 lines
3.3 KiB
Lua
Raw Normal View History

2023-12-22 16:12:47 +00:00
--
-- Main Home Page
--
2023-04-16 19:05:28 +00:00
2024-04-13 18:47:20 +00:00
local iocontrol = require("pocket.iocontrol")
2024-06-14 01:43:56 +00:00
local pocket = require("pocket.pocket")
2023-04-16 19:05:28 +00:00
2024-04-13 18:47:20 +00:00
local core = require("graphics.core")
2023-12-22 16:12:47 +00:00
2024-04-13 18:47:20 +00:00
local AppMultiPane = require("graphics.elements.appmultipane")
local Div = require("graphics.elements.div")
local TextBox = require("graphics.elements.textbox")
2023-12-22 16:12:47 +00:00
2024-04-13 18:47:20 +00:00
local App = require("graphics.elements.controls.app")
2023-04-16 19:05:28 +00:00
2024-06-14 01:43:56 +00:00
local ALIGN = core.ALIGN
local cpair = core.cpair
2023-04-16 19:05:28 +00:00
2024-06-14 01:43:56 +00:00
local APP_ID = pocket.APP_ID
2023-04-16 19:05:28 +00:00
-- new home page view
---@param root graphics_element parent
local function new_view(root)
2023-12-22 16:12:47 +00:00
local db = iocontrol.get_db()
2024-04-13 18:47:20 +00:00
local main = Div{parent=root,x=1,y=1,height=19}
2024-06-14 01:43:56 +00:00
local app = db.nav.register_app(APP_ID.ROOT, main)
2024-04-13 20:18:27 +00:00
2024-04-13 18:47:20 +00:00
local apps_1 = Div{parent=main,x=1,y=1,height=15}
local apps_2 = Div{parent=main,x=1,y=1,height=15}
local panes = { apps_1, apps_2 }
2024-04-13 20:18:27 +00:00
local app_pane = AppMultiPane{parent=main,x=1,y=1,height=18,panes=panes,active_color=colors.lightGray,nav_colors=cpair(colors.lightGray,colors.gray),scroll_nav=true,drag_nav=true,callback=app.switcher}
2024-04-13 20:18:27 +00:00
app.set_root_pane(app_pane)
2024-04-13 18:47:20 +00:00
app.new_page(app.new_page(nil, 1), 2)
2024-04-13 18:47:20 +00:00
local function open(id) db.nav.open_app(id) end
app.set_sidebar({
{ label = " #\x10", tall = true, color = core.cpair(colors.black, colors.green), callback = function () open(APP_ID.ROOT) end }
})
2024-04-13 18:47:20 +00:00
local active_fg_bg = cpair(colors.white,colors.gray)
App{parent=apps_1,x=2,y=2,text="U",title="Units",callback=function()open(APP_ID.UNITS)end,app_fg_bg=cpair(colors.black,colors.yellow),active_fg_bg=active_fg_bg}
App{parent=apps_1,x=9,y=2,text="F",title="Facil",callback=function()open(APP_ID.DUMMY)end,app_fg_bg=cpair(colors.black,colors.orange),active_fg_bg=active_fg_bg}
App{parent=apps_1,x=16,y=2,text="\x15",title="Control",callback=function()open(APP_ID.DUMMY)end,app_fg_bg=cpair(colors.black,colors.green),active_fg_bg=active_fg_bg}
App{parent=apps_1,x=2,y=7,text="\x17",title="Process",callback=function()open(APP_ID.DUMMY)end,app_fg_bg=cpair(colors.black,colors.purple),active_fg_bg=active_fg_bg}
App{parent=apps_1,x=9,y=7,text="\x7f",title="Waste",callback=function()open(APP_ID.DUMMY)end,app_fg_bg=cpair(colors.black,colors.brown),active_fg_bg=active_fg_bg}
App{parent=apps_1,x=16,y=7,text="\x08",title="Devices",callback=function()open(APP_ID.DUMMY)end,app_fg_bg=cpair(colors.black,colors.lightGray),active_fg_bg=active_fg_bg}
2024-06-04 00:52:59 +00:00
App{parent=apps_1,x=2,y=12,text="\xb6",title="Guide",callback=function()open(APP_ID.GUIDE)end,app_fg_bg=cpair(colors.black,colors.cyan),active_fg_bg=active_fg_bg}
App{parent=apps_1,x=9,y=12,text="?",title="About",callback=function()open(APP_ID.ABOUT)end,app_fg_bg=cpair(colors.black,colors.white),active_fg_bg=active_fg_bg}
TextBox{parent=apps_2,text="Diagnostic Apps",x=1,y=2,height=1,alignment=ALIGN.CENTER}
App{parent=apps_2,x=2,y=4,text="\x0f",title="Alarm",callback=function()open(APP_ID.ALARMS)end,app_fg_bg=cpair(colors.black,colors.red),active_fg_bg=active_fg_bg}
App{parent=apps_2,x=9,y=4,text="\x1e",title="LoopT",callback=function()open(APP_ID.DUMMY)end,app_fg_bg=cpair(colors.black,colors.cyan),active_fg_bg=active_fg_bg}
App{parent=apps_2,x=16,y=4,text="@",title="Comps",callback=function()open(APP_ID.DUMMY)end,app_fg_bg=cpair(colors.black,colors.orange),active_fg_bg=active_fg_bg}
2023-04-16 19:05:28 +00:00
return main
end
return new_view