Does anyone have an easy way on OS X to animate window sizing. I.E. when a ‘more’ button is clicked I want to increase the height of a window but in a nice smooth apple manor.
I can think of plenty of ways of doing this with timers etc but wondered if there was a native way/declare.
Incase you don’t want the full overhead of macoslib or you don’t have the MBS plugins, you can add the following code to a Window subclass (or a module, just make sure to add the Extends parameter)
[code]Sub Resize(width as Integer, height as Integer) #if TargetCocoa
Declare Function contentRectForFrameRect Lib “Cocoa” Selector “contentRectForFrameRect:” (id As Integer, windowFrame As NSRect) As NSRect
Declare Sub setFrameDisplayAnimate Lib “Cocoa” Selector “setFrame:display:animate:” (WindowRef As Integer, inNSRect As NSRect, Display As Boolean, Animate As Boolean)
DIM newRect As NSRect
newRect.X = me.Left
newRect.Y = me.Top
newRect.Width = Width
newRect.Height = Height
DIM contentRect As NSRect = contentRectForFrameRect(me.Handle, newRect)
newRect.y = Screen(0).Height - (newRect.Y + me.Height) - (newRect.Height - me.Height)
newRect.Height = newRect.Height - (contentRect.Height - newRect.Height) // adjust for the titlebar/toolbar
setFrameDisplayAnimate me.Handle, newRect, TRUE, TRUE
#else
me.Width = width
me.Height = height #endif
End Sub[/code]
You will also need a structure called NSRect with the following declarations
X As Single
Y As Single
Width As Single
Height As Single
[quote=153357:@Thom McGrath]Plugging my own stuff here, but I get no money from this, so you can use my animation kit to do this as well. No plugins or declares required.