From 4d87887709299714eb6d7439488a5f88350a5951 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Mon, 3 Jun 2024 20:52:59 -0400 Subject: [PATCH] #403 pocket guide fixes --- pocket/ui/apps/guide.lua | 19 ++++++++----------- pocket/ui/main.lua | 8 ++++++-- pocket/ui/pages/home_page.lua | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/pocket/ui/apps/guide.lua b/pocket/ui/apps/guide.lua index 1ad1b3b..9fd9628 100644 --- a/pocket/ui/apps/guide.lua +++ b/pocket/ui/apps/guide.lua @@ -36,9 +36,9 @@ local function new_view(root) local list = { { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(iocontrol.APP_ID.ROOT) end }, - { label = "Use", tall = true, color = core.cpair(colors.black, colors.purple), callback = function () app.switcher(1) end }, - { label = "UIs", tall = true, color = core.cpair(colors.black, colors.blue), callback = function () app.switcher(2) end }, - { label = "FPs", tall = true, color = core.cpair(colors.black, colors.lightGray), callback = function () app.switcher(3) end } + { label = "Use", color = core.cpair(colors.black, colors.purple), callback = function () app.switcher(2) end }, + { label = "UIs", color = core.cpair(colors.black, colors.blue), callback = function () app.switcher(3) end }, + { label = "FPs", color = core.cpair(colors.black, colors.lightGray), callback = function () app.switcher(4) end } } app.set_sidebar(list) @@ -46,7 +46,6 @@ local function new_view(root) local function load() local page_div = Div{parent=main,y=2} local p_width = page_div.get_width() - 2 - local sub_panes = {} local main_page = app.new_page(nil, 1) local use_page = app.new_page(main_page, 2) @@ -54,6 +53,10 @@ local function new_view(root) local fps_page = app.new_page(main_page, 4) local home = Div{parent=page_div,x=2,width=p_width} + local use = Div{parent=page_div,x=2,width=p_width} + local uis = Div{parent=page_div,x=2,width=p_width} + local fps = Div{parent=page_div,x=2,width=p_width} + local panes = { home, use, uis, fps } TextBox{parent=home,y=1,text="cc-mek-scada Guide",height=1,alignment=ALIGN.CENTER} @@ -61,8 +64,6 @@ local function new_view(root) PushButton{parent=home,text="Operator UIs >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=uis_page.nav_to} PushButton{parent=home,text="Front Panels >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=fps_page.nav_to} - local use = Div{parent=page_div,x=2,width=p_width} - TextBox{parent=use,y=1,text="System Usage",height=1,alignment=ALIGN.CENTER} PushButton{parent=use,x=2,y=1,text="<",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=main_page.nav_to} @@ -73,8 +74,6 @@ local function new_view(root) PushButton{parent=use,text="Automatic Control >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=function()end} PushButton{parent=use,text="Waste Control >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=function()end} - local uis = Div{parent=page_div,x=2,width=p_width} - TextBox{parent=uis,y=1,text="Operator UIs",height=1,alignment=ALIGN.CENTER} PushButton{parent=uis,x=2,y=1,text="<",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=main_page.nav_to} @@ -83,8 +82,6 @@ local function new_view(root) PushButton{parent=uis,text="Pocket UI >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=function()end} PushButton{parent=uis,text="Coordinator UI >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=function()end} - local fps = Div{parent=page_div,x=2,width=p_width} - TextBox{parent=fps,y=1,text="Front Panels",height=1,alignment=ALIGN.CENTER} PushButton{parent=fps,x=2,y=1,text="<",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=main_page.nav_to} @@ -96,7 +93,7 @@ local function new_view(root) PushButton{parent=fps,text="Coordinator >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=function()end} -- setup multipane - local u_pane = MultiPane{parent=page_div,x=1,y=1,panes={home,use,uis,fps,table.unpack(sub_panes)}} + local u_pane = MultiPane{parent=page_div,x=1,y=1,panes=panes} app.set_root_pane(u_pane) end diff --git a/pocket/ui/main.lua b/pocket/ui/main.lua index eaecc1e..9f33e1f 100644 --- a/pocket/ui/main.lua +++ b/pocket/ui/main.lua @@ -2,10 +2,13 @@ -- Pocket GUI Root -- +local util = require("scada-common.util") + local iocontrol = require("pocket.iocontrol") local diag_apps = require("pocket.ui.apps.diag_apps") local dummy_app = require("pocket.ui.apps.dummy_app") +local guide_app = require("pocket.ui.apps.guide") local sys_apps = require("pocket.ui.apps.sys_apps") local unit_app = require("pocket.ui.apps.unit") @@ -74,11 +77,12 @@ local function init(main) home_page(page_div) unit_app(page_div) - diag_apps(page_div) + guide_app(page_div) sys_apps(page_div) + diag_apps(page_div) dummy_app(page_div) - assert(#db.nav.get_containers() == iocontrol.APP_ID.NUM_APPS, "app IDs were not sequential or some apps weren't registered") + assert(util.table_len(db.nav.get_containers()) == iocontrol.APP_ID.NUM_APPS, "app IDs were not sequential or some apps weren't registered") db.nav.set_pane(MultiPane{parent=page_div,x=1,y=1,panes=db.nav.get_containers()}) db.nav.set_sidebar(Sidebar{parent=main_pane,x=1,y=1,height=18,fg_bg=cpair(colors.white,colors.gray)}) diff --git a/pocket/ui/pages/home_page.lua b/pocket/ui/pages/home_page.lua index 483a881..8854614 100644 --- a/pocket/ui/pages/home_page.lua +++ b/pocket/ui/pages/home_page.lua @@ -51,7 +51,7 @@ local function new_view(root) 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} - App{parent=apps_1,x=2,y=12,text="\xb6",title="Guide",callback=function()open(APP_ID.DUMMY)end,app_fg_bg=cpair(colors.black,colors.cyan),active_fg_bg=active_fg_bg} + 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}