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.
There is a Window.SmoothResize method in macoslib. Or, if you have the MBS plugins, you can use Window.SmoothResizeMBS.
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)
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
me.Width = width
me.Height = height
You will also need a structure called NSRect with the following declarations
X As Single
Y As Single
Width As Single
Height As Single
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.
or, if you want OS X declares, here’s a very unfinished project, but Resize and SetFrame are working
and a handful of other methods & properties:
[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.
Thanks Thom, this is a fantastic resource and very simple to use and gives great results.