You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

611 lines
22 KiB

local DF = _G["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
return
end
local _
3 years ago
local texCoordinates
local CreateImageEditorFrame = function()
local background_frame = CreateFrame("frame", "DetailsFrameworkImageEditBackground", UIParent, "BackdropTemplate")
background_frame:SetPoint("center", UIParent, "center")
3 years ago
background_frame:SetFrameStrata("TOOLTIP")
background_frame:SetSize(790, 560)
background_frame:SetClampedToScreen(true)
tinsert(UISpecialFrames, "DetailsFrameworkImageEditBackground")
background_frame:SetResizable(true)
background_frame:SetMovable(true)
background_frame:SetScript("OnMouseDown", function(self)
self:StartMoving()
end)
background_frame:SetScript("OnMouseUp", function(self)
self:StopMovingOrSizing()
end)
DF:CreateTitleBar (background_frame, "Image Editor")
DF:ApplyStandardBackdrop(background_frame, false, 0.98)
DF:CreateStatusBar(background_frame)
3 years ago
background_frame:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
background_frame:SetBackdropColor(0, 0, 0, 0.9)
background_frame:SetBackdropBorderColor(0, 0, 0, 1)
local editorWindow = DF:NewPanel(background_frame, nil, "DetailsFrameworkImageEdit", nil, 650, 500, false)
editorWindow:SetPoint("topleft", background_frame, "topleft", 10, -30)
editorWindow:SetResizable(true)
--editorWindow:SetMovable(true)
editorWindow:Show()
--editorWindow:SetClampedToScreen(true)
editorWindow:SetFrameStrata("TOOLTIP")
editorWindow:SetFrameLevel(background_frame:GetFrameLevel())
editorWindow:SetResizeBounds(100, 100, 500, 500)
_G.DetailsFrameworkImageEditTable = editorWindow
editorWindow.hooks = {}
local background = DF:NewImage(editorWindow, nil, nil, nil, "background", nil, "background", "$parentBackgroundImage")
background:SetAllPoints()
background:SetTexture(0, 0, 0, .8)
local edit_texture = DF:NewImage(editorWindow, nil, 500, 500, "artwork", nil, "edit_texture", "$parentImage")
edit_texture:SetAllPoints()
_G.DetailsFrameworkImageEdit_EditTexture = edit_texture
local haveHFlip = false
local haveVFlip = false
--Top Slider
local topCoordTexture = DF:NewImage(editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageTopCoord")
3 years ago
topCoordTexture:SetPoint("topleft", editorWindow, "topleft")
topCoordTexture:SetPoint("topright", editorWindow, "topright")
topCoordTexture:SetColorTexture(1, 0, 0)
topCoordTexture.height = 1
topCoordTexture.alpha = .2
3 years ago
local topSlider = DF:NewSlider (editorWindow, nil, "$parentTopSlider", "topSlider", 100, 100, 0.1, 100, 0.1, 0)
topSlider:SetAllPoints(editorWindow.widget)
topSlider:SetOrientation("VERTICAL")
topSlider.backdrop = nil
topSlider.fractional = true
topSlider:SetHook("OnEnter", function() return true end)
topSlider:SetHook("OnLeave", function() return true end)
3 years ago
local topSliderThumpTexture = topSlider:CreateTexture(nil, "overlay")
topSliderThumpTexture:SetColorTexture(1, 1, 1)
topSliderThumpTexture:SetWidth(512)
topSliderThumpTexture:SetHeight(1)
topSlider:SetThumbTexture (topSliderThumpTexture)
topSlider:SetHook("OnValueChange", function(_, _, value)
3 years ago
topCoordTexture.image:SetHeight(editorWindow.frame:GetHeight()/100*value)
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
end)
topSlider:Hide()
--Bottom Slider
local bottomCoordTexture = DF:NewImage(editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageBottomCoord")
3 years ago
bottomCoordTexture:SetPoint("bottomleft", editorWindow, "bottomleft", 0, 0)
bottomCoordTexture:SetPoint("bottomright", editorWindow, "bottomright", 0, 0)
bottomCoordTexture:SetColorTexture(1, 0, 0)
bottomCoordTexture.height = 1
bottomCoordTexture.alpha = .2
local bottomSlider = DF:NewSlider (editorWindow, nil, "$parentBottomSlider", "bottomSlider", 100, 100, 0.1, 100, 0.1, 100)
bottomSlider:SetAllPoints(editorWindow.widget)
bottomSlider:SetOrientation("VERTICAL")
bottomSlider.backdrop = nil
bottomSlider.fractional = true
bottomSlider:SetHook("OnEnter", function() return true end)
bottomSlider:SetHook("OnLeave", function() return true end)
3 years ago
local bottomSliderThumpTexture = bottomSlider:CreateTexture(nil, "overlay")
bottomSliderThumpTexture:SetColorTexture(1, 1, 1)
bottomSliderThumpTexture:SetWidth(512)
bottomSliderThumpTexture:SetHeight(1)
bottomSlider:SetThumbTexture (bottomSliderThumpTexture)
bottomSlider:SetHook("OnValueChange", function(_, _, value)
value = math.abs(value-100)
bottomCoordTexture.image:SetHeight(math.max(editorWindow.frame:GetHeight()/100*value, 1))
3 years ago
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
end)
bottomSlider:Hide()
--Left Slider
local leftCoordTexture = DF:NewImage(editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageLeftCoord")
3 years ago
leftCoordTexture:SetPoint("topleft", editorWindow, "topleft", 0, 0)
leftCoordTexture:SetPoint("bottomleft", editorWindow, "bottomleft", 0, 0)
leftCoordTexture:SetColorTexture(1, 0, 0)
leftCoordTexture.width = 1
leftCoordTexture.alpha = .2
3 years ago
local leftSlider = DF:NewSlider (editorWindow, nil, "$parentLeftSlider", "leftSlider", 100, 100, 0.1, 100, 0.1, 0.1)
leftSlider:SetAllPoints(editorWindow.widget)
leftSlider.backdrop = nil
leftSlider.fractional = true
leftSlider:SetHook("OnEnter", function() return true end)
leftSlider:SetHook("OnLeave", function() return true end)
3 years ago
local leftSliderThumpTexture = leftSlider:CreateTexture(nil, "overlay")
leftSliderThumpTexture:SetColorTexture(1, 1, 1)
leftSliderThumpTexture:SetWidth(1)
leftSliderThumpTexture:SetHeight(512)
leftSlider:SetThumbTexture (leftSliderThumpTexture)
leftSlider:SetHook("OnValueChange", function(_, _, value)
3 years ago
leftCoordTexture.image:SetWidth(editorWindow.frame:GetWidth()/100*value)
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
end)
leftSlider:Hide()
--Right Slider
local rightCoordTexture = DF:NewImage(editorWindow, nil, nil, nil, "overlay", nil, nil, "$parentImageRightCoord")
3 years ago
rightCoordTexture:SetPoint("topright", editorWindow, "topright", 0, 0)
rightCoordTexture:SetPoint("bottomright", editorWindow, "bottomright", 0, 0)
rightCoordTexture:SetColorTexture(1, 0, 0)
rightCoordTexture.width = 1
rightCoordTexture.alpha = .2
3 years ago
local rightSlider = DF:NewSlider (editorWindow, nil, "$parentRightSlider", "rightSlider", 100, 100, 0.1, 100, 0.1, 100)
rightSlider:SetAllPoints(editorWindow.widget)
rightSlider.backdrop = nil
rightSlider.fractional = true
rightSlider:SetHook("OnEnter", function() return true end)
rightSlider:SetHook("OnLeave", function() return true end)
--[
3 years ago
local rightSliderThumpTexture = rightSlider:CreateTexture(nil, "overlay")
rightSliderThumpTexture:SetColorTexture(1, 1, 1)
rightSliderThumpTexture:SetWidth(1)
rightSliderThumpTexture:SetHeight(512)
rightSlider:SetThumbTexture (rightSliderThumpTexture)
--]]
rightSlider:SetHook("OnValueChange", function(_, _, value)
value = math.abs(value-100)
rightCoordTexture.image:SetWidth(math.max(editorWindow.frame:GetWidth()/100*value, 1))
3 years ago
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
end)
rightSlider:Hide()
--Edit Buttons
local buttonsBackground = DF:NewPanel(background_frame, nil, "DetailsFrameworkImageEditButtonsBg", nil, 115, 230, false)
3 years ago
--buttonsBackground:SetPoint("topleft", window, "topright", 2, 0)
buttonsBackground:SetPoint("topright", background_frame, "topright", -8, -10)
--buttonsBackground:Hide()
--buttonsBackground:SetMovable(true)
--tinsert(UISpecialFrames, "DetailsFrameworkImageEditButtonsBg")
3 years ago
buttonsBackground:SetFrameStrata("TOOLTIP")
local alphaFrameShown = false
local editingSide = nil
local lastButton = nil
local alphaFrame
local originalColor = {0.9999, 0.8196, 0}
3 years ago
local enableTexEdit = function(button, bottom, side)
if (alphaFrameShown) then
alphaFrame:Hide()
alphaFrameShown = false
button.text:SetTextColor(unpack(originalColor))
end
if (ColorPickerFrame:IsShown()) then
ColorPickerFrame:Hide()
end
if (lastButton) then
lastButton.text:SetTextColor(unpack(originalColor))
end
if (editingSide == side) then
3 years ago
editorWindow [editingSide.."Slider"]:Hide()
editingSide = nil
return
elseif (editingSide) then
3 years ago
editorWindow [editingSide.."Slider"]:Hide()
end
editingSide = side
button.text:SetTextColor(1, 1, 1)
lastButton = button
3 years ago
editorWindow [side.."Slider"]:Show()
end
local yMod = -10
3 years ago
local leftTexCoordButton = DF:NewButton(buttonsBackground, nil, "$parentLeftTexButton", nil, 100, 20, enableTexEdit, "left", nil, nil, "Crop Left", 1)
leftTexCoordButton:SetPoint("topright", buttonsBackground, "topright", -8, -10 + yMod)
leftTexCoordButton:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
3 years ago
local rightTexCoordButton = DF:NewButton(buttonsBackground, nil, "$parentRightTexButton", nil, 100, 20, enableTexEdit, "right", nil, nil, "Crop Right", 1)
rightTexCoordButton:SetPoint("topright", buttonsBackground, "topright", -8, -30 + yMod)
rightTexCoordButton:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
3 years ago
local topTexCoordButton = DF:NewButton(buttonsBackground, nil, "$parentTopTexButton", nil, 100, 20, enableTexEdit, "top", nil, nil, "Crop Top", 1)
topTexCoordButton:SetPoint("topright", buttonsBackground, "topright", -8, -50 + yMod)
topTexCoordButton:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
3 years ago
local bottomTexCoordButton = DF:NewButton(buttonsBackground, nil, "$parentBottomTexButton", nil, 100, 20, enableTexEdit, "bottom", nil, nil, "Crop Bottom", 1)
bottomTexCoordButton:SetPoint("topright", buttonsBackground, "topright", -8, -70 + yMod)
bottomTexCoordButton:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
3 years ago
local Alpha = DF:NewButton(buttonsBackground, nil, "$parentBottomAlphaButton", nil, 100, 20, alpha, nil, nil, nil, "Alpha", 1)
Alpha:SetPoint("topright", buttonsBackground, "topright", -8, -115 + yMod)
Alpha:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
--overlay color
3 years ago
local selectedColor = function(default)
if (default) then
3 years ago
edit_texture:SetVertexColor(unpack(default))
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
else
3 years ago
edit_texture:SetVertexColor(ColorPickerFrame:GetColorRGB())
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
end
end
local changeColor = function()
ColorPickerFrame.func = nil
ColorPickerFrame.opacityFunc = nil
ColorPickerFrame.cancelFunc = nil
ColorPickerFrame.previousValues = nil
3 years ago
local right, g, bottom = edit_texture:GetVertexColor()
ColorPickerFrame:SetColorRGB (right, g, bottom)
ColorPickerFrame:SetParent(buttonsBackground.widget)
ColorPickerFrame.hasOpacity = false
3 years ago
ColorPickerFrame.previousValues = {right, g, bottom}
ColorPickerFrame.func = selectedColor
ColorPickerFrame.cancelFunc = selectedColor
ColorPickerFrame:ClearAllPoints()
3 years ago
ColorPickerFrame:SetPoint("left", buttonsBackground.widget, "right")
ColorPickerFrame:Show()
if (alphaFrameShown) then
alphaFrame:Hide()
alphaFrameShown = false
Alpha.button.text:SetTextColor(unpack(originalColor))
end
if (lastButton) then
lastButton.text:SetTextColor(unpack(originalColor))
if (editingSide) then
3 years ago
editorWindow [editingSide.."Slider"]:Hide()
end
end
end
3 years ago
local changeColorButton = DF:NewButton(buttonsBackground, nil, "$parentOverlayColorButton", nil, 100, 20, changeColor, nil, nil, nil, "Color", 1)
changeColorButton:SetPoint("topright", buttonsBackground, "topright", -8, -95 + yMod)
changeColorButton:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
alphaFrame = DF:NewPanel(buttonsBackground, nil, "DetailsFrameworkImageEditAlphaBg", nil, 40, 225)
3 years ago
alphaFrame:SetPoint("topleft", buttonsBackground, "topright", 2, 0)
alphaFrame:Hide()
local alphaSlider = DF:NewSlider (alphaFrame, nil, "$parentAlphaSlider", "alphaSlider", 30, 220, 1, 100, 1, edit_texture:GetAlpha()*100)
3 years ago
alphaSlider:SetPoint("top", alphaFrame, "top", 0, -5)
alphaSlider:SetOrientation("VERTICAL")
alphaSlider.thumb:SetSize(40, 30)
--leftSlider.backdrop = nil
--leftSlider.fractional = true
3 years ago
local alpha = function(button)
if (ColorPickerFrame:IsShown()) then
ColorPickerFrame:Hide()
end
if (lastButton) then
lastButton.text:SetTextColor(unpack(originalColor))
if (editingSide) then
3 years ago
editorWindow [editingSide.."Slider"]:Hide()
end
end
if (not alphaFrameShown) then
alphaFrame:Show()
3 years ago
alphaSlider:SetValue(edit_texture:GetAlpha()*100)
alphaFrameShown = true
button.text:SetTextColor(1, 1, 1)
else
alphaFrame:Hide()
alphaFrameShown = false
button.text:SetTextColor(unpack(originalColor))
end
end
Alpha.clickfunction = alpha
alphaSlider:SetHook("OnValueChange", function(_, _, value)
3 years ago
edit_texture:SetAlpha(value/100)
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
end)
local resizer = CreateFrame("Button", nil, editorWindow.widget, "BackdropTemplate")
resizer:SetNormalTexture([[Interface\AddOns\Details\images\skins\default_skin]])
resizer:SetHighlightTexture([[Interface\AddOns\Details\images\skins\default_skin]])
resizer:GetNormalTexture():SetTexCoord(0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
resizer:GetHighlightTexture():SetTexCoord(0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
3 years ago
resizer:SetWidth(16)
resizer:SetHeight(16)
resizer:SetPoint("BOTTOMRIGHT", editorWindow.widget, "BOTTOMRIGHT", 0, 0)
resizer:EnableMouse(true)
resizer:SetFrameLevel(editorWindow.widget:GetFrameLevel() + 2)
resizer:SetScript("OnMouseDown", function(self, button)
editorWindow.widget:StartSizing("BOTTOMRIGHT")
end)
resizer:SetScript("OnMouseUp", function(self, button)
3 years ago
editorWindow.widget:StopMovingOrSizing()
editorWindow:ClearAllPoints()
editorWindow:SetPoint("topleft", background_frame, "topleft", 10, -30)
end)
3 years ago
editorWindow.widget:SetScript("OnMouseDown", function()
editorWindow.widget:StartMoving()
end)
3 years ago
editorWindow.widget:SetScript("OnMouseUp", function()
editorWindow.widget:StopMovingOrSizing()
editorWindow:ClearAllPoints()
editorWindow:SetPoint("topleft", background_frame, "topleft", 10, -30)
end)
3 years ago
editorWindow.widget:SetScript("OnSizeChanged", function()
edit_texture.width = editorWindow.width
edit_texture.height = editorWindow.height
leftSliderThumpTexture:SetHeight(editorWindow.height)
rightSliderThumpTexture:SetHeight(editorWindow.height)
topSliderThumpTexture:SetWidth(editorWindow.width)
bottomSliderThumpTexture:SetWidth(editorWindow.width)
rightCoordTexture.image:SetWidth(math.max( (editorWindow.frame:GetWidth() / 100 * math.abs(rightSlider:GetValue()-100)), 1))
3 years ago
leftCoordTexture.image:SetWidth(editorWindow.frame:GetWidth()/100*leftSlider:GetValue())
bottomCoordTexture:SetHeight(math.max( (editorWindow.frame:GetHeight() / 100 * math.abs(bottomSlider:GetValue()-100)), 1))
3 years ago
topCoordTexture:SetHeight(editorWindow.frame:GetHeight()/100*topSlider:GetValue())
3 years ago
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
end)
3 years ago
--flip button
local flip = function(button, bottom, side)
if (side == 1) then
haveHFlip = not haveHFlip
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
3 years ago
elseif (side == 2) then
haveVFlip = not haveVFlip
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
end
3 years ago
end
local flipButtonH = DF:NewButton(buttonsBackground, nil, "$parentFlipButton", nil, 100, 20, flip, 1, nil, nil, "Flip H", 1)
flipButtonH:SetPoint("topright", buttonsBackground, "topright", -8, -140 + yMod)
flipButtonH:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
--select area to crop
local dragFrame = CreateFrame("frame", nil, background_frame, "BackdropTemplate")
dragFrame:EnableMouse(false)
dragFrame:SetFrameStrata("TOOLTIP")
dragFrame:SetPoint("topleft", edit_texture.widget, "topleft")
dragFrame:SetPoint("bottomright", edit_texture.widget, "bottomright")
dragFrame:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Worldmap\UI-QuestBlob-Inside]], tileSize = 256, tile = true})
dragFrame:SetBackdropColor(1, 1, 1, .2)
dragFrame:Hide()
local selectionBoxUp = dragFrame:CreateTexture(nil, "overlay")
selectionBoxUp:SetHeight(1)
selectionBoxUp:SetColorTexture(1, 1, 1)
local selectionBoxDown = dragFrame:CreateTexture(nil, "overlay")
selectionBoxDown:SetHeight(1)
selectionBoxDown:SetColorTexture(1, 1, 1)
local selectionBoxLeft = dragFrame:CreateTexture(nil, "overlay")
selectionBoxLeft:SetWidth(1)
selectionBoxLeft:SetColorTexture(1, 1, 1)
local selectionBoxRight = dragFrame:CreateTexture(nil, "overlay")
selectionBoxRight:SetWidth(1)
selectionBoxRight:SetColorTexture(1, 1, 1)
function dragFrame.ClearSelectionBoxPoints()
selectionBoxUp:ClearAllPoints()
selectionBoxDown:ClearAllPoints()
selectionBoxLeft:ClearAllPoints()
selectionBoxRight:ClearAllPoints()
end
local startCropFunc = function()
dragFrame:Show()
dragFrame:EnableMouse(true)
end
local cropSelection = DF:NewButton(buttonsBackground, nil, "$parentCropSelection", nil, 100, 20, startCropFunc, 2, nil, nil, "Crop Selection", 1)
cropSelection:InstallCustomTexture()
dragFrame.OnTick = function(self, deltaTime)
local x1, y1 = unpack(self.ClickedAt)
local x2, y2 = GetCursorPosition()
dragFrame.ClearSelectionBoxPoints()
if (x2 > x1) then
--right
if (y1 > y2) then
--top
selectionBoxUp:SetPoint("topleft", UIParent, "bottomleft", x1, y1)
selectionBoxUp:SetPoint("topright", UIParent, "bottomleft", x2, y1)
selectionBoxLeft:SetPoint("topleft", UIParent, "bottomleft", x1, y1)
selectionBoxLeft:SetPoint("bottomleft", UIParent, "bottomleft", x1, y2)
else
3 years ago
--bottom
end
3 years ago
else
--left
if (y2 > y1) then
--top
else
3 years ago
--bottom
end
3 years ago
end
end
3 years ago
dragFrame:SetScript("OnMouseDown", function(self, MouseButton)
if (MouseButton == "LeftButton") then
self.ClickedAt = {GetCursorPosition()}
dragFrame:SetScript("OnUpdate", dragFrame.OnTick)
end
3 years ago
end)
3 years ago
dragFrame:SetScript("OnMouseUp", function(self, MouseButton)
if (MouseButton == "LeftButton") then
self.ReleaseAt = {GetCursorPosition()}
dragFrame:EnableMouse(false)
dragFrame:Hide()
dragFrame:SetScript("OnUpdate", nil)
print(self.ClickedAt[1], self.ClickedAt[2], self.ReleaseAt[1], self.ReleaseAt[2])
3 years ago
end
end)
3 years ago
--accept
editorWindow.accept = function(self, bottom, keepEditing)
if (not keepEditing) then
background_frame:Hide()
3 years ago
alphaFrame:Hide()
ColorPickerFrame:Hide()
end
3 years ago
local coords = {}
local left, right, top, bottom = leftSlider.value/100, rightSlider.value/100, topSlider.value/100, bottomSlider.value/100
3 years ago
if (haveHFlip) then
coords [1] = right
coords [2] = left
else
coords [1] = left
coords [2] = right
end
3 years ago
if (haveVFlip) then
coords [3] = bottom
coords [4] = top
else
coords [3] = top
coords [4] = bottom
end
return editorWindow.callback_func(edit_texture.width, edit_texture.height, {edit_texture:GetVertexColor()}, edit_texture:GetAlpha(), coords, editorWindow.extra_param)
end
3 years ago
local acceptButton = DF:NewButton(buttonsBackground, nil, "$parentAcceptButton", nil, 100, 20, editorWindow.accept, nil, nil, nil, "Done", 1)
acceptButton:SetPoint("topright", buttonsBackground, "topright", -8, -200)
acceptButton:SetTemplate(DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
3 years ago
function DF:RefreshImageEditor()
if (edit_texture.maximize) then
DetailsFrameworkImageEdit:SetSize(266, 226)
else
DetailsFrameworkImageEdit:SetSize(edit_texture.width, edit_texture.height)
end
3 years ago
local left, right, top, bottom = unpack(texCoordinates)
if (left > right) then
haveHFlip = true
leftSlider:SetValue(right * 100)
rightSlider:SetValue(left * 100)
else
haveHFlip = false
leftSlider:SetValue(left * 100)
rightSlider:SetValue(right * 100)
end
3 years ago
if (top > bottom) then
haveVFlip = true
topSlider:SetValue(bottom * 100)
bottomSlider:SetValue(top * 100)
else
haveVFlip = false
topSlider:SetValue(top * 100)
bottomSlider:SetValue(bottom * 100)
end
if (editorWindow.callback_func) then
editorWindow.accept(nil, nil, true)
end
end
background_frame:Hide()
3 years ago
end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function DF:ImageEditor(callback, texture, texcoord, colors, width, height, extraParam, alpha, maximize)
if (not _G.DetailsFrameworkImageEdit) then
CreateImageEditorFrame()
end
local window = _G.DetailsFrameworkImageEditTable
texcoord = texcoord or {0, 1, 0, 1}
texCoordinates = texcoord
colors = colors or {1, 1, 1, 1}
alpha = alpha or 1
_G.DetailsFrameworkImageEdit_EditTexture:SetTexture(texture)
_G.DetailsFrameworkImageEdit_EditTexture.width = width
_G.DetailsFrameworkImageEdit_EditTexture.height = height
_G.DetailsFrameworkImageEdit_EditTexture.maximize = maximize
_G.DetailsFrameworkImageEdit_EditTexture:SetVertexColor(colors [1], colors [2], colors [3])
_G.DetailsFrameworkImageEdit_EditTexture:SetAlpha(alpha)
DF.Schedules.NewTimer(0.2, DF.RefreshImageEditor)
window:GetParent():Show()
3 years ago
window.callback_func = callback
window.extra_param = extraParam
--DetailsFrameworkImageEditButtonsBg:Show()
--DetailsFrameworkImageEditButtonsBg:SetBackdrop(nil)
3 years ago
table.wipe(window.hooks)
end