From 20c6b7b37ee744da3b71e71f5d976beae64a317b Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 10 Dec 2016 18:35:04 +0100 Subject: [PATCH] refactoring --- color.lua | 20 +++++++++----------- gui/auction_listing.lua | 13 +++++-------- tabs/auctions/frame.lua | 2 +- tabs/bids/frame.lua | 2 +- tabs/search/frame.lua | 2 +- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/color.lua b/color.lua index 9cc3f93..29471f3 100644 --- a/color.lua +++ b/color.lua @@ -17,21 +17,19 @@ function C(r, g, b, a) return setmetatable(T, mt) end -W = wrapper - -M.color = W-{ - text = W-{enabled = C(255, 254, 250, 1), disabled = C(147, 151, 139, 1)}, - label = W-{enabled = C(216, 225, 211, 1), disabled = C(150, 148, 140, 1)}, +M.color = immutable-{ + text = immutable-{enabled = C(255, 254, 250, 1), disabled = C(147, 151, 139, 1)}, + label = immutable-{enabled = C(216, 225, 211, 1), disabled = C(150, 148, 140, 1)}, link = C(153, 255, 255, 1), - window = W-{background = C(24, 24, 24, .93), border = C(30, 30, 30, 1)}, - panel = W-{background = C(24, 24, 24, 1), border = C(255, 255, 255, .03)}, - content = W-{background = C(42, 42, 42, 1), border = C(0, 0, 0, 0)}, - state = W-{enabled = C(70, 140, 70, 1), disabled = C(140, 70, 70, 1)}, + window = immutable-{background = C(24, 24, 24, .93), border = C(30, 30, 30, 1)}, + panel = immutable-{background = C(24, 24, 24, 1), border = C(255, 255, 255, .03)}, + content = immutable-{background = C(42, 42, 42, 1), border = C(0, 0, 0, 0)}, + state = immutable-{enabled = C(70, 140, 70, 1), disabled = C(140, 70, 70, 1)}, - tooltip = W-{ + tooltip = immutable-{ value = C(255, 255, 154, 1), merchant = C(204, 127, 25, 1), - disenchant = W-{ + disenchant = immutable-{ value = C(25, 153, 153, 1), distribution = C(204, 204, 51, 1), source = C(178, 178, 178, 1), diff --git a/gui/auction_listing.lua b/gui/auction_listing.lua index d2b6b1e..a73e942 100644 --- a/gui/auction_listing.lua +++ b/gui/auction_listing.lua @@ -73,7 +73,6 @@ function item_column_fill(cell, record, _, _, _, indented) end M.search_config = { - rows = 16, { title = 'Item', width = .35, @@ -244,7 +243,6 @@ M.search_config = { } M.auctions_config = { - rows = 20, { title = 'Item', width = .35, @@ -380,7 +378,6 @@ M.auctions_config = { } M.bids_config = { - rows = 20, { title = 'Item', width = .35, @@ -799,7 +796,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.fill(row.cells[i], record, displayNumAuctions, numPlayerAuctions, expandable, indented) end end, @@ -911,10 +908,10 @@ local methods = { end, } -function M.new(parent, config) +function M.new(parent, rows, config) local rt = CreateFrame('Frame', nil, parent) rt.config = config - rt.ROW_HEIGHT = (parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / config.rows + rt.ROW_HEIGHT = (parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / rows rt.expanded = T rt.handlers = T rt.sorts = T @@ -944,7 +941,7 @@ function M.new(parent, config) end) scrollFrame:SetAllPoints(contentFrame) rt.scrollFrame = scrollFrame - FauxScrollFrame_Update(rt.scrollFrame, 0, config.rows, rt.ROW_HEIGHT) + FauxScrollFrame_Update(rt.scrollFrame, 0, rows, rt.ROW_HEIGHT) local scrollBar = _G[scrollFrame:GetName() .. 'ScrollBar'] scrollBar:ClearAllPoints() @@ -1002,7 +999,7 @@ function M.new(parent, config) end rt.rows = T - for i = 1, config.rows do + for i = 1, rows do local row = CreateFrame('Frame', nil, rt.contentFrame) row:SetHeight(rt.ROW_HEIGHT) if i == 1 then diff --git a/tabs/auctions/frame.lua b/tabs/auctions/frame.lua index bf88b7f..919f90d 100644 --- a/tabs/auctions/frame.lua +++ b/tabs/auctions/frame.lua @@ -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.new(frame.listing, auction_listing.auctions_config) +listing = auction_listing.new(frame.listing, 20, auction_listing.auctions_config) listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8) listing:Reset() listing:SetHandler('OnCellClick', function(cell, button) diff --git a/tabs/bids/frame.lua b/tabs/bids/frame.lua index 1464973..c99425f 100644 --- a/tabs/bids/frame.lua +++ b/tabs/bids/frame.lua @@ -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.new(frame.listing, auction_listing.bids_config) +listing = auction_listing.new(frame.listing, 20, auction_listing.bids_config) listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8) listing:Reset() listing:SetHandler('OnCellClick', function(cell, button) diff --git a/tabs/search/frame.lua b/tabs/search/frame.lua index a53b5d6..7433aef 100644 --- a/tabs/search/frame.lua +++ b/tabs/search/frame.lua @@ -516,7 +516,7 @@ for _ = 1, 5 do status_bar:Hide() tinsert(status_bars, status_bar) - local table = auction_listing.new(frame.results, auction_listing.search_config) + local table = auction_listing.new(frame.results, 16, 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