From: dynaflash Date: Mon, 12 Jan 2009 00:07:38 +0000 (+0000) Subject: MacGui: Separate Picture Settings and Preview Window Initial Implementation X-Git-Tag: 0.9.4~881 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e73b3884143ae1fb8c8cd9a384c1ef959fa0a86;p=handbrake MacGui: Separate Picture Settings and Preview Window Initial Implementation - Picture Settings is now a hud style inspector panel: -- Allows more room to be displayed along with Main Window. -- Has button (though ugly ... for now) to open the preview window. - Separate Preview Window: -- Preview Window can now show the entire preview content via a hud style overlay controller (ala iTunes, DvdPlayer controls) activated by mouse movement. -- Has button to allow opening the Picture Settings inspector. -- Full Screen Mode (ala iTunes, DvdPlayer) which should help for max preview size for HD sources. - Note: all hud style controls in this implementation are created only using core animation filters, I decided against a third party hud control framework, though one can certainly be implemented at any time. - Known Issues: -- WARNING: Quitting HB while in full screen mode will crash the macgui. -- The hud overlay controls in the Preview Window will align kind of wonky when the resolution is scaled way below the source. -- Ideally, after moving the mouse within the preview area then stopping, after a certain amount of time the hud overlay control box should disappear. -- Hud style controls still need alot of development to fit within the HIG. -- Need a keboard shortcut for the Preview Window. -- As usual with initial implementations there are likely many more Bugs/Issues. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2076 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/macosx/Controller.h b/macosx/Controller.h index e05b0afd8..6ca336a36 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -11,6 +11,7 @@ #import "ChapterTitles.h" #import "PictureController.h" +#import "HBPreviewController.h" #import "HBQueueController.h" #import "HBAdvancedController.h" #import "HBPreferencesController.h" @@ -26,6 +27,7 @@ BOOL fIsDragging; } @end + @interface HBController : NSObject { IBOutlet NSWindow * fWindow; @@ -41,8 +43,10 @@ BOOL fIsDragging; IBOutlet NSButton * fScanSrcTitleCancelButton; IBOutlet NSButton * fScanSrcTitleOpenButton; - /* Picture panel */ + /* Picture Settings */ PictureController * fPictureController; + /* Picture Preview */ + PreviewController * fPreviewController; /* Advanced options tab */ HBAdvancedController * fAdvancedOptions; @@ -299,6 +303,10 @@ BOOL fIsDragging; - (IBAction) audioDRCSliderChanged: (id) sender; - (IBAction) showPicturePanel: (id) sender; +- (void) picturePanelFullScreen; +- (void) picturePanelWindowed; + +- (IBAction) showPreviewWindow: (id) sender; - (void)pictureSettingsDidChange; - (IBAction) calculatePictureSizing: (id) sender; - (IBAction) openMainWindow: (id) sender; diff --git a/macosx/Controller.mm b/macosx/Controller.mm index d507bbcba..3ca252b3c 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -9,6 +9,7 @@ #import "HBPreferencesController.h" #import "HBDVDDetector.h" #import "HBPresets.h" +#import "HBPreviewController.h" #define DragDropSimplePboardType @"MyCustomOutlineViewPboardType" @@ -61,6 +62,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It } outputPanel = [[HBOutputPanelController alloc] init]; fPictureController = [[PictureController alloc] init]; + //fPreviewController = [[PreviewController alloc] init]; fQueueController = [[HBQueueController alloc] init]; fAdvancedOptions = [[HBAdvancedController alloc] init]; /* we init the HBPresets class which currently is only used @@ -90,6 +92,10 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It /* Init others controllers */ [fPictureController SetHandle: fHandle]; [fPictureController setHBController: self]; + /* fPreviewController */ + //[fPreviewController SetHandle: fHandle]; + //[fPreviewController setHBController: self]; + [fQueueController setHandle: fQueueEncodeLibhb]; [fQueueController setHBController: self]; @@ -198,7 +204,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) app { - + [fPreviewController goWindowedScreen:nil]; // Warn if encoding a movie hb_state_t s; hb_get_state( fQueueEncodeLibhb, &s ); @@ -241,6 +247,8 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It [outputPanel release]; [fQueueController release]; [fPictureController release]; + + [fPreviewController release]; hb_close(&fHandle); hb_close(&fQueueEncodeLibhb); } @@ -3599,9 +3607,9 @@ fWorkingCount = 0; AutoCropLeft = job->crop[2]; AutoCropRight = job->crop[3]; - /* Reset the new title in fPictureController */ + /* Reset the new title in fPictureController && fPreviewController*/ [fPictureController SetTitle:title]; - + //[fPreviewController SetTitle:title]; /* Update subtitle popups */ hb_subtitle_t * subtitle; [fSubPopUp removeAllItems]; @@ -5161,13 +5169,22 @@ the user is using "Custom" settings by determining the sender*/ - (IBAction) showPicturePanel: (id) sender { - /* - hb_list_t * list = hb_get_titles( fHandle ); - hb_title_t * title = (hb_title_t *) hb_list_item( list, - [fSrcTitlePopUp indexOfSelectedItem] ); - */ - //[fPictureController showPreviewPanel:sender forTitle:title]; - [fPictureController showPictureWindow:sender]; + [fPictureController showPictureWindow:sender]; +} + +- (void) picturePanelFullScreen +{ + [fPictureController setToFullScreenMode]; +} + +- (void) picturePanelWindowed +{ + [fPictureController setToWindowedMode]; +} + +- (IBAction) showPreviewWindow: (id) sender +{ + [fPictureController showPreviewWindow:sender]; } #pragma mark - @@ -5758,8 +5775,9 @@ return YES; if (fTitle->width < [[chosenPreset objectForKey:@"PictureWidth"] intValue] || fTitle->height < [[chosenPreset objectForKey:@"PictureHeight"] intValue]) { /* if so, then we use the sources height and width to avoid scaling up */ - job->width = fTitle->width; - job->height = fTitle->height; + //job->width = fTitle->width; + //job->height = fTitle->height; + [self revertPictureSizeToMax:nil]; } else // source width/height is >= the preset height/width { diff --git a/macosx/English.lproj/MainMenu.xib b/macosx/English.lproj/MainMenu.xib index aa14d9342..6abcd884d 100644 --- a/macosx/English.lproj/MainMenu.xib +++ b/macosx/English.lproj/MainMenu.xib @@ -2,13 +2,13 @@ 1050 - 9F33 + 9G55 670 - 949.34 - 352.00 + 949.43 + 353.00 YES - + YES @@ -40,7 +40,7 @@ {3.40282e+38, 3.40282e+38} {213, 107} - + 256 YES @@ -3219,7 +3219,6 @@ {760, 550} - {{0, 0}, {1920, 1178}} {213, 129} @@ -3836,6 +3835,14 @@ + + + Preview Window + + 2147483647 + + + Activity Window @@ -6526,6 +6533,14 @@ 5156 + + + showPreviewWindow: + + + + 5158 + @@ -7664,6 +7679,7 @@ + @@ -9934,6 +9950,11 @@ + + 5157 + + + @@ -9952,6 +9973,7 @@ 1190.ImportedFromIB2 1191.IBPluginDependency 1191.ImportedFromIB2 + 1192.IBEditorWindowLastContentRect 1192.IBPluginDependency 1192.ImportedFromIB2 1193.IBPluginDependency @@ -10232,6 +10254,7 @@ 1900.ImportedFromIB2 1948.IBPluginDependency 1948.ImportedFromIB2 + 1949.IBEditorWindowLastContentRect 1949.IBPluginDependency 1949.ImportedFromIB2 1950.IBPluginDependency @@ -10403,6 +10426,7 @@ 2839.ImportedFromIB2 2840.IBPluginDependency 2840.ImportedFromIB2 + 29.IBEditorWindowLastContentRect 29.IBPluginDependency 29.ImportedFromIB2 29.editorWindowContentRectSynchronizationRect @@ -10598,6 +10622,7 @@ 5135.IBPluginDependency 5153.IBPluginDependency 5153.ImportedFromIB2 + 5157.IBPluginDependency 56.IBPluginDependency 56.ImportedFromIB2 57.IBPluginDependency @@ -10626,6 +10651,7 @@ com.apple.InterfaceBuilder.CocoaPlugin + {{262, 642}, {211, 183}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -10913,6 +10939,7 @@ com.apple.InterfaceBuilder.CocoaPlugin + {{195, 732}, {236, 93}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -11091,6 +11118,7 @@ com.apple.InterfaceBuilder.CocoaPlugin + {{0, 825}, {394, 20}} com.apple.InterfaceBuilder.CocoaPlugin {{63, 836}, {394, 20}} @@ -11301,6 +11329,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -11335,7 +11364,7 @@ - 5156 + 5158 @@ -11389,6 +11418,7 @@ showNewScan: showPicturePanel: showPreferencesWindow: + showPreviewWindow: showQueueWindow: showSourceTitleScanPanel: subtitleSelectionChanged: @@ -11450,6 +11480,7 @@ id id id + id @@ -11747,13 +11778,6 @@ NSOutlineView - - NSObject - - IBProjectSource - PictureController.h - - NSObject diff --git a/macosx/English.lproj/PicturePreview.xib b/macosx/English.lproj/PicturePreview.xib new file mode 100644 index 000000000..adf47df43 --- /dev/null +++ b/macosx/English.lproj/PicturePreview.xib @@ -0,0 +1,1306 @@ + + + + 1050 + 9G55 + 670 + 949.43 + 353.00 + + YES + + + + YES + com.apple.QTKitIBPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + PreviewController + + + FirstResponder + + + NSApplication + + + 7 + 2 + {{482, 423}, {475, 433}} + 1886913536 + HandBrake Preview + NSPanel + + View + + {3.40282e+38, 3.40282e+38} + + + 256 + + YES + + + 18 + + YES + + + 256 + + YES + + + 274 + + YES + + YES + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + NSFilenamesPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT TIFF v4.0 pasteboard type + + + {{-1, -2}, {475, 450}} + + YES + + 130560 + 33554432 + 0 + 1 + 0 + NO + + YES + + + + 274 + + YES + + YES + Apple URL pasteboard type + CorePasteboardFlavorType 0x6D6F6F76 + NSFilenamesPboardType + QTMoviePasteboardType + + + {{-10, -2}, {484, 450}} + + + 1 + MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA + + + + + + + + + 45 + + YES + + + 256 + + YES + + + 292 + {{18, 12}, {77, 17}} + + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + + YES + + 67239424 + 134479872 + Live Preview + + LucidaGrande + 9.000000e+00 + 3614 + + + -2038284033 + 164 + + + 200 + 25 + + + + + 289 + {{271, 11}, {69, 17}} + + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + + YES + + 67239424 + 134479872 + Full Screen + + + -2038284033 + 164 + + + 200 + 25 + + + + + 289 + {{346, 11}, {54, 17}} + + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + + YES + + 67239424 + 134479872 + Settings + + + -2038284033 + 164 + + + 200 + 25 + + + + + 289 + {{108, 15}, {89, 11}} + + YES + + 68288064 + 71566336 + Duration (seconds): + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2OQA + + + + 1 + MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA + + + + + + 289 + {{199, 12}, {45, 15}} + + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + + YES + + -2076049856 + 264192 + + + 109199615 + 1 + + + 400 + 75 + + + Item 1 + + 1048576 + 2147483647 + 1 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + _popUpItemAction: + + + YES + + OtherViews + + YES + + + + Item 2 + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + Item 3 + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + 1 + YES + YES + 2 + + + + + 290 + {{18, 40}, {382, 16}} + + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + + YES + + 67501824 + 262144 + + + + 9.000000e+00 + 0.000000e+00 + 0.000000e+00 + 0.000000e+00 + 10 + 1 + YES + NO + + + + + 290 + {{15, 66}, {388, 14}} + + YES + + 67239424 + 4325376 + + + LucidaGrande + 1.100000e+01 + 3100 + + + YES + + + 1 + MSAxIDEAA + + + + + {{1, 1}, {418, 98}} + + + + {{30, 114}, {420, 100}} + + {0, 0} + + 67239424 + 0 + Picture Controls + + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 3 + MCAwLjgwMDAwMDAxAA + + + + 1 + 4 + 0 + NO + 6.000000e+00 + + + 1 + MCAwIDAgMC43NQA + + + + + 45 + + YES + + + 256 + + YES + + + -2147482368 + + {{17, 27}, {325, 12}} + + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + + 16650 + 2.000000e+01 + 1.000000e+02 + + + + 265 + {{357, 24}, {46, 17}} + + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + + YES + + 67239424 + 134479872 + Cancel + + + -2038284033 + 164 + + + 200 + 25 + + + + + 256 + {{15, 61}, {391, 12}} + + YES + + 68288064 + 4326400 + Preparing Preview + + + + 2 + MC45MDE5NjA4NSAwLjkwMTk2MDg1IDAuOTAxOTYwODUgMAA + + + + + + {{1, 1}, {418, 98}} + + + + {{29, 266}, {420, 100}} + + {0, 0} + + 67239424 + 0 + Encoding Controls + + + + 3 + MCAwLjgwMDAwMDAxAA + + + + 1 + 4 + 0 + NO + 6.000000e+00 + + + 1 + MCAwIDAgMC43NQA + + + + {{1, 1}, {473, 431}} + + + + {475, 433} + + {0, 0} + + 67239424 + 0 + Box + + + + 3 + MCAwLjgwMDAwMDAxAA + + + + 1 + 3 + 0 + NO + + + {475, 433} + + + {{0, 0}, {1440, 878}} + {3.40282e+38, 3.40282e+38} + + + + + YES + + + fInfoField + + + + 73 + + + + fPictureView + + + + 181 + + + + window + + + + 184 + + + + fMovieView + + + + 208 + + + + fPictureSlider + + + + 211 + + + + pictureSliderChanged: + + + + 212 + + + + fMovieCreationProgressIndicator + + + + 214 + + + + fCreatePreviewMovieButton + + + + 217 + + + + createMoviePreview: + + + + 218 + + + + fPreviewMovieStatusField + + + + 225 + + + + fPreviewMovieLengthPopUp + + + + 232 + + + + previewDurationPopUpChanged: + + + + 233 + + + + fPreviewWindow + + + + 244 + + + + fEncodingControlBox + + + + 253 + + + + fPictureControlBox + + + + 254 + + + + fPictureViewArea + + + + 258 + + + + fCancelPreviewMovieButton + + + + 263 + + + + createMoviePreview: + + + + 264 + + + + fFullScreenToggleButton + + + + 267 + + + + toggleScreenMode: + + + + 270 + + + + fPictureSettingsToggleButton + + + + 273 + + + + showPictureSettings: + + + + 274 + + + + + YES + + 0 + + YES + + + + + + -2 + + + RmlsZSdzIE93bmVyA + + + -1 + + + First Responder + + + -3 + + + Application + + + 5 + + + YES + + + + PreviewPanel + + + 6 + + + YES + + + + + + 257 + + + YES + + + + + + + + + 179 + + + YES + + + + + + 180 + + + + + 207 + + + + + 252 + + + YES + + + + + + + + 213 + + + + + 223 + + + YES + + + + + + 224 + + + + + 251 + + + YES + + + + + + + + + + + + 38 + + + YES + + + + + + 215 + + + YES + + + + + + 234 + + + YES + + + + + + 226 + + + YES + + + + + + 209 + + + YES + + + + + + 210 + + + + + 227 + + + YES + + + + + + 228 + + + YES + + + + + + + + 231 + + + + + 230 + + + + + 229 + + + + + 235 + + + + + 216 + + + + + 165 + + + + + 261 + + + YES + + + + + + 262 + + + + + 265 + + + YES + + + + + + 266 + + + + + 271 + + + YES + + + + + + 272 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + -3.ImportedFromIB2 + 179.IBPluginDependency + 180.IBPluginDependency + 207.IBPluginDependency + 209.IBPluginDependency + 210.IBPluginDependency + 213.IBPluginDependency + 215.IBPluginDependency + 215.IBViewIntegration.shadowBlurRadius + 215.IBViewIntegration.shadowColor + 215.IBViewIntegration.shadowOffsetHeight + 215.IBViewIntegration.shadowOffsetWidth + 216.IBPluginDependency + 223.IBPluginDependency + 224.IBPluginDependency + 226.IBPluginDependency + 226.ImportedFromIB2 + 228.IBEditorWindowLastContentRect + 228.IBPluginDependency + 228.ImportedFromIB2 + 229.IBPluginDependency + 229.ImportedFromIB2 + 230.IBPluginDependency + 230.ImportedFromIB2 + 231.IBPluginDependency + 231.ImportedFromIB2 + 234.IBPluginDependency + 235.IBPluginDependency + 251.IBViewIntegration.shadowBlurRadius + 251.IBViewIntegration.shadowColor + 251.IBViewIntegration.shadowOffsetHeight + 251.IBViewIntegration.shadowOffsetWidth + 252.IBViewIntegration.shadowBlurRadius + 252.IBViewIntegration.shadowColor + 252.IBViewIntegration.shadowOffsetHeight + 252.IBViewIntegration.shadowOffsetWidth + 257.IBPluginDependency + 261.IBPluginDependency + 262.IBPluginDependency + 265.IBPluginDependency + 265.IBViewIntegration.shadowBlurRadius + 265.IBViewIntegration.shadowColor + 265.IBViewIntegration.shadowOffsetHeight + 265.IBViewIntegration.shadowOffsetWidth + 266.IBPluginDependency + 271.IBPluginDependency + 271.IBViewIntegration.shadowBlurRadius + 271.IBViewIntegration.shadowColor + 271.IBViewIntegration.shadowOffsetHeight + 271.IBViewIntegration.shadowOffsetWidth + 272.IBPluginDependency + 38.IBPluginDependency + 38.ImportedFromIB2 + 5.IBEditorWindowLastContentRect + 5.IBPluginDependency + 5.IBViewEditorWindowController.showingLayoutRectangles + 5.IBWindowTemplateEditedContentRect + 5.ImportedFromIB2 + 5.editorWindowContentRectSynchronizationRect + 5.windowTemplate.hasMaxSize + 5.windowTemplate.hasMinSize + 5.windowTemplate.maxSize + 5.windowTemplate.minSize + 6.IBPluginDependency + 6.ImportedFromIB2 + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.QTKitIBPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + 3 + MAA + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + {{656, 304}, {87, 48}} + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + {{34, 423}, {475, 433}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{34, 423}, {475, 433}} + + {{221, 276}, {533, 580}} + + + {3.40282e+38, 3.40282e+38} + {453, 550} + com.apple.InterfaceBuilder.CocoaPlugin + + + + + YES + + YES + + + YES + + + + + YES + + YES + + + YES + + + + 274 + + + + YES + + FirstResponder + NSObject + + IBUserSource + + + + + NSBox + NSView + + IBUserSource + + + + + NSObject + + IBUserSource + + + + + PreviewController + NSWindowController + + YES + + YES + SettingsChanged: + createMoviePreview: + goFullScreen: + goWindowedScreen: + pictureSliderChanged: + previewDurationPopUpChanged: + showMoviePreview: + showPictureSettings: + showPreviewWindow: + toggleScreenMode: + + + YES + id + id + id + id + id + id + NSString + id + id + id + + + + YES + + YES + fCancelPreviewMovieButton + fCreatePreviewMovieButton + fEncodingControlBox + fFullScreenToggleButton + fInfoField + fMovieCreationProgressIndicator + fMovieView + fPictureControlBox + fPictureSettingsToggleButton + fPictureSlider + fPictureView + fPictureViewArea + fPreviewMovieLengthPopUp + fPreviewMovieStatusField + fPreviewWindow + fShowPreviewMovieButton + + + YES + NSButton + NSButton + NSBox + NSButton + NSTextField + NSProgressIndicator + QTMovieView + NSBox + NSButton + NSSlider + NSImageView + NSBox + NSPopUpButton + NSTextField + NSWindow + NSButton + + + + IBProjectSource + HBPreviewController.h + + + + + 0 + ../HandBrake.xcodeproj + 3 + + diff --git a/macosx/English.lproj/PictureSettings.xib b/macosx/English.lproj/PictureSettings.xib index 0d529c935..74bfbec31 100644 --- a/macosx/English.lproj/PictureSettings.xib +++ b/macosx/English.lproj/PictureSettings.xib @@ -8,11 +8,10 @@ 353.00 YES - + YES - com.apple.QTKitIBPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -27,92 +26,22 @@ NSApplication - 7 + 8215 2 - {{482, 299}, {484, 557}} - 1886912512 + {{1211, 357}, {229, 518}} + 1886913536 Picture Settings NSPanel View - {3.40282e+38, 3.40282e+38} - {453, 558} + {10000, 10000} + {230, 500} 256 YES - - - 290 - {{20, 57}, {413, 5}} - - {0, 0} - - 67239424 - 0 - Box - - LucidaGrande - 1.300000e+01 - 1044 - - - 6 - System - textBackgroundColor - - 3 - MQA - - - - 3 - MCAwLjgwMDAwMDAxAA - - - 3 - 2 - 0 - NO - - - - 290 - {{16, 19}, {215, 14}} - - YES - - 67239424 - 4325376 - - - LucidaGrande - 1.100000e+01 - 3100 - - - - 6 - System - controlColor - - 3 - MC42NjY2NjY2OQA - - - - 6 - System - controlTextColor - - 3 - MAA - - - - 265 @@ -126,8 +55,35 @@ 292 - {{112, 65}, {19, 28}} + {{110, 62}, {19, 28}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + + + YES + + + 6.000000e-01 + 4.500000e-01 + 3.000000e-01 + 1.000000e+00 + + + YES + + YES 917024 @@ -141,8 +97,22 @@ 292 - {{155, 35}, {19, 28}} + {{153, 32}, {19, 28}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES 917024 @@ -156,8 +126,22 @@ 256 - {{18, 96}, {77, 40}} + {{16, 93}, {20, 40}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES 2 1 @@ -167,7 +151,11 @@ -2080244224 131072 Automatic - + + LucidaGrande + 1.100000e+01 + 3100 + 1211912703 0 @@ -196,15 +184,19 @@ 75 - {77, 18} + {20, 18} {4, 4} - 1143472128 + 1143480320 NSActionCell 67239424 0 Radio - + + LucidaGrande + 1.300000e+01 + 1044 + 1211912703 0 @@ -214,7 +206,7 @@ YES YES - + TU0AKgAABRgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAA @@ -321,14 +313,25 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 75 - - + + 6 + System + controlColor + + 3 + MC42NjY2NjY2OQA + + + + 3 + MQA + 292 - {{54, 69}, {56, 19}} + {{52, 66}, {56, 19}} YES @@ -338,19 +341,20 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA YES - - - 6 - System - textColor - + + 1 + MC4yIDAuMiAwLjIAA + + + 1 + MSAxIDEAA 292 - {{54, 10}, {56, 19}} + {{52, 7}, {56, 19}} YES @@ -360,15 +364,29 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA YES - - + + 292 - {{76, 35}, {19, 28}} + {{74, 32}, {19, 28}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES 917024 @@ -382,7 +400,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 292 - {{97, 40}, {56, 19}} + {{95, 37}, {56, 19}} YES @@ -392,14 +410,14 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA YES - - + + 292 - {{18, 40}, {56, 19}} + {{16, 37}, {56, 19}} YES @@ -409,15 +427,29 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA YES - - + + 292 - {{113, 5}, {19, 28}} + {{111, 2}, {19, 28}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES 917024 @@ -428,20 +460,57 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA YES + + + 256 + {{41, 116}, {68, 17}} + + YES + + 67239424 + 4194304 + Automatic + + + + + + + + + 256 + {{41, 93}, {68, 17}} + + YES + + 67239424 + 4194304 + Custom + + + + + + - {{2, 2}, {189, 146}} + {{2, 15}, {189, 144}} - {{272, 234}, {193, 163}} + {{17, 183}, {193, 161}} {0, 0} 67239424 0 - Crop + - + + 6 + System + textBackgroundColor + + 3 MCAwLjgwMDAwMDAxAA @@ -450,12 +519,12 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 3 0 - 2 + 5 NO - 265 + 268 YES @@ -466,7 +535,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 256 - {{14, 64}, {55, 14}} + {{14, 53}, {55, 14}} YES @@ -476,13 +545,35 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - + + 1 + MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA + + + + + + 256 + {{16, 24}, {123, 17}} + + YES + + 67239424 + 71303168 + Keep Aspect Ratio: + + + + + 1 + MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA + 292 - {{77, 62}, {62, 19}} + {{77, 51}, {62, 19}} YES @@ -492,15 +583,29 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA YES - - + + 256 - {{7, 36}, {152, 18}} + {{141, 25}, {18, 18}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES 67239424 @@ -522,7 +627,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 292 - {{141, 57}, {19, 28}} + {{141, 46}, {19, 28}} YES @@ -539,7 +644,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 256 - {{14, 91}, {55, 14}} + {{14, 80}, {55, 14}} YES @@ -549,13 +654,13 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - + 292 - {{77, 89}, {62, 19}} + {{77, 78}, {62, 19}} YES @@ -565,15 +670,29 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA YES - - + + 292 - {{141, 84}, {19, 28}} + {{141, 73}, {19, 28}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES 917024 @@ -589,8 +708,22 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 268 - {{82, 16}, {100, 15}} + {{82, 0}, {100, 15}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES -2076049856 @@ -664,7 +797,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 268 - {{7, 15}, {73, 14}} + {{7, 2}, {73, 14}} YES @@ -674,21 +807,21 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - + - {{2, 2}, {189, 119}} + {{2, 18}, {189, 110}} - {{274, 401}, {193, 136}} + {{19, 362}, {193, 130}} {0, 0} 67239424 0 - Size + @@ -699,7 +832,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 3 0 - 2 + 4 NO @@ -715,8 +848,22 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 256 - {{73, 92}, {110, 15}} + {{73, 74}, {110, 15}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES -2076049856 @@ -789,7 +936,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 256 - {{2, 90}, {68, 17}} + {{2, 72}, {68, 17}} YES @@ -799,14 +946,44 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - + + + + + + 256 + {{2, 97}, {68, 17}} + + YES + + 67239424 + 71303168 + Detelecine: + + + + 256 - {{6, 116}, {82, 18}} + {{71, 99}, {18, 18}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES 67239424 @@ -826,8 +1003,22 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 256 - {{4, 17}, {82, 18}} + {{64, -1}, {22, 18}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES 67239424 @@ -847,8 +1038,22 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 256 - {{74, 65}, {109, 15}} + {{74, 47}, {109, 15}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES -2076049856 @@ -917,7 +1122,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 256 - {{19, 64}, {51, 17}} + {{19, 46}, {51, 17}} YES @@ -927,13 +1132,13 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - + 256 - {{10, 40}, {51, 17}} + {{10, 22}, {51, 17}} YES @@ -943,13 +1148,29 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - + + + + + + 256 + {{14, 1}, {55, 14}} + + YES + + 67239424 + 71303168 + Decomb: + + + + 256 - {{56, 42}, {31, 14}} + {{56, 24}, {31, 14}} YES @@ -959,14 +1180,28 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - + 268 - {{88, 40}, {96, 16}} + {{88, 19}, {96, 16}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES -2079981824 @@ -985,17 +1220,17 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - {{2, 2}, {189, 143}} + {{2, 18}, {189, 133}} - {{272, 70}, {193, 160}} + {{17, 10}, {193, 153}} {0, 0} 67239424 0 - Filters + @@ -1006,137 +1241,86 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 3 0 - 2 + 4 NO - + - -2147483374 - - YES - - - 256 - {208, 451} - - - - {{20, 74}, {208, 451}} + 256 + {{17, 341}, {68, 17}} - {0, 0} - + YES + 67239424 - 0 - Box + 4194304 + Crop - - - 3 - MCAwLjgwMDAwMDAxAA - + + + - - 0 - 3 - 0 - NO - + - 274 - - YES - - YES - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - NSFilenamesPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT TIFF v4.0 pasteboard type - - - {{20, 74}, {208, 451}} + 256 + {{19, 489}, {55, 17}} YES - - 130560 - 33554432 - 0 - 1 - 0 - NO - - YES - - - - 268 - - YES - - YES - Apple URL pasteboard type - CorePasteboardFlavorType 0x6D6F6F76 - NSFilenamesPboardType - QTMoviePasteboardType + + 67239424 + 4194304 + Size + + + + + 1 + MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA - {{20, 74}, {208, 451}} - - - 1 - MC44MDAwMDAwMSAwLjgwMDAwMDAxIDAuODAwMDAwMDEAA - - - - - - + - 290 - {{18, 37}, {210, 16}} + 256 + {{19, 163}, {44, 14}} YES - - -2079981824 - 262144 - - - - 9.000000e+00 - 0.000000e+00 - 0.000000e+00 - 0.000000e+00 - 10 - 1 - YES - NO + + 67239424 + 4194304 + Filters + + + + - - - -2147482334 - - {{19, 36}, {210, 12}} - - 16650 - 2.000000e+01 - 1.000000e+02 - - + - 289 - {{235, 18}, {85, 16}} + 268 + {{156, 490}, {57, 16}} + YES + + YES + + + 7.019608e-01 + 7.019608e-01 + 7.019608e-01 + 1.000000e+00 + + + YES + + YES - + 67239424 134479872 - Live Preview + Preview - + -2038284033 129 @@ -1145,112 +1329,12 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 25 - - - -2147483358 - {{17, 61}, {214, 12}} - - YES - - 68288064 - 4457472 - - - - - 2 - MC45MDE5NjA4NSAwLjkwMTk2MDg1IDAuOTAxOTYwODUAA - - - - - - - 289 - {{417, 19}, {48, 15}} - - YES - - -2076049856 - 264192 - - - 109199615 - 1 - - - 400 - 75 - - - Item 1 - - 1048576 - 2147483647 - 1 - - - _popUpItemAction: - - - YES - - OtherViews - - YES - - - - Item 2 - - 1048576 - 2147483647 - - - _popUpItemAction: - - - - - Item 3 - - 1048576 - 2147483647 - - - _popUpItemAction: - - - - - 1 - YES - YES - 2 - - - - - 289 - {{324, 21}, {89, 11}} - - YES - - 68288064 - 71566336 - Duration (seconds): - - - - - - - {484, 557} + {229, 518} {{0, 0}, {1440, 878}} - {453, 580} + {230, 519} {3.40282e+38, 3.40282e+38} @@ -1385,14 +1469,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 69 - - - fInfoField - - - - 73 - fRatioCheck @@ -1505,22 +1581,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 142 - - - fPictureView - - - - 181 - - - - fPictureViewArea - - - - 183 - window @@ -1553,78 +1613,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 206 - - - fMovieView - - - - 208 - - - - fPictureSlider - - - - 211 - - - - pictureSliderChanged: - - - - 212 - - - - fMovieCreationProgressIndicator - - - - 214 - - - - fCreatePreviewMovieButton - - - - 217 - - - - createMoviePreview: - - - - 218 - - - - fPreviewMovieStatusField - - - - 225 - - - - fPreviewMovieLengthPopUp - - - - 232 - - - - previewDurationPopUpChanged: - - - - 233 - fDecombCheck @@ -1673,6 +1661,22 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 243 + + + fPreviewOpenButton + + + + 272 + + + + showPreviewWindow: + + + + 273 + @@ -1718,20 +1722,13 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA YES + - - - - - - - - - - - - + + + + @@ -1749,33 +1746,16 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA + + - - 21 - - - YES - - - 256 - {{2, 2}, {734, 1}} - - - - - - 22 - - - 23 YES - @@ -1784,15 +1764,9 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - - - - - 38 - - - YES - + + + @@ -1810,22 +1784,10 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA + - - 92 - - - YES - - - - - 165 - - - 12 @@ -2250,20 +2212,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - - 179 - - - YES - - - - - - 180 - - - 195 @@ -2307,128 +2255,144 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - 207 - - - - - 209 - + 236 + YES - + - + - 210 - - + 237 + + - 213 - - + 244 + + + YES + + + - 215 - + 245 + + + + + 246 + YES - + - + - 216 - - + 247 + + - 223 - + 248 + YES - + - + - 224 - - + 249 + + - 226 - + 250 + YES - + - + + + + 251 + + - 227 - + 252 + YES - + - + + + + 253 + + - 228 - + 260 + YES - - - + - + - 229 - - + 261 + + - 230 - - + 262 + + + YES + + + - 231 - - + 263 + + - 234 - + 264 + YES - + - 235 - - + 265 + + - 236 - + 270 + YES - + - + - 237 - - + 271 + + @@ -2468,53 +2432,48 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 16.ImportedFromIB2 17.IBPluginDependency 17.ImportedFromIB2 - 179.IBPluginDependency 18.IBPluginDependency 18.ImportedFromIB2 - 180.IBPluginDependency 19.IBPluginDependency 19.ImportedFromIB2 195.IBPluginDependency + 195.IBViewIntegration.shadowBlurRadius + 195.IBViewIntegration.shadowColor + 195.IBViewIntegration.shadowOffsetHeight + 195.IBViewIntegration.shadowOffsetWidth 196.IBPluginDependency 197.IBPluginDependency 197.ImportedFromIB2 204.IBPluginDependency 204.ImportedFromIB2 - 207.IBPluginDependency - 209.IBPluginDependency - 21.IBPluginDependency - 21.ImportedFromIB2 - 210.IBPluginDependency - 213.IBPluginDependency - 215.IBPluginDependency - 216.IBPluginDependency - 22.IBPluginDependency - 22.ImportedFromIB2 - 223.IBPluginDependency - 224.IBPluginDependency - 226.IBPluginDependency - 226.ImportedFromIB2 - 228.IBEditorWindowLastContentRect - 228.IBPluginDependency - 228.ImportedFromIB2 - 229.IBPluginDependency - 229.ImportedFromIB2 23.IBPluginDependency 23.ImportedFromIB2 - 230.IBPluginDependency - 230.ImportedFromIB2 - 231.IBPluginDependency - 231.ImportedFromIB2 - 234.IBPluginDependency - 235.IBPluginDependency 236.IBPluginDependency 236.ImportedFromIB2 + 244.IBPluginDependency + 244.ImportedFromIB2 + 246.IBPluginDependency + 246.ImportedFromIB2 + 248.IBPluginDependency + 248.ImportedFromIB2 25.IBPluginDependency 25.ImportedFromIB2 + 250.IBPluginDependency + 250.ImportedFromIB2 + 252.IBPluginDependency + 252.ImportedFromIB2 26.IBPluginDependency 26.ImportedFromIB2 + 260.IBPluginDependency + 260.ImportedFromIB2 + 262.IBPluginDependency + 262.ImportedFromIB2 + 264.IBPluginDependency + 264.ImportedFromIB2 27.IBPluginDependency 27.ImportedFromIB2 + 270.IBPluginDependency + 271.IBPluginDependency 28.IBPluginDependency 28.ImportedFromIB2 29.IBPluginDependency @@ -2535,8 +2494,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 36.ImportedFromIB2 37.IBPluginDependency 37.ImportedFromIB2 - 38.IBPluginDependency - 38.ImportedFromIB2 39.IBPluginDependency 39.ImportedFromIB2 41.IBPluginDependency @@ -2569,146 +2526,138 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 7.ImportedFromIB2 9.IBPluginDependency 9.ImportedFromIB2 - 92.IBPluginDependency - 92.ImportedFromIB2 YES com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.QTKitIBPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + 3 + MAA + + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - - {{656, 304}, {87, 48}} + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - - {{320, 299}, {484, 557}} + + {{563, 338}, {229, 518}} com.apple.InterfaceBuilder.CocoaPlugin - - {{320, 299}, {484, 557}} - + + {{563, 338}, {229, 518}} + {{221, 276}, {533, 580}} - - + + {3.40282e+38, 3.40282e+38} - {453, 558} - com.apple.InterfaceBuilder.CocoaPlugin - + {230, 500} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + @@ -2731,7 +2680,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA - 243 + 273 @@ -2759,12 +2708,9 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA YES SettingsChanged: - createMoviePreview: deblockSliderChanged: - pictureSliderChanged: - previewDurationPopUpChanged: - showMoviePreview: showPictureWindow: + showPreviewWindow: YES @@ -2772,18 +2718,13 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA id id id - id - NSString - id YES YES - delegate fAnamorphicPopUp - fCreatePreviewMovieButton fCropBottomField fCropBottomStepper fCropLeftField @@ -2803,27 +2744,19 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA fHeightField fHeightStepper fInfoField - fMovieCreationProgressIndicator - fMovieView fPictureCropBox fPictureFilterBox fPictureSizeBox fPictureSlider - fPictureView - fPictureViewArea fPictureWindow - fPreviewMovieLengthPopUp - fPreviewMovieStatusField + fPreviewOpenButton fRatioCheck - fShowPreviewMovieButton fWidthField fWidthStepper YES - id NSPopUpButton - NSButton NSTextField NSStepper NSTextField @@ -2843,17 +2776,11 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA NSTextField NSStepper NSTextField - NSProgressIndicator - QTMovieView NSBox NSBox NSBox NSSlider - NSImageView - NSBox NSWindow - NSPopUpButton - NSTextField NSButton NSButton NSTextField diff --git a/macosx/HBPreviewController.h b/macosx/HBPreviewController.h new file mode 100644 index 000000000..21e262bc2 --- /dev/null +++ b/macosx/HBPreviewController.h @@ -0,0 +1,99 @@ +/* $Id: HBPreviewController.h,v 1.6 2005/04/14 20:40:05 titer Exp $ + + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ + +#import + +#include "hb.h" +/* Needed for Quicktime movie previews */ +#import + +@class HBController; + +#define HB_NUM_HBLIB_PICTURES 20 // # of preview pictures libhb should generate + +@interface PreviewController : NSWindowController +{ + hb_handle_t * fHandle; + hb_title_t * fTitle; + + HBController *fHBController; // reference to HBController + + IBOutlet NSWindow * fPreviewWindow; + NSWindow * fFullScreenWindow; // Full Screen window + NSMutableDictionary * fPicturePreviews; // NSImages, one for each preview libhb creates, created lazily + int fPicture; + + IBOutlet NSImageView * fPictureView; + IBOutlet NSBox * fPictureViewArea; + IBOutlet NSBox * fPictureControlBox; + IBOutlet NSBox * fEncodingControlBox; + + IBOutlet NSSlider * fPictureSlider; + IBOutlet NSTextField * fInfoField; + + BOOL isEncoding; + + + int MaxOutputWidth; + int MaxOutputHeight; + + int output_width, output_height, output_par_width, output_par_height; + int display_width; + + /* Full Screen Mode Toggle */ + IBOutlet NSButton * fFullScreenToggleButton; + IBOutlet NSButton * fPictureSettingsToggleButton; + BOOL isFullScreen; + /* Movie Previews */ + IBOutlet NSButton * fCreatePreviewMovieButton; + IBOutlet NSButton * fCancelPreviewMovieButton; + IBOutlet NSButton * fShowPreviewMovieButton; + NSString * fPreviewMoviePath; + IBOutlet NSProgressIndicator * fMovieCreationProgressIndicator; + hb_handle_t * fPreviewLibhb; // private libhb for creating previews + NSTimer * fLibhbTimer; // timer for retrieving state from libhb + IBOutlet NSTextField * fPreviewMovieStatusField; + BOOL play_movie; // flag used to determine whether or not to automatically play the movie when done. + IBOutlet QTMovieView * fMovieView; + IBOutlet NSPopUpButton * fPreviewMovieLengthPopUp; // popup of choices for length of preview in seconds +} +- (id)init; + +- (void) SetHandle: (hb_handle_t *) handle; +- (void) SetTitle: (hb_title_t *) title; +- (void)setHBController: (HBController *)controller; +- (IBAction) showPreviewWindow: (id)sender; +- (BOOL)acceptsMouseMovedEvents; +- (void) displayPreview; +- (void) showHideHudControls; +- (IBAction) SettingsChanged: (id) sender; +- (IBAction) pictureSliderChanged: (id) sender; +- (IBAction)showPictureSettings:(id)sender; +/* Full Screen */ +- (IBAction)toggleScreenMode:(id)sender; +- (IBAction)goFullScreen:(id)sender; +- (IBAction)goWindowedScreen:(id)sender; + +/* Movie Previews */ +- (void) startReceivingLibhbNotifications; +- (void) stopReceivingLibhbNotifications; + +- (IBAction) createMoviePreview: (id) sender; +- (void) libhbStateChanged: (hb_state_t &) state; +- (IBAction) showMoviePreview: (NSString *) path; +- (IBAction) previewDurationPopUpChanged: (id) sender; + + +- (IBAction)showPreviewPanel: (id)sender forTitle: (hb_title_t *)title; + ++ (NSImage *) makeImageForPicture: (int)pictureIndex + libhb:(hb_handle_t*)handle + title:(hb_title_t*)title + removeBorders:(BOOL)removeBorders; +- (NSImage *) imageForPicture: (int) pictureIndex; +- (void) purgeImageCache; +@end + diff --git a/macosx/HBPreviewController.mm b/macosx/HBPreviewController.mm new file mode 100644 index 000000000..d2d5dae97 --- /dev/null +++ b/macosx/HBPreviewController.mm @@ -0,0 +1,1148 @@ +/* $Id: HBPreviewController.mm,v 1.11 2005/08/01 15:10:44 titer Exp $ + + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ + +#import "HBPreviewController.h" +#import "Controller.h" +//#import "PictureController.h" + +@interface PreviewController (Private) + +- (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize; +- (void)resizeSheetForViewSize: (NSSize)viewSize; +- (void)setViewSize: (NSSize)viewSize; +- (BOOL)viewNeedsToResizeToSize: (NSSize)newSize; + +@end + +@implementation PreviewController + +- (id)init +{ + if (self = [super initWithWindowNibName:@"PicturePreview"]) + { + // NSWindowController likes to lazily load its window. However since + // this controller tries to set all sorts of outlets before the window + // is displayed, we need it to load immediately. The correct way to do + // this, according to the documentation, is simply to invoke the window + // getter once. + // + // If/when we switch a lot of this stuff to bindings, this can probably + // go away. + [self window]; + + fPicturePreviews = [[NSMutableDictionary dictionaryWithCapacity: HB_NUM_HBLIB_PICTURES] retain]; + /* Init libhb with check for updates libhb style set to "0" so its ignored and lets sparkle take care of it */ + int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue]; + fPreviewLibhb = hb_init(loggingLevel, 0); + + } + return self; +} + + +- (void) mouseMoved:(NSEvent *)theEvent +{ + [super mouseMoved:theEvent]; + + [self showHideHudControls]; +} + + +- (void) showHideHudControls +{ + /* Test for mouse location to show/hide hud controls */ + NSPoint mouseLoc; + NSRect targetFrame; + if (isFullScreen) + { + mouseLoc = [fFullScreenWindow mouseLocationOutsideOfEventStream]; + } + else + { + mouseLoc = [fPreviewWindow mouseLocationOutsideOfEventStream]; + } + targetFrame = [fPictureViewArea frame]; + /* If we are not encoding a preview, we show/hide the hud controls */ + if (isEncoding == NO) + { + if (NSPointInRect (mouseLoc, targetFrame)) + { + /* Mouse is over the preview area so show hud controls */ + [[fPictureControlBox animator] setHidden: NO]; + } + else + { + [[fPictureControlBox animator] setHidden: YES]; + } + } +} + + + +//------------------------------------------------------------------------------------ +// Displays and brings the picture window to the front +//------------------------------------------------------------------------------------ +- (IBAction) showPreviewWindow: (id)sender +{ + [self showWindow:sender]; + /* lets set the preview window to accept mouse moved events */ + [fPreviewWindow setAcceptsMouseMovedEvents:YES]; + [self pictureSliderChanged:nil]; + [self startReceivingLibhbNotifications]; +} + +- (void)setHBController: (HBController *)controller +{ + fHBController = controller; +} + +- (void)awakeFromNib +{ + [fPreviewWindow setDelegate:self]; + /* lets set the preview window to accept mouse moved events */ + [fPreviewWindow setAcceptsMouseMovedEvents:YES]; + //[self pictureSliderChanged:nil]; + [self startReceivingLibhbNotifications]; + + isFullScreen = NO; + + /* Setup our layers for core animation */ + [fPictureViewArea setWantsLayer:YES]; + [fPictureView setWantsLayer:YES]; + + [fMovieView setWantsLayer:YES]; + + [fEncodingControlBox setWantsLayer:YES]; + [fCancelPreviewMovieButton setWantsLayer:YES]; + [fMovieCreationProgressIndicator setWantsLayer:YES]; + + [fPictureControlBox setWantsLayer:YES]; + [fPictureSlider setWantsLayer:YES]; + [fFullScreenToggleButton setWantsLayer:YES]; + [fPictureSettingsToggleButton setWantsLayer:YES]; + [fCreatePreviewMovieButton setWantsLayer:YES]; + [fShowPreviewMovieButton setWantsLayer:YES]; + + +} +- (BOOL)acceptsMouseMovedEvents +{ +return YES; +} + +- (void)windowWillClose:(NSNotification *)aNotification +{ + /* Upon Closing the picture window, we make sure we clean up any + * preview movie that might be playing + */ + play_movie = NO; + hb_stop( fPreviewLibhb ); + isEncoding = NO; + // Show the picture view + [fPictureView setHidden:NO]; + [fMovieView pause:nil]; + [fMovieView setHidden:YES]; + if (isFullScreen) + { + [self goWindowedScreen:nil]; + } + + isFullScreen = NO; + +} + +- (BOOL)windowShouldClose:(id)fPictureWindow +{ + return YES; +} + +- (void) dealloc +{ + hb_stop(fPreviewLibhb); + if (fPreviewMoviePath) + { + [[NSFileManager defaultManager] removeFileAtPath:fPreviewMoviePath handler:nil]; + [fPreviewMoviePath release]; + } + + [fLibhbTimer invalidate]; + [fLibhbTimer release]; + + [fPicturePreviews release]; + [fFullScreenWindow release]; + + [super dealloc]; +} + +- (void) SetHandle: (hb_handle_t *) handle +{ + fHandle = handle; + + + + /* we set the preview length popup in seconds */ + [fPreviewMovieLengthPopUp removeAllItems]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"5"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"10"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"15"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"20"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"25"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"30"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"35"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"40"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"45"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"50"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"55"]; + [fPreviewMovieLengthPopUp addItemWithTitle: @"60"]; + + /* adjust the preview slider length */ + /* We use our advance pref to determine how many previews we scanned */ + int hb_num_previews = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue]; + [fPictureSlider setMaxValue: hb_num_previews - 1.0]; + [fPictureSlider setNumberOfTickMarks: hb_num_previews]; + + if ([[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewLength"]) + { + [fPreviewMovieLengthPopUp selectItemWithTitle:[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewLength"]]; + } + else + { + /* currently hard set default to 10 seconds */ + [fPreviewMovieLengthPopUp selectItemAtIndex: 1]; + } +} + +- (void) SetTitle: (hb_title_t *) title +{ + hb_job_t * job = title->job; + + fTitle = title; +fPicture = 0; +MaxOutputWidth = title->width - job->crop[2] - job->crop[3]; + MaxOutputHeight = title->height - job->crop[0] - job->crop[1]; + [self SettingsChanged: nil]; +} + + + +// Adjusts the window to draw the current picture (fPicture) adjusting its size as +// necessary to display as much of the picture as possible. +- (void) displayPreview +{ + hb_job_t * job = fTitle->job; + /* lets make sure that the still picture view is not hidden and that + * the movie preview is + */ + [fMovieView pause:nil]; + [fMovieView setHidden:YES]; + [fMovieCreationProgressIndicator stopAnimation: nil]; + [fMovieCreationProgressIndicator setHidden: YES]; + + [fPictureView setHidden:NO]; + + [fPictureView setImage: [self imageForPicture: fPicture]]; + + NSSize displaySize = NSMakeSize( ( CGFloat )fTitle->width, ( CGFloat )fTitle->height ); + /* Set the picture size display fields below the Preview Picture*/ + if( fTitle->job->pixel_ratio == 1 ) // Original PAR Implementation + { + output_width = fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]; + output_height = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]; + display_width = output_width * fTitle->job->pixel_aspect_width / fTitle->job->pixel_aspect_height; + [fInfoField setStringValue:[NSString stringWithFormat: + @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d", + fTitle->width, fTitle->height, output_width, output_height, display_width, output_height]]; + displaySize.width *= ( ( CGFloat )fTitle->job->pixel_aspect_width ) / ( ( CGFloat )fTitle->job->pixel_aspect_height ); + } + else if (fTitle->job->pixel_ratio == 2) // Loose Anamorphic + { + hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height); + display_width = output_width * output_par_width / output_par_height; + [fInfoField setStringValue:[NSString stringWithFormat: + @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d", + fTitle->width, fTitle->height, output_width, output_height, display_width, output_height]]; + + displaySize.width = display_width; + } + else // No Anamorphic + { + [fInfoField setStringValue: [NSString stringWithFormat: + @"Source: %dx%d, Output: %dx%d", fTitle->width, fTitle->height, + fTitle->job->width, fTitle->job->height]]; + } + + NSSize viewSize = [self optimalViewSizeForImageSize:displaySize]; + if( [self viewNeedsToResizeToSize:viewSize] ) + { + /* In the case of loose anamorphic, do not resize the window when scaling down */ + // FIX ME: we need a new way to do this as we do not havefWidthField anymore + //if (fTitle->job->pixel_ratio != 2 || [fWidthField intValue] == fTitle->width) + if (fTitle->job->pixel_ratio != 2 || (fTitle->job->pixel_ratio == 2 && output_width == fTitle->width)) + { + [self resizeSheetForViewSize:viewSize]; + [self setViewSize:viewSize]; + } + } + + // Show the scaled text (use the height to check since the width can vary + // with anamorphic video). + if( ( ( int )viewSize.height ) != fTitle->height ) + { + CGFloat scale = viewSize.width / ( ( CGFloat ) fTitle->width ); + NSString *scaleString = [NSString stringWithFormat: + NSLocalizedString( @" (Preview scaled to %.0f%% actual size)", + @"String shown when a preview is scaled" ), + scale * 100.0]; + [fInfoField setStringValue: [[fInfoField stringValue] stringByAppendingString:scaleString]]; + } + +} + +- (IBAction) previewDurationPopUpChanged: (id) sender +{ + +[[NSUserDefaults standardUserDefaults] setObject:[fPreviewMovieLengthPopUp titleOfSelectedItem] forKey:@"PreviewLength"]; + +} + + + + + +- (IBAction) SettingsChanged: (id) sender +{ + // Purge the existing picture previews so they get recreated the next time + // they are needed. + [self purgeImageCache]; + /* We actually call displayPreview now from pictureSliderChanged which keeps + * our picture preview slider in sync with the previews being shown + */ + //[self displayPreview]; + [self pictureSliderChanged:nil]; +} + +- (IBAction) pictureSliderChanged: (id) sender +{ + // Show the picture view + [fPictureView setHidden:NO]; + [fMovieView pause:nil]; + [fMovieView setHidden:YES]; + [fEncodingControlBox setHidden: YES]; + + int newPicture = [fPictureSlider intValue]; + if (newPicture != fPicture) + { + fPicture = newPicture; + } + [self displayPreview]; + +} + +- (IBAction)showPreviewPanel: (id)sender forTitle: (hb_title_t *)title +{ + [self SetTitle:title]; + [self showWindow:sender]; + isFullScreen = NO; + +} + +- (IBAction)showPictureSettings:(id)sender +{ +[fHBController showPicturePanel:self]; +} + + +#pragma mark Cocoa For Fullscreen Mode + +- (IBAction)toggleScreenMode:(id)sender +{ + if (!isFullScreen) + { + [self goFullScreen:nil]; + } + else + { + [self goWindowedScreen:nil]; + } +} + +- (IBAction)goFullScreen:(id)sender +{ + // Get the screen information. + NSScreen* mainScreen = [NSScreen mainScreen]; + NSDictionary* screenInfo = [mainScreen deviceDescription]; + NSNumber* screenID = [screenInfo objectForKey:@"NSScreenNumber"]; + // Capture the screen. + CGDirectDisplayID displayID = (CGDirectDisplayID)[screenID longValue]; + CGDisplayErr err = CGDisplayCapture(displayID); + + if (err == CGDisplayNoErr) + { + + // Create the full-screen window. + NSRect winRect = [fPreviewWindow frame]; + fFullScreenWindow = [[NSWindow alloc] initWithContentRect:winRect + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered + defer:NO + screen:[NSScreen mainScreen]]; + + // Establish the window attributes. + [fFullScreenWindow setReleasedWhenClosed:NO]; + [fFullScreenWindow setDisplaysWhenScreenProfileChanges:YES]; + [fFullScreenWindow setDelegate:self]; + + /* insert a view into the new window */ + [fFullScreenWindow setContentView:fPictureViewArea]; + [fPictureViewArea setNeedsDisplay:YES]; + + // Center the window + + /* Better to center the window using the screen's frame + * and the windows origin. Note that we should take into + * account the auto sizing and alignment that occurs in + * setViewSize each time the preview changes. + */ + + NSSize screenSize = [[NSScreen mainScreen] frame].size; + NSSize windowSize = [fFullScreenWindow frame].size; + NSPoint windowOrigin = [fFullScreenWindow frame].origin; + + /* Adjust our origin y (vertical) based on the screen height */ + windowOrigin.y = (screenSize.height - windowSize.height) / 2.0; + windowOrigin.x = (screenSize.width - windowSize.width) / 2.0; + + [fFullScreenWindow setFrameOrigin:windowOrigin]; + + /* Using the simple center method for NSWindow + * though note this will cause the window to be slightly + * higher than center + */ + //[fFullScreenWindow center]; + + /* lets kill the timer for now */ + [self stopReceivingLibhbNotifications]; + + /* We need to retain the fPreviewWindow */ + [fPreviewWindow retain]; + + [self setWindow:fFullScreenWindow]; + + // The window has to be above the level of the shield window. + int32_t shieldLevel = CGShieldingWindowLevel(); + + [fFullScreenWindow setLevel:shieldLevel]; + + // Show the window. + [fFullScreenWindow makeKeyAndOrderFront:self]; + + [fPreviewWindow setAcceptsMouseMovedEvents:NO]; + [fFullScreenWindow setAcceptsMouseMovedEvents:YES]; + + /* Change the name of fFullScreenToggleButton appropriately */ + [fFullScreenToggleButton setTitle: @"Windowed"]; + + /* Lets fire the timer back up for the hud controls, etc. */ + [self startReceivingLibhbNotifications]; + + isFullScreen = YES; + + /* make sure we are set to a still preview */ + [self pictureSliderChanged:nil]; + + /* set the picture settings pallete above the shielding level */ + [fHBController picturePanelFullScreen]; + } +} + +- (IBAction)goWindowedScreen:(id)sender +{ + + /* Get the screen info to release the display but don't actually do + * it until the windowed screen is setup. + */ + NSScreen* mainScreen = [NSScreen mainScreen]; + NSDictionary* screenInfo = [mainScreen deviceDescription]; + NSNumber* screenID = [screenInfo objectForKey:@"NSScreenNumber"]; + CGDirectDisplayID displayID = (CGDirectDisplayID)[screenID longValue]; + + [fFullScreenWindow setAcceptsMouseMovedEvents:NO]; + [fFullScreenWindow dealloc]; + [fFullScreenWindow release]; + + + [fPreviewWindow setContentView:fPictureViewArea]; + [fPictureViewArea setNeedsDisplay:YES]; + [self setWindow:fPreviewWindow]; + + // Show the window. + [fPreviewWindow makeKeyAndOrderFront:self]; + + /* Set the window back to regular level */ + [fPreviewWindow setLevel:NSNormalWindowLevel]; + + [fPreviewWindow setAcceptsMouseMovedEvents:YES]; + + + /* Set the isFullScreen flag back to NO */ + isFullScreen = NO; + [self showPreviewWindow:nil]; + + /* Change the name of fFullScreenToggleButton appropriately */ + [fFullScreenToggleButton setTitle: @"Full Screen"]; + + /* set the picture settings pallete back to normal level */ + [fHBController picturePanelFullScreen]; + + /* Release the display now that the we are back in windowed mode */ + CGDisplayRelease(displayID); + +} + + +#pragma mark Still Preview Image Processing + + +// This function converts an image created by libhb (specified via pictureIndex) into +// an NSImage suitable for the GUI code to use. If removeBorders is YES, +// makeImageForPicture crops the image generated by libhb stripping off the gray +// border around the content. This is the low-level method that generates the image. +// -imageForPicture calls this function whenever it can't find an image in its cache. ++ (NSImage *) makeImageForPicture: (int)pictureIndex + libhb:(hb_handle_t*)handle + title:(hb_title_t*)title + removeBorders:(BOOL)removeBorders +{ + if (removeBorders) + { + // |<---------- title->width ----------->| + // | |<---- title->job->width ---->| | + // | | | | + // ....................................... + // ....+-----------------------------+.... + // ....| |....<-- gray border + // ....| |.... + // ....| |.... + // ....| |<------- image + // ....| |.... + // ....| |.... + // ....| |.... + // ....| |.... + // ....| |.... + // ....+-----------------------------+.... + // ....................................... + + static uint8_t * buffer; + static int bufferSize; + + // Make sure we have a big enough buffer to receive the image from libhb. libhb + // creates images with a one-pixel border around the original content. Hence we + // add 2 pixels horizontally and vertically to the buffer size. + int srcWidth = title->width + 2; + int srcHeight= title->height + 2; + int newSize; + newSize = srcWidth * srcHeight * 4; + if( bufferSize < newSize ) + { + bufferSize = newSize; + buffer = (uint8_t *) realloc( buffer, bufferSize ); + } + + hb_get_preview( handle, title, pictureIndex, buffer ); + + // Create an NSBitmapImageRep and copy the libhb image into it, converting it from + // libhb's format to one suitable for NSImage. Along the way, we'll strip off the + // border around libhb's image. + + // The image data returned by hb_get_preview is 4 bytes per pixel, BGRA format. + // Alpha is ignored. + + int dstWidth = title->job->width; + int dstHeight = title->job->height; + NSBitmapFormat bitmapFormat = (NSBitmapFormat)NSAlphaFirstBitmapFormat; + NSBitmapImageRep * imgrep = [[[NSBitmapImageRep alloc] + initWithBitmapDataPlanes:nil + pixelsWide:dstWidth + pixelsHigh:dstHeight + bitsPerSample:8 + samplesPerPixel:3 // ignore alpha + hasAlpha:NO + isPlanar:NO + colorSpaceName:NSCalibratedRGBColorSpace + bitmapFormat:bitmapFormat + bytesPerRow:dstWidth * 4 + bitsPerPixel:32] autorelease]; + + int borderTop = (srcHeight - dstHeight) / 2; + int borderLeft = (srcWidth - dstWidth) / 2; + + UInt32 * src = (UInt32 *)buffer; + UInt32 * dst = (UInt32 *)[imgrep bitmapData]; + src += borderTop * srcWidth; // skip top rows in src to get to first row of dst + src += borderLeft; // skip left pixels in src to get to first pixel of dst + for (int r = 0; r < dstHeight; r++) + { + for (int c = 0; c < dstWidth; c++) +#if TARGET_RT_LITTLE_ENDIAN + *dst++ = Endian32_Swap(*src++); +#else + *dst++ = *src++; +#endif + src += (srcWidth - dstWidth); // skip to next row in src + } + + NSImage * img = [[[NSImage alloc] initWithSize: NSMakeSize(dstWidth, dstHeight)] autorelease]; + [img addRepresentation:imgrep]; + + return img; + } + else + { + // Make sure we have big enough buffer + static uint8_t * buffer; + static int bufferSize; + + int newSize; + newSize = ( title->width + 2 ) * (title->height + 2 ) * 4; + if( bufferSize < newSize ) + { + bufferSize = newSize; + buffer = (uint8_t *) realloc( buffer, bufferSize ); + } + + hb_get_preview( handle, title, pictureIndex, buffer ); + + // The image data returned by hb_get_preview is 4 bytes per pixel, BGRA format. + // We'll copy that into an NSImage swapping it to ARGB in the process. Alpha is + // ignored. + int width = title->width + 2; // hblib adds a one-pixel border to the image + int height = title->height + 2; + int numPixels = width * height; + NSBitmapFormat bitmapFormat = (NSBitmapFormat)NSAlphaFirstBitmapFormat; + NSBitmapImageRep * imgrep = [[[NSBitmapImageRep alloc] + initWithBitmapDataPlanes:nil + pixelsWide:width + pixelsHigh:height + bitsPerSample:8 + samplesPerPixel:3 // ignore alpha + hasAlpha:NO + isPlanar:NO + colorSpaceName:NSCalibratedRGBColorSpace + bitmapFormat:bitmapFormat + bytesPerRow:width * 4 + bitsPerPixel:32] autorelease]; + + UInt32 * src = (UInt32 *)buffer; + UInt32 * dst = (UInt32 *)[imgrep bitmapData]; + for (int i = 0; i < numPixels; i++) +#if TARGET_RT_LITTLE_ENDIAN + *dst++ = Endian32_Swap(*src++); +#else + *dst++ = *src++; +#endif + + NSImage * img = [[[NSImage alloc] initWithSize: NSMakeSize(width, height)] autorelease]; + [img addRepresentation:imgrep]; + + return img; + } +} + +// Returns the preview image for the specified index, retrieving it from its internal +// cache or by calling makeImageForPicture if it is not cached. Generally, you should +// use imageForPicture so that images are cached. Calling makeImageForPicture will +// always generate a new copy of the image. +- (NSImage *) imageForPicture: (int) pictureIndex +{ + // The preview for the specified index may not currently exist, so this method + // generates it if necessary. + NSString * key = [NSString stringWithFormat:@"%d", pictureIndex]; + NSImage * theImage = [fPicturePreviews objectForKey:key]; + if (!theImage) + { + theImage = [PreviewController makeImageForPicture:pictureIndex libhb:fHandle title:fTitle removeBorders: NO]; + [fPicturePreviews setObject:theImage forKey:key]; + } + return theImage; +} + +// Purges all images from the cache. The next call to imageForPicture will cause a new +// image to be generated. +- (void) purgeImageCache +{ + [fPicturePreviews removeAllObjects]; +} + + + +#pragma mark Movie Preview +- (IBAction) createMoviePreview: (id) sender +{ + + + /* Lets make sure the still picture previews are showing in case + * there is currently a movie showing */ + [self pictureSliderChanged:nil]; + + /* Rip or Cancel ? */ + hb_state_t s; + hb_get_state2( fPreviewLibhb, &s ); + + if(sender == fCancelPreviewMovieButton && (s.state == HB_STATE_WORKING || s.state == HB_STATE_PAUSED)) + { + + play_movie = NO; + hb_stop( fPreviewLibhb ); + [fPictureView setHidden:NO]; + [fMovieView pause:nil]; + [fMovieView setHidden:YES]; + [fPictureSlider setHidden:NO]; + isEncoding = NO; + + return; + } + + + /* we use controller.mm's prepareJobForPreview to go ahead and set all of our settings + * however, we want to use a temporary destination field of course + * so that we do not put our temp preview in the users chosen + * directory */ + + hb_job_t * job = fTitle->job; + + /* We run our current setting through prepeareJob in Controller.mm + * just as if it were a regular encode */ + + [fHBController prepareJobForPreview]; + + /* Destination file. We set this to our preview directory + * changing the extension appropriately.*/ + if (fTitle->job->mux == HB_MUX_MP4) // MP4 file + { + /* we use .m4v for our mp4 files so that ac3 and chapters in mp4 will play properly */ + fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.m4v"; + } + else if (fTitle->job->mux == HB_MUX_MKV) // MKV file + { + fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.mkv"; + } + else if (fTitle->job->mux == HB_MUX_AVI) // AVI file + { + fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.avi"; + } + else if (fTitle->job->mux == HB_MUX_OGM) // OGM file + { + fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.ogm"; + } + + fPreviewMoviePath = [[fPreviewMoviePath stringByExpandingTildeInPath]retain]; + + /* See if there is an existing preview file, if so, delete it */ + if( ![[NSFileManager defaultManager] fileExistsAtPath:fPreviewMoviePath] ) + { + [[NSFileManager defaultManager] removeFileAtPath:fPreviewMoviePath + handler:nil]; + } + + /* We now direct our preview encode to fPreviewMoviePath */ + fTitle->job->file = [fPreviewMoviePath UTF8String]; + + /* We use our advance pref to determine how many previews to scan */ + int hb_num_previews = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue]; + job->start_at_preview = fPicture + 1; + job->seek_points = hb_num_previews; + + /* we use the preview duration popup to get the specified + * number of seconds for the preview encode. + */ + + job->pts_to_stop = [[fPreviewMovieLengthPopUp titleOfSelectedItem] intValue] * 90000LL; + + /* lets go ahead and send it off to libhb + * Note: unlike a full encode, we only send 1 pass regardless if the final encode calls for 2 passes. + * this should suffice for a fairly accurate short preview and cuts our preview generation time in half. + */ + hb_add( fPreviewLibhb, job ); + + [fEncodingControlBox setHidden: NO]; + [fPictureControlBox setHidden: YES]; + + [fMovieCreationProgressIndicator setHidden: NO]; + [fPreviewMovieStatusField setHidden: NO]; + + isEncoding = YES; + + play_movie = YES; + + /* Let fPreviewLibhb do the job */ + hb_start( fPreviewLibhb ); + +} + +- (void) startReceivingLibhbNotifications +{ + if (!fLibhbTimer) + { + fLibhbTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(libhbTimerFired:) userInfo:nil repeats:YES]; + [fLibhbTimer retain]; + } +} + +- (void) stopReceivingLibhbNotifications +{ + if (fLibhbTimer) + { + [fLibhbTimer invalidate]; + [fLibhbTimer release]; + fLibhbTimer = nil; + } +} +- (void) libhbTimerFired: (NSTimer*)theTimer +{ + hb_state_t s; + hb_get_state( fPreviewLibhb, &s ); + [self libhbStateChanged: s]; + +} + +- (void) libhbStateChanged: (hb_state_t &)state +{ + switch( state.state ) + { + case HB_STATE_IDLE: + case HB_STATE_SCANNING: + case HB_STATE_SCANDONE: + break; + + case HB_STATE_WORKING: + { +#define p state.param.working + + NSMutableString * string; + /* Update text field */ + string = [NSMutableString stringWithFormat: NSLocalizedString( @"Encoding preview: %.2f %%", @"" ), 100.0 * p.progress]; + + if( p.seconds > -1 ) + { + [string appendFormat: + NSLocalizedString( @" (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)", @"" ), + p.rate_cur, p.rate_avg, p.hours, p.minutes, p.seconds]; + } + [fPreviewMovieStatusField setStringValue: string]; + + [fMovieCreationProgressIndicator setIndeterminate: NO]; + /* Update slider */ + [fMovieCreationProgressIndicator setDoubleValue: 100.0 * p.progress]; + + [fCreatePreviewMovieButton setTitle: @"Cancel Preview"]; + + break; + + } +#undef p + +#define p state.param.muxing + case HB_STATE_MUXING: + { + // Update fMovieCreationProgressIndicator + [fMovieCreationProgressIndicator setIndeterminate: YES]; + [fMovieCreationProgressIndicator startAnimation: nil]; + [fPreviewMovieStatusField setStringValue: [NSString stringWithFormat: + NSLocalizedString( @"Muxing Preview ...", @"" )]]; + break; + } +#undef p + case HB_STATE_PAUSED: + [fMovieCreationProgressIndicator stopAnimation: nil]; + break; + + case HB_STATE_WORKDONE: + { + // Delete all remaining jobs since libhb doesn't do this on its own. + hb_job_t * job; + while( ( job = hb_job(fPreviewLibhb, 0) ) ) + hb_rem( fHandle, job ); + + [fPreviewMovieStatusField setStringValue: @""]; + [fPreviewMovieStatusField setHidden: YES]; + + [fMovieCreationProgressIndicator stopAnimation: nil]; + [fMovieCreationProgressIndicator setHidden: YES]; + [fEncodingControlBox setHidden: YES]; + isEncoding = NO; + /* we make sure the picture slider and preview match */ + [self pictureSliderChanged:nil]; + + + // Show the movie view + if (play_movie) + { + [self showMoviePreview:fPreviewMoviePath]; + } + + [fCreatePreviewMovieButton setTitle: @"Live Preview"]; + + + break; + } + } + +} + +- (IBAction) showMoviePreview: (NSString *) path +{ + /* Since the gray background for the still images is part of + * fPictureView, lets leave the picture view visible and postion + * the fMovieView over the image portion of fPictureView so + * we retain the gray cropping border we have already established + * with the still previews + */ + [fMovieView setHidden:NO]; + + /* Load the new movie into fMovieView */ + QTMovie * aMovie; + NSRect movieBounds; + if (path) + { + [fMovieView setControllerVisible: YES]; + /* let's make sure there is no movie currently set */ + [fMovieView setMovie:nil]; + + aMovie = [QTMovie movieWithFile:path error:nil]; + + /* we get some size information from the preview movie */ + Rect movieBox; + GetMovieBox ([aMovie quickTimeMovie], &movieBox); + movieBounds = [fMovieView movieBounds]; + movieBounds.size.height = movieBox.bottom - movieBox.top; + + if ([fMovieView isControllerVisible]) + movieBounds.size.height += [fMovieView controllerBarHeight]; + /* since for whatever the reason I cannot seem to get the [fMovieView controllerBarHeight] + * For now just use 15 for additional height as it seems to line up well + */ + movieBounds.size.height += 15; + + movieBounds.size.width = movieBox.right - movieBox.left; + + /* We need to find out if the preview movie needs to be scaled down so + * that it doesn't overflow our available viewing container (just like for image + * in -displayPreview) for HD sources, etc. [fPictureViewArea frame].size.height*/ + if( ((int)movieBounds.size.height) > [fPictureView frame].size.height ) + { + /* The preview movie would be larger than the available viewing area + * in the preview movie, so we go ahead and scale it down to the same size + * as the still preview or we readjust our window to allow for the added height if need be + */ + NSSize displaySize = NSMakeSize( (float)movieBounds.size.width, (float)movieBounds.size.height ); + //NSSize displaySize = NSMakeSize( (float)fTitle->width, (float)fTitle->height ); + NSSize viewSize = [self optimalViewSizeForImageSize:displaySize]; + if( [self viewNeedsToResizeToSize:viewSize] ) + { + + [self resizeSheetForViewSize:viewSize]; + [self setViewSize:viewSize]; + + } + + [fMovieView setFrameSize:viewSize]; + } + else + { + /* Since the preview movie is smaller than the available viewing area + * we can go ahead and use the preview movies native size */ + [fMovieView setFrameSize:movieBounds.size]; + } + + // lets reposition the movie if need be + + NSPoint origin = [fPictureViewArea frame].origin; + origin.x += trunc(([fPictureViewArea frame].size.width - + [fMovieView frame].size.width) / 2.0); + /* We need to detect whether or not we are currently less than the available height.*/ + if (movieBounds.size.height < [fPictureView frame].size.height) + { + /* If we are, we are adding 15 to the height to allow for the controller bar so + * we need to subtract half of that for the origin.y to get the controller bar + * below the movie to it lines up vertically with where our still preview was + */ + origin.y += trunc((([fPictureViewArea frame].size.height - + [fMovieView frame].size.height) / 2.0) - 7.5); + } + else + { + /* if we are >= to the height of the picture view area, the controller bar + * gets taken care of with picture resizing, so we do not want to offset the height + */ + origin.y += trunc(([fPictureViewArea frame].size.height - + [fMovieView frame].size.height) / 2.0); + } + [fMovieView setFrameOrigin:origin]; + + [fMovieView setMovie:aMovie]; + /// to actually play the movie + [fMovieView play:aMovie]; + } + else + { + aMovie = nil; + } + isEncoding = NO; +} + + +@end + +@implementation PreviewController (Private) + +// +// -[PictureController(Private) optimalViewSizeForImageSize:] +// +// Given the size of the preview image to be shown, returns the best possible +// size for the view. +// +- (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize +{ + // The min size is 320x240 + CGFloat minWidth = 480.0; + CGFloat minHeight = 360.0; + + NSSize screenSize = [[NSScreen mainScreen] frame].size; + NSSize sheetSize = [[self window] frame].size; + NSSize viewAreaSize = [fPictureViewArea frame].size; + CGFloat paddingX = sheetSize.width - viewAreaSize.width; + CGFloat paddingY = sheetSize.height - viewAreaSize.height; + CGFloat maxWidth; + CGFloat maxHeight; + + if (isFullScreen) + { + /* We are in full screen mode so lets use the full screen if we need to */ + maxWidth = screenSize.width - paddingX; + maxHeight = screenSize.height - paddingY; + } + else + { + // The max size of the view is when the sheet is taking up 85% of the screen. + maxWidth = (0.85 * screenSize.width) - paddingX; + maxHeight = (0.85 * screenSize.height) - paddingY; + } + + NSSize resultSize = imageSize; + + // Its better to have a view that's too small than a view that's too big, so + // apply the maximum constraints last. + if( resultSize.width < minWidth ) + { + resultSize.height *= (minWidth / resultSize.width); + resultSize.width = minWidth; + } + if( resultSize.height < minHeight ) + { + resultSize.width *= (minHeight / resultSize.height); + resultSize.height = minHeight; + } + if( resultSize.width > maxWidth ) + { + resultSize.height *= (maxWidth / resultSize.width); + resultSize.width = maxWidth; + } + if( resultSize.height > maxHeight ) + { + resultSize.width *= (maxHeight / resultSize.height); + resultSize.height = maxHeight; + } + + return resultSize; +} + +// +// -[PictureController(Private) resizePanelForViewSize:animate:] +// +// Resizes the entire sheet to accomodate a view of a particular size. +// +- (void)resizeSheetForViewSize: (NSSize)viewSize +{ + // Figure out the deltas for the new frame area + NSSize currentSize = [fPictureViewArea frame].size; + CGFloat deltaX = viewSize.width - currentSize.width; + CGFloat deltaY = viewSize.height - currentSize.height; + + // Now resize the whole panel by those same deltas, but don't exceed the min + NSRect frame = [[self window] frame]; + NSSize maxSize = [[self window] maxSize]; + NSSize minSize = [[self window] minSize]; + frame.size.width += deltaX; + frame.size.height += deltaY; + if( frame.size.width < minSize.width ) + { + frame.size.width = minSize.width; + } + + if( frame.size.height < minSize.height ) + { + frame.size.height = minSize.height; + } + + + // But now the sheet is off-center, so also shift the origin to center it and + // keep the top aligned. + if( frame.size.width != [[self window] frame].size.width ) + frame.origin.x -= (deltaX / 2.0); + + if (isFullScreen) + { + if( frame.size.height != [[self window] frame].size.height ) + frame.origin.y -= (deltaY / 2.0); + } + else + { + if( frame.size.height != [[self window] frame].size.height ) + frame.origin.y -= deltaY; + } + + [[self window] setFrame:frame display:YES animate:YES]; +} + +// +// -[PictureController(Private) setViewSize:] +// +// Changes the view's size and centers it vertically inside of its area. +// Assumes resizeSheetForViewSize: has already been called. +// +- (void)setViewSize: (NSSize)viewSize +{ + [fPictureView setFrameSize:viewSize]; + + // center it vertically + NSPoint origin = [fPictureViewArea frame].origin; + origin.y += ([fPictureViewArea frame].size.height - + [fPictureView frame].size.height) / 2.0; + [fPictureView setFrameOrigin:origin]; + + NSPoint controlboxorigin = [fPictureView frame].origin; + + /* for now, put the origin.y 100 above the bottom of the fPictureView */ + controlboxorigin.y += 100; + + controlboxorigin.x += ([fPictureViewArea frame].size.width - + [fPictureControlBox frame].size.width) / 2.0; + /* requires that thefPictureControlBox and the fEncodingControlBox + * are the same width to line up. + */ + [fPictureControlBox setFrameOrigin:controlboxorigin]; + [fEncodingControlBox setFrameOrigin:controlboxorigin]; + +} + + +- (BOOL)viewNeedsToResizeToSize: (NSSize)newSize +{ + NSSize viewSize = [fPictureView frame].size; + return (newSize.width != viewSize.width || newSize.height != viewSize.height); +} + +@end diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj index d4ab9eb39..5af76b49b 100644 --- a/macosx/HandBrake.xcodeproj/project.pbxproj +++ b/macosx/HandBrake.xcodeproj/project.pbxproj @@ -73,11 +73,11 @@ 25DE1FB70C169A0C00F01FC8 /* HBPreferencesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 25DE1FB50C169A0C00F01FC8 /* HBPreferencesController.m */; }; 4D1125D809D72FD200E0657B /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D1125D709D72FD200E0657B /* libz.dylib */; }; 4DD93F8F082036E8008E1322 /* Controller.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF3C8CB052889CD00A80101 /* Controller.h */; }; - 4DD93F92082036E8008E1322 /* PictureController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1FD381073D19CE00E46515 /* PictureController.h */; }; + 4DD93F92082036E8008E1322 /* HBPreviewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1FD381073D19CE00E46515 /* HBPreviewController.h */; }; 4DD93F97082036E8008E1322 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 4DD93F9A082036E8008E1322 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.mm */; settings = {ATTRIBUTES = (); }; }; 4DD93F9B082036E8008E1322 /* Controller.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4DF3C8CC052889CD00A80101 /* Controller.mm */; }; - 4DD93F9E082036E8008E1322 /* PictureController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D1FD382073D19CE00E46515 /* PictureController.mm */; }; + 4DD93F9E082036E8008E1322 /* HBPreviewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D1FD382073D19CE00E46515 /* HBPreviewController.mm */; }; 4DD93FA2082036E8008E1322 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; 4DD93FA3082036E8008E1322 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DEB2024052B055F00C39CA9 /* IOKit.framework */; }; 4DD93FA4082036E8008E1322 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DDE9724052B7B2B00C39CA9 /* OpenGL.framework */; }; @@ -95,15 +95,19 @@ A22C85ED0D05D35100C10E36 /* HBPresets.m in Sources */ = {isa = PBXBuildFile; fileRef = A22C85EB0D05D35000C10E36 /* HBPresets.m */; }; A25289E60D87A27D00461D5B /* enctheora.c in Sources */ = {isa = PBXBuildFile; fileRef = A25289E50D87A27D00461D5B /* enctheora.c */; }; A25289E70D87A2CB00461D5B /* enctheora.c in Sources */ = {isa = PBXBuildFile; fileRef = A25289E50D87A27D00461D5B /* enctheora.c */; }; + A25962E10F15077500B3BF4E /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A25962E00F15077500B3BF4E /* Quartz.framework */; }; A273E0510C57B39A00493A45 /* Pause.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A273E04A0C57B39A00493A45 /* Pause.tiff */; }; A273E0520C57B39A00493A45 /* Play.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A273E04B0C57B39A00493A45 /* Play.tiff */; }; A273E0530C57B39A00493A45 /* Stop.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A273E04C0C57B39A00493A45 /* Stop.tiff */; }; A273E09A0C57C1CC00493A45 /* muxmkv.c in Sources */ = {isa = PBXBuildFile; fileRef = A273E0950C57C19500493A45 /* muxmkv.c */; }; A273E09B0C57C1CD00493A45 /* muxmkv.c in Sources */ = {isa = PBXBuildFile; fileRef = A273E0950C57C19500493A45 /* muxmkv.c */; }; + A27BB4EA0EFAB9310027CDF9 /* PicturePreview.xib in Resources */ = {isa = PBXBuildFile; fileRef = A27BB4E80EFAB9310027CDF9 /* PicturePreview.xib */; }; A29E05800BE1283E000533F5 /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A29E057F0BE1283E000533F5 /* Growl.framework */; }; A29E058B0BE12889000533F5 /* Growl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A29E057F0BE1283E000533F5 /* Growl.framework */; }; A2A1EC310C76C35E00827E0D /* HBDVDDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = A2A1EC300C76C35E00827E0D /* HBDVDDetector.h */; }; A2A1EC3A0C76C58400827E0D /* HBDVDDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A1EC390C76C58400827E0D /* HBDVDDetector.m */; }; + A2BF08050EFAB5D400C0E025 /* PictureController.h in Headers */ = {isa = PBXBuildFile; fileRef = A2BF08030EFAB5D400C0E025 /* PictureController.h */; }; + A2BF08060EFAB5D400C0E025 /* PictureController.mm in Sources */ = {isa = PBXBuildFile; fileRef = A2BF08040EFAB5D400C0E025 /* PictureController.mm */; }; A2D0A0AB0D3E5929002D57CB /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2D0A0AA0D3E5929002D57CB /* Sparkle.framework */; }; A2D0A0BF0D3E596F002D57CB /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A2D0A0AA0D3E5929002D57CB /* Sparkle.framework */; }; A2D7AD670C998AD30082CA33 /* ActivityWindow.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A2D7AD5E0C998AD30082CA33 /* ActivityWindow.tiff */; }; @@ -240,8 +244,8 @@ 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 4D1125D709D72FD200E0657B /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = ""; }; - 4D1FD381073D19CE00E46515 /* PictureController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PictureController.h; sourceTree = ""; }; - 4D1FD382073D19CE00E46515 /* PictureController.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = PictureController.mm; sourceTree = ""; }; + 4D1FD381073D19CE00E46515 /* HBPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HBPreviewController.h; sourceTree = ""; }; + 4D1FD382073D19CE00E46515 /* HBPreviewController.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = HBPreviewController.mm; sourceTree = ""; }; 4DDE9724052B7B2B00C39CA9 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = ""; }; 4DEB2024052B055F00C39CA9 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; 4DF3C8CB052889CD00A80101 /* Controller.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Controller.h; sourceTree = ""; }; @@ -260,13 +264,17 @@ A22C85EA0D05D35000C10E36 /* HBPresets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBPresets.h; sourceTree = ""; }; A22C85EB0D05D35000C10E36 /* HBPresets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBPresets.m; sourceTree = ""; }; A25289E50D87A27D00461D5B /* enctheora.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = enctheora.c; path = ../libhb/enctheora.c; sourceTree = SOURCE_ROOT; }; + A25962E00F15077500B3BF4E /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = /System/Library/Frameworks/Quartz.framework; sourceTree = ""; }; A273E04A0C57B39A00493A45 /* Pause.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Pause.tiff; sourceTree = ""; }; A273E04B0C57B39A00493A45 /* Play.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Play.tiff; sourceTree = ""; }; A273E04C0C57B39A00493A45 /* Stop.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Stop.tiff; sourceTree = ""; }; A273E0950C57C19500493A45 /* muxmkv.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = muxmkv.c; path = ../libhb/muxmkv.c; sourceTree = SOURCE_ROOT; }; + A27BB4E90EFAB9310027CDF9 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/PicturePreview.xib; sourceTree = ""; }; A29E057F0BE1283E000533F5 /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Growl.framework; sourceTree = ""; }; A2A1EC300C76C35E00827E0D /* HBDVDDetector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HBDVDDetector.h; sourceTree = ""; }; A2A1EC390C76C58400827E0D /* HBDVDDetector.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = HBDVDDetector.m; sourceTree = ""; }; + A2BF08030EFAB5D400C0E025 /* PictureController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PictureController.h; sourceTree = ""; }; + A2BF08040EFAB5D400C0E025 /* PictureController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PictureController.mm; sourceTree = ""; }; A2D0A0AA0D3E5929002D57CB /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = ""; }; A2D7AD5E0C998AD30082CA33 /* ActivityWindow.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = ActivityWindow.tiff; sourceTree = ""; }; A2D7AD5F0C998AD30082CA33 /* AddToQueue.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = AddToQueue.tiff; sourceTree = ""; }; @@ -356,6 +364,7 @@ A2D0A0AB0D3E5929002D57CB /* Sparkle.framework in Frameworks */, A20F46DC0EBB5E7A005B861B /* QuickTime.framework in Frameworks */, A20F47010EBB5EC2005B861B /* QTKit.framework in Frameworks */, + A25962E10F15077500B3BF4E /* Quartz.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -399,6 +408,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + A27BB4E80EFAB9310027CDF9 /* PicturePreview.xib */, A273E0460C57B39A00493A45 /* icons */, 0DFA5C7A0B8DD1E90020BC09 /* HandBrake.icns */, E39AA4DA0D32DC0B0007A415 /* MainMenu.xib */, @@ -414,6 +424,7 @@ 29B97323FDCFA39411CA2CEA /* Frameworks */ = { isa = PBXGroup; children = ( + A25962E00F15077500B3BF4E /* Quartz.framework */, A20F47000EBB5EC2005B861B /* QTKit.framework */, A20F46DB0EBB5E7A005B861B /* QuickTime.framework */, D289A9F20DBBE7AC00CE614B /* CoreServices.framework */, @@ -487,13 +498,15 @@ 526FBC930B4CAA260064E04C /* HandBrake Sources */ = { isa = PBXGroup; children = ( + A2BF08030EFAB5D400C0E025 /* PictureController.h */, + 4DF3C8CC052889CD00A80101 /* Controller.mm */, + A2BF08040EFAB5D400C0E025 /* PictureController.mm */, A22C85EA0D05D35000C10E36 /* HBPresets.h */, A22C85EB0D05D35000C10E36 /* HBPresets.m */, 0DFA5D060B8DD9040020BC09 /* HandBrake.plist */, - 4D1FD381073D19CE00E46515 /* PictureController.h */, - 4D1FD382073D19CE00E46515 /* PictureController.mm */, + 4D1FD381073D19CE00E46515 /* HBPreviewController.h */, + 4D1FD382073D19CE00E46515 /* HBPreviewController.mm */, 4DF3C8CB052889CD00A80101 /* Controller.h */, - 4DF3C8CC052889CD00A80101 /* Controller.mm */, 593034E90BBA39A100172349 /* ChapterTitles.h */, 593034EA0BBA39A100172349 /* ChapterTitles.m */, A2A1EC300C76C35E00827E0D /* HBDVDDetector.h */, @@ -576,7 +589,7 @@ buildActionMask = 2147483647; files = ( 4DD93F8F082036E8008E1322 /* Controller.h in Headers */, - 4DD93F92082036E8008E1322 /* PictureController.h in Headers */, + 4DD93F92082036E8008E1322 /* HBPreviewController.h in Headers */, A2A1EC310C76C35E00827E0D /* HBDVDDetector.h in Headers */, 253886010BFE0A5B0064E995 /* HBOutputRedirect.h in Headers */, 253886170BFE0C160064E995 /* HBOutputPanelController.h in Headers */, @@ -585,6 +598,7 @@ A9AC41E00C918DB500DDF9B8 /* HBAdvancedController.h in Headers */, E37172680C977D340072B384 /* HBImageAndTextCell.h in Headers */, A22C85EC0D05D35000C10E36 /* HBPresets.h in Headers */, + A2BF08050EFAB5D400C0E025 /* PictureController.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -727,6 +741,7 @@ E39AA4E90D32DC0B0007A415 /* PictureSettings.xib in Resources */, E39AA4EA0D32DC0B0007A415 /* AdvancedView.xib in Resources */, E39AA4EB0D32DC0B0007A415 /* OutputPanel.xib in Resources */, + A27BB4EA0EFAB9310027CDF9 /* PicturePreview.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -841,7 +856,7 @@ 59CBD2650BBB4D1B004A3BE3 /* ChapterTitles.m in Sources */, 4DD93F9A082036E8008E1322 /* main.mm in Sources */, 4DD93F9B082036E8008E1322 /* Controller.mm in Sources */, - 4DD93F9E082036E8008E1322 /* PictureController.mm in Sources */, + 4DD93F9E082036E8008E1322 /* HBPreviewController.mm in Sources */, A2A1EC3A0C76C58400827E0D /* HBDVDDetector.m in Sources */, 253886020BFE0A5B0064E995 /* HBOutputRedirect.m in Sources */, 253886180BFE0C160064E995 /* HBOutputPanelController.m in Sources */, @@ -850,6 +865,7 @@ A9AC41DF0C918DB500DDF9B8 /* HBAdvancedController.m in Sources */, E37172670C977D340072B384 /* HBImageAndTextCell.m in Sources */, A22C85ED0D05D35100C10E36 /* HBPresets.m in Sources */, + A2BF08060EFAB5D400C0E025 /* PictureController.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -877,6 +893,14 @@ name = InfoPlist.strings; sourceTree = ""; }; + A27BB4E80EFAB9310027CDF9 /* PicturePreview.xib */ = { + isa = PBXVariantGroup; + children = ( + A27BB4E90EFAB9310027CDF9 /* English */, + ); + name = PicturePreview.xib; + sourceTree = ""; + }; E39AA4DA0D32DC0B0007A415 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( diff --git a/macosx/PictureController.h b/macosx/PictureController.h index 91f88b9ed..b8af4be59 100644 --- a/macosx/PictureController.h +++ b/macosx/PictureController.h @@ -6,26 +6,26 @@ #import -#include "hb.h" -/* Needed for Quicktime movie previews */ -#import +#include "hb.h" @class HBController; +@class PreviewController; -#define HB_NUM_HBLIB_PICTURES 20 // # of preview pictures libhb should generate + +//#define HB_NUM_HBLIB_PICTURES 20 // # of preview pictures libhb should generate @interface PictureController : NSWindowController { hb_handle_t * fHandle; hb_title_t * fTitle; - HBController *fHBController; // reference to HBController + HBController *fHBController; + PreviewController *fPreviewController; // reference to HBController IBOutlet NSWindow * fPictureWindow; NSMutableDictionary * fPicturePreviews; // NSImages, one for each preview libhb creates, created lazily int fPicture; - IBOutlet NSImageView * fPictureView; - IBOutlet NSBox * fPictureViewArea; + IBOutlet NSBox * fPictureSizeBox; IBOutlet NSBox * fPictureCropBox; IBOutlet NSBox * fPictureFilterBox; @@ -54,12 +54,16 @@ IBOutlet NSSlider * fPictureSlider; IBOutlet NSTextField * fInfoField; + IBOutlet NSButton * fPreviewOpenButton; + int MaxOutputWidth; int MaxOutputHeight; BOOL autoCrop; BOOL allowLooseAnamorphic; + int output_width, output_height, output_par_width, output_par_height; int display_width; + /* used to track the previous state of the keep aspect ratio checkbox when turning anamorphic on, so it can be returned to the previous state when anamorphic is turned @@ -74,19 +78,7 @@ int deblock; } fPictureFilterSettings; - id delegate; - - /* Movie Previews */ - IBOutlet NSButton * fCreatePreviewMovieButton; - IBOutlet NSButton * fShowPreviewMovieButton; - NSString * fPreviewMoviePath; - IBOutlet NSProgressIndicator * fMovieCreationProgressIndicator; - hb_handle_t * fPreviewLibhb; // private libhb for creating previews - NSTimer * fLibhbTimer; // timer for retrieving state from libhb - IBOutlet NSTextField * fPreviewMovieStatusField; - BOOL play_movie; // flag used to determine whether or not to automatically play the movie when done. - IBOutlet QTMovieView * fMovieView; - IBOutlet NSPopUpButton * fPreviewMovieLengthPopUp; // popup of choices for length of preview in seconds + } - (id)init; @@ -94,21 +86,14 @@ - (void) SetTitle: (hb_title_t *) title; - (void)setHBController: (HBController *)controller; - (IBAction) showPictureWindow: (id)sender; +- (IBAction) showPreviewWindow: (id)sender; - (void) setInitialPictureFilters; -- (void) displayPreview; + - (IBAction) SettingsChanged: (id) sender; -- (IBAction) pictureSliderChanged: (id) sender; -/* Movie Previews */ -- (void) startReceivingLibhbNotifications; -- (void) stopReceivingLibhbNotifications; -- (IBAction) createMoviePreview: (id) sender; -- (void) libhbStateChanged: (hb_state_t &) state; -- (IBAction) showMoviePreview: (NSString *) path; -- (IBAction) previewDurationPopUpChanged: (id) sender; - (BOOL) autoCrop; - (void) setAutoCrop: (BOOL) setting; @@ -129,11 +114,10 @@ - (IBAction)showPreviewPanel: (id)sender forTitle: (hb_title_t *)title; -+ (NSImage *) makeImageForPicture: (int)pictureIndex - libhb:(hb_handle_t*)handle - title:(hb_title_t*)title - removeBorders:(BOOL)removeBorders; -- (NSImage *) imageForPicture: (int) pictureIndex; -- (void) purgeImageCache; + +- (void) setToFullScreenMode; +- (void) setToWindowedMode; + + @end diff --git a/macosx/PictureController.mm b/macosx/PictureController.mm index 8d61f562e..df70de657 100644 --- a/macosx/PictureController.mm +++ b/macosx/PictureController.mm @@ -6,15 +6,9 @@ #import "PictureController.h" #import "Controller.h" +#import "HBPreviewController.h" -@interface PictureController (Private) -- (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize; -- (void)resizeSheetForViewSize: (NSSize)viewSize; -- (void)setViewSize: (NSSize)viewSize; -- (BOOL)viewNeedsToResizeToSize: (NSSize)newSize; - -@end @implementation PictureController @@ -32,11 +26,8 @@ // go away. [self window]; - fPicturePreviews = [[NSMutableDictionary dictionaryWithCapacity: HB_NUM_HBLIB_PICTURES] retain]; - /* Init libhb with check for updates libhb style set to "0" so its ignored and lets sparkle take care of it */ - int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue]; - fPreviewLibhb = hb_init(loggingLevel, 0); - } + fPreviewController = [[PreviewController alloc] init]; + } return self; } @@ -48,9 +39,35 @@ [self showWindow:sender]; } +- (IBAction) showPreviewWindow: (id)sender +{ + [fPreviewController showWindow:sender]; +} + +- (void) setToFullScreenMode +{ + [self showWindow:nil]; + int32_t shieldLevel = CGShieldingWindowLevel(); + + [fPictureWindow setLevel:shieldLevel]; + // Show the window. + [fPictureWindow makeKeyAndOrderFront:self]; +} + +- (void) setToWindowedMode +{ + /* Set the window back to regular level */ + + [self showWindow:nil]; + + [[self window] setLevel:NSNormalWindowLevel]; +} + - (void)setHBController: (HBController *)controller { fHBController = controller; + [fPreviewController setHBController: controller]; + } - (void)awakeFromNib @@ -61,12 +78,7 @@ - (void)windowWillClose:(NSNotification *)aNotification { - /* Upon Closing the picture window, we make sure we clean up any - * preview movie that might be playing - */ - play_movie = NO; - hb_stop( fPreviewLibhb ); - [self pictureSliderChanged:nil]; + } - (BOOL)windowShouldClose:(id)fPictureWindow @@ -76,17 +88,7 @@ - (void) dealloc { - hb_stop(fPreviewLibhb); - if (fPreviewMoviePath) - { - [[NSFileManager defaultManager] removeFileAtPath:fPreviewMoviePath handler:nil]; - [fPreviewMoviePath release]; - } - - [fLibhbTimer invalidate]; - [fLibhbTimer release]; - - [fPicturePreviews release]; + [fPreviewController release]; [super dealloc]; } @@ -110,36 +112,9 @@ [fCropRightStepper setIncrement: 2]; [fCropRightStepper setMinValue: 0]; - /* we set the preview length popup in seconds */ - [fPreviewMovieLengthPopUp removeAllItems]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"5"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"10"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"15"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"20"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"25"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"30"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"35"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"40"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"45"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"50"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"55"]; - [fPreviewMovieLengthPopUp addItemWithTitle: @"60"]; - - /* adjust the preview slider length */ - /* We use our advance pref to determine how many previews we scanned */ - int hb_num_previews = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue]; - [fPictureSlider setMaxValue: hb_num_previews - 1.0]; - [fPictureSlider setNumberOfTickMarks: hb_num_previews]; + [fPreviewController SetHandle: fHandle]; - if ([[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewLength"]) - { - [fPreviewMovieLengthPopUp selectItemWithTitle:[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewLength"]]; - } - else - { - /* currently hard set default to 10 seconds */ - [fPreviewMovieLengthPopUp selectItemAtIndex: 1]; - } + } - (void) SetTitle: (hb_title_t *) title @@ -147,7 +122,9 @@ hb_job_t * job = title->job; fTitle = title; - + + + [fWidthStepper setMaxValue: title->width]; [fWidthStepper setIntValue: job->width]; [fWidthField setIntValue: job->width]; @@ -200,6 +177,9 @@ fPicture = 0; MaxOutputWidth = title->width - job->crop[2] - job->crop[3]; MaxOutputHeight = title->height - job->crop[0] - job->crop[1]; + + //[fPreviewController SetTitle:fTitle]; + [self SettingsChanged: nil]; } @@ -229,82 +209,6 @@ are maintained across different sources */ } -// Adjusts the window to draw the current picture (fPicture) adjusting its size as -// necessary to display as much of the picture as possible. -- (void) displayPreview -{ - - /* lets make sure that the still picture view is not hidden and that - * the movie preview is - */ - [fMovieView pause:nil]; - [fMovieView setHidden:YES]; - [fMovieCreationProgressIndicator stopAnimation: nil]; - [fMovieCreationProgressIndicator setHidden: YES]; - - [fPictureView setHidden:NO]; - - [fPictureView setImage: [self imageForPicture: fPicture]]; - - NSSize displaySize = NSMakeSize( ( CGFloat )fTitle->width, ( CGFloat )fTitle->height ); - /* Set the picture size display fields below the Preview Picture*/ - if( fTitle->job->pixel_ratio == 1 ) // Original PAR Implementation - { - output_width = fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3]; - output_height = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1]; - display_width = output_width * fTitle->job->pixel_aspect_width / fTitle->job->pixel_aspect_height; - [fInfoField setStringValue:[NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d", - fTitle->width, fTitle->height, output_width, output_height, display_width, output_height]]; - displaySize.width *= ( ( CGFloat )fTitle->job->pixel_aspect_width ) / ( ( CGFloat )fTitle->job->pixel_aspect_height ); - } - else if (fTitle->job->pixel_ratio == 2) // Loose Anamorphic - { - display_width = output_width * output_par_width / output_par_height; - [fInfoField setStringValue:[NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d", - fTitle->width, fTitle->height, output_width, output_height, display_width, output_height]]; - - displaySize.width = display_width; - } - else // No Anamorphic - { - [fInfoField setStringValue: [NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d", fTitle->width, fTitle->height, - fTitle->job->width, fTitle->job->height]]; - } - - NSSize viewSize = [self optimalViewSizeForImageSize:displaySize]; - if( [self viewNeedsToResizeToSize:viewSize] ) - { - /* In the case of loose anamorphic, do not resize the window when scaling down */ - if (fTitle->job->pixel_ratio != 2 || [fWidthField intValue] == fTitle->width) - { - [self resizeSheetForViewSize:viewSize]; - [self setViewSize:viewSize]; - } - } - - // Show the scaled text (use the height to check since the width can vary - // with anamorphic video). - if( ( ( int )viewSize.height ) != fTitle->height ) - { - CGFloat scale = viewSize.width / ( ( CGFloat ) fTitle->width ); - NSString *scaleString = [NSString stringWithFormat: - NSLocalizedString( @" (Preview scaled to %.0f%% actual size)", - @"String shown when a preview is scaled" ), - scale * 100.0]; - [fInfoField setStringValue: [[fInfoField stringValue] stringByAppendingString:scaleString]]; - } - -} - -- (IBAction) previewDurationPopUpChanged: (id) sender -{ - -[[NSUserDefaults standardUserDefaults] setObject:[fPreviewMovieLengthPopUp titleOfSelectedItem] forKey:@"PreviewLength"]; - -} @@ -492,6 +396,8 @@ are maintained across different sources */ [fCropLeftField setIntValue: job->crop[2]]; [fCropRightStepper setIntValue: job->crop[3]]; [fCropRightField setIntValue: job->crop[3]]; + + [fPreviewController SetTitle:fTitle]; /* Sanity Check Here for < 16 px preview to avoid crashing hb_get_preview. In fact, just for kicks lets getting previews at a min limit of 32, since @@ -501,12 +407,12 @@ are maintained across different sources */ // Purge the existing picture previews so they get recreated the next time // they are needed. - [self purgeImageCache]; + [fPreviewController purgeImageCache]; /* We actually call displayPreview now from pictureSliderChanged which keeps * our picture preview slider in sync with the previews being shown */ - //[self displayPreview]; - [self pictureSliderChanged:nil]; + + [fPreviewController pictureSliderChanged:nil]; } @@ -517,334 +423,7 @@ are maintained across different sources */ } -- (IBAction) pictureSliderChanged: (id) sender -{ - // Show the picture view - [fCreatePreviewMovieButton setTitle: @"Live Preview"]; - [fPictureView setHidden:NO]; - [fMovieView pause:nil]; - [fMovieView setHidden:YES]; - [fPreviewMovieStatusField setHidden: YES]; - - int newPicture = [fPictureSlider intValue]; - if (newPicture != fPicture) - { - fPicture = newPicture; - } - [self displayPreview]; - -} - -#pragma mark Movie Preview -- (IBAction) createMoviePreview: (id) sender -{ - - - /* Lets make sure the still picture previews are showing in case - * there is currently a movie showing */ - [self pictureSliderChanged:nil]; - - /* Rip or Cancel ? */ - hb_state_t s; - hb_get_state2( fPreviewLibhb, &s ); - - if(s.state == HB_STATE_WORKING || s.state == HB_STATE_PAUSED) - { - - play_movie = NO; - hb_stop( fPreviewLibhb ); - [fPictureView setHidden:NO]; - [fMovieView pause:nil]; - [fMovieView setHidden:YES]; - [fPictureSlider setHidden:NO]; - [fCreatePreviewMovieButton setTitle: @"Live Preview"]; - return; - } - - - /* we use controller.mm's prepareJobForPreview to go ahead and set all of our settings - * however, we want to use a temporary destination field of course - * so that we do not put our temp preview in the users chosen - * directory */ - - hb_job_t * job = fTitle->job; - - /* We run our current setting through prepeareJob in Controller.mm - * just as if it were a regular encode */ - - [fHBController prepareJobForPreview]; - - /* Destination file. We set this to our preview directory - * changing the extension appropriately.*/ - if (fTitle->job->mux == HB_MUX_MP4) // MP4 file - { - /* we use .m4v for our mp4 files so that ac3 and chapters in mp4 will play properly */ - fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.m4v"; - } - else if (fTitle->job->mux == HB_MUX_MKV) // MKV file - { - fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.mkv"; - } - else if (fTitle->job->mux == HB_MUX_AVI) // AVI file - { - fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.avi"; - } - else if (fTitle->job->mux == HB_MUX_OGM) // OGM file - { - fPreviewMoviePath = @"~/Library/Application Support/HandBrake/Previews/preview_temp.ogm"; - } - - fPreviewMoviePath = [[fPreviewMoviePath stringByExpandingTildeInPath]retain]; - - /* See if there is an existing preview file, if so, delete it */ - if( ![[NSFileManager defaultManager] fileExistsAtPath:fPreviewMoviePath] ) - { - [[NSFileManager defaultManager] removeFileAtPath:fPreviewMoviePath - handler:nil]; - } - - /* We now direct our preview encode to fPreviewMoviePath */ - fTitle->job->file = [fPreviewMoviePath UTF8String]; - - /* We use our advance pref to determine how many previews to scan */ - int hb_num_previews = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue]; - job->start_at_preview = fPicture + 1; - job->seek_points = hb_num_previews; - - /* we use the preview duration popup to get the specified - * number of seconds for the preview encode. - */ - - job->pts_to_stop = [[fPreviewMovieLengthPopUp titleOfSelectedItem] intValue] * 90000LL; - - /* lets go ahead and send it off to libhb - * Note: unlike a full encode, we only send 1 pass regardless if the final encode calls for 2 passes. - * this should suffice for a fairly accurate short preview and cuts our preview generation time in half. - */ - hb_add( fPreviewLibhb, job ); - - [fPictureSlider setHidden:YES]; - [fMovieCreationProgressIndicator setHidden: NO]; - [fPreviewMovieStatusField setHidden: NO]; - [self startReceivingLibhbNotifications]; - - - [fCreatePreviewMovieButton setTitle: @"Cancel Preview"]; - - play_movie = YES; - - /* Let fPreviewLibhb do the job */ - hb_start( fPreviewLibhb ); - -} -- (void) startReceivingLibhbNotifications -{ - if (!fLibhbTimer) - { - fLibhbTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(libhbTimerFired:) userInfo:nil repeats:YES]; - [fLibhbTimer retain]; - } -} - -- (void) stopReceivingLibhbNotifications -{ - if (fLibhbTimer) - { - [fLibhbTimer invalidate]; - [fLibhbTimer release]; - fLibhbTimer = nil; - } -} -- (void) libhbTimerFired: (NSTimer*)theTimer -{ - hb_state_t s; - hb_get_state( fPreviewLibhb, &s ); - [self libhbStateChanged: s]; -} -- (void) libhbStateChanged: (hb_state_t &)state -{ - switch( state.state ) - { - case HB_STATE_IDLE: - case HB_STATE_SCANNING: - case HB_STATE_SCANDONE: - break; - - case HB_STATE_WORKING: - { -#define p state.param.working - - NSMutableString * string; - /* Update text field */ - string = [NSMutableString stringWithFormat: NSLocalizedString( @"Encoding %d seconds of preview %d: %.2f %%", @"" ), [[fPreviewMovieLengthPopUp titleOfSelectedItem] intValue], fPicture + 1, 100.0 * p.progress]; - - if( p.seconds > -1 ) - { - [string appendFormat: - NSLocalizedString( @" (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)", @"" ), - p.rate_cur, p.rate_avg, p.hours, p.minutes, p.seconds]; - } - [fPreviewMovieStatusField setStringValue: string]; - - [fMovieCreationProgressIndicator setIndeterminate: NO]; - /* Update slider */ - [fMovieCreationProgressIndicator setDoubleValue: 100.0 * p.progress]; - - [fCreatePreviewMovieButton setTitle: @"Cancel Preview"]; - - break; - - } -#undef p - -#define p state.param.muxing - case HB_STATE_MUXING: - { - // Update fMovieCreationProgressIndicator - [fMovieCreationProgressIndicator setIndeterminate: YES]; - [fMovieCreationProgressIndicator startAnimation: nil]; - [fPreviewMovieStatusField setStringValue: [NSString stringWithFormat: - NSLocalizedString( @"Muxing Preview ...", @"" )]]; - break; - } -#undef p - case HB_STATE_PAUSED: - [fMovieCreationProgressIndicator stopAnimation: nil]; - break; - - case HB_STATE_WORKDONE: - { - // Delete all remaining jobs since libhb doesn't do this on its own. - hb_job_t * job; - while( ( job = hb_job(fPreviewLibhb, 0) ) ) - hb_rem( fHandle, job ); - - [self stopReceivingLibhbNotifications]; - [fPreviewMovieStatusField setStringValue: @""]; - [fPreviewMovieStatusField setHidden: YES]; - - [fMovieCreationProgressIndicator stopAnimation: nil]; - [fMovieCreationProgressIndicator setHidden: YES]; - /* we make sure the picture slider and preview match */ - [self pictureSliderChanged:nil]; - [fPictureSlider setHidden:NO]; - - // Show the movie view - if (play_movie) - { - [self showMoviePreview:fPreviewMoviePath]; - } - - [fCreatePreviewMovieButton setTitle: @"Live Preview"]; - - - break; - } - } - -} - -- (IBAction) showMoviePreview: (NSString *) path -{ - /* Since the gray background for the still images is part of - * fPictureView, lets leave the picture view visible and postion - * the fMovieView over the image portion of fPictureView so - * we retain the gray cropping border we have already established - * with the still previews - */ - [fMovieView setHidden:NO]; - - /* Load the new movie into fMovieView */ - QTMovie * aMovie; - NSRect movieBounds; - if (path) - { - [fMovieView setControllerVisible: YES]; - /* let's make sure there is no movie currently set */ - [fMovieView setMovie:nil]; - - aMovie = [QTMovie movieWithFile:path error:nil]; - - /* we get some size information from the preview movie */ - Rect movieBox; - GetMovieBox ([aMovie quickTimeMovie], &movieBox); - movieBounds = [fMovieView movieBounds]; - movieBounds.size.height = movieBox.bottom - movieBox.top; - - if ([fMovieView isControllerVisible]) - movieBounds.size.height += [fMovieView controllerBarHeight]; - /* since for whatever the reason I cannot seem to get the [fMovieView controllerBarHeight] - * For now just use 15 for additional height as it seems to line up well - */ - movieBounds.size.height += 15; - - movieBounds.size.width = movieBox.right - movieBox.left; - - /* We need to find out if the preview movie needs to be scaled down so - * that it doesn't overflow our available viewing container (just like for image - * in -displayPreview) for HD sources, etc. [fPictureViewArea frame].size.height*/ - if( ((int)movieBounds.size.height) > [fPictureView frame].size.height ) - { - /* The preview movie would be larger than the available viewing area - * in the preview movie, so we go ahead and scale it down to the same size - * as the still preview or we readjust our window to allow for the added height if need be - */ - NSSize displaySize = NSMakeSize( (float)movieBounds.size.width, (float)movieBounds.size.height ); - //NSSize displaySize = NSMakeSize( (float)fTitle->width, (float)fTitle->height ); - NSSize viewSize = [self optimalViewSizeForImageSize:displaySize]; - if( [self viewNeedsToResizeToSize:viewSize] ) - { - - [self resizeSheetForViewSize:viewSize]; - [self setViewSize:viewSize]; - - } - - [fMovieView setFrameSize:viewSize]; - } - else - { - /* Since the preview movie is smaller than the available viewing area - * we can go ahead and use the preview movies native size */ - [fMovieView setFrameSize:movieBounds.size]; - } - - // lets reposition the movie if need be - - NSPoint origin = [fPictureViewArea frame].origin; - origin.x += trunc(([fPictureViewArea frame].size.width - - [fMovieView frame].size.width) / 2.0); - /* We need to detect whether or not we are currently less than the available height.*/ - if (movieBounds.size.height < [fPictureView frame].size.height) - { - /* If we are, we are adding 15 to the height to allow for the controller bar so - * we need to subtract half of that for the origin.y to get the controller bar - * below the movie to it lines up vertically with where our still preview was - */ - origin.y += trunc((([fPictureViewArea frame].size.height - - [fMovieView frame].size.height) / 2.0) - 7.5); - } - else - { - /* if we are >= to the height of the picture view area, the controller bar - * gets taken care of with picture resizing, so we do not want to offset the height - */ - origin.y += trunc(([fPictureViewArea frame].size.height - - [fMovieView frame].size.height) / 2.0); - } - [fMovieView setFrameOrigin:origin]; - - [fMovieView setMovie:aMovie]; - /// to actually play the movie - [fMovieView play:aMovie]; - } - else - { - aMovie = nil; - } - -} #pragma mark - @@ -920,300 +499,5 @@ are maintained across different sources */ } - -// This function converts an image created by libhb (specified via pictureIndex) into -// an NSImage suitable for the GUI code to use. If removeBorders is YES, -// makeImageForPicture crops the image generated by libhb stripping off the gray -// border around the content. This is the low-level method that generates the image. -// -imageForPicture calls this function whenever it can't find an image in its cache. -+ (NSImage *) makeImageForPicture: (int)pictureIndex - libhb:(hb_handle_t*)handle - title:(hb_title_t*)title - removeBorders:(BOOL)removeBorders -{ - if (removeBorders) - { - // |<---------- title->width ----------->| - // | |<---- title->job->width ---->| | - // | | | | - // ....................................... - // ....+-----------------------------+.... - // ....| |....<-- gray border - // ....| |.... - // ....| |.... - // ....| |<------- image - // ....| |.... - // ....| |.... - // ....| |.... - // ....| |.... - // ....| |.... - // ....+-----------------------------+.... - // ....................................... - - static uint8_t * buffer; - static int bufferSize; - - // Make sure we have a big enough buffer to receive the image from libhb. libhb - // creates images with a one-pixel border around the original content. Hence we - // add 2 pixels horizontally and vertically to the buffer size. - int srcWidth = title->width + 2; - int srcHeight= title->height + 2; - int newSize; - newSize = srcWidth * srcHeight * 4; - if( bufferSize < newSize ) - { - bufferSize = newSize; - buffer = (uint8_t *) realloc( buffer, bufferSize ); - } - - hb_get_preview( handle, title, pictureIndex, buffer ); - - // Create an NSBitmapImageRep and copy the libhb image into it, converting it from - // libhb's format to one suitable for NSImage. Along the way, we'll strip off the - // border around libhb's image. - - // The image data returned by hb_get_preview is 4 bytes per pixel, BGRA format. - // Alpha is ignored. - - int dstWidth = title->job->width; - int dstHeight = title->job->height; - NSBitmapFormat bitmapFormat = (NSBitmapFormat)NSAlphaFirstBitmapFormat; - NSBitmapImageRep * imgrep = [[[NSBitmapImageRep alloc] - initWithBitmapDataPlanes:nil - pixelsWide:dstWidth - pixelsHigh:dstHeight - bitsPerSample:8 - samplesPerPixel:3 // ignore alpha - hasAlpha:NO - isPlanar:NO - colorSpaceName:NSCalibratedRGBColorSpace - bitmapFormat:bitmapFormat - bytesPerRow:dstWidth * 4 - bitsPerPixel:32] autorelease]; - - int borderTop = (srcHeight - dstHeight) / 2; - int borderLeft = (srcWidth - dstWidth) / 2; - - UInt32 * src = (UInt32 *)buffer; - UInt32 * dst = (UInt32 *)[imgrep bitmapData]; - src += borderTop * srcWidth; // skip top rows in src to get to first row of dst - src += borderLeft; // skip left pixels in src to get to first pixel of dst - for (int r = 0; r < dstHeight; r++) - { - for (int c = 0; c < dstWidth; c++) -#if TARGET_RT_LITTLE_ENDIAN - *dst++ = Endian32_Swap(*src++); -#else - *dst++ = *src++; -#endif - src += (srcWidth - dstWidth); // skip to next row in src - } - - NSImage * img = [[[NSImage alloc] initWithSize: NSMakeSize(dstWidth, dstHeight)] autorelease]; - [img addRepresentation:imgrep]; - - return img; - } - else - { - // Make sure we have big enough buffer - static uint8_t * buffer; - static int bufferSize; - - int newSize; - newSize = ( title->width + 2 ) * (title->height + 2 ) * 4; - if( bufferSize < newSize ) - { - bufferSize = newSize; - buffer = (uint8_t *) realloc( buffer, bufferSize ); - } - - hb_get_preview( handle, title, pictureIndex, buffer ); - - // The image data returned by hb_get_preview is 4 bytes per pixel, BGRA format. - // We'll copy that into an NSImage swapping it to ARGB in the process. Alpha is - // ignored. - int width = title->width + 2; // hblib adds a one-pixel border to the image - int height = title->height + 2; - int numPixels = width * height; - NSBitmapFormat bitmapFormat = (NSBitmapFormat)NSAlphaFirstBitmapFormat; - NSBitmapImageRep * imgrep = [[[NSBitmapImageRep alloc] - initWithBitmapDataPlanes:nil - pixelsWide:width - pixelsHigh:height - bitsPerSample:8 - samplesPerPixel:3 // ignore alpha - hasAlpha:NO - isPlanar:NO - colorSpaceName:NSCalibratedRGBColorSpace - bitmapFormat:bitmapFormat - bytesPerRow:width * 4 - bitsPerPixel:32] autorelease]; - - UInt32 * src = (UInt32 *)buffer; - UInt32 * dst = (UInt32 *)[imgrep bitmapData]; - for (int i = 0; i < numPixels; i++) -#if TARGET_RT_LITTLE_ENDIAN - *dst++ = Endian32_Swap(*src++); -#else - *dst++ = *src++; -#endif - - NSImage * img = [[[NSImage alloc] initWithSize: NSMakeSize(width, height)] autorelease]; - [img addRepresentation:imgrep]; - - return img; - } -} - -// Returns the preview image for the specified index, retrieving it from its internal -// cache or by calling makeImageForPicture if it is not cached. Generally, you should -// use imageForPicture so that images are cached. Calling makeImageForPicture will -// always generate a new copy of the image. -- (NSImage *) imageForPicture: (int) pictureIndex -{ - // The preview for the specified index may not currently exist, so this method - // generates it if necessary. - NSString * key = [NSString stringWithFormat:@"%d", pictureIndex]; - NSImage * theImage = [fPicturePreviews objectForKey:key]; - if (!theImage) - { - theImage = [PictureController makeImageForPicture:pictureIndex libhb:fHandle title:fTitle removeBorders: NO]; - [fPicturePreviews setObject:theImage forKey:key]; - } - return theImage; -} - -// Purges all images from the cache. The next call to imageForPicture will cause a new -// image to be generated. -- (void) purgeImageCache -{ - [fPicturePreviews removeAllObjects]; -} - @end -@implementation PictureController (Private) - -// -// -[PictureController(Private) optimalViewSizeForImageSize:] -// -// Given the size of the preview image to be shown, returns the best possible -// size for the view. -// -- (NSSize)optimalViewSizeForImageSize: (NSSize)imageSize -{ - // The min size is 320x240 - CGFloat minWidth = 320.0; - CGFloat minHeight = 240.0; - - NSSize screenSize = [[NSScreen mainScreen] frame].size; - NSSize sheetSize = [[self window] frame].size; - NSSize viewAreaSize = [fPictureViewArea frame].size; - CGFloat paddingX = sheetSize.width - viewAreaSize.width; - CGFloat paddingY = sheetSize.height - viewAreaSize.height; - /* Since we are now non-modal, lets go ahead and allow the mac size to - * go up to the full screen height or width below. Am leaving the original - * code here that blindjimmy setup for 85% in case we don't like it. - */ - // The max size of the view is when the sheet is taking up 85% of the screen. - //CGFloat maxWidth = (0.85 * screenSize.width) - paddingX; - //CGFloat maxHeight = (0.85 * screenSize.height) - paddingY; - CGFloat maxWidth = screenSize.width - paddingX; - CGFloat maxHeight = screenSize.height - paddingY; - - NSSize resultSize = imageSize; - - // Its better to have a view that's too small than a view that's too big, so - // apply the maximum constraints last. - if( resultSize.width < minWidth ) - { - resultSize.height *= (minWidth / resultSize.width); - resultSize.width = minWidth; - } - if( resultSize.height < minHeight ) - { - resultSize.width *= (minHeight / resultSize.height); - resultSize.height = minHeight; - } - if( resultSize.width > maxWidth ) - { - resultSize.height *= (maxWidth / resultSize.width); - resultSize.width = maxWidth; - } - if( resultSize.height > maxHeight ) - { - resultSize.width *= (maxHeight / resultSize.height); - resultSize.height = maxHeight; - } - - return resultSize; -} - -// -// -[PictureController(Private) resizePanelForViewSize:animate:] -// -// Resizes the entire sheet to accomodate a view of a particular size. -// -- (void)resizeSheetForViewSize: (NSSize)viewSize -{ - // Figure out the deltas for the new frame area - NSSize currentSize = [fPictureViewArea frame].size; - CGFloat deltaX = viewSize.width - currentSize.width; - CGFloat deltaY = viewSize.height - currentSize.height; - - // Now resize the whole panel by those same deltas, but don't exceed the min - NSRect frame = [[self window] frame]; - NSSize maxSize = [[self window] maxSize]; - NSSize minSize = [[self window] minSize]; - frame.size.width += deltaX; - frame.size.height += deltaY; - if( frame.size.width < minSize.width ) - { - frame.size.width = minSize.width; - } - if( frame.size.height < minSize.height ) - { - frame.size.height = minSize.height; - } - - // But now the sheet is off-center, so also shift the origin to center it and - // keep the top aligned. - if( frame.size.width != [[self window] frame].size.width ) - frame.origin.x -= (deltaX / 2.0); - - if( frame.size.height != [[self window] frame].size.height ) - frame.origin.y -= deltaY; - - [[self window] setFrame:frame display:YES animate:YES]; -} - -// -// -[PictureController(Private) setViewSize:] -// -// Changes the view's size and centers it vertically inside of its area. -// Assumes resizeSheetForViewSize: has already been called. -// -- (void)setViewSize: (NSSize)viewSize -{ - [fPictureView setFrameSize:viewSize]; - - // center it vertically - NSPoint origin = [fPictureViewArea frame].origin; - origin.y += ([fPictureViewArea frame].size.height - - [fPictureView frame].size.height) / 2.0; - [fPictureView setFrameOrigin:origin]; -} - -// -// -[PictureController(Private) viewNeedsToResizeToSize:] -// -// Returns YES if the view will need to resize to match the given size. -// -- (BOOL)viewNeedsToResizeToSize: (NSSize)newSize -{ - NSSize viewSize = [fPictureView frame].size; - return (newSize.width != viewSize.width || newSize.height != viewSize.height); -} - -@end