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.fr/>.
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"];
130 /* Set deinterlaces level according to the integer in the main window */
131 [fDeinterlacePopUp selectItemAtIndex: fPictureFilterSettings.deinterlace];
133 /* we use a popup to show the denoise settings */
134 [fDenoisePopUp removeAllItems];
135 [fDenoisePopUp addItemWithTitle: @"None"];
136 [fDenoisePopUp addItemWithTitle: @"Weak"];
137 [fDenoisePopUp addItemWithTitle: @"Medium"];
138 [fDenoisePopUp addItemWithTitle: @"Strong"];
139 /* Set denoises level according to the integer in the main window */
140 [fDenoisePopUp selectItemAtIndex: fPictureFilterSettings.denoise];
144 // Adjusts the window to draw the current picture (fPicture) adjusting its size as
145 // necessary to display as much of the picture as possible.
146 - (void) displayPreview
148 [fPictureView setImage: [self imageForPicture: fPicture]];
150 NSSize displaySize = NSMakeSize( (float)fTitle->width, (float)fTitle->height );
151 /* Set the picture size display fields below the Preview Picture*/
152 if( fTitle->job->pixel_ratio == 1 ) // Original PAR Implementation
154 output_width = fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3];
155 output_height = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1];
156 display_width = output_width * fTitle->job->pixel_aspect_width / fTitle->job->pixel_aspect_height;
157 [fInfoField setStringValue:[NSString stringWithFormat:
158 @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d",
159 fTitle->width, fTitle->height, output_width, output_height, display_width, output_height]];
160 displaySize.width *= ((float)fTitle->job->pixel_aspect_width) / ((float)fTitle->job->pixel_aspect_height);
162 else if (fTitle->job->pixel_ratio == 2) // Loose Anamorphic
164 display_width = output_width * output_par_width / output_par_height;
165 [fInfoField setStringValue:[NSString stringWithFormat:
166 @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d",
167 fTitle->width, fTitle->height, output_width, output_height, display_width, output_height]];
169 /* FIXME: needs to be fixed so that the picture window does not resize itself on the first
170 anamorphic width drop
172 if (fTitle->width - 8 < output_width)
174 displaySize.width *= ((float)output_par_width) / ((float)output_par_height);
177 else // No Anamorphic
179 [fInfoField setStringValue: [NSString stringWithFormat:
180 @"Source: %dx%d, Output: %dx%d", fTitle->width, fTitle->height,
181 fTitle->job->width, fTitle->job->height]];
184 NSSize viewSize = [self optimalViewSizeForImageSize:displaySize];
185 if( [self viewNeedsToResizeToSize:viewSize] )
187 [self resizeSheetForViewSize:viewSize];
188 [self setViewSize:viewSize];
191 // Show the scaled text (use the height to check since the width can vary
192 // with anamorphic video).
193 if( ((int)viewSize.height) != fTitle->height )
195 float scale = viewSize.width / ((float)fTitle->width);
196 NSString *scaleString = [NSString stringWithFormat:
197 NSLocalizedString( @" (Preview scaled to %.0f%% actual size)",
198 @"String shown when a preview is scaled" ),
200 [fInfoField setStringValue:
201 [[fInfoField stringValue] stringByAppendingString:scaleString]];
204 [fPrevButton setEnabled: ( fPicture > 0 )];
205 [fNextButton setEnabled: ( fPicture < 9 )];
208 - (IBAction) SettingsChanged: (id) sender
210 hb_job_t * job = fTitle->job;
212 if( [fAnamorphicPopUp indexOfSelectedItem] > 0 )
214 if ([fAnamorphicPopUp indexOfSelectedItem] == 2) // Loose anamorphic
216 job->pixel_ratio = 2;
217 [fWidthStepper setEnabled: YES];
218 [fWidthField setEnabled: YES];
219 /* We set job->width and call hb_set_anamorphic_size in libhb to do a "dry run" to get
220 * the values to be used by libhb for loose anamorphic
222 job->width = [fWidthStepper intValue];
223 hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
224 [fHeightStepper setIntValue: output_height];
225 [fHeightField setIntValue: output_height];
226 job->height = [fHeightStepper intValue];
229 else // must be "1" or strict anamorphic
231 [fWidthStepper setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
232 [fWidthField setIntValue: fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]];
234 /* This will show correct anamorphic height values, but
235 show distorted preview picture ratio */
236 [fHeightStepper setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]];
237 [fHeightField setIntValue: fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]];
238 job->width = [fWidthStepper intValue];
239 job->height = [fHeightStepper intValue];
241 job->pixel_ratio = 1;
242 [fWidthStepper setEnabled: NO];
243 [fWidthField setEnabled: NO];
246 /* if the sender is the Anamorphic checkbox, record the state
247 of KeepAspect Ratio so it can be reset if Anamorphic is unchecked again */
248 if (sender == fAnamorphicPopUp)
250 keepAspectRatioPreviousState = [fRatioCheck state];
252 [fRatioCheck setState:NSOffState];
253 [fRatioCheck setEnabled: NO];
256 [fHeightStepper setEnabled: NO];
257 [fHeightField setEnabled: NO];
262 job->width = [fWidthStepper intValue];
263 job->height = [fHeightStepper intValue];
264 job->pixel_ratio = 0;
265 [fWidthStepper setEnabled: YES];
266 [fWidthField setEnabled: YES];
267 [fHeightStepper setEnabled: YES];
268 [fHeightField setEnabled: YES];
269 [fRatioCheck setEnabled: YES];
270 /* if the sender is the Anamorphic checkbox, we return the
271 keep AR checkbox to its previous state */
272 if (sender == fAnamorphicPopUp)
274 [fRatioCheck setState:keepAspectRatioPreviousState];
280 job->keep_ratio = ( [fRatioCheck state] == NSOnState );
282 fPictureFilterSettings.deinterlace = [fDeinterlacePopUp indexOfSelectedItem];
283 /* if the gui deinterlace settings are fast through slowest, the job->deinterlace
284 value needs to be set to one, for the job as well as the previews showing deinterlacing
285 otherwise set job->deinterlace to 0 or "off" */
286 if (fPictureFilterSettings.deinterlace > 0)
288 job->deinterlace = 1;
292 job->deinterlace = 0;
294 fPictureFilterSettings.denoise = [fDenoisePopUp indexOfSelectedItem];
295 fPictureFilterSettings.vfr = [fVFRCheck state];
296 if (fPictureFilterSettings.vfr > 0)
298 [fDetelecineCheck setState:NSOnState];
299 [fDetelecineCheck setEnabled: NO];
303 [fDetelecineCheck setEnabled: YES];
305 fPictureFilterSettings.detelecine = [fDetelecineCheck state];
306 fPictureFilterSettings.deblock = [fDeblockCheck state];
307 //job->pixel_ratio = ( [fPARCheck state] == NSOnState );
309 autoCrop = ( [fCropMatrix selectedRow] == 0 );
310 [fCropTopStepper setEnabled: !autoCrop];
311 [fCropBottomStepper setEnabled: !autoCrop];
312 [fCropLeftStepper setEnabled: !autoCrop];
313 [fCropRightStepper setEnabled: !autoCrop];
317 memcpy( job->crop, fTitle->crop, 4 * sizeof( int ) );
321 job->crop[0] = [fCropTopStepper intValue];
322 job->crop[1] = [fCropBottomStepper intValue];
323 job->crop[2] = [fCropLeftStepper intValue];
324 job->crop[3] = [fCropRightStepper intValue];
327 if( job->keep_ratio )
329 if( sender == fWidthStepper || sender == fRatioCheck ||
330 sender == fCropTopStepper || sender == fCropBottomStepper )
332 hb_fix_aspect( job, HB_KEEP_WIDTH );
333 if( job->height > fTitle->height )
335 job->height = fTitle->height;
336 hb_fix_aspect( job, HB_KEEP_HEIGHT );
341 hb_fix_aspect( job, HB_KEEP_HEIGHT );
342 if( job->width > fTitle->width )
344 job->width = fTitle->width;
345 hb_fix_aspect( job, HB_KEEP_WIDTH );
350 [fWidthStepper setIntValue: job->width];
351 [fWidthField setIntValue: job->width];
352 if( [fAnamorphicPopUp indexOfSelectedItem] < 2 )
354 [fHeightStepper setIntValue: job->height];
355 [fHeightField setIntValue: job->height];
357 [fCropTopStepper setIntValue: job->crop[0]];
358 [fCropTopField setIntValue: job->crop[0]];
359 [fCropBottomStepper setIntValue: job->crop[1]];
360 [fCropBottomField setIntValue: job->crop[1]];
361 [fCropLeftStepper setIntValue: job->crop[2]];
362 [fCropLeftField setIntValue: job->crop[2]];
363 [fCropRightStepper setIntValue: job->crop[3]];
364 [fCropRightField setIntValue: job->crop[3]];
365 /* Sanity Check Here for < 16 px preview to avoid
366 crashing hb_get_preview. In fact, just for kicks
367 lets getting previews at a min limit of 32, since
368 no human can see any meaningful detail below that */
369 if (job->width >= 64 && job->height >= 64)
371 // Purge the existing picture previews so they get recreated the next time
373 [self purgeImageCache];
374 [self displayPreview];
378 - (IBAction) PreviousPicture: (id) sender
385 [self displayPreview];
388 - (IBAction) NextPicture: (id) sender
395 [self displayPreview];
398 - (IBAction) ClosePanel: (id) sender
400 if ([delegate respondsToSelector:@selector(pictureSettingsDidChange)])
401 [delegate pictureSettingsDidChange];
403 [NSApp endSheet: fPicturePanel];
404 [fPicturePanel orderOut: self];
411 - (void) setAutoCrop: (BOOL) setting
416 - (BOOL) allowLooseAnamorphic
418 return allowLooseAnamorphic;
421 - (void) setAllowLooseAnamorphic: (BOOL) setting
423 allowLooseAnamorphic = setting;
428 return fPictureFilterSettings.detelecine;
431 - (void) setDetelecine: (int) setting
433 fPictureFilterSettings.detelecine = setting;
438 return fPictureFilterSettings.vfr;
441 - (void) setVFR: (int) setting
443 fPictureFilterSettings.vfr = setting;
448 return fPictureFilterSettings.deinterlace;
451 - (void) setDeinterlace: (int) setting {
452 fPictureFilterSettings.deinterlace = setting;
457 return fPictureFilterSettings.denoise;
460 - (void) setDenoise: (int) setting
462 fPictureFilterSettings.denoise = setting;
467 return fPictureFilterSettings.deblock;
470 - (void) setDeblock: (int) setting
472 fPictureFilterSettings.deblock = setting;
475 - (void)showPanelInWindow: (NSWindow *)fWindow forTitle: (hb_title_t *)title
477 [self SetTitle:title];
479 [NSApp beginSheet:fPicturePanel
480 modalForWindow:fWindow
487 // This function converts an image created by libhb (specified via pictureIndex) into
488 // an NSImage suitable for the GUI code to use. If removeBorders is YES,
489 // makeImageForPicture crops the image generated by libhb stripping off the gray
490 // border around the content. This is the low-level method that generates the image.
491 // -imageForPicture calls this function whenever it can't find an image in its cache.
492 + (NSImage *) makeImageForPicture: (int)pictureIndex
493 libhb:(hb_handle_t*)handle
494 title:(hb_title_t*)title
495 removeBorders:(BOOL)removeBorders
499 // |<---------- title->width ----------->|
500 // | |<---- title->job->width ---->| |
502 // .......................................
503 // ....+-----------------------------+....
504 // ....| |....<-- gray border
507 // ....| |<------- image
513 // ....+-----------------------------+....
514 // .......................................
516 static uint8_t * buffer;
517 static int bufferSize;
519 // Make sure we have a big enough buffer to receive the image from libhb. libhb
520 // creates images with a one-pixel border around the original content. Hence we
521 // add 2 pixels horizontally and vertically to the buffer size.
522 int srcWidth = title->width + 2;
523 int srcHeight= title->height + 2;
525 newSize = srcWidth * srcHeight * 4;
526 if( bufferSize < newSize )
528 bufferSize = newSize;
529 buffer = (uint8_t *) realloc( buffer, bufferSize );
532 hb_get_preview( handle, title, pictureIndex, buffer );
534 // Create an NSBitmapImageRep and copy the libhb image into it, converting it from
535 // libhb's format to one suitable for NSImage. Along the way, we'll strip off the
536 // border around libhb's image.
538 // The image data returned by hb_get_preview is 4 bytes per pixel, BGRA format.
541 int dstWidth = title->job->width;
542 int dstHeight = title->job->height;
543 NSBitmapFormat bitmapFormat = (NSBitmapFormat)NSAlphaFirstBitmapFormat;
544 NSBitmapImageRep * imgrep = [[[NSBitmapImageRep alloc]
545 initWithBitmapDataPlanes:nil
549 samplesPerPixel:3 // ignore alpha
552 colorSpaceName:NSCalibratedRGBColorSpace
553 bitmapFormat:bitmapFormat
554 bytesPerRow:dstWidth * 4
555 bitsPerPixel:32] autorelease];
557 int borderTop = (srcHeight - dstHeight) / 2;
558 int borderLeft = (srcWidth - dstWidth) / 2;
560 UInt32 * src = (UInt32 *)buffer;
561 UInt32 * dst = (UInt32 *)[imgrep bitmapData];
562 src += borderTop * srcWidth; // skip top rows in src to get to first row of dst
563 src += borderLeft; // skip left pixels in src to get to first pixel of dst
564 for (int r = 0; r < dstHeight; r++)
566 for (int c = 0; c < dstWidth; c++)
567 #if TARGET_RT_LITTLE_ENDIAN
568 *dst++ = Endian32_Swap(*src++);
572 src += (srcWidth - dstWidth); // skip to next row in src
575 NSImage * img = [[[NSImage alloc] initWithSize: NSMakeSize(dstWidth, dstHeight)] autorelease];
576 [img addRepresentation:imgrep];
582 // Make sure we have big enough buffer
583 static uint8_t * buffer;
584 static int bufferSize;
587 newSize = ( title->width + 2 ) * (title->height + 2 ) * 4;
588 if( bufferSize < newSize )
590 bufferSize = newSize;
591 buffer = (uint8_t *) realloc( buffer, bufferSize );
594 hb_get_preview( handle, title, pictureIndex, buffer );
596 // The image data returned by hb_get_preview is 4 bytes per pixel, BGRA format.
597 // We'll copy that into an NSImage swapping it to ARGB in the process. Alpha is
599 int width = title->width + 2; // hblib adds a one-pixel border to the image
600 int height = title->height + 2;
601 int numPixels = width * height;
602 NSBitmapFormat bitmapFormat = (NSBitmapFormat)NSAlphaFirstBitmapFormat;
603 NSBitmapImageRep * imgrep = [[[NSBitmapImageRep alloc]
604 initWithBitmapDataPlanes:nil
608 samplesPerPixel:3 // ignore alpha
611 colorSpaceName:NSCalibratedRGBColorSpace
612 bitmapFormat:bitmapFormat
613 bytesPerRow:width * 4
614 bitsPerPixel:32] autorelease];
616 UInt32 * src = (UInt32 *)buffer;
617 UInt32 * dst = (UInt32 *)[imgrep bitmapData];
618 for (int i = 0; i < numPixels; i++)
619 #if TARGET_RT_LITTLE_ENDIAN
620 *dst++ = Endian32_Swap(*src++);
625 NSImage * img = [[[NSImage alloc] initWithSize: NSMakeSize(width, height)] autorelease];
626 [img addRepresentation:imgrep];
632 // Returns the preview image for the specified index, retrieving it from its internal
633 // cache or by calling makeImageForPicture if it is not cached. Generally, you should
634 // use imageForPicture so that images are cached. Calling makeImageForPicture will
635 // always generate a new copy of the image.
636 - (NSImage *) imageForPicture: (int) pictureIndex
638 // The preview for the specified index may not currently exist, so this method
639 // generates it if necessary.
640 NSString * key = [NSString stringWithFormat:@"%d", pictureIndex];
641 NSImage * theImage = [fPicturePreviews objectForKey:key];
644 theImage = [PictureController makeImageForPicture:pictureIndex libhb:fHandle title:fTitle removeBorders: NO];
645 [fPicturePreviews setObject:theImage forKey:key];
650 // Purges all images from the cache. The next call to imageForPicture will cause a new
651 // image to be generated.
652 - (void) purgeImageCache
654 [fPicturePreviews removeAllObjects];
657 - (BOOL) loadMyNibFile
659 if(![NSBundle loadNibNamed:@"PictureSettings" owner:self])
661 NSLog(@"Warning! Could not load myNib file.\n");
670 @implementation PictureController (Private)
673 // -[PictureController(Private) optimalViewSizeForImageSize:]
675 // Given the size of the preview image to be shown, returns the best possible
676 // size for the OpenGL view.
678 - (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize
680 // The min size is 320x240
681 float minWidth = 320.0;
682 float minHeight = 240.0;
684 // The max size of the view is when the sheet is taking up 85% of the screen.
685 NSSize screenSize = [[NSScreen mainScreen] frame].size;
686 NSSize sheetSize = [fPicturePanel frame].size;
687 NSSize viewAreaSize = [fPictureViewArea frame].size;
688 float paddingX = sheetSize.width - viewAreaSize.width;
689 float paddingY = sheetSize.height - viewAreaSize.height;
690 float maxWidth = (0.85 * screenSize.width) - paddingX;
691 float maxHeight = (0.85 * screenSize.height) - paddingY;
693 NSSize resultSize = imageSize;
695 // Its better to have a view that's too small than a view that's too big, so
696 // apply the maximum constraints last.
697 if( resultSize.width < minWidth )
699 resultSize.height *= (minWidth / resultSize.width);
700 resultSize.width = minWidth;
702 if( resultSize.height < minHeight )
704 resultSize.width *= (minHeight / resultSize.height);
705 resultSize.height = minHeight;
707 if( resultSize.width > maxWidth )
709 resultSize.height *= (maxWidth / resultSize.width);
710 resultSize.width = maxWidth;
712 if( resultSize.height > maxHeight )
714 resultSize.width *= (maxHeight / resultSize.height);
715 resultSize.height = maxHeight;
722 // -[PictureController(Private) resizePanelForViewSize:animate:]
724 // Resizes the entire sheet to accomodate an OpenGL view of a particular size.
726 - (void)resizeSheetForViewSize: (NSSize)viewSize
728 // Figure out the deltas for the new frame area
729 NSSize currentSize = [fPictureViewArea frame].size;
730 float deltaX = viewSize.width - currentSize.width;
731 float deltaY = viewSize.height - currentSize.height;
733 // Now resize the whole panel by those same deltas, but don't exceed the min
734 NSRect frame = [fPicturePanel frame];
735 NSSize maxSize = [fPicturePanel maxSize];
736 NSSize minSize = [fPicturePanel minSize];
737 frame.size.width += deltaX;
738 frame.size.height += deltaY;
739 if( frame.size.width < minSize.width )
741 frame.size.width = minSize.width;
743 if( frame.size.height < minSize.height )
745 frame.size.height = minSize.height;
748 // But now the sheet is off-center, so also shift the origin to center it and
749 // keep the top aligned.
750 frame.origin.x -= (deltaX / 2.0);
751 frame.origin.y -= deltaY;
753 [fPicturePanel setFrame:frame display:YES animate:YES];
757 // -[PictureController(Private) setViewSize:]
759 // Changes the OpenGL view's size and centers it vertially inside of its area.
760 // Assumes resizeSheetForViewSize: has already been called.
762 - (void)setViewSize: (NSSize)viewSize
764 [fPictureView setFrameSize:viewSize];
766 // center it vertically
767 NSPoint origin = [fPictureViewArea frame].origin;
768 origin.y += ([fPictureViewArea frame].size.height -
769 [fPictureView frame].size.height) / 2.0;
770 [fPictureView setFrameOrigin:origin];
774 // -[PictureController(Private) viewNeedsToResizeToSize:]
776 // Returns YES if the view will need to resize to match the given size.
778 - (BOOL)viewNeedsToResizeToSize: (NSSize)newSize
780 NSSize viewSize = [fPictureView frame].size;
781 return (newSize.width != viewSize.width || newSize.height != viewSize.height);