17_18_LochModan.lua confirmed working, added in .toc
[WoW-TourGuide.git] / WidgetWarlock.lua
blob821c771683dfdaca8bb1c65e9f10a5e50430043e
3 WidgetWarlock = {}
6 WidgetWarlock.TooltipBorderBG = {
7 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
8 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
9 edgeSize = 16,
10 insets = {left = 4, right = 4, top = 4, bottom = 4}
14 function WidgetWarlock.SummonCheckBox(size, parent, ...)
15 local check = CreateFrame("CheckButton", nil, parent)
16 check:SetWidth(size)
17 check:SetHeight(size)
18 if select(1, ...) then check:SetPoint(...) end
20 check:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up")
21 check:SetPushedTexture("Interface\\Buttons\\UI-CheckBox-Down")
22 check:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
23 check:SetDisabledCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled")
24 check:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check")
26 return check
27 end
30 function WidgetWarlock.SummonTexture(parent, layer, w, h, texture, ...)
31 local tex = parent:CreateTexture(nil, layer)
32 if w then tex:SetWidth(w) end
33 if h then tex:SetHeight(h) end
34 tex:SetTexture(texture)
35 if select(1, ...) then tex:SetPoint(...) end
36 return tex
37 end
40 function WidgetWarlock.SummonFontString(parent, layer, inherit, text, ...)
41 local fs = parent:CreateFontString(nil, layer, inherit)
42 fs:SetText(text)
43 if select(1, ...) then fs:SetPoint(...) end
44 return fs
45 end
48 -----------------------
49 -- Fade In --
50 -----------------------
52 local fadetimes = setmetatable({}, {__index = function() return 1 end})
53 local elapsed = setmetatable({}, {__index = function() return 0 end})
56 function WidgetWarlock.SetFadeTime(frame, time)
57 assert(frame, "No frame passed")
58 assert(type(time) == "number", "Time must be a number")
59 assert(time > 0, "Time must be positive")
60 fadetimes[frame] = time
61 end
64 function WidgetWarlock.FadeIn(frame, elap)
65 elapsed[frame] = elapsed[frame] + elap
66 if elapsed[frame] > fadetimes[frame] then
67 frame:SetScript("OnUpdate", nil)
68 frame:SetAlpha(1)
69 elapsed[frame] = 0
70 else frame:SetAlpha(elapsed[frame]/fadetimes[frame]) end
71 end
74 --------------------------
75 -- Scroll Bar --
76 --------------------------
78 function WidgetWarlock.ConjureScrollBar(parent, hasborder)
79 local f = CreateFrame("Slider", nil, parent)
80 f:SetWidth(16)
82 local upbutt = CreateFrame("Button", nil, f, "UIPanelScrollUpButtonTemplate")
83 upbutt:SetPoint("BOTTOM", f, "TOP")
85 local downbutt = CreateFrame("Button", nil, f, "UIPanelScrollDownButtonTemplate")
86 downbutt:SetPoint("TOP", f, "BOTTOM")
88 f:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
89 local thumb = f:GetThumbTexture()
90 thumb:SetHeight(16)
91 thumb:SetWidth(16)
92 thumb:SetTexCoord(0.25, 0.75, 0.25, 0.75)
94 if hasborder then
95 local uptext = f:CreateTexture(nil, "BACKGROUND")
96 uptext:SetWidth(31)
97 uptext:SetHeight(256)
98 uptext:SetPoint("TOPLEFT", upbutt, "TOPLEFT", -7, 5)
99 uptext:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar")
100 uptext:SetTexCoord(0, 0.484375, 0, 1.0)
102 local downtex = f:CreateTexture(nil, "BACKGROUND")
103 downtex:SetWidth(31)
104 downtex:SetHeight(106)
105 downtex:SetPoint("BOTTOMLEFT", downbutt, "BOTTOMLEFT", -7, -3)
106 downtex:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ScrollBar")
107 downtex:SetTexCoord(0.515625, 1.0, 0, 0.4140625)
110 return f, upbutt, downbutt