WoWInterface SVN FluidFrames

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 6 to Rev 7
    Reverse comparison

Rev 6 → Rev 7

trunk/FluidFrames/FrameReparent.lua New file
0,0 → 1,89
----------------------------
-- Accociative Reparent Code
-- Fixes things like dragging ActionBar1 by also reparenting anchored siblings
----------------------------
 
--[[-- Get the hash size of a table --]]--
local function tsize(t)
local i = 0
for k in pairs(t) do
i=i+1
end
return i
end
 
--[[-- Get the hash keys as a list --]]--
local function keyList(t)
local keys = {}
for k in pairs(t) do
tinsert(keys, k)
end
return keys
end
 
function FluidFrames.ReparentAssociatedFrames(frame, oldParent, newParent)
if oldParent and oldParent ~= newParent then
--frame:SetParent(newParent)
FluidFrames.DebugPrint(format(FLUIDFRAMES_REPARENTING, frame:GetName(), FluidFrames.OrNil(oldParent:GetName()), FluidFrames.OrNil(newParent:GetName())))
for i,v in ipairs(FluidFrames.GetPositionallyDependantOn(frame, oldParent)) do
v:SetParent(newParent)
end
end
end
 
function FluidFrames.FreeFrameFromParent(frame)
local oldParent = frame:GetParent()
if oldParent then
local newParent = getglobal(FluidFrames.NEW_PARENT)
FluidFrames.ReparentAssociatedFrames(frame, oldParent, newParent)
end
end
 
function FluidFrames.ResetFrameParent(frame, origParent)
--local parent = getglobal(FluidFrames.NEW_PARENT)
local parent = frame:GetParent()
FluidFrames.ReparentAssociatedFrames(frame, parent, origParent)
end
 
function FluidFrames.GetPositionallyDependantOn(frame, parent)
local frameSet = { [frame] = true }
if parent.GetChildren then
local siblings = { parent:GetChildren() }
local size = 0
local newSize = tsize(frameSet)
while size < newSize do
FluidFrames.GetAnchoredTo(frameSet, unpack(siblings))
size = newSize
newSize = tsize(frameSet)
end
end
if parent.GetRegions then
local siblings = { parent:GetRegions() }
local size = 0
local newSize = tsize(frameSet)
while size < newSize do
FluidFrames.GetAnchoredTo(frameSet, unpack(siblings))
size = newSize
newSize = tsize(frameSet)
end
end
return keyList(frameSet)
end
 
--[[-- From a list of frames/regions add the ones that are anchored once only to one of the frames in the frameSet to the frameSet. --]]--
function FluidFrames.GetAnchoredTo(frameSet, first, ...)
if first and not frameSet[first] and first:GetNumPoints() == 1 then
--TODO: check if it's anchored to a child of the frame
local relativeFrame = select(2, first:GetPoint(1))
if frameSet[relativeFrame] then
frameSet[first] = true
if select("#", ...) > 0 then
FluidFrames.GetAnchoredTo(frameSet, ...)
end
end
end
if select("#", ...) > 0 then
FluidFrames.GetAnchoredTo(frameSet, ...)
end
end
 
trunk/FluidFrames/FrameReset.lua New file
0,0 → 1,133
----------------------------
-- Reset Code
----------------------------
 
FluidFramesModifiedFrames = {}
 
function FluidFrames.StoreFrameDefault(frame, storeScale, storeDimentions)
local name = frame:GetName()
if (not name) then
return
end
local data = FluidFramesModifiedFrames[name]
if (not data) then
data = {}
end
if (storeScale and not data.scale) then
data.scale = frame:GetScale()
end
if (storeDimentions and (not data.height or not data.width)) then
data.height = frame:GetHeight()
data.width = frame:GetWidth()
end
if (not data.parent) then
local parent = frame:GetParent()
data.parent = parent and parent:GetName() or parent
end
if (not data.point) then
data.point = {}
for i=1, frame:GetNumPoints() do
local pdata = { frame:GetPoint(i) }
--{ point, relativeTo, relativePoint, xofs, yofs }
if (pdata[2] and pdata[2].GetName and pdata[2]:GetName()) then
pdata[2] = pdata[2]:GetName()
tinsert(data.point, pdata)
else
--No anchor name.... won't save accross sessions (deleted on VARIABLES_LOADED).
FluidFrames.Print(format(FLUIDFRAMES_UNNAMED_ANCHOR, name))
tinsert(data.point, pdata)
end
end
end
if (not FluidFramesModifiedFrames[name]) then
FluidFramesModifiedFrames[name] = data
FluidFrames.UpdateGUI()
end
end
 
function FluidFrames.ResetFrame(frame)
-- Remove saved position regardless.
frame:SetUserPlaced(nil)
 
local name = frame:GetName()
if (not name) then
FluidFrames.Print(FLUIDFRAMES_CANT_RESET_UNNAMED)
return
elseif (not FluidFramesModifiedFrames[name]) then
FluidFrames.Print(format(FLUIDFRAMES_CANT_RESET_NO_DEFAULT, name))
return
end
local data = FluidFramesModifiedFrames[name]
--WOW Crash!!! uncomment this and reset a frame. FluidFrames.RescaleFrame(frame, data.width/frame:GetWidth(), data.height/frame:GetHeight())
 
FluidFrames.Mobilize(frame)
 
if (type(data.parent) == "string") then
local parent = getglobal(data.parent)
if (parent) then
FluidFrames.ResetFrameParent(frame, parent)
end
elseif (type(data.parent) == "table") then
FluidFrames.ResetFrameParent(frame, data.parent)
end
 
if (data.scale) then
--frame:SetScale(data.scale)
FluidFrames.RelativelyScaleFrame(frame, data.scale/frame:GetScale())
end
 
if (data.width and data.height) then
local widthScale = data.width/frame:GetWidth()
local heightScale = data.height/frame:GetHeight()
FluidFrames.RescaleFrame(frame, widthScale, heightScale, true)
end
 
frame:ClearAllPoints()
for i=1, #data.point do
frame:SetPoint(data.point[i][1], data.point[i][2], data.point[i][3], data.point[i][4], data.point[i][5])
end
 
FluidFrames.UnlockHiddenFrame(frame)
 
FluidFramesModifiedFrames[name] = nil
 
-- Refresh frame with it's OnShow updates
frame:Hide()
frame:Show()
 
FluidFrames.DragFrame.frame = nil
FluidFrames.DragFrame:Hide()
 
FluidFrames.UpdateGUI()
FluidFrames.Print(format(FLUIDFRAMES_RESET, name))
end
 
function FluidFrames.ResetAll()
FluidFrames.DoNotUpdateGUI = true
for k,v in pairs(FluidFramesModifiedFrames) do
local frame = getglobal(k)
if (frame) then
FluidFrames.ResetFrame(frame)
else
FluidFrames.Print(format(FLUIDFRAMES_CANT_RESET_NOT_FOUND, k))
end
end
FluidFrames.DoNotUpdateGUI = nil
FluidFrames.UpdateGUI()
FluidFrames.Print(FLUIDFRAMES_RESET_ALL_FINISHED)
end
 
SlashCmdList["FLUIDFRAMESSLASH"] = FluidFrames.ResetAll;
 
function FluidFrames.ReshowAll()
FluidFrames.DoNotUpdateGUI = true
for k,v in pairs(FluidFramesModifiedFrames) do
local frame = getglobal(k)
if (frame and frame.FFHidden) then
FluidFrames.UnlockHiddenFrame(frame)
end
end
FluidFrames.DoNotUpdateGUI = nil
FluidFrames.UpdateGUI()
FluidFrames.Print(FLUIDFRAMES_RESHOW_ALL_FINISHED)
end
trunk/FluidFrames/FluidFrames.lua
14,6 → 14,7
 
TODO: HideUIPanel or ShowUIPanel hook that repositions 'center' UIPanelWindows
TODO: make 'full' UIPanelWindows highlightable when UIParent is hidden. Like WorldMapFrame
TODO: Add a module to disable SetPoint unless highlighted
]]--
 
FluidFrames = {}
24,19 → 25,23
 
FluidFrames.NEW_PARENT = "UIParent"
 
local function Print(text)
----------------------------
-- Util Functions
----------------------------
 
function FluidFrames.Print(text)
-- Grey
DEFAULT_CHAT_FRAME:AddMessage(text, .5,.5,.5)
end
 
local function DebugPrint(text)
function FluidFrames.DebugPrint(text)
if (FluidFrames.debug) then
-- Grey
DEFAULT_CHAT_FRAME:AddMessage(text, .5,.5,.5)
end
end
 
local function OrNil(text)
function FluidFrames.OrNil(text)
return text or FLUIDFRAMES_NIL
end
 
50,20 → 55,15
return x <= y + delta and x >= y - delta
end
 
----------------------------
-- Initialization
----------------------------
 
FluidFrames.UninitializedFrames = {}
FluidFrames.ReanchoredFrames = {}
FluidFrames.ReshownFrames = {}
FluidFrames.ReparentedFrames = {}
 
FluidFrames.FramesToDragByParent = {
"PaperDollFrame",
"ReputationFrame",
"SkillFrame",
"PVPFrameHonor",
"PetPaperDollFrame",
"PetPaperDollFrameCompanionFrame",
"TokenFrame",
"PVPFrame",
"SendMailFrame",
}
 
FluidFrames.FramesToInitLater = {
["QuestWatchFrame"] = true,
}
85,21 → 85,21
 
local frame = getglobal(k)
if (not frame) then
DebugPrint(format(FLUIDFRAMES_CANT_FIND_STORED, k))
FluidFrames.DebugPrint(format(FLUIDFRAMES_CANT_FIND_STORED, k))
-- Add to the Uninitialized list and check on subsequent ADDON_LOADED and PLAYER_REGEN_ENABLED events
if (frameList ~= FluidFrames.UninitializedFrames) then
FluidFrames.UninitializedFrames[k] = frameList[k]
end
 
elseif (frame:IsProtected() and InCombatLockdown()) then
DebugPrint(format(FLUIDFRAMES_CANT_MOVE_IN_COMBAT, k))
FluidFrames.DebugPrint(format(FLUIDFRAMES_CANT_MOVE_IN_COMBAT, k))
-- Add to the Uninitialized list and check on subsequent ADDON_LOADED and PLAYER_REGEN_ENABLED events
if (frameList ~= FluidFrames.UninitializedFrames) then
FluidFrames.UninitializedFrames[k] = frameList[k]
end
 
elseif (FluidFrames.FramesToInitLater[k] and frameList ~= FluidFrames.UninitializedFrames) then
DebugPrint(format(FLUIDFRAMES_DELAYING_EXCEPTION_FRAME, k))
FluidFrames.DebugPrint(format(FLUIDFRAMES_DELAYING_EXCEPTION_FRAME, k))
-- Exception frames load on PLAYER_REGEN_ENABLED or QUEST_LOG_UPDATE after PLAYER_ENTERING_WORLD
FluidFrames.UninitializedFrames[k] = frameList[k]
 
109,16 → 109,17
local data = v.immobilized
if (data.point) then
if (data.scale and not FluidFrames.Compare(data.scale, frame:GetScale())) then
frame:SetScale(data.scale)
--frame:SetScale(data.scale)
FluidFrames.RelativelyScaleFrame(frame, data.scale/frame:GetScale())
end
if (data.width and data.height) then
local widthScale = data.width/frame:GetWidth()
local heightScale = data.height/frame:GetHeight()
if (FluidFrames.debug) then
Print("Dimension Restore: "..(frame.GetName and frame:GetName() or "(nil)"))
Print("Saved Width: "..FluidFrames.Round(data.width, 100).." Curr Width: "..FluidFrames.Round(frame:GetWidth(), 100))
Print("Saved Height: "..FluidFrames.Round(data.height, 100).." Curr Height: "..FluidFrames.Round(frame:GetHeight(), 100))
Print("WidthScale: "..FluidFrames.Round(widthScale, 100).." HeightScale: "..FluidFrames.Round(heightScale, 100))
FluidFrames.Print("Dimension Restore: "..(frame.GetName and frame:GetName() or "(nil)"))
FluidFrames.Print("Saved Width: "..FluidFrames.Round(data.width, 100).." Curr Width: "..FluidFrames.Round(frame:GetWidth(), 100))
FluidFrames.Print("Saved Height: "..FluidFrames.Round(data.height, 100).." Curr Height: "..FluidFrames.Round(frame:GetHeight(), 100))
FluidFrames.Print("WidthScale: "..FluidFrames.Round(widthScale, 100).." HeightScale: "..FluidFrames.Round(heightScale, 100))
end
FluidFrames.RescaleFrame(frame, widthScale, heightScale, true)
end
164,123 → 165,12
end
end
 
function FluidFrames.InitTempDraggableFrames()
-- Make UIPanels temporarily draggable (position not saved)
for frameName,info in pairs(UIPanelWindows) do
if (info.area ~= "full") then
local frame = getglobal(frameName)
if (frame and frame.GetTitleRegion) then
local titleRegion = frame:GetTitleRegion()
if (not titleRegion) then
titleRegion = frame:CreateTitleRegion()
end
--titleRegion:SetAllPoints(frame)
frame:EnableMouse(1)
end
end
end
 
--[[
for i,frameName in pairs(UIChildWindows) do
local frame = getglobal(frameName)
if (frame and frame.GetTitleRegion) then
local titleRegion = frame:GetTitleRegion()
if (not titleRegion) then
titleRegion = frame:CreateTitleRegion()
end
--titleRegion:SetAllPoints(frame)
frame:EnableMouse(1)
end
end
]]--
 
-- Disable the mouse on a few child frames so that the parent is draggable
for i,frameName in ipairs(FluidFrames.FramesToDragByParent) do
local frame = getglobal(frameName)
if (frame) then
frame:EnableMouse(nil)
end
end
 
--Exceptions
if (not MinimapCluster:GetTitleRegion()) then
MinimapCluster:SetScript("OnEnter", function()
local tempthis = this
this = MinimapZoneTextButton
MinimapZoneTextButton:GetScript("OnEnter")(MinimapZoneTextButton)
this = tempthis
end)
MinimapCluster:SetScript("OnLeave", function()
local tempthis = this
this = MinimapZoneTextButton
MinimapZoneTextButton:GetScript("OnLeave")(MinimapZoneTextButton)
this = tempthis
end)
MinimapCluster:CreateTitleRegion():SetAllPoints(MinimapCluster)
MinimapZoneTextButton:EnableMouse(nil)
end
 
-- Update Enabled (mostly for LoD)
if (FluidFrames_SavedVars) then
FluidFrames.ToggleTempDraggableFrames(FluidFrames_SavedVars.TempDraggable == "1")
end
end
----------------------------
-- Event Frame
----------------------------
 
function FluidFrames.ToggleTempDraggableFrames(value)
for frameName,info in pairs(UIPanelWindows) do
if (info.area ~= "full") then
local frame = getglobal(frameName)
if (frame and frame.GetTitleRegion) then
local titleRegion = frame:GetTitleRegion()
if (titleRegion) then
if (value) then
titleRegion:SetAllPoints(frame)
else
titleRegion:ClearAllPoints()
titleRegion:SetHeight(0)
titleRegion:SetWidth(0)
end
end
end
end
end
 
--[[
for i,frameName in pairs(UIChildWindows) do
local frame = getglobal(frameName)
if (frame and frame.GetTitleRegion) then
local titleRegion = frame:GetTitleRegion()
if (titleRegion) then
if (value) then
titleRegion:SetAllPoints(frame)
else
titleRegion:ClearAllPoints()
titleRegion:SetHeight(0)
titleRegion:SetWidth(0)
end
end
end
end
]]--
 
--Exceptions
local titleRegion = MinimapCluster:GetTitleRegion()
if (titleRegion) then
if (value) then
titleRegion:SetAllPoints(MinimapCluster)
else
titleRegion:ClearAllPoints()
titleRegion:SetHeight(0)
titleRegion:SetWidth(0)
end
end
 
if (value and AchievementFrame) then
AchievementFrameHeader:EnableMouse(false)
end
end
 
function FluidFrames.OnEvent(self, event, arg1)
function FluidFrames.EventOnEvent(self, event, arg1)
if (event == "ADDON_LOADED") then
-- Catch Load on Demand Addon frames
-- Use OnUpdate to load after their LoadWith's
290,20 → 180,37
FluidFrames.InitTempDraggableFrames()
--FluidFrames.RegisterPortfolio()
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self.init_flag = true
 
elseif (event == "PLAYER_ENTERING_WORLD") then
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("QUEST_LOG_UPDATE")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("ADDON_LOADED")
 
if (not FluidFramesModifiedFrames) then
FluidFramesModifiedFrames = {}
else
FluidFrames.InitMovedFrames(FluidFramesModifiedFrames)
hooksecurefunc("CreateFrame", FluidFrames.CreateFrameHook)
--self:UnregisterEvent("PLAYER_ENTERING_WORLD")
if self.init_flag then
self.init_flag = nil
self:RegisterEvent("QUEST_LOG_UPDATE")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self.init_regen_flag = true
self:RegisterEvent("ADDON_LOADED")
 
if (not FluidFramesModifiedFrames) then
FluidFramesModifiedFrames = {}
else
FluidFrames.InitMovedFrames(FluidFramesModifiedFrames)
hooksecurefunc("CreateFrame", FluidFrames.CreateFrameHook)
end
--FluidFrames.InitTempDraggableFrames()
end
--FluidFrames.InitTempDraggableFrames()
if self.secure_setpoint_flag then
self.secure_setpoint_flag = nil
FluidFrames.RestoreSetPoint()
end
if self.secure_setparent_flag then
self.secure_setparent_flag = nil
FluidFrames.RestoreSetParent()
end
if self.secure_show_flag then
self.secure_show_flag = nil
FluidFrames.RestoreHide()
end
 
-- QUEST_LOG_UPDATE should fire when you log in or reloadui, regardless of whether you have any quests
--This makes sure QuestWatchFrame has been resized
312,9 → 219,23
FluidFrames.InitMovedFrames(FluidFrames.UninitializedFrames)
 
elseif (event == "PLAYER_REGEN_ENABLED") then
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
FluidFrames.InitMovedFrames(FluidFrames.UninitializedFrames)
 
--self:UnregisterEvent("PLAYER_REGEN_ENABLED")
if self.init_regen_flag then
self.init_regen_flag = nil
FluidFrames.InitMovedFrames(FluidFrames.UninitializedFrames)
end
if self.secure_setpoint_flag then
self.secure_setpoint_flag = nil
FluidFrames.RestoreSetPoint()
end
if self.secure_setparent_flag then
self.secure_setparent_flag = nil
FluidFrames.RestoreSetParent()
end
if self.secure_show_flag then
self.secure_show_flag = nil
FluidFrames.RestoreHide()
end
end
end
 
330,76 → 251,14
FluidFrames.InitTempDraggableFrames()
self.nextFrameInit = false
end
end
 
function FluidFrames.OnUpdate(self, delay)
if (self.frame and (self.isResizing or self.isMoving or self.isRescaling)) then
if (not this.count) then
self.count = delay
elseif (this.count < .02) then
self.count = self.count + delay
 
elseif (this.isRescaling) then
this.count = 0
local frame = self.frame
 
local x, y = GetCursorPosition()
local UIScale = UIParent:GetEffectiveScale()
local currScale = self:GetEffectiveScale()
x = x / currScale - 10 / currScale
y = y / currScale + 10 / currScale
local left = self:GetLeft()
local top = self:GetTop()
local wScale = (x-left)/self:GetWidth()
local hScale = (top-y)/self:GetHeight()
local scale = max(min(max(wScale, hScale), 1.2), 0.8)
 
if (scale < 1 and currScale < 0.1) then
return
end
 
FluidFrames.RelativelyScaleFrame(this, scale)
FluidFrames.RelativelyScaleFrame(frame, scale)
 
local xOffset = left/scale
local yOffset = top/scale - this:GetHeight()
 
frame:SetUserPlaced(nil)
frame:ClearAllPoints()
frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", xOffset, yOffset)
frame:SetUserPlaced(1)
 
self:ClearAllPoints()
self:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", xOffset, yOffset)
 
else
self.count = 0
local frame = self.frame
 
if (this.isResizing) then
local wScale = self:GetWidth()/frame:GetWidth()
if (frame.MFwScale) then
frame.MFwScale = frame.MFwScale * wScale
else
frame.MFwScale = wScale
end
local hScale = self:GetHeight()/frame:GetHeight()
if (frame.MFhScale) then
frame.MFhScale = frame.MFhScale * hScale
else
frame.MFhScale = hScale
end
 
FluidFrames.RescaleFrame(frame, wScale, hScale, not IsAltKeyDown())
end
 
frame:SetUserPlaced(nil)
frame:ClearAllPoints()
frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", self:GetLeft(), self:GetBottom())
frame:SetUserPlaced(1)
 
end
if self.setparent_flag then
self.setparent_flag = nil
FluidFrames.RestoreSetParent()
end
if self.show_flag then
self.show_flag = nil
FluidFrames.RestoreHide()
end
end
 
function FluidFrames.InitEventFrame()
408,1080 → 267,13
end
local eventFrame = CreateFrame("Frame", "FluidEventFrame", UIParent)
eventFrame:RegisterEvent("VARIABLES_LOADED")
eventFrame:SetScript("OnEvent", FluidFrames.OnEvent)
eventFrame:SetScript("OnEvent", FluidFrames.EventOnEvent)
eventFrame:SetScript("OnUpdate", FluidFrames.EventOnUpdate)
FluidFrames.EventFrame = eventFrame
end
 
function FluidFrames.InitDraggableFrame()
if (FluidFrames.DragFrame) then
return
end
 
local dragFrame = CreateFrame("Frame", "FluidFrame", UIParent)
dragFrame:Hide()
dragFrame:SetToplevel(1)
dragFrame:SetFrameStrata("TOOLTIP")
dragFrame:SetResizable(1)
dragFrame:SetMovable(1)
dragFrame:EnableMouse("LeftButton")
dragFrame:SetAlpha(0.25)
 
dragFrame:SetScript("OnMouseDown", FluidFrames.StartMoving)
dragFrame:SetScript("OnMouseUp", FluidFrames.StopDragFrameMovingOrSizing)
dragFrame:SetScript("OnUpdate", FluidFrames.OnUpdate)
 
local minsize = 10
 
FluidFrames.DragFrame = dragFrame
 
--dragFrame:CreateTitleRegion():SetAllPoints(dragFrame)
--Frame:GetTitleRegion()
 
local red = 0
local green = 0.2
local blue = 0.7
-- Don't make bigger than the UIParent?
dragFrame:SetMinResize(minsize, minsize)
--dragFrame:SetMaxResize()
 
local background = dragFrame:CreateTexture("FluidFrameBackground", "BACKGROUND")
background:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
background:SetVertexColor(red, green, blue)
background:SetPoint("TOP", 0, -2)
background:SetPoint("BOTTOM", 0, 1)
background:SetPoint("LEFT", 1, 0)
background:SetPoint("RIGHT", -1, 0)
 
local ResizeTopLeft = CreateFrame("Button", "FluidFrameResizeTopLeft", dragFrame)
--ResizeTopLeft:SetFrameLevel(ResizeTopLeft:GetFrameLevel()-1)
ResizeTopLeft:SetHeight(16)
ResizeTopLeft:SetWidth(16)
ResizeTopLeft:SetPoint("TOPLEFT", -2, 2)
local rtlTexture = ResizeTopLeft:CreateTexture("FluidFramertlTexture", "BACKGROUND")
rtlTexture:SetVertexColor(red, green, blue)
rtlTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rtlTexture:SetAllPoints(ResizeTopLeft) --TOPLEFT 16/16?
rtlTexture:SetTexCoord(0, 0.25, 0, 0.125)
ResizeTopLeft:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "TOPLEFT") end)
ResizeTopLeft:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeTopLeft:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rtlTexture) end)
ResizeTopLeft:SetScript("OnLeave", function() rtlTexture:SetVertexColor(red, green, blue) end)
 
local ResizeTopRight = CreateFrame("Button", "FluidFrameResizeTopRight", dragFrame)
--ResizeTopRight:SetFrameLevel(ResizeTopRight:GetFrameLevel()-1)
ResizeTopRight:SetHeight(16)
ResizeTopRight:SetWidth(16)
ResizeTopRight:SetPoint("TOPRIGHT", 2, 2)
local rtrTexture = ResizeTopRight:CreateTexture("FluidFramertrTexture", "BACKGROUND")
rtrTexture:SetVertexColor(red, green, blue)
rtrTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rtrTexture:SetAllPoints(ResizeTopRight) --TOPRIGHT 16/16?
rtrTexture:SetTexCoord(0.75, 1.0, 0, 0.125)
ResizeTopRight:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "TOPRIGHT") end)
ResizeTopRight:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeTopRight:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rtrTexture) end)
ResizeTopRight:SetScript("OnLeave", function() rtrTexture:SetVertexColor(red, green, blue) end)
 
local ResizeBottomLeft = CreateFrame("Button", "FluidFrameResizeBottomLeft", dragFrame)
--ResizeBottomLeft:SetFrameLevel(ResizeBottomLeft:GetFrameLevel()-1)
ResizeBottomLeft:SetHeight(16)
ResizeBottomLeft:SetWidth(16)
ResizeBottomLeft:SetPoint("BOTTOMLEFT", -2, -3)
local rblTexture = ResizeBottomLeft:CreateTexture("FluidFramerblTexture", "BACKGROUND")
rblTexture:SetVertexColor(red, green, blue)
rblTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rblTexture:SetAllPoints(ResizeBottomLeft) --TOPLEFT 16/16?
rblTexture:SetTexCoord(0, 0.25, 0.7265625, 0.8515625)
ResizeBottomLeft:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "BOTTOMLEFT") end)
ResizeBottomLeft:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeBottomLeft:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rblTexture) end)
ResizeBottomLeft:SetScript("OnLeave", function() rblTexture:SetVertexColor(red, green, blue) end)
 
local ResizeBottomRight = CreateFrame("Button", "FluidFrameResizeBottomRight", dragFrame)
--ResizeBottomRight:SetFrameLevel(ResizeBottomRight:GetFrameLevel()-1)
ResizeBottomRight:SetHeight(16)
ResizeBottomRight:SetWidth(16)
ResizeBottomRight:SetPoint("BOTTOMRIGHT", 2, -3)
local rbrTexture = ResizeBottomRight:CreateTexture("FluidFramerbrTexture", "BACKGROUND")
rbrTexture:SetVertexColor(red, green, blue)
rbrTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rbrTexture:SetAllPoints(ResizeBottomRight) --BOTTOMRIGHT 16/16?
rbrTexture:SetTexCoord(0.75, 1.0, 0.7265625, 0.8515625)
ResizeBottomRight:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "BOTTOMRIGHT") end)
ResizeBottomRight:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeBottomRight:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rbrTexture) end)
ResizeBottomRight:SetScript("OnLeave", function() rbrTexture:SetVertexColor(red, green, blue) end)
 
local ResizeTop = CreateFrame("Button", "FluidFrameResizeTop", dragFrame)
--ResizeTop:SetFrameLevel(ResizeTop:GetFrameLevel()-1)
ResizeTop:SetHeight(16)
ResizeTop:SetWidth(16)
ResizeTop:SetPoint("LEFT", ResizeTopLeft, "RIGHT", 0, 0)
ResizeTop:SetPoint("RIGHT", ResizeTopRight, "LEFT", 0, 0)
local rtTexture = ResizeTop:CreateTexture("FluidFramertTexture", "BACKGROUND")
rtTexture:SetVertexColor(red, green, blue)
rtTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rtTexture:SetAllPoints(ResizeTop)
rtTexture:SetTexCoord(0.25, 0.75, 0, 0.125)
ResizeTop:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "TOP") end)
ResizeTop:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeTop:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rtTexture) end)
ResizeTop:SetScript("OnLeave", function() rtTexture:SetVertexColor(red, green, blue) end)
 
local ResizeBottom = CreateFrame("Button", "FluidFrameResizeBottom", dragFrame)
--ResizeBottom:SetFrameLevel(ResizeBottom:GetFrameLevel()-1)
ResizeBottom:SetHeight(16)
ResizeBottom:SetWidth(16)
ResizeBottom:SetPoint("LEFT", ResizeBottomLeft, "RIGHT", 0, 0)
ResizeBottom:SetPoint("RIGHT", ResizeBottomRight, "LEFT", 0, 0)
local rbTexture = ResizeBottom:CreateTexture("FluidFramerbTexture", "BACKGROUND")
rbTexture:SetVertexColor(red, green, blue)
rbTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rbTexture:SetAllPoints(ResizeBottom) --TOPLEFT 16/16?
rbTexture:SetTexCoord(0.25, 0.75, 0.7265625, 0.8515625)
ResizeBottom:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "BOTTOM") end)
ResizeBottom:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeBottom:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rbTexture) end)
ResizeBottom:SetScript("OnLeave", function() rbTexture:SetVertexColor(red, green, blue) end)
 
local ResizeLeft = CreateFrame("Button", "FluidFrameResizeLeft", dragFrame)
--ResizeLeft:SetFrameLevel(ResizeLeft:GetFrameLevel()-1)
ResizeLeft:SetHeight(16)
ResizeLeft:SetWidth(16)
ResizeLeft:SetPoint("TOP", ResizeTopLeft, "BOTTOM", 0, 0)
ResizeLeft:SetPoint("BOTTOM", ResizeBottomLeft, "TOP", 0, 0)
local rbTexture = ResizeLeft:CreateTexture("FluidFramerbTexture", "BACKGROUND")
rbTexture:SetVertexColor(red, green, blue)
rbTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rbTexture:SetAllPoints(ResizeLeft)
rbTexture:SetTexCoord(0, 0.25, 0.125, 0.7265625)
ResizeLeft:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "LEFT") end)
ResizeLeft:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeLeft:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rbTexture) end)
ResizeLeft:SetScript("OnLeave", function() rbTexture:SetVertexColor(red, green, blue) end)
 
local ResizeRight = CreateFrame("Button", "FluidFrameResizeRight", dragFrame)
--ResizeRight:SetFrameLevel(ResizeRight:GetFrameLevel()-1)
ResizeRight:SetHeight(16)
ResizeRight:SetWidth(16)
ResizeRight:SetPoint("TOP", ResizeTopRight, "BOTTOM", 0, 0)
ResizeRight:SetPoint("BOTTOM", ResizeBottomRight, "TOP", 0, 0)
local rrTexture = ResizeRight:CreateTexture("FluidFramerrTexture", "BACKGROUND")
rrTexture:SetVertexColor(red, green, blue)
rrTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rrTexture:SetAllPoints(ResizeRight)
rrTexture:SetTexCoord(0.75, 1.0, 0.125, 0.7265625)
ResizeRight:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "RIGHT") end)
ResizeRight:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeRight:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rrTexture) end)
ResizeRight:SetScript("OnLeave", function() rrTexture:SetVertexColor(red, green, blue) end)
 
local Scale = CreateFrame("Button", "FluidFrameRescale", dragFrame)
Scale:SetFrameLevel(Scale:GetFrameLevel()+1)
Scale:SetHeight(20)
Scale:SetWidth(20)
Scale:SetPoint("BOTTOMRIGHT", 20, -20)
local sTexture = Scale:CreateTexture("FluidFrameRescaleTexture", "BACKGROUND")
sTexture:SetVertexColor(red, green, blue)
sTexture:SetTexture("Interface\\AddOns\\FluidFrames\\Skin\\Rescale")
sTexture:SetAllPoints(Scale)
Scale:SetScript("OnMouseDown", FluidFrames.StartParentRescaling)
Scale:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
Scale:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(sTexture) end)
Scale:SetScript("OnLeave", function() sTexture:SetVertexColor(red, green, blue) end)
 
local HideButton = CreateFrame("Button", "FluidFrameHideButton", dragFrame, "UIPanelButtonTemplate2")
HideButton:SetText(HIDE)
HideButton:SetPoint("BOTTOM", dragFrame, "TOP", 10, 0)
HideButton:SetScript("OnClick", FluidFrames.HideButton_OnClick)
HideButton:SetClampedToScreen(1)
end
 
function FluidFrames.SetColorHighlight(frame)
if (IsShiftKeyDown()) then
frame:SetVertexColor(1, 0.82, 0)
end
end
 
function FluidFrames.HideButton_OnClick(self)
if (FluidFrames.DragFrame.frame.FFHidden) then
FluidFrames.UnlockHiddenFrame(FluidFrames.DragFrame.frame)
self:SetText(HIDE)
else
FluidFrames.StoreFrameDefault(FluidFrames.DragFrame.frame)
FluidFrames.LockHiddenFrame(FluidFrames.DragFrame.frame)
self:SetText(SHOW)
end
end
 
function FluidFrames.StartParentResizing(self, button, anchorPoint)
local frame = self:GetParent()
if (frame.isLocked) then
return
end
if (frame:IsProtected() and InCombatLockdown()) then
Print(format(FLUIDFRAMES_CANT_RESIZE_IN_COMBAT, frame:GetName()))
return
elseif (button == "RightButton") then
FluidFrames.ResetFrame(frame.frame)
elseif (IsShiftKeyDown()) then
FluidFrames.StoreFrameDefault(frame.frame, true, true)
FluidFrames.Mobilize(frame.frame)
FluidFrames.FreeFrameFromParent(frame.frame)
frame.isResizing = true
frame:StartSizing(anchorPoint)
else
FluidFrames.StoreFrameDefault(frame.frame)
FluidFrames.Mobilize(frame.frame)
FluidFrames.FreeFrameFromParent(frame.frame)
frame:StartMoving()
frame.isMoving = true
end
end
 
function FluidFrames.StartMoving(self, button)
if (self.frame:IsProtected() and InCombatLockdown()) then
Print(format(FLUIDFRAMES_CANT_MOVE_IN_COMBAT, self.frame:GetName()))
return
elseif (button == "RightButton") then
FluidFrames.ResetFrame(self.frame)
elseif (not self.isLocked) then
FluidFrames.StoreFrameDefault(self.frame)
FluidFrames.Mobilize(self.frame)
FluidFrames.FreeFrameFromParent(self.frame)
self:StartMoving()
self.isMoving = true
end
end
 
function FluidFrames.StartParentRescaling(self, button)
local frame = self:GetParent()
if (frame:IsProtected() and InCombatLockdown()) then
Print(format(FLUIDFRAMES_CANT_RESCALE_IN_COMBAT, frame:GetName()))
return
elseif (button == "RightButton") then
FluidFrames.ResetFrame(frame.frame)
elseif (IsShiftKeyDown()) then
if (not frame.isLocked) then
FluidFrames.StoreFrameDefault(frame.frame, true)
FluidFrames.Mobilize(frame.frame)
FluidFrames.FreeFrameFromParent(frame.frame)
frame.isRescaling = true
end
else
FluidFrames.StoreFrameDefault(frame.frame)
FluidFrames.Mobilize(frame.frame)
FluidFrames.FreeFrameFromParent(frame.frame)
frame:StartMoving()
frame.isMoving = true
end
end
 
function FluidFrames.StopParentMovingOrSizing(self)
if (button ~= "RightButton") then
local frame = self:GetParent()
frame:StopMovingOrSizing()
if (frame.isRescaling or frame.isResizing or frame.isMoving) then
local storeScale = frame.isRescaling or frame.isResizing
local storeDimentions = frame.isResizing
frame.isMoving = nil
frame.isResizing = nil
frame.isRescaling = nil
FluidFrames.ImmobilizeAndStoreDimentions(frame.frame, storeScale, storeDimentions)
end
end
end
 
function FluidFrames.StopDragFrameMovingOrSizing(self)
if (button ~= "RightButton") then
self:StopMovingOrSizing()
local storeScale = self.isRescaling or self.isResizing
local storeDimentions = self.isResizing
self.isMoving = nil
self.isResizing = nil
self.isRescaling = nil
FluidFrames.ImmobilizeAndStoreDimentions(self.frame, storeScale, storeDimentions)
end
end
 
--/z FluidFrames.StartFrameResize(FriendsFrame)
function FluidFrames.StartFrameResize(frame)
if (not frame) then
return
elseif (frame:IsProtected() and InCombatLockdown()) then
Print(format(FLUIDFRAMES_CANT_RESIZE_IN_COMBAT, frame:GetName()))
return
end
FluidFrames.InitDraggableFrame()
local dragFrame = FluidFrames.DragFrame
 
Print(format(FLUIDFRAMES_START_RESIZE, OrNil(frame:GetName())))
 
dragFrame:SetWidth(frame:GetWidth())
dragFrame:SetHeight(frame:GetHeight())
local left = frame:GetLeft()
local bottom = frame:GetBottom()
dragFrame:ClearAllPoints()
dragFrame:SetPoint("BOTTOMLEFT", left, bottom)
frame:SetUserPlaced(nil)
frame:ClearAllPoints()
frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
frame:SetUserPlaced(1)
dragFrame.frame = frame
dragFrame:Show()
end
 
function FluidFrames.EndResizeFrame(frame)
if (not frame) then
return
end
local dragFrame = FluidFrames.DragFrame
 
Print(format(FLUIDFRAMES_STOP_RESIZE, OrNil(frame:GetName())))
 
dragFrame.frame = nil
dragFrame:Hide()
end
 
function FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings, ...)
for i=1, select("#", ...) do
local child = select(i, ...)
if (child) then
if (child:IsObjectType("FontString")) then
local fontName, fontHeight, fontFlags = child:GetFont()
if (fontName and fontHeight > 0 and heightScale ~= child:GetParent():GetScale()) then
child:SetFont(fontName, fontHeight*heightScale, fontFlags)
--Print("Resizing FontString: "..(child:GetName() or "<Unnamed>").." Scale: "..FluidFrames.Round(heightScale, 100).." FontSize: "..FluidFrames.Round(fontHeight*heightScale, 100))
end
if ( resizeFontStrings and child:GetStringWidth() > 0 and not FluidFrames.Compare(child:GetStringWidth(), child:GetWidth()) ) then
--Use height for now, untill there's a way to check if the FontString has been absoolutely sized or not
if (child.GetName and child:GetName()) then
--Print(child:GetName()..": resizeFontStrings - "..floor(child:GetStringWidth()).." "..floor(child:GetWidth()).." "..floor(child:GetHeight()).." "..FluidFrames.Round(heightScale, 100))
child:SetWidth(child:GetWidth()*heightScale)
child:SetHeight(child:GetHeight()*heightScale)
--Print("SetWidth: "..FluidFrames.Round(child:GetWidth()*heightScale, 100).." SetHeight: "..FluidFrames.Round(child:GetHeight()*heightScale, 100))
end
end
else
child:SetWidth(child:GetWidth()*widthScale)
child:SetHeight(child:GetHeight()*heightScale)
end
if (child.GetChildren) then
FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings, child:GetChildren())
end
if (child.GetRegions) then
FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings, child:GetRegions())
end
 
if (child.GetNumPoints) then
for p=1, child:GetNumPoints() do
local point, relativeTo, relativePoint, xOffset, yOffset = child:GetPoint(p)
child:SetPoint(point, relativeTo, relativePoint, xOffset*widthScale, yOffset*heightScale)
end
end
end
end
end
 
--/z FluidFrames.RescaleFrame(ShapeshiftBarFrame, 1.5, 1)
--/z FluidFrames.RescaleFrame(PlayerFrame, 1.5, 1)
function FluidFrames.RescaleFrame(frame, widthScale, heightScale, resizeFontStrings)
if (not frame) then
return
elseif (frame:IsProtected() and InCombatLockdown()) then
return
end
 
frame:SetWidth(frame:GetWidth()*widthScale)
frame:SetHeight(frame:GetHeight()*heightScale)
 
if (frame.GetChildren) then
FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings, frame:GetChildren())
end
if (frame.GetRegions) then
FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings, frame:GetRegions())
end
end
 
function FluidFrames.RelativelyScaleFrame(frame, scale)
if (not frame) then
return
end
frame:SetScale(frame:GetScale()*scale)
end
 
----------------------------
-- Frame Stack Code
----------------------------
 
FluidFrames.FrameStack = {}
FluidFrames.ExcludedFrames = {
WorldFrame = true,
UIParent = true,
 
MainMenuBarArtFrame = true,
MainMenuBarOverlayFrame = true,
TargetFrameTextureFrame = true,
LFGWizardFrame = true,
FriendsListFrame = true,
}
for i=1, NUM_CONTAINER_FRAMES do
FluidFrames.ExcludedFrames["ContainerFrame"..i] = true
end
 
function FluidFrames.IsChildFrame(frame, child)
if (not frame or not child) then
return
end
while (child ~= frame) do
child = child:GetParent()
if (not child) then
return false
end
end
return true
end
 
function FluidFrames.BuildCursorFrameStack()
local stack = FluidFrames.FrameStack
 
--Empty Stack
local stackSize = #stack
while (stackSize > 0) do
tremove(stack, #stack)
stackSize = #stack
end
 
local frame = EnumerateFrames()
while (frame) do
local frameName = frame.GetName and frame:GetName()
if (frame:IsVisible()
and (not frameName or not FluidFrames.ExcludedFrames[frameName])
and MouseIsOver(frame)
and not FluidFrames.IsChildFrame(FluidFrames.DragFrame, frame)
) then
tinsert(stack, frame)
end
frame = EnumerateFrames(frame)
end
end
 
function FluidFrames.GetNextStackFrame(frame, showAll)
local stack = FluidFrames.FrameStack
 
local returnNext
 
if (not frame) then
if (#stack > 0) then
returnNext = true
else
return
end
end
 
for i, sFrame in ipairs(stack) do
if (showAll or sFrame:GetName()) then
if (returnNext) then
return sFrame
elseif (frame == sFrame) then
returnNext = true
end
end
end
end
 
 
function FluidFrames.GetPreviousStackFrame(frame)
local stack = FluidFrames.FrameStack
 
if (not frame) then
if (#stack > 0) then
return stack[#stack]
else
return
end
end
 
local prevFrame
for i, sFrame in ipairs(stack) do
if (frame == sFrame) then
return prevFrame
end
prevFrame = sFrame
end
end
 
----------------------------
-- Highlight a Frame
----------------------------
 
function FluidFrames.HighlightMouseFrame(showAll)
 
local dragFrame = FluidFrames.DragFrame
 
if (dragFrame.isResizing) then
dragFrame:StopMovingOrSizing()
dragFrame.isResizing = nil
end
 
FluidFrames.BuildCursorFrameStack()
 
local newFrame
if (not dragFrame:IsVisible()) then
if (IsShiftKeyDown()) then
newFrame = FluidFrames.GetPreviousStackFrame()
else
newFrame = FluidFrames.GetNextStackFrame()
end
else
if (#FluidFrames.FrameStack > 0) then
if (IsShiftKeyDown()) then
newFrame = FluidFrames.GetPreviousStackFrame(dragFrame.frame)
else
newFrame = FluidFrames.GetNextStackFrame(dragFrame.frame)
end
if (not newFrame) then
dragFrame.frame = nil
dragFrame:Hide()
return
end
end
end
 
if (not newFrame) then
Print(FLUIDFRAMES_NO_MOVABLE_FRAMES)
dragFrame.frame = nil
dragFrame:Hide()
return
end
 
 
local parent = newFrame:GetParent()
Print(format(FLUIDFRAMES_HIGHLIGHT, OrNil(newFrame:GetName()), OrNil(parent and parent:GetName())))
 
dragFrame:SetWidth(newFrame:GetWidth())
dragFrame:SetHeight(newFrame:GetHeight())
local scale = newFrame:GetEffectiveScale()/UIParent:GetEffectiveScale()
dragFrame:SetScale(scale)
local left = newFrame:GetLeft()
local bottom = newFrame:GetBottom()
dragFrame:ClearAllPoints()
dragFrame:SetPoint("BOTTOMLEFT", left, bottom)
 
newFrame:SetMovable(1)
 
if (parent == UIParent or parent == nil) then
--[[
newFrame:SetUserPlaced(nil)
newFrame:ClearAllPoints()
newFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
newFrame:SetUserPlaced(1)
]]--
end
 
dragFrame.frame = newFrame
dragFrame:Show()
end
 
----------------------------
-- Immobilization Code
----------------------------
 
function FluidFrames.SetPointHook(self, ...)
if (self.FFImmobilized) then
--DebugPrint(format("%s:SetPoint intercepted - Immobilized.", self:GetName()))
local data = FluidFramesModifiedFrames[self:GetName()]
if (data and data.immobilized) then
if (self:IsProtected() and InCombatLockdown()) then
DebugPrint(format("%s:SetPoint intercepted - Can't move in combat.", self:GetName()))
else
self.FFImmobilized = nil
self:ClearAllPoints()
self:SetPoint(unpack(data.immobilized.point))
self.FFImmobilized = true
DebugPrint(format("%s:SetPoint intercepted - Moved to saved location.", self:GetName()))
end
end
else
--DebugPrint(format("%s:SetPoint intercepted - Mobile: %s.", self:GetName(), (this and this.GetName and this:GetName() or "Unknown")))
end
end
 
function FluidFrames.SetWidthHook(self, width)
if (self.FFImmobilized) then
DebugPrint(format("%s:SetWidth intercepted - %s.", self:GetName(), width))
-- Allow SetWidth when immobilized, update saved data
local data = FluidFramesModifiedFrames[self:GetName()]
if (data and data.immobilized and data.immobilized.width and data.width) then
-- Update Reset Width by scaling by difference between the previous immobilized width and the new width
data.width = data.width * (width / data.immobilized.width)
-- Update Immobilized Width
data.immobilized.width = width
end
end
end
 
function FluidFrames.SetHeightHook(self, height)
if (self.FFImmobilized) then
DebugPrint(format("%s:SetHeight intercepted - %s.", self:GetName(), height))
-- Allow SetHeight when immobilized, update saved data
local data = FluidFramesModifiedFrames[self:GetName()]
if (data and data.immobilized and data.immobilized.height and data.height) then
-- Update Reset Height by scaling by difference between the previous immobilized height and the new height
data.height = data.height * (height / data.immobilized.height)
-- Update Immobilized Height
data.immobilized.height = height
--[[ Update position (since it's will be set from the bottom left)
self.FFImmobilized = nil
self:ClearAllPoints()
self:SetPoint(unpack(data.immobilized.point))
self.FFImmobilized = true
]]--
end
end
end
 
function FluidFrames.SetParentHook(self, oldParent)
if (self.FFImmobilized) then
local newParent = getglobal(FluidFrames.NEW_PARENT)
DebugPrint(format("%s:SetParent intercepted - %s.", self:GetName(), oldParent.GetName and oldParent:GetName() or oldParent))
-- Undo SetParent
self.FFImmobilized = nil
FluidFrames.ReparentAssociatedFrames(self, oldParent, newParent)
self.FFImmobilized = true
end
end
 
function FluidFrames.SetImmobilizeHooks(frame)
if (not frame.FFSetXHooked) then
hooksecurefunc(frame, "SetPoint", FluidFrames.SetPointHook)
hooksecurefunc(frame, "SetWidth", FluidFrames.SetWidthHook)
hooksecurefunc(frame, "SetHeight", FluidFrames.SetHeightHook)
hooksecurefunc(frame, "SetParent", FluidFrames.SetParentHook)
frame.FFSetXHooked = true
end
end
 
 
function FluidFrames.Immobilize(frame)
if (frame.GetName and frame:GetName()) then
 
FluidFrames.SetImmobilizeHooks(frame)
 
-- Should be just a single point relative to UIParent. Maybe store in SV? Set relativeTo = "UIParent"?
local data = FluidFramesModifiedFrames[frame:GetName()]
if (data) then
local point = { frame:GetPoint(1) }
if (point[2] == UIParent) then
point[2] = "UIParent"
frame.FFImmobilized = true
 
if (not data.immobilized) then
data.immobilized = {}
end
data.immobilized.point = point
else
if (data.immobilized) then
if (not data.immobilized.scale) then
data.immobilized = nil
else
data.immobilized.point = nil
end
end
frame.FFImmobilized = nil
Print(format(FLUIDFRAMES_CANT_IMMOBILIZE_NOT_UIPARENT, frame:GetName()))
end
else
Print(format(FLUIDFRAMES_CANT_IMMOBILIZE_NO_DEFAULT, frame:GetName()))
end
else
Print(FLUIDFRAMES_CANT_IMMOBILIZE_UNNAMED)
end
end
 
function FluidFrames.ImmobilizeAndStoreDimentions(frame, storeScale, storeDimentions)
if (frame.GetName and frame:GetName()) then
 
FluidFrames.SetImmobilizeHooks(frame)
 
-- Should be just a single point relative to UIParent. Maybe store in SV? Set relativeTo = "UIParent"?
local data = FluidFramesModifiedFrames[frame:GetName()]
if (data) then
local point = { frame:GetPoint(1) }
if (point[2] == UIParent) then
point[2] = "UIParent"
frame.FFImmobilized = true
 
if (not data.immobilized) then
data.immobilized = {}
end
data.immobilized.point = point
if (storeScale) then
data.immobilized.scale = frame:GetScale()
end
if (storeDimentions) then
data.immobilized.height = frame:GetHeight()
data.immobilized.width = frame:GetWidth()
end
else
data.immobilized = nil
frame.FFImmobilized = nil
Print(format(FLUIDFRAMES_CANT_IMMOBILIZE_NOT_UIPARENT, frame:GetName()))
end
else
Print(format(FLUIDFRAMES_CANT_IMMOBILIZE_NO_DEFAULT, frame:GetName()))
end
else
Print(FLUIDFRAMES_CANT_IMMOBILIZE_UNNAMED)
end
end
 
function FluidFrames.Mobilize(frame)
frame.FFImmobilized = nil
if (frame.GetName and frame:GetName()) then
local data = FluidFramesModifiedFrames[frame:GetName()]
if (data and data.immobilized) then
data.immobilized.point = nil
--data.immobilized = nil
end
end
end
 
 
----------------------------
-- Accociative Reparent Code (Fixes things like dragging ActionBar1
----------------------------
 
function FluidFrames.FreeFrameSiblingsFromParent(frame, oldParent, newParent, reShow, ...)
for i=1, select("#", ...) do
local sibling = select(i, ...)
if (sibling and sibling:GetParent() == oldParent) then
if (sibling:GetNumPoints() == 1) then
local pdata = { sibling:GetPoint(1) }
if (pdata[2] == frame) then
if (sibling.GetName) then
DebugPrint(format(FLUIDFRAMES_REPARENTING_SIBLING, sibling:GetName(), OrNil(oldParent:GetName()), OrNil(newParent:GetName())))
end
sibling:SetParent(newParent)
--if (reShow and sibling:IsShown()) then
-- sibling:Show()
--end
FluidFrames.FreeFrameSiblingsFromParent(sibling, oldParent, newParent, reShow, ...)
FluidFrames.FreeFrameSiblingsFromParent(sibling, oldParent, newParent, reShow, ...)
end
end
end
end
end
--/z FluidFrames.FreeFrameSiblingsFromParent(ActionButton1, MainMenuBarArtFrame, UIParent, MainMenuBarArtFrame:GetChildren())
--/z FluidFrames.FreeFrameSiblingsFromParent(CharacterMicroButton, MainMenuBarArtFrame, UIParent, MainMenuBarArtFrame:GetChildren())
 
--[[
function FluidFrames.HasHiddenAncestorFrame(frame)
local parent = frame:GetParent()
if (not parent or FluidFrames.ExcludedFrames[parent]) then
return false
elseif (parent.FFHidden) then
return true
else
return FluidFrames.HasHiddenAncestorFrame(parent)
end
end
]]--
 
function FluidFrames.ReparentAssociatedFrames(frame, oldParent, newParent)
if (oldParent and oldParent ~= newParent) then
frame:SetParent(newParent)
--local reShow = FluidFrames.HasHiddenAncestorFrame(oldParent)
--if (reShow and frame:IsShown()) then
-- frame:Show()
--end
DebugPrint(format(FLUIDFRAMES_REPARENTING, frame:GetName(), OrNil(oldParent:GetName()), OrNil(newParent:GetName())))
FluidFrames.FreeFrameSiblingsFromParent(frame, oldParent, newParent, reShow, oldParent:GetChildren())
FluidFrames.FreeFrameSiblingsFromParent(frame, oldParent, newParent, reShow, oldParent:GetRegions())
end
end
 
function FluidFrames.FreeFrameFromParent(frame)
local oldParent = frame:GetParent()
if (oldParent) then
local newParent = getglobal(FluidFrames.NEW_PARENT)
FluidFrames.ReparentAssociatedFrames(frame, oldParent, newParent)
end
end
 
function FluidFrames.ResetFrameParent(frame, origParent)
--local parent = getglobal(FluidFrames.NEW_PARENT)
local parent = frame:GetParent()
FluidFrames.ReparentAssociatedFrames(frame, parent, origParent)
end
 
----------------------------
-- Hide Code
----------------------------
 
function FluidFrames.ShowHook(self)
if (self.FFHidden) then
self:Hide()
end
end
 
--/z FluidFrames.LockHiddenFrame(MainMenuBar)
function FluidFrames.LockHiddenFrame(frame)
if (frame.GetName and frame:GetName()) then
if (not frame.FFShowHooked) then
hooksecurefunc(frame, "Show", FluidFrames.ShowHook)
frame.FFShowHooked = true
end
local data = FluidFramesModifiedFrames[frame:GetName()]
if (data) then
DebugPrint(format("Hiding: %s", frame:GetName()))
frame.FFHidden = true
data.hidden = true
data.unitAttr = frame:GetAttribute("unit")
if (data.unitAttr) then
frame:SetAttribute("unit", nil)
end
frame:Hide()
FluidFrames.UpdateGUI()
else
DebugPrint(format(FLUIDFRAMES_CANT_HIDE, frame:GetName()))
end
end
end
 
--/z FluidFrames.UnlockHiddenFrame(MainMenuBar)
--MainMenuBarBackpackButton:Show()
function FluidFrames.UnlockHiddenFrame(frame)
if (frame.GetName and frame:GetName()) then
local data = FluidFramesModifiedFrames[frame:GetName()]
if (data) then
DebugPrint(format("Un-hiding: %s", frame:GetName()))
frame.FFHidden = nil
data.hidden = nil
if (data.unitAttr) then
frame:SetAttribute("unit", data.unitAttr)
data.unitAttr = nil
end
frame:Show()
FluidFrames.UpdateGUI()
else
DebugPrint(format(FLUIDFRAMES_CANT_HIDE, frame:GetName()))
end
end
end
 
----------------------------
-- Reset Code
----------------------------
 
FluidFramesModifiedFrames = {}
 
function FluidFrames.StoreFrameDefault(frame, storeScale, storeDimentions)
local name = frame:GetName()
if (not name) then
return
end
local data = FluidFramesModifiedFrames[name]
if (not data) then
data = {}
end
if (storeScale and not data.scale) then
data.scale = frame:GetScale()
end
if (storeDimentions and (not data.height or not data.width)) then
data.height = frame:GetHeight()
data.width = frame:GetWidth()
end
if (not data.parent) then
local parent = frame:GetParent()
data.parent = parent and parent:GetName() or parent
end
if (not data.point) then
data.point = {}
for i=1, frame:GetNumPoints() do
local pdata = { frame:GetPoint(i) }
--{ point, relativeTo, relativePoint, xofs, yofs }
if (pdata[2] and pdata[2].GetName and pdata[2]:GetName()) then
pdata[2] = pdata[2]:GetName()
tinsert(data.point, pdata)
else
--No anchor name.... won't save accross sessions (deleted on VARIABLES_LOADED).
Print(format(FLUIDFRAMES_UNNAMED_ANCHOR, name))
tinsert(data.point, pdata)
end
end
end
if (not FluidFramesModifiedFrames[name]) then
FluidFramesModifiedFrames[name] = data
FluidFrames.UpdateGUI()
end
end
 
function FluidFrames.ResetFrame(frame)
-- Remove saved position regardless.
frame:SetUserPlaced(nil)
 
local name = frame:GetName()
if (not name) then
Print(FLUIDFRAMES_CANT_RESET_UNNAMED)
return
elseif (not FluidFramesModifiedFrames[name]) then
Print(format(FLUIDFRAMES_CANT_RESET_NO_DEFAULT, name))
return
end
local data = FluidFramesModifiedFrames[name]
--WOW Crash!!! uncomment this and reset a frame. FluidFrames.RescaleFrame(frame, data.width/frame:GetWidth(), data.height/frame:GetHeight())
 
FluidFrames.Mobilize(frame)
 
if (type(data.parent) == "string") then
local parent = getglobal(data.parent)
if (parent) then
FluidFrames.ResetFrameParent(frame, parent)
end
elseif (type(data.parent) == "table") then
FluidFrames.ResetFrameParent(frame, data.parent)
end
 
if (data.scale) then
frame:SetScale(data.scale)
end
 
if (data.width and data.height) then
local widthScale = data.width/frame:GetWidth()
local heightScale = data.height/frame:GetHeight()
FluidFrames.RescaleFrame(frame, widthScale, heightScale, true)
end
 
frame:ClearAllPoints()
for i=1, #data.point do
frame:SetPoint(data.point[i][1], data.point[i][2], data.point[i][3], data.point[i][4], data.point[i][5])
end
 
FluidFrames.UnlockHiddenFrame(frame)
 
FluidFramesModifiedFrames[name] = nil
 
-- Refresh frame with it's OnShow updates
frame:Hide()
frame:Show()
 
FluidFrames.DragFrame.frame = nil
FluidFrames.DragFrame:Hide()
 
FluidFrames.UpdateGUI()
Print(format(FLUIDFRAMES_RESET, name))
end
 
function FluidFrames.ResetAll()
FluidFrames.DoNotUpdateGUI = true
for k,v in pairs(FluidFramesModifiedFrames) do
local frame = getglobal(k)
if (frame) then
FluidFrames.ResetFrame(frame)
else
Print(format(FLUIDFRAMES_CANT_RESET_NOT_FOUND, k))
end
end
FluidFrames.DoNotUpdateGUI = nil
FluidFrames.UpdateGUI()
Print(FLUIDFRAMES_RESET_ALL_FINISHED)
end
 
SlashCmdList["FLUIDFRAMESSLASH"] = FluidFrames.ResetAll;
 
function FluidFrames.ReshowAll()
FluidFrames.DoNotUpdateGUI = true
for k,v in pairs(FluidFramesModifiedFrames) do
local frame = getglobal(k)
if (frame and frame.FFHidden) then
FluidFrames.UnlockHiddenFrame(frame)
end
end
FluidFrames.DoNotUpdateGUI = nil
FluidFrames.UpdateGUI()
Print(FLUIDFRAMES_RESHOW_ALL_FINISHED)
end
 
 
----------------------------
-- Portfolio Registration
----------------------------
 
function FluidFrames.UpdateGUI()
if (Portfolio) then
if (not FluidFrames.DoNotUpdateGUI) then
--TODO: add update options to show hidden and moved frames
--FluidFrames.RegisterPortfolio(true)
end
end
end
 
function FluidFrames.RegisterPortfolio()
 
local Portfolio = LibStub and LibStub("Portfolio")
if not Portfolio then return end
 
local optionTable = {
id="FluidFrames";
subText=FLUIDFRAMES_DESC_FULL;
options={
-- Pulls the first header and helptext from the addon toc data
{
id = "TempDraggable";
text = FLUIDFRAMES_TEMP_DRAGGABLE;
type = CONTROLTYPE_CHECKBOX;
callback = function(value)
FluidFrames.ToggleTempDraggableFrames(value == "1")
end;
defaultValue = "1",
};
{
id = "Reset";
text = FLUIDFRAMES_RESET_ALL;
type = CONTROLTYPE_BUTTON;
callback = FluidFrames.ResetAll;
point = {nil, nil, nil, 0, -30};
};
{
id = "Reshow";
text = FLUIDFRAMES_RESHOW_ALL;
type = CONTROLTYPE_BUTTON;
callback = FluidFrames.ReshowAll;
point = {"TOPLEFT", "Reset", "TOPRIGHT", 40, 0};
};
{
id = "Help";
text = FLUIDFRAMES_HELP_HEADER;
subText = FLUIDFRAMES_HELP1..FLUIDFRAMES_NEWLINE..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP2..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP3..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP4..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP5..FLUIDFRAMES_NEWLINE..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP6..FLUIDFRAMES_NEWLINE..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP7..FLUIDFRAMES_NEWLINE..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP8;
type = CONTROLTYPE_HEADER;
point = {nil, "Reset", nil, nil, -40};
init = function(header, subtext)
subtext:SetHeight(140)
end;
};
};
savedVarTable = "FluidFrames_SavedVars";
}
 
Portfolio.RegisterOptionSet(optionTable)
end
 
FluidFrames.RegisterPortfolio()
 
 
----------------------------
-- OnLoad Inits
----------------------------
FluidFrames.InitDraggableFrame()
FluidFrames.InitEventFrame()
 
trunk/FluidFrames/FrameHighlight.lua New file
0,0 → 1,172
----------------------------
-- Frame Stack Code
----------------------------
 
FluidFrames.FrameStack = {}
FluidFrames.ExcludedFrames = {
WorldFrame = true,
UIParent = true,
 
MainMenuBarArtFrame = true,
MainMenuBarOverlayFrame = true,
TargetFrameTextureFrame = true,
LFGWizardFrame = true,
FriendsListFrame = true,
}
for i=1, NUM_CONTAINER_FRAMES do
FluidFrames.ExcludedFrames["ContainerFrame"..i] = true
end
 
function FluidFrames.IsChildFrame(frame, child)
if (not frame or not child) then
return
end
while (child ~= frame) do
child = child:GetParent()
if (not child) then
return false
end
end
return true
end
 
function FluidFrames.BuildCursorFrameStack()
local stack = FluidFrames.FrameStack
 
--Empty Stack
local stackSize = #stack
while (stackSize > 0) do
tremove(stack, #stack)
stackSize = #stack
end
 
local frame = EnumerateFrames()
while (frame) do
local frameName = frame.GetName and frame:GetName()
if (frame:IsVisible()
and (not frameName or not FluidFrames.ExcludedFrames[frameName])
and MouseIsOver(frame)
and not FluidFrames.IsChildFrame(FluidFrames.DragFrame, frame)
) then
tinsert(stack, frame)
end
frame = EnumerateFrames(frame)
end
end
 
function FluidFrames.GetNextStackFrame(frame, showAll)
local stack = FluidFrames.FrameStack
 
local returnNext
 
if (not frame) then
if (#stack > 0) then
returnNext = true
else
return
end
end
 
for i, sFrame in ipairs(stack) do
if (showAll or sFrame:GetName()) then
if (returnNext) then
return sFrame
elseif (frame == sFrame) then
returnNext = true
end
end
end
end
 
 
function FluidFrames.GetPreviousStackFrame(frame)
local stack = FluidFrames.FrameStack
 
if (not frame) then
if (#stack > 0) then
return stack[#stack]
else
return
end
end
 
local prevFrame
for i, sFrame in ipairs(stack) do
if (frame == sFrame) then
return prevFrame
end
prevFrame = sFrame
end
end
 
----------------------------
-- Frame Highlight
----------------------------
 
function FluidFrames.HighlightMouseFrame(showAll)
 
local dragFrame = FluidFrames.DragFrame
 
if (dragFrame.isResizing) then
dragFrame:StopMovingOrSizing()
dragFrame.isResizing = nil
end
 
FluidFrames.BuildCursorFrameStack()
 
local newFrame
if (not dragFrame:IsVisible()) then
if (IsShiftKeyDown()) then
newFrame = FluidFrames.GetPreviousStackFrame()
else
newFrame = FluidFrames.GetNextStackFrame()
end
else
if (#FluidFrames.FrameStack > 0) then
if (IsShiftKeyDown()) then
newFrame = FluidFrames.GetPreviousStackFrame(dragFrame.frame)
else
newFrame = FluidFrames.GetNextStackFrame(dragFrame.frame)
end
if (not newFrame) then
dragFrame.frame = nil
dragFrame:Hide()
return
end
end
end
 
if (not newFrame) then
FluidFrames.Print(FLUIDFRAMES_NO_MOVABLE_FRAMES)
dragFrame.frame = nil
dragFrame:Hide()
return
end
 
 
local parent = newFrame:GetParent()
FluidFrames.Print(format(FLUIDFRAMES_HIGHLIGHT, FluidFrames.OrNil(newFrame:GetName()), FluidFrames.OrNil(parent and parent:GetName())))
 
dragFrame:SetWidth(newFrame:GetWidth())
dragFrame:SetHeight(newFrame:GetHeight())
local scale = newFrame:GetEffectiveScale()/UIParent:GetEffectiveScale()
dragFrame:SetScale(scale)
local left = newFrame:GetLeft()
local bottom = newFrame:GetBottom()
dragFrame:ClearAllPoints()
dragFrame:SetPoint("BOTTOMLEFT", left, bottom)
 
newFrame:SetMovable(1)
 
if (parent == UIParent or parent == nil) then
--[[
newFrame:SetUserPlaced(nil)
newFrame:ClearAllPoints()
newFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
newFrame:SetUserPlaced(1)
]]--
end
 
dragFrame.frame = newFrame
dragFrame:Show()
end
trunk/FluidFrames/DraggableFrame.lua New file
0,0 → 1,409
----------------------------
-- Draggable Frame
----------------------------
 
function FluidFrames.InitDraggableFrame()
if (FluidFrames.DragFrame) then
return
end
 
local dragFrame = CreateFrame("Frame", "FluidFrame", UIParent)
dragFrame:Hide()
dragFrame:SetToplevel(1)
dragFrame:SetFrameStrata("TOOLTIP")
dragFrame:SetResizable(1)
dragFrame:SetMovable(1)
dragFrame:EnableMouse("LeftButton")
dragFrame:SetAlpha(0.25)
 
dragFrame:SetScript("OnMouseDown", FluidFrames.StartMoving)
dragFrame:SetScript("OnMouseUp", FluidFrames.StopDragFrameMovingOrSizing)
dragFrame:SetScript("OnUpdate", FluidFrames.OnUpdate)
 
local minsize = 10
 
FluidFrames.DragFrame = dragFrame
 
--dragFrame:CreateTitleRegion():SetAllPoints(dragFrame)
--Frame:GetTitleRegion()
 
local red = 0
local green = 0.2
local blue = 0.7
-- Don't make bigger than the UIParent?
dragFrame:SetMinResize(minsize, minsize)
--dragFrame:SetMaxResize()
 
local background = dragFrame:CreateTexture("FluidFrameBackground", "BACKGROUND")
background:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
background:SetVertexColor(red, green, blue)
background:SetPoint("TOP", 0, -2)
background:SetPoint("BOTTOM", 0, 1)
background:SetPoint("LEFT", 1, 0)
background:SetPoint("RIGHT", -1, 0)
 
local ResizeTopLeft = CreateFrame("Button", "FluidFrameResizeTopLeft", dragFrame)
--ResizeTopLeft:SetFrameLevel(ResizeTopLeft:GetFrameLevel()-1)
ResizeTopLeft:SetHeight(16)
ResizeTopLeft:SetWidth(16)
ResizeTopLeft:SetPoint("TOPLEFT", -2, 2)
local rtlTexture = ResizeTopLeft:CreateTexture("FluidFramertlTexture", "BACKGROUND")
rtlTexture:SetVertexColor(red, green, blue)
rtlTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rtlTexture:SetAllPoints(ResizeTopLeft) --TOPLEFT 16/16?
rtlTexture:SetTexCoord(0, 0.25, 0, 0.125)
ResizeTopLeft:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "TOPLEFT") end)
ResizeTopLeft:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeTopLeft:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rtlTexture) end)
ResizeTopLeft:SetScript("OnLeave", function() rtlTexture:SetVertexColor(red, green, blue) end)
 
local ResizeTopRight = CreateFrame("Button", "FluidFrameResizeTopRight", dragFrame)
--ResizeTopRight:SetFrameLevel(ResizeTopRight:GetFrameLevel()-1)
ResizeTopRight:SetHeight(16)
ResizeTopRight:SetWidth(16)
ResizeTopRight:SetPoint("TOPRIGHT", 2, 2)
local rtrTexture = ResizeTopRight:CreateTexture("FluidFramertrTexture", "BACKGROUND")
rtrTexture:SetVertexColor(red, green, blue)
rtrTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rtrTexture:SetAllPoints(ResizeTopRight) --TOPRIGHT 16/16?
rtrTexture:SetTexCoord(0.75, 1.0, 0, 0.125)
ResizeTopRight:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "TOPRIGHT") end)
ResizeTopRight:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeTopRight:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rtrTexture) end)
ResizeTopRight:SetScript("OnLeave", function() rtrTexture:SetVertexColor(red, green, blue) end)
 
local ResizeBottomLeft = CreateFrame("Button", "FluidFrameResizeBottomLeft", dragFrame)
--ResizeBottomLeft:SetFrameLevel(ResizeBottomLeft:GetFrameLevel()-1)
ResizeBottomLeft:SetHeight(16)
ResizeBottomLeft:SetWidth(16)
ResizeBottomLeft:SetPoint("BOTTOMLEFT", -2, -3)
local rblTexture = ResizeBottomLeft:CreateTexture("FluidFramerblTexture", "BACKGROUND")
rblTexture:SetVertexColor(red, green, blue)
rblTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rblTexture:SetAllPoints(ResizeBottomLeft) --TOPLEFT 16/16?
rblTexture:SetTexCoord(0, 0.25, 0.7265625, 0.8515625)
ResizeBottomLeft:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "BOTTOMLEFT") end)
ResizeBottomLeft:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeBottomLeft:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rblTexture) end)
ResizeBottomLeft:SetScript("OnLeave", function() rblTexture:SetVertexColor(red, green, blue) end)
 
local ResizeBottomRight = CreateFrame("Button", "FluidFrameResizeBottomRight", dragFrame)
--ResizeBottomRight:SetFrameLevel(ResizeBottomRight:GetFrameLevel()-1)
ResizeBottomRight:SetHeight(16)
ResizeBottomRight:SetWidth(16)
ResizeBottomRight:SetPoint("BOTTOMRIGHT", 2, -3)
local rbrTexture = ResizeBottomRight:CreateTexture("FluidFramerbrTexture", "BACKGROUND")
rbrTexture:SetVertexColor(red, green, blue)
rbrTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rbrTexture:SetAllPoints(ResizeBottomRight) --BOTTOMRIGHT 16/16?
rbrTexture:SetTexCoord(0.75, 1.0, 0.7265625, 0.8515625)
ResizeBottomRight:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "BOTTOMRIGHT") end)
ResizeBottomRight:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeBottomRight:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rbrTexture) end)
ResizeBottomRight:SetScript("OnLeave", function() rbrTexture:SetVertexColor(red, green, blue) end)
 
local ResizeTop = CreateFrame("Button", "FluidFrameResizeTop", dragFrame)
--ResizeTop:SetFrameLevel(ResizeTop:GetFrameLevel()-1)
ResizeTop:SetHeight(16)
ResizeTop:SetWidth(16)
ResizeTop:SetPoint("LEFT", ResizeTopLeft, "RIGHT", 0, 0)
ResizeTop:SetPoint("RIGHT", ResizeTopRight, "LEFT", 0, 0)
local rtTexture = ResizeTop:CreateTexture("FluidFramertTexture", "BACKGROUND")
rtTexture:SetVertexColor(red, green, blue)
rtTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rtTexture:SetAllPoints(ResizeTop)
rtTexture:SetTexCoord(0.25, 0.75, 0, 0.125)
ResizeTop:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "TOP") end)
ResizeTop:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeTop:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rtTexture) end)
ResizeTop:SetScript("OnLeave", function() rtTexture:SetVertexColor(red, green, blue) end)
 
local ResizeBottom = CreateFrame("Button", "FluidFrameResizeBottom", dragFrame)
--ResizeBottom:SetFrameLevel(ResizeBottom:GetFrameLevel()-1)
ResizeBottom:SetHeight(16)
ResizeBottom:SetWidth(16)
ResizeBottom:SetPoint("LEFT", ResizeBottomLeft, "RIGHT", 0, 0)
ResizeBottom:SetPoint("RIGHT", ResizeBottomRight, "LEFT", 0, 0)
local rbTexture = ResizeBottom:CreateTexture("FluidFramerbTexture", "BACKGROUND")
rbTexture:SetVertexColor(red, green, blue)
rbTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rbTexture:SetAllPoints(ResizeBottom) --TOPLEFT 16/16?
rbTexture:SetTexCoord(0.25, 0.75, 0.7265625, 0.8515625)
ResizeBottom:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "BOTTOM") end)
ResizeBottom:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeBottom:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rbTexture) end)
ResizeBottom:SetScript("OnLeave", function() rbTexture:SetVertexColor(red, green, blue) end)
 
local ResizeLeft = CreateFrame("Button", "FluidFrameResizeLeft", dragFrame)
--ResizeLeft:SetFrameLevel(ResizeLeft:GetFrameLevel()-1)
ResizeLeft:SetHeight(16)
ResizeLeft:SetWidth(16)
ResizeLeft:SetPoint("TOP", ResizeTopLeft, "BOTTOM", 0, 0)
ResizeLeft:SetPoint("BOTTOM", ResizeBottomLeft, "TOP", 0, 0)
local rbTexture = ResizeLeft:CreateTexture("FluidFramerbTexture", "BACKGROUND")
rbTexture:SetVertexColor(red, green, blue)
rbTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rbTexture:SetAllPoints(ResizeLeft)
rbTexture:SetTexCoord(0, 0.25, 0.125, 0.7265625)
ResizeLeft:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "LEFT") end)
ResizeLeft:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeLeft:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rbTexture) end)
ResizeLeft:SetScript("OnLeave", function() rbTexture:SetVertexColor(red, green, blue) end)
 
local ResizeRight = CreateFrame("Button", "FluidFrameResizeRight", dragFrame)
--ResizeRight:SetFrameLevel(ResizeRight:GetFrameLevel()-1)
ResizeRight:SetHeight(16)
ResizeRight:SetWidth(16)
ResizeRight:SetPoint("TOP", ResizeTopRight, "BOTTOM", 0, 0)
ResizeRight:SetPoint("BOTTOM", ResizeBottomRight, "TOP", 0, 0)
local rrTexture = ResizeRight:CreateTexture("FluidFramerrTexture", "BACKGROUND")
rrTexture:SetVertexColor(red, green, blue)
rrTexture:SetTexture("Interface\\ChatFrame\\ChatFrameBorder")
rrTexture:SetAllPoints(ResizeRight)
rrTexture:SetTexCoord(0.75, 1.0, 0.125, 0.7265625)
ResizeRight:SetScript("OnMouseDown", function(self, button) FluidFrames.StartParentResizing(self, button, "RIGHT") end)
ResizeRight:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
ResizeRight:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(rrTexture) end)
ResizeRight:SetScript("OnLeave", function() rrTexture:SetVertexColor(red, green, blue) end)
 
local Scale = CreateFrame("Button", "FluidFrameRescale", dragFrame)
Scale:SetFrameLevel(Scale:GetFrameLevel()+1)
Scale:SetHeight(20)
Scale:SetWidth(20)
Scale:SetPoint("BOTTOMRIGHT", 20, -20)
local sTexture = Scale:CreateTexture("FluidFrameRescaleTexture", "BACKGROUND")
sTexture:SetVertexColor(red, green, blue)
sTexture:SetTexture("Interface\\AddOns\\FluidFrames\\Skin\\Rescale")
sTexture:SetAllPoints(Scale)
Scale:SetScript("OnMouseDown", FluidFrames.StartParentRescaling)
Scale:SetScript("OnMouseUp", FluidFrames.StopParentMovingOrSizing)
Scale:SetScript("OnEnter", function() FluidFrames.SetColorHighlight(sTexture) end)
Scale:SetScript("OnLeave", function() sTexture:SetVertexColor(red, green, blue) end)
 
local HideButton = CreateFrame("Button", "FluidFrameHideButton", dragFrame, "UIPanelButtonTemplate2")
HideButton:SetText(HIDE)
HideButton:SetPoint("BOTTOM", dragFrame, "TOP", 10, 0)
HideButton:SetScript("OnClick", FluidFrames.HideButton_OnClick)
HideButton:SetClampedToScreen(1)
end
 
function FluidFrames.SetColorHighlight(frame)
if (IsShiftKeyDown()) then
frame:SetVertexColor(1, 0.82, 0)
end
end
 
function FluidFrames.HideButton_OnClick(self)
if (FluidFrames.DragFrame.frame.FFHidden) then
FluidFrames.UnlockHiddenFrame(FluidFrames.DragFrame.frame)
self:SetText(HIDE)
else
FluidFrames.StoreFrameDefault(FluidFrames.DragFrame.frame)
FluidFrames.LockHiddenFrame(FluidFrames.DragFrame.frame)
self:SetText(SHOW)
end
end
 
function FluidFrames.StartParentResizing(self, button, anchorPoint)
local frame = self:GetParent()
if (frame.isLocked) then
return
end
if (frame:IsProtected() and InCombatLockdown()) then
FluidFrames.Print(format(FLUIDFRAMES_CANT_RESIZE_IN_COMBAT, frame:GetName()))
return
elseif (button == "RightButton") then
FluidFrames.ResetFrame(frame.frame)
elseif (IsShiftKeyDown()) then
FluidFrames.StoreFrameDefault(frame.frame, true, true)
FluidFrames.Mobilize(frame.frame)
FluidFrames.FreeFrameFromParent(frame.frame)
frame.isResizing = true
frame:StartSizing(anchorPoint)
else
FluidFrames.StoreFrameDefault(frame.frame)
FluidFrames.Mobilize(frame.frame)
FluidFrames.FreeFrameFromParent(frame.frame)
frame:StartMoving()
frame.isMoving = true
end
end
 
function FluidFrames.StartMoving(self, button)
if (self.frame:IsProtected() and InCombatLockdown()) then
FluidFrames.Print(format(FLUIDFRAMES_CANT_MOVE_IN_COMBAT, self.frame:GetName()))
return
elseif (button == "RightButton") then
FluidFrames.ResetFrame(self.frame)
elseif (not self.isLocked) then
FluidFrames.StoreFrameDefault(self.frame)
FluidFrames.Mobilize(self.frame)
FluidFrames.FreeFrameFromParent(self.frame)
self:StartMoving()
self.isMoving = true
end
end
 
function FluidFrames.StartParentRescaling(self, button)
local frame = self:GetParent()
if (frame:IsProtected() and InCombatLockdown()) then
FluidFrames.Print(format(FLUIDFRAMES_CANT_RESCALE_IN_COMBAT, frame:GetName()))
return
elseif (button == "RightButton") then
FluidFrames.ResetFrame(frame.frame)
elseif (IsShiftKeyDown()) then
if (not frame.isLocked) then
FluidFrames.StoreFrameDefault(frame.frame, true)
FluidFrames.Mobilize(frame.frame)
FluidFrames.FreeFrameFromParent(frame.frame)
frame.isRescaling = true
end
else
FluidFrames.StoreFrameDefault(frame.frame)
FluidFrames.Mobilize(frame.frame)
FluidFrames.FreeFrameFromParent(frame.frame)
frame:StartMoving()
frame.isMoving = true
end
end
 
function FluidFrames.StopParentMovingOrSizing(self)
if (button ~= "RightButton") then
local frame = self:GetParent()
frame:StopMovingOrSizing()
if (frame.isRescaling or frame.isResizing or frame.isMoving) then
local storeScale = frame.isRescaling or frame.isResizing
local storeDimentions = frame.isResizing
frame.isMoving = nil
frame.isResizing = nil
frame.isRescaling = nil
FluidFrames.ImmobilizeAndStoreDimentions(frame.frame, storeScale, storeDimentions)
end
end
end
 
function FluidFrames.StopDragFrameMovingOrSizing(self)
if (button ~= "RightButton") then
self:StopMovingOrSizing()
local storeScale = self.isRescaling or self.isResizing
local storeDimentions = self.isResizing
self.isMoving = nil
self.isResizing = nil
self.isRescaling = nil
FluidFrames.ImmobilizeAndStoreDimentions(self.frame, storeScale, storeDimentions)
end
end
 
--/z FluidFrames.StartFrameResize(FriendsFrame)
function FluidFrames.StartFrameResize(frame)
if (not frame) then
return
elseif (frame:IsProtected() and InCombatLockdown()) then
FluidFrames.Print(format(FLUIDFRAMES_CANT_RESIZE_IN_COMBAT, frame:GetName()))
return
end
FluidFrames.InitDraggableFrame()
local dragFrame = FluidFrames.DragFrame
 
FluidFrames.Print(format(FLUIDFRAMES_START_RESIZE, FluidFrames.OrNil(frame:GetName())))
 
dragFrame:SetWidth(frame:GetWidth())
dragFrame:SetHeight(frame:GetHeight())
local left = frame:GetLeft()
local bottom = frame:GetBottom()
dragFrame:ClearAllPoints()
dragFrame:SetPoint("BOTTOMLEFT", left, bottom)
frame:SetUserPlaced(nil)
frame:ClearAllPoints()
frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
frame:SetUserPlaced(1)
dragFrame.frame = frame
dragFrame:Show()
end
 
function FluidFrames.EndResizeFrame(frame)
if (not frame) then
return
end
local dragFrame = FluidFrames.DragFrame
 
FluidFrames.Print(format(FLUIDFRAMES_STOP_RESIZE, FluidFrames.OrNil(frame:GetName())))
 
dragFrame.frame = nil
dragFrame:Hide()
end
 
function FluidFrames.OnUpdate(self, delay)
if (self.frame and (self.isResizing or self.isMoving or self.isRescaling)) then
if (not this.count) then
self.count = delay
elseif (this.count < .02) then
self.count = self.count + delay
 
elseif (this.isRescaling) then
this.count = 0
local frame = self.frame
 
local x, y = GetCursorPosition()
local UIScale = UIParent:GetEffectiveScale()
local currScale = self:GetEffectiveScale()
x = x / currScale - 10 / currScale
y = y / currScale + 10 / currScale
local left = self:GetLeft()
local top = self:GetTop()
local wScale = (x-left)/self:GetWidth()
local hScale = (top-y)/self:GetHeight()
local scale = max(min(max(wScale, hScale), 1.2), 0.8)
 
if (scale < 1 and currScale < 0.1) then
return
end
 
FluidFrames.RelativelyScaleFrame(this, scale)
FluidFrames.RelativelyScaleFrame(frame, scale)
 
local xOffset = left/scale
local yOffset = top/scale - this:GetHeight()
 
frame:SetUserPlaced(nil)
frame:ClearAllPoints()
frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", xOffset, yOffset)
frame:SetUserPlaced(1)
 
self:ClearAllPoints()
self:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", xOffset, yOffset)
 
else
self.count = 0
local frame = self.frame
 
if (this.isResizing) then
local wScale = self:GetWidth()/frame:GetWidth()
if (frame.MFwScale) then
frame.MFwScale = frame.MFwScale * wScale
else
frame.MFwScale = wScale
end
local hScale = self:GetHeight()/frame:GetHeight()
if (frame.MFhScale) then
frame.MFhScale = frame.MFhScale * hScale
else
frame.MFhScale = hScale
end
 
FluidFrames.RescaleFrame(frame, wScale, hScale, not IsAltKeyDown())
end
 
frame:SetUserPlaced(nil)
frame:ClearAllPoints()
frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", self:GetLeft(), self:GetBottom())
frame:SetUserPlaced(1)
 
end
end
end
 
----------------------------
-- OnLoad Inits
----------------------------
FluidFrames.InitDraggableFrame()
trunk/FluidFrames/FrameTempDragging.lua New file
0,0 → 1,127
----------------------------
-- Temp Draggable Frames
----------------------------
 
FluidFrames.FramesToDragByParent = {
"PaperDollFrame",
"ReputationFrame",
"SkillFrame",
"PVPFrameHonor",
"PetPaperDollFrame",
"PetPaperDollFrameCompanionFrame",
"TokenFrame",
"PVPFrame",
"SendMailFrame",
}
 
function FluidFrames.InitTempDraggableFrames()
-- Make UIPanels temporarily draggable (position not saved)
for frameName,info in pairs(UIPanelWindows) do
if (info.area ~= "full") then
local frame = getglobal(frameName)
if (frame and frame.GetTitleRegion) then
local titleRegion = frame:GetTitleRegion()
if (not titleRegion) then
titleRegion = frame:CreateTitleRegion()
end
--titleRegion:SetAllPoints(frame)
frame:EnableMouse(1)
end
end
end
 
--[[
for i,frameName in pairs(UIChildWindows) do
local frame = getglobal(frameName)
if (frame and frame.GetTitleRegion) then
local titleRegion = frame:GetTitleRegion()
if (not titleRegion) then
titleRegion = frame:CreateTitleRegion()
end
--titleRegion:SetAllPoints(frame)
frame:EnableMouse(1)
end
end
]]--
 
-- Disable the mouse on a few child frames so that the parent is draggable
for i,frameName in ipairs(FluidFrames.FramesToDragByParent) do
local frame = getglobal(frameName)
if (frame) then
frame:EnableMouse(nil)
end
end
 
-- Update Enabled (mostly for LoD)
if (FluidFrames_SavedVars) then
FluidFrames.ToggleTempDraggableFrames(FluidFrames_SavedVars.TempDraggable == "1")
end
end
 
function FluidFrames.ToggleTempDraggableFrames(value)
for frameName,info in pairs(UIPanelWindows) do
if (info.area ~= "full") then
local frame = getglobal(frameName)
if (frame and frame.GetTitleRegion) then
local titleRegion = frame:GetTitleRegion()
if (titleRegion) then
if (value) then
titleRegion:SetAllPoints(frame)
else
titleRegion:ClearAllPoints()
titleRegion:SetHeight(0)
titleRegion:SetWidth(0)
end
end
end
end
end
 
--[[
for i,frameName in pairs(UIChildWindows) do
local frame = getglobal(frameName)
if (frame and frame.GetTitleRegion) then
local titleRegion = frame:GetTitleRegion()
if (titleRegion) then
if (value) then
titleRegion:SetAllPoints(frame)
else
titleRegion:ClearAllPoints()
titleRegion:SetHeight(0)
titleRegion:SetWidth(0)
end
end
end
end
]]--
 
if (value and AchievementFrame) then
AchievementFrameHeader:EnableMouse(false)
end
end
 
function FluidFrames.ToggleTempDraggableMinimap(value)
local titleRegion = MinimapCluster:GetTitleRegion()
if (not titleRegion) then
if (value) then
--Init
MinimapCluster:SetScript("OnEnter", function()
MinimapZoneTextButton:GetScript("OnEnter")(MinimapZoneTextButton)
end)
MinimapCluster:SetScript("OnLeave", function()
MinimapZoneTextButton:GetScript("OnLeave")(MinimapZoneTextButton)
end)
titleRegion = MinimapCluster:CreateTitleRegion()
titleRegion:SetAllPoints(MinimapCluster)
MinimapZoneTextButton:EnableMouse(nil)
end
else
if (value) then
titleRegion:SetAllPoints(MinimapCluster)
else
titleRegion:ClearAllPoints()
titleRegion:SetHeight(0)
titleRegion:SetWidth(0)
end
end
end
trunk/FluidFrames/FluidImmobilize.lua New file
0,0 → 1,206
----------------------------
-- Immobilization Code
----------------------------
 
function FluidFrames.SetPointHook(self, ...)
if (self.FFImmobilized) then
--FluidFrames.DebugPrint(format("%s:SetPoint intercepted - Immobilized.", self:GetName()))
local frameName = self:GetName()
local data = FluidFramesModifiedFrames[frameName]
if (data and data.immobilized) then
if (self:IsProtected() and InCombatLockdown()) then
-- Store frame to move on next PLAYER_REGEN_ENABLED or PLAYER_ENTERING_WORLD
FluidFrames.ReanchoredFrames[frameName] = self
FluidFrames.EventFrame.secure_setpoint_flag = true
FluidFrames.DebugPrint(format("%s:SetPoint intercepted - Delayed until after combat.", frameName))
else
self.FFImmobilized = nil
self:ClearAllPoints()
self:SetPoint(unpack(data.immobilized.point))
self.FFImmobilized = true
FluidFrames.DebugPrint(format("%s:SetPoint intercepted - Moved to saved location.", frameName))
end
end
else
--FluidFrames.DebugPrint(format("%s:SetPoint intercepted - Mobile: %s.", self:GetName(), (this and this.GetName and this:GetName() or "Unknown")))
end
end
 
function FluidFrames.SetWidthHook(self, width)
if (self.FFImmobilized) then
FluidFrames.DebugPrint(format("%s:SetWidth intercepted - %s.", self:GetName(), width))
-- Allow SetWidth when immobilized, update saved data
local data = FluidFramesModifiedFrames[self:GetName()]
if (data and data.immobilized and data.immobilized.width and data.width) then
-- Update Reset Width by scaling by difference between the previous immobilized width and the new width
data.width = data.width * (width / data.immobilized.width)
-- Update Immobilized Width
data.immobilized.width = width
end
end
end
 
function FluidFrames.SetHeightHook(self, height)
if (self.FFImmobilized) then
FluidFrames.DebugPrint(format("%s:SetHeight intercepted - %s.", self:GetName(), height))
-- Allow SetHeight when immobilized, update saved data
local data = FluidFramesModifiedFrames[self:GetName()]
if (data and data.immobilized and data.immobilized.height and data.height) then
-- Update Reset Height by scaling by difference between the previous immobilized height and the new height
data.height = data.height * (height / data.immobilized.height)
-- Update Immobilized Height
data.immobilized.height = height
--[[ Update position (since it's will be set from the bottom left)
self.FFImmobilized = nil
self:ClearAllPoints()
self:SetPoint(unpack(data.immobilized.point))
self.FFImmobilized = true
]]--
end
end
end
 
function FluidFrames.SetParentHook(self, oldParent)
if (self.FFImmobilized) then
local frameName = self:GetName()
FluidFrames.DebugPrint(format("%s:SetParent intercepted - %s.", frameName, oldParent.GetName and oldParent:GetName() or oldParent))
if (self:IsProtected() and InCombatLockdown()) then
-- Store frame to reparent on next PLAYER_REGEN_ENABLED or PLAYER_ENTERING_WORLD
FluidFrames.ReparentedFrames[frameName] = self
FluidFrames.EventFrame.secure_setparent_flag = true
else
-- Store frame to reparent on next OnUpdate
FluidFrames.ReparentedFrames[frameName] = self
FluidFrames.EventFrame.setparent_flag = true
end
end
end
 
function FluidFrames.SetImmobilizeHooks(frame)
if (not frame.FFSetXHooked) then
hooksecurefunc(frame, "SetParent", FluidFrames.SetParentHook)
hooksecurefunc(frame, "SetPoint", FluidFrames.SetPointHook)
hooksecurefunc(frame, "SetWidth", FluidFrames.SetWidthHook)
hooksecurefunc(frame, "SetHeight", FluidFrames.SetHeightHook)
frame.FFSetXHooked = true
end
end
 
 
function FluidFrames.Immobilize(frame)
if (frame.GetName and frame:GetName()) then
 
FluidFrames.SetImmobilizeHooks(frame)
 
-- Should be just a single point relative to UIParent. Maybe store in SV? Set relativeTo = "UIParent"?
local data = FluidFramesModifiedFrames[frame:GetName()]
if (data) then
local point = { frame:GetPoint(1) }
if (point[2] == UIParent) then
point[2] = "UIParent"
frame.FFImmobilized = true
 
if (not data.immobilized) then
data.immobilized = {}
end
data.immobilized.point = point
else
if (data.immobilized) then
if (not data.immobilized.scale) then
data.immobilized = nil
else
data.immobilized.point = nil
end
end
frame.FFImmobilized = nil
FluidFrames.Print(format(FLUIDFRAMES_CANT_IMMOBILIZE_NOT_UIPARENT, frame:GetName()))
end
else
FluidFrames.Print(format(FLUIDFRAMES_CANT_IMMOBILIZE_NO_DEFAULT, frame:GetName()))
end
else
FluidFrames.Print(FLUIDFRAMES_CANT_IMMOBILIZE_UNNAMED)
end
end
 
function FluidFrames.ImmobilizeAndStoreDimentions(frame, storeScale, storeDimentions)
if (frame.GetName and frame:GetName()) then
 
FluidFrames.SetImmobilizeHooks(frame)
 
-- Should be just a single point relative to UIParent. Maybe store in SV? Set relativeTo = "UIParent"?
local data = FluidFramesModifiedFrames[frame:GetName()]
if (data) then
local point = { frame:GetPoint(1) }
if (point[2] == UIParent) then
point[2] = "UIParent"
frame.FFImmobilized = true
 
if (not data.immobilized) then
data.immobilized = {}
end
data.immobilized.point = point
if (storeScale) then
data.immobilized.scale = frame:GetScale()
end
if (storeDimentions) then
data.immobilized.height = frame:GetHeight()
data.immobilized.width = frame:GetWidth()
end
else
data.immobilized = nil
frame.FFImmobilized = nil
FluidFrames.Print(format(FLUIDFRAMES_CANT_IMMOBILIZE_NOT_UIPARENT, frame:GetName()))
end
else
FluidFrames.Print(format(FLUIDFRAMES_CANT_IMMOBILIZE_NO_DEFAULT, frame:GetName()))
end
else
FluidFrames.Print(FLUIDFRAMES_CANT_IMMOBILIZE_UNNAMED)
end
end
 
function FluidFrames.Mobilize(frame)
frame.FFImmobilized = nil
if (frame.GetName and frame:GetName()) then
local data = FluidFramesModifiedFrames[frame:GetName()]
if (data and data.immobilized) then
data.immobilized.point = nil
--data.immobilized = nil
end
end
end
 
function FluidFrames.RestoreSetPoint()
local outOfCombat = not InCombatLockdown()
for frameName, frame in pairs(FluidFrames.ReanchoredFrames) do
if outOfCombat or not frame:IsProtected() then
local data = FluidFramesModifiedFrames[frameName]
if (data and data.immobilized) then
frame.FFImmobilized = nil
frame:ClearAllPoints()
frame:SetPoint(unpack(data.immobilized.point))
frame.FFImmobilized = true
FluidFrames.DebugPrint(format("%s - Moved to saved location.", frameName))
end
FluidFrames.ReanchoredFrames[frameName] = nil
end
end
end
 
function FluidFrames.RestoreSetParent()
local newParent = getglobal(FluidFrames.NEW_PARENT)
local outOfCombat = not InCombatLockdown()
for frameName, frame in pairs(FluidFrames.ReparentedFrames) do
if outOfCombat or not frame:IsProtected() then
local data = FluidFramesModifiedFrames[frameName]
local oldParent = frame:GetParent()
if (data and data.immobilized and oldParent ~= newParent) then
frame.FFImmobilized = nil
FluidFrames.ReparentAssociatedFrames(frame, oldParent, newParent)
frame.FFImmobilized = true
end
FluidFrames.ReparentedFrames[frameName] = nil
end
end
end
trunk/FluidFrames/FrameHide.lua New file
0,0 → 1,91
----------------------------
-- Hide Code
----------------------------
 
function FluidFrames.ShowHook(frame)
if (frame.FFHidden) then
local frameName = frame:GetName()
if frame:IsProtected() and InCombatLockdown() then
-- Store frame to hide on next PLAYER_REGEN_ENABLED or PLAYER_ENTERING_WORLD
FluidFrames.ReshownFrames[frameName] = frame
FluidFrames.EventFrame.secure_show_flag = true
FluidFrames.DebugPrint(format("%s:Show intercepted - Hide delayed until after combat.", frameName))
else
-- Store frame to hide on next OnUpdate
FluidFrames.ReshownFrames[frameName] = frame
FluidFrames.EventFrame.show_flag = true
end
end
end
 
--/z FluidFrames.LockHiddenFrame(MainMenuBar)
function FluidFrames.LockHiddenFrame(frame)
if (frame.GetName and frame:GetName()) then
if (not frame.FFShowHooked) then
hooksecurefunc(frame, "Show", FluidFrames.ShowHook)
frame.FFShowHooked = true
end
local data = FluidFramesModifiedFrames[frame:GetName()]
if (data) then
FluidFrames.DebugPrint(format("Hiding: %s", frame:GetName()))
frame.FFHidden = true
data.hidden = true
data.unitAttr = frame:GetAttribute("unit")
if (data.unitAttr) then
frame:SetAttribute("unit", nil)
end
FluidFrames.HideAssociatedFrames(frame)
FluidFrames.UpdateGUI()
else
FluidFrames.DebugPrint(format(FLUIDFRAMES_CANT_HIDE, frame:GetName()))
end
end
end
 
--/z FluidFrames.UnlockHiddenFrame(MainMenuBar)
--MainMenuBarBackpackButton:Show()
function FluidFrames.UnlockHiddenFrame(frame)
if (frame.GetName and frame:GetName()) then
local data = FluidFramesModifiedFrames[frame:GetName()]
if (data) then
FluidFrames.DebugPrint(format("Un-hiding: %s", frame:GetName()))
frame.FFHidden = nil
data.hidden = nil
if (data.unitAttr) then
frame:SetAttribute("unit", data.unitAttr)
data.unitAttr = nil
end
FluidFrames.ShowAssociatedFrames(frame)
FluidFrames.UpdateGUI()
else
FluidFrames.DebugPrint(format(FLUIDFRAMES_CANT_HIDE, frame:GetName()))
end
end
end
 
function FluidFrames.HideAssociatedFrames(frame)
for i,frame in ipairs(FluidFrames.GetPositionallyDependantOn(frame, frame:GetParent())) do
frame:Hide()
end
end
 
function FluidFrames.ShowAssociatedFrames(frame)
--TODO: only show ones that weren't manually hidden?
for i,frame in ipairs(FluidFrames.GetPositionallyDependantOn(frame, frame:GetParent())) do
frame:Show()
end
end
 
function FluidFrames.RestoreHide()
local outOfCombat = not InCombatLockdown()
for frameName, frame in pairs(FluidFrames.ReshownFrames) do
if outOfCombat or not frame:IsProtected() then
local data = FluidFramesModifiedFrames[frameName]
if (data and data.hidden) then
FluidFrames.HideAssociatedFrames(frame)
FluidFrames.DebugPrint(format("%s - ReHidden.", frameName))
end
FluidFrames.ReshownFrames[frameName] = nil
end
end
end
trunk/FluidFrames/FluidFrames.toc
5,12 → 5,22
## RequiredDeps: Portfolio
## OptionalDeps:
## SavedVariablesPerCharacter: FluidFramesModifiedFrames, FluidFrames_SavedVars
## Version: 2.2
## X-Date: Oct 15 2008
## Version: 2.3
## X-Category: Frames
## X-Revision: $Rev: 5127 $
## X-Date: $Date: 2007-11-13 18:34:54 -0600 (Tue, 13 Nov 2007) $
## X-Website: http://www.wowinterface.com/downloads/info7080-FluidFrames.html
## X-Email: karlkfi@yahoo.com
## X-Localizations: enUS
## X-CompatibleLocales: enUS, enGB
localization.en.lua
FluidFrames.lua
DraggableFrame.lua
FluidImmobilize.lua
FrameHide.lua
FrameHighlight.lua
FrameReparent.lua
FrameRescale.lua
FrameReset.lua
FrameTempDragging.lua
PortfolioRegistration.lua
trunk/FluidFrames/readme.rtf
1,6 → 1,7
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf350
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf430
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;\red0\green127\blue15;}
{\colortbl;\red255\green255\blue255;\red0\green127\blue15;\red0\green128\blue0;\red229\green229\blue229;
\red0\green0\blue0;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid1}
{\list\listtemplateid2\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid2}
{\list\listtemplateid3\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid3}
15,7 → 16,7
{\list\listtemplateid12\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid12}
{\list\listtemplateid13\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid13}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}{\listoverride\listid3\listoverridecount0\ls3}{\listoverride\listid4\listoverridecount0\ls4}{\listoverride\listid5\listoverridecount0\ls5}{\listoverride\listid6\listoverridecount0\ls6}{\listoverride\listid7\listoverridecount0\ls7}{\listoverride\listid8\listoverridecount0\ls8}{\listoverride\listid9\listoverridecount0\ls9}{\listoverride\listid10\listoverridecount0\ls10}{\listoverride\listid11\listoverridecount0\ls11}{\listoverride\listid12\listoverridecount0\ls12}{\listoverride\listid13\listoverridecount0\ls13}}
\margl1440\margr1440\vieww12240\viewh15840\viewkind1
\margl1440\margr1440\vieww12700\viewh20860\viewkind1
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural
 
\f0\b\fs48 \cf2 FluidFrames
24,6 → 25,7
\cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural
\cf0 Move, hide, scale, and resize frames with independent x&y axes.\
http://www.wowinterface.com/downloads/info7080-FluidFrames.html\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
107,11 → 109,38
\ls13\ilvl0\cf0 {\listtext \'95 }If secure frames are moved by default blizzard code while in combat they cannot be moved back until after combat. Also, you will not be able to drag secure frames in combat.\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\cf0 \
\pard\pardeftab720\ql\qnatural
 
\b\fs32 \cf3 Feedback & Support
\b0\fs26 \cf4 \
\cf5 If you have bugs or feature requests please use the buttons on the WoWInterface page.\
For other feedback, use the comments. \
If you'd like to donate to show your support, that can be done through paypal with a paypal account or by credit card. Remember donations are much appreciated but non-contractual. Thank you!\
{\field{\*\fldinst{HYPERLINK "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4165527"}}{\fldrslt https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4165527}}\cf4 \
 
\fs24 \cf0 \
 
\b\fs32 \cf3 FAQ:
\b0\fs26 \cf4 \
\cf5 Q) How do I use the same settings for all my characters?\
A) Edit FluidFrames.toc and change "SavedVariablesPerCharacter" to "SavedVariables"\
\
Q) How do I control a Vehicle/MindControl when the MainMenuBar is hidden.\
A) Temporarily unhide the MainMenuBar, highlight it and drag it up off the bottom. Execute the script "/run BonusActionBarFrame:Show()". The BonusActionBarFrame should appear bellow the MainMenuBar. Highlight it and drag it where you'd like. Highlight the MainMenuBar, right click to reset it, then click the 'Hide' button above it and un-highlight it by using the binding again. Note that if you don't do this when hiding the MainMenuBar your primary action bar bindings may break when you leave a Vehicle/MindControl.\cf4 \
 
\fs24 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
 
\b\fs36 \cf2 Change Log:
\b0\fs24 \cf0 \
\
v2.3\
- Added out of combat delays to re-hide and re-position secure frames that were moved in combat.\
- Added dependent sibling frame detection to scale/resize/hide frames that had the same parent and whose position is exclusively dependent on the frame being scaled/resized/hidden or one of its other dependent sibling frames.\
- Delayed SetParent and Show hooks to undo on the next OnUpdate so as to also catch dependent siblings parented or shown at the same time.\
- Delayed SetPoint, SetParent and Show hooks to undo when you leave combat for secure frames.\
- Refactored code to a number of files to make updating easier.\
\
v2.2\
- Enabled SendMailFrame, TokenFrame, and the PetPaperDollFrameCompanionFrame for dragging their parent frame\
- Found a bug that was breaking UIChildWindows dragging, but then decided to just disable it by design, since those frames are all anchored to their parent frame, which are draggable.\
trunk/FluidFrames/PortfolioRegistration.lua New file
0,0 → 1,120
-- <= == == == == == == == == == == == == =>
-- => Option Registration
-- <= == == == == == == == == == == == == =>
 
local Portfolio = LibStub and LibStub("Portfolio")
if not Portfolio then return end
 
local optionTable = {
id="FluidFrames";
subText=FLUIDFRAMES_DESC_FULL;
options={
-- Pulls the first header and helptext from the addon toc data
{
id = "TempDraggable";
text = FLUIDFRAMES_TEMP_DRAGGABLE;
type = CONTROLTYPE_CHECKBOX;
callback = function(value)
FluidFrames.ToggleTempDraggableFrames(value == "1")
end;
defaultValue = "1",
};
{
id = "TempDraggableMinimap";
text = FLUIDFRAMES_TEMP_DRAGGABLE_MINIMAP;
type = CONTROLTYPE_CHECKBOX;
callback = function(value)
FluidFrames.ToggleTempDraggableMinimap(value == "1")
end;
defaultValue = "0",
};
{
id = "Reset";
text = FLUIDFRAMES_RESET_ALL;
type = CONTROLTYPE_BUTTON;
callback = FluidFrames.ResetAll;
point = {nil, nil, nil, 0, -30};
};
{
id = "Reshow";
text = FLUIDFRAMES_RESHOW_ALL;
type = CONTROLTYPE_BUTTON;
callback = FluidFrames.ReshowAll;
point = {"TOPLEFT", "Reset", "TOPRIGHT", 40, 0};
};
{
id = "Help";
text = FLUIDFRAMES_HELP_HEADER;
subText = FLUIDFRAMES_HELP1..FLUIDFRAMES_NEWLINE..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP2..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP3..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP4..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP5..FLUIDFRAMES_NEWLINE..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP6..FLUIDFRAMES_NEWLINE..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP7..FLUIDFRAMES_NEWLINE..FLUIDFRAMES_NEWLINE
..FLUIDFRAMES_HELP8;
type = CONTROLTYPE_HEADER;
point = {nil, "Reset", nil, nil, -40};
init = function(header, subtext)
subtext:SetHeight(140)
end;
};
{
id = "ResetHeader";
text = "Modified Frames";
type = CONTROLTYPE_HEADER;
};
{
id = "ResetIndividual";
type = CONTROLTYPE_WINDOW;
height = 160;
options = {
};
};
{
id = "ReshowHeader";
text = "Hidden Frames";
type = CONTROLTYPE_HEADER;
};
{
id = "ReshowIndividual";
type = CONTROLTYPE_WINDOW;
height = 160;
options = {
};
};
};
savedVarTable = "FluidFrames_SavedVars";
}
 
FluidFrames.OptionsFrame = Portfolio.RegisterOptionSet(optionTable)
 
function FluidFrames.UpdateGUI()
if (FluidFrames.OptionsFrame) then
if (not FluidFrames.DoNotUpdateGUI) then
--TODO: add update options to show hidden and moved frames
--[[
local optionsFrame = FluidFrames.OptionsFrame
local resetWindow = optionsFrame:GetControl("ResetIndividual")
local frame = _G[frameName]
local option = {
id = "Reset-"..frameName;
text = "Reset";
type = CONTROLTYPE_BUTTON;
callback = function() FluidFrames.ResetFrame(frame) end;
point = {nil, nil, nil, 0, -30};
}
local control = resetWindow:RegisterControl(option)
 
option = {
id = "Reset-"..frameName;
text = "Reset";
type = CONTROLTYPE_BUTTON;
callback = function() FluidFrames.ResetFrame(frame) end;
point = {nil, nil, nil, 0, -30};
}
local control = resetWindow:RegisterControl(option)
]]--
end
end
end
trunk/FluidFrames/FrameRescale.lua New file
0,0 → 1,79
----------------------------
-- Rescale Code
----------------------------
 
function FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings, ...)
for i=1, select("#", ...) do
local child = select(i, ...)
if (child) then
if (child:IsObjectType("FontString")) then
local fontName, fontHeight, fontFlags = child:GetFont()
if (fontName and fontHeight > 0 and heightScale ~= child:GetParent():GetScale()) then
child:SetFont(fontName, fontHeight*heightScale, fontFlags)
--FluidFrames.Print("Resizing FontString: "..(child:GetName() or "<Unnamed>").." Scale: "..FluidFrames.Round(heightScale, 100).." FontSize: "..FluidFrames.Round(fontHeight*heightScale, 100))
end
if ( resizeFontStrings and child:GetStringWidth() > 0 and not FluidFrames.Compare(child:GetStringWidth(), child:GetWidth()) ) then
--Use height for now, untill there's a way to check if the FontString has been absoolutely sized or not
if (child.GetName and child:GetName()) then
--FluidFrames.Print(child:GetName()..": resizeFontStrings - "..floor(child:GetStringWidth()).." "..floor(child:GetWidth()).." "..floor(child:GetHeight()).." "..FluidFrames.Round(heightScale, 100))
child:SetWidth(child:GetWidth()*heightScale)
child:SetHeight(child:GetHeight()*heightScale)
--FluidFrames.Print("SetWidth: "..FluidFrames.Round(child:GetWidth()*heightScale, 100).." SetHeight: "..FluidFrames.Round(child:GetHeight()*heightScale, 100))
end
end
else
--FluidFrames.Print(child:GetName())
child:SetWidth(child:GetWidth()*widthScale)
child:SetHeight(child:GetHeight()*heightScale)
end
if (child.GetChildren) then
FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings, child:GetChildren())
end
if (child.GetRegions) then
FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings, child:GetRegions())
end
 
if (child.GetNumPoints) then
for p=1, child:GetNumPoints() do
local point, relativeTo, relativePoint, xOffset, yOffset = child:GetPoint(p)
child:SetPoint(point, relativeTo, relativePoint, xOffset*widthScale, yOffset*heightScale)
end
end
end
end
end
 
--/z FluidFrames.RescaleFrame(ShapeshiftBarFrame, 1.5, 1)
--/z FluidFrames.RescaleFrame(PlayerFrame, 1.5, 1)
function FluidFrames.RescaleFrame(frame, widthScale, heightScale, resizeFontStrings)
if (not frame) then
return
elseif (frame:IsProtected() and InCombatLockdown()) then
return
end
 
--frame:SetWidth(frame:GetWidth()*widthScale)
--frame:SetHeight(frame:GetHeight()*heightScale)
 
--[[
if (frame.GetChildren) then
FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings, frame:GetChildren())
end
if (frame.GetRegions) then
FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings, frame:GetRegions())
end
]]--
 
FluidFrames.RescaleChildren(widthScale, heightScale, resizeFontStrings,
unpack(FluidFrames.GetPositionallyDependantOn(frame, frame:GetParent())))
end
 
function FluidFrames.RelativelyScaleFrame(frame, scale)
if (not frame) then
return
end
--frame:SetScale(frame:GetScale()*scale)
for i,v in ipairs(FluidFrames.GetPositionallyDependantOn(frame, frame:GetParent())) do
v:SetScale(v:GetScale()*scale)
end
end
trunk/FluidFrames/localization.en.lua
61,6 → 61,7
FLUIDFRAMES_RESET_HELP = "Re-show and reset the location of %s"
FLUIDFRAMES_RESET_FEEDBACK = "%s has been reset."
FLUIDFRAMES_TEMP_DRAGGABLE = "Enable temporary dragging of UI Panels"
FLUIDFRAMES_TEMP_DRAGGABLE_MINIMAP = "Enable temporary dragging of Minimap"
 
FLUIDFRAMES_NEWLINE = "\n"