+ Reply to Thread
Results 1 to 14 of 14

Thread: Detecting resize...

  1. #1
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default Detecting resize...

    Is there any way to detect a resize other than checking UIParent:GetBounds()?

    Also, it seems to me that scaling the window down vertically continues to report a height of 1024 even if the actual height is now much smaller...?
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  2. #2
    Champion Lorandii's Avatar
    Join Date
    Jun 2011
    Posts
    516

    Default

    Look at lines 2415 2418 of the PTR details documentation. It is in the live docs too, but different line numbers.
    1. Size
    2. Frame event documentation:
    3. Signals that the frame's size has changed.
    4. Layout.Event:Size()

  3. #3
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Oh, that's...

    Huh.

    For once, I think the idiom of having frame events be function hooks, not tables of event hooks, is sort of bad.

    Because it seems to me that a whole lot of addons might want to hook UIParent.Event:Size.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

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

    Default

    Create your own frame with SetAllPoints() to UIParent and implement it's Event.Size instead.

  5. #5
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Quote Originally Posted by Imhothar View Post
    Create your own frame with SetAllPoints() to UIParent and implement it's Event.Size instead.
    My big concern about this would just be that if I have a ton of frames, I see a noticeable CPU load (according to the performance meter built into the game), and adding a lot of frames just to track that one thing seems expensive.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  6. #6
    Champion Lorandii's Avatar
    Join Date
    Jun 2011
    Posts
    516

    Default

    I'm confused. Why would multiple addons hook UIParent:Size? Sure, some addons might, but the majority won't. And the ones that would hook that tend to be mutually exclusive, meaning nobody installs more than one full UI replacement package. Further, how often do users change the UI scale? Tops, I'd guess 1-3 times until it looks good, and then they never touch it.

    Unless I am missing something entirely.

  7. #7
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Quote Originally Posted by Lorandii View Post
    I'm confused. Why would multiple addons hook UIParent:Size? Sure, some addons might, but the majority won't. And the ones that would hook that tend to be mutually exclusive, meaning nobody installs more than one full UI replacement package. Further, how often do users change the UI scale? Tops, I'd guess 1-3 times until it looks good, and then they never touch it.

    Unless I am missing something entirely.
    Not UI scale, window size.

    Look at GoofBall. I need to know the size of the playing field. What happens if you are playing windowed and resize the window? I suddenly have balls moving in ways which are definitely wrong. Or say I want to make a window fit on screen; I need to know if the "screen" just got smaller.

    This won't change all that often, for most users, but it's something that windowed-mode players might change several times a session, and any addon that involves frame positioning could conceivably have to care about. Doing a tooltip-like thing at fixed coordinates? You need to know whether those coordinates are no longer visible...
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

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

    Default

    Quote Originally Posted by the_real_seebs View Post
    My big concern about this would just be that if I have a ton of frames, I see a noticeable CPU load (according to the performance meter built into the game), and adding a lot of frames just to track that one thing seems expensive.
    I wouldn't worry much about this. My Bags Addon has 4 frames per item button (the button itself, icon texture, amount text and stack text). If you have 50 items in your bags that is 200 frames. Showing them takes my addon from 0.1% to 5%.

    The mere existance of a frame is not something to worry about so much. Avoid it if you can, but don't be paranoid about it, especially when it is empty (i.e. no texture or text which needs extra processing). More important is keeping frequent event handlers like MouseMove or Event.System.Update.Begin as short as possible.

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

    Default

    Other thing: SetVisible(false) on the frame keeps CPU load even lower, even on emtpy ones and you still receive Event.Size.

  10. #10
    Plane Touched Verea's Avatar
    Join Date
    Feb 2011
    Location
    Netherlands
    Posts
    200

    Default

    Quote Originally Posted by the_real_seebs View Post
    Oh, that's...

    Huh.

    For once, I think the idiom of having frame events be function hooks, not tables of event hooks, is sort of bad.

    Because it seems to me that a whole lot of addons might want to hook UIParent.Event:Size.
    Instead of looking for an API function for everything, consider implementing a very easy solution.

    Code:
    myFrame.Event.Hooks = {} -- empty table
    
    function myFrame.Event:Resize()
        -- do event stuff
    
        callResizeEvent({oldWidth = ow, newWidth = nw, oldHeight = oh, newHeight = nh)
    end
    
    local function callResizeEvent(info)
        -- Call all functions hooking into this event.
        for key, func in pairs(self.Event.Hooks) do
            assert(type(func[1]) == "function", "callResizeEvent: " .. func[2] .. " / " .. func[3] .. ": is not a function.")
            func[1](info)
        end
    end
    
    local function printSize(info)
         print("The width was changed to: " .. info.newWidth)
         print("The height was changed to: " .. info.newHeight)
    end
    
    -- Insert the event into our table.
    table.insert(myFrame.Event.Hooks, { printSize, "My Addon Name", "Func Description")
    Verae, level 60 Cleric @ Blightweald, Guild Master of Tea Club
    I want to fly like an eagle, to the sea.
    I want to fly like an eagle, let my spirit carry me.

  11. #11
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    But I don't want to do this to MY frame, I want to monitor the size of UIParent.

    So far as I can tell, any addon that's going to want to do this will want to monitor the size of UIParent, directly or indirectly.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  12. #12
    Plane Touched Verea's Avatar
    Join Date
    Feb 2011
    Location
    Netherlands
    Posts
    200

    Default

    Quote Originally Posted by the_real_seebs View Post
    But I don't want to do this to MY frame, I want to monitor the size of UIParent.

    So far as I can tell, any addon that's going to want to do this will want to monitor the size of UIParent, directly or indirectly.
    Indeed it is.
    Verae, level 60 Cleric @ Blightweald, Guild Master of Tea Club
    I want to fly like an eagle, to the sea.
    I want to fly like an eagle, let my spirit carry me.

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

    Default

    Quote Originally Posted by the_real_seebs View Post
    But I don't want to do this to MY frame, I want to monitor the size of UIParent.

    So far as I can tell, any addon that's going to want to do this will want to monitor the size of UIParent, directly or indirectly.
    The only bullet-proof solution right now is to use your own frame which is attached to UIParent unless we get the ability to hook frame events with multiple observers. I know it is not what you want to hear, but at least it works

  14. #14
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Quote Originally Posted by Imhothar View Post
    The only bullet-proof solution right now is to use your own frame which is attached to UIParent unless we get the ability to hook frame events with multiple observers. I know it is not what you want to hear, but at least it works
    Yup. So that's my next major rethinking project for GoofBall.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

+ 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