From 3c92bf430f04ac8fdb21a5f1fa5558ef90691403 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Tue, 9 Aug 2016 01:28:01 +0200 Subject: [PATCH] some refactoring, slight style changes --- gui.lua | 7 +++---- tables/auction_listing.lua | 40 +++++++++++++++++++------------------- tables/item_listing.lua | 17 +++++++++------- tables/listing.lua | 12 ++++++------ tabs/post/frames.lua | 7 ------- tabs/search/core.lua | 2 ++ 6 files changed, 41 insertions(+), 44 deletions(-) diff --git a/gui.lua b/gui.lua index d5166db..83932a9 100644 --- a/gui.lua +++ b/gui.lua @@ -430,16 +430,15 @@ function public.item(parent) item:SetHeight(40) local btn = CreateFrame('CheckButton', 'aux_frame'..aux.id(), item, 'ActionButtonTemplate') item.button = btn - btn:SetPoint('LEFT', 2, 0.5) + btn:SetPoint('LEFT', 2, .5) btn:SetHighlightTexture(nil) btn:RegisterForClicks() - btn:EnableMouse(nil) item.texture = getglobal(btn:GetName()..'Icon') - item.texture:SetTexCoord(0.06,0.94,0.06,0.94) + item.texture:SetTexCoord(.06, .94, .06, .94) item.name = aux.gui.label(btn, 15) item.name:SetJustifyH('LEFT') item.name:SetPoint('LEFT', btn, 'RIGHT', 10, 0) - item.name:SetPoint('RIGHT', item, 'RIGHT', -10, 0.5) + item.name:SetPoint('RIGHT', item, 'RIGHT', -10, .5) item.count = getglobal(btn:GetName()..'Count') item.count:SetTextHeight(17) return item diff --git a/tables/auction_listing.lua b/tables/auction_listing.lua index 2d0d744..a6e6747 100644 --- a/tables/auction_listing.lua +++ b/tables/auction_listing.lua @@ -25,8 +25,6 @@ function private.item_column_init(rt, cell) cell.spacer = spacer local iconBtn = CreateFrame('Button', nil, cell) - iconBtn:SetBackdrop({edgeFile=[[Interface\Buttons\WHITE8X8]], edgeSize=1.5}) - iconBtn:SetBackdropBorderColor(0, 1, 0, 0) iconBtn:SetPoint('TOPLEFT', spacer, 'TOPRIGHT') iconBtn:SetHeight(rt.ROW_HEIGHT) iconBtn:SetWidth(rt.ROW_HEIGHT) @@ -37,6 +35,8 @@ function private.item_column_init(rt, cell) local icon = iconBtn:CreateTexture(nil, 'ARTWORK') icon:SetPoint('TOPLEFT', 2, -2) icon:SetPoint('BOTTOMRIGHT', -2, 2) + icon:SetTexCoord(.08, .94, .08, .94) + cell.iconBtn = iconBtn cell.icon = icon @@ -556,12 +556,12 @@ local methods = { OnContentSizeChanged = function() local width = arg1 local rt = this:GetParent() - for i, cell in ipairs(rt.headCells) do + for _, cell in rt.headCells do cell:SetWidth(cell.info.width * width) end - for _, row in ipairs(rt.rows) do - for i, cell in ipairs(row.cells) do + for _, row in rt.rows do + for i, cell in row.cells do cell:SetWidth(rt.headCells[i].info.width * width) end end @@ -574,7 +574,7 @@ local methods = { if button == 'RightButton' and rt.headCells[this.columnIndex].info.isPrice then aux_price_per_unit = not aux_price_per_unit - for i, cell in ipairs(rt.headCells) do + for _, cell in rt.headCells do if cell.info.isPrice then cell:SetText(cell.info.title[aux_price_per_unit and 1 or 2]) end @@ -720,7 +720,7 @@ local methods = { for _, info in ipairs(self.rowInfo) do local totalAuctions, totalPlayerAuctions = 0, 0 - for _, childInfo in ipairs(info.children) do + for _, childInfo in info.children do totalAuctions = totalAuctions + childInfo.numAuctions if aux.is_player(childInfo.record.owner) then totalPlayerAuctions = totalPlayerAuctions + childInfo.numAuctions @@ -733,10 +733,10 @@ local methods = { UpdateRows = function(self) -- hide all the rows - for _, row in ipairs(self.rows) do row:Hide() end + for _, row in self.rows do row:Hide() end -- update sorting highlights - for _, cell in ipairs(self.headCells) do + for _, cell in self.headCells do local tex = cell:GetNormalTexture() tex:SetTexture([[Interface\AddOns\aux-AddOn\WorldStateFinalScore-Highlight]]) tex:SetTexCoord(0.017, 1, 0.083, 0.909) @@ -785,7 +785,7 @@ local methods = { return tostring(a) < tostring(b) end - for i, info in ipairs(self.rowInfo) do + for _, info in ipairs(self.rowInfo) do sort(info.children, sort_helper) end sort(self.rowInfo, sort_helper) @@ -794,11 +794,11 @@ local methods = { -- update all the rows local rowIndex = 1 - FauxScrollFrame_GetOffset(self.scrollFrame) - for i, info in ipairs(self.rowInfo) do + for _, info in ipairs(self.rowInfo) do if self.expanded[info.expandKey] then -- show each of the rows for this base item since it's expanded - for j, childInfo in ipairs(info.children) do - self:SetRowInfo(rowIndex, childInfo.record, childInfo.numAuctions, 0, j > 1, false, info.expandKey, childInfo.numAuctions) + for i, childInfo in info.children do + self:SetRowInfo(rowIndex, childInfo.record, childInfo.numAuctions, 0, i > 1, false, info.expandKey, childInfo.numAuctions) rowIndex = rowIndex + 1 end else @@ -821,7 +821,7 @@ local methods = { end row.data = {record=record, expandable=expandable, indented=indented, numAuctions=numAuctions, expandKey=expandKey} - for i, column_config in ipairs(self.config) do + for i, column_config in self.config do column_config.set(row.cells[i], record, displayNumAuctions, numPlayerAuctions, expandable, indented) end end, @@ -835,7 +835,7 @@ local methods = { self.selected = selectedData and self.selected or nil -- show / hide highlight accordingly - for _, row in ipairs(self.rows) do + for _, row in self.rows do if self.selected and row.data and row.data.record.search_signature == self.selected.search_signature then row.highlight:Show() else @@ -873,7 +873,7 @@ local methods = { -- get index of selected row local prevSelectedIndex if rt.selected then - for index, row in ipairs(rt.rows) do + for index, row in rt.rows do if row:IsVisible() and row.data and row.data.record == rt.selected then prevSelectedIndex = index end @@ -973,7 +973,7 @@ local methods = { if not self.selected then return end local selectedData for _, info in ipairs(self.rowInfo) do - for _, childInfo in ipairs(info.children) do + for _, childInfo in info.children do if childInfo.record.search_signature == self.selected.search_signature then selectedData = childInfo break @@ -986,7 +986,7 @@ local methods = { GetTotalAuctions = function(self) local numResults = 0 for _, info in ipairs(self.rowInfo) do - for _, childInfo in ipairs(info.children) do + for _, childInfo in info.children do numResults = numResults + childInfo.numAuctions end end @@ -1014,7 +1014,7 @@ function public.CreateAuctionResultsTable(parent, config) end rt:SetScript('OnShow', function() - for i, cell in ipairs(this.headCells) do + for _, cell in this.headCells do if cell.info.isPrice then cell:SetText(cell.info.title[aux_price_per_unit and 1 or 2]) end @@ -1053,7 +1053,7 @@ function public.CreateAuctionResultsTable(parent, config) -- create the header cells rt.headCells = {} - for i, column_config in ipairs(rt.config) do + for i, column_config in rt.config do local cell = CreateFrame('Button', rtName..'HeadCol'..i, rt.contentFrame) cell:SetHeight(HEAD_HEIGHT) if i == 1 then diff --git a/tables/item_listing.lua b/tables/item_listing.lua index 706435e..7c4932a 100644 --- a/tables/item_listing.lua +++ b/tables/item_listing.lua @@ -10,7 +10,7 @@ function public.render(item_listing) local rows = item_listing.rows - for i, row in ipairs(rows) do + for i, row in rows do local item_record = item_listing.item_records[i + offset] if item_record then @@ -36,7 +36,7 @@ function public.render(item_listing) end end -function public.create(parent, on_click, on_enter, on_leave, selected) +function public.create(parent, on_click, selected) local name = 'aux_item_list' local id = 1 @@ -75,25 +75,28 @@ function public.create(parent, on_click, on_enter, on_leave, selected) row:SetHeight(ROW_HEIGHT) row:SetWidth(195) row:SetPoint('TOPLEFT', content, 2, -((row_index-1) * ROW_HEIGHT)) + row:RegisterForClicks('LeftButtonUp', 'RightButtonUp') row:SetScript('OnClick', on_click) row:SetScript('OnEnter', function() row.highlight:Show() - on_enter() end) row:SetScript('OnLeave', function() if not selected(row.item_record) then row.highlight:Hide() end - on_leave() end) row.item = aux.gui.item(row) - row.item:EnableMouse(nil) row.item:SetScale(0.9) row.item:SetPoint('LEFT', 2.5, 0) row.item:SetPoint('RIGHT', -2.5, 0) - row:RegisterForClicks('LeftButtonUp', 'RightButtonUp') - + row.item.button:SetScript('OnEnter', function() + aux.info.set_tooltip(row.item_record.itemstring, this, 'ANCHOR_RIGHT') + end) + row.item.button:SetScript('OnLeave', function() + GameTooltip:Hide() + end) + local highlight = row:CreateTexture() highlight:SetAllPoints(row) highlight:Hide() diff --git a/tables/listing.lua b/tables/listing.lua index 48af33d..4082460 100644 --- a/tables/listing.lua +++ b/tables/listing.lua @@ -126,7 +126,7 @@ local methods = { st.rows[i].highlight:Hide() end - for colNum, col in ipairs(st.rows[i].cols) do + for colNum, col in st.rows[i].cols do if st.colInfo[colNum] then local colData = data.cols[colNum] if type(colData.value) == 'function' then @@ -250,7 +250,7 @@ local methods = { end -- adjust head col widths - for colNum, col in ipairs(st.headCols) do + for colNum, col in st.headCols do if st.colInfo[colNum] then col:Show() col:SetWidth(st.colInfo[colNum].width * width) @@ -268,7 +268,7 @@ local methods = { end -- adjust rows widths - for rowNum, row in ipairs(st.rows) do + for rowNum, row in st.rows do if rowNum > st.sizes.numRows then row.data = nil row:Hide() @@ -278,7 +278,7 @@ local methods = { while getn(row.cols) < getn(st.colInfo) do st:AddRowCol(rowNum) end - for colNum, col in ipairs(row.cols) do + for colNum, col in row.cols do if st.headCols[colNum] and st.colInfo[colNum] then col:Show() col:SetWidth(st.colInfo[colNum].width * width) @@ -324,7 +324,7 @@ local methods = { tinsert(st.headCols, col) -- add new cells to the rows - for rowNum, row in ipairs(st.rows) do + for rowNum, row in st.rows do while getn(row.cols) < getn(st.headCols) do st:AddRowCol(rowNum) end @@ -390,7 +390,7 @@ local methods = { SetHeadFontSize = function(st, size) st.sizes.headFontSize = size -- update the text size of the head cols - for _, col in ipairs(st.headCols) do + for _, col in st.headCols do if st.sizes.headFontSize then col.text:SetFont(aux.gui.config.font, st.sizes.headFontSize) else diff --git a/tabs/post/frames.lua b/tabs/post/frames.lua index ae761cf..34403b6 100644 --- a/tabs/post/frames.lua +++ b/tabs/post/frames.lua @@ -50,12 +50,6 @@ private.item_listing = aux.item_listing.create( aux.search_tab.execute(nil, false) end end, - function() - aux.info.set_tooltip(this.item_record.itemstring, this, 'ANCHOR_RIGHT') - end, - function() - GameTooltip:Hide() - end, function(item_record) return item_record == m.selected_item end @@ -119,7 +113,6 @@ end do local item = aux.gui.item(m.frame.parameters) item:SetPoint('TOPLEFT', 6, -6) - item.button:EnableMouse(true) item.button:SetScript('OnEnter', function() if m.selected_item then aux.info.set_tooltip(m.selected_item.itemstring, this, 'ANCHOR_RIGHT') diff --git a/tabs/search/core.lua b/tabs/search/core.lua index 50f855f..51a77ef 100644 --- a/tabs/search/core.lua +++ b/tabs/search/core.lua @@ -920,6 +920,8 @@ do end m.filter_display:SetWidth(widest_line) m.filter_display:SetText(text) + local scroll_frame = m.filter_display:GetParent() + scroll_frame:SetHorizontalScroll(max(scroll_frame:GetWidth() - widest_line, scroll_frame:GetHorizontalScroll())) end end