test update AceGUI-3.0-SharedMediaWidgets

This commit is contained in:
Bunny67
2018-06-07 21:10:09 +03:00
parent abe3e4cd83
commit d34a72dd33
6 changed files with 66 additions and 44 deletions
@@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0")
local AGSMW = LibStub("AceGUISharedMediaWidgets-1.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 do
local widgetType = "LSM30_Background" local widgetType = "LSM30_Background"
local widgetVersion = 11 local widgetVersion = 11
@@ -15,7 +19,7 @@ do
self:ClearAllPoints() self:ClearAllPoints()
self:Hide() self:Hide()
self.check:Hide() self.check:Hide()
table.insert(contentFrameCache, self) tinsert(contentFrameCache, self)
end end
local function ContentOnClick(this, button) local function ContentOnClick(this, button)
@@ -36,7 +40,7 @@ do
local function GetContentLine() local function GetContentLine()
local frame local frame
if next(contentFrameCache) then if next(contentFrameCache) then
frame = table.remove(contentFrameCache) frame = tremove(contentFrameCache)
else else
frame = CreateFrame("Button", nil, UIParent) frame = CreateFrame("Button", nil, UIParent)
--frame:SetWidth(200) --frame:SetWidth(200)
@@ -140,7 +144,7 @@ do
end end
local function textSort(a,b) local function textSort(a,b)
return string.upper(a) < string.upper(b) return upper(a) < upper(b)
end end
local sortedlist = {} local sortedlist = {}
@@ -156,13 +160,12 @@ do
self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT") self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0) self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0)
for k, v in pairs(self.list) do for k, v in pairs(self.list) do
sortedlist[getn(sortedlist)+1] = k tinsert(sortedlist, k)
end end
table.sort(sortedlist, textSort) sort(sortedlist, textSort)
for i, k in ipairs(sortedlist) do for i, k in ipairs(sortedlist) do
local f = GetContentLine() local f = GetContentLine()
f.text:SetText(k) f.text:SetText(k)
--print(k)
if k == self.value then if k == self.value then
f.check:Show() f.check:Show()
end end
@@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0")
local AGSMW = LibStub("AceGUISharedMediaWidgets-1.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 do
local widgetType = "LSM30_Border" local widgetType = "LSM30_Border"
local widgetVersion = 11 local widgetVersion = 11
@@ -15,7 +19,7 @@ do
self:ClearAllPoints() self:ClearAllPoints()
self:Hide() self:Hide()
self.check:Hide() self.check:Hide()
table.insert(contentFrameCache, self) tinsert(contentFrameCache, self)
end end
local function ContentOnClick(this, button) local function ContentOnClick(this, button)
@@ -39,7 +43,7 @@ do
local function GetContentLine() local function GetContentLine()
local frame local frame
if next(contentFrameCache) then if next(contentFrameCache) then
frame = table.remove(contentFrameCache) frame = tremove(contentFrameCache)
else else
frame = CreateFrame("Button", nil, UIParent) frame = CreateFrame("Button", nil, UIParent)
--frame:SetWidth(200) --frame:SetWidth(200)
@@ -135,7 +139,7 @@ do
end end
local function textSort(a,b) local function textSort(a,b)
return string.upper(a) < string.upper(b) return upper(a) < upper(b)
end end
local sortedlist = {} local sortedlist = {}
@@ -151,13 +155,12 @@ do
self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT") self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0) self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0)
for k, v in pairs(self.list) do for k, v in pairs(self.list) do
sortedlist[getn(sortedlist)+1] = k tinsert(sortedlist, k)
end end
table.sort(sortedlist, textSort) sort(sortedlist, textSort)
for i, k in ipairs(sortedlist) do for i, k in ipairs(sortedlist) do
local f = GetContentLine() local f = GetContentLine()
f.text:SetText(k) f.text:SetText(k)
--print(k)
if k == self.value then if k == self.value then
f.check:Show() f.check:Show()
end end
@@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0")
local AGSMW = LibStub("AceGUISharedMediaWidgets-1.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 do
local widgetType = "LSM30_Font" local widgetType = "LSM30_Font"
local widgetVersion = 11 local widgetVersion = 11
@@ -15,7 +19,7 @@ do
self:ClearAllPoints() self:ClearAllPoints()
self:Hide() self:Hide()
self.check:Hide() self.check:Hide()
table.insert(contentFrameCache, self) tinsert(contentFrameCache, self)
end end
local function ContentOnClick() local function ContentOnClick()
@@ -29,7 +33,7 @@ do
local function GetContentLine() local function GetContentLine()
local frame local frame
if next(contentFrameCache) then if next(contentFrameCache) then
frame = table.remove(contentFrameCache) frame = tremove(contentFrameCache)
else else
frame = CreateFrame("Button", nil, UIParent) frame = CreateFrame("Button", nil, UIParent)
--frame:SetWidth(200) --frame:SetWidth(200)
@@ -120,7 +124,7 @@ do
end end
local function textSort(a,b) local function textSort(a,b)
return string.upper(a) < string.upper(b) return upper(a) < upper(b)
end end
local sortedlist = {} local sortedlist = {}
@@ -136,9 +140,9 @@ do
self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT") self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0) self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0)
for k, v in pairs(self.list) do for k, v in pairs(self.list) do
sortedlist[getn(sortedlist)+1] = k tinsert(sortedlist, k)
end end
table.sort(sortedlist, textSort) sort(sortedlist, textSort)
for i, k in ipairs(sortedlist) do for i, k in ipairs(sortedlist) do
local f = GetContentLine() local f = GetContentLine()
local _, size, outline= f.text:GetFont() local _, size, outline= f.text:GetFont()
@@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0")
local AGSMW = LibStub("AceGUISharedMediaWidgets-1.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 do
local widgetType = "LSM30_Sound" local widgetType = "LSM30_Sound"
local widgetVersion = 11 local widgetVersion = 11
@@ -15,7 +19,7 @@ do
self:ClearAllPoints() self:ClearAllPoints()
self:Hide() self:Hide()
self.check:Hide() self.check:Hide()
table.insert(contentFrameCache, self) tinsert(contentFrameCache, self)
end end
local function ContentOnClick() local function ContentOnClick()
@@ -35,7 +39,7 @@ do
local function GetContentLine() local function GetContentLine()
local frame local frame
if next(contentFrameCache) then if next(contentFrameCache) then
frame = table.remove(contentFrameCache) frame = tremove(contentFrameCache)
else else
frame = CreateFrame("Button", nil, UIParent) frame = CreateFrame("Button", nil, UIParent)
--frame:SetWidth(200) --frame:SetWidth(200)
@@ -145,7 +149,7 @@ do
end end
local function textSort(a,b) local function textSort(a,b)
return string.upper(a) < string.upper(b) return upper(a) < upper(b)
end end
local sortedlist = {} local sortedlist = {}
@@ -161,9 +165,9 @@ do
self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT") self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0) self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0)
for k, v in pairs(self.list) do for k, v in pairs(self.list) do
sortedlist[getn(sortedlist)+1] = k tinsert(sortedlist, k)
end end
table.sort(sortedlist, textSort) sort(sortedlist, textSort)
for i, k in ipairs(sortedlist) do for i, k in ipairs(sortedlist) do
local f = GetContentLine() local f = GetContentLine()
f.text:SetText(k) f.text:SetText(k)
@@ -6,6 +6,10 @@ local Media = LibStub("LibSharedMedia-3.0")
local AGSMW = LibStub("AceGUISharedMediaWidgets-1.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 do
local widgetType = "LSM30_Statusbar" local widgetType = "LSM30_Statusbar"
local widgetVersion = 11 local widgetVersion = 11
@@ -15,7 +19,7 @@ do
self:ClearAllPoints() self:ClearAllPoints()
self:Hide() self:Hide()
self.check:Hide() self.check:Hide()
table.insert(contentFrameCache, self) tinsert(contentFrameCache, self)
end end
local function ContentOnClick() local function ContentOnClick()
@@ -29,7 +33,7 @@ do
local function GetContentLine() local function GetContentLine()
local frame local frame
if next(contentFrameCache) then if next(contentFrameCache) then
frame = table.remove(contentFrameCache) frame = tremove(contentFrameCache)
else else
frame = CreateFrame("Button", nil, UIParent) frame = CreateFrame("Button", nil, UIParent)
--frame:SetWidth(200) --frame:SetWidth(200)
@@ -129,7 +133,7 @@ do
end end
local function textSort(a,b) local function textSort(a,b)
return string.upper(a) < string.upper(b) return upper(a) < upper(b)
end end
local sortedlist = {} local sortedlist = {}
@@ -145,13 +149,12 @@ do
self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT") self.dropdown:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0) self.dropdown:SetPoint("TOPRIGHT", self.frame, "BOTTOMRIGHT", width < 160 and (160 - width) or 0, 0)
for k, v in pairs(self.list) do for k, v in pairs(self.list) do
sortedlist[getn(sortedlist)+1] = k tinsert(sortedlist, k)
end end
table.sort(sortedlist, textSort) sort(sortedlist, textSort)
for i, k in ipairs(sortedlist) do for i, k in ipairs(sortedlist) do
local f = GetContentLine() local f = GetContentLine()
f.text:SetText(k) f.text:SetText(k)
--print(k)
if k == self.value then if k == self.value then
f.check:Show() f.check:Show()
end end
@@ -16,6 +16,9 @@ local Media = LibStub("LibSharedMedia-3.0")
AGSMW = AGSMW or {} AGSMW = AGSMW or {}
local next, ipairs = next, ipairs
local tinsert, tremove = table.insert, table.remove
AceGUIWidgetLSMlists = { AceGUIWidgetLSMlists = {
['font'] = Media:HashTable("font"), ['font'] = Media:HashTable("font"),
['sound'] = Media:HashTable("sound"), ['sound'] = Media:HashTable("sound"),
@@ -160,38 +163,40 @@ do
self.slider:SetValue(self.slider:GetValue()+(15*dir*-1)) self.slider:SetValue(self.slider:GetValue()+(15*dir*-1))
end end
local numContentRepo = 0
local function AddFrame(self, frame) local function AddFrame(self, frame)
frame:SetParent(self.contentframe) frame:SetParent(self.contentframe)
frame:SetFrameStrata(self:GetFrameStrata()) frame:SetFrameStrata(self:GetFrameStrata())
frame:SetFrameLevel(self:GetFrameLevel() + 100) frame:SetFrameLevel(self:GetFrameLevel() + 100)
if next(self.contentRepo) then if next(self.contentRepo) then
frame:SetPoint("TOPLEFT", self.contentRepo[getn(self.contentRepo)], "BOTTOMLEFT", 0, 0) frame:SetPoint("TOPLEFT", self.contentRepo[numContentRepo], "BOTTOMLEFT", 0, 0)
frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0)
self.contentframe:SetHeight(self.contentframe:GetHeight() + frame:GetHeight()) self.contentframe:SetHeight(self.contentframe:GetHeight() + frame:GetHeight())
self.contentRepo[getn(self.contentRepo)+1] = frame numContentRepo = numContentRepo + 1
self.contentRepo[numContentRepo] = frame
else else
self.contentframe:SetHeight(frame:GetHeight()) self.contentframe:SetHeight(frame:GetHeight())
frame:SetPoint("TOPLEFT", self.contentframe, "TOPLEFT", 0, 0) frame:SetPoint("TOPLEFT", self.contentframe, 0, 0)
frame:SetPoint("RIGHT", self.contentframe, "RIGHT", 0, 0) numContentRepo = 1
self.contentRepo[1] = frame self.contentRepo[1] = frame
end end
if self.contentframe:GetHeight() > UIParent:GetHeight()*2/5 - 20 then if self.contentframe:GetHeight() > GetScreenHeight()*2/5 - 20 then
self.scrollframe:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -28, 12) self.scrollframe:SetWidth(128)
self:SetHeight(UIParent:GetHeight()*2/5) self:SetHeight(GetScreenHeight()*2/5)
self.slider:Show() self.slider:Show()
self:SetScript("OnMouseWheel", OnMouseWheel) self:SetScript("OnMouseWheel", function() OnMouseWheel(this, arg1) end)
self.scrollframe:UpdateScrollChildRect() self.scrollframe:UpdateScrollChildRect()
self.slider:SetMinMaxValues(0, self.contentframe:GetHeight()-self.scrollframe:GetHeight()) self.slider:SetMinMaxValues(0, self.contentframe:GetHeight()-self.scrollframe:GetHeight())
else else
self.scrollframe:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -14, 12) self.scrollframe:SetWidth(142)
self:SetHeight(self.contentframe:GetHeight()+25) self:SetHeight(self.contentframe:GetHeight()+25)
self.slider:Hide() self.slider:Hide()
self:SetScript("OnMouseWheel", nil) self:SetScript("OnMouseWheel", nil)
self.scrollframe:UpdateScrollChildRect() self.scrollframe:UpdateScrollChildRect()
self.slider:SetMinMaxValues(0, 0) self.slider:SetMinMaxValues(0, 0)
end end
frame:SetWidth(self.scrollframe:GetWidth())
self.contentframe:SetWidth(self.scrollframe:GetWidth()) self.contentframe:SetWidth(self.scrollframe:GetWidth())
end end
@@ -200,6 +205,7 @@ do
frame:ReturnSelf() frame:ReturnSelf()
self.contentRepo[i] = nil self.contentRepo[i] = nil
end end
numContentRepo = 0
end end
local function slider_OnValueChanged() local function slider_OnValueChanged()
@@ -210,7 +216,7 @@ do
function AGSMW:GetDropDownFrame() function AGSMW:GetDropDownFrame()
local frame local frame
if next(DropDownCache) then if next(DropDownCache) then
frame = table.remove(DropDownCache) frame = tremove(DropDownCache)
else else
frame = CreateFrame("Frame", nil, UIParent) frame = CreateFrame("Frame", nil, UIParent)
frame:SetClampedToScreen(true) frame:SetClampedToScreen(true)
@@ -225,14 +231,13 @@ do
frame.contentframe = contentframe frame.contentframe = contentframe
local scrollframe = CreateFrame("ScrollFrame", nil, frame) 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("TOPLEFT", frame, "TOPLEFT", 14, -13)
scrollframe:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -14, 12)
scrollframe:SetScrollChild(contentframe) scrollframe:SetScrollChild(contentframe)
frame.scrollframe = scrollframe frame.scrollframe = scrollframe
contentframe:SetPoint("TOPLEFT", scrollframe) contentframe:SetPoint("TOPLEFT", scrollframe)
contentframe:SetPoint("TOPRIGHT", scrollframe)
local bgTex = frame:CreateTexture(nil, "ARTWORK") local bgTex = frame:CreateTexture(nil, "ARTWORK")
bgTex:SetAllPoints(scrollframe) bgTex:SetAllPoints(scrollframe)
@@ -255,7 +260,7 @@ do
slider:SetScript("OnValueChanged", slider_OnValueChanged) slider:SetScript("OnValueChanged", slider_OnValueChanged)
frame.slider = slider frame.slider = slider
end end
frame:SetHeight(UIParent:GetHeight()*2/5) frame:SetHeight(GetScreenHeight()*2/5)
frame.slider:SetValue(0) frame.slider:SetValue(0)
frame:Show() frame:Show()
return frame return frame
@@ -267,7 +272,7 @@ do
frame:Hide() frame:Hide()
frame:SetBackdrop(frameBackdrop) frame:SetBackdrop(frameBackdrop)
frame.bgTex:SetTexture(nil) frame.bgTex:SetTexture(nil)
table.insert(DropDownCache, frame) tinsert(DropDownCache, frame)
return nil return nil
end end
end end