much faster layout calculation

This commit is contained in:
Eduardo Bart
2011-08-22 22:08:36 -03:00
parent bfa3903940
commit 3c72c844d2
6 changed files with 125 additions and 70 deletions

View File

@@ -15,14 +15,16 @@ function Console.onLog(level, message, time)
if level == LogDebug then
color = '#5555ff'
elseif level == LogInfo then
color = '#55ff55'
color = '#5555ff'
elseif level == LogWarning then
color = '#ffff00'
else
color = '#ff0000'
end
Console.addLine(message, color)
if level ~= LogDebug then
Console.addLine(message, color)
end
logLocked = false
end
@@ -35,12 +37,17 @@ function Console.addLine(text, color)
label:setStyle('ConsoleLabel')
label:setText(text)
label:setForegroundColor(color)
console:insertChild(label, -1)
console:insertChild(3, label)
local lastLabel = console:getChildByIndex(4)
if lastLabel then
lastLabel:addAnchor(AnchorBottom, "prev", AnchorTop)
end
numLines = numLines + 1
if numLines > maxLines then
local firstLine = console:getChildByIndex(0)
firstLine:destroy()
local firstLabel = console:getChildByIndex(-1)
firstLabel:destroy()
end
end

View File

@@ -1,7 +1,7 @@
ConsoleLabel < UILabel
font: terminus-14px-bold
height: 16
anchors.bottom: next.top
anchors.bottom: commandBox.top
anchors.left: parent.left
anchors.right: parent.right
margin.left: 2
@@ -13,6 +13,7 @@ RectPanel
anchors.fill: parent
UILabel
id: commandSymbolLabel
size: 18 20
anchors.bottom: parent.bottom
anchors.left: parent.left
@@ -32,4 +33,4 @@ RectPanel
function(self)
Console.executeCommand(self:getText())
self:clearText()
end
end