1. Need some help. I made a button which displays some tracking data for Honor points. Since my 1st version of the addon, I have added additional items to track (valor and justice points for example) and made the button hight/width larger. The problem is the local cache is saving the size of the button and even though I have specified new min/max height and width in the XML, the button is being drawn at the last location and last size the user made it. The new text is appearing outside the boundary of my button background image.(If it is hard to visualize so I included a screenshot)

    Frame Issue

    If I use the mouse to resize the frame and try to make it too small, the code is preventing me from doing it (i.e. obeying the new min height/width) as designed. However as people update to the new version of the addon, it new size/height is not being used. I tried to correct this programitacly on the "next" load for people who have already been using this addon- I put some code in to detect the size of the frame and if it is too small (or to large for that matter), for the button size to the new min size..however even after executing a Frame:SetSize, it doesn't actually set the size- or if it does, it doesnt draw it the right size. Is there a away to force a re-draw of the button to the appropriate size? Here is the code snippet I am using when loading the frame (which is actually a button) and detecting if it is out of bounds (which would be the case on an addon-update from version 1 to version 2)

    The 'frame' referenced in the code is actually the pointer to the "button"

     -- OnLoad Event Code for the main Mod Frame
     function PointsTracker_OnLoad(frame)
         frame:RegisterForClicks("RightButtonUp")
         frame:RegisterForDrag("LeftButton","RightButton")
        frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
        frame:SetMinResize(200, 80)
        frame:SetMaxResize(600, 240)
        --check that the frame is the appropriate size
        widthcheck, heightcheck = frame:GetSize()
        if widthcheck > 600 then
            frame:SetSize(200,80)
        end
    
        if heightcheck > 240 then
            frame:SetSize(200,80)
        end
    
        if widthcheck < 80 then
            frame:SetSize(200,80)
        end
    
        if heightcheck < 200 then
            frame:SetSize(200,80)
        end
    

    . . . . .

  2. Where is the frames position and size set outside of this code? It may be that you are calling this code too early, before the frame has been placed and sized.. but it's hard to see that without knowing how that's being done.

    I would just add print statements to see what is happening and why your code is not being called.. or if its being overwritten later.

  3.  I actually set up the initial frame(button) in XML
    
     What I am seeing is that my check function above is actually returning the X=350 and Y=200 all the time (or close to it, something like 349.xxx and Y=199.xxx)
    
      What is happening is that when I allow people to resize the button, the game automatically saves the new size in the local-layout cache file. So in-between versions when I added a few more lines and extended the height of the frame, the boarder comes up in the middle of the frame instead of around all the corners.
    
      What I am trying to do is after loading up the addon, detect the actual size of the frame and the re-draw it to the correct size. It appears that my Call to frame:GetSize() is actually returning the values set in the XML- but the border appears to be rendering at the size in the layout-local cache file.
    
      But no matter what code I put in, even if I try to force the frame to the original size in the XML, it does not re-draw and although the frame might be the right size, the border is not rendering around the edges of the whole frame as showing my my screenshot (its terminating where the old code text stopped) This driving me insane - I know it is something subtle that I am missing but I just cant figure out what it is.
     > 
     > here is the snipit from the XML that setups up the UI for this mod.
     > 
       <Button name="PointsTrackerFrame" parent="UIParent" enableMouse="true" movable="true" resizable="true" frameStrata="LOW">
        <Size x="350" y="200" /> 
        <Anchors>
            <Anchor Points="TOP" relativePoints="BOTTOM" relativeTo="PlayerFrame">
                <Offset x="0" y="0" /> 
            </Anchor>
        </Anchors>
        <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
       <BackgroundInsets>
        <AbsInset left="11" right="12" top="12" bottom="11" /> 
        </BackgroundInsets>
       <TileSize>
        <AbsValue val="32" /> 
        </TileSize>
      <EdgeSize>
        <AbsValue val="32" /> 
        </EdgeSize>
        </Backdrop>
    
  4. I think that if I knew the steps to move a frame via LUA, then I could apply that logic to my addon.

    Pick any frame that an addon makes. Its easy to allow resizing and dragging. But if you lets say implemented a "reset to default" function and wanted to make the frame the original starting size, what is the pseudo logic code to do that?. My thinking was

    1- Get the frame handle

    2- (OPTIONAL) Hide the frame

    3- Set the frame's Parent

    4- Set the frame's height & width

    5- Set the frame's anchor points

    6- Set the frame's background (border)

    7- Re-draw the frame <==== THIS IS THE PART I DONT SEE HOW TO DO I was looking for a frame:Redraw or frame:Render or frame:Reset or something similar

    8- (OPTIONAL) Show the frame

    So this thread could boil down to 1 question possibly - how do you force the UI to re-draw a region (frame)?

    Anoher example that I could think of to explain the type of functionality I am trying to create is this:

    Draw a frame (say 100x100) with a border. Make it appear in the "UPPERLEFT" quadrant of the screen - then pause for say 15 seconds hide the frame and re-draw it in the "UPPERRIGHT" quadrant of the screen- pause 15, hide the frame and re-draw it in the "LOWERLEFT" quadrant of the screen- pause 15 then hide hte frame and re-draw it in the "LOWERRIGHT" quadrant of the screen.

  5. I think that if I knew the steps to move a frame via LUA, then I could apply that logic to my addon.

    Pick any frame that an addon makes. Its easy to allow resizing and dragging. But if you lets say implemented a "reset to default" function and wanted to make the frame the original starting size, what is the pseudo logic code to do that?. My thinking was

    1. Get the frame handle
    2. frame:ClearAllPoints()
    3. Anchor the frame using frame:SetPoint()
    4. Size the frame using frame:SetSize()

    That's it. You don't need to do anything else.

    1- Get the frame handle

    2- (OPTIONAL) Hide the frame

    Unnecessary and potentially confusing

    3- Set the frame's Parent

    Parent should never change

    4- Set the frame's height & width

    5- Set the frame's anchor points

    Can't set them without clearing them first or you'll get bad behaviour.

    6- Set the frame's background (border)

    Why did this change in the first place?

    7- Re-draw the frame <==== THIS IS THE PART I DONT SEE HOW TO DO I was looking for a frame:Redraw or frame:Render or frame:Reset or something similar

    There is no 'redraw' frame. Everything happens immediately.

    8- (OPTIONAL) Show the frame

    So this thread could boil down to 1 question possibly - how do you force the UI to re-draw a region (frame)?

    You don't. You just make the changes you want and they're instantly reflected. The screen is redrawn anywhere between 40 and 100 times a second.

    Anoher example that I could think of to explain the type of functionality I am trying to create is this:

    Draw a frame (say 100x100) with a border. Make it appear in the "UPPERLEFT" quadrant of the screen - then pause for say 15 seconds hide the frame and re-draw it in the "UPPERRIGHT" quadrant of the screen- pause 15, hide the frame and re-draw it in the "LOWERLEFT" quadrant of the screen- pause 15 then hide hte frame and re-draw it in the "LOWERRIGHT" quadrant of the screen.

    I'm not sure I understand why this is difficult. This is trivial to do by simply re-anchoring the frame every 15 seconds.

  6. First off- I'd like to thank you for taking the time to respond to my post. With other development projects (like java, google apps, python) I have tons of people to talk to and help debug, and figure stuff out together at work. However none of my colleagues know LUA or make wow addons. So there's no one to bounce questions off of! - So thanks again for responding! Please see replies below.

    I think that if I knew the steps to move a frame via LUA, then I could apply that logic to my addon.

    Pick any frame that an addon makes. Its easy to allow resizing and dragging. But if you lets say implemented a "reset to default" function and wanted to make the frame the original starting size, what is the pseudo logic code to do that?. My thinking was

    1. Get the frame handle
    2. frame:ClearAllPoints()
    3. Anchor the frame using frame:SetPoint()
    4. Size the frame using frame:SetSize()

    That's it. You don't need to do anything else.

    Good to know that my logic is basically correct. None the less when I run this code I dont see the GUI updating. The background image (the border) is cutting across the middle of the frame.

    1- Get the frame handle

    2- (OPTIONAL) Hide the frame

    Unnecessary and potentially confusing

    Agree. I just wasnt sure.

    3- Set the frame's Parent

    Parent should never change

    OK Thanks for that info.

    4- Set the frame's height & width

    5- Set the frame's anchor points

    Can't set them without clearing them first or you'll get bad behaviour.

    I've included a ClearAllPoints in my code. Thank you.

    6- Set the frame's background (border)

    Why did this change in the first place?

    This really doesn't need to change- but my symptom is that the frame size "appears" to NOT be changing due to the fact the the background border is not outlining the whole frame. Maybe this was the wrong path to take- I figured if I reapplied the background texture, this would fix the problem. This just doesn't appear to be working.

    7- Re-draw the frame <==== THIS IS THE PART I DONT SEE HOW TO DO I was looking for a frame:Redraw or frame:Render or frame:Reset or something similar

    There is no 'redraw' frame. Everything happens immediately.

    OK that is good to know. Something is overriding my settings I am assuming. What I did discover is that if I rename the frame in my code and XML to a different name i.e FrameNew (basically start over) then the initial size/position of the frame resets. So there is definitely something caching the position and size. I added a frame:SetDontSavePosition(true) into the code and confirmed that the layout-local file is no longer caching the x,y height and width of the frame now. So for my addon-issue, I can use this work-around to solve my issue where as people upgrade to my latest version, the text will now all display inside the frame and inside the boarder.

    I still want to understand what why I am having an issue with expanding the frame (remember I am using a button for this frame) with a new SetSize and actually seeing the frame (and the boarder) redraw to the new correct size.

    8- (OPTIONAL) Show the frame

    So this thread could boil down to 1 question possibly - how do you force the UI to re-draw a region (frame)?

    You don't. You just make the changes you want and they're instantly reflected. The screen is redrawn anywhere between 40 and 100 times a second.

    Anoher example that I could think of to explain the type of functionality I am trying to create is this:

    Draw a frame (say 100x100) with a border. Make it appear in the "UPPERLEFT" quadrant of the screen - then pause for say 15 seconds hide the frame and re-draw it in the "UPPERRIGHT" quadrant of the screen- pause 15, hide the frame and re-draw it in the "LOWERLEFT" quadrant of the screen- pause 15 then hide hte frame and re-draw it in the "LOWERRIGHT" quadrant of the screen.

    I'm not sure I understand why this is difficult. This is trivial to do by simply re-anchoring the frame every 15 seconds.

    It would seem trivial - however the expected behavior is not what is happening for me- I am trying to see whats wrong in my code - or perhaps what else is wrong in my game environment that is not allowing me to see my anchor change and frame size changes on the screen.

  7. First off- I'd like to thank you for taking the time to respond to my post. With other development projects (like java, google apps, python) I have tons of people to talk to and help debug, and figure stuff out together at work. However none of my colleagues know LUA or make wow addons. So there's no one to bounce questions off of! - So thanks again for responding! Please see replies below.

    No worries

    I think that if I knew the steps to move a frame via LUA, then I could apply that logic to my addon.

    Pick any frame that an addon makes. Its easy to allow resizing and dragging. But if you lets say implemented a "reset to default" function and wanted to make the frame the original starting size, what is the pseudo logic code to do that?. My thinking was

    1. Get the frame handle
    2. frame:ClearAllPoints()
    3. Anchor the frame using frame:SetPoint()
    4. Size the frame using frame:SetSize()

    That's it. You don't need to do anything else.

    Good to know that my logic is basically correct. None the less when I run this code I dont see the GUI updating. The background image (the border) is cutting across the middle of the frame.

    1- Get the frame handle

    2- (OPTIONAL) Hide the frame

    Unnecessary and potentially confusing

    Agree. I just wasnt sure.

    3- Set the frame's Parent

    Parent should never change

    OK Thanks for that info.

    4- Set the frame's height & width

    5- Set the frame's anchor points

    Can't set them without clearing them first or you'll get bad behaviour.

    I've included a ClearAllPoints in my code. Thank you.

    6- Set the frame's background (border)

    Why did this change in the first place?

    This really doesn't need to change- but my symptom is that the frame size "appears" to NOT be changing due to the fact the the background border is not outlining the whole frame. Maybe this was the wrong path to take- I figured if I reapplied the background texture, this would fix the problem. This just doesn't appear to be working.

    If you want to see the size of the frame, create a texture that is setAllPoints="true" and then give it a color rather than a file. Something like red, that you can't miss. This will tell you where and how large your frame is all the time and may work better than a backdrop.

    7- Re-draw the frame <==== THIS IS THE PART I DONT SEE HOW TO DO I was looking for a frame:Redraw or frame:Render or frame:Reset or something similar

    There is no 'redraw' frame. Everything happens immediately.

    OK that is good to know. Something is overriding my settings I am assuming. What I did discover is that if I rename the frame in my code and XML to a different name i.e FrameNew (basically start over) then the initial size/position of the frame resets. So there is definitely something caching the position and size. I added a frame:SetDontSavePosition(true) into the code and confirmed that the layout-local file is no longer caching the x,y height and width of the frame now. So for my addon-issue, I can use this work-around to solve my issue where as people upgrade to my latest version, the text will now all display inside the frame and inside the boarder.

    You can always check the size using GetRect(). It also may help to remove the backdrop SetBackdrop(nil) and then re-apply. It's hard to tell.

    I still want to understand what why I am having an issue with expanding the frame (remember I am using a button for this frame) with a new SetSize and actually seeing the frame (and the boarder) redraw to the new correct size.

    8- (OPTIONAL) Show the frame

    So this thread could boil down to 1 question possibly - how do you force the UI to re-draw a region (frame)?

    You don't. You just make the changes you want and they're instantly reflected. The screen is redrawn anywhere between 40 and 100 times a second.

    Anoher example that I could think of to explain the type of functionality I am trying to create is this:

    Draw a frame (say 100x100) with a border. Make it appear in the "UPPERLEFT" quadrant of the screen - then pause for say 15 seconds hide the frame and re-draw it in the "UPPERRIGHT" quadrant of the screen- pause 15, hide the frame and re-draw it in the "LOWERLEFT" quadrant of the screen- pause 15 then hide hte frame and re-draw it in the "LOWERRIGHT" quadrant of the screen.

    I'm not sure I understand why this is difficult. This is trivial to do by simply re-anchoring the frame every 15 seconds.

    It would seem trivial - however the expected behavior is not what is happening for me- I am trying to see whats wrong in my code - or perhaps what else is wrong in my game environment that is not allowing me to see my anchor change and frame size changes on the screen.

    What doesn't work about this? What happens instead?

  8. I figured it out finally! I believe this was a timing issue.I was firing my code in the frame_Onload event - this was actually too soon. I moved it to fire in the frame_OnEvent for "VARIABLES_LOADED"and now it is working. The "print statement for debugging" suggestion really helped me figure out what was going on.

    Thanks!

    Here's the code block

          function PointsTracker_ResetButton(frame)
                frame:ClearAllPoints()
                frame:SetSize(220,110) -- set the size.
                frame:SetPoint("TOP", "PlayerFrame", "BOTTOM", 300, 100) --set the anchor point
          end
    
          function PointsTracker_FrameOutofBounds(frame)
                 --check that the frame is the appropriate size
                widthcheck, heightcheck = frame:GetSize()
                print("Width: ",widthcheck, "Height: ",heightcheck)
                --check if frame is out of bounds
                if widthcheck > 600 then --frame is too wide
                    PointsTracker_ResetButton(frame)
                    return true
                elseif heightcheck > 240 then --frame is too tall
                    PointsTracker_ResetButton(frame)
                    return true
                elseif widthcheck < 200 then --frame is too narrow
                    PointsTracker_ResetButton(frame)
                    return true
                elseif heightcheck < 100 then --frame is too short
                    PointsTracker_ResetButton(frame)
                    return true
                else
                    return false
                end
           end
    
          -- Event Catcher for addon
          function PointsTracker_OnEvent(frame, event, ...)
    
            if event == "VARIABLES_LOADED" then
                PointsTracker_MMButton_Init() -- initialize MM button
                if PointsTracker_FrameOutofBounds(frame) then
                    print("Frame out of bounds")
                    PointsTracker_ResetButton(frame) -- iniialize frame to a sane size
                else
                    print("Frame is sane")
                end
    
            end