added align to labels
This commit is contained in:
@@ -23,6 +23,7 @@ local function getTextVerticalAlign(h, textAlign)
|
|||||||
if (textAlign == "bottom") then
|
if (textAlign == "bottom") then
|
||||||
offset = h
|
offset = h
|
||||||
end
|
end
|
||||||
|
if(offset<1)then offset=1 end
|
||||||
return offset
|
return offset
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,7 @@ function basalt.autoUpdate(isActive)
|
|||||||
drawHelper.update()
|
drawHelper.update()
|
||||||
while updaterActive do
|
while updaterActive do
|
||||||
local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later
|
local event, p1, p2, p3, p4 = os.pullEventRaw() -- change to raw later
|
||||||
local ok, err = pcall(basaltUpdateEvent(event, p1, p2, p3, p4))
|
basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||||
if not(ok)then
|
|
||||||
parentTerminal.clear()
|
|
||||||
error(err)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -91,13 +87,8 @@ end
|
|||||||
if (basalt.debugger) then
|
if (basalt.debugger) then
|
||||||
basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug", colors.black, colors.gray)
|
basalt.debugFrame = basalt.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug", colors.black, colors.gray)
|
||||||
basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.width - 2, basalt.debugFrame.height - 3):setPosition(2, 3):setScrollable(true):show()
|
basalt.debugList = basalt.debugFrame:addList("debugList"):setSize(basalt.debugFrame.width - 2, basalt.debugFrame.height - 3):setPosition(2, 3):setScrollable(true):show()
|
||||||
basalt.debugFrame:addButton("back"):setAnchor("right"):setSize(1, 1):setText("\22"):onClick(function()
|
basalt.debugFrame:addButton("back"):setAnchor("right"):setSize(1, 1):setText("\22"):onClick(function() basalt.oldFrame:show() end):setBackground(colors.red):show()
|
||||||
basalt.oldFrame:show()
|
basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function() basalt.oldFrame = activeFrame basalt.debugFrame:show() end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()
|
||||||
end) :setBackground(colors.red):show()
|
|
||||||
basalt.debugLabel = basalt.debugFrame:addLabel("debugLabel"):onClick(function()
|
|
||||||
basalt.oldFrame = activeFrame
|
|
||||||
basalt.debugFrame:show()
|
|
||||||
end) :setBackground(colors.black):setForeground(colors.white):setAnchor("bottom"):setZIndex(20):show()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (basalt.debugger) then
|
if (basalt.debugger) then
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ local function Label(name)
|
|||||||
local autoWidth = true
|
local autoWidth = true
|
||||||
base:setValue("")
|
base:setValue("")
|
||||||
|
|
||||||
|
local textHorizontalAlign = "left"
|
||||||
|
local textVerticalAlign = "top"
|
||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
getType = function(self)
|
getType = function(self)
|
||||||
return objectType
|
return objectType
|
||||||
@@ -21,9 +24,17 @@ local function Label(name)
|
|||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
setTextAlign = function(self, hor, vert)
|
||||||
|
textHorizontalAlign = hor or textHorizontalAlign
|
||||||
|
textVerticalAlign = vert or textVerticalAlign
|
||||||
|
self:setVisualChanged()
|
||||||
|
return self
|
||||||
|
end;
|
||||||
|
|
||||||
setSize = function(self, width, height)
|
setSize = function(self, width, height)
|
||||||
self.width, self.height = width, height
|
base.setSize(self, width, height)
|
||||||
autoWidth = false
|
autoWidth = false
|
||||||
|
self:setVisualChanged()
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -31,9 +42,15 @@ local function Label(name)
|
|||||||
if (base.draw(self)) then
|
if (base.draw(self)) then
|
||||||
if (self.parent ~= nil) then
|
if (self.parent ~= nil) then
|
||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
self.parent:setBackground(obx, oby, self.width, self.height, self.bgColor)
|
local verticalAlign = getTextVerticalAlign(self.height, textVerticalAlign)
|
||||||
self.parent:setForeground(obx, oby, self.width, self.height, self.fgColor)
|
self.parent:drawBackgroundBox(obx, oby, self.width, self.height, self.bgColor)
|
||||||
self.parent:writeText(obx, oby, self:getValue():sub(1, self.width), self.bgColor, self.fgColor)
|
self.parent:drawForegroundBox(obx, oby, self.width, self.height, self.fgColor)
|
||||||
|
self.parent:drawTextBox(obx, oby, self.width, self.height, " ")
|
||||||
|
for n = 1, self.height do
|
||||||
|
if (n == verticalAlign) then
|
||||||
|
self.parent:writeText(obx, oby + (n - 1), getTextHorizontalAlign(self:getValue(), self.width, textHorizontalAlign), self.bgColor, self.fgColor)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|||||||
Reference in New Issue
Block a user