-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtekKonfigDropdown.lua
86 lines (68 loc) · 3 KB
/
tekKonfigDropdown.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Dropdown", 3)
if not lib then return end
oldminor = oldminor or 0
local GameTooltip = GameTooltip
local function HideTooltip() GameTooltip:Hide() end
local function ShowTooltip(self)
if self.frame.tiptext then
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT")
GameTooltip:SetText(self.frame.tiptext, nil, nil, nil, nil, true)
end
end
local function ShowTooltip2(self) ShowTooltip(self.container) end
local function OnClick(self)
ToggleDropDownMenu(nil, nil, self:GetParent())
PlaySound("igMainMenuOptionCheckBoxOn")
end
local function OnHide() CloseDropDownMenus() end
-- Create a dropdown.
-- All args optional, parent recommended
function lib.new(parent, label, ...)
local container = CreateFrame("Button", nil, parent)
container:SetWidth(149+13) container:SetHeight(32+24)
container:SetScript("OnEnter", ShowTooltip)
container:SetScript("OnLeave", HideTooltip)
if select("#", ...) > 0 then container:SetPoint(...) end
local name = "tekKonfigDropdown"..GetTime() -- Sadly, some of these frames must be named
local f = CreateFrame("Frame", name, parent)
f:SetWidth(149) f:SetHeight(32)
f:SetPoint("TOPLEFT", container, -13, -24)
f:EnableMouse(true)
f:SetScript("OnHide", OnHide)
container.frame = f
local ltex = f:CreateTexture(name.."Left", "ARTWORK")
ltex:SetWidth(25) ltex:SetHeight(64)
ltex:SetPoint("TOPLEFT", 0, 17)
ltex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame")
ltex:SetTexCoord(0, 0.1953125, 0, 1)
local rtex = f:CreateTexture(nil, "ARTWORK")
rtex:SetWidth(25) rtex:SetHeight(64)
rtex:SetPoint("RIGHT")
rtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame")
rtex:SetTexCoord(0.8046875, 1, 0, 1)
local mtex = f:CreateTexture(nil, "ARTWORK")
mtex:SetWidth(115) mtex:SetHeight(64)
mtex:SetPoint("LEFT", ltex, "RIGHT")
mtex:SetPoint("RIGHT", rtex, "LEFT")
mtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame")
mtex:SetTexCoord(0.1953125, 0.8046875, 0, 1)
local text = f:CreateFontString(name.."Text", "ARTWORK", "GameFontHighlightSmall")
text:SetWidth(0) text:SetHeight(10)
text:SetPoint("RIGHT", rtex, -43, 2)
text:SetJustifyH("RIGHT")
local button = CreateFrame("Button", nil, f)
button:SetWidth(24) button:SetHeight(24)
button:SetPoint("TOPRIGHT", rtex, -16, -18)
button:SetScript("OnClick", OnClick)
button:SetScript("OnEnter", ShowTooltip2)
button.container = container
button:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up")
button:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down")
button:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight")
button:SetDisabledTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled")
button:GetHighlightTexture():SetBlendMode("ADD")
local labeltext = f:CreateFontString(nil, "BACKGROUND", "GameFontNormal")--GameFontHighlight
labeltext:SetPoint("BOTTOMLEFT", container, "TOPLEFT", 16-13, 3-24)
labeltext:SetText(label)
return f, text, container, labeltext
end