advertisement

Article:
  Movies and Menus
Subject:   some isolations
Date:   2002-02-01 13:11:27
From:   michele
Response to: some isolations

Post a Reply


Article:
Movies and Menus
Subject: some isolations
Date: 2002-02-01 11:16:34
From: psheldon
Response to: Thanks, some observations
------------------------------------------------------------------------
I used the original nib file before I started messing with autoresizing.
I was able to comment out your file types and get some action.
Now, I've lost autoresizing code, for, when I try to use it, the movie window dissappears.
The best I can show you is the code with the resizing stuff commented out so the window doesn't dissappear. I don't know how to make a cleaner isolation or leaner question presentation than showing this.


- (IBAction)openMovie:(id)sender
{
NSArray *fileTypes = [NSArray arrayWithObjects:@"mov", @"mpg",
@"mp3", @"jpg", nil];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
int result = [oPanel runModalForDirectory:NSHomeDirectory() file:nil types:fileTypes];
if (result == NSOKButton)
{
NSRect frameView = [movieView frame];
NSSize viewSize;


NSArray *movieToOpen = [oPanel URLs];
NSURL *movieURL = [movieToOpen objectAtIndex:0];
NSMovie *movie = [[NSMovie alloc] initWithURL:movieURL byReference:NO];
if you don't autorelease here, you'll have to do it later.


This line:
NSWindow *window = [NSApp mainWindow];
is strictly equivalent to this one:
NSWindow *movieWindow = [movieView window];
because there is only one window at a time, this is the main window and
there is an outlet defined in Controller.h: IBOutlet NSMovieView *movieView;
This outlet is connected from Controller to NSMovieView view.


[window setTitle:[[[oPanel filenames] objectAtIndex:0] lastPathComponent]];


You'll have to set the movie, before showing the controller, resizing the view, make it key and displaying it, otherwise, the controller could not show and the size could not be adjusted to your movie.


[movieView setMovie:movie];


[movieView showController:YES adjustingSize:YES];//michele


Here comes the code for resizing window
In the nib file, do not set any springs to the custom view, because it would be applied when you resize together with the code for resizing. Then it'll be bloody.
For example: I've made the view in nib file: 20, 20 for margins 292, 203 for width and height
the window: 21, 53 for the margins 339, 243 for width and height
minimum size: 221, 153 maximum size: 800, 600
// Draw the movie at magnification 1
viewSize = [movieView sizeForMagnification:1.0];
[movieView resizeWithMagnification:1.0];
viewSize.width = 2*frameView.origin.x + viewSize.width;
viewSize.height = 2*frameView.origin.y + viewSize.height;
[window setContentSize:viewSize];



[window makeKeyAndOrderFront: self];//michele


[window display];//michele


}
}


Hope this helps you


Michèle


1 to 1 of 1
  1. tried your ordering and no springs
    2002-02-02 10:27:24  psheldon [View]

    • forgot to tell fact
      2002-02-02 10:32:53  psheldon [View]

      • thanks michele
        2002-02-03 21:56:46  psheldon [View]

      • added if before size adjustment to avoid mp3's
        2002-02-02 18:50:56  psheldon [View]

1 to 1 of 1