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