vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Anchoring Code by Ammo - taken from BigWigs |
||
3 | ]] |
||
4 | |||
5 | function HotCandy:SetupFrames() |
||
6 | local f, t |
||
7 | |||
8 | f, _, _ = GameFontNormal:GetFont() |
||
9 | |||
10 | self.frames = {} |
||
11 | self.frames.anchor = CreateFrame("Frame", "HotCandyBarAnchor", UIParent) |
||
12 | self.frames.anchor.owner = self |
||
13 | self.frames.anchor:Hide() |
||
14 | |||
15 | self.frames.anchor:SetWidth(175) |
||
16 | self.frames.anchor:SetHeight(75) |
||
17 | self.frames.anchor:SetBackdrop({ |
||
18 | bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", tile = true, tileSize = 16, |
||
19 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, |
||
20 | insets = {left = 4, right = 4, top = 4, bottom = 4}, |
||
21 | }) |
||
22 | self.frames.anchor:SetBackdropBorderColor(.5, .5, .5) |
||
23 | self.frames.anchor:SetBackdropColor(0,0,0) |
||
24 | self.frames.anchor:ClearAllPoints() |
||
25 | self.frames.anchor:SetPoint("CENTER", UIParent, "CENTER", 0, 0) |
||
26 | self.frames.anchor:EnableMouse(true) |
||
27 | self.frames.anchor:RegisterForDrag("LeftButton") |
||
28 | self.frames.anchor:SetMovable(true) |
||
29 | self.frames.anchor:SetScript("OnDragStart", function() this:StartMoving() end) |
||
30 | self.frames.anchor:SetScript("OnDragStop", function() this:StopMovingOrSizing() this.owner:SavePosition() end) |
||
31 | |||
32 | |||
33 | self.frames.cfade = self.frames.anchor:CreateTexture(nil, "BORDER") |
||
34 | self.frames.cfade:SetWidth(169) |
||
35 | self.frames.cfade:SetHeight(25) |
||
36 | self.frames.cfade:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") |
||
37 | self.frames.cfade:SetPoint("TOP", self.frames.anchor, "TOP", 0, -4) |
||
38 | self.frames.cfade:SetBlendMode("ADD") |
||
39 | self.frames.cfade:SetGradientAlpha("VERTICAL", .1, .1, .1, 0, .25, .25, .25, 1) |
||
40 | self.frames.anchor.Fade = self.frames.fade |
||
41 | |||
42 | self.frames.cheader = self.frames.anchor:CreateFontString(nil,"OVERLAY") |
||
43 | self.frames.cheader:SetFont(f, 14) |
||
44 | self.frames.cheader:SetWidth(150) |
||
45 | self.frames.cheader:SetText("Bars") |
||
46 | self.frames.cheader:SetTextColor(1, .8, 0) |
||
47 | self.frames.cheader:ClearAllPoints() |
||
48 | self.frames.cheader:SetPoint("TOP", self.frames.anchor, "TOP", 0, -10) |
||
49 | |||
50 | self.frames.leftbutton = CreateFrame("Button", nil, self.frames.anchor) |
||
51 | self.frames.leftbutton.owner = self |
||
52 | self.frames.leftbutton:SetWidth(40) |
||
53 | self.frames.leftbutton:SetHeight(25) |
||
54 | self.frames.leftbutton:SetPoint("RIGHT", self.frames.anchor, "CENTER", -10, -15) |
||
55 | self.frames.leftbutton:SetScript( "OnClick", function() self:TestBars() end ) |
||
56 | |||
57 | |||
58 | t = self.frames.leftbutton:CreateTexture() |
||
59 | t:SetWidth(50) |
||
60 | t:SetHeight(32) |
||
61 | t:SetPoint("CENTER", self.frames.leftbutton, "CENTER") |
||
62 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up") |
||
63 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
64 | self.frames.leftbutton:SetNormalTexture(t) |
||
65 | |||
66 | t = self.frames.leftbutton:CreateTexture(nil, "BACKGROUND") |
||
67 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down") |
||
68 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
69 | t:SetAllPoints(self.frames.leftbutton) |
||
70 | self.frames.leftbutton:SetPushedTexture(t) |
||
71 | |||
72 | t = self.frames.leftbutton:CreateTexture() |
||
73 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Highlight") |
||
74 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
75 | t:SetAllPoints(self.frames.leftbutton) |
||
76 | t:SetBlendMode("ADD") |
||
77 | self.frames.leftbutton:SetHighlightTexture(t) |
||
78 | self.frames.leftbuttontext = self.frames.leftbutton:CreateFontString(nil,"OVERLAY") |
||
79 | self.frames.leftbuttontext:SetFontObject(GameFontHighlight) |
||
80 | self.frames.leftbuttontext:SetText("Test") |
||
81 | self.frames.leftbuttontext:SetAllPoints(self.frames.leftbutton) |
||
82 | |||
83 | self.frames.rightbutton = CreateFrame("Button", nil, self.frames.anchor) |
||
84 | self.frames.rightbutton.owner = self |
||
85 | self.frames.rightbutton:SetWidth(40) |
||
86 | self.frames.rightbutton:SetHeight(25) |
||
87 | self.frames.rightbutton:SetPoint("LEFT", self.frames.anchor, "CENTER", 10, -15) |
||
88 | self.frames.rightbutton:SetScript( "OnClick", function() self:HideAnchors() end ) |
||
89 | |||
90 | |||
91 | t = self.frames.rightbutton:CreateTexture() |
||
92 | t:SetWidth(50) |
||
93 | t:SetHeight(32) |
||
94 | t:SetPoint("CENTER", self.frames.rightbutton, "CENTER") |
||
95 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Up") |
||
96 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
97 | self.frames.rightbutton:SetNormalTexture(t) |
||
98 | |||
99 | t = self.frames.rightbutton:CreateTexture(nil, "BACKGROUND") |
||
100 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Down") |
||
101 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
102 | t:SetAllPoints(self.frames.rightbutton) |
||
103 | self.frames.rightbutton:SetPushedTexture(t) |
||
104 | |||
105 | t = self.frames.rightbutton:CreateTexture() |
||
106 | t:SetTexture("Interface\\Buttons\\UI-Panel-Button-Highlight") |
||
107 | t:SetTexCoord(0, 0.625, 0, 0.6875) |
||
108 | t:SetAllPoints(self.frames.rightbutton) |
||
109 | t:SetBlendMode("ADD") |
||
110 | self.frames.rightbutton:SetHighlightTexture(t) |
||
111 | self.frames.rightbuttontext = self.frames.rightbutton:CreateFontString(nil,"OVERLAY") |
||
112 | self.frames.rightbuttontext:SetFontObject(GameFontHighlight) |
||
113 | self.frames.rightbuttontext:SetText("Close") |
||
114 | self.frames.rightbuttontext:SetAllPoints(self.frames.rightbutton) |
||
115 | |||
116 | self:RestorePosition() |
||
117 | end |
||
118 | |||
119 | function HotCandy:ShowAnchors() |
||
120 | self.frames.anchor:Show() |
||
121 | end |
||
122 | |||
123 | |||
124 | function HotCandy:HideAnchors() |
||
125 | self.frames.anchor:Hide() |
||
126 | end |
||
127 | |||
128 | function HotCandy:SavePosition() |
||
129 | local f = self.frames.anchor |
||
130 | local s = f:GetEffectiveScale() |
||
131 | |||
132 | self.db.profile.posx = f:GetLeft() * s |
||
133 | self.db.profile.posy = f:GetTop() * s |
||
134 | end |
||
135 | |||
136 | function HotCandy:TestBars() |
||
137 | for i=1,4 do |
||
138 | self:ShowCandyBar("Test "..i, 15+(i*4)) |
||
139 | end |
||
140 | end |
||
141 | |||
142 | function HotCandy:RestorePosition() |
||
143 | local x = self.db.profile.posx |
||
144 | local y = self.db.profile.posy |
||
145 | |||
146 | if not x or not y then return end |
||
147 | |||
148 | local f = self.frames.anchor |
||
149 | local s = f:GetEffectiveScale() |
||
150 | |||
151 | f:ClearAllPoints() |
||
152 | f:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x / s, y / s) |
||
153 | end |