Thread Tools Display Modes
09-12-10, 06:46 AM   #1
tayedaen
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 13
Question Cata: Problem with EnumerateFrames

Hi !

I just got a problem with EnumerateFrames().
I hope somebody can enlighten me what is going on here.
It seems EnumerateFrames() is no longer iterating through ALL frames (at least not in build 12942).
Perhaps secure frames are not included, perhaps I get only frames that are not a direct child to UIParent. Who knows

For example with the following code I NEVER get the frame 'TargetFrame'.
Code:
    local frame = EnumerateFrames()
    while (frame) do
        local frameName = frame:GetName() or "noname";
        DEFAULT_CHAT_FRAME:AddMessage("frame found: "..frameName);
        frame = EnumerateFrames(frame);
    end
Do you have any idea what is happening here ?
 
09-12-10, 07:10 AM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
I noticed the same when I was editing FluidFrames to make it work on Cataclysm.

Have no idea what it skips.
 
09-12-10, 08:05 AM   #3
tayedaen
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 13
Yeah, I took your version of fluidframes, and did not get what I wanted because of this.
So I rewrote the highlighting part of it.
It's finished, but not tested yet.
I will post my code when it's tested.
 
09-12-10, 08:48 AM   #4
tayedaen
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 13
New version of 'FrameHighlight.lua':
Code:
----------------------------
-- 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.Is_Allowed(testframe)

  if not testframe then
    return false
  end

--Check 2 checks for excluded frames
  local frameName = testframe:GetName() or "noFrameName"
  if FluidFrames.ExcludedFrames[frameName] then
    return false
  end

--Check 3 checks if testframe is a child of FluidFrames.DragFrame
    while (testframe) do
        if (testframe == FluidFrames.DragFrame) then
            return false
        end
    testframe = testframe:GetParent()
    end
  return true
end

function FluidFrames.IsUnique_and_Allowed(stack,testframe)

--Check 1 checks for duplicates
    for i, frame in ipairs(stack) do
    if frame == testframe then
      return false
    end
    end

--Do the other two checks in a separate function
  local allowed = FluidFrames.Is_Allowed(testframe)

    return allowed
end

function FluidFrames.BuildCursorFrameStack()

    local stack = FluidFrames.FrameStack
    
    --Empty Stack
    local stackSize = #stack
    while (stackSize > 0) do
        tremove(stack, #stack)
        stackSize = #stack
    end
    
--Build Stack Part 1:  
--   This iterates though all frames, adding them to the stack IF the frame is underneath the mouse
    local frame = EnumerateFrames()
    while (frame) do
      if (frame:IsVisible() and MouseIsOver(frame) and FluidFrames.Is_Allowed(frame)) then
        tinsert(stack, frame)
        end
        frame = EnumerateFrames(frame)
    end
    
--Build Stack Part 2:
-- gets the frame underneath the mouse with the method GetMouseFocus()
    frame = GetMouseFocus()
    if FluidFrames.IsUnique_and_Allowed(stack,frame) then
    tinsert(stack, frame)
  end 
  
--Build Stack Part 3:
-- Iterate through all the parents of the found frames...
  local tempstack = stack
    for i, frame in ipairs(tempstack) do
    local parent = frame:GetParent()
    while (parent) do
      if (frame:IsVisible() and MouseIsOver(parent)
      and FluidFrames.IsUnique_and_Allowed(stack,parent)) then
          tinsert(stack, parent)
      end
      parent = parent:GetParent()
    end
    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

Last edited by tayedaen : 09-15-10 at 05:29 PM.
 
09-12-10, 09:21 AM   #5
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
Erm, I've a workaround in my local copy too

I just didn't want to stray too far from the "doesn't give errors" stage,
as I expect the mod to get some author love anyway (it's not abandonware).
 
09-12-10, 09:22 AM   #6
tayedaen
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 13
The code above works perfectly here.

It uses 3 different methods consecutively to get all frames:
1) EnumerateFrames()
2) GetMouseFocus()
3) It iterates though all frames from 1) and 2) and gets all parents of these frames

Duplicates are removed, and checks for excluded frames are done.
Feel free to use the code.

Last edited by tayedaen : 09-12-10 at 09:23 AM. Reason: typo
 
09-12-10, 02:43 PM   #7
Iriel
Super Moderator
WoWInterface Super Mod
Featured
Join Date: Jun 2005
Posts: 578
I'm told that a bug in the C api has been found and will be fixed in a subsequent release.
 
 

WoWInterface » AddOns, Compilations, Macros » Cataclysm Beta » Cata: Problem with EnumerateFrames

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off