+ Reply to Thread
Results 1 to 9 of 9

Thread: LibFrameRecycler

  1. #1
    Rift Disciple
    Join Date
    Jan 2011
    Posts
    147

    Default LibFrameRecycler

    Greetings fellow addon developers!

    If you have a need to recreate frames on a regular basis and worry about stressing the Rift API by creating lots of frames, I bring you LibFrameRecycler!

    LibFrameRecycler provides an alternate CreateFrame function and a RecycleFrame function that act in concert to allow you to reuse frames that you have thrown away. Just use the replacement CreateFrame function and then call RecycleFrame when you no longer need that frame. The library will squirrel it away to be resurrected later when you call the CreateFrame function with the same frame type again.

    http://www.riftui.com/downloads/info...eRecycler.html

    Known issues:
    • Frame names are not updated when resurrected -- Zorba, I need a SetName! ;)

  2. #2
    Sword of Telara DoomSprout's Avatar
    Join Date
    Apr 2011
    Posts
    876

    Default

    I'm sure I remember Zorba saying recycling frames was a bad idea at some point. I can't remember why now, though. Might be worth a quick search just to make sure there's nothing that's going to bite you in this library.

    (Sorry, not trying to be negative, it's just something I remember seeing somewhere)

    Edit: Ignore me, I found the thread. There is no issue, and you even mention this library in it

    It was this one
    Last edited by DoomSprout; 04-20-2012 at 04:21 AM.

    Gadgets: Unit Frames and Other Stuff for RIFT

  3. #3
    Rift Chaser NerfedWar's Avatar
    Join Date
    Dec 2010
    Posts
    377

    Default

    Quote Originally Posted by dOxxx View Post
    Greetings fellow addon developers!

    If you have a need to recreate frames on a regular basis and worry about stressing the Rift API by creating lots of frames, I bring you LibFrameRecycler!

    LibFrameRecycler provides an alternate CreateFrame function and a RecycleFrame function that act in concert to allow you to reuse frames that you have thrown away. Just use the replacement CreateFrame function and then call RecycleFrame when you no longer need that frame. The library will squirrel it away to be resurrected later when you call the CreateFrame function with the same frame type again.

    http://www.riftui.com/downloads/info...eRecycler.html

    Known issues:
    • Frame names are not updated when resurrected -- Zorba, I need a SetName! ;)
    Started work on something similar but never finished it some time ago, but I simply rehooked the CreateFrame function. Considered doing the same?

    Some devs might not like the idea of you hooking such a critical function, but the benefits especially if you get your addon to load before theirs will be worht it.
    Last edited by NerfedWar; 04-20-2012 at 09:37 PM.
    ...the internet treats censorship as damage, and routes around it...
    NerfedWar Addons and Tutorials
    * Note: tutorials are currently being ported to the new site.

  4. #4
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Just remember that frames are in fact nothing else but tables and can have any arbitrary table members. When I get a frame from CreateFrame() I expect it to have Event as it's only member (which equals the result of GetEventTable()), have all members of the Event table set to nil and the appropriate metatable for this type of frame.

    Long story short, there should be no difference between a new or recycled frame table (including the name as soon as there's a method to change it), neither in strata/layer/position or anything else someone might have changed since its creation.
    Last edited by Imhothar; 04-21-2012 at 10:39 AM.

  5. #5
    Rift Disciple
    Join Date
    Jan 2011
    Posts
    147

    Default

    Quote Originally Posted by NerfedWar View Post
    Started work on something similar but never finished it some time ago, but I simply rehooked the CreateFrame function. Considered doing the same?

    Some devs might not like the idea of you hooking such a critical function, but the benefits especially if you get your addon to load before theirs will be worht it.
    I would rather a developer choose to use this than force it on every addon that loads after my library. For many addons it's simply not necessary since they create their frames once and that's it.

    Using it in a particular addon instead of UI.CreateFrame is quite easy:

    local CreateFrame = Library.LibFrameRecycler.CreateFrame

    Put that at the top of your file and then use CreateFrame(...) instead of UI.CreateFrame(...).

  6. #6
    Rift Disciple
    Join Date
    Jan 2011
    Posts
    147

    Default

    Quote Originally Posted by Imhothar View Post
    Just remember that frames are in fact nothing else but tables and can have any arbitrary table members. When I get a frame from CreateFrame() I expect it to have Event as it's only member (which equals the result of GetEventTable()), have all members of the Event table set to nil and the appropriate metatable for this type of frame.

    Long story short, there should be no difference between a new or recycled frame table (including the name as soon as there's a method to change it), neither in strata/layer/position or anything else someone might have changed since its creation.
    That's a good point about Event. It currently doesn't clear out the Event table and it should.

    However, it would be quite difficult to remove other members from the frame's table since it's standard functions like SetPoint, etc. exist in that table and I would have to be able to distinguish between a member that should be there and one that was added by the user.

  7. #7
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Quote Originally Posted by dOxxx View Post
    However, it would be quite difficult to remove other members from the frame's table since it's standard functions like SetPoint, etc. exist in that table and I would have to be able to distinguish between a member that should be there and one that was added by the user.
    Not correct, the API methods are part of the table's metatable, not the table itself.

  8. #8
    Rift Disciple
    Join Date
    Jan 2011
    Posts
    147

    Default

    I've uploaded a new version of the library which clears event handlers and resets various type-specific properties when a frame is recycled.

  9. #9
    Rift Disciple
    Join Date
    Jan 2011
    Posts
    147

    Default

    And yet another version goes up which removes any extra table members when the frame is recycled.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts