How do you make QTMovie full screen when played? - cocoa

How do you make QTMovie full screen when played?
I have been trying to hunt around for a solution for this. The last response points to a document that has since been deprecated, is there an updated solution for OS X 10.7/10.8?
Thanks!

To solve this you can set your NSWindow as a fullscreen window this will show your movie in full screen mode.
There are two ways to do it, one is with NSApplication and the other is with NSWindow.
To do it with NSApplication, you’ll make this simple call
[[NSApplication sharedApplication]
setPresentationOptions:NSFullScreenWindowMask];
To do it with NSWindow you’ll make this one
[window setCollectionBehavior:
NSWindowCollectionBehaviorFullScreenPrimary];
There is also an NSWindowCollectionBehaviorFullScreenAuxiliary that you can use to allow auxiliary windows to show up in the space with the main window.
To more details click here

Related

How can I display a modal sheet in NSWindow fullscreen mode without visually shifting the host window?

Objective-C desktop Cocoa ap. The application is a highly specific edge case (a standalone kiosk with a one-button interface). I mention this first in hopes of avoiding the HIG lecture. ;)
I am using a modal sheet view to display a PDF document over top of my usual content. The code is very simple:
[docViewerHostWindow beginSheet:docViewer completionHandler:nil];
DocViewerHostWindow is an NSWindow accessed as the parent of the NSView that calls the sheet. If it matters, "docViewer" is a subclass of NSWindow containing a PDFView.
When the application is running in a window, everything functions as it should. When the application is running fullscreen things work as advertised but there is a visual glitch: the entire content behind the model shifts to the right until the sheet is dismissed. It appears this is deliberate (and animated) but I can't figure out where it is coming from or how to disable it.
I enter fullscreen this way:
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO],NSFullScreenModeAllScreens,nil];
[self enterFullScreenMode:[NSScreen mainScreen] withOptions:options];
This basic NSLog illustrates the problem:
NSLog(#"Before: %f,%f",docViewerHostWindow.frame.origin.x,docViewerHostWindow.frame.origin.y);
[docViewerHostWindow beginSheet:docViewer completionHandler:nil];
NSLog(#"After: %f,%f",docViewerHostWindow.frame.origin.x,docViewerHostWindow.frame.origin.y);
**Log when running windowed (same origin before and after) **
2015-08-09 22:52:46.641 Before: 311.000000,491.000000
2015-08-09 22:52:47.050 After: 311.000000,491.000000
**Log when running fullscreen (origin shifts in fullscreen) **
2015-08-09 22:52:46.641 Before: 0.000000,0.000000
2015-08-09 22:52:47.050 After: 80.000000,-23.000000
I have tried to force the origin of the window both before and after opening the sheet, but this didn't help. I'm not even sure where to look - any clues on what is causing this and why?
Update: To be clear I am NOT talking about the default animation on the sheet itself (as described in this question) rather this is something that happens to the host window, but only in fullscreen.
The effect seen is the application moving out of the way of the (invisible) dock and the menubar (thank you #KenThomases whose comment helped figure that out). In addition to the accepted answer above, I found another solution:
Apple provides a number of kiosk mode tricks which are helpful here, in particular note their example regarding hiding the menubar and dock by adding code to awakeFromNib.
However, this is less than ideal in a non-kiosk ap, what we'd like is to have the kiosk options only in full screen mode. Fortunately this is possible by passing the options to enterFullScreenMode:withOptions:. The regular presentation mode options are restored when we exitFullScreenMode:withOptions
The documentation is a bit thin, but this did the trick:
NSApplicationPresentationOptions kioskOptions = NSApplicationPresentationHideDock + NSApplicationPresentationHideMenuBar;
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO],NSFullScreenModeAllScreens,
[NSNumber numberWithInteger:kioskOptions],NSFullScreenModeApplicationPresentationOptions, nil];
[self enterFullScreenMode:[NSScreen mainscreen] withOptions:options];
The issue is apparently related to the window avoiding the Dock.
I think it's also related to the fact that you're putting a view, not a window, in full-screen mode. When you do that, the view is sort of moved out of its normal window. But then, when you begin a sheet on the view's window, you're bringing that back into the picture, so to speak. (You might check if the view's window property is actually the same window it was before it entered full-screen mode. If it's not, you really have no business attaching a sheet to it.)
I would recommend that you use a borderless window, positioned to cover the screen, at a window level of NSStatusWindowLevel + 1. That's the technique recommended in Apple's OpenGL Programming Guide for Mac: Drawing to the Full Screen (which is, admittedly, a somewhat different context that you're working in). So, you would not use -[NSView enterFullScreenMode:withOptions:]. If you want to set the application's presentationOptions for kiosk-mode-type behavior, you can do that, too.

NSWindowController displays nib before windowDidLoad finishes

When I try launching my app through Spotlight without building it through XCode, the NSWindowController displays the unmodified nib (with the standard gray background color, etc) for a split second before windowDidLoad finishes. This looks awful, since views are in the wrong places and aren't colored correctly.
I tried removing everything from windowDidLoad to see if something in there was slowing it down, but that didn't improve things. I also tried moving the setting of the background color to initWithWindowNibName, but that didn't help either.
Is there a way to delay showing the window while it finishes loading?
Here's the code I'm using to initialize the NSWindowController:
self.windowController = [[WindowController alloc] initWithWindowNibName:#"WindowController"];
[self.windowController showWindow:self];
[[self.windowController window] makeKeyAndOrderFront:nil];
Disable NSWindowController's "visible at launch" property in Interface Builder.
(Of course, I post the question then immediately figure out the answer.)

OS X Lion: Fullscreen NSWindow Bait & Switch

I currently have a NSWindow that allows for full screen. The window has a video player and a playlist below it. When the user goes fullscreen, I want to get rid of the playlist and just show the video.
My first thoughts for doing this is to swap out the window when I detect a fullscreen entry point. I have found that I can detect this with the following:
- (void)windowWillEnterFullScreen:(NSNotification *)notification
{
NSLog(#"My window is going fullscreen");
}
But I have been unable to figure out how to swap out the window for a new one at this point. One option I haven't yet attempted would be to modify all of the resizing flags of the video and hide the other components but I'm not certain if this would be the best solution.
Does anyone have any suggestions on a better way for doing this?
Why do you want to swap the window? Just manipulate the views in the window.
Just remove the playlist from your view when you go fullscreen with -removeFromSuperview and then resize the video view so that it fills your window.
Make sure you hold a reference to the view as an ivar somewhere, because otherwise the view will be deallocated. You can then use that reference to add the view back when the window exits full-screen mode.

Cocoa Pop-up Window Similar to iCal

I want to open an overlay window (pop up window) when a user selects a cell in my NSTableView similar to selecting an event in iCal. Selecting the event in iCal shows a Window to edit the event, but does so by smoothly animating the window open and adding an arrow pointing to the even in the underlying calendar. Does anyone know what is being used here? Is this a bunch of hidden/custom APIs or is this available for public use?
The editor pane appears to be a custom borderless, transparent window with a custom view (the view defines the shape and therefore the shadow it casts). Learn more here. You might even use MAAttachedWindow.
Regarding animation, it's as simple as asking the window's animator to animate the frame and the alpha value (grouping them together). You'll probably want to set everything up directly in its "start position" first (ie, while the window is off-screen, set its alpha to zero, and its frame to some smaller version so it "zooms in" a la iCal), then put it on screen and start the grouped animation:
[NSAnimationContext beginGrouping];
[[window animator] setFrame:someNewSlightlyLargerFrame];
[[window animator] setAlphaValue:1.0];
[NSAnimationContext endGrouping];
Once the grouping is ended, the animation will begin (asynchronously) and your code execution will continue. Something to think about is getting everything "staged" first (including making sure the subviews of your window are already updated beforehand, so they don't change in the middle of your animation ... unless you want them to).
So the two separate techniques you need to understand are a custom window and basic Cocoa animation.
If you're using OSX 10.7 and above, NSPopover will do the job you're looking for.
Are you talking about selecting even from a list at the bottom of iCal app?
Not sure what exactly you are referring to but there is an api for animating transformations within a timespan.
Looking at other Apple's applications, Apple's developers utilize the same api available to anyone else (mostly I guess). There is lots of stuff that can be customized and Apple customizes whatever is required until it looks right from design point of view ...

Centering Windows on screen

Short and sweet: How can I tell Interface Builder to center a window on a user's screen? I've seen the positioning tool on the inspector, but eyeballing doesn't always land as squarely as I like. Is this something where I should switch over to Xcode and add something to the init or awakeFromNib methods?
You could use [window center] as answered by wahkiz, but that might not be exactly what you want. The documentation states that this will put the window centered horizontally, but somewhat above the vertical centre. In this way the window has a visual prominence.
If you want to put your window in the exact centre, then manual positioning (as commented by Koning Baard XIV) will work for you.
Use [window center]; for the centre of the window to be centred to the screen.
Also, assuming you're in 10.5+, there is a centre to screen button in Interface Builder.
In your appdelegate, in applicationfinishedlaunching, add this code at the bottom.
[window center];
For macOS Mojave this worked for me, in AppDelegate applicationDidFinishLaunching for the Main Window:
[[[NSApplication sharedApplication] mainWindow] center];

Resources