|
Tercio@11
|
1
|
|
Tercio@11
|
2 local DF = _G ["DetailsFramework"]
|
|
Tercio@20
|
3 if (not DF or not DetailsFrameworkCanLoad) then
|
|
Tercio@20
|
4 return
|
|
Tercio@20
|
5 end
|
|
Tercio@20
|
6
|
|
Tercio@11
|
7 local _
|
|
Tercio@11
|
8
|
|
Tercio@11
|
9 local window = DF:NewPanel (UIParent, nil, "DetailsFrameworkImageEdit", nil, 100, 100, false)
|
|
Tercio@11
|
10 window:SetPoint ("center", UIParent, "center")
|
|
Tercio@11
|
11 window:SetResizable (true)
|
|
Tercio@11
|
12 window:SetMovable (true)
|
|
Tercio@11
|
13 tinsert (UISpecialFrames, "DetailsFrameworkImageEdit")
|
|
Tercio@11
|
14 window:SetFrameStrata ("TOOLTIP")
|
|
Tercio@11
|
15 window:SetMaxResize (266, 226)
|
|
Tercio@11
|
16
|
|
Tercio@11
|
17 window.hooks = {}
|
|
Tercio@11
|
18
|
|
Tercio@11
|
19 local background = DF:NewImage (window, nil, nil, nil, "background", nil, nil, "$parentBackground")
|
|
Tercio@11
|
20 background:SetAllPoints()
|
|
Tercio@11
|
21 background:SetTexture (0, 0, 0, .8)
|
|
Tercio@11
|
22
|
|
Tercio@11
|
23 local edit_texture = DF:NewImage (window, nil, 300, 250, "artwork", nil, nil, "$parentImage")
|
|
Tercio@11
|
24 edit_texture:SetAllPoints()
|
|
Tercio@11
|
25
|
|
Tercio@11
|
26 local background_frame = CreateFrame ("frame", "DetailsFrameworkImageEditBackground", DetailsFrameworkImageEdit)
|
|
Tercio@11
|
27 background_frame:SetPoint ("topleft", DetailsFrameworkImageEdit, "topleft", -10, 12)
|
|
Tercio@11
|
28 background_frame:SetFrameStrata ("DIALOG")
|
|
Tercio@11
|
29 background_frame:SetSize (400, 252)
|
|
Tercio@11
|
30
|
|
Tercio@11
|
31 background_frame:SetResizable (true)
|
|
Tercio@11
|
32 background_frame:SetMovable (true)
|
|
Tercio@11
|
33
|
|
Tercio@11
|
34 background_frame:SetScript ("OnMouseDown", function()
|
|
Tercio@11
|
35 window:StartMoving()
|
|
Tercio@11
|
36 end)
|
|
Tercio@11
|
37 background_frame:SetScript ("OnMouseUp", function()
|
|
Tercio@11
|
38 window:StopMovingOrSizing()
|
|
Tercio@11
|
39 end)
|
|
Tercio@11
|
40
|
|
Tercio@22
|
41 background_frame:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
|
|
Tercio@22
|
42 background_frame:SetBackdropColor (0, 0, 0, 0.9)
|
|
Tercio@22
|
43 background_frame:SetBackdropBorderColor (0, 0, 0, 1)
|
|
Tercio@11
|
44
|
|
Tercio@11
|
45 local haveHFlip = false
|
|
Tercio@11
|
46 local haveVFlip = false
|
|
Tercio@11
|
47
|
|
Tercio@11
|
48 --> Top Slider
|
|
Tercio@11
|
49
|
|
Tercio@11
|
50 local topCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageTopCoord")
|
|
Tercio@11
|
51 topCoordTexture:SetPoint ("topleft", window, "topleft")
|
|
Tercio@11
|
52 topCoordTexture:SetPoint ("topright", window, "topright")
|
|
Tercio@11
|
53 topCoordTexture.color = "red"
|
|
Tercio@11
|
54 topCoordTexture.height = 1
|
|
Tercio@11
|
55 topCoordTexture.alpha = .2
|
|
Tercio@11
|
56
|
|
Tercio@11
|
57 local topSlider = DF:NewSlider (window, nil, "$parentTopSlider", "topSlider", 100, 100, 0.1, 100, 0.1, 0)
|
|
Tercio@11
|
58 topSlider:SetAllPoints (window.widget)
|
|
Tercio@11
|
59 topSlider:SetOrientation ("VERTICAL")
|
|
Tercio@11
|
60 topSlider.backdrop = nil
|
|
Tercio@11
|
61 topSlider.fractional = true
|
|
Tercio@11
|
62 topSlider:SetHook ("OnEnter", function() return true end)
|
|
Tercio@11
|
63 topSlider:SetHook ("OnLeave", function() return true end)
|
|
Tercio@11
|
64
|
|
Tercio@11
|
65 local topSliderThumpTexture = topSlider:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
66 topSliderThumpTexture:SetTexture (1, 1, 1)
|
|
Tercio@11
|
67 topSliderThumpTexture:SetWidth (512)
|
|
Tercio@11
|
68 topSliderThumpTexture:SetHeight (3)
|
|
Tercio@11
|
69 topSlider:SetThumbTexture (topSliderThumpTexture)
|
|
Tercio@11
|
70
|
|
Tercio@11
|
71 topSlider:SetHook ("OnValueChange", function (_, _, value)
|
|
Tercio@11
|
72 topCoordTexture.image:SetHeight (window.frame:GetHeight()/100*value)
|
|
Tercio@11
|
73 if (window.callback_func) then
|
|
Tercio@22
|
74 window.accept (nil, nil, true)
|
|
Tercio@11
|
75 end
|
|
Tercio@11
|
76 end)
|
|
Tercio@11
|
77
|
|
Tercio@11
|
78 topSlider:Hide()
|
|
Tercio@11
|
79
|
|
Tercio@11
|
80 --> Bottom Slider
|
|
Tercio@11
|
81
|
|
Tercio@11
|
82 local bottomCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageBottomCoord")
|
|
Tercio@11
|
83 bottomCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0)
|
|
Tercio@11
|
84 bottomCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0)
|
|
Tercio@11
|
85 bottomCoordTexture.color = "red"
|
|
Tercio@11
|
86 bottomCoordTexture.height = 1
|
|
Tercio@11
|
87 bottomCoordTexture.alpha = .2
|
|
Tercio@11
|
88
|
|
Tercio@11
|
89 local bottomSlider= DF:NewSlider (window, nil, "$parentBottomSlider", "bottomSlider", 100, 100, 0.1, 100, 0.1, 100)
|
|
Tercio@11
|
90 bottomSlider:SetAllPoints (window.widget)
|
|
Tercio@11
|
91 bottomSlider:SetOrientation ("VERTICAL")
|
|
Tercio@11
|
92 bottomSlider.backdrop = nil
|
|
Tercio@11
|
93 bottomSlider.fractional = true
|
|
Tercio@11
|
94 bottomSlider:SetHook ("OnEnter", function() return true end)
|
|
Tercio@11
|
95 bottomSlider:SetHook ("OnLeave", function() return true end)
|
|
Tercio@11
|
96
|
|
Tercio@11
|
97 local bottomSliderThumpTexture = bottomSlider:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
98 bottomSliderThumpTexture:SetTexture (1, 1, 1)
|
|
Tercio@11
|
99 bottomSliderThumpTexture:SetWidth (512)
|
|
Tercio@11
|
100 bottomSliderThumpTexture:SetHeight (3)
|
|
Tercio@11
|
101 bottomSlider:SetThumbTexture (bottomSliderThumpTexture)
|
|
Tercio@11
|
102
|
|
Tercio@11
|
103 bottomSlider:SetHook ("OnValueChange", function (_, _, value)
|
|
Tercio@11
|
104 value = math.abs (value-100)
|
|
Tercio@11
|
105 bottomCoordTexture.image:SetHeight (math.max (window.frame:GetHeight()/100*value, 1))
|
|
Tercio@11
|
106 if (window.callback_func) then
|
|
Tercio@22
|
107 window.accept (nil, nil, true)
|
|
Tercio@11
|
108 end
|
|
Tercio@11
|
109 end)
|
|
Tercio@11
|
110
|
|
Tercio@11
|
111 bottomSlider:Hide()
|
|
Tercio@11
|
112
|
|
Tercio@11
|
113 --> Left Slider
|
|
Tercio@11
|
114
|
|
Tercio@11
|
115 local leftCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageLeftCoord")
|
|
Tercio@11
|
116 leftCoordTexture:SetPoint ("topleft", window, "topleft", 0, 0)
|
|
Tercio@11
|
117 leftCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0)
|
|
Tercio@11
|
118 leftCoordTexture.color = "red"
|
|
Tercio@11
|
119 leftCoordTexture.width = 1
|
|
Tercio@11
|
120 leftCoordTexture.alpha = .2
|
|
Tercio@11
|
121
|
|
Tercio@11
|
122 local leftSlider = DF:NewSlider (window, nil, "$parentLeftSlider", "leftSlider", 100, 100, 0.1, 100, 0.1, 0.1)
|
|
Tercio@11
|
123 leftSlider:SetAllPoints (window.widget)
|
|
Tercio@11
|
124 leftSlider.backdrop = nil
|
|
Tercio@11
|
125 leftSlider.fractional = true
|
|
Tercio@11
|
126 leftSlider:SetHook ("OnEnter", function() return true end)
|
|
Tercio@11
|
127 leftSlider:SetHook ("OnLeave", function() return true end)
|
|
Tercio@11
|
128
|
|
Tercio@11
|
129 local leftSliderThumpTexture = leftSlider:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
130 leftSliderThumpTexture:SetTexture (1, 1, 1)
|
|
Tercio@11
|
131 leftSliderThumpTexture:SetWidth (3)
|
|
Tercio@11
|
132 leftSliderThumpTexture:SetHeight (512)
|
|
Tercio@11
|
133 leftSlider:SetThumbTexture (leftSliderThumpTexture)
|
|
Tercio@11
|
134
|
|
Tercio@11
|
135 leftSlider:SetHook ("OnValueChange", function (_, _, value)
|
|
Tercio@11
|
136 leftCoordTexture.image:SetWidth (window.frame:GetWidth()/100*value)
|
|
Tercio@11
|
137 if (window.callback_func) then
|
|
Tercio@22
|
138 window.accept (nil, nil, true)
|
|
Tercio@11
|
139 end
|
|
Tercio@11
|
140 end)
|
|
Tercio@11
|
141
|
|
Tercio@11
|
142 leftSlider:Hide()
|
|
Tercio@11
|
143
|
|
Tercio@11
|
144 --> Right Slider
|
|
Tercio@11
|
145
|
|
Tercio@11
|
146 local rightCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageRightCoord")
|
|
Tercio@11
|
147 rightCoordTexture:SetPoint ("topright", window, "topright", 0, 0)
|
|
Tercio@11
|
148 rightCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0)
|
|
Tercio@11
|
149 rightCoordTexture.color = "red"
|
|
Tercio@11
|
150 rightCoordTexture.width = 1
|
|
Tercio@11
|
151 rightCoordTexture.alpha = .2
|
|
Tercio@11
|
152
|
|
Tercio@11
|
153 local rightSlider = DF:NewSlider (window, nil, "$parentRightSlider", "rightSlider", 100, 100, 0.1, 100, 0.1, 100)
|
|
Tercio@11
|
154 rightSlider:SetAllPoints (window.widget)
|
|
Tercio@11
|
155 rightSlider.backdrop = nil
|
|
Tercio@11
|
156 rightSlider.fractional = true
|
|
Tercio@11
|
157 rightSlider:SetHook ("OnEnter", function() return true end)
|
|
Tercio@11
|
158 rightSlider:SetHook ("OnLeave", function() return true end)
|
|
Tercio@11
|
159 --[
|
|
Tercio@11
|
160 local rightSliderThumpTexture = rightSlider:CreateTexture (nil, "overlay")
|
|
Tercio@11
|
161 rightSliderThumpTexture:SetTexture (1, 1, 1)
|
|
Tercio@11
|
162 rightSliderThumpTexture:SetWidth (3)
|
|
Tercio@11
|
163 rightSliderThumpTexture:SetHeight (512)
|
|
Tercio@11
|
164 rightSlider:SetThumbTexture (rightSliderThumpTexture)
|
|
Tercio@11
|
165 --]]
|
|
Tercio@11
|
166 rightSlider:SetHook ("OnValueChange", function (_, _, value)
|
|
Tercio@11
|
167 value = math.abs (value-100)
|
|
Tercio@11
|
168 rightCoordTexture.image:SetWidth (math.max (window.frame:GetWidth()/100*value, 1))
|
|
Tercio@11
|
169 if (window.callback_func) then
|
|
Tercio@22
|
170 window.accept (nil, nil, true)
|
|
Tercio@11
|
171 end
|
|
Tercio@11
|
172 end)
|
|
Tercio@11
|
173
|
|
Tercio@11
|
174 rightSlider:Hide()
|
|
Tercio@11
|
175
|
|
Tercio@11
|
176 --> Edit Buttons
|
|
Tercio@11
|
177
|
|
Tercio@11
|
178 local buttonsBackground = DF:NewPanel (UIParent, nil, "DetailsFrameworkImageEditButtonsBg", nil, 115, 230)
|
|
Tercio@11
|
179 --buttonsBackground:SetPoint ("topleft", window, "topright", 2, 0)
|
|
Tercio@11
|
180 buttonsBackground:SetPoint ("topright", background_frame, "topright", -8, -10)
|
|
Tercio@11
|
181 buttonsBackground:Hide()
|
|
Tercio@11
|
182 --buttonsBackground:SetMovable (true)
|
|
Tercio@11
|
183 tinsert (UISpecialFrames, "DetailsFrameworkImageEditButtonsBg")
|
|
Tercio@11
|
184 buttonsBackground:SetFrameStrata ("TOOLTIP")
|
|
Tercio@11
|
185
|
|
Tercio@11
|
186 local alphaFrameShown = false
|
|
Tercio@11
|
187
|
|
Tercio@11
|
188 local editingSide = nil
|
|
Tercio@11
|
189 local lastButton = nil
|
|
Tercio@11
|
190 local alphaFrame
|
|
Tercio@11
|
191 local originalColor = {0.9999, 0.8196, 0}
|
|
Tercio@11
|
192
|
|
Tercio@22
|
193 local enableTexEdit = function (button, b, side)
|
|
Tercio@11
|
194
|
|
Tercio@11
|
195 if (alphaFrameShown) then
|
|
Tercio@11
|
196 alphaFrame:Hide()
|
|
Tercio@11
|
197 alphaFrameShown = false
|
|
Tercio@11
|
198 button.text:SetTextColor (unpack (originalColor))
|
|
Tercio@11
|
199 end
|
|
Tercio@11
|
200
|
|
Tercio@11
|
201 if (ColorPickerFrame:IsShown()) then
|
|
Tercio@11
|
202 ColorPickerFrame:Hide()
|
|
Tercio@11
|
203 end
|
|
Tercio@11
|
204
|
|
Tercio@11
|
205 if (lastButton) then
|
|
Tercio@11
|
206 lastButton.text:SetTextColor (unpack (originalColor))
|
|
Tercio@11
|
207 end
|
|
Tercio@11
|
208
|
|
Tercio@11
|
209 if (editingSide == side) then
|
|
Tercio@11
|
210 window [editingSide.."Slider"]:Hide()
|
|
Tercio@11
|
211 editingSide = nil
|
|
Tercio@11
|
212 return
|
|
Tercio@11
|
213
|
|
Tercio@11
|
214 elseif (editingSide) then
|
|
Tercio@11
|
215 window [editingSide.."Slider"]:Hide()
|
|
Tercio@11
|
216 end
|
|
Tercio@11
|
217
|
|
Tercio@11
|
218 editingSide = side
|
|
Tercio@11
|
219 button.text:SetTextColor (1, 1, 1)
|
|
Tercio@11
|
220 lastButton = button
|
|
Tercio@11
|
221
|
|
Tercio@11
|
222 window [side.."Slider"]:Show()
|
|
Tercio@11
|
223 end
|
|
Tercio@11
|
224
|
|
Tercio@11
|
225 local leftTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentLeftTexButton", nil, 100, 20, enableTexEdit, "left", nil, nil, "Crop Left", 1)
|
|
Tercio@11
|
226 leftTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -10)
|
|
Tercio@11
|
227 local rightTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentRightTexButton", nil, 100, 20, enableTexEdit, "right", nil, nil, "Crop Right", 1)
|
|
Tercio@11
|
228 rightTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -30)
|
|
Tercio@11
|
229 local topTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentTopTexButton", nil, 100, 20, enableTexEdit, "top", nil, nil, "Crop Top", 1)
|
|
Tercio@11
|
230 topTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -50)
|
|
Tercio@11
|
231 local bottomTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentBottomTexButton", nil, 100, 20, enableTexEdit, "bottom", nil, nil, "Crop Bottom", 1)
|
|
Tercio@11
|
232 bottomTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -70)
|
|
Tercio@11
|
233 leftTexCoordButton:InstallCustomTexture()
|
|
Tercio@11
|
234 rightTexCoordButton:InstallCustomTexture()
|
|
Tercio@11
|
235 topTexCoordButton:InstallCustomTexture()
|
|
Tercio@11
|
236 bottomTexCoordButton:InstallCustomTexture()
|
|
Tercio@11
|
237
|
|
Tercio@11
|
238 local Alpha = DF:NewButton (buttonsBackground, nil, "$parentBottomAlphaButton", nil, 100, 20, alpha, nil, nil, nil, "Alpha", 1)
|
|
Tercio@11
|
239 Alpha:SetPoint ("topright", buttonsBackground, "topright", -8, -115)
|
|
Tercio@11
|
240 Alpha:InstallCustomTexture()
|
|
Tercio@11
|
241
|
|
Tercio@11
|
242 --> overlay color
|
|
Tercio@11
|
243 local selectedColor = function (default)
|
|
Tercio@11
|
244 if (default) then
|
|
Tercio@11
|
245 edit_texture:SetVertexColor (unpack (default))
|
|
Tercio@11
|
246 if (window.callback_func) then
|
|
Tercio@22
|
247 window.accept (nil, nil, true)
|
|
Tercio@11
|
248 end
|
|
Tercio@11
|
249 else
|
|
Tercio@11
|
250 edit_texture:SetVertexColor (ColorPickerFrame:GetColorRGB())
|
|
Tercio@11
|
251 if (window.callback_func) then
|
|
Tercio@22
|
252 window.accept (nil, nil, true)
|
|
Tercio@11
|
253 end
|
|
Tercio@11
|
254 end
|
|
Tercio@11
|
255 end
|
|
Tercio@11
|
256
|
|
Tercio@11
|
257 local changeColor = function()
|
|
Tercio@11
|
258
|
|
Tercio@11
|
259 ColorPickerFrame.func = nil
|
|
Tercio@11
|
260 ColorPickerFrame.opacityFunc = nil
|
|
Tercio@11
|
261 ColorPickerFrame.cancelFunc = nil
|
|
Tercio@11
|
262 ColorPickerFrame.previousValues = nil
|
|
Tercio@11
|
263
|
|
Tercio@11
|
264 local r, g, b = edit_texture:GetVertexColor()
|
|
Tercio@11
|
265 ColorPickerFrame:SetColorRGB (r, g, b)
|
|
Tercio@11
|
266 ColorPickerFrame:SetParent (buttonsBackground.widget)
|
|
Tercio@11
|
267 ColorPickerFrame.hasOpacity = false
|
|
Tercio@11
|
268 ColorPickerFrame.previousValues = {r, g, b}
|
|
Tercio@11
|
269 ColorPickerFrame.func = selectedColor
|
|
Tercio@11
|
270 ColorPickerFrame.cancelFunc = selectedColor
|
|
Tercio@11
|
271 ColorPickerFrame:ClearAllPoints()
|
|
Tercio@11
|
272 ColorPickerFrame:SetPoint ("left", buttonsBackground.widget, "right")
|
|
Tercio@11
|
273 ColorPickerFrame:Show()
|
|
Tercio@11
|
274
|
|
Tercio@11
|
275 if (alphaFrameShown) then
|
|
Tercio@11
|
276 alphaFrame:Hide()
|
|
Tercio@11
|
277 alphaFrameShown = false
|
|
Tercio@11
|
278 Alpha.button.text:SetTextColor (unpack (originalColor))
|
|
Tercio@11
|
279 end
|
|
Tercio@11
|
280
|
|
Tercio@11
|
281 if (lastButton) then
|
|
Tercio@11
|
282 lastButton.text:SetTextColor (unpack (originalColor))
|
|
Tercio@11
|
283 if (editingSide) then
|
|
Tercio@11
|
284 window [editingSide.."Slider"]:Hide()
|
|
Tercio@11
|
285 end
|
|
Tercio@11
|
286 end
|
|
Tercio@11
|
287 end
|
|
Tercio@11
|
288
|
|
Tercio@11
|
289 local changeColorButton = DF:NewButton (buttonsBackground, nil, "$parentOverlayColorButton", nil, 100, 20, changeColor, nil, nil, nil, "Color", 1)
|
|
Tercio@11
|
290 changeColorButton:SetPoint ("topright", buttonsBackground, "topright", -8, -95)
|
|
Tercio@11
|
291 changeColorButton:InstallCustomTexture()
|
|
Tercio@11
|
292
|
|
Tercio@11
|
293 alphaFrame = DF:NewPanel (buttonsBackground, nil, "DetailsFrameworkImageEditAlphaBg", nil, 40, 225)
|
|
Tercio@11
|
294 alphaFrame:SetPoint ("topleft", buttonsBackground, "topright", 2, 0)
|
|
Tercio@11
|
295 alphaFrame:Hide()
|
|
Tercio@11
|
296 local alphaSlider = DF:NewSlider (alphaFrame, nil, "$parentAlphaSlider", "alphaSlider", 30, 220, 1, 100, 1, edit_texture:GetAlpha()*100)
|
|
Tercio@11
|
297 alphaSlider:SetPoint ("top", alphaFrame, "top", 0, -5)
|
|
Tercio@11
|
298 alphaSlider:SetOrientation ("VERTICAL")
|
|
Tercio@11
|
299 alphaSlider.thumb:SetSize (40, 30)
|
|
Tercio@11
|
300 --leftSlider.backdrop = nil
|
|
Tercio@11
|
301 --leftSlider.fractional = true
|
|
Tercio@11
|
302
|
|
Tercio@22
|
303 local alpha = function (button)
|
|
Tercio@11
|
304
|
|
Tercio@11
|
305 if (ColorPickerFrame:IsShown()) then
|
|
Tercio@11
|
306 ColorPickerFrame:Hide()
|
|
Tercio@11
|
307 end
|
|
Tercio@11
|
308
|
|
Tercio@11
|
309 if (lastButton) then
|
|
Tercio@11
|
310 lastButton.text:SetTextColor (unpack (originalColor))
|
|
Tercio@11
|
311 if (editingSide) then
|
|
Tercio@11
|
312 window [editingSide.."Slider"]:Hide()
|
|
Tercio@11
|
313 end
|
|
Tercio@11
|
314 end
|
|
Tercio@11
|
315
|
|
Tercio@11
|
316 if (not alphaFrameShown) then
|
|
Tercio@11
|
317 alphaFrame:Show()
|
|
Tercio@11
|
318 alphaSlider:SetValue (edit_texture:GetAlpha()*100)
|
|
Tercio@11
|
319 alphaFrameShown = true
|
|
Tercio@11
|
320 button.text:SetTextColor (1, 1, 1)
|
|
Tercio@11
|
321 else
|
|
Tercio@11
|
322 alphaFrame:Hide()
|
|
Tercio@11
|
323 alphaFrameShown = false
|
|
Tercio@11
|
324 button.text:SetTextColor (unpack (originalColor))
|
|
Tercio@11
|
325 end
|
|
Tercio@11
|
326 end
|
|
Tercio@11
|
327
|
|
Tercio@11
|
328 Alpha.clickfunction = alpha
|
|
Tercio@11
|
329
|
|
Tercio@11
|
330 alphaSlider:SetHook ("OnValueChange", function (_, _, value)
|
|
Tercio@11
|
331 edit_texture:SetAlpha (value/100)
|
|
Tercio@11
|
332 if (window.callback_func) then
|
|
Tercio@22
|
333 window.accept (nil, nil, true)
|
|
Tercio@11
|
334 end
|
|
Tercio@11
|
335 end)
|
|
Tercio@11
|
336
|
|
Tercio@11
|
337 local resizer = CreateFrame ("Button", nil, window.widget)
|
|
Tercio@11
|
338 resizer:SetNormalTexture ([[Interface\AddOns\Details\images\skins\default_skin]])
|
|
Tercio@11
|
339 resizer:SetHighlightTexture ([[Interface\AddOns\Details\images\skins\default_skin]])
|
|
Tercio@11
|
340 resizer:GetNormalTexture():SetTexCoord (0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
|
|
Tercio@11
|
341 resizer:GetHighlightTexture():SetTexCoord (0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
|
|
Tercio@11
|
342 resizer:SetWidth (16)
|
|
Tercio@11
|
343 resizer:SetHeight (16)
|
|
Tercio@11
|
344 resizer:SetPoint ("BOTTOMRIGHT", window.widget, "BOTTOMRIGHT", 0, 0)
|
|
Tercio@11
|
345 resizer:EnableMouse (true)
|
|
Tercio@11
|
346 resizer:SetFrameLevel (window.widget:GetFrameLevel() + 2)
|
|
Tercio@11
|
347
|
|
Tercio@11
|
348 resizer:SetScript ("OnMouseDown", function (self, button)
|
|
Tercio@11
|
349 window.widget:StartSizing ("BOTTOMRIGHT")
|
|
Tercio@11
|
350 end)
|
|
Tercio@11
|
351
|
|
Tercio@11
|
352 resizer:SetScript ("OnMouseUp", function (self, button)
|
|
Tercio@11
|
353 window.widget:StopMovingOrSizing()
|
|
Tercio@11
|
354 end)
|
|
Tercio@11
|
355
|
|
Tercio@11
|
356 window.widget:SetScript ("OnMouseDown", function()
|
|
Tercio@11
|
357 window.widget:StartMoving()
|
|
Tercio@11
|
358 end)
|
|
Tercio@11
|
359 window.widget:SetScript ("OnMouseUp", function()
|
|
Tercio@11
|
360 window.widget:StopMovingOrSizing()
|
|
Tercio@11
|
361 end)
|
|
Tercio@11
|
362
|
|
Tercio@11
|
363 window.widget:SetScript ("OnSizeChanged", function()
|
|
Tercio@11
|
364 edit_texture.width = window.width
|
|
Tercio@11
|
365 edit_texture.height = window.height
|
|
Tercio@11
|
366 leftSliderThumpTexture:SetHeight (window.height)
|
|
Tercio@11
|
367 rightSliderThumpTexture:SetHeight (window.height)
|
|
Tercio@11
|
368 topSliderThumpTexture:SetWidth (window.width)
|
|
Tercio@11
|
369 bottomSliderThumpTexture:SetWidth (window.width)
|
|
Tercio@11
|
370
|
|
Tercio@11
|
371 rightCoordTexture.image:SetWidth (math.max ( (window.frame:GetWidth() / 100 * math.abs (rightSlider:GetValue()-100)), 1))
|
|
Tercio@11
|
372 leftCoordTexture.image:SetWidth (window.frame:GetWidth()/100*leftSlider:GetValue())
|
|
Tercio@11
|
373 bottomCoordTexture:SetHeight (math.max ( (window.frame:GetHeight() / 100 * math.abs (bottomSlider:GetValue()-100)), 1))
|
|
Tercio@11
|
374 topCoordTexture:SetHeight (window.frame:GetHeight()/100*topSlider:GetValue())
|
|
Tercio@11
|
375
|
|
Tercio@11
|
376 if (window.callback_func) then
|
|
Tercio@22
|
377 window.accept (nil, nil, true)
|
|
Tercio@11
|
378 end
|
|
Tercio@11
|
379 end)
|
|
Tercio@11
|
380
|
|
Tercio@11
|
381
|
|
Tercio@11
|
382
|
|
Tercio@11
|
383 --> flip
|
|
Tercio@22
|
384 local flip = function (button, b, side)
|
|
Tercio@11
|
385 if (side == 1) then
|
|
Tercio@11
|
386 haveHFlip = not haveHFlip
|
|
Tercio@11
|
387 if (window.callback_func) then
|
|
Tercio@22
|
388 window.accept (nil, nil, true)
|
|
Tercio@11
|
389 end
|
|
Tercio@11
|
390 elseif (side == 2) then
|
|
Tercio@11
|
391 haveVFlip = not haveVFlip
|
|
Tercio@11
|
392 if (window.callback_func) then
|
|
Tercio@22
|
393 window.accept (nil, nil, true)
|
|
Tercio@11
|
394 end
|
|
Tercio@11
|
395 end
|
|
Tercio@11
|
396 end
|
|
Tercio@11
|
397
|
|
Tercio@11
|
398 local flipButtonH = DF:NewButton (buttonsBackground, nil, "$parentFlipButton", nil, 100, 20, flip, 1, nil, nil, "Flip H", 1)
|
|
Tercio@11
|
399 flipButtonH:SetPoint ("topright", buttonsBackground, "topright", -8, -140)
|
|
Tercio@11
|
400 flipButtonH:InstallCustomTexture()
|
|
Tercio@11
|
401 --
|
|
Tercio@11
|
402 local flipButtonV = DF:NewButton (buttonsBackground, nil, "$parentFlipButton2", nil, 100, 20, flip, 2, nil, nil, "Flip V", 1)
|
|
Tercio@11
|
403 flipButtonV:SetPoint ("topright", buttonsBackground, "topright", -8, -160)
|
|
Tercio@11
|
404 flipButtonV:InstallCustomTexture()
|
|
Tercio@11
|
405
|
|
Tercio@11
|
406 --> accept
|
|
Tercio@22
|
407 window.accept = function (self, b, keep_editing)
|
|
Tercio@11
|
408
|
|
Tercio@11
|
409 if (not keep_editing) then
|
|
Tercio@11
|
410 buttonsBackground:Hide()
|
|
Tercio@11
|
411 window:Hide()
|
|
Tercio@11
|
412 alphaFrame:Hide()
|
|
Tercio@11
|
413 ColorPickerFrame:Hide()
|
|
Tercio@11
|
414 end
|
|
Tercio@11
|
415
|
|
Tercio@11
|
416 local coords = {}
|
|
Tercio@11
|
417 local l, r, t, b = leftSlider.value/100, rightSlider.value/100, topSlider.value/100, bottomSlider.value/100
|
|
Tercio@11
|
418
|
|
Tercio@11
|
419 if (haveHFlip) then
|
|
Tercio@11
|
420 coords [1] = r
|
|
Tercio@11
|
421 coords [2] = l
|
|
Tercio@11
|
422 else
|
|
Tercio@11
|
423 coords [1] = l
|
|
Tercio@11
|
424 coords [2] = r
|
|
Tercio@11
|
425 end
|
|
Tercio@11
|
426
|
|
Tercio@11
|
427 if (haveVFlip) then
|
|
Tercio@11
|
428 coords [3] = b
|
|
Tercio@11
|
429 coords [4] = t
|
|
Tercio@11
|
430 else
|
|
Tercio@11
|
431 coords [3] = t
|
|
Tercio@11
|
432 coords [4] = b
|
|
Tercio@11
|
433 end
|
|
Tercio@11
|
434
|
|
Tercio@11
|
435 return window.callback_func (edit_texture.width, edit_texture.height, {edit_texture:GetVertexColor()}, edit_texture:GetAlpha(), coords, window.extra_param)
|
|
Tercio@11
|
436 end
|
|
Tercio@11
|
437
|
|
Tercio@11
|
438 local acceptButton = DF:NewButton (buttonsBackground, nil, "$parentAcceptButton", nil, 100, 20, window.accept, nil, nil, nil, "Done", 1)
|
|
Tercio@11
|
439 acceptButton:SetPoint ("topright", buttonsBackground, "topright", -8, -200)
|
|
Tercio@11
|
440 acceptButton:InstallCustomTexture()
|
|
Tercio@11
|
441
|
|
Tercio@11
|
442
|
|
Tercio@11
|
443
|
|
Tercio@11
|
444 window:Hide()
|
|
Tercio@11
|
445 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
446
|
|
Tercio@11
|
447 local ttexcoord
|
|
Tercio@11
|
448 function DF:ImageEditor (callback, texture, texcoord, colors, width, height, extraParam, alpha, maximize)
|
|
Tercio@11
|
449
|
|
Tercio@11
|
450 texcoord = texcoord or {0, 1, 0, 1}
|
|
Tercio@11
|
451 ttexcoord = texcoord
|
|
Tercio@11
|
452
|
|
Tercio@11
|
453 colors = colors or {1, 1, 1, 1}
|
|
Tercio@11
|
454
|
|
Tercio@11
|
455 alpha = alpha or 1
|
|
Tercio@11
|
456
|
|
Tercio@11
|
457 edit_texture:SetTexture (texture)
|
|
Tercio@11
|
458 edit_texture.width = width
|
|
Tercio@11
|
459 edit_texture.height = height
|
|
Tercio@11
|
460 edit_texture.maximize = maximize
|
|
Tercio@11
|
461
|
|
Tercio@11
|
462 edit_texture:SetVertexColor (colors [1], colors [2], colors [3])
|
|
Tercio@11
|
463
|
|
Tercio@11
|
464 edit_texture:SetAlpha (alpha)
|
|
Tercio@11
|
465
|
|
Tercio@11
|
466 DF:ScheduleTimer ("RefreshImageEditor", 0.2)
|
|
Tercio@11
|
467
|
|
Tercio@11
|
468 window:Show()
|
|
Tercio@11
|
469 window.callback_func = callback
|
|
Tercio@11
|
470 window.extra_param = extraParam
|
|
Tercio@11
|
471 buttonsBackground:Show()
|
|
Tercio@22
|
472 buttonsBackground.widget:SetBackdrop (nil)
|
|
Tercio@11
|
473
|
|
Tercio@11
|
474 table.wipe (window.hooks)
|
|
Tercio@11
|
475 end
|
|
Tercio@11
|
476
|
|
Tercio@11
|
477 function DF:RefreshImageEditor()
|
|
Tercio@11
|
478
|
|
Tercio@11
|
479 if (edit_texture.maximize) then
|
|
Tercio@11
|
480 DetailsFrameworkImageEdit:SetSize (266, 226)
|
|
Tercio@11
|
481 else
|
|
Tercio@11
|
482 DetailsFrameworkImageEdit:SetSize (edit_texture.width, edit_texture.height)
|
|
Tercio@11
|
483 end
|
|
Tercio@11
|
484
|
|
Tercio@11
|
485 local l, r, t, b = unpack (ttexcoord)
|
|
Tercio@11
|
486
|
|
Tercio@11
|
487 if (l > r) then
|
|
Tercio@11
|
488 haveHFlip = true
|
|
Tercio@11
|
489 leftSlider:SetValue (r * 100)
|
|
Tercio@11
|
490 rightSlider:SetValue (l * 100)
|
|
Tercio@11
|
491 else
|
|
Tercio@11
|
492 haveHFlip = false
|
|
Tercio@11
|
493 leftSlider:SetValue (l * 100)
|
|
Tercio@11
|
494 rightSlider:SetValue (r * 100)
|
|
Tercio@11
|
495 end
|
|
Tercio@11
|
496
|
|
Tercio@11
|
497 if (t > b) then
|
|
Tercio@11
|
498 haveVFlip = true
|
|
Tercio@11
|
499 topSlider:SetValue (b * 100)
|
|
Tercio@11
|
500 bottomSlider:SetValue (t * 100)
|
|
Tercio@11
|
501 else
|
|
Tercio@11
|
502 haveVFlip = false
|
|
Tercio@11
|
503 topSlider:SetValue (t * 100)
|
|
Tercio@11
|
504 bottomSlider:SetValue (b * 100)
|
|
Tercio@11
|
505 end
|
|
Tercio@11
|
506
|
|
Tercio@11
|
507 if (window.callback_func) then
|
|
Tercio@22
|
508 window.accept (nil, nil, true)
|
|
Tercio@11
|
509 end
|
|
Tercio@11
|
510
|
|
Tercio@11
|
511 end
|
|
Tercio@11
|
512 |