mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#193 pocket main application core
This commit is contained in:
parent
d9ec3d7825
commit
e9290540f5
@ -45,6 +45,7 @@ local element = {}
|
||||
---|colormap_args
|
||||
---|displaybox_args
|
||||
---|div_args
|
||||
---|multipane_args
|
||||
---|pipenet_args
|
||||
---|rectangle_args
|
||||
---|textbox_args
|
||||
|
42
graphics/elements/multipane.lua
Normal file
42
graphics/elements/multipane.lua
Normal file
@ -0,0 +1,42 @@
|
||||
-- Multi-Pane Display Graphics Element
|
||||
|
||||
local element = require("graphics.element")
|
||||
|
||||
---@class multipane_args
|
||||
---@field panes table panes to swap between
|
||||
---@field parent graphics_element
|
||||
---@field id? string element id
|
||||
---@field x? integer 1 if omitted
|
||||
---@field y? integer 1 if omitted
|
||||
---@field width? integer parent width if omitted
|
||||
---@field height? integer parent height if omitted
|
||||
---@field gframe? graphics_frame frame instead of x/y/width/height
|
||||
---@field fg_bg? cpair foreground/background colors
|
||||
|
||||
-- new multipane element
|
||||
---@nodiscard
|
||||
---@param args multipane_args
|
||||
---@return graphics_element element, element_id id
|
||||
local function multipane(args)
|
||||
assert(type(args.panes) == "table", "graphics.elements.multipane: panes is a required field")
|
||||
|
||||
-- create new graphics element base object
|
||||
local e = element.new(args)
|
||||
|
||||
-- select which pane is shown
|
||||
---@param value integer pane to show
|
||||
function e.set_value(value)
|
||||
if (e.value ~= value) and (value > 0) and (value <= #args.panes) then
|
||||
e.value = value
|
||||
|
||||
for i = 1, #args.panes do args.panes[i].hide() end
|
||||
args.panes[value].show()
|
||||
end
|
||||
end
|
||||
|
||||
e.set_value(1)
|
||||
|
||||
return e.get()
|
||||
end
|
||||
|
||||
return multipane
|
@ -16,7 +16,7 @@ local config = require("pocket.config")
|
||||
local pocket = require("pocket.pocket")
|
||||
local renderer = require("pocket.renderer")
|
||||
|
||||
local POCKET_VERSION = "alpha-v0.1.0"
|
||||
local POCKET_VERSION = "alpha-v0.1.1"
|
||||
|
||||
-- local print = util.print
|
||||
local println = util.println
|
||||
|
22
pocket/ui/components/boiler_page.lua
Normal file
22
pocket/ui/components/boiler_page.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local style = require("pocket.ui.style")
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
local Div = require("graphics.elements.div")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local cpair = core.graphics.cpair
|
||||
|
||||
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
|
||||
|
||||
-- new boiler page view
|
||||
---@param root graphics_element parent
|
||||
local function new_view(root)
|
||||
local main = Div{parent=root,x=1,y=1}
|
||||
|
||||
TextBox{parent=main,text="BOILERS",x=1,y=1,height=1,alignment=TEXT_ALIGN.CENTER}
|
||||
|
||||
return main
|
||||
end
|
||||
|
||||
return new_view
|
22
pocket/ui/components/home_page.lua
Normal file
22
pocket/ui/components/home_page.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local style = require("pocket.ui.style")
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
local Div = require("graphics.elements.div")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local cpair = core.graphics.cpair
|
||||
|
||||
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
|
||||
|
||||
-- new home page view
|
||||
---@param root graphics_element parent
|
||||
local function new_view(root)
|
||||
local main = Div{parent=root,x=1,y=1}
|
||||
|
||||
TextBox{parent=main,text="HOME",x=1,y=1,height=1,alignment=TEXT_ALIGN.CENTER}
|
||||
|
||||
return main
|
||||
end
|
||||
|
||||
return new_view
|
22
pocket/ui/components/reactor_page.lua
Normal file
22
pocket/ui/components/reactor_page.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local style = require("pocket.ui.style")
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
local Div = require("graphics.elements.div")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local cpair = core.graphics.cpair
|
||||
|
||||
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
|
||||
|
||||
-- new reactor page view
|
||||
---@param root graphics_element parent
|
||||
local function new_view(root)
|
||||
local main = Div{parent=root,x=1,y=1}
|
||||
|
||||
TextBox{parent=main,text="REACTOR",x=1,y=1,height=1,alignment=TEXT_ALIGN.CENTER}
|
||||
|
||||
return main
|
||||
end
|
||||
|
||||
return new_view
|
22
pocket/ui/components/turbine_page.lua
Normal file
22
pocket/ui/components/turbine_page.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local style = require("pocket.ui.style")
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
local Div = require("graphics.elements.div")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local cpair = core.graphics.cpair
|
||||
|
||||
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
|
||||
|
||||
-- new turbine page view
|
||||
---@param root graphics_element parent
|
||||
local function new_view(root)
|
||||
local main = Div{parent=root,x=1,y=1}
|
||||
|
||||
TextBox{parent=main,text="TURBINES",x=1,y=1,height=1,alignment=TEXT_ALIGN.CENTER}
|
||||
|
||||
return main
|
||||
end
|
||||
|
||||
return new_view
|
22
pocket/ui/components/unit_page.lua
Normal file
22
pocket/ui/components/unit_page.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local style = require("pocket.ui.style")
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
local Div = require("graphics.elements.div")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local cpair = core.graphics.cpair
|
||||
|
||||
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
|
||||
|
||||
-- new unit page view
|
||||
---@param root graphics_element parent
|
||||
local function new_view(root)
|
||||
local main = Div{parent=root,x=1,y=1}
|
||||
|
||||
TextBox{parent=main,text="UNITS",x=1,y=1,height=1,alignment=TEXT_ALIGN.CENTER}
|
||||
|
||||
return main
|
||||
end
|
||||
|
||||
return new_view
|
@ -8,11 +8,18 @@ local style = require("pocket.ui.style")
|
||||
|
||||
local conn_waiting = require("pocket.ui.components.conn_waiting")
|
||||
|
||||
local home_page = require("pocket.ui.components.home_page")
|
||||
local unit_page = require("pocket.ui.components.unit_page")
|
||||
local reactor_page = require("pocket.ui.components.reactor_page")
|
||||
local boiler_page = require("pocket.ui.components.boiler_page")
|
||||
local turbine_page = require("pocket.ui.components.turbine_page")
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
local ColorMap = require("graphics.elements.colormap")
|
||||
local DisplayBox = require("graphics.elements.displaybox")
|
||||
local Div = require("graphics.elements.div")
|
||||
local MultiPane = require("graphics.elements.multipane")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local PushButton = require("graphics.elements.controls.push_button")
|
||||
@ -59,7 +66,19 @@ local function init(monitor)
|
||||
}
|
||||
}
|
||||
|
||||
local sidebar = Sidebar{parent=main,x=1,y=2,tabs=sidebar_tabs,fg_bg=cpair(colors.white,colors.gray),callback=function()end}
|
||||
local mp_div = Div{parent=main,x=4,y=2}
|
||||
|
||||
local pane_1 = home_page(mp_div)
|
||||
local pane_2 = unit_page(mp_div)
|
||||
local pane_3 = reactor_page(mp_div)
|
||||
local pane_4 = boiler_page(mp_div)
|
||||
local pane_5 = turbine_page(mp_div)
|
||||
|
||||
local panes = { pane_1, pane_2, pane_3, pane_4, pane_5 }
|
||||
|
||||
local multipane = MultiPane{parent=mp_div,x=1,y=1,panes=panes}
|
||||
|
||||
local sidebar = Sidebar{parent=main,x=1,y=2,tabs=sidebar_tabs,fg_bg=cpair(colors.white,colors.gray),callback=multipane.set_value}
|
||||
|
||||
return main
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user