Adding reboot button

This commit is contained in:
Gabriel Moreira Minossi 2021-01-11 21:33:11 -03:00
parent a7ef9a0002
commit d995a8f670
2 changed files with 14 additions and 29 deletions

View File

@ -65,7 +65,7 @@ Event.listen(
local function drawTitle(title)
local x = Constants.baseWidth
local y = 1
local width = 3 * Constants.baseWidth
local width = math.floor(2.5 * Constants.baseWidth)
local height = math.floor(0.8 * Constants.baseHeight)
Widget.drawBaseWidget(x, y, width, height, title)
end
@ -88,6 +88,14 @@ local function drawNavigationButton(self, index)
end
end
local function drawRebootButton()
local width = math.floor(0.3 * Constants.baseWidth)
local height = math.floor(0.6 * Constants.baseHeight)
local x = math.floor(3.25 * Constants.baseWidth) + math.floor((Constants.baseWidth - width) / 2)
local y = math.floor((Constants.baseHeight - height) / 2)
Widget.drawBaseWidget(x, y, width, height, "Restart")
end
local function clickNavigationButton(self)
if not self.active then
return
@ -135,6 +143,7 @@ function page.create(element)
for i = 1, 9 do
elements.machineWidgets.active[i] = elements.machineWidgets[9 * (elements.machineWidgets.active.index - 1) + i]
end
elements.navigationButtons[1] = {
title = "",
active = true,
@ -154,11 +163,14 @@ function page.create(element)
draw = drawNavigationButton
}
elements[4.5] = {
elements.rebootButton = {
onClick = function()
Computer.shutdown(true)
end
}
drawRebootButton()
elements[4.5] = elements.rebootButton
elements[6] = elements.machineWidgets.active[1]
elements[7] = elements.machineWidgets.active[2]

View File

@ -1,27 +0,0 @@
-- Import section
Page = require("api.gui.page")
Graphics = require("graphics.graphics")
Colors = require("colors")
Component = require("component")
GPU = Component.gpu
--
local panel = {
currentPage = Page.overview
}
function panel.render()
Graphics.rectangle(GPU, 0, 0, 20, 160, Colors.background)
for index, page in ipairs(Page) do
if page ~= panel.currentPage then
Graphics.text(GPU, 0, 10 * (index - 1), Colors.labelColor, panel.title)
end
end
end
function panel.navigate(page)
panel.findText(page.title)
page.render()
end
return panel