Mercurial > wow > hansgar_and_franzok_assist
comparison Libs/DF/pictureedit.lua @ 49:7d5934415ad0 r49-release
- framework update.
| author | Tercio |
|---|---|
| date | Wed, 05 Jul 2017 15:20:21 -0300 |
| parents | dbd417f413a8 |
| children | 0682d738499b |
comparison
equal
deleted
inserted
replaced
| 48:a671a2cf52ee | 49:7d5934415ad0 |
|---|---|
| 10 window:SetPoint ("center", UIParent, "center") | 10 window:SetPoint ("center", UIParent, "center") |
| 11 window:SetResizable (true) | 11 window:SetResizable (true) |
| 12 window:SetMovable (true) | 12 window:SetMovable (true) |
| 13 tinsert (UISpecialFrames, "DetailsFrameworkImageEdit") | 13 tinsert (UISpecialFrames, "DetailsFrameworkImageEdit") |
| 14 window:SetFrameStrata ("TOOLTIP") | 14 window:SetFrameStrata ("TOOLTIP") |
| 15 window:SetMaxResize (266, 226) | 15 window:SetMaxResize (650, 500) |
| 16 | 16 |
| 17 window.hooks = {} | 17 window.hooks = {} |
| 18 | 18 |
| 19 local background = DF:NewImage (window, nil, nil, nil, "background", nil, nil, "$parentBackground") | 19 local background = DF:NewImage (window, nil, nil, nil, "background", nil, nil, "$parentBackground") |
| 20 background:SetAllPoints() | 20 background:SetAllPoints() |
| 21 background:SetTexture (0, 0, 0, .8) | 21 background:SetTexture (0, 0, 0, .8) |
| 22 | 22 |
| 23 local edit_texture = DF:NewImage (window, nil, 300, 250, "artwork", nil, nil, "$parentImage") | 23 local edit_texture = DF:NewImage (window, nil, 650, 500, "artwork", nil, nil, "$parentImage") |
| 24 edit_texture:SetAllPoints() | 24 edit_texture:SetAllPoints() |
| 25 | 25 |
| 26 local background_frame = CreateFrame ("frame", "DetailsFrameworkImageEditBackground", DetailsFrameworkImageEdit) | 26 local background_frame = CreateFrame ("frame", "DetailsFrameworkImageEditBackground", DetailsFrameworkImageEdit) |
| 27 background_frame:SetPoint ("topleft", DetailsFrameworkImageEdit, "topleft", -10, 12) | 27 background_frame:SetPoint ("topleft", DetailsFrameworkImageEdit, "topleft", -10, 12) |
| 28 background_frame:SetFrameStrata ("DIALOG") | 28 background_frame:SetFrameStrata ("DIALOG") |
| 29 background_frame:SetSize (400, 252) | 29 background_frame:SetSize (800, 540) |
| 30 | 30 |
| 31 background_frame:SetResizable (true) | 31 background_frame:SetResizable (true) |
| 32 background_frame:SetMovable (true) | 32 background_frame:SetMovable (true) |
| 33 | 33 |
| 34 background_frame:SetScript ("OnMouseDown", function() | 34 background_frame:SetScript ("OnMouseDown", function() |
| 48 --> Top Slider | 48 --> Top Slider |
| 49 | 49 |
| 50 local topCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageTopCoord") | 50 local topCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageTopCoord") |
| 51 topCoordTexture:SetPoint ("topleft", window, "topleft") | 51 topCoordTexture:SetPoint ("topleft", window, "topleft") |
| 52 topCoordTexture:SetPoint ("topright", window, "topright") | 52 topCoordTexture:SetPoint ("topright", window, "topright") |
| 53 topCoordTexture.color = "red" | 53 topCoordTexture:SetColorTexture (1, 0, 0) |
| 54 topCoordTexture.height = 1 | 54 topCoordTexture.height = 1 |
| 55 topCoordTexture.alpha = .2 | 55 topCoordTexture.alpha = .2 |
| 56 | 56 |
| 57 local topSlider = DF:NewSlider (window, nil, "$parentTopSlider", "topSlider", 100, 100, 0.1, 100, 0.1, 0) | 57 local topSlider = DF:NewSlider (window, nil, "$parentTopSlider", "topSlider", 100, 100, 0.1, 100, 0.1, 0) |
| 58 topSlider:SetAllPoints (window.widget) | 58 topSlider:SetAllPoints (window.widget) |
| 61 topSlider.fractional = true | 61 topSlider.fractional = true |
| 62 topSlider:SetHook ("OnEnter", function() return true end) | 62 topSlider:SetHook ("OnEnter", function() return true end) |
| 63 topSlider:SetHook ("OnLeave", function() return true end) | 63 topSlider:SetHook ("OnLeave", function() return true end) |
| 64 | 64 |
| 65 local topSliderThumpTexture = topSlider:CreateTexture (nil, "overlay") | 65 local topSliderThumpTexture = topSlider:CreateTexture (nil, "overlay") |
| 66 topSliderThumpTexture:SetTexture (1, 1, 1) | 66 topSliderThumpTexture:SetColorTexture (1, 1, 1) |
| 67 topSliderThumpTexture:SetWidth (512) | 67 topSliderThumpTexture:SetWidth (512) |
| 68 topSliderThumpTexture:SetHeight (3) | 68 topSliderThumpTexture:SetHeight (1) |
| 69 topSlider:SetThumbTexture (topSliderThumpTexture) | 69 topSlider:SetThumbTexture (topSliderThumpTexture) |
| 70 | 70 |
| 71 topSlider:SetHook ("OnValueChange", function (_, _, value) | 71 topSlider:SetHook ("OnValueChange", function (_, _, value) |
| 72 topCoordTexture.image:SetHeight (window.frame:GetHeight()/100*value) | 72 topCoordTexture.image:SetHeight (window.frame:GetHeight()/100*value) |
| 73 if (window.callback_func) then | 73 if (window.callback_func) then |
| 80 --> Bottom Slider | 80 --> Bottom Slider |
| 81 | 81 |
| 82 local bottomCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageBottomCoord") | 82 local bottomCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageBottomCoord") |
| 83 bottomCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0) | 83 bottomCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0) |
| 84 bottomCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0) | 84 bottomCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0) |
| 85 bottomCoordTexture.color = "red" | 85 bottomCoordTexture:SetColorTexture (1, 0, 0) |
| 86 bottomCoordTexture.height = 1 | 86 bottomCoordTexture.height = 1 |
| 87 bottomCoordTexture.alpha = .2 | 87 bottomCoordTexture.alpha = .2 |
| 88 | 88 |
| 89 local bottomSlider= DF:NewSlider (window, nil, "$parentBottomSlider", "bottomSlider", 100, 100, 0.1, 100, 0.1, 100) | 89 local bottomSlider= DF:NewSlider (window, nil, "$parentBottomSlider", "bottomSlider", 100, 100, 0.1, 100, 0.1, 100) |
| 90 bottomSlider:SetAllPoints (window.widget) | 90 bottomSlider:SetAllPoints (window.widget) |
| 93 bottomSlider.fractional = true | 93 bottomSlider.fractional = true |
| 94 bottomSlider:SetHook ("OnEnter", function() return true end) | 94 bottomSlider:SetHook ("OnEnter", function() return true end) |
| 95 bottomSlider:SetHook ("OnLeave", function() return true end) | 95 bottomSlider:SetHook ("OnLeave", function() return true end) |
| 96 | 96 |
| 97 local bottomSliderThumpTexture = bottomSlider:CreateTexture (nil, "overlay") | 97 local bottomSliderThumpTexture = bottomSlider:CreateTexture (nil, "overlay") |
| 98 bottomSliderThumpTexture:SetTexture (1, 1, 1) | 98 bottomSliderThumpTexture:SetColorTexture (1, 1, 1) |
| 99 bottomSliderThumpTexture:SetWidth (512) | 99 bottomSliderThumpTexture:SetWidth (512) |
| 100 bottomSliderThumpTexture:SetHeight (3) | 100 bottomSliderThumpTexture:SetHeight (1) |
| 101 bottomSlider:SetThumbTexture (bottomSliderThumpTexture) | 101 bottomSlider:SetThumbTexture (bottomSliderThumpTexture) |
| 102 | 102 |
| 103 bottomSlider:SetHook ("OnValueChange", function (_, _, value) | 103 bottomSlider:SetHook ("OnValueChange", function (_, _, value) |
| 104 value = math.abs (value-100) | 104 value = math.abs (value-100) |
| 105 bottomCoordTexture.image:SetHeight (math.max (window.frame:GetHeight()/100*value, 1)) | 105 bottomCoordTexture.image:SetHeight (math.max (window.frame:GetHeight()/100*value, 1)) |
| 113 --> Left Slider | 113 --> Left Slider |
| 114 | 114 |
| 115 local leftCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageLeftCoord") | 115 local leftCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageLeftCoord") |
| 116 leftCoordTexture:SetPoint ("topleft", window, "topleft", 0, 0) | 116 leftCoordTexture:SetPoint ("topleft", window, "topleft", 0, 0) |
| 117 leftCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0) | 117 leftCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0) |
| 118 leftCoordTexture.color = "red" | 118 leftCoordTexture:SetColorTexture (1, 0, 0) |
| 119 leftCoordTexture.width = 1 | 119 leftCoordTexture.width = 1 |
| 120 leftCoordTexture.alpha = .2 | 120 leftCoordTexture.alpha = .2 |
| 121 | 121 |
| 122 local leftSlider = DF:NewSlider (window, nil, "$parentLeftSlider", "leftSlider", 100, 100, 0.1, 100, 0.1, 0.1) | 122 local leftSlider = DF:NewSlider (window, nil, "$parentLeftSlider", "leftSlider", 100, 100, 0.1, 100, 0.1, 0.1) |
| 123 leftSlider:SetAllPoints (window.widget) | 123 leftSlider:SetAllPoints (window.widget) |
| 125 leftSlider.fractional = true | 125 leftSlider.fractional = true |
| 126 leftSlider:SetHook ("OnEnter", function() return true end) | 126 leftSlider:SetHook ("OnEnter", function() return true end) |
| 127 leftSlider:SetHook ("OnLeave", function() return true end) | 127 leftSlider:SetHook ("OnLeave", function() return true end) |
| 128 | 128 |
| 129 local leftSliderThumpTexture = leftSlider:CreateTexture (nil, "overlay") | 129 local leftSliderThumpTexture = leftSlider:CreateTexture (nil, "overlay") |
| 130 leftSliderThumpTexture:SetTexture (1, 1, 1) | 130 leftSliderThumpTexture:SetColorTexture (1, 1, 1) |
| 131 leftSliderThumpTexture:SetWidth (3) | 131 leftSliderThumpTexture:SetWidth (1) |
| 132 leftSliderThumpTexture:SetHeight (512) | 132 leftSliderThumpTexture:SetHeight (512) |
| 133 leftSlider:SetThumbTexture (leftSliderThumpTexture) | 133 leftSlider:SetThumbTexture (leftSliderThumpTexture) |
| 134 | 134 |
| 135 leftSlider:SetHook ("OnValueChange", function (_, _, value) | 135 leftSlider:SetHook ("OnValueChange", function (_, _, value) |
| 136 leftCoordTexture.image:SetWidth (window.frame:GetWidth()/100*value) | 136 leftCoordTexture.image:SetWidth (window.frame:GetWidth()/100*value) |
| 144 --> Right Slider | 144 --> Right Slider |
| 145 | 145 |
| 146 local rightCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageRightCoord") | 146 local rightCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageRightCoord") |
| 147 rightCoordTexture:SetPoint ("topright", window, "topright", 0, 0) | 147 rightCoordTexture:SetPoint ("topright", window, "topright", 0, 0) |
| 148 rightCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0) | 148 rightCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0) |
| 149 rightCoordTexture.color = "red" | 149 rightCoordTexture:SetColorTexture (1, 0, 0) |
| 150 rightCoordTexture.width = 1 | 150 rightCoordTexture.width = 1 |
| 151 rightCoordTexture.alpha = .2 | 151 rightCoordTexture.alpha = .2 |
| 152 | 152 |
| 153 local rightSlider = DF:NewSlider (window, nil, "$parentRightSlider", "rightSlider", 100, 100, 0.1, 100, 0.1, 100) | 153 local rightSlider = DF:NewSlider (window, nil, "$parentRightSlider", "rightSlider", 100, 100, 0.1, 100, 0.1, 100) |
| 154 rightSlider:SetAllPoints (window.widget) | 154 rightSlider:SetAllPoints (window.widget) |
| 156 rightSlider.fractional = true | 156 rightSlider.fractional = true |
| 157 rightSlider:SetHook ("OnEnter", function() return true end) | 157 rightSlider:SetHook ("OnEnter", function() return true end) |
| 158 rightSlider:SetHook ("OnLeave", function() return true end) | 158 rightSlider:SetHook ("OnLeave", function() return true end) |
| 159 --[ | 159 --[ |
| 160 local rightSliderThumpTexture = rightSlider:CreateTexture (nil, "overlay") | 160 local rightSliderThumpTexture = rightSlider:CreateTexture (nil, "overlay") |
| 161 rightSliderThumpTexture:SetTexture (1, 1, 1) | 161 rightSliderThumpTexture:SetColorTexture (1, 1, 1) |
| 162 rightSliderThumpTexture:SetWidth (3) | 162 rightSliderThumpTexture:SetWidth (1) |
| 163 rightSliderThumpTexture:SetHeight (512) | 163 rightSliderThumpTexture:SetHeight (512) |
| 164 rightSlider:SetThumbTexture (rightSliderThumpTexture) | 164 rightSlider:SetThumbTexture (rightSliderThumpTexture) |
| 165 --]] | 165 --]] |
| 166 rightSlider:SetHook ("OnValueChange", function (_, _, value) | 166 rightSlider:SetHook ("OnValueChange", function (_, _, value) |
| 167 value = math.abs (value-100) | 167 value = math.abs (value-100) |
| 397 | 397 |
| 398 local flipButtonH = DF:NewButton (buttonsBackground, nil, "$parentFlipButton", nil, 100, 20, flip, 1, nil, nil, "Flip H", 1) | 398 local flipButtonH = DF:NewButton (buttonsBackground, nil, "$parentFlipButton", nil, 100, 20, flip, 1, nil, nil, "Flip H", 1) |
| 399 flipButtonH:SetPoint ("topright", buttonsBackground, "topright", -8, -140) | 399 flipButtonH:SetPoint ("topright", buttonsBackground, "topright", -8, -140) |
| 400 flipButtonH:InstallCustomTexture() | 400 flipButtonH:InstallCustomTexture() |
| 401 -- | 401 -- |
| 402 local flipButtonV = DF:NewButton (buttonsBackground, nil, "$parentFlipButton2", nil, 100, 20, flip, 2, nil, nil, "Flip V", 1) | 402 |
| 403 flipButtonV:SetPoint ("topright", buttonsBackground, "topright", -8, -160) | 403 |
| 404 flipButtonV:InstallCustomTexture() | 404 --> select area to crop |
| 405 local DragFrame = CreateFrame ("frame", nil, background_frame) | |
| 406 DragFrame:EnableMouse (false) | |
| 407 DragFrame:SetFrameStrata ("TOOLTIP") | |
| 408 DragFrame:SetPoint ("topleft", edit_texture.widget, "topleft") | |
| 409 DragFrame:SetPoint ("bottomright", edit_texture.widget, "bottomright") | |
| 410 DragFrame:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Worldmap\UI-QuestBlob-Inside]], tileSize = 256, tile = true}) | |
| 411 DragFrame:SetBackdropColor (1, 1, 1, .2) | |
| 412 DragFrame:Hide() | |
| 413 | |
| 414 local SelectionBox_Up = DragFrame:CreateTexture (nil, "overlay") | |
| 415 SelectionBox_Up:SetHeight (1) | |
| 416 SelectionBox_Up:SetColorTexture (1, 1, 1) | |
| 417 local SelectionBox_Down = DragFrame:CreateTexture (nil, "overlay") | |
| 418 SelectionBox_Down:SetHeight (1) | |
| 419 SelectionBox_Down:SetColorTexture (1, 1, 1) | |
| 420 local SelectionBox_Left = DragFrame:CreateTexture (nil, "overlay") | |
| 421 SelectionBox_Left:SetWidth (1) | |
| 422 SelectionBox_Left:SetColorTexture (1, 1, 1) | |
| 423 local SelectionBox_Right = DragFrame:CreateTexture (nil, "overlay") | |
| 424 SelectionBox_Right:SetWidth (1) | |
| 425 SelectionBox_Right:SetColorTexture (1, 1, 1) | |
| 426 | |
| 427 function DragFrame.ClearSelectionBoxPoints() | |
| 428 SelectionBox_Up:ClearAllPoints() | |
| 429 SelectionBox_Down:ClearAllPoints() | |
| 430 SelectionBox_Left:ClearAllPoints() | |
| 431 SelectionBox_Right:ClearAllPoints() | |
| 432 end | |
| 433 | |
| 434 local StartCrop = function() | |
| 435 DragFrame:Show() | |
| 436 DragFrame:EnableMouse (true) | |
| 437 end | |
| 438 | |
| 439 local CropSelection = DF:NewButton (buttonsBackground, nil, "$parentCropSelection", nil, 100, 20, StartCrop, 2, nil, nil, "Crop Selection", 1) | |
| 440 --CropSelection:SetPoint ("topright", buttonsBackground, "topright", -8, -260) | |
| 441 CropSelection:InstallCustomTexture() | |
| 442 | |
| 443 DragFrame.OnTick = function (self, deltaTime) | |
| 444 local x1, y1 = unpack (self.ClickedAt) | |
| 445 local x2, y2 = GetCursorPosition() | |
| 446 DragFrame.ClearSelectionBoxPoints() | |
| 447 | |
| 448 print (x1, y1, x2, y2) | |
| 449 | |
| 450 if (x2 > x1) then | |
| 451 --right | |
| 452 if (y1 > y2) then | |
| 453 --top | |
| 454 SelectionBox_Up:SetPoint ("topleft", UIParent, "bottomleft", x1, y1) | |
| 455 SelectionBox_Up:SetPoint ("topright", UIParent, "bottomleft", x2, y1) | |
| 456 | |
| 457 SelectionBox_Left:SetPoint ("topleft", UIParent, "bottomleft", x1, y1) | |
| 458 SelectionBox_Left:SetPoint ("bottomleft", UIParent, "bottomleft", x1, y2) | |
| 459 | |
| 460 print (1) | |
| 461 else | |
| 462 --bottom | |
| 463 | |
| 464 end | |
| 465 else | |
| 466 --left | |
| 467 if (y2 > y1) then | |
| 468 --top | |
| 469 | |
| 470 else | |
| 471 --bottom | |
| 472 | |
| 473 end | |
| 474 end | |
| 475 | |
| 476 end | |
| 477 | |
| 478 DragFrame:SetScript ("OnMouseDown", function (self, MouseButton) | |
| 479 if (MouseButton == "LeftButton") then | |
| 480 self.ClickedAt = {GetCursorPosition()} | |
| 481 DragFrame:SetScript ("OnUpdate", DragFrame.OnTick) | |
| 482 | |
| 483 end | |
| 484 end) | |
| 485 DragFrame:SetScript ("OnMouseUp", function (self, MouseButton) | |
| 486 if (MouseButton == "LeftButton") then | |
| 487 self.ReleaseAt = {GetCursorPosition()} | |
| 488 DragFrame:EnableMouse (false) | |
| 489 DragFrame:Hide() | |
| 490 DragFrame:SetScript ("OnUpdate", nil) | |
| 491 print (self.ClickedAt[1], self.ClickedAt[2], self.ReleaseAt[1], self.ReleaseAt[2]) | |
| 492 end | |
| 493 end) | |
| 405 | 494 |
| 406 --> accept | 495 --> accept |
| 407 window.accept = function (self, b, keep_editing) | 496 window.accept = function (self, b, keep_editing) |
| 408 | 497 |
| 409 if (not keep_editing) then | 498 if (not keep_editing) then |
