#62 graphics layouts
This commit is contained in:
45
coordinator/ui/dialog.lua
Normal file
45
coordinator/ui/dialog.lua
Normal file
@@ -0,0 +1,45 @@
|
||||
local completion = require("cc.completion")
|
||||
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
local print_ts = util.print_ts
|
||||
local println_ts = util.println_ts
|
||||
|
||||
local dialog = {}
|
||||
|
||||
function dialog.ask_y_n(question, default)
|
||||
print(question)
|
||||
|
||||
if default == true then
|
||||
print(" (Y/n)? ")
|
||||
else
|
||||
print(" (y/N)? ")
|
||||
end
|
||||
|
||||
local response = read(nil, nil)
|
||||
|
||||
if response == "" then
|
||||
return default
|
||||
elseif response == "Y" or response == "y" then
|
||||
return true
|
||||
elseif response == "N" or response == "n" then
|
||||
return false
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function dialog.ask_options(options, cancel)
|
||||
print("> ")
|
||||
local response = read(nil, nil, function(text) return completion.choice(text, options) end)
|
||||
|
||||
if response == cancel then return false end
|
||||
|
||||
if util.table_contains(options, response) then
|
||||
return response
|
||||
else return nil end
|
||||
end
|
||||
|
||||
return dialog
|
||||
21
coordinator/ui/main_layout.lua
Normal file
21
coordinator/ui/main_layout.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
--
|
||||
-- Main SCADA Coordinator GUI
|
||||
--
|
||||
|
||||
local core = require("graphics.core")
|
||||
local layout = require("graphics.layout")
|
||||
|
||||
local style = require("coordinator.ui.style")
|
||||
|
||||
local displaybox = require("graphics.elements.displaybox")
|
||||
local textbox = require("graphics.elements.textbox")
|
||||
|
||||
local function init(monitor)
|
||||
local main = layout.create(monitor, displaybox{window=monitor,fg_bg=style.root})
|
||||
|
||||
textbox{parent=main,text="Nuclear Generation Facility SCADA Coordinator",alignment=core.graphics.TEXT_ALIGN.CENTER,height=1,fg_bg=style.header}
|
||||
|
||||
return main
|
||||
end
|
||||
|
||||
return init
|
||||
11
coordinator/ui/style.lua
Normal file
11
coordinator/ui/style.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
local style = {}
|
||||
|
||||
-- MAIN LAYOUT --
|
||||
|
||||
style.root = core.graphics.cpair(colors.black, colors.lightGray)
|
||||
style.header = core.graphics.cpair(colors.white,colors.gray)
|
||||
|
||||
return style
|
||||
21
coordinator/ui/unit_layout.lua
Normal file
21
coordinator/ui/unit_layout.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
--
|
||||
-- Reactor Unit SCADA Coordinator GUI
|
||||
--
|
||||
|
||||
local core = require("graphics.core")
|
||||
local layout = require("graphics.layout")
|
||||
|
||||
local style = require("coordinator.ui.style")
|
||||
|
||||
local displaybox = require("graphics.elements.displaybox")
|
||||
local textbox = require("graphics.elements.textbox")
|
||||
|
||||
local function init(monitor, id)
|
||||
local main = layout.create(monitor, displaybox{window=monitor,fg_bg=style.root})
|
||||
|
||||
textbox{parent=main,text="Reactor Unit #" .. id,alignment=core.graphics.TEXT_ALIGN.CENTER,height=1,fg_bg=style.header}
|
||||
|
||||
return main
|
||||
end
|
||||
|
||||
return init
|
||||
Reference in New Issue
Block a user