Coffeehouse Thread

23 posts

Implementing 'Sheets' in Windows

Back to Forum: Coffeehouse
  • User profile image
    W3bbo

    'Sheets' is the name Apple gave to their modal dialog system in OS X. They're those animated drop-down dialog windows you get flying out of the titlebar and unfolding. They're often used for open/save/print dialogs, and for toolbar customization. I think (in principle, at least) they're great because they clearly tie a window-modal dialog with its parent: dragging or moving the parent window also moves the dialog. However the main complaint is how it obscures the view of the original document.

    Anyway, here's an example of Sheets in action:

    http://hints.macworld.com/images/sheet_before.mov

    I understand you could implement this kind of feature by applying a series of complicated global transforms to the graphics object with a different transform per frame of animation (alternatively, render the whole dialog to a bitmap and then apply transformations to that). At least that's how you'd do it in theory.

    ...what I want to know is how you'd do it in practice. In MS Windows having a window that has an alpha component is expensive and often has painting issues (as anyone who has seen Adobe's recent splash screens can testify).

    In WinForms this can probably be done by creating a new 32-bit Bitmap object, creating a Graphics/DC, and telling a parent form to paint to this new DC (it would then recursively render all the child controls). You'd then display the animation with this single bitmap, after the animation has played you then display the 'real' form. However you lose the ability to get interactive controls whilst in mid-animation. Apple did something like this in earlier builds of Safari for Windows, so I know it isn't something you can only do with the assistance of the window manager.

    I'm also interested to hear how you would accomplish this in WPF. I imagine it might be easier, as you can have chrome-less WPF windows and apply arbitrary 3D transformations to them and maintain control interactivity, but by using WPF...you'd be using WPF and all of the related hassle.

    Does anyone have any thoughts on this?

  • User profile image
    AndyC

    It's laughably easy to do this with WPF, though I wouldn't ever do it because it doesn't fit the way the Windows platform generally works. Taskdialogs are actually a better way of model communication, in my opinion.

  • User profile image
    aL_

    if wpf you could use a databound shader effect to do the 'rounding off' between the original window and dialog

    for the actual 'sliding out' effect you could just have a usecontrol with a static height with your dialogbox content (this is also where you'd have the shadereffect), placed in another panel with an initial height of 0 that is docked to the top of the base control. you'd then animate the height of this panel. When the dialogbox 'slides out' the dialogbox content would then look like it was clipped by the base control.

    i havent tried this ofcourse but it should work:)

  • User profile image
    W3bbo

    , aL_ wrote

    if wpf you could use a databound shader effect to do the 'rounding off' between the original window and dialog

    for the actual 'sliding out' effect you could just have a usecontrol with a static height with your dialogbox content (this is also where you'd have the shadereffect), placed in another panel with an initial height of 0 that is docked to the top of the base control. you'd then animate the height of this panel. When the dialogbox 'slides out' the dialogbox content would then look like it was clipped by the base control.

    i havent tried this ofcourse but it should work:)

    That's simple sliding though. If you look at the video file I posted (use the scrubber to watch it in slow-motion) you can see it appears to 'bend' and then fan out as it expands, so it isn't a resize that's going on. I also don't think a child control would work here because Sheets can be bigger than the window that created them, so they must be a separate Win32 window.

  • User profile image
    aL_

    @W3bbo:

    the bending would come from the data bound ShaderEffect. since its a hlsl shader it would also run in hardware so it would have no practical perf inpact.

    as for windowsize, that could potentially be a problem, but you could just make another Window class and call ShowDialog on it and have the animations run as the window opens, the basic implementation strategy should be applicable all the same

  • User profile image
    Blue Ink

    In WPF you could probably get something like that with a Popup. If I remember correctly that's how they implemented several flyouts in the WPF Ribbon. The bending part would still require the Pixel Shader _aL mentioned, but that's actually fun.

  • User profile image
    LCARSNxG

    Don't attempt this in WinForms or using GDI. That's guaranteed to provide glitchy performance. I agree with what's already been said regarding a WPF implementation.

    However, I'm curious, why would you want to implement this in a Windows application?

  • User profile image
    W3bbo

    , LCARSNxG wrote

    However, I'm curious, why would you want to implement this in a Windows application?

    The "animate anything" abilities of OS X introduce new ways of communicating data flow and program features with users, and this has been possible with OS X right from the start with 10.0 in 2002, and it was all baked right into the OS so you get system-level support for these animations (such as the 'genie' effect when minimising windows to the dock, and these sheet animations, for example).

    I have ideas for applications I want to build that would benefit from these kinds of animations, but as you point out doing them in WinForms wouldn't work well and WPF would be better, but why is WPF necessary? Why can't we do these things with established tools? The fact you need to use a VM-based platform to do these things without spending years writing an animated widget framework makes me annoyed, and things don't look set to change in Windows 8.

  • User profile image
    aL_

    , W3bbo wrote

    but why is WPF necessary? Why can't we do these things with established tools?

    thats like asking why you cant build a skyscraper using timber frames.. they just dont stand up to that application. How is winforms the "established tools" anyway, mfc, gdi and even directx are far older..

    The fact you need to use a VM-based platform to do these things without spending years writing an animated widget framework makes me annoyed, and things don't look set to change in Windows 8.

    You dont. atleast if you dont mind going for c++, take Direct2D for example, that what most of the Live suite software use (with a unmanaged ui framework that i dont recall the name of, DirectUI maybe?).

    Not that i see a perticular problem with .net having a VM, but i'd say things are looking to change in win8 with all these rumors about native compilation for .net going around..

  • User profile image
    Frank Hileman

    Not that i see a perticular problem with .net having a VM, but i'd say things are looking to change in win8 with all these rumors about native compilation for .net going around..

    Please expand on the rumors. I have not heard of them.

    The interesting thing about the Apple approach to animations: they are based more on immediate mode rendering, and optimized more for small devices. The animations we see on the iPhone are mostly scrolling, which works well even on an ancient device. WPF was designed for heavy desktop hardware and is memory hungry.

    Personally I would disable the ugly animation shown in the movie.

  • User profile image
    AndyC

    , Frank Hileman wrote

    *snip*

    Personally I would disable the ugly animation shown in the movie.

    The slightly over-the-top animations in Mac OS exist mainly to prevent developers from trying to implement their own versions of something and just live within the framework that Apple provide, thus ensuring things behave the way users expect. It's quite a clever trick really.

  • User profile image
    Frank Hileman

    The slightly over-the-top animations in Mac OS exist mainly to prevent developers from trying to implement their own versions of something and just live within the framework that Apple provide, thus ensuring things behave the way users expect. It's quite a clever trick really.

    It is clever. Some people can stand lots of animations, and some people cannot. I am one of those who cannot stand them. They look great in a demo, later becoming tiresome.

  • User profile image
    W3bbo

    , Frank Hileman wrote

    *snip*

    It is clever. Some people can stand lots of animations, and some people cannot. I am one of those who cannot stand them. They look great in a demo, later becoming tiresome.

    The art is all about getting animations right: they short be short and subtle, but also clear. The 'expanding sheets' isn't a good example of animation done totally right: I'd have made it twice as fast and also given it a 'fade in' so it isn't as jarring. I also think sheet dialogs should be smaller, but anyway.

    FWIW, you can disable animations in OS X, but you have to modify *.plist files directly.

  • User profile image
    evildictait​or

    , W3bbo wrote

    ... I'd have made it twice as fast and also given it a 'fade in' so it isn't as jarring. I also think sheet dialogs should be smaller, but anyway...

    You mean like the Windows Vista/7 maximize/minimise window animation?

    I remember in Longhorn the UX guys at MS tried a "wobble when you shake the window" animation which everyone was really impressed at during demos but got taken out before the beta. When lots of people complained the response was "we tried it and people loved it for a couple of minutes whilst they played with it and then it pissed them off because it got in the way of them doing work quickly".

  • User profile image
    aL_

    , Frank Hileman wrote

     Please expand on the rumors. I have not heard of them.

    Rumor has it Bartok/Pheonix is making it into windows. then there is the mysterious Jupiter and SLR stuff that appears to be a native version(or more native atleast) of the clr.

    hopefully microsoft will release some more info on these codenames soon Smiley

  • User profile image
    Frank Hileman

    Thanks, aL_!

  • User profile image
    longzheng

    We're looking to do this in MetroTwit with our prompts and stuff Smiley

  • User profile image
    Adam​Speight2008

    Why would you want to do, distracting animation carp, any way? 

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.