fixed monitors, added setIndex4scrollbars, added dynamic values

This commit is contained in:
Robert Jelic
2022-07-08 19:46:28 +02:00
parent 8665eed03e
commit cbdf439791
17 changed files with 382 additions and 55 deletions

View File

@@ -1,3 +1,5 @@
local lerp = require("Lerp")
return function(name)
local object = {}
local objectType = "Animation"
@@ -232,4 +234,4 @@ return function(name)
object.__index = object
return object
end
end

View File

@@ -37,16 +37,17 @@ return function(name)
if (base.draw(self)) then
if (self.parent ~= nil) then
local obx, oby = self:getAnchorPosition()
local verticalAlign = utils.getTextVerticalAlign(self.height, textVerticalAlign)
local w,h = self:getSize()
local verticalAlign = utils.getTextVerticalAlign(h, textVerticalAlign)
if(self.bgColor~=false)then
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
self.parent:drawTextBox(obx, oby, self.width, self.height, " ")
self.parent:drawBackgroundBox(obx, oby, w, h, self.bgColor)
self.parent:drawTextBox(obx, oby, w, h, " ")
end
if(self.fgColor~=false)then self.parent:drawForegroundBox(obx, oby, self.width, self.height, self.fgColor) end
for n = 1, self.height do
if(self.fgColor~=false)then self.parent:drawForegroundBox(obx, oby, w, h, self.fgColor) end
for n = 1, h do
if (n == verticalAlign) then
self.parent:setText(obx, oby + (n - 1), utils.getTextHorizontalAlign(self:getValue(), self.width, textHorizontalAlign))
self.parent:setText(obx, oby + (n - 1), utils.getTextHorizontalAlign(self:getValue(), w, textHorizontalAlign))
end
end
end

View File

@@ -0,0 +1,53 @@
local Object = require("Object")
local geometric = require("geometric")
local tHex = require("tHex")
return function(name)
-- Graphic
local base = Object(name)
local objectType = "Graphic"
base:setZIndex(2)
local graphic = {}
local graphicCache = {}
local object = {
getType = function(self)
return objectType
end;
addCircle = function(self, rad, color, x, y, filled)
table.insert(graphic, {area=geometric.circle(x or 1, y or 1, rad, filled), color=color})
return self
end;
addElipse = function(self, rad,rad2, color, x, y, filled)
table.insert(graphic, {area=geometric.elipse(x or 1, y or 1, rad, rad2, filled), color=color})
return self
end;
draw = function(self)
if (base.draw(self)) then
if (self.parent ~= nil) then
if(#graphic>0)then
local obx, oby = self:getAnchorPosition()
if(self.bgColor~=false)then
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
end
for _,v in pairs(graphic)do
local col = tHex[v.color]
for _,b in pairs(v.area)do
if(b.x>=1)and(b.x<=self.width)and(b.y>=1)and(b.y<=self.height)then
self.parent:setBG(obx+b.x-1, oby+b.y-1, col)
end
end
end
end
end
self:setVisualChanged(false)
end
end;
}
return setmetatable(object, base)
end

View File

@@ -1,5 +1,5 @@
return function(name)
-- Pane
-- Image
local base = Object(name)
local objectType = "Image"
base:setZIndex(2)

View File

@@ -82,9 +82,26 @@ return function(name)
self.parent:drawTextBox(obx, oby, self.width, self.height, " ") end
if(self.fgColor~=false)then self.parent:drawForegroundBox(obx, oby, self.width, self.height, self.fgColor) end
if(fontsize==0)then
for n = 1, self.height do
if (n == verticalAlign) then
self.parent:setText(obx, oby + (n - 1), utils.getTextHorizontalAlign(self:getValue(), self.width, textHorizontalAlign))
if not(autoSize)then
local splittedText = utils.splitString(self:getValue(), " ")
local text = {}
local line = ""
for _,v in pairs(splittedText)do
if(line:len()+v:len()<=self.width)then
line = line=="" and v or line.." "..v
else
table.insert(text, line)
line = v:sub(1,self.width)
end
end
for k,v in pairs(text)do
self.parent:setText(obx, oby+k-1, v)
end
else
for n = 1, self.height do
if (n == verticalAlign) then
self.parent:setText(obx, oby + (n - 1), utils.getTextHorizontalAlign(self:getValue(), self.width, textHorizontalAlign))
end
end
end
else

View File

@@ -31,6 +31,20 @@ return function(name)
return self
end;
setIndex = function(self, _index)
index = _index
if (index < 1) then
index = 1
end
index = math.min(index, (barType == "vertical" and self.height or self.width) - (symbolSize - 1))
self:setValue(maxValue / (barType == "vertical" and self.height or self.width) * index)
return self
end,
getIndex = function(self)
return index
end,
setSymbolSize = function(self, size)
symbolSize = tonumber(size) or 1
if (barType == "vertical") then