Resizing panel buttons and title

This commit is contained in:
Gabriel Moreira Minossi 2021-01-11 16:17:27 -03:00
parent bb9cf07b30
commit 90612b7ae5
3 changed files with 36 additions and 14 deletions

View File

@ -64,16 +64,18 @@ Event.listen(
local function drawTitle(title)
local x = Constants.baseWidth
local y = 0
local scale = 3
Widget.drawBaseWidget(x, y, scale, title)
local y = 1
local width = 3 * Constants.baseWidth
local height = 0.8 * Constants.baseHeight
Widget.drawBaseWidget(x, y, width, height, title)
end
local function drawPanelSection(index, title)
local x = 0
local y = (index - 1) * Constants.baseHeight
local scale = 1
Widget.drawBaseWidget(x, y, scale, title)
local width = 0.6 * Constants.baseWidth
local height = 0.6 * Constants.baseHeight
local x = (Constants.baseWidth - width) / 2
local y = (index - 1) * Constants.baseHeight + (Constants.baseHeight - height) / 2
Widget.drawBaseWidget(x, y, width, height, title)
end
function page.create(element)

View File

@ -25,15 +25,21 @@ local function drawProgress(x, y, width, height, progress, maxProgress, color)
DoubleBuffer.drawSemiPixelRectangle(x + 6 - lengths.first, y + 1, lengths.first, 1, color)
DoubleBuffer.drawSemiPixelRectangle(x + 1, y + 2, 1, lengths.second, color)
DoubleBuffer.drawSemiPixelRectangle(x + 1, y + height, lengths.third, 1, color)
DoubleBuffer.drawRectangle(x + width - 6, (y + height) / 2, 2, 1, Colors.machineBackground, Colors.machineBackground, "")
DoubleBuffer.drawRectangle(
x + width - 6,
(y + height) / 2,
2,
1,
Colors.machineBackground,
Colors.machineBackground,
""
)
DoubleBuffer.drawSemiPixelRectangle(x + width - 4, y + height, lengths.first, 1, color)
DoubleBuffer.drawSemiPixelRectangle(x + width, y + height - lengths.second, 1, lengths.second, color)
DoubleBuffer.drawSemiPixelRectangle(x + 1 + width - lengths.third, y + 1, lengths.third, 1, color)
end
function widget.drawBaseWidget(x, y, scale, title)
local width = Constants.baseWidth * scale
local height = Constants.baseHeight
function widget.drawBaseWidget(x, y, width, height, title)
DoubleBuffer.drawRectangle(
x + 1,
y + 1,
@ -43,9 +49,18 @@ function widget.drawBaseWidget(x, y, scale, title)
Colors.machineBackground,
""
)
DoubleBuffer.drawLine(
x + 3,
y + math.ceil(0.5 * height),
x + width - 3,
y + math.ceil(0.5 * height),
Colors.machineBackground,
Colors.textColor,
""
)
DoubleBuffer.drawFrame(x + 1, y + 1, width - 1, height - 1, Colors.labelColor)
DoubleBuffer.drawLine(x + 3, y + 5, x + width - 3, y + 5, Colors.machineBackground, Colors.textColor, "")
DoubleBuffer.drawText(x + math.floor((width - Unicode.len(title)) / 2), y + 3, Colors.labelColor, title)
title = Unicode.len(title) < width - 8 and " " .. title .. " " or " " .. string.gsub(title, "%l*%s", "") .. " "
DoubleBuffer.drawText(x + math.floor((width - Unicode.len(title) + 1) / 2), y + 3, Colors.labelColor, title)
end
local function draw(self, index)
@ -58,7 +73,7 @@ local function draw(self, index)
local x = Constants.baseWidth + Constants.baseWidth * ((index - 1) % 3)
local y = height * math.ceil((index) / 3)
widget.drawBaseWidget(x, y, scale, self.name)
widget.drawBaseWidget(x, y, width, height, self.name)
drawProgress(x, 2 * y, width - 1, 2 * (height - 1), 1, 1, Colors.progressBackground)
drawProgress(x, 2 * y, width - 1, 2 * (height - 1), self.progress, self.maxProgress, Colors.barColor)

View File

@ -19,6 +19,11 @@ function MultiBlock:getNumberOfProblems()
return Parser.parseProblems(sensorInformation[5])
end
function MultiBlock:getProgress()
local sensorInformation = self:getSensorInformation()
return Parser.parseProgress(sensorInformation[1])
end
function MultiBlock:getEfficiencyPercentage()
local sensorInformation = self:getSensorInformation()
return Parser.parseEfficiency(sensorInformation[5])