mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-26 05:14:21 +00:00
Improve DrawLineNumbersPanel performance
Only draw the line numbers of visible lines
This commit is contained in:
parent
10c9663191
commit
bff0a29bff
@ -1631,7 +1631,6 @@ function skin.DrawLineNumbersPanel(object)
|
|||||||
local theight = font:getHeight("a")
|
local theight = font:getHeight("a")
|
||||||
local textcolor = skin.controls.linenumberspanel_text_color
|
local textcolor = skin.controls.linenumberspanel_text_color
|
||||||
local bodycolor = skin.controls.linenumberspanel_body_color
|
local bodycolor = skin.controls.linenumberspanel_body_color
|
||||||
local mody = y
|
|
||||||
|
|
||||||
object:SetWidth(10 + font:getWidth(#lines))
|
object:SetWidth(10 + font:getWidth(#lines))
|
||||||
love.graphics.setFont(font)
|
love.graphics.setFont(font)
|
||||||
@ -1642,10 +1641,18 @@ function skin.DrawLineNumbersPanel(object)
|
|||||||
love.graphics.setColor(bordercolor)
|
love.graphics.setColor(bordercolor)
|
||||||
--skin.OutlinedRectangle(x, y, width, height, true, true, true, false)
|
--skin.OutlinedRectangle(x, y, width, height, true, true, true, false)
|
||||||
|
|
||||||
for i=1, #lines do
|
local startline = math.ceil(offsety / theight)
|
||||||
|
if startline < 1 then
|
||||||
|
startline = 1
|
||||||
|
end
|
||||||
|
local endline = math.ceil(startline + (height / theight)) + 1
|
||||||
|
if endline > #lines then
|
||||||
|
endline = #lines
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=startline, endline do
|
||||||
love.graphics.setColor(textcolor)
|
love.graphics.setColor(textcolor)
|
||||||
love.graphics.print(i, x + 5, mody - offsety)
|
love.graphics.print(i, x + 5, (y + (theight * (i - 1))) - offsety)
|
||||||
mody = mody + theight
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user