table layout and sorting change

This commit is contained in:
Manuel Simon Hirsig
2016-12-04 16:38:38 +01:00
parent c6b8a904be
commit 979318b073
7 changed files with 227 additions and 297 deletions
+85 -139
View File
@@ -58,24 +58,26 @@ function item_column_init(rt, cell)
cell.text:SetPoint('BOTTOMRIGHT', 0, 0)
end
function item_column_fill(cell, record, _, _, _, indented)
cell.icon:SetTexture(record.texture)
if indented then
cell.spacer:SetWidth(10)
cell.icon:SetAlpha(.5)
cell.text:SetAlpha(.7)
else
cell.spacer:SetWidth(1)
cell.icon:SetAlpha(1)
cell.text:SetAlpha(1)
end
cell.text:SetText(gsub(record.link, '[%[%]]', ''))
end
M.search_config = {
{
title = 'Item',
width = .35,
init = item_column_init,
fill = function(cell, record, _, _, _, indented)
cell.icon:SetTexture(record.texture)
if indented then
cell.spacer:SetWidth(10)
cell.icon:SetAlpha(.5)
cell.text:SetAlpha(.7)
else
cell.spacer:SetWidth(1)
cell.icon:SetAlpha(1)
cell.text:SetAlpha(1)
end
cell.text:SetText(gsub(record.link, '[%[%]]', ''))
end,
fill = item_column_fill,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.name, record_b.name, desc)
end,
@@ -118,7 +120,7 @@ M.search_config = {
end,
},
{
title = 'Stack Size',
title = 'Stack\nSize',
width = .055,
align = 'CENTER',
fill = function(cell, record)
@@ -129,7 +131,7 @@ M.search_config = {
end,
},
{
title = 'Time Left',
title = 'Time\nLeft',
width = .04,
align = 'CENTER',
fill = function(cell, record)
@@ -191,6 +193,18 @@ M.search_config = {
else
price_b = aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
end
if record_a.high_bidder and not record_b.high_bidder then
return sort_util.GT
elseif record_b.high_bidder and not record_a.high_bidder then
return sort_util.LT
end
if price_a == price_b then
if record_a.high_bid == 0 and record_b.high_bid ~= 0 then
return sort_util.GT
elseif record_b.high_bid == 0 and record_a.high_bid ~= 0 then
return sort_util.LT
end
end
return sort_util.compare(price_a, price_b, desc)
end,
},
@@ -213,7 +227,7 @@ M.search_config = {
end,
},
{
title = '% Hist. Value',
title = '% Hist.\nValue',
width = .08,
align = 'CENTER',
fill = function(cell, record)
@@ -233,19 +247,7 @@ M.auctions_config = {
title = 'Item',
width = .35,
init = item_column_init,
fill = function(cell, record, _, _, _, indented)
cell.icon:SetTexture(record.texture)
if indented then
cell.spacer:SetWidth(10)
cell.icon:SetAlpha(.5)
cell.text:SetAlpha(.7)
else
cell.spacer:SetWidth(1)
cell.icon:SetAlpha(1)
cell.text:SetAlpha(1)
end
cell.text:SetText(gsub(record.link, '[%[%]]', ''))
end,
fill = item_column_fill,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.name, record_b.name, desc)
end,
@@ -285,7 +287,7 @@ M.auctions_config = {
end,
},
{
title = 'Stack Size',
title = 'Stack\nSize',
width = .055,
align = 'CENTER',
fill = function(cell, record)
@@ -296,7 +298,7 @@ M.auctions_config = {
end,
},
{
title = 'Time Left',
title = 'Time\nLeft',
width = .04,
align = 'CENTER',
fill = function(cell, record)
@@ -380,19 +382,7 @@ M.bids_config = {
title = 'Item',
width = .35,
init = item_column_init,
fill = function(cell, record, _, _, _, indented)
cell.icon:SetTexture(record.texture)
if indented then
cell.spacer:SetWidth(10)
cell.icon:SetAlpha(.5)
cell.text:SetAlpha(.7)
else
cell.spacer:SetWidth(1)
cell.icon:SetAlpha(1)
cell.text:SetAlpha(1)
end
cell.text:SetText(gsub(record.link, '[%[%]]', ''))
end,
fill = item_column_fill,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.name, record_b.name, desc)
end,
@@ -419,7 +409,7 @@ M.bids_config = {
end,
},
{
title = 'Stack Size',
title = 'Stack\nSize',
width = .055,
align = 'CENTER',
fill = function(cell, record)
@@ -430,7 +420,7 @@ M.bids_config = {
end,
},
{
title = 'Time Left',
title = 'Time\nLeft',
width = .04,
align = 'CENTER',
fill = function(cell, record)
@@ -556,7 +546,8 @@ end
local methods = {
OnContentSizeChanged = function(self, width)
OnContentSizeChanged = function(self)
local width = self.contentFrame:GetRight() - self.contentFrame:GetLeft()
for _, cell in self.headCells do
cell:SetWidth(cell.info.width * width)
end
@@ -570,7 +561,6 @@ local methods = {
OnHeadColumnClick = function()
local button = arg1
local rt = this.rt
if rt.disabled then return end
if button == 'RightButton' and rt.headCells[this.columnIndex].info.isPrice then
_G.aux_price_per_unit = not aux_price_per_unit
@@ -608,7 +598,6 @@ local methods = {
OnCellEnter = function()
local rt = this.rt
local row = this.row
if rt.disabled then return end
if this ~= row.cells[1] or not rt.isShowingItemTooltip then
if rt.expanded[row.data.expandKey] then
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
@@ -633,7 +622,6 @@ local methods = {
OnCellClick = function()
local button = arg1
if this.rt.disabled then return end
if IsControlKeyDown() then
DressUpItemLink(this.row.data.record.link)
elseif IsShiftKeyDown() and ChatFrameEditBox:IsVisible() then
@@ -656,7 +644,6 @@ local methods = {
local rt = this.rt
local rowData = this.row.data
local expand = not rt.expanded[rowData.expandKey]
if rt.disabled or expand and not rowData.expandable then return end
rt.expanded[rowData.expandKey] = expand
rt:UpdateRowInfo()
@@ -702,6 +689,12 @@ local methods = {
end
end
-- -- if there's only one item in the result, expand it TODO
-- if getn(self.rowInfo) == 1 and self.expanded[self.rowInfo[1].expandKey] == nil then
-- self.expanded[self.rowInfo[1].expandKey] = true
-- self.rowInfo.numDisplayRows = getn(self.rowInfo[1].children)
-- end
for i = 1, getn(self.rowInfo) do
local info = self.rowInfo[i]
local totalAuctions, totalPlayerAuctions = 0, 0
@@ -713,11 +706,23 @@ local methods = {
end
info.totalAuctions = totalAuctions
info.totalPlayerAuctions = totalPlayerAuctions
end
end
end,
UpdateRows = function(self)
for _, row in self.rows do row:Hide() end
if self.rowInfo.numDisplayRows > getn(self.rows) then
self.contentFrame:SetPoint('BOTTOMRIGHT', -15, 0)
else
self.contentFrame:SetPoint('BOTTOMRIGHT', 0, 0)
end
self:OnContentSizeChanged()
FauxScrollFrame_Update(self.scrollFrame, self.rowInfo.numDisplayRows, getn(self.rows), self.ROW_HEIGHT)
local maxOffset = max(self.rowInfo.numDisplayRows - getn(self.rows), 0)
if FauxScrollFrame_GetOffset(self.scrollFrame) > maxOffset then
FauxScrollFrame_SetOffset(self.scrollFrame, maxOffset)
end
for _, cell in self.headCells do
local tex = cell:GetNormalTexture()
@@ -735,13 +740,6 @@ local methods = {
end
end
FauxScrollFrame_Update(self.scrollFrame, self.rowInfo.numDisplayRows, getn(self.rows), self.ROW_HEIGHT)
local maxOffset = max(self.rowInfo.numDisplayRows - getn(self.rows), 0)
if FauxScrollFrame_GetOffset(self.scrollFrame) > maxOffset then
FauxScrollFrame_SetOffset(self.scrollFrame, maxOffset)
end
if not self.isSorted then
local function sort_helper(a, b)
@@ -774,6 +772,7 @@ local methods = {
self.isSorted = true
end
for _, row in self.rows do row:Hide() end
local rowIndex = 1 - FauxScrollFrame_GetOffset(self.scrollFrame)
for i = 1, getn(self.rowInfo) do
local info = self.rowInfo[i]
@@ -807,8 +806,6 @@ local methods = {
end,
SetSelectedRecord = function(self, record, silent)
if self.disabled then return end
self.selected = record
local selectedData = self:GetSelection()
self.selected = selectedData and self.selected or nil
@@ -821,47 +818,46 @@ local methods = {
end
end
if not silent and self.handlers.OnSelectionChanged and not self.scrollDisabled then
if not silent and self.handlers.OnSelectionChanged then
self.handlers.OnSelectionChanged(self, selectedData or nil)
end
end,
Reset = function(rt)
wipe(rt.expanded)
rt:UpdateRowInfo()
rt:UpdateRows()
rt:SetSelectedRecord()
Reset = function(self)
wipe(self.expanded)
self:UpdateRowInfo()
self:UpdateRows()
self:SetSelectedRecord()
end,
SetDatabase = function(rt, database)
if database and database ~= rt.records then
rt.records = database
SetDatabase = function(self, database)
if database and database ~= self.records then
self.records = database
end
-- get index of selected row
local prevSelectedIndex
if rt.selected then
for i, row in rt.rows do
if row:IsVisible() and row.data and row.data.record == rt.selected then
if self.selected then
for i, row in self.rows do
if row:IsVisible() and row.data and row.data.record == self.selected then
prevSelectedIndex = i
end
end
end
rt:UpdateRowInfo()
rt:UpdateRows()
self:UpdateRowInfo()
self:UpdateRows()
if not rt.selected and prevSelectedIndex then
if not self.selected and prevSelectedIndex then
-- try to select the same row
local row = rt.rows[prevSelectedIndex]
local row = self.rows[prevSelectedIndex]
if row and row:IsVisible() and row.data and row.data.record then
rt:SetSelectedRecord(row.data.record)
self:SetSelectedRecord(row.data.record)
end
if not rt.selected then
if not self.selected then
-- select the first row
row = rt.rows[1]
row = self.rows[1]
if row and row:IsVisible() and row.data and row.data.record then
rt:SetSelectedRecord(row.data.record)
self:SetSelectedRecord(row.data.record)
end
end
end
@@ -875,27 +871,8 @@ local methods = {
self:SetDatabase()
end,
RemoveSelectedRecord = function(self, count)
count = count or 1
for i = 1, count do
local index = key(self.selected, self.records)
if index then
tremove(self.records, index)
end
end
self:SetDatabase()
end,
InsertAuctionRecord = function(self, record, count)
count = count or 1
for i = 1, count do
tinsert(self.records, record)
end
self:SetDatabase()
end,
ContainsRecord = function(rt, record)
if key(record, rt.records) then
ContainsRecord = function(self, record)
if key(record, self.records) then
return true
end
end,
@@ -916,28 +893,10 @@ local methods = {
self:UpdateRows()
end,
SetScrollDisabled = function(self, disabled)
self.scrollDisabled = disabled
end,
SetHandler = function(self, event, handler)
self.handlers[event] = handler
end,
SetDisabled = function(self, disabled)
self.disabled = disabled
if not disabled then
-- if there's only one item in the result, expand it
if getn(self.rowInfo) == 1 and self.expanded[self.rowInfo[1].expandKey] == nil then
self.expanded[self.rowInfo[1].expandKey] = true
self.rowInfo.numDisplayRows = getn(self.rowInfo[1].children)
end
self:UpdateRows()
-- select the first row
self:SetSelectedRecord(getn(self.rowInfo) > 0 and self.rowInfo[1].children[1].record)
end
end,
GetSelection = function(self)
if not self.selected then return end
local selectedData
@@ -951,24 +910,13 @@ local methods = {
end
return selectedData
end,
GetTotalAuctions = function(self)
local numResults = 0
for i = 1, getn(self.rowInfo) do
for _, childInfo in self.rowInfo[i].children do
numResults = numResults + childInfo.numAuctions
end
end
return numResults
end,
}
function M.CreateAuctionResultsTable(parent, config)
function M.new(parent, config)
local rt = CreateFrame('Frame', nil, parent)
rt.config = config
local numRows = 16
rt.ROW_HEIGHT = (parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / numRows
rt.scrollDisabled = nil
rt.expanded = T
rt.handlers = T
rt.sorts = T
@@ -989,14 +937,12 @@ function M.CreateAuctionResultsTable(parent, config)
local contentFrame = CreateFrame('Frame', nil, rt)
contentFrame:SetPoint('TOPLEFT', 0, 0)
contentFrame:SetPoint('BOTTOMRIGHT', -15, 0)
contentFrame:SetPoint('BOTTOMRIGHT', 0, 0)
rt.contentFrame = contentFrame
local scrollFrame = CreateFrame('ScrollFrame', gui.unique_name, rt, 'FauxScrollFrameTemplate')
scrollFrame:SetScript('OnVerticalScroll', function()
if not rt.scrollDisabled then
FauxScrollFrame_OnVerticalScroll(rt.ROW_HEIGHT, function() rt:UpdateRows() end)
end
FauxScrollFrame_OnVerticalScroll(rt.ROW_HEIGHT, function() rt:UpdateRows() end)
end)
scrollFrame:SetAllPoints(contentFrame)
rt.scrollFrame = scrollFrame
@@ -1125,6 +1071,6 @@ function M.CreateAuctionResultsTable(parent, config)
rt:SetAllPoints()
--TODO change, maybe use for resize without scrollbar?
rt:OnContentSizeChanged(contentFrame:GetWidth())
rt:OnContentSizeChanged()
return rt
end
+1 -1
View File
@@ -41,7 +41,7 @@ function M.render(item_listing)
end
end
function M.create(parent, on_click, selected)
function M.new(parent, on_click, selected)
local content = CreateFrame('Frame', nil, parent)
content:SetPoint('TOPLEFT', 0, -51)
content:SetPoint('BOTTOMRIGHT', -15, 0)
+123 -139
View File
@@ -54,33 +54,93 @@ local handlers = {
}
local methods = {
RefreshRows = function(st)
if not st.rowData then return end
FauxScrollFrame_Update(st.scrollFrame, getn(st.rowData), st.sizes.numRows, ST_ROW_HEIGHT)
local offset = FauxScrollFrame_GetOffset(st.scrollFrame)
st.offset = offset
Update = function(self)
if getn(self.colInfo) > 1 or self.colInfo[1].name then
self.sizes.headHeight = ST_HEAD_HEIGHT
else
self.sizes.headHeight = 0
end
self.sizes.numRows = max(floor((self:GetParent():GetHeight() - self.sizes.headHeight - ST_HEAD_SPACE) / ST_ROW_HEIGHT), 0)
for i = 1, st.sizes.numRows do
st.rows[i].data = nil
if i > getn(st.rowData) then
st.rows[i]:Hide()
self.scrollBar:ClearAllPoints()
self.scrollBar:SetPoint('BOTTOMRIGHT', self, -1, 1)
self.scrollBar:SetPoint('TOPRIGHT', self, -1, -self.sizes.headHeight - ST_HEAD_SPACE - 1)
if getn(self.rowData or empty) > self.sizes.numRows then
self.contentFrame:SetPoint('BOTTOMRIGHT', -15, 0)
else
self.contentFrame:SetPoint('BOTTOMRIGHT', 0, 0)
end
local width = self.contentFrame:GetRight() - self.contentFrame:GetLeft()
while getn(self.headCols) < getn(self.colInfo) do
self:AddColumn()
end
for i, col in self.headCols do
if self.colInfo[i] then
col:Show()
col:SetWidth(self.colInfo[i].width * width)
col:SetHeight(self.sizes.headHeight)
col.text:SetText(self.colInfo[i].name or '')
col.text:SetJustifyH(self.colInfo[i].headAlign or 'CENTER')
else
col:Hide()
end
end
while getn(self.rows) < self.sizes.numRows do
self:AddRow()
end
for i, row in self.rows do
if i > self.sizes.numRows then
row.data = nil
row:Hide()
else
row:Show()
while getn(row.cols) < getn(self.colInfo) do
self:AddRowCol(i)
end
for j, col in row.cols do
if self.headCols[j] and self.colInfo[j] then
col:Show()
col:SetWidth(self.colInfo[j].width * width)
col.text:SetJustifyH(self.colInfo[j].align or 'LEFT')
else
col:Hide()
end
end
end
end
if not self.rowData then return end
FauxScrollFrame_Update(self.scrollFrame, getn(self.rowData), self.sizes.numRows, ST_ROW_HEIGHT)
local offset = FauxScrollFrame_GetOffset(self.scrollFrame)
self.offset = offset
for i = 1, self.sizes.numRows do
self.rows[i].data = nil
if i > getn(self.rowData) then
self.rows[i]:Hide()
else
st.rows[i]:Show()
local data = st.rowData[i + offset]
self.rows[i]:Show()
local data = self.rowData[i + offset]
if not data then break end
st.rows[i].data = data
self.rows[i].data = data
if (st.selected == key(st.rowData, data) and not st.selectionDisabled)
or (st.highlighted and st.highlighted == key(st.rowData, data))
or st.rows[i].mouseover
if (self.selected == key(self.rowData, data) and not self.selectionDisabled)
or (self.highlighted and self.highlighted == key(self.rowData, data))
or self.rows[i].mouseover
then
st.rows[i].highlight:Show()
self.rows[i].highlight:Show()
else
st.rows[i].highlight:Hide()
self.rows[i].highlight:Hide()
end
for j, col in st.rows[i].cols do
if st.colInfo[j] then
for j, col in self.rows[i].cols do
if self.colInfo[j] then
local colData = data.cols[j]
if type(colData.value) == 'function' then
col.text:SetText(colData.value(unpack(colData.args)))
@@ -93,126 +153,50 @@ local methods = {
end
end,
SetData = function(st, rowData)
for _, row in st.rowData or empty do
SetData = function(self, rowData)
for _, row in self.rowData or empty do
for _, col in row.cols do release(col) end
release(row.cols)
release(row)
end
st.rowData = rowData
st.updateSort = true
st:RefreshRows()
self.rowData = rowData
self.updateSort = true
self:Update()
end,
SetSelection = function(st, predicate)
st:ClearSelection()
for i, rowDatum in st.rowData do
SetSelection = function(self, predicate)
self:ClearSelection()
for i, rowDatum in self.rowData do
if predicate(rowDatum) then
st.selected = i
st:RefreshRows()
self.selected = i
self:Update()
break
end
end
end,
GetSelection = function(st)
return st.selected
GetSelection = function(self)
return self.selected
end,
ClearSelection = function(st)
st.selected = nil
st:RefreshRows()
ClearSelection = function(self)
self.selected = nil
self:Update()
end,
DisableSelection = function(st, value)
st.selectionDisabled = value
DisableSelection = function(self, value)
self.selectionDisabled = value
end,
DisableHighlight = function(st, value)
st.highlightDisabled = value
end,
GetNumRows = function(st)
return st.sizes.numRows
end,
SetHighlighted = function(st, row)
st.highlighted = row
st:RefreshRows()
end,
Redraw = function(st)
local width = st:GetWidth() - 14
if getn(st.colInfo) > 1 or st.colInfo[1].name then
st.sizes.headHeight = ST_HEAD_HEIGHT
else
st.sizes.headHeight = 0
end
st.sizes.numRows = max(floor((st:GetParent():GetHeight() - st.sizes.headHeight - ST_HEAD_SPACE) / ST_ROW_HEIGHT), 0)
st.scrollBar:ClearAllPoints()
st.scrollBar:SetPoint('BOTTOMRIGHT', st, -1, 1)
st.scrollBar:SetPoint('TOPRIGHT', st, -1, -st.sizes.headHeight - ST_HEAD_SPACE - 1)
if st.rows and st.rows[1] then
st.rows[1]:SetPoint('TOPLEFT', 0, -(st.sizes.headHeight + ST_HEAD_SPACE))
st.rows[1]:SetPoint('TOPRIGHT', 0, -(st.sizes.headHeight + ST_HEAD_SPACE))
end
while getn(st.headCols) < getn(st.colInfo) do
st:AddColumn()
end
for i, col in st.headCols do
if st.colInfo[i] then
col:Show()
col:SetWidth(st.colInfo[i].width * width)
col:SetHeight(st.sizes.headHeight)
col.text:SetText(st.colInfo[i].name or '')
col.text:SetJustifyH(st.colInfo[i].headAlign or 'CENTER')
else
col:Hide()
end
end
while getn(st.rows) < st.sizes.numRows do
st:AddRow()
end
for i, row in st.rows do
if i > st.sizes.numRows then
row.data = nil
row:Hide()
else
row:Show()
while getn(row.cols) < getn(st.colInfo) do
st:AddRowCol(i)
end
for j, col in row.cols do
if st.headCols[j] and st.colInfo[j] then
col:Show()
col:SetWidth(st.colInfo[j].width * width)
col.text:SetJustifyH(st.colInfo[j].align or 'LEFT')
else
col:Hide()
end
end
end
end
st:RefreshRows()
end,
AddColumn = function(st)
local colNum = getn(st.headCols) + 1
local col = CreateFrame('Frame', st:GetName() .. 'HeadCol' .. colNum, st.contentFrame)
AddColumn = function(self)
local colNum = getn(self.headCols) + 1
local col = CreateFrame('Frame', self:GetName() .. 'HeadCol' .. colNum, self.contentFrame)
if colNum == 1 then
col:SetPoint('TOPLEFT', 0, 0)
else
col:SetPoint('TOPLEFT', st.headCols[colNum - 1], 'TOPRIGHT')
col:SetPoint('TOPLEFT', self.headCols[colNum - 1], 'TOPRIGHT')
end
col.st = st
col.st = self
col.colNum = colNum
local text = col:CreateFontString()
@@ -227,18 +211,18 @@ local methods = {
tex:SetTexCoord(.017, 1, .083, .909)
tex:SetAlpha(.5)
tinsert(st.headCols, col)
tinsert(self.headCols, col)
-- add new cells to the rows
for i, row in st.rows do
while getn(row.cols) < getn(st.headCols) do
st:AddRowCol(i)
for i, row in self.rows do
while getn(row.cols) < getn(self.headCols) do
self:AddRowCol(i)
end
end
end,
AddRowCol = function(st, rowNum)
local row = st.rows[rowNum]
AddRowCol = function(self, rowNum)
local row = self.rows[rowNum]
local colNum = getn(row.cols) + 1
local col = CreateFrame('Frame', nil, row)
local text = col:CreateFontString()
@@ -252,7 +236,7 @@ local methods = {
for name, func in handlers do
col:SetScript(name, func)
end
col.st = st
col.st = self
col.row = row
if colNum == 1 then
@@ -263,28 +247,28 @@ local methods = {
tinsert(row.cols, col)
end,
AddRow = function(st)
local row = CreateFrame('Frame', nil, st.contentFrame)
AddRow = function(self)
local row = CreateFrame('Frame', nil, self.contentFrame)
row:SetHeight(ST_ROW_HEIGHT)
local rowNum = getn(st.rows) + 1
local rowNum = getn(self.rows) + 1
if rowNum == 1 then
row:SetPoint('TOPLEFT', 2, -(st.sizes.headHeight + ST_HEAD_SPACE))
row:SetPoint('TOPRIGHT', 0, -(st.sizes.headHeight + ST_HEAD_SPACE))
row:SetPoint('TOPLEFT', 2, -(self.sizes.headHeight + ST_HEAD_SPACE))
row:SetPoint('TOPRIGHT', 0, -(self.sizes.headHeight + ST_HEAD_SPACE))
else
row:SetPoint('TOPLEFT', 2, -(st.sizes.headHeight + ST_HEAD_SPACE + (rowNum - 1) * ST_ROW_HEIGHT))
row:SetPoint('TOPRIGHT', 0, -(st.sizes.headHeight + ST_HEAD_SPACE + (rowNum - 1) * ST_ROW_HEIGHT))
row:SetPoint('TOPLEFT', 2, -(self.sizes.headHeight + ST_HEAD_SPACE + (rowNum - 1) * ST_ROW_HEIGHT))
row:SetPoint('TOPRIGHT', 0, -(self.sizes.headHeight + ST_HEAD_SPACE + (rowNum - 1) * ST_ROW_HEIGHT))
end
local highlight = row:CreateTexture()
highlight:SetAllPoints()
highlight:SetTexture(1, .9, .9, .1)
highlight:Hide()
row.highlight = highlight
row.st = st
row.st = self
row.cols = T
st.rows[rowNum] = row
for i = 1, getn(st.colInfo) do
st:AddRowCol(rowNum)
self.rows[rowNum] = row
for i = 1, getn(self.colInfo) do
self:AddRowCol(rowNum)
end
end,
@@ -295,23 +279,23 @@ local methods = {
SetColInfo = function(st, colInfo)
colInfo = colInfo or DEFAULT_COL_INFO
st.colInfo = colInfo
st:Redraw()
st:Update()
end,
}
function M.CreateScrollingTable(parent)
function M.new(parent)
ST_COUNT = ST_COUNT + 1
local st = CreateFrame('Frame', 'TSMScrollingTable' .. ST_COUNT, parent)
st:SetAllPoints()
local contentFrame = CreateFrame('Frame', nil, st)
contentFrame:SetPoint('TOPLEFT', 0, 0)
contentFrame:SetPoint('BOTTOMRIGHT', -15, 0)
contentFrame:SetPoint('BOTTOMRIGHT', 0, 0)
st.contentFrame = contentFrame
local scrollFrame = CreateFrame('ScrollFrame', st:GetName() .. 'ScrollFrame', st, 'FauxScrollFrameTemplate')
scrollFrame:SetScript('OnVerticalScroll', function()
FauxScrollFrame_OnVerticalScroll(ST_ROW_HEIGHT, function() st:RefreshRows() end)
FauxScrollFrame_OnVerticalScroll(ST_ROW_HEIGHT, function() st:Update() end)
end)
scrollFrame:SetAllPoints(contentFrame)
st.scrollFrame = scrollFrame
+1 -1
View File
@@ -13,7 +13,7 @@ frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8)
frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0)
listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.auctions_config)
listing = auction_listing.new(frame.listing, auction_listing.auctions_config)
listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8)
listing:Reset()
listing:SetHandler('OnCellClick', function(cell, button)
+1 -1
View File
@@ -13,7 +13,7 @@ frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8)
frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0)
listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.bids_config)
listing = auction_listing.new(frame.listing, auction_listing.bids_config)
listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8)
listing:Reset()
listing:SetHandler('OnCellClick', function(cell, button)
+11 -11
View File
@@ -51,7 +51,7 @@ end
gui.horizontal_line(frame.inventory, -48)
inventory_listing = item_listing.create(
inventory_listing = item_listing.new(
frame.inventory,
function()
if arg1 == 'LeftButton' then
@@ -67,26 +67,26 @@ inventory_listing = item_listing.create(
end
)
bid_listing = listing.CreateScrollingTable(frame.bid_listing)
bid_listing = listing.new(frame.bid_listing)
bid_listing:SetColInfo{
{name='Auctions', width=.17, align='CENTER'},
{name='Time Left', width=.11, align='CENTER'},
{name='Stack Size', width=.11, align='CENTER'},
{name='Auction Bid|n (per item)', width=.4, align='RIGHT'},
{name='% Hist. Value', width=.21, align='CENTER'},
{name='Time\nLeft', width=.11, align='CENTER'},
{name='Stack\nSize', width=.11, align='CENTER'},
{name='Auction Bid\n(per item)', width=.4, align='RIGHT'},
{name='% Hist.\nValue', width=.21, align='CENTER'},
}
bid_listing:DisableSelection(true)
bid_listing:SetHandler('OnClick', function(table, row_data, column, button)
unit_start_price = undercut(row_data.record, stack_size_slider:GetValue(), button == 'RightButton')
end)
buyout_listing = listing.CreateScrollingTable(frame.buyout_listing)
buyout_listing = listing.new(frame.buyout_listing)
buyout_listing:SetColInfo{
{name='Auctions', width=.17, align='CENTER'},
{name='Time Left', width=.11, align='CENTER'},
{name='Stack Size', width=.12, align='CENTER'},
{name='Auction Buyout|n (per item)', width=.4, align='RIGHT'},
{name='% Hist. Value', width=.20, align='CENTER'},
{name='Time\nLeft', width=.11, align='CENTER'},
{name='Stack\nSize', width=.12, align='CENTER'},
{name='Auction Buyout\n(per item)', width=.4, align='RIGHT'},
{name='% Hist.\nValue', width=.20, align='CENTER'},
}
buyout_listing:DisableSelection(true)
buyout_listing:SetHandler('OnClick', function(table, row_data, column, button)
+5 -5
View File
@@ -24,12 +24,12 @@ frame.saved = CreateFrame('Frame', nil, frame)
frame.saved:SetAllPoints(AuxFrame.content)
frame.saved.favorite = gui.panel(frame.saved)
frame.saved.favorite:SetWidth(415)
frame.saved.favorite:SetWidth(393)
frame.saved.favorite:SetPoint('TOPLEFT', 0, 0)
frame.saved.favorite:SetPoint('BOTTOMLEFT', 0, 0)
frame.saved.recent = gui.panel(frame.saved)
frame.saved.recent:SetWidth(342.5)
frame.saved.recent:SetWidth(364.5)
frame.saved.recent:SetPoint('TOPRIGHT', 0, 0)
frame.saved.recent:SetPoint('BOTTOMRIGHT', 0, 0)
do
@@ -516,7 +516,7 @@ for _ = 1, 5 do
status_bar:Hide()
tinsert(status_bars, status_bar)
local table = auction_listing.CreateAuctionResultsTable(frame.results, auction_listing.search_config)
local table = auction_listing.new(frame.results, auction_listing.search_config)
table:SetHandler('OnCellClick', function(cell, button)
if IsAltKeyDown() and current_search.table:GetSelection().record == cell.row.data.record then
if button == 'LeftButton' then
@@ -534,10 +534,10 @@ for _ = 1, 5 do
tinsert(tables, table)
end
favorite_searches_listing = listing.CreateScrollingTable(frame.saved.favorite)
favorite_searches_listing = listing.new(frame.saved.favorite)
favorite_searches_listing:SetColInfo{{name='Auto Buy', width=.07, align='CENTER'}, {name='Favorite Searches', width=.93}}
recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent)
recent_searches_listing = listing.new(frame.saved.recent)
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
for listing in temp-S(favorite_searches_listing, recent_searches_listing) do