Merge pull request #1047 from jgmdev/PR/cv-draw-visible

CommandView: improve performance by only drawing visible
This commit is contained in:
Guldoman 2022-06-20 17:35:06 +02:00 committed by GitHub
commit 205e554d87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -334,20 +334,20 @@ local function draw_suggestions_box(self)
end
-- draw suggestion text
local suggestion_offset = math.max(self.suggestion_idx - max_suggestions, 0)
local offset = math.max(self.suggestion_idx - max_suggestions, 0)
local last = math.min(offset + max_suggestions, #self.suggestions)
core.push_clip_rect(rx, ry, rw, rh)
local i = 1 + suggestion_offset
while i <= #self.suggestions do
local first = 1 + offset
for i=first, last do
local item = self.suggestions[i]
local color = (i == self.suggestion_idx) and style.accent or style.text
local y = self.position.y - (i - suggestion_offset) * lh - dh
local y = self.position.y - (i - offset) * lh - dh
common.draw_text(self:get_font(), color, item.text, nil, x, y, 0, lh)
if item.info then
local w = self.size.x - x - style.padding.x
common.draw_text(self:get_font(), style.dim, item.info, "right", x, y, w, lh)
end
i = i + 1
end
core.pop_clip_rect()
end