From d34a72dd33b8e80cec011b882e8d533b4171de64 Mon Sep 17 00:00:00 2001 From: Bunny67 Date: Thu, 7 Jun 2018 21:10:09 +0300 Subject: [PATCH] test update AceGUI-3.0-SharedMediaWidgets --- .../BackgroundWidget.lua | 15 +++++--- .../BorderWidget.lua | 15 +++++--- .../FontWidget.lua | 14 ++++--- .../SoundWidget.lua | 14 ++++--- .../StatusbarWidget.lua | 15 +++++--- .../prototypes.lua | 37 +++++++++++-------- 6 files changed, 66 insertions(+), 44 deletions(-) diff --git a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/BackgroundWidget.lua b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/BackgroundWidget.lua index dfdae49..6c3a678 100644 --- a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/BackgroundWidget.lua +++ b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/BackgroundWidget.lua @@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0") local AGSMW = LibStub("AceGUISharedMediaWidgets-1.0") +local next, ipairs, pairs = next, ipairs, pairs +local upper = string.upper +local tinsert, sort, tremove = table.insert, table.sort, table.remove + do local widgetType = "LSM30_Background" local widgetVersion = 11 @@ -15,7 +19,7 @@ do self:ClearAllPoints() self:Hide() self.check:Hide() - table.insert(contentFrameCache, self) + tinsert(contentFrameCache, self) end local function ContentOnClick(this, button) @@ -36,7 +40,7 @@ do local function GetContentLine() local frame if next(contentFrameCache) then - frame = table.remove(contentFrameCache) + frame = tremove(contentFrameCache) else frame = CreateFrame("Button", nil, UIParent) --frame:SetWidth(200) @@ -140,7 +144,7 @@ do end local function textSort(a,b) - return string.upper(a) < string.upper(b) + return upper(a) < upper(b) end local sortedlist = {} @@ -156,13 +160,12 @@ do self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT") self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0) for k, v in pairs(self.list) do - sortedlist[getn(sortedlist)+1] = k + tinsert(sortedlist, k) end - table.sort(sortedlist, textSort) + sort(sortedlist, textSort) for i, k in ipairs(sortedlist) do local f = GetContentLine() f.text:SetText(k) - --print(k) if k == self.value then f.check:Show() end diff --git a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/BorderWidget.lua b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/BorderWidget.lua index 5d77863..b2cd579 100644 --- a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/BorderWidget.lua +++ b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/BorderWidget.lua @@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0") local AGSMW = LibStub("AceGUISharedMediaWidgets-1.0") +local next, ipairs, pairs = next, ipairs, pairs +local upper = string.upper +local tinsert, sort, tremove = table.insert, table.sort, table.remove + do local widgetType = "LSM30_Border" local widgetVersion = 11 @@ -15,7 +19,7 @@ do self:ClearAllPoints() self:Hide() self.check:Hide() - table.insert(contentFrameCache, self) + tinsert(contentFrameCache, self) end local function ContentOnClick(this, button) @@ -39,7 +43,7 @@ do local function GetContentLine() local frame if next(contentFrameCache) then - frame = table.remove(contentFrameCache) + frame = tremove(contentFrameCache) else frame = CreateFrame("Button", nil, UIParent) --frame:SetWidth(200) @@ -135,7 +139,7 @@ do end local function textSort(a,b) - return string.upper(a) < string.upper(b) + return upper(a) < upper(b) end local sortedlist = {} @@ -151,13 +155,12 @@ do self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT") self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0) for k, v in pairs(self.list) do - sortedlist[getn(sortedlist)+1] = k + tinsert(sortedlist, k) end - table.sort(sortedlist, textSort) + sort(sortedlist, textSort) for i, k in ipairs(sortedlist) do local f = GetContentLine() f.text:SetText(k) - --print(k) if k == self.value then f.check:Show() end diff --git a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/FontWidget.lua b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/FontWidget.lua index 3a8229d..6ba564b 100644 --- a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/FontWidget.lua +++ b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/FontWidget.lua @@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0") local AGSMW = LibStub("AceGUISharedMediaWidgets-1.0") +local next, ipairs, pairs = next, ipairs, pairs +local upper = string.upper +local tinsert, sort, tremove = table.insert, table.sort, table.remove + do local widgetType = "LSM30_Font" local widgetVersion = 11 @@ -15,7 +19,7 @@ do self:ClearAllPoints() self:Hide() self.check:Hide() - table.insert(contentFrameCache, self) + tinsert(contentFrameCache, self) end local function ContentOnClick() @@ -29,7 +33,7 @@ do local function GetContentLine() local frame if next(contentFrameCache) then - frame = table.remove(contentFrameCache) + frame = tremove(contentFrameCache) else frame = CreateFrame("Button", nil, UIParent) --frame:SetWidth(200) @@ -120,7 +124,7 @@ do end local function textSort(a,b) - return string.upper(a) < string.upper(b) + return upper(a) < upper(b) end local sortedlist = {} @@ -136,9 +140,9 @@ do self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT") self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0) for k, v in pairs(self.list) do - sortedlist[getn(sortedlist)+1] = k + tinsert(sortedlist, k) end - table.sort(sortedlist, textSort) + sort(sortedlist, textSort) for i, k in ipairs(sortedlist) do local f = GetContentLine() local _, size, outline= f.text:GetFont() diff --git a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/SoundWidget.lua b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/SoundWidget.lua index 962a2e4..3d5ee3f 100644 --- a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/SoundWidget.lua +++ b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/SoundWidget.lua @@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0") local AGSMW = LibStub("AceGUISharedMediaWidgets-1.0") +local next, ipairs, pairs = next, ipairs, pairs +local upper = string.upper +local tinsert, sort, tremove = table.insert, table.sort, table.remove + do local widgetType = "LSM30_Sound" local widgetVersion = 11 @@ -15,7 +19,7 @@ do self:ClearAllPoints() self:Hide() self.check:Hide() - table.insert(contentFrameCache, self) + tinsert(contentFrameCache, self) end local function ContentOnClick() @@ -35,7 +39,7 @@ do local function GetContentLine() local frame if next(contentFrameCache) then - frame = table.remove(contentFrameCache) + frame = tremove(contentFrameCache) else frame = CreateFrame("Button", nil, UIParent) --frame:SetWidth(200) @@ -145,7 +149,7 @@ do end local function textSort(a,b) - return string.upper(a) < string.upper(b) + return upper(a) < upper(b) end local sortedlist = {} @@ -161,9 +165,9 @@ do self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT") self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0) for k, v in pairs(self.list) do - sortedlist[getn(sortedlist)+1] = k + tinsert(sortedlist, k) end - table.sort(sortedlist, textSort) + sort(sortedlist, textSort) for i, k in ipairs(sortedlist) do local f = GetContentLine() f.text:SetText(k) diff --git a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/StatusbarWidget.lua b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/StatusbarWidget.lua index 884cc2b..b7e10cf 100644 --- a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/StatusbarWidget.lua +++ b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/StatusbarWidget.lua @@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0") local AGSMW = LibStub("AceGUISharedMediaWidgets-1.0") +local next, ipairs, pairs = next, ipairs, pairs +local upper = string.upper +local tinsert, sort, tremove = table.insert, table.sort, table.remove + do local widgetType = "LSM30_Statusbar" local widgetVersion = 11 @@ -15,7 +19,7 @@ do self:ClearAllPoints() self:Hide() self.check:Hide() - table.insert(contentFrameCache, self) + tinsert(contentFrameCache, self) end local function ContentOnClick() @@ -29,7 +33,7 @@ do local function GetContentLine() local frame if next(contentFrameCache) then - frame = table.remove(contentFrameCache) + frame = tremove(contentFrameCache) else frame = CreateFrame("Button", nil, UIParent) --frame:SetWidth(200) @@ -129,7 +133,7 @@ do end local function textSort(a,b) - return string.upper(a) < string.upper(b) + return upper(a) < upper(b) end local sortedlist = {} @@ -145,13 +149,12 @@ do self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT") self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0) for k, v in pairs(self.list) do - sortedlist[getn(sortedlist)+1] = k + tinsert(sortedlist, k) end - table.sort(sortedlist, textSort) + sort(sortedlist, textSort) for i, k in ipairs(sortedlist) do local f = GetContentLine() f.text:SetText(k) - --print(k) if k == self.value then f.check:Show() end diff --git a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/prototypes.lua b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/prototypes.lua index b2e8965..cd645eb 100644 --- a/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/prototypes.lua +++ b/ElvUI_Config/Libraries/AceGUI-3.0-SharedMediaWidgets/prototypes.lua @@ -16,6 +16,9 @@ local Media = LibStub("LibSharedMedia-3.0") AGSMW = AGSMW or {} +local next, ipairs = next, ipairs +local tinsert, tremove = table.insert, table.remove + AceGUIWidgetLSMlists = { ['font'] = Media:HashTable("font"), ['sound'] = Media:HashTable("sound"), @@ -160,38 +163,40 @@ do self.slider:SetValue(self.slider:GetValue()+(15*dir*-1)) end + local numContentRepo = 0 local function AddFrame(self, frame) frame:SetParent(self.contentframe) frame:SetFrameStrata(self:GetFrameStrata()) frame:SetFrameLevel(self:GetFrameLevel() + 100) if next(self.contentRepo) then - frame:SetPoint("TOPLEFT", self.contentRepo[getn(self.contentRepo)], "BOTTOMLEFT", 0, 0) - frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0) + frame:SetPoint("TOPLEFT", self.contentRepo[numContentRepo], "BOTTOMLEFT", 0, 0) self.contentframe:SetHeight(self.contentframe:GetHeight() + frame:GetHeight()) - self.contentRepo[getn(self.contentRepo)+1] = frame + numContentRepo = numContentRepo + 1 + self.contentRepo[numContentRepo] = frame else self.contentframe:SetHeight(frame:GetHeight()) - frame:SetPoint("TOPLEFT", self.contentframe, "TOPLEFT", 0, 0) - frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0) + frame:SetPoint("TOPLEFT", self.contentframe, 0, 0) + numContentRepo = 1 self.contentRepo[1] = frame end - if self.contentframe:GetHeight() > UIParent:GetHeight()*2/5 - 20 then - self.scrollframe:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -28, 12) - self:SetHeight(UIParent:GetHeight()*2/5) + if self.contentframe:GetHeight() > GetScreenHeight()*2/5 - 20 then + self.scrollframe:SetWidth(128) + self:SetHeight(GetScreenHeight()*2/5) self.slider:Show() - self:SetScript("OnMouseWheel", OnMouseWheel) + self:SetScript("OnMouseWheel", function() OnMouseWheel(this, arg1) end) self.scrollframe:UpdateScrollChildRect() self.slider:SetMinMaxValues(0, self.contentframe:GetHeight()-self.scrollframe:GetHeight()) else - self.scrollframe:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -14, 12) + self.scrollframe:SetWidth(142) self:SetHeight(self.contentframe:GetHeight()+25) self.slider:Hide() self:SetScript("OnMouseWheel", nil) self.scrollframe:UpdateScrollChildRect() self.slider:SetMinMaxValues(0, 0) end + frame:SetWidth(self.scrollframe:GetWidth()) self.contentframe:SetWidth(self.scrollframe:GetWidth()) end @@ -200,6 +205,7 @@ do frame:ReturnSelf() self.contentRepo[i] = nil end + numContentRepo = 0 end local function slider_OnValueChanged() @@ -210,7 +216,7 @@ do function AGSMW:GetDropDownFrame() local frame if next(DropDownCache) then - frame = table.remove(DropDownCache) + frame = tremove(DropDownCache) else frame = CreateFrame("Frame", nil, UIParent) frame:SetClampedToScreen(true) @@ -225,14 +231,13 @@ do frame.contentframe = contentframe local scrollframe = CreateFrame("ScrollFrame", nil, frame) - scrollframe:SetWidth(160) + scrollframe:SetWidth(128) + scrollframe:SetHeight((GetScreenHeight()*2/5) - 24) scrollframe:SetPoint("TOPLEFT", frame, "TOPLEFT", 14, -13) - scrollframe:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -14, 12) scrollframe:SetScrollChild(contentframe) frame.scrollframe = scrollframe contentframe:SetPoint("TOPLEFT", scrollframe) - contentframe:SetPoint("TOPRIGHT", scrollframe) local bgTex = frame:CreateTexture(nil, "ARTWORK") bgTex:SetAllPoints(scrollframe) @@ -255,7 +260,7 @@ do slider:SetScript("OnValueChanged", slider_OnValueChanged) frame.slider = slider end - frame:SetHeight(UIParent:GetHeight()*2/5) + frame:SetHeight(GetScreenHeight()*2/5) frame.slider:SetValue(0) frame:Show() return frame @@ -267,7 +272,7 @@ do frame:Hide() frame:SetBackdrop(frameBackdrop) frame.bgTex:SetTexture(nil) - table.insert(DropDownCache, frame) + tinsert(DropDownCache, frame) return nil end end