|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
----------------------
-- ZO_AbstractSingleTemplateGridScrollList
----------------------
ZO_GRID_SCROLL_LIST_AUTOFILL = true
ZO_GRID_SCROLL_LIST_DONT_AUTOFILL = false
end
self.controlsAddedSinceLastFill = 0
self.autoFillRows = autofillRows or false
end
function ZO_AbstractSingleTemplateGridScrollList:SetHeaderTemplate(templateName, height, setupFunc, onHideFunc, resetControlFunc)
self.headerOperationId = self:AddHeaderTemplate(templateName, height, setupFunc, onHideFunc, resetControlFunc)
end
function ZO_AbstractSingleTemplateGridScrollList:SetGridEntryTemplate(templateName, width, height, setupFunc, onHideFunc, resetControlFunc, spacingX, spacingY, centerEntries)
self.entryOperationId = self:AddEntryTemplate(templateName, width, height, setupFunc, onHideFunc, resetControlFunc, spacingX, spacingY, centerEntries)
end
-- Note: Order matters. When using this function, it must be called after SetGridEntryTemplate
end
self.numCellsPerRow = numCellsPerRow
end
if self.currentHeaderData ~= gridHeaderData then
if self.currentHeaderData or #scrollData > 0 then
-- we're starting a new section, so first make sure to fill out the last row of the previous section
ZO_ScrollList_AddOperation(self.list, ZO_SCROLL_LIST_OPERATION_LINE_BREAK, { lineBreakAmount = self.headerPrePadding })
end
self.currentHeaderData = gridHeaderData
self.currentHeaderName = gridHeaderData -- Maintaining backwards compatability
if self.currentHeaderData and self.currentHeaderData ~= "" then
-- data is only being kept for theoretical addon compat. There's no reason to have the entry data in the header operation, and no one should use it.
ZO_ScrollList_AddOperation(self.list, self.headerOperationId, { header = gridHeaderData, data = data })
if self.headerPostPadding > 0 then
ZO_ScrollList_AddOperation(self.list, ZO_SCROLL_LIST_OPERATION_LINE_BREAK, { lineBreakAmount = self.headerPostPadding, indentX = self.indentAmount })
end
end
end
self.controlsAddedSinceLastFill = self.controlsAddedSinceLastFill + 1
end
if self.autoFillRows then
local numMissingCells = self.numCellsPerRow - zo_mod(self.controlsAddedSinceLastFill, self.numCellsPerRow)
if numMissingCells ~= self.numCellsPerRow then -- the row was full, don't need to add any empty cells
for i = 1, numMissingCells do
ZO_ScrollList_AddOperation(self.list, self.entryOperationId, { gridHeaderData = gridHeaderData, isEmptyCell = true })
end
end
end
self.controlsAddedSinceLastFill = 0
end
if #scrollData > 0 then -- only try to fill in a row if there exists a row to fill in
end
self.controlsAddedSinceLastFill = 0
end |