|
|
@ -1611,6 +1611,15 @@ function List:setChoices(choices, selected)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
self:setSelected(selected)
|
|
|
|
self:setSelected(selected)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Check if page_top needs to be adjusted
|
|
|
|
|
|
|
|
if #self.choices - self.page_size < 0 then
|
|
|
|
|
|
|
|
self.page_top = 1
|
|
|
|
|
|
|
|
elseif self.selected <= math.floor(self.page_size / 2) then
|
|
|
|
|
|
|
|
self.page_top = 1
|
|
|
|
|
|
|
|
elseif self.selected >= #self.choices - math.floor(self.page_size / 2) then
|
|
|
|
|
|
|
|
self.page_top = #self.choices - self.page_size + 1
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function List:setSelected(selected)
|
|
|
|
function List:setSelected(selected)
|
|
|
@ -1651,10 +1660,26 @@ local function update_list_scrollbar(list)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function List:postComputeFrame(body)
|
|
|
|
function List:postComputeFrame(body)
|
|
|
|
self.page_size = math.max(1, math.floor(body.height / self.row_height))
|
|
|
|
local row_count = math.floor(body.height / self.row_height)
|
|
|
|
if #self.choices - self.page_size < 0 then
|
|
|
|
self.page_size = math.max(1, row_count)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local num_choices = #self.choices
|
|
|
|
|
|
|
|
if num_choices == 0 then
|
|
|
|
self.page_top = 1
|
|
|
|
self.page_top = 1
|
|
|
|
|
|
|
|
update_list_scrollbar(self)
|
|
|
|
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local max_page_top = math.max(1, num_choices - row_count + 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.selected > num_choices - row_count then
|
|
|
|
|
|
|
|
self.page_top = max_page_top
|
|
|
|
|
|
|
|
elseif self.selected < self.page_top then
|
|
|
|
|
|
|
|
self.page_top = self.selected
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
self.page_top = math.max(1, self.selected - row_count + 1)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
update_list_scrollbar(self)
|
|
|
|
update_list_scrollbar(self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|