major listing code change

This commit is contained in:
Manuel Simon Hirsig
2016-01-24 11:29:40 +01:00
parent 6ec8915a41
commit 66671f864f
6 changed files with 196 additions and 98 deletions
+1
View File
@@ -16,6 +16,7 @@ scan_util.lua
stack.lua stack.lua
post.lua post.lua
sheet.lua sheet.lua
listing_util.lua
history.lua history.lua
info.xml info.xml
completion.xml completion.xml
+12 -3
View File
@@ -29,7 +29,10 @@ public.views = {
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0) Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
end, end,
on_row_leave = function (sheet, row_index) on_row_leave = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(0) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
if sheet.data[data_index][1].signature ~= Aux.util.safe_index{private.selected, 'signature'} then
sheet.rows[row_index].highlight:SetAlpha(0)
end
AuxTooltip:Hide() AuxTooltip:Hide()
ResetCursor() ResetCursor()
end, end,
@@ -171,7 +174,10 @@ public.views = {
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0) Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
end, end,
on_row_leave = function (sheet, row_index) on_row_leave = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(0) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
if sheet.data[data_index].signature ~= Aux.util.safe_index{private.selected, 'signature'} then
sheet.rows[row_index].highlight:SetAlpha(0)
end
AuxTooltip:Hide() AuxTooltip:Hide()
ResetCursor() ResetCursor()
end, end,
@@ -315,7 +321,10 @@ public.views = {
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0) Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
end, end,
on_row_leave = function (sheet, row_index) on_row_leave = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(0) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
if sheet.data[data_index].signature ~= Aux.util.safe_index{private.selected, 'signature'} then
sheet.rows[row_index].highlight:SetAlpha(0)
end
AuxTooltip:Hide() AuxTooltip:Hide()
ResetCursor() ResetCursor()
end, end,
+69 -31
View File
@@ -16,6 +16,10 @@ function group_alpha_setter(cell, group)
cell:SetAlpha(Aux.util.all(group, function(auction) return auction.gone end) and 0.3 or 1) cell:SetAlpha(Aux.util.all(group, function(auction) return auction.gone end) and 0.3 or 1)
end end
function private.clear_selection()
private.listings[aux_view]:clear_selection()
end
public.recently_searched_config = { public.recently_searched_config = {
on_row_click = function (sheet, row_index) on_row_click = function (sheet, row_index)
PlaySound('igMainMenuOptionCheckBoxOn') PlaySound('igMainMenuOptionCheckBoxOn')
@@ -23,12 +27,6 @@ public.recently_searched_config = {
AuxItemSearchFrameItemItemInputBox:Hide() AuxItemSearchFrameItemItemInputBox:Hide()
public.set_item(sheet.data[data_index].item_id) public.set_item(sheet.data[data_index].item_id)
end, end,
on_row_enter = function(sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(.5)
end,
on_row_leave = function(sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(0)
end,
columns = { columns = {
{ {
title = 'Item', title = 'Item',
@@ -77,17 +75,14 @@ public.views = {
name = 'Buyout', name = 'Buyout',
on_row_click = function (sheet, row_index) on_row_click = function (sheet, row_index)
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
sheet:clear_selection()
sheet:select(sheet.data[data_index])
public.on_row_click(Aux.util.filter(sheet.data[data_index], function(auction) return not auction.gone end)[1] or sheet.data[data_index][1]) public.on_row_click(Aux.util.filter(sheet.data[data_index], function(auction) return not auction.gone end)[1] or sheet.data[data_index][1])
end, end,
on_row_enter = function (sheet, row_index) on_row_enter = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(.5)
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0) Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
end, end,
on_row_leave = function (sheet, row_index) on_row_leave = function (sheet, row_index)
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
if sheet.data[data_index][1].signature ~= Aux.util.safe_index{private.selected, 'signature'} then
sheet.rows[row_index].highlight:SetAlpha(0)
end
AuxTooltip:Hide() AuxTooltip:Hide()
ResetCursor() ResetCursor()
end, end,
@@ -103,11 +98,6 @@ public.views = {
row_setter = function(row, group) row_setter = function(row, group)
row.itemstring = Aux.info.itemstring(group[1].item_id, group[1].suffix_id, nil, group[1].enchant_id) row.itemstring = Aux.info.itemstring(group[1].item_id, group[1].suffix_id, nil, group[1].enchant_id)
row.EnhTooltip_info = group[1].EnhTooltip_info row.EnhTooltip_info = group[1].EnhTooltip_info
if group[1].signature == Aux.util.safe_index{private.selected, 'signature'} then
row.highlight:SetAlpha(.5)
else
row.highlight:SetAlpha(0)
end
end, end,
columns = { columns = {
{ {
@@ -185,14 +175,14 @@ public.views = {
name = 'Bid', name = 'Bid',
on_row_click = function (sheet, row_index) on_row_click = function (sheet, row_index)
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
sheet:clear_selection()
sheet:select(sheet.data[data_index])
public.on_row_click(sheet.data[data_index]) public.on_row_click(sheet.data[data_index])
end, end,
on_row_enter = function (sheet, row_index) on_row_enter = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(.5)
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0) Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
end, end,
on_row_leave = function (sheet, row_index) on_row_leave = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(0)
AuxTooltip:Hide() AuxTooltip:Hide()
ResetCursor() ResetCursor()
end, end,
@@ -287,14 +277,14 @@ public.views = {
name = 'Full', name = 'Full',
on_row_click = function (sheet, row_index) on_row_click = function (sheet, row_index)
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame) local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
sheet:clear_selection()
sheet:select(sheet.data[data_index])
public.on_row_click(sheet.data[data_index]) public.on_row_click(sheet.data[data_index])
end, end,
on_row_enter = function (sheet, row_index) on_row_enter = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(.5)
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0) Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
end, end,
on_row_leave = function (sheet, row_index) on_row_leave = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(0)
AuxTooltip:Hide() AuxTooltip:Hide()
ResetCursor() ResetCursor()
end, end,
@@ -463,7 +453,7 @@ public.views = {
} }
function public.on_close() function public.on_close()
private.selected = nil private.clear_selection()
private.buyout_button:Disable() private.buyout_button:Disable()
end end
@@ -477,6 +467,56 @@ function public.on_open()
end end
function public.on_load() function public.on_load()
private.listings = {}
do
local config = public.recently_searched_config
private.listings.recently_searched = Aux.sheet.create{
frame = AuxItemSearchFrameRecentlySearchedListing,
columns = config.columns,
sort_order = config.sort_order,
row_setter = config.row_setter,
on_row_click = config.on_row_click,
on_row_enter = config.on_row_enter,
on_row_leave = config.on_row_leave,
plain = true,
}
end
do
local config = public.views[Aux.view.BUYOUT]
private.listings[Aux.view.BUYOUT] = Aux.sheet.create{
frame = AuxItemSearchFrameAuctionsBuyListing,
columns = config.columns,
sort_order = config.sort_order,
row_setter = config.row_setter,
on_row_click = config.on_row_click,
on_row_enter = config.on_row_enter,
on_row_leave = config.on_row_leave,
}
end
do
local config = public.views[Aux.view.BID]
private.listings[Aux.view.BID] = Aux.sheet.create{
frame = AuxItemSearchFrameAuctionsBidListing,
columns = config.columns,
sort_order = config.sort_order,
row_setter = config.row_setter,
on_row_click = config.on_row_click,
on_row_enter = config.on_row_enter,
on_row_leave = config.on_row_leave,
}
end
do
local config = public.views[Aux.view.FULL]
private.listings[Aux.view.FULL] = Aux.sheet.create{
frame = AuxItemSearchFrameAuctionsFullListing,
columns = config.columns,
sort_order = config.sort_order,
row_setter = config.row_setter,
on_row_click = config.on_row_click,
on_row_enter = config.on_row_enter,
on_row_leave = config.on_row_leave,
}
end
do do
local btn = Aux.gui.button(AuxItemSearchFrameItem, 15, '$parentRefreshButton') local btn = Aux.gui.button(AuxItemSearchFrameItem, 15, '$parentRefreshButton')
btn:SetPoint('BOTTOMLEFT', 8, 15) btn:SetPoint('BOTTOMLEFT', 8, 15)
@@ -577,18 +617,18 @@ function update_listing()
if aux_view == Aux.view.BUYOUT then if aux_view == Aux.view.BUYOUT then
AuxItemSearchFrameAuctionsBuyListing:Show() AuxItemSearchFrameAuctionsBuyListing:Show()
local buy_records = auctions and Aux.util.filter(auctions, function(auction) return auction.owner ~= UnitName('player') and auction.buyout_price end) or {} local buy_records = auctions and Aux.util.filter(auctions, function(auction) return auction.owner ~= UnitName('player') and auction.buyout_price end) or {}
Aux.sheet.populate(AuxItemSearchFrameAuctionsBuyListing.sheet, auctions and Aux.util.group_by(buy_records, function(a1, a2) return a1.item_id == a2.item_id and a1.suffix_id == a2.suffix_id and a1.enchant_id == a2.enchant_id and a1.aux_quantity == a2.aux_quantity and a1.buyout_price == a2.buyout_price end) or {}) Aux.sheet.populate(private.listings[Aux.view.BUYOUT], auctions and Aux.util.group_by(buy_records, function(a1, a2) return a1.item_id == a2.item_id and a1.suffix_id == a2.suffix_id and a1.enchant_id == a2.enchant_id and a1.aux_quantity == a2.aux_quantity and a1.buyout_price == a2.buyout_price end) or {})
AuxItemSearchFrameAuctions:SetWidth(AuxItemSearchFrameAuctionsBuyListing:GetWidth() + 40) AuxItemSearchFrameAuctions:SetWidth(AuxItemSearchFrameAuctionsBuyListing:GetWidth() + 40)
AuxFrame:SetWidth(AuxItemSearchFrameItem:GetWidth() + AuxItemSearchFrameAuctions:GetWidth() + 15) AuxFrame:SetWidth(AuxItemSearchFrameItem:GetWidth() + AuxItemSearchFrameAuctions:GetWidth() + 15)
elseif aux_view == Aux.view.BID then elseif aux_view == Aux.view.BID then
AuxItemSearchFrameAuctionsBidListing:Show() AuxItemSearchFrameAuctionsBidListing:Show()
local bid_records = auctions and Aux.util.filter(auctions, function(auction) return auction.owner ~= UnitName('player') end) or {} local bid_records = auctions and Aux.util.filter(auctions, function(auction) return auction.owner ~= UnitName('player') end) or {}
Aux.sheet.populate(AuxItemSearchFrameAuctionsBidListing.sheet, bid_records) Aux.sheet.populate(private.listings[Aux.view.BID], bid_records)
AuxItemSearchFrameAuctions:SetWidth(AuxItemSearchFrameAuctionsBidListing:GetWidth() + 40) AuxItemSearchFrameAuctions:SetWidth(AuxItemSearchFrameAuctionsBidListing:GetWidth() + 40)
AuxFrame:SetWidth(AuxItemSearchFrameItem:GetWidth() + AuxItemSearchFrameAuctions:GetWidth() + 15) AuxFrame:SetWidth(AuxItemSearchFrameItem:GetWidth() + AuxItemSearchFrameAuctions:GetWidth() + 15)
elseif aux_view == Aux.view.FULL then elseif aux_view == Aux.view.FULL then
AuxItemSearchFrameAuctionsFullListing:Show() AuxItemSearchFrameAuctionsFullListing:Show()
Aux.sheet.populate(AuxItemSearchFrameAuctionsFullListing.sheet, auctions or {}) Aux.sheet.populate(private.listings[Aux.view.FULL], auctions or {})
AuxItemSearchFrameAuctions:SetWidth(AuxItemSearchFrameAuctionsFullListing:GetWidth() + 40) AuxItemSearchFrameAuctions:SetWidth(AuxItemSearchFrameAuctionsFullListing:GetWidth() + 40)
AuxFrame:SetWidth(AuxItemSearchFrameItem:GetWidth() + AuxItemSearchFrameAuctions:GetWidth() + 15) AuxFrame:SetWidth(AuxItemSearchFrameItem:GetWidth() + AuxItemSearchFrameAuctions:GetWidth() + 15)
end end
@@ -601,12 +641,13 @@ function hide_sheet()
end end
function public.set_view(view) function public.set_view(view)
private.clear_selection()
aux_view = view aux_view = view
update_listing() update_listing()
end end
function private.update_recently_searched() function private.update_recently_searched()
Aux.sheet.populate(AuxItemSearchFrameRecentlySearchedListing.sheet, aux_recently_searched) Aux.sheet.populate(private.listings.recently_searched, aux_recently_searched)
end end
function public.set_item(item_id) function public.set_item(item_id)
@@ -754,7 +795,7 @@ function find_auction(entry, express_mode, buyout_mode)
Aux.scan_util.find_auction(test, search_query, entry.page, private.status_bar, function(index) Aux.scan_util.find_auction(test, search_query, entry.page, private.status_bar, function(index)
if not index then if not index then
entry.gone = true entry.gone = true
private.selected = nil private.clear_selection()
refresh = true refresh = true
return return
end end
@@ -768,7 +809,7 @@ function find_auction(entry, express_mode, buyout_mode)
entry.gone = true entry.gone = true
end end
PlaceAuctionBid('list', index, amount) PlaceAuctionBid('list', index, amount)
private.selected = nil private.clear_selection()
refresh = true refresh = true
else else
private.buyout_button:SetScript('OnClick', function() private.buyout_button:SetScript('OnClick', function()
@@ -783,7 +824,7 @@ function find_auction(entry, express_mode, buyout_mode)
PlaceAuctionBid('list', index, amount) PlaceAuctionBid('list', index, amount)
private.buyout_button:Disable() private.buyout_button:Disable()
private.selected = nil private.clear_selection()
refresh = true refresh = true
end) end)
private.buyout_button:Enable() private.buyout_button:Enable()
@@ -793,9 +834,6 @@ end
function public.on_row_click(entry) function public.on_row_click(entry)
private.selected = entry
update_listing()
local express_mode = IsAltKeyDown() local express_mode = IsAltKeyDown()
local buyout_mode = arg1 == 'LeftButton' local buyout_mode = arg1 == 'LeftButton'
+60 -60
View File
@@ -86,21 +86,21 @@
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor> <Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
<Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor> <Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
</Anchors> </Anchors>
<Scripts> <!--<Scripts>-->
<OnLoad> <!--<OnLoad>-->
local config = Aux.item_search_frame.recently_searched_config <!--local config = Aux.item_search_frame.recently_searched_config-->
this.sheet = Aux.sheet.create{ <!--this.sheet = Aux.sheet.create{-->
frame = this, <!--frame = this,-->
columns = config.columns, <!--columns = config.columns,-->
sort_order = config.sort_order, <!--sort_order = config.sort_order,-->
row_setter = config.row_setter, <!--row_setter = config.row_setter,-->
on_row_click = config.on_row_click, <!--on_row_click = config.on_row_click,-->
on_row_enter = config.on_row_enter, <!--on_row_enter = config.on_row_enter,-->
on_row_leave = config.on_row_leave, <!--on_row_leave = config.on_row_leave,-->
plain = true, <!--plain = true,-->
} <!--}-->
</OnLoad> <!--</OnLoad>-->
</Scripts> <!--</Scripts>-->
</Frame> </Frame>
</Frames> </Frames>
</Frame> </Frame>
@@ -120,63 +120,63 @@
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor> <Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
<Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor> <Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
</Anchors> </Anchors>
<Scripts> <!--<Scripts>-->
<OnLoad> <!--<OnLoad>-->
local config = Aux.item_search_frame.views[1] <!--local config = Aux.item_search_frame.views[1]-->
this.sheet = Aux.sheet.create{ <!--this.sheet = Aux.sheet.create{-->
frame = this, <!--frame = this,-->
columns = config.columns, <!--columns = config.columns,-->
sort_order = config.sort_order, <!--sort_order = config.sort_order,-->
row_setter = config.row_setter, <!--row_setter = config.row_setter,-->
on_row_click = config.on_row_click, <!--on_row_click = config.on_row_click,-->
on_row_enter = config.on_row_enter, <!--on_row_enter = config.on_row_enter,-->
on_row_leave = config.on_row_leave, <!--on_row_leave = config.on_row_leave,-->
on_row_update = config.on_row_update, <!--on_row_update = config.on_row_update,-->
} <!--}-->
</OnLoad> <!--</OnLoad>-->
</Scripts> <!--</Scripts>-->
</Frame> </Frame>
<Frame name="$parentBidListing" hidden="true"> <Frame name="$parentBidListing" hidden="true">
<Anchors> <Anchors>
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor> <Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
<Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor> <Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
</Anchors> </Anchors>
<Scripts> <!--<Scripts>-->
<OnLoad> <!--<OnLoad>-->
local config = Aux.item_search_frame.views[2] <!--local config = Aux.item_search_frame.views[2]-->
this.sheet = Aux.sheet.create{ <!--this.sheet = Aux.sheet.create{-->
frame = this, <!--frame = this,-->
columns = config.columns, <!--columns = config.columns,-->
sort_order = config.sort_order, <!--sort_order = config.sort_order,-->
row_setter = config.row_setter, <!--row_setter = config.row_setter,-->
on_row_click = config.on_row_click, <!--on_row_click = config.on_row_click,-->
on_row_enter = config.on_row_enter, <!--on_row_enter = config.on_row_enter,-->
on_row_leave = config.on_row_leave, <!--on_row_leave = config.on_row_leave,-->
on_row_update = config.on_row_update, <!--on_row_update = config.on_row_update,-->
} <!--}-->
</OnLoad> <!--</OnLoad>-->
</Scripts> <!--</Scripts>-->
</Frame> </Frame>
<Frame name="$parentFullListing" hidden="true"> <Frame name="$parentFullListing" hidden="true">
<Anchors> <Anchors>
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor> <Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
<Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor> <Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
</Anchors> </Anchors>
<Scripts> <!--<Scripts>-->
<OnLoad> <!--<OnLoad>-->
local config = Aux.item_search_frame.views[3] <!--local config = Aux.item_search_frame.views[3]-->
this.sheet = Aux.sheet.create{ <!--this.sheet = Aux.sheet.create{-->
frame = this, <!--frame = this,-->
columns = config.columns, <!--columns = config.columns,-->
sort_order = config.sort_order, <!--sort_order = config.sort_order,-->
row_setter = config.row_setter, <!--row_setter = config.row_setter,-->
on_row_click = config.on_row_click, <!--on_row_click = config.on_row_click,-->
on_row_enter = config.on_row_enter, <!--on_row_enter = config.on_row_enter,-->
on_row_leave = config.on_row_leave, <!--on_row_leave = config.on_row_leave,-->
on_row_update = config.on_row_update, <!--on_row_update = config.on_row_update,-->
} <!--}-->
</OnLoad> <!--</OnLoad>-->
</Scripts> <!--</Scripts>-->
</Frame> </Frame>
</Frames> </Frames>
</Frame> </Frame>
+15
View File
@@ -0,0 +1,15 @@
local m = {}
Aux.listing_util = m
function m.money_column(name, getter)
return {
title = name,
width = 80,
comparator = function(datum1, datum2) return Aux.util.compare(getter(datum1), getter(datum2), Aux.util.GT) end,
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
cell_setter = function(cell, datum)
cell.text:SetText(Aux.util.money_string(getter(datum)))
-- group_alpha_setter(cell, getter(datum))
end,
}
end
+37 -2
View File
@@ -48,6 +48,11 @@ function public.render(sheet)
if datum then if datum then
if sheet.row_setter then if sheet.row_setter then
if sheet.selected[datum] then
row.highlight:SetAlpha(0.5)
else
row.highlight:SetAlpha(0)
end
sheet.row_setter(row, datum) sheet.row_setter(row, datum)
end end
row:Show() row:Show()
@@ -186,8 +191,21 @@ function public.create(params)
local row_idx = row_index local row_idx = row_index
row:SetScript('OnClick', function() if sheet.on_row_click then sheet.on_row_click(sheet, row_idx) end end) row:SetScript('OnClick', function() if sheet.on_row_click then sheet.on_row_click(sheet, row_idx) end end)
row:SetScript('OnEnter', function() if sheet.on_row_enter then sheet.on_row_enter(sheet, row_idx) end end) row:SetScript('OnEnter', function()
row:SetScript('OnLeave', function() if sheet.on_row_leave then sheet.on_row_leave(sheet, row_idx) end end) sheet.rows[row_idx].highlight:SetAlpha(.5)
if sheet.on_row_enter then
sheet.on_row_enter(sheet, row_idx)
end
end)
row:SetScript('OnLeave', function()
local data_index = row_idx + FauxScrollFrame_GetOffset(sheet.scroll_frame)
if not sheet.selected[sheet.data[data_index]] then
sheet.rows[row_idx].highlight:SetAlpha(0)
end
if sheet.on_row_leave then
sheet.on_row_leave(sheet, row_idx)
end
end)
row:SetScript('OnUpdate', function() if sheet.on_row_update then sheet.on_row_update(sheet, row_idx) end end) row:SetScript('OnUpdate', function() if sheet.on_row_update then sheet.on_row_update(sheet, row_idx) end end)
row.cells = {} row.cells = {}
@@ -232,6 +250,7 @@ function public.create(params)
rows = rows, rows = rows,
columns = params.columns, columns = params.columns,
data = {}, data = {},
selected = {},
sort_order = params.sort_order, sort_order = params.sort_order,
row_setter = params.row_setter, row_setter = params.row_setter,
on_row_click = params.on_row_click, on_row_click = params.on_row_click,
@@ -241,6 +260,21 @@ function public.create(params)
} }
scroll_frame.sheet = sheet scroll_frame.sheet = sheet
function sheet:clear_selection()
self.selected = {}
public.render(self)
end
function sheet:select(datum)
self.selected[datum] = true
public.render(self)
end
function sheet:deselect(datum)
self.selected[datum] = false
public.render(self)
end
return sheet return sheet
end end
@@ -272,6 +306,7 @@ end
function public.populate(sheet, data) function public.populate(sheet, data)
sheet.data = data sheet.data = data
sheet.selected = {}
Aux.util.merge_sort(sheet.data, private.row_comparator(sheet)) Aux.util.merge_sort(sheet.data, private.row_comparator(sheet))