1 /* $Id: PictureController.mm,v 1.11 2005/08/01 15:10:44 titer Exp $
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.m0k.org/>.
5 It may be used under the terms of the GNU General Public License. */
7 #include "PictureController.h"
9 @interface PictureController (Private)
11 - (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize;
12 - (void)resizeSheetForViewSize: (NSSize)viewSize;
13 - (void)setViewSize: (NSSize)viewSize;
14 - (BOOL)viewNeedsToResizeToSize: (NSSize)newSize;
18 @implementation PictureController
20 - (id)initWithDelegate:(id)del
22 if (self = [super init])
26 fPicturePreviews = [[NSMutableDictionary dictionaryWithCapacity: HB_NUM_HBLIB_PICTURES] retain];
33 [fPicturePreviews release];
37 - (void) SetHandle: (hb_handle_t *) handle
41 [fWidthStepper setValueWraps: NO];
42 [fWidthStepper setIncrement: 16];
43 [fWidthStepper setMinValue: 64];
44 [fHeightStepper setValueWraps: NO];
45 [fHeightStepper setIncrement: 16];
46 [fHeightStepper setMinValue: 64];
48 [fCropTopStepper setIncrement: 2];
49 [fCropTopStepper setMinValue: 0];
50 [fCropBottomStepper setIncrement: 2];
51 [fCropBottomStepper setMinValue: 0];
52 [fCropLeftStepper setIncrement: 2];
53 [fCropLeftStepper setMinValue: 0];
54 [fCropRightStepper setIncrement: 2];
55 [fCropRightStepper setMinValue: 0];
58 - (void) SetTitle: (hb_title_t *) title
60 hb_job_t * job = title->job;
64 [fWidthStepper setMaxValue: title->width];
65 [fWidthStepper setIntValue: job->width];
66 [fWidthField setIntValue: job->width];
67 [fHeightStepper setMaxValue: title->height];
68 [fHeightStepper setIntValue: job->height];
69 [fHeightField setIntValue: job->height];
70 [fRatioCheck setState: job->keep_ratio ? NSOnState : NSOffState];
71 [fCropTopStepper setMaxValue: title->height/2-2];
72 [fCropBottomStepper setMaxValue: title->height/2-2];
73 [fCropLeftStepper setMaxValue: title->width/2-2];
74 [fCropRightStepper setMaxValue: title->width/2-2];
76 /* Populate the Anamorphic NSPopUp button here */
77 [fAnamorphicPopUp removeAllItems];
78 [fAnamorphicPopUp addItemWithTitle: @"None"];
79 [fAnamorphicPopUp addItemWithTitle: @"Strict"];
80 if (allowLooseAnamorphic)
82 [fAnamorphicPopUp addItemWithTitle: @"Loose"];
84 [fAnamorphicPopUp selectItemAtIndex: job->pixel_ratio];
86 /* We initially set the previous state of keep ar to on */
87 keepAspectRatioPreviousState = 1;
90 [fCropMatrix selectCellAtRow: 1 column:0];
91 /* If auto, lets set the crop steppers according to current job->crop values */
92 [fCropTopStepper setIntValue: job->crop[0]];
93 [fCropTopField setIntValue: job->crop[0]];
94 [fCropBottomStepper setIntValue: job->crop[1]];
95 [fCropBottomField setIntValue: job->crop[1]];
96 [fCropLeftStepper setIntValue: job->crop[2]];
97 [fCropLeftField setIntValue: job->crop[2]];
98 [fCropRightStepper setIntValue: job->crop[3]];
99 [fCropRightField setIntValue: job->crop[3]];
103 [fCropMatrix selectCellAtRow: 0 column:0];
106 /* Set filters widgets according to the filters struct */
107 [fVFRCheck setState:fPictureFilterSettings.vfr];
108 [fDetelecineCheck setState:fPictureFilterSettings.detelecine];
109 [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
110 [fDenoisePopUp selectItemAtIndex: fPictureFilterSettings.denoise];
111 [fDeblockCheck setState: fPictureFilterSettings.deblock];
114 MaxOutputWidth = title->width - job->crop[2] - job->crop[3];
115 MaxOutputHeight = title->height - job->crop[0] - job->crop[1];
116 [self SettingsChanged: nil];
119 /* we use this to setup the initial picture filters upon first launch, after that their states
120 are maintained across different sources */
121 - (void) setInitialPictureFilters
123 /* we use a popup to show the deinterlace settings */
124 [fDeinterlacePopUp removeAllItems];
125 [fDeinterlacePopUp addItemWithTitle: @"None"];
126 [fDeinterlacePopUp addItemWithTitle: @"Fast"];
127 [fDeinterlacePopUp addItemWithTitle: @"Slow"];
128 [fDeinterlacePopUp addItemWithTitle: @"Slower"];
129 [fDeinterlacePopUp addItemWithTitle: @"Slowest"];
131 /* Set deinterlaces level according to the integer in the main window */
132 [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
134 /* we use a popup to show the denoise settings */
135 [fDenoisePopUp removeAllItems];
136 [fDenoisePopUp addItemWithTitle: @"None"];
137 [fDenoisePopUp addItemWithTitle: @"Weak"];
138 [fDenoisePopUp addItemWithTitle: @"Medium"];
139 [fDenoisePopUp addItemWithTitle: @"Strong"];
140 /* Set denoises level according to the integer in the main window */
141 [fDenoisePopUp selectItemAtIndex: fPictureFilterSettings.denoise];
145 // Adjusts the window to draw the current picture (fPicture) adjusting its size as
146 // necessary to display as much of the picture as possible.
147 - (void) displayPreview
149 [fPictureView setImage: [self imageForPicture: fPicture]];
151 NSSize displaySize = NSMakeSize( (float)fTitle->width, (float)fTitle->height );
152 /* Set the picture size display fields below the Preview Picture*/
153 if( fTitle->job->pixel_ratio == 1 ) // Original PAR Implementation
155 output_width = fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3];
156 output_height = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1];
157 display_width = output_width * fTitle->job->pixel_aspect_width / fTitle->job->pixel_aspect_height;
158 [fInfoField setStringValue:[NSString stringWithFormat:
159 @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d",
160 fTitle->width, fTitle->height, output_width, output_height, display_width, output_height]];
161 displaySize.width *= ((float)fTitle->job->pixel_aspect_width) / ((float)fTitle->job->pixel_aspect_height);
163 else if (fTitle->job->pixel_ratio == 2) // Loose Anamorphic
165 display_width = output_width * output_par_width / output_par_height;
166 [fInfoField setStringValue:[NSString stringWithFormat:
167 @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d",
168 fTitle->width, fTitle->height, output_width, output_height, display_width, output_height]];
170 /* FIXME: needs to be fixed so that the picture window does not resize itself on the first
171 anamorphic width drop
173 if (fTitle->width - 8 < output_width)
175 displaySize.width *= ((float)output_par_width) / ((float)output_par_height);
178 else // No Anamorphic
180 [fInfoField setStringValue: [NSString stringWithFormat:
181 @"Source: %dx%d, Output: %dx%d", fTitle->width, fTitle->height,
182 fTitle->job->width, fTitle->job->height]];
185 NSSize viewSize = [self optimalViewSizeForImageSize:displaySize];
186 if( [self viewNeedsToResizeToSize:viewSize] )
188 [self resizeSheetForViewSize:viewSize];
189 [self setViewSize:viewSize];
192 // Show the scaled text (use the height to check since the width can vary
193 // with anamorphic video).
194 if( ((int)viewSize.height) != fTitle->height )
196 float scale = viewSize.width / ((float)fTitle->width);
197 NSString *scaleString = [NSString stringWithFormat:
198 NSLocalizedString( @" (Preview scaled to %.0f%% actual size)",
199 @"String shown when a preview is scaled" ),
201 [fInfoField setStringValue:
202 [[fInfoField stringValue] stringByAppendingString:scaleString]];
205 [fPrevButton setEnabled: ( fPicture > 0 )];
206 [fNextButton setEnabled: ( fPicture < 9 )];
209 - (IBAction) SettingsChanged: (id) sender
211 hb_job_t * job = fTitle->job;
213 if( [fAnamorphicPopUp indexOfSelectedItem] > 0 )
215 if ([fAnamorphicPopUp indexOfSelectedItem] == 2) // Loose anamorphic
217 job->pixel_ratio = 2;
218 [fWidthStepper setEnabled: YES];
219 [fWidthField setEnabled: YES];
220 /* We set job->width and call hb_set_anamorphic_size in libhb to do a "dry run" to get
221 * the values to be used by libhb for loose anamorphic
223 job->width = [fWidthStepper intValue];
224 hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
225 [fHeightStepper setIntValue: output_height];
226 [fHeightField setIntValue: output_height];
227 job->height = [fHeightStepper intValue];
230 else // must be "1" or strict anamorphic
232 [fWidthStepper setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
233 [fWidthField setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
235 /* This will show correct anamorphic height values, but
236 show distorted preview picture ratio */
237 [fHeightStepper setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]];
238 [fHeightField setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]];
239 job->width = [fWidthStepper intValue];
240 job->height = [fHeightStepper intValue];
242 job->pixel_ratio = 1;
243 [fWidthStepper setEnabled: NO];
244 [fWidthField setEnabled: NO];
247 /* if the sender is the Anamorphic checkbox, record the state
248 of KeepAspect Ratio so it can be reset if Anamorphic is unchecked again */
249 if (sender == fAnamorphicPopUp)
251 keepAspectRatioPreviousState = [fRatioCheck state];
253 [fRatioCheck setState:NSOffState];
254 [fRatioCheck setEnabled: NO];
257 [fHeightStepper setEnabled: NO];
258 [fHeightField setEnabled: NO];
263 job->width = [fWidthStepper intValue];
264 job->height = [fHeightStepper intValue];
265 job->pixel_ratio = 0;
266 [fWidthStepper setEnabled: YES];
267 [fWidthField setEnabled: YES];
268 [fHeightStepper setEnabled: YES];
269 [fHeightField setEnabled: YES];
270 [fRatioCheck setEnabled: YES];
271 /* if the sender is the Anamorphic checkbox, we return the
272 keep AR checkbox to its previous state */
273 if (sender == fAnamorphicPopUp)
275 [fRatioCheck setState:keepAspectRatioPreviousState];
281 job->keep_ratio = ( [fRatioCheck state] == NSOnState );
283 fPictureFilterSettings.deinterlace = [fDeinterlacePopUp indexOfSelectedItem];
284 /* if the gui deinterlace settings are fast through slowest, the job->deinterlace
285 value needs to be set to one, for the job as well as the previews showing deinterlacing
286 otherwise set job->deinterlace to 0 or "off" */
287 if (fPictureFilterSettings.deinterlace > 0)
289 job->deinterlace = 1;
293 job->deinterlace = 0;
295 fPictureFilterSettings.denoise = [fDenoisePopUp indexOfSelectedItem];
296 fPictureFilterSettings.vfr = [fVFRCheck state];
297 if (fPictureFilterSettings.vfr > 0)
299 [fDetelecineCheck setState:NSOnState];
300 [fDetelecineCheck setEnabled: NO];
304 [fDetelecineCheck setEnabled: YES];
306 fPictureFilterSettings.detelecine = [fDetelecineCheck state];
307 fPictureFilterSettings.deblock = [fDeblockCheck state];
308 //job->pixel_ratio = ( [fPARCheck state] == NSOnState );
310 autoCrop = ( [fCropMatrix selectedRow] == 0 );
311 [fCropTopStepper setEnabled: !autoCrop];
312 [fCropBottomStepper setEnabled: !autoCrop];
313 [fCropLeftStepper setEnabled: !autoCrop];
314 [fCropRightStepper setEnabled: !autoCrop];
318 memcpy( job->crop, fTitle->crop, 4 * sizeof( int ) );
322 job->crop[0] = [fCropTopStepper intValue];
323 job->crop[1] = [fCropBottomStepper intValue];
324 job->crop[2] = [fCropLeftStepper intValue];
325 job->crop[3] = [fCropRightStepper intValue];
328 if( job->keep_ratio )
330 if( sender == fWidthStepper || sender == fRatioCheck ||
331 sender == fCropTopStepper || sender == fCropBottomStepper )
333 hb_fix_aspect( job, HB_KEEP_WIDTH );
334 if( job->height > fTitle->height )
336 job->height = fTitle->height;
337 hb_fix_aspect( job, HB_KEEP_HEIGHT );
342 hb_fix_aspect( job, HB_KEEP_HEIGHT );
343 if( job->width > fTitle->width )
345 job->width = fTitle->width;
346 hb_fix_aspect( job, HB_KEEP_WIDTH );
351 [fWidthStepper setIntValue: job->width];
352 [fWidthField setIntValue: job->width];
353 if( [fAnamorphicPopUp indexOfSelectedItem] < 2 )
355 [fHeightStepper setIntValue: job->height];
356 [fHeightField setIntValue: job->height];
358 [fCropTopStepper setIntValue: job->crop[0]];
359 [fCropTopField setIntValue: job->crop[0]];
360 [fCropBottomStepper setIntValue: job->crop[1]];
361 [fCropBottomField setIntValue: job->crop[1]];
362 [fCropLeftStepper setIntValue: job->crop[2]];
363 [fCropLeftField setIntValue: job->crop[2]];
364 [fCropRightStepper setIntValue: job->crop[3]];
365 [fCropRightField setIntValue: job->crop[3]];
366 /* Sanity Check Here for < 16 px preview to avoid
367 crashing hb_get_preview. In fact, just for kicks
368 lets getting previews at a min limit of 32, since
369 no human can see any meaningful detail below that */
370 if (job->width >= 64 && job->height >= 64)
372 // Purge the existing picture previews so they get recreated the next time
374 [self purgeImageCache];
375 [self displayPreview];
379 - (IBAction) PreviousPicture: (id) sender
386 [self displayPreview];
389 - (IBAction) NextPicture: (id) sender
396 [self displayPreview];
399 - (IBAction) ClosePanel: (id) sender
401 if ([delegate respondsToSelector:@selector(pictureSettingsDidChange)])
402 [delegate pictureSettingsDidChange];
404 [NSApp endSheet: fPicturePanel];
405 [fPicturePanel orderOut: self];
412 - (void) setAutoCrop: (BOOL) setting
417 - (BOOL) allowLooseAnamorphic
419 return allowLooseAnamorphic;
422 - (void) setAllowLooseAnamorphic: (BOOL) setting
424 allowLooseAnamorphic = setting;
429 return fPictureFilterSettings.detelecine;
432 - (void) setDetelecine: (int) setting
434 fPictureFilterSettings.detelecine = setting;
439 return fPictureFilterSettings.vfr;
442 - (void) setVFR: (int) setting
444 fPictureFilterSettings.vfr = setting;
449 return fPictureFilterSettings.deinterlace;
452 - (void) setDeinterlace: (int) setting {
453 fPictureFilterSettings.deinterlace = setting;
458 return fPictureFilterSettings.denoise;
461 - (void) setDenoise: (int) setting
463 fPictureFilterSettings.denoise = setting;
468 return fPictureFilterSettings.deblock;
471 - (void) setDeblock: (int) setting
473 fPictureFilterSettings.deblock = setting;
476 - (void)showPanelInWindow: (NSWindow *)fWindow forTitle: (hb_title_t *)title
478 [self SetTitle:title];
480 [NSApp beginSheet:fPicturePanel
481 modalForWindow:fWindow
488 // This function converts an image created by libhb (specified via pictureIndex) into
489 // an NSImage suitable for the GUI code to use. If removeBorders is YES,
490 // makeImageForPicture crops the image generated by libhb stripping off the gray
491 // border around the content. This is the low-level method that generates the image.
492 // -imageForPicture calls this function whenever it can't find an image in its cache.
493 + (NSImage *) makeImageForPicture: (int)pictureIndex
494 libhb:(hb_handle_t*)handle
495 title:(hb_title_t*)title
496 removeBorders:(BOOL)removeBorders
500 // |<---------- title->width ----------->|
501 // | |<---- title->job->width ---->| |
503 // .......................................
504 // ....+-----------------------------+....
505 // ....| |....<-- gray border
508 // ....| |<------- image
514 // ....+-----------------------------+....
515 // .......................................
517 static uint8_t * buffer;
518 static int bufferSize;
520 // Make sure we have a big enough buffer to receive the image from libhb. libhb
521 // creates images with a one-pixel border around the original content. Hence we
522 // add 2 pixels horizontally and vertically to the buffer size.
523 int srcWidth = title->width + 2;
524 int srcHeight= title->height + 2;
526 newSize = srcWidth * srcHeight * 4;
527 if( bufferSize < newSize )
529 bufferSize = newSize;
530 buffer = (uint8_t *) realloc( buffer, bufferSize );
533 hb_get_preview( handle, title, pictureIndex, buffer );
535 // Create an NSBitmapImageRep and copy the libhb image into it, converting it from
536 // libhb's format to one suitable for NSImage. Along the way, we'll strip off the
537 // border around libhb's image.
539 // The image data returned by hb_get_preview is 4 bytes per pixel, BGRA format.
542 int dstWidth = title->job->width;
543 int dstHeight = title->job->height;
544 NSBitmapFormat bitmapFormat = (NSBitmapFormat)NSAlphaFirstBitmapFormat;
545 NSBitmapImageRep * imgrep = [[[NSBitmapImageRep alloc]
546 initWithBitmapDataPlanes:nil
550 samplesPerPixel:3 // ignore alpha
553 colorSpaceName:NSCalibratedRGBColorSpace
554 bitmapFormat:bitmapFormat
555 bytesPerRow:dstWidth * 4
556 bitsPerPixel:32] autorelease];
558 int borderTop = (srcHeight - dstHeight) / 2;
559 int borderLeft = (srcWidth - dstWidth) / 2;
561 UInt32 * src = (UInt32 *)buffer;
562 UInt32 * dst = (UInt32 *)[imgrep bitmapData];
563 src += borderTop * srcWidth; // skip top rows in src to get to first row of dst
564 src += borderLeft; // skip left pixels in src to get to first pixel of dst
565 for (int r = 0; r < dstHeight; r++)
567 for (int c = 0; c < dstWidth; c++)
568 #if TARGET_RT_LITTLE_ENDIAN
569 *dst++ = Endian32_Swap(*src++);
573 src += (srcWidth - dstWidth); // skip to next row in src
576 NSImage * img = [[[NSImage alloc] initWithSize: NSMakeSize(dstWidth, dstHeight)] autorelease];
577 [img addRepresentation:imgrep];
583 // Make sure we have big enough buffer
584 static uint8_t * buffer;
585 static int bufferSize;
588 newSize = ( title->width + 2 ) * (title->height + 2 ) * 4;
589 if( bufferSize < newSize )
591 bufferSize = newSize;
592 buffer = (uint8_t *) realloc( buffer, bufferSize );
595 hb_get_preview( handle, title, pictureIndex, buffer );
597 // The image data returned by hb_get_preview is 4 bytes per pixel, BGRA format.
598 // We'll copy that into an NSImage swapping it to ARGB in the process. Alpha is
600 int width = title->width + 2; // hblib adds a one-pixel border to the image
601 int height = title->height + 2;
602 int numPixels = width * height;
603 NSBitmapFormat bitmapFormat = (NSBitmapFormat)NSAlphaFirstBitmapFormat;
604 NSBitmapImageRep * imgrep = [[[NSBitmapImageRep alloc]
605 initWithBitmapDataPlanes:nil
609 samplesPerPixel:3 // ignore alpha
612 colorSpaceName:NSCalibratedRGBColorSpace
613 bitmapFormat:bitmapFormat
614 bytesPerRow:width * 4
615 bitsPerPixel:32] autorelease];
617 UInt32 * src = (UInt32 *)buffer;
618 UInt32 * dst = (UInt32 *)[imgrep bitmapData];
619 for (int i = 0; i < numPixels; i++)
620 #if TARGET_RT_LITTLE_ENDIAN
621 *dst++ = Endian32_Swap(*src++);
626 NSImage * img = [[[NSImage alloc] initWithSize: NSMakeSize(width, height)] autorelease];
627 [img addRepresentation:imgrep];
633 // Returns the preview image for the specified index, retrieving it from its internal
634 // cache or by calling makeImageForPicture if it is not cached. Generally, you should
635 // use imageForPicture so that images are cached. Calling makeImageForPicture will
636 // always generate a new copy of the image.
637 - (NSImage *) imageForPicture: (int) pictureIndex
639 // The preview for the specified index may not currently exist, so this method
640 // generates it if necessary.
641 NSString * key = [NSString stringWithFormat:@"%d", pictureIndex];
642 NSImage * theImage = [fPicturePreviews objectForKey:key];
645 theImage = [PictureController makeImageForPicture:pictureIndex libhb:fHandle title:fTitle removeBorders: NO];
646 [fPicturePreviews setObject:theImage forKey:key];
651 // Purges all images from the cache. The next call to imageForPicture will cause a new
652 // image to be generated.
653 - (void) purgeImageCache
655 [fPicturePreviews removeAllObjects];
658 - (BOOL) loadMyNibFile
660 if(![NSBundle loadNibNamed:@"PictureSettings" owner:self])
662 NSLog(@"Warning! Could not load myNib file.\n");
671 @implementation PictureController (Private)
674 // -[PictureController(Private) optimalViewSizeForImageSize:]
676 // Given the size of the preview image to be shown, returns the best possible
677 // size for the OpenGL view.
679 - (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize
681 // The min size is 320x240
682 float minWidth = 320.0;
683 float minHeight = 240.0;
685 // The max size of the view is when the sheet is taking up 85% of the screen.
686 NSSize screenSize = [[NSScreen mainScreen] frame].size;
687 NSSize sheetSize = [fPicturePanel frame].size;
688 NSSize viewAreaSize = [fPictureViewArea frame].size;
689 float paddingX = sheetSize.width - viewAreaSize.width;
690 float paddingY = sheetSize.height - viewAreaSize.height;
691 float maxWidth = (0.85 * screenSize.width) - paddingX;
692 float maxHeight = (0.85 * screenSize.height) - paddingY;
694 NSSize resultSize = imageSize;
696 // Its better to have a view that's too small than a view that's too big, so
697 // apply the maximum constraints last.
698 if( resultSize.width < minWidth )
700 resultSize.height *= (minWidth / resultSize.width);
701 resultSize.width = minWidth;
703 if( resultSize.height < minHeight )
705 resultSize.width *= (minHeight / resultSize.height);
706 resultSize.height = minHeight;
708 if( resultSize.width > maxWidth )
710 resultSize.height *= (maxWidth / resultSize.width);
711 resultSize.width = maxWidth;
713 if( resultSize.height > maxHeight )
715 resultSize.width *= (maxHeight / resultSize.height);
716 resultSize.height = maxHeight;
723 // -[PictureController(Private) resizePanelForViewSize:animate:]
725 // Resizes the entire sheet to accomodate an OpenGL view of a particular size.
727 - (void)resizeSheetForViewSize: (NSSize)viewSize
729 // Figure out the deltas for the new frame area
730 NSSize currentSize = [fPictureViewArea frame].size;
731 float deltaX = viewSize.width - currentSize.width;
732 float deltaY = viewSize.height - currentSize.height;
734 // Now resize the whole panel by those same deltas, but don't exceed the min
735 NSRect frame = [fPicturePanel frame];
736 NSSize maxSize = [fPicturePanel maxSize];
737 NSSize minSize = [fPicturePanel minSize];
738 frame.size.width += deltaX;
739 frame.size.height += deltaY;
740 if( frame.size.width < minSize.width )
742 frame.size.width = minSize.width;
744 if( frame.size.height < minSize.height )
746 frame.size.height = minSize.height;
749 // But now the sheet is off-center, so also shift the origin to center it and
750 // keep the top aligned.
751 frame.origin.x -= (deltaX / 2.0);
752 frame.origin.y -= deltaY;
754 [fPicturePanel setFrame:frame display:YES animate:YES];
758 // -[PictureController(Private) setViewSize:]
760 // Changes the OpenGL view's size and centers it vertially inside of its area.
761 // Assumes resizeSheetForViewSize: has already been called.
763 - (void)setViewSize: (NSSize)viewSize
765 [fPictureView setFrameSize:viewSize];
767 // center it vertically
768 NSPoint origin = [fPictureViewArea frame].origin;
769 origin.y += ([fPictureViewArea frame].size.height -
770 [fPictureView frame].size.height) / 2.0;
771 [fPictureView setFrameOrigin:origin];
775 // -[PictureController(Private) viewNeedsToResizeToSize:]
777 // Returns YES if the view will need to resize to match the given size.
779 - (BOOL)viewNeedsToResizeToSize: (NSSize)newSize
781 NSSize viewSize = [fPictureView frame].size;
782 return (newSize.width != viewSize.width || newSize.height != viewSize.height);