mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
fixes to page navigation nav_up
This commit is contained in:
parent
99096e0fc9
commit
03de90c3d8
@ -47,6 +47,18 @@ function iocontrol.alloc_nav()
|
||||
if self.root._c[pane_id] then self.root._c[pane_id].nav_to() end
|
||||
end
|
||||
|
||||
-- find the pane this element belongs to
|
||||
---@param parent nav_tree_node
|
||||
local function _find_pane(parent)
|
||||
if parent == nil then
|
||||
return nil
|
||||
elseif parent.pane_elem then
|
||||
return parent.pane_elem
|
||||
else
|
||||
return _find_pane(parent._p)
|
||||
end
|
||||
end
|
||||
|
||||
self.cur_page = self.root
|
||||
|
||||
---@class pocket_nav
|
||||
@ -62,7 +74,8 @@ function iocontrol.alloc_nav()
|
||||
page._p._c[pane_id] = page
|
||||
|
||||
function page.nav_to()
|
||||
if page._p.pane_elem then page._p.pane_elem.set_value(page.pane_id) end
|
||||
local p_pane = _find_pane(page._p)
|
||||
if p_pane then p_pane.set_value(page.pane_id) end
|
||||
self.cur_page = page
|
||||
end
|
||||
|
||||
@ -80,7 +93,7 @@ function iocontrol.alloc_nav()
|
||||
function io.nav.nav_up()
|
||||
local parent = self.cur_page._p
|
||||
-- if a parent is defined and this element is not root
|
||||
if parent and parent.pane_id ~= 0 then self.cur_page = parent end
|
||||
if parent then parent.nav_to() end
|
||||
end
|
||||
|
||||
io.nav_root = self.root
|
||||
@ -88,8 +101,15 @@ end
|
||||
|
||||
-- complete initialization of navigation by providing the root muiltipane
|
||||
---@param root_pane graphics_element navigation root multipane
|
||||
function iocontrol.init_nav(root_pane)
|
||||
---@param default_page integer? page to nagivate to if nav_up is called on a base node
|
||||
function iocontrol.init_nav(root_pane, default_page)
|
||||
io.nav_root.pane_elem = root_pane
|
||||
|
||||
---@todo keep this?
|
||||
-- if default_page ~= nil then
|
||||
-- io.nav_root.nav_to = function() io.nav_root.switcher(default_page) end
|
||||
-- end
|
||||
|
||||
return io.nav_root
|
||||
end
|
||||
|
||||
|
@ -21,6 +21,7 @@ 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")
|
||||
local Sidebar = require("graphics.elements.controls.sidebar")
|
||||
|
||||
local LINK_STATE = iocontrol.LINK_STATE
|
||||
@ -32,7 +33,7 @@ local cpair = core.cpair
|
||||
-- create new main view
|
||||
---@param main graphics_element main displaybox
|
||||
local function init(main)
|
||||
local ps = iocontrol.get_db().ps
|
||||
local db = iocontrol.get_db()
|
||||
|
||||
-- window header message
|
||||
TextBox{parent=main,y=1,text="ALPHA APP - INCOMPLETE",alignment=ALIGN.CENTER,height=1,fg_bg=style.header}
|
||||
@ -47,7 +48,7 @@ local function init(main)
|
||||
|
||||
local root_pane = MultiPane{parent=root_pane_div,x=1,y=1,panes={conn_sv_wait,conn_api_wait,main_pane}}
|
||||
|
||||
root_pane.register(ps, "link_state", function (state)
|
||||
root_pane.register(db.ps, "link_state", function (state)
|
||||
if state == LINK_STATE.UNLINKED or state == LINK_STATE.API_LINK_ONLY then
|
||||
root_pane.set_value(1)
|
||||
elseif state == LINK_STATE.SV_LINK_ONLY then
|
||||
@ -78,6 +79,8 @@ local function init(main)
|
||||
|
||||
Sidebar{parent=main_pane,x=1,y=1,tabs=sidebar_tabs,fg_bg=cpair(colors.white,colors.gray),callback=base.switcher}
|
||||
|
||||
PushButton{parent=main_pane,x=1,y=19,text="\x1b",min_width=3,fg_bg=cpair(colors.white,colors.gray),active_fg_bg=cpair(colors.gray,colors.black),callback=db.nav.nav_up}
|
||||
|
||||
--#endregion
|
||||
end
|
||||
|
||||
|
@ -40,7 +40,7 @@ local function new_view(root)
|
||||
|
||||
local npage_diag = db.nav.new_page(nil, 6, page_pane)
|
||||
local npage_home = db.nav.new_page(npage_diag, 1)
|
||||
local npage_alarm = db.nav.new_page(npage_diag, 2)
|
||||
local npage_alarm = db.nav.new_page(npage_home, 2)
|
||||
|
||||
------------------------
|
||||
-- Alarm Testing Page --
|
||||
|
Loading…
Reference in New Issue
Block a user