diff options
author | ritsuka <[email protected]> | 2014-12-20 18:56:10 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2014-12-20 18:56:10 +0000 |
commit | f1846aaeac294291862156447bff495c1f016613 (patch) | |
tree | 8e183230e25b056e87c406d3eb1c9bf9332219f4 /macosx | |
parent | 4ced50fce98afc403c48a1f06a2f8f05d2d79c96 (diff) |
MacGui: integrated HBPicture in HBPictureController and started to move things over to HBJob.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6628 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.h | 1 | ||||
-rw-r--r-- | macosx/Controller.m | 309 | ||||
-rw-r--r-- | macosx/English.lproj/PictureSettings.xib | 237 | ||||
-rw-r--r-- | macosx/HBPreviewController.h | 19 | ||||
-rw-r--r-- | macosx/HBPreviewController.m | 92 | ||||
-rw-r--r-- | macosx/HBPreviewGenerator.h | 7 | ||||
-rw-r--r-- | macosx/HBPreviewGenerator.m | 37 | ||||
-rw-r--r-- | macosx/PictureController.h | 15 | ||||
-rw-r--r-- | macosx/PictureController.m | 566 |
9 files changed, 370 insertions, 913 deletions
diff --git a/macosx/Controller.h b/macosx/Controller.h index 380e8b0b7..77b66c0e3 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -193,7 +193,6 @@ extern NSString *keyTitleTag; - (IBAction) formatPopUpChanged: (id) sender; - (IBAction) autoSetM4vExtension: (id) sender; -- (void) prepareJob; - (IBAction) browseFile: (id) sender; - (IBAction) showPicturePanel: (id) sender; diff --git a/macosx/Controller.m b/macosx/Controller.m index ec3c6b46c..39377cfd4 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -21,9 +21,8 @@ #import "HBAudioDefaults.h" #import "HBSubtitlesDefaults.h" -#import "HBJob.h" - #import "HBCore.h" +#import "HBJob.h" NSString *HBContainerChangedNotification = @"HBContainerChangedNotification"; NSString *keyContainerTag = @"keyContainerTag"; @@ -79,6 +78,7 @@ NSString *keyTitleTag = @"keyTitleTag"; // Inits the controllers outputPanel = [[HBOutputPanelController alloc] init]; fPictureController = [[HBPictureController alloc] init]; + fPreviewController = [[HBPreviewController alloc] init]; fQueueController = [[HBQueueController alloc] init]; // we init the HBPresetsManager class @@ -110,9 +110,11 @@ NSString *keyTitleTag = @"keyTitleTag"; int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue]; // Init libhb _core = [[HBCore alloc] initWithLoggingLevel:loggingLevel]; + _core.name = @"ScanCore"; // Init a separate instance of libhb for user scanning and setting up jobs _queueCore = [[HBCore alloc] initWithLoggingLevel:loggingLevel]; + _queueCore.name = @"QueueCore"; // Registers the observers to the cores notifications. [self registerScanCoreNotifications]; @@ -122,13 +124,17 @@ NSString *keyTitleTag = @"keyTitleTag"; [GrowlApplicationBridge setGrowlDelegate: self]; [fPictureController setDelegate:self]; - [fPictureController setHandle:self.core.hb_handle]; + + fPreviewController.delegate = self; + [fPreviewController setCore:self.core]; [fQueueController setHandle:self.queueCore.hb_handle]; [fQueueController setHBController:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(autoSetM4vExtension:) name:HBMixdownChangedNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateMp4Checkboxes:) name:HBVideoEncoderChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pictureSettingsDidChange) name:HBPictureChangedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pictureSettingsDidChange) name:HBFiltersChangedNotification object:nil]; dockIconProgress = 0; } @@ -569,9 +575,6 @@ NSString *keyTitleTag = @"keyTitleTag"; stringWithFormat:@"%@/Desktop/Movie.mp4", NSHomeDirectory()]]; - /* Set Auto Crop to On at launch */ - [fPictureController setAutoCrop:YES]; - /* Bottom */ [fStatusField setStringValue: @""]; @@ -1465,7 +1468,8 @@ NSString *keyTitleTag = @"keyTitleTag"; // Notify anyone interested (audio/subtitles/chapters controller) that there's no title fTitle = NULL; - [fPictureController setTitle:NULL]; + fPictureController.picture = nil; + fPreviewController.job = nil; [[NSNotificationCenter defaultCenter] postNotification: [NSNotification notificationWithName: HBTitleChangedNotification @@ -1547,7 +1551,9 @@ NSString *keyTitleTag = @"keyTitleTag"; SuccessfulScan = NO; // Notify PictureController that there's no title - [fPictureController setTitle:NULL]; + fPictureController.picture = nil; + fPictureController.filters = nil; + fPreviewController.job = nil; // Notify anyone interested (video/audio/subtitles/chapters controller) that there's no title [[NSNotificationCenter defaultCenter] postNotification: @@ -2006,10 +2012,7 @@ static void queueFSEventStreamCallback( hb_list_t * list = hb_get_titles(self.core.hb_handle); hb_title_t * title = (hb_title_t *) hb_list_item( list, (int)[fSrcTitlePopUp indexOfSelectedItem] ); - hb_job_t * job = title->job; - - - + /* We use a number system to set the encode status of the queue item * 0 == already encoded * 1 == is being encoded @@ -2087,13 +2090,7 @@ static void queueFSEventStreamCallback( [fVideoController.video prepareVideoForQueueFileJob:queueFileJob]; /* Picture Sizing */ - [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"]; - [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"]; - [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.keep_display_aspect] forKey:@"PictureKeepRatio"]; - [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"]; - [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->modulus] forKey:@"PictureModulus"]; - [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->par.num] forKey:@"PicturePARPixelWidth"]; - [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->par.den] forKey:@"PicturePARPixelHeight"]; + [fPictureController.picture preparePictureForQueueFileJob:queueFileJob]; /* Text summaries of various settings */ [queueFileJob setObject:[NSString stringWithString:[self pictureSettingsSummary]] @@ -2102,13 +2099,6 @@ static void queueFSEventStreamCallback( forKey:@"PictureFiltersSummary"]; [queueFileJob setObject:[NSString stringWithString:[self muxerOptionsSummary]] forKey:@"MuxerOptionsSummary"]; - - /* Set crop settings here */ - [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"]; - [queueFileJob setObject:[NSNumber numberWithInt:job->crop[0]] forKey:@"PictureTopCrop"]; - [queueFileJob setObject:[NSNumber numberWithInt:job->crop[1]] forKey:@"PictureBottomCrop"]; - [queueFileJob setObject:[NSNumber numberWithInt:job->crop[2]] forKey:@"PictureLeftCrop"]; - [queueFileJob setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"]; /* Picture Filters */ HBFilters *filters = fPictureController.filters; @@ -2155,8 +2145,8 @@ static void queueFSEventStreamCallback( /* Codecs */ /* Framerate */ - [queueFileJob setObject:[NSNumber numberWithInt:title->vrate.num] forKey:@"JobVrate"]; - [queueFileJob setObject:[NSNumber numberWithInt:title->vrate.den] forKey:@"JobVrateBase"]; + [queueFileJob setObject:[NSNumber numberWithInt:title->vrate.num] forKey:@"JobVrate"]; + [queueFileJob setObject:[NSNumber numberWithInt:title->vrate.den] forKey:@"JobVrateBase"]; /* we need to auto relase the queueFileJob and return it */ [queueFileJob autorelease]; @@ -2266,7 +2256,7 @@ static void queueFSEventStreamCallback( { hb_list_t * list = hb_get_titles( self.queueCore.hb_handle ); hb_title_t * title = (hb_title_t *) hb_list_item( list,0 ); // is always zero since now its a single title scan - hb_job_t * job = title->job; + hb_job_t * job = hb_job_init(title); if( !hb_list_count( list ) ) { @@ -2277,7 +2267,7 @@ static void queueFSEventStreamCallback( [HBUtilities writeToActivityLog: "Preset: %s", [[queueToApply objectForKey:@"PresetName"] UTF8String]]; [HBUtilities writeToActivityLog: "processNewQueueEncode number of passes expected is: %d", ([[queueToApply objectForKey:@"VideoTwoPass"] intValue] + 1)]; hb_job_set_file(job, [[queueToApply objectForKey:@"DestinationPath"] UTF8String]); - [self prepareJob]; + [self prepareJob:job]; /* * If scanning we need to do some extra setup of the job. @@ -2370,8 +2360,8 @@ static void queueFSEventStreamCallback( */ - (IBAction)applyQueueSettingsToMainWindow:(id)sender { - NSMutableDictionary * queueToApply = [QueueFileArray objectAtIndex:fqueueEditRescanItemNum]; - hb_job_t * job = fTitle->job; + NSDictionary *queueToApply = [QueueFileArray objectAtIndex:fqueueEditRescanItemNum]; + if (queueToApply) { [HBUtilities writeToActivityLog: "applyQueueSettingsToMainWindow: queue item found"]; @@ -2416,40 +2406,9 @@ static void queueFSEventStreamCallback( [fSubtitlesViewController addTracksFromQueue:[queueToApply objectForKey:@"SubtitleList"]]; /* Picture Settings */ - - /* If Cropping is set to custom, then recall all four crop values from - when the preset was created and apply them */ - if ([[queueToApply objectForKey:@"PictureAutoCrop"] intValue] == 0) - { - [fPictureController setAutoCrop:NO]; - - /* Here we use the custom crop values saved at the time the preset was saved */ - job->crop[0] = [[queueToApply objectForKey:@"PictureTopCrop"] intValue]; - job->crop[1] = [[queueToApply objectForKey:@"PictureBottomCrop"] intValue]; - job->crop[2] = [[queueToApply objectForKey:@"PictureLeftCrop"] intValue]; - job->crop[3] = [[queueToApply objectForKey:@"PictureRightCrop"] intValue]; - - } - else /* if auto crop has been saved in preset, set to auto and use post scan auto crop */ - { - [fPictureController setAutoCrop:YES]; - /* Here we use the auto crop values determined right after scan */ - job->crop[0] = fTitle->crop[0]; - job->crop[1] = fTitle->crop[1]; - job->crop[2] = fTitle->crop[2]; - job->crop[3] = fTitle->crop[3]; - - } - - job->anamorphic.mode = [[queueToApply objectForKey:@"PicturePAR"] intValue]; - job->modulus = [[queueToApply objectForKey:@"PictureModulus"] intValue]; - job->maxWidth = job->maxHeight = 0; - job->anamorphic.keep_display_aspect = [[queueToApply objectForKey:@"PictureKeepRatio"] intValue]; - job->width = [[queueToApply objectForKey:@"PictureWidth"] intValue]; - job->height = [[queueToApply objectForKey:@"PictureHeight"] intValue]; + [fPictureController.picture applyPictureSettingsFromQueue:queueToApply]; /* Filters */ - HBFilters *filters = [fPictureController filters]; /* We only allow *either* Decomb or Deinterlace. So check for the PictureDecombDeinterlace key. */ @@ -2523,7 +2482,6 @@ static void queueFSEventStreamCallback( filters.grayscale = [queueToApply[@"VideoGrayScale"] boolValue]; /* we call SetTitle: in fPictureController so we get an instant update in the Picture Settings window */ - [fPictureController setTitle:fTitle]; [self pictureSettingsDidChange]; [fPresetSelectedDisplay setStringValue:queueToApply[@"PresetName"]]; @@ -2560,6 +2518,23 @@ static void queueFSEventStreamCallback( /* Video Encoder */ [fVideoController.video prepareVideoForJobPreview:job andTitle:title]; + /* Picture Size Settings */ + HBPicture *pict = self.job.picture; + job->width = pict.width; + job->height = pict.height; + + job->anamorphic.keep_display_aspect = pict.keepDisplayAspect; + job->anamorphic.mode = pict.anamorphicMode; + job->modulus = pict.modulus; + job->par.num = pict.parWidth; + job->par.den = pict.parHeight; + + /* Here we use the crop values saved at the time the preset was saved */ + job->crop[0] = pict.cropTop; + job->crop[1] = pict.cropBottom; + job->crop[2] = pict.cropLeft; + job->crop[3] = pict.cropRight; + /* Subtitle settings */ BOOL one_burned = NO; int i = 0; @@ -2854,13 +2829,13 @@ static void queueFSEventStreamCallback( #pragma mark - #pragma mark Job Handling -- (void) prepareJob -{ - +- (void) prepareJob:(hb_job_t *)job +{ NSDictionary * queueToApply = [QueueFileArray objectAtIndex:currentQueueEncodeIndex]; + hb_list_t * list = hb_get_titles(self.queueCore.hb_handle); hb_title_t * title = (hb_title_t *) hb_list_item( list,0 ); // is always zero since now its a single title scan - hb_job_t * job = title->job; + hb_audio_config_t * audio; hb_filter_object_t * filter; /* Title Angle for dvdnav */ @@ -3794,19 +3769,21 @@ static void queueFSEventStreamCallback( - (IBAction) titlePopUpChanged: (id) sender { - hb_list_t * list = hb_get_titles( self.core.hb_handle ); - hb_title_t * title = (hb_title_t*) - hb_list_item( list, (int)[fSrcTitlePopUp indexOfSelectedItem] ); - // If there is already a title load, save the current settings to a preset if (titleLoaded) { self.selectedPreset = [self createPresetFromCurrentSettings]; } + HBTitle *hbtitle = [self.core.titles objectAtIndex:fSrcTitlePopUp.indexOfSelectedItem]; + self.job = [[[HBJob alloc] initWithTitle:hbtitle + url:[NSURL fileURLWithPath:fSrcDVD2Field.stringValue] + andPreset:self.selectedPreset] autorelease]; + + hb_title_t *title = hbtitle.hb_title; + /* If we are a stream type and a batch scan, grok the output file name from title->name upon title change */ - if ((title->type == HB_STREAM_TYPE || title->type == HB_FF_STREAM_TYPE) && - hb_list_count( list ) > 1 ) + if ((title->type == HB_STREAM_TYPE || title->type == HB_FF_STREAM_TYPE) && self.core.titles.count) { /* we set the default name according to the new title->name */ [fDstFile2Field setStringValue: [NSString stringWithFormat: @@ -3854,9 +3831,10 @@ static void queueFSEventStreamCallback( /* Start Get and set the initial pic size for display */ fTitle = title; - - /* Set Auto Crop to on upon selecting a new title */ - [fPictureController setAutoCrop:YES]; + + fPictureController.picture = self.job.picture; + fPictureController.filters = self.job.filters; + fPreviewController.job = self.job; /* Update the others views */ [[NSNotificationCenter defaultCenter] postNotification: @@ -3866,13 +3844,16 @@ static void queueFSEventStreamCallback( [NSData dataWithBytesNoCopy: &fTitle length: sizeof(fTitle) freeWhenDone: NO], keyTitleTag, nil]]]; + /* Set Auto Crop to on upon selecting a new title */ + fPictureController.picture.autocrop = YES; + /* If Auto Naming is on. We create an output filename of dvd name - title number */ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAutoNaming"]) { [self updateFileName]; } - /* apply the current preset */ + /* apply the current preset */ [self applyPreset:self.selectedPreset]; } @@ -4107,31 +4088,31 @@ the user is using "Custom" settings by determining the sender*/ fVideoController.pictureFilters = fPictureController.filters.summary; /* Store storage resolution for unparse */ - if (fTitle) - { - fVideoController.video.widthForUnparse = fTitle->job->width; - fVideoController.video.heightForUnparse = fTitle->job->height; - } + fVideoController.video.widthForUnparse = fPictureController.picture.width; + fVideoController.video.heightForUnparse = fPictureController.picture.height; + + [fPreviewController reloadPreviews]; } #pragma mark - #pragma mark - Text Summaries -- (NSString*) pictureSettingsSummary +- (NSString *)pictureSettingsSummary { NSMutableString *summary = [NSMutableString stringWithString:@""]; - if (fPictureController && fTitle && fTitle->job) + if (fPictureController.picture) { - [summary appendString:[fPictureController pictureSizeInfoString]]; - if (fTitle->job->anamorphic.mode != HB_ANAMORPHIC_STRICT) + HBPicture *pict = fPictureController.picture; + [summary appendString:fPictureController.picture.info]; + if (pict.anamorphicMode != HB_ANAMORPHIC_STRICT) { // anamorphic is not Strict, show the modulus - [summary appendFormat:@", Modulus: %d", fTitle->job->modulus]; + [summary appendFormat:@", Modulus: %d", pict.modulus]; } [summary appendFormat:@", Crop: %s %d/%d/%d/%d", - [fPictureController autoCrop] ? "Auto" : "Custom", - fTitle->job->crop[0], fTitle->job->crop[1], - fTitle->job->crop[2], fTitle->job->crop[3]]; + pict.autocrop ? "Auto" : "Custom", + pict.cropTop, pict.cropBottom, + pict.cropLeft, pict.cropRight]; } return [NSString stringWithString:summary]; } @@ -4232,12 +4213,12 @@ the user is using "Custom" settings by determining the sender*/ - (IBAction) showPicturePanel: (id) sender { - [fPictureController showPictureWindow:sender]; + [fPictureController showPictureWindow]; } - (IBAction) showPreviewWindow: (id) sender { - [fPictureController showPreviewWindow:sender]; + [fPreviewController showWindow:sender]; } #pragma mark - Preset Methods @@ -4249,7 +4230,6 @@ the user is using "Custom" settings by determining the sender*/ self.selectedPreset = preset; self.customPreset = NO; - hb_job_t * job = fTitle->job; NSDictionary *chosenPreset = preset.content; [fPresetSelectedDisplay setStringValue:[chosenPreset objectForKey:@"PresetName"]]; @@ -4291,126 +4271,8 @@ the user is using "Custom" settings by determining the sender*/ [fSubtitlesViewController applySettingsFromPreset:chosenPreset]; /* Picture Settings */ - /* Note: objectForKey:@"UsesPictureSettings" refers to picture size, which encompasses: - * height, width, keep ar, anamorphic and crop settings. - * picture filters are handled separately below. - */ - int maxWidth = fTitle->geometry.width - job->crop[2] - job->crop[3]; - int maxHeight = fTitle->geometry.height - job->crop[0] - job->crop[1]; - job->maxWidth = job->maxHeight = 0; - /* Check to see if the objectForKey:@"UsesPictureSettings is greater than 0, as 0 means use picture sizing "None" - * ( 2 is use max for source and 1 is use exact size when the preset was created ) and the - * preset completely ignores any picture sizing values in the preset. - */ - if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] > 0) - { - /* If Cropping is set to custom, then recall all four crop values from - when the preset was created and apply them */ - if ([[chosenPreset objectForKey:@"PictureAutoCrop"] intValue] == 0) - { - [fPictureController setAutoCrop:NO]; - - /* Here we use the custom crop values saved at the time the preset was saved */ - job->crop[0] = [[chosenPreset objectForKey:@"PictureTopCrop"] intValue]; - job->crop[1] = [[chosenPreset objectForKey:@"PictureBottomCrop"] intValue]; - job->crop[2] = [[chosenPreset objectForKey:@"PictureLeftCrop"] intValue]; - job->crop[3] = [[chosenPreset objectForKey:@"PictureRightCrop"] intValue]; - - } - else /* if auto crop has been saved in preset, set to auto and use post scan auto crop */ - { - [fPictureController setAutoCrop:YES]; - /* Here we use the auto crop values determined right after scan */ - job->crop[0] = fTitle->crop[0]; - job->crop[1] = fTitle->crop[1]; - job->crop[2] = fTitle->crop[2]; - job->crop[3] = fTitle->crop[3]; - } - - /* crop may have changed, reset maxWidth/maxHeight */ - maxWidth = fTitle->geometry.width - job->crop[2] - job->crop[3]; - maxHeight = fTitle->geometry.height - job->crop[0] - job->crop[1]; - - /* Set modulus */ - if ([chosenPreset objectForKey:@"PictureModulus"]) - { - job->modulus = [[chosenPreset objectForKey:@"PictureModulus"] intValue]; - } - else - { - job->modulus = 16; - } - - /* - * Assume max picture settings initially - */ - job->anamorphic.mode = [[chosenPreset objectForKey:@"PicturePAR"] intValue]; - job->width = fTitle->geometry.width - job->crop[2] - job->crop[3]; - job->height = fTitle->geometry.height - job->crop[0] - job->crop[1]; - job->anamorphic.keep_display_aspect = [[chosenPreset objectForKey:@"PictureKeepRatio"] intValue]; - - /* Check to see if the objectForKey:@"UsesPictureSettings" is 2, - * which means "Use max. picture size for source" - * If not 2 it must be 1 here which means "Use the picture - * size specified in the preset" - */ - if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] != 2 && - [[chosenPreset objectForKey:@"UsesMaxPictureSettings"] intValue] != 1) - { - /* - * if the preset specifies neither max. width nor height - * (both are 0), use the max. picture size - * - * if the specified non-zero dimensions exceed those of the - * source, also use the max. picture size (no upscaling) - */ - if ([[chosenPreset objectForKey:@"PictureWidth"] intValue] > 0) - { - job->maxWidth = [[chosenPreset objectForKey:@"PictureWidth"] intValue]; - } - if ([[chosenPreset objectForKey:@"PictureHeight"] intValue] > 0) - { - job->maxHeight = [[chosenPreset objectForKey:@"PictureHeight"] intValue]; - } - } - } - /* Modulus added to maxWidth/maxHeight to allow a small amount of - * upscaling to the next mod boundary. This does not apply to - * explicit limits set for device compatibility. It only applies - * when limiting to cropped title dimensions. - */ - maxWidth += job->modulus - 1; - maxHeight += job->modulus - 1; - if (job->maxWidth == 0 || job->maxWidth > maxWidth) - job->maxWidth = maxWidth; - if (job->maxHeight == 0 || job->maxHeight > maxHeight) - job->maxHeight = maxHeight; - - hb_geometry_t srcGeo, resultGeo; - hb_geometry_settings_t uiGeo; - - srcGeo.width = fTitle->geometry.width; - srcGeo.height = fTitle->geometry.height; - srcGeo.par = fTitle->geometry.par; - - uiGeo.mode = job->anamorphic.mode; - uiGeo.keep = !!job->anamorphic.keep_display_aspect * HB_KEEP_DISPLAY_ASPECT; - uiGeo.itu_par = 0; - uiGeo.modulus = job->modulus; - memcpy(uiGeo.crop, job->crop, sizeof(int[4])); - uiGeo.geometry.width = job->width; - uiGeo.geometry.height = job->height; - uiGeo.geometry.par = job->par; - uiGeo.maxWidth = job->maxWidth; - uiGeo.maxHeight = job->maxHeight; - hb_set_anamorphic_size2(&srcGeo, &uiGeo, &resultGeo); - - job->width = resultGeo.width; - job->height = resultGeo.height; - job->par = resultGeo.par; - /* we call SetTitle: in fPictureController so we get an instant update in the Picture Settings window */ - [fPictureController setTitle:fTitle]; + [fPictureController.picture applySettingsFromPreset:chosenPreset]; [fPictureController.filters applySettingsFromPreset:chosenPreset]; [self pictureSettingsDidChange]; } @@ -4451,7 +4313,7 @@ the user is using "Custom" settings by determining the sender*/ { /* Show the add panel */ HBAddPresetController *addPresetController = [[HBAddPresetController alloc] initWithPreset:[self createPresetFromCurrentSettings] - videoSize:NSMakeSize(fTitle->job->width, fTitle->job->height)]; + videoSize:NSMakeSize(fPictureController.picture.width, fPictureController.picture.height)]; [NSApp beginSheet:addPresetController.window modalForWindow:fWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:addPresetController]; } @@ -4498,26 +4360,15 @@ the user is using "Custom" settings by determining the sender*/ // Video encoder [fVideoController.video prepareVideoForPreset:preset]; - // Picture Sizing preset[@"PictureWidth"] = currentPreset[@"PictureWidth"]; preset[@"PictureHeight"] = currentPreset[@"PictureHeight"]; - hb_job_t *job = fTitle->job; - preset[@"PictureKeepRatio"] = @(job->anamorphic.keep_display_aspect); - preset[@"PicturePAR"] = @(job->anamorphic.mode); - preset[@"PictureModulus"] = @(job->modulus); - - // Set crop settings - preset[@"PictureAutoCrop"] = @(fPictureController.autoCrop); - - preset[@"PictureTopCrop"] = @(job->crop[0]); - preset[@"PictureBottomCrop"] = @(job->crop[1]); - preset[@"PictureLeftCrop"] = @(job->crop[2]); - preset[@"PictureRightCrop"] = @(job->crop[3]); - // Picture Filters [fPictureController.filters prepareFiltersForPreset:preset]; + // Picture Size + [fPictureController.picture preparePictureForPreset:preset]; + // Audio [fAudioController.settings prepareAudioDefaultsForPreset:preset]; diff --git a/macosx/English.lproj/PictureSettings.xib b/macosx/English.lproj/PictureSettings.xib index f7f43f608..9fac46c13 100644 --- a/macosx/English.lproj/PictureSettings.xib +++ b/macosx/English.lproj/PictureSettings.xib @@ -1,23 +1,14 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14B23" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14C81f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> <dependencies> <deployment version="1060" identifier="macosx"/> <development version="5100" identifier="xcode"/> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/> </dependencies> <objects> <customObject id="-2" userLabel="File's Owner" customClass="HBPictureController"> <connections> <outlet property="fAnamorphicPopUp" destination="132" id="140"/> - <outlet property="fCropBottomField" destination="10" id="53"/> - <outlet property="fCropBottomStepper" destination="14" id="54"/> - <outlet property="fCropLeftField" destination="11" id="55"/> - <outlet property="fCropLeftStepper" destination="19" id="56"/> - <outlet property="fCropMatrix" destination="16" id="57"/> - <outlet property="fCropRightField" destination="9" id="58"/> - <outlet property="fCropRightStepper" destination="15" id="59"/> - <outlet property="fCropTopField" destination="13" id="60"/> - <outlet property="fCropTopStepper" destination="12" id="61"/> <outlet property="fDeblockField" destination="291" id="372"/> <outlet property="fDecombBox" destination="315" id="364"/> <outlet property="fDecombDeinterlaceBox" destination="287" id="360"/> @@ -29,23 +20,11 @@ <outlet property="fDenoiseTuneLabel" destination="gpP-sp-Lev" id="Q7g-G7-JZZ"/> <outlet property="fDenoiseTunePopUp" destination="Upd-5E-OpR" id="5UN-Gt-l11"/> <outlet property="fDetelecineBox" destination="286" id="356"/> - <outlet property="fDisplayWidthField" destination="396" id="407"/> - <outlet property="fDisplayWidthLabel" destination="402" id="526"/> - <outlet property="fHeightField" destination="43" id="66"/> - <outlet property="fHeightStepper" destination="46" id="67"/> - <outlet property="fModulusLabel" destination="390" id="532"/> - <outlet property="fModulusPopUp" destination="384" id="392"/> - <outlet property="fParHeightField" destination="442" id="449"/> - <outlet property="fParHeightLabel" destination="446" id="525"/> - <outlet property="fParWidthField" destination="440" id="448"/> - <outlet property="fParWidthLabel" destination="444" id="524"/> + <outlet property="fHeightStepper" destination="46" id="cLy-f3-fot"/> <outlet property="fPictureCropBox" destination="7" id="242"/> <outlet property="fPictureSizeBox" destination="436" id="437"/> - <outlet property="fRatioCheck" destination="45" id="74"/> <outlet property="fSizeFilterView" destination="281" id="419"/> - <outlet property="fSizeInfoField" destination="278" id="280"/> - <outlet property="fWidthField" destination="42" id="68"/> - <outlet property="fWidthStepper" destination="44" id="69"/> + <outlet property="fWidthStepper" destination="44" id="z49-FB-Xci"/> <outlet property="window" destination="5" id="184"/> </connections> </customObject> @@ -61,7 +40,7 @@ <autoresizingMask key="autoresizingMask"/> <userGuides> <userLayoutGuide affinity="minY"/> - <userLayoutGuide location="115" affinity="minX"/> + <userLayoutGuide location="114" affinity="minX"/> </userGuides> <subviews> <textField verticalHuggingPriority="750" id="262"> @@ -81,6 +60,9 @@ <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/> </textFieldCell> + <connections> + <binding destination="-2" name="value" keyPath="self.picture.info" id="Qs2-Ni-TWK"/> + </connections> </textField> <tabView controlSize="mini" initialItem="282" id="281"> <rect key="frame" x="-12" y="18" width="658" height="216"/> @@ -107,6 +89,13 @@ <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="hidden" keyPath="self.picture.customAnamorphicEnabled" id="aUz-kE-qa4"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + </connections> </textField> <textField verticalHuggingPriority="750" id="396"> <rect key="frame" x="278" y="106" width="61" height="16"/> @@ -117,7 +106,18 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="settingsChanged:" target="-2" id="EIO-m9-bQ5"/> + <binding destination="-2" name="enabled" keyPath="self.picture.keepDisplayAspect" previousBinding="zMs-ue-T1n" id="gD3-Yl-3au"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="hidden" keyPath="self.picture.customAnamorphicEnabled" previousBinding="gD3-Yl-3au" id="PSj-Fl-3Ni"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="editable" keyPath="self.picture.customAnamorphicEnabled" id="zMs-ue-T1n"/> + <binding destination="-2" name="value" keyPath="self.picture.displayWidth" id="nMg-v2-Fvg"/> </connections> </textField> <textField verticalHuggingPriority="750" id="440"> @@ -129,7 +129,18 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="settingsChanged:" target="-2" id="Ip6-Hp-U6K"/> + <binding destination="-2" name="enabled" keyPath="self.picture.keepDisplayAspect" previousBinding="Wvz-jo-lwE" id="b7l-Ej-dxa"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="hidden" keyPath="self.picture.customAnamorphicEnabled" previousBinding="b7l-Ej-dxa" id="4ER-Vi-m2V"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="editable" keyPath="self.picture.customAnamorphicEnabled" id="Wvz-jo-lwE"/> + <binding destination="-2" name="value" keyPath="self.picture.parWidth" id="PXg-GA-vo6"/> </connections> </textField> <textField verticalHuggingPriority="750" id="442"> @@ -141,7 +152,18 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="settingsChanged:" target="-2" id="YvM-ki-flP"/> + <binding destination="-2" name="enabled" keyPath="self.picture.keepDisplayAspect" previousBinding="Vjg-8L-veN" id="kG8-EC-OJR"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="hidden" keyPath="self.picture.customAnamorphicEnabled" previousBinding="kG8-EC-OJR" id="6PT-Pz-qs1"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="editable" keyPath="self.picture.customAnamorphicEnabled" id="Vjg-8L-veN"/> + <binding destination="-2" name="value" keyPath="self.picture.parHeight" id="HrI-5d-evg"/> </connections> </textField> <textField verticalHuggingPriority="750" id="444"> @@ -152,6 +174,13 @@ <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="hidden" keyPath="self.picture.customAnamorphicEnabled" id="Gp6-pf-QeR"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + </connections> </textField> <textField verticalHuggingPriority="750" id="446"> <rect key="frame" x="202" y="56" width="71" height="16"/> @@ -161,6 +190,13 @@ <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="hidden" keyPath="self.picture.customAnamorphicEnabled" id="IQs-tB-UlR"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + </connections> </textField> <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="44"> <rect key="frame" x="143" y="103" width="15" height="22"/> @@ -169,25 +205,28 @@ <font key="font" metaFont="smallSystem"/> </stepperCell> <connections> - <action selector="settingsChanged:" target="-2" id="je3-pw-SC3"/> + <binding destination="-2" name="maxValue" keyPath="self.picture.maxWidth" id="P3g-UC-vRH"/> + <binding destination="-2" name="value" keyPath="self.picture.width" previousBinding="P3g-UC-vRH" id="Ilz-OP-M5c"/> + <binding destination="-2" name="enabled" keyPath="self.picture.widthEditable" id="ied-mi-MjS"/> </connections> </stepper> <popUpButton verticalHuggingPriority="750" id="384"> <rect key="frame" x="75" y="15" width="46" height="15"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <popUpButtonCell key="cell" type="push" title="16" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="387" id="385"> + <popUpButtonCell key="cell" type="push" title="4" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="389" id="385"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="miniSystem"/> <menu key="menu" title="OtherViews" id="386"> <items> - <menuItem title="16" state="on" id="387"/> + <menuItem title="16" id="387"/> <menuItem title="8" id="388"/> - <menuItem title="4" id="389"/> + <menuItem title="4" state="on" id="389"/> + <menuItem title="2" id="Fx1-DI-r18"/> </items> </menu> </popUpButtonCell> <connections> - <action selector="settingsChanged:" target="-2" id="fS2-p2-Ldc"/> + <binding destination="-2" name="selectedValue" keyPath="self.picture.modulus" id="anc-Ha-mxE"/> </connections> </popUpButton> <textField verticalHuggingPriority="750" id="42"> @@ -202,7 +241,13 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="settingsChanged:" target="-2" id="EJC-vL-fSK"/> + <binding destination="-2" name="editable" keyPath="self.picture.widthEditable" id="YBx-pZ-bPA"/> + <binding destination="-2" name="value" keyPath="self.picture.width" id="Dr6-U5-h7T"> + <dictionary key="options"> + <integer key="NSNullPlaceholder" value="0"/> + <bool key="NSValidatesImmediately" value="YES"/> + </dictionary> + </binding> </connections> </textField> <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="46"> @@ -212,7 +257,9 @@ <font key="font" metaFont="smallSystem"/> </stepperCell> <connections> - <action selector="settingsChanged:" target="-2" id="77Y-D7-WA9"/> + <binding destination="-2" name="value" keyPath="self.picture.height" previousBinding="nJk-wN-aaB" id="l4c-7G-SMf"/> + <binding destination="-2" name="enabled" keyPath="self.picture.heightEditable" id="Fdi-IK-Y16"/> + <binding destination="-2" name="maxValue" keyPath="self.picture.maxHeight" id="nJk-wN-aaB"/> </connections> </stepper> <textField verticalHuggingPriority="750" id="138"> @@ -236,19 +283,19 @@ <popUpButton verticalHuggingPriority="750" id="132"> <rect key="frame" x="75" y="38" width="80" height="15"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="135" id="173"> + <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" inset="2" id="173"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="miniSystem"/> <menu key="menu" title="OtherViews" id="134"> <items> - <menuItem title="Item 1" state="on" id="135"/> + <menuItem title="Item 1" id="135"/> <menuItem title="Item 2" id="136"/> <menuItem title="Item 3" id="137"/> </items> </menu> </popUpButtonCell> <connections> - <action selector="settingsChanged:" target="-2" id="OGE-xz-yb7"/> + <binding destination="-2" name="selectedIndex" keyPath="self.picture.anamorphicMode" id="nZC-Kh-dDe"/> </connections> </popUpButton> <textField verticalHuggingPriority="750" id="390"> @@ -284,7 +331,13 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="settingsChanged:" target="-2" id="hfw-v1-XQB"/> + <binding destination="-2" name="editable" keyPath="self.picture.heightEditable" id="Je1-xf-WNB"/> + <binding destination="-2" name="value" keyPath="self.picture.height" id="T7h-fp-Qs6"> + <dictionary key="options"> + <integer key="NSNullPlaceholder" value="0"/> + <bool key="NSValidatesImmediately" value="YES"/> + </dictionary> + </binding> </connections> </textField> <button id="45"> @@ -295,7 +348,8 @@ <font key="font" metaFont="smallSystem"/> </buttonCell> <connections> - <action selector="settingsChanged:" target="-2" id="urF-IM-OfA"/> + <binding destination="-2" name="value" keyPath="self.picture.keepDisplayAspect" id="8uc-2H-rkz"/> + <binding destination="-2" name="enabled" keyPath="self.picture.keepDisplayAspectEditable" id="DSI-Ra-G0d"/> </connections> </button> </subviews> @@ -317,7 +371,13 @@ <font key="font" metaFont="smallSystem"/> </stepperCell> <connections> - <action selector="settingsChanged:" target="-2" id="gih-EE-fLI"/> + <binding destination="-2" name="maxValue" keyPath="self.picture.maxVerticalCrop" id="9ff-Ns-69S"/> + <binding destination="-2" name="enabled" keyPath="self.picture.autocrop" id="Vp0-sU-c5s"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.picture.cropTop" previousBinding="9ff-Ns-69S" id="4Cj-4f-6FM"/> </connections> </stepper> <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="15"> @@ -325,10 +385,16 @@ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <stepperCell key="cell" controlSize="small" continuous="YES" alignment="left" increment="2" maxValue="59" id="155"> <font key="font" metaFont="smallSystem"/> - <connections> - <action selector="settingsChanged:" target="-2" id="pwP-2b-uZ1"/> - </connections> </stepperCell> + <connections> + <binding destination="-2" name="maxValue" keyPath="self.picture.maxHorizontalCrop" id="39d-dv-rDM"/> + <binding destination="-2" name="enabled" keyPath="self.picture.autocrop" id="5QD-Dh-bzl"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.picture.cropRight" previousBinding="39d-dv-rDM" id="OUg-17-HR9"/> + </connections> </stepper> <matrix verticalHuggingPriority="750" allowsEmptySelection="NO" autosizesCells="NO" id="16"> <rect key="frame" x="64" y="92" width="90" height="31"/> @@ -353,7 +419,11 @@ </column> </cells> <connections> - <action selector="settingsChanged:" target="-2" id="dUb-Ct-S9f"/> + <binding destination="-2" name="selectedIndex" keyPath="self.picture.autocrop" id="9wD-y3-pVM"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> </connections> </matrix> <textField verticalHuggingPriority="750" id="13"> @@ -365,7 +435,17 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="settingsChanged:" target="-2" id="LEd-0c-EqV"/> + <binding destination="-2" name="enabled" keyPath="self.picture.autocrop" id="DlH-KY-uVi"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.picture.cropTop" id="ABP-Q9-NDw"> + <dictionary key="options"> + <string key="NSNullPlaceholder">0</string> + <bool key="NSValidatesImmediately" value="YES"/> + </dictionary> + </binding> </connections> </textField> <textField verticalHuggingPriority="750" id="10"> @@ -377,7 +457,17 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="settingsChanged:" target="-2" id="txb-hc-ans"/> + <binding destination="-2" name="enabled" keyPath="self.picture.autocrop" id="Hai-0I-6yj"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.picture.cropBottom" id="nVf-lw-Tr1"> + <dictionary key="options"> + <string key="NSNullPlaceholder">0</string> + <bool key="NSValidatesImmediately" value="YES"/> + </dictionary> + </binding> </connections> </textField> <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="19"> @@ -385,10 +475,16 @@ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <stepperCell key="cell" controlSize="small" continuous="YES" alignment="left" increment="2" maxValue="59" id="156"> <font key="font" metaFont="smallSystem"/> - <connections> - <action selector="settingsChanged:" target="-2" id="Ds0-vg-mpO"/> - </connections> </stepperCell> + <connections> + <binding destination="-2" name="maxValue" keyPath="self.picture.maxHorizontalCrop" id="2Rh-om-NkW"/> + <binding destination="-2" name="enabled" keyPath="self.picture.autocrop" id="WmV-2A-EDo"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.picture.cropLeft" previousBinding="2Rh-om-NkW" id="hk3-CS-WKR"/> + </connections> </stepper> <textField verticalHuggingPriority="750" id="9"> <rect key="frame" x="194" y="56" width="36" height="16"/> @@ -399,7 +495,17 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="settingsChanged:" target="-2" id="FQT-HE-w3X"/> + <binding destination="-2" name="enabled" keyPath="self.picture.autocrop" id="yw7-7Q-sse"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.picture.cropRight" id="lou-1C-A2w"> + <dictionary key="options"> + <string key="NSNullPlaceholder">0</string> + <bool key="NSValidatesImmediately" value="YES"/> + </dictionary> + </binding> </connections> </textField> <textField verticalHuggingPriority="750" id="11"> @@ -411,7 +517,17 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="settingsChanged:" target="-2" id="JTs-h7-4xm"/> + <binding destination="-2" name="enabled" keyPath="self.picture.autocrop" id="egn-yP-dYe"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.picture.cropLeft" id="ste-Ks-OLX"> + <dictionary key="options"> + <string key="NSNullPlaceholder">0</string> + <bool key="NSValidatesImmediately" value="YES"/> + </dictionary> + </binding> </connections> </textField> <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="14"> @@ -419,10 +535,16 @@ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <stepperCell key="cell" controlSize="small" continuous="YES" alignment="left" increment="2" maxValue="59" id="154"> <font key="font" metaFont="smallSystem"/> - <connections> - <action selector="settingsChanged:" target="-2" id="e3a-Lo-Umb"/> - </connections> </stepperCell> + <connections> + <binding destination="-2" name="maxValue" keyPath="self.picture.maxVerticalCrop" id="jS8-Tg-h3O"/> + <binding destination="-2" name="enabled" keyPath="self.picture.autocrop" id="soK-UE-pde"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.picture.cropBottom" previousBinding="jS8-Tg-h3O" id="k6f-Bd-Crr"/> + </connections> </stepper> <textField verticalHuggingPriority="750" id="382"> <rect key="frame" x="3" y="107" width="59" height="17"/> @@ -896,7 +1018,8 @@ <connections> <outlet property="delegate" destination="-2" id="hby-dR-NFK"/> </connections> - <point key="canvasLocation" x="182.5" y="419"/> + <point key="canvasLocation" x="-1.5" y="238"/> </window> + <userDefaultsController representsSharedInstance="YES" id="vUw-ux-GVV"/> </objects> </document> diff --git a/macosx/HBPreviewController.h b/macosx/HBPreviewController.h index ed7fd19ab..36a71faed 100644 --- a/macosx/HBPreviewController.h +++ b/macosx/HBPreviewController.h @@ -5,19 +5,22 @@ It may be used under the terms of the GNU General Public License. */ #import <Cocoa/Cocoa.h> -#include "hb.h" @class HBController; -@interface HBPreviewController : NSWindowController <NSWindowDelegate> +@class HBCore; +@class HBJob; -@property (nonatomic) BOOL deinterlacePreview; -@property (nonatomic, readonly) NSString *pictureSizeInfoString; +@interface HBPreviewController : NSWindowController <NSWindowDelegate> @property (nonatomic, assign) HBController *delegate; -@property (nonatomic, assign) hb_handle_t *handle; -@property (nonatomic, assign) hb_title_t *title; - -- (void) reload; +@property (nonatomic, assign) HBCore *core; +@property (nonatomic, assign) HBJob *job; + +/** + * Reloads the preview images. + * Usually called after a picture setting changes. + */ +- (void)reloadPreviews; @end diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m index 2d4174ef7..21cc58f33 100644 --- a/macosx/HBPreviewController.m +++ b/macosx/HBPreviewController.m @@ -10,6 +10,9 @@ #import "Controller.h" #import <QTKit/QTKit.h> +#import "HBPicture.h" +#import "HBJob.h" + @implementation QTMovieView (HBQTMovieViewExtensions) - (void) mouseMoved: (NSEvent *) theEvent @@ -228,18 +231,18 @@ typedef enum ViewMode : NSUInteger { self.backingScaleFactor = 1.0; } -- (void) setTitle: (hb_title_t *) title +- (void) setJob:(HBJob *)job { - _title = title; + _job = job; self.generator.delegate = nil; [self.generator cancel]; self.generator = nil; - if (_title) + if (job) { /* alloc and init a generator for the current title */ - self.generator = [[[HBPreviewGenerator alloc] initWithHandle:self.handle andTitle:self.title] autorelease]; + self.generator = [[[HBPreviewGenerator alloc] initWithCore:self.core job:self.job] autorelease]; /* adjust the preview slider length */ [fPictureSlider setMaxValue: self.generator.imagesCount - 1.0]; @@ -250,9 +253,9 @@ typedef enum ViewMode : NSUInteger { } } -- (void) reload +- (void) reloadPreviews { - if (self.title) + if (self.job) { // Purge the existing picture previews so they get recreated the next time // they are needed. @@ -264,12 +267,16 @@ typedef enum ViewMode : NSUInteger { - (void) showWindow: (id) sender { + [super showWindow:sender]; + if (self.currentViewMode == ViewModeMoviePreview) { [self startMovieTimer]; } - - [super showWindow:sender]; + else + { + [self reloadPreviews]; + } } - (void) windowWillClose: (NSNotification *) aNotification @@ -302,8 +309,8 @@ typedef enum ViewMode : NSUInteger { // Scale factor changed, update the preview window // to the new situation self.backingScaleFactor = newBackingScaleFactor; - if (self.title) - [self reload]; + if (self.job) + [self reloadPreviews]; } } @@ -546,7 +553,7 @@ typedef enum ViewMode : NSUInteger { NSPoint mouseLoc = [theEvent locationInWindow]; /* Test for mouse location to show/hide hud controls */ - if (self.currentViewMode != ViewModeEncoding && self.title) + if (self.currentViewMode != ViewModeEncoding && self.job) { /* Since we are not encoding, verify which control hud to show * or hide based on aMovie ( aMovie indicates we need movie controls ) @@ -665,46 +672,18 @@ typedef enum ViewMode : NSUInteger { */ - (void) displayPreview { - hb_title_t *title = self.title; - - NSImage *fPreviewImage = [self.generator imageAtIndex:self.pictureIndex shouldCache:YES]; - NSSize imageScaledSize = [fPreviewImage size]; - [self.pictureLayer setContents:fPreviewImage]; + if (self.window.isVisible) + { + NSImage *fPreviewImage = [self.generator imageAtIndex:self.pictureIndex shouldCache:YES]; + [self.pictureLayer setContents:fPreviewImage]; + } - NSSize displaySize = NSMakeSize( ( CGFloat )title->geometry.width, ( CGFloat )title->geometry.height ); - NSString *sizeInfoString; + HBPicture *pict = self.job.picture; /* Set the picture size display fields below the Preview Picture*/ - int display_width; - display_width = title->job->width * title->job->par.num / title->job->par.den; - if (title->job->anamorphic.mode == HB_ANAMORPHIC_STRICT) // Original PAR Implementation - { - sizeInfoString = [NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Strict", - title->geometry.width, title->geometry.height, title->job->width, title->job->height, display_width, title->job->height]; - } - else if (title->job->anamorphic.mode == HB_ANAMORPHIC_LOOSE) // Loose Anamorphic - { - sizeInfoString = [NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Loose", - title->geometry.width, title->geometry.height, title->job->width, title->job->height, display_width, title->job->height]; - } - else if (title->job->anamorphic.mode == HB_ANAMORPHIC_CUSTOM) // Custom Anamorphic - { - sizeInfoString = [NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Custom", - title->geometry.width, title->geometry.height, title->job->width, title->job->height, display_width, title->job->height]; - } - else // No Anamorphic - { - sizeInfoString = [NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d", - title->geometry.width, title->geometry.height, title->job->width, title->job->height]; - } - displaySize.width = display_width; - displaySize.height = title->job->height; - imageScaledSize.width = display_width; - imageScaledSize.height = title->job->height; + int display_width = pict.width * pict.parWidth / pict.parHeight; + NSSize imageScaledSize = NSMakeSize(display_width, pict.height); + NSSize displaySize = NSMakeSize(display_width, pict.height); if (self.backingScaleFactor != 1.0) { @@ -793,13 +772,13 @@ typedef enum ViewMode : NSUInteger { /* Set the info fields in the hud controller */ [fInfoField setStringValue: [NSString stringWithFormat: - @"%@", sizeInfoString]]; + @"%@", self.job.picture.info]]; [fscaleInfoField setStringValue: [NSString stringWithFormat: @"%@", scaleString]]; /* Set the info field in the window title bar */ - [[self window] setTitle:[NSString stringWithFormat: @"Preview - %@ %@",sizeInfoString, scaleString]]; + [[self window] setTitle:[NSString stringWithFormat: @"Preview - %@ %@", self.job.picture.info, scaleString]]; } - (IBAction) previewDurationPopUpChanged: (id) sender @@ -807,15 +786,9 @@ typedef enum ViewMode : NSUInteger { [[NSUserDefaults standardUserDefaults] setObject:[fPreviewMovieLengthPopUp titleOfSelectedItem] forKey:@"PreviewLength"]; } -- (void) setDeinterlacePreview: (BOOL) deinterlacePreview -{ - _deinterlacePreview = deinterlacePreview; - self.generator.deinterlace = deinterlacePreview; -} - - (IBAction) pictureSliderChanged: (id) sender { - if ((self.pictureIndex != [fPictureSlider intValue] || !sender) && self.title) { + if ((self.pictureIndex != [fPictureSlider intValue] || !sender) && self.job) { self.pictureIndex = [fPictureSlider intValue]; [self displayPreview]; } @@ -839,11 +812,6 @@ typedef enum ViewMode : NSUInteger { } } -- (NSString *) pictureSizeInfoString -{ - return [fInfoField stringValue]; -} - - (IBAction) showPictureSettings: (id) sender { [self.delegate showPicturePanel:self]; diff --git a/macosx/HBPreviewGenerator.h b/macosx/HBPreviewGenerator.h index 72e3b5153..c8219bc54 100644 --- a/macosx/HBPreviewGenerator.h +++ b/macosx/HBPreviewGenerator.h @@ -5,7 +5,9 @@ It may be used under the terms of the GNU General Public License. */ #import <Cocoa/Cocoa.h> -#include "hb.h" + +@class HBCore; +@class HBJob; @protocol HBPreviewGeneratorDelegate <NSObject> @@ -19,9 +21,8 @@ @interface HBPreviewGenerator : NSObject @property (nonatomic, assign) id <HBPreviewGeneratorDelegate> delegate; -@property (nonatomic) BOOL deinterlace; -- (id) initWithHandle: (hb_handle_t *) handle andTitle: (hb_title_t *) title; +- (instancetype)initWithCore:(HBCore *)core job:(HBJob *)job; /* Still image generator */ - (NSImage *) imageAtIndex: (NSUInteger) index shouldCache: (BOOL) cache; diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m index 3e9adbe9b..f089ade22 100644 --- a/macosx/HBPreviewGenerator.m +++ b/macosx/HBPreviewGenerator.m @@ -7,9 +7,11 @@ #import "HBPreviewGenerator.h" #import "HBUtilities.h" -#import "HBCore.h" #import "Controller.h" +#import "HBCore.h" +#import "HBJob.h" + typedef enum EncodeState : NSUInteger { EncodeStateIdle, EncodeStateWorking, @@ -20,8 +22,8 @@ typedef enum EncodeState : NSUInteger { @property (nonatomic, readonly, retain) NSMutableDictionary *picturePreviews; @property (nonatomic, readonly) NSUInteger imagesCount; -@property (nonatomic, readonly) hb_handle_t *handle; -@property (nonatomic, readonly) hb_title_t *title; +@property (nonatomic, readonly) HBCore *scanCore; +@property (nonatomic, readonly) HBJob *job; @property (nonatomic) HBCore *core; @property (nonatomic, getter=isCancelled) BOOL cancelled; @@ -33,13 +35,13 @@ typedef enum EncodeState : NSUInteger { @implementation HBPreviewGenerator -- (id) initWithHandle: (hb_handle_t *) handle andTitle: (hb_title_t *) title +- (instancetype)initWithCore:(HBCore *)core job:(HBJob *)job { self = [super init]; if (self) { - _handle = handle; - _title = title; + _scanCore = core; + _job = job; _picturePreviews = [[NSMutableDictionary alloc] init]; _imagesCount = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue]; } @@ -65,10 +67,13 @@ typedef enum EncodeState : NSUInteger { if (!theImage) { + HBFilters *filters = self.job.filters; + BOOL deinterlace = (filters.deinterlace && !filters.useDecomb) || (filters.decomb && filters.useDecomb); + theImage = [HBPreviewGenerator makeImageForPicture:index - libhb:self.handle - title:self.title - deinterlace:self.deinterlace]; + libhb:self.scanCore.hb_handle + picture:self.job.picture + deinterlace:deinterlace]; if (cache && theImage) [self.picturePreviews setObject:theImage forKey:@(index)]; } @@ -99,23 +104,24 @@ typedef enum EncodeState : NSUInteger { */ + (NSImage *) makeImageForPicture: (NSUInteger) pictureIndex libhb: (hb_handle_t *) handle - title: (hb_title_t *) title + picture: (HBPicture *) picture deinterlace: (BOOL) deinterlace { NSImage *img = nil; hb_geometry_settings_t geo; memset(&geo, 0, sizeof(geo)); - geo.geometry.width = title->job->width; - geo.geometry.height = title->job->height; + geo.geometry.width = picture.width; + geo.geometry.height = picture.height; // HBPreviewController will scale the image later, // ignore the par. geo.geometry.par.num = 1; geo.geometry.par.den = 1; - memcpy(geo.crop, title->job->crop, sizeof(int[4])); + int crop[4] = {picture.cropTop, picture.cropBottom, picture.cropLeft, picture.cropRight}; + memcpy(geo.crop, crop, sizeof(int[4])); hb_image_t *image; - image = hb_get_preview2(handle, title->index, (int)pictureIndex, &geo, deinterlace); + image = hb_get_preview2(handle, picture.title.hb_title->index, (int)pictureIndex, &geo, deinterlace); if (image) { @@ -196,7 +202,7 @@ typedef enum EncodeState : NSUInteger { if (self.core || index >= self.imagesCount) return NO; - hb_job_t *job = self.title->job; + hb_job_t *job = self.job.title.hb_title->job; /* Generate the file url and directories. */ if (job->mux & HB_MUX_MASK_MP4) @@ -235,6 +241,7 @@ typedef enum EncodeState : NSUInteger { int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue]; self.core = [[[HBCore alloc] initWithLoggingLevel:loggingLevel] autorelease]; + self.core.name = @"PreviewCore"; /* * If scanning we need to do some extra setup of the job. diff --git a/macosx/PictureController.h b/macosx/PictureController.h index 777868efb..c2ea23d5c 100644 --- a/macosx/PictureController.h +++ b/macosx/PictureController.h @@ -5,28 +5,23 @@ It may be used under the terms of the GNU General Public License. */ #import <Cocoa/Cocoa.h> + #import "HBFilters.h" -#include "hb.h" +#import "HBPicture.h" @protocol HBPictureControllerDelegate <NSObject> -- (void) pictureSettingsDidChange; +- (IBAction)showPreviewWindow:(id)sender; @end @interface HBPictureController : NSWindowController <NSWindowDelegate> @property (nonatomic, readwrite, retain) HBFilters *filters; -@property (nonatomic, readwrite) BOOL autoCrop; +@property (nonatomic, readwrite, retain) HBPicture *picture; @property (nonatomic, readwrite, assign) id <HBPictureControllerDelegate> delegate; -- (void) setHandle:(hb_handle_t *) handle; -- (void) setTitle:(hb_title_t *) title; - -- (IBAction) showPictureWindow: (id)sender; -- (IBAction) showPreviewWindow: (id)sender; - -- (NSString *) pictureSizeInfoString; +- (void)showPictureWindow; @end diff --git a/macosx/PictureController.m b/macosx/PictureController.m index 779cff60e..c1a813ae5 100644 --- a/macosx/PictureController.m +++ b/macosx/PictureController.m @@ -8,6 +8,8 @@ #import "PictureController.h" #import "HBPreviewController.h" +#import "HBTitle.h" + @interface HBCustomFilterTransformer : NSValueTransformer @end @@ -37,44 +39,14 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; @interface HBPictureController () { - hb_title_t * fTitle; - - HBPreviewController * fPreviewController; - /* Picture Sizing */ IBOutlet NSTabView * fSizeFilterView; IBOutlet NSBox * fPictureSizeBox; IBOutlet NSBox * fPictureCropBox; - IBOutlet NSTextField * fWidthField; + IBOutlet NSPopUpButton * fAnamorphicPopUp; IBOutlet NSStepper * fWidthStepper; - IBOutlet NSTextField * fHeightField; IBOutlet NSStepper * fHeightStepper; - IBOutlet NSTextField * fRatioLabel; - IBOutlet NSButton * fRatioCheck; - IBOutlet NSMatrix * fCropMatrix; - IBOutlet NSTextField * fCropTopField; - IBOutlet NSStepper * fCropTopStepper; - IBOutlet NSTextField * fCropBottomField; - IBOutlet NSStepper * fCropBottomStepper; - IBOutlet NSTextField * fCropLeftField; - IBOutlet NSStepper * fCropLeftStepper; - IBOutlet NSTextField * fCropRightField; - IBOutlet NSStepper * fCropRightStepper; - - IBOutlet NSTextField * fModulusLabel; - IBOutlet NSPopUpButton * fModulusPopUp; - - IBOutlet NSTextField * fDisplayWidthField; - IBOutlet NSTextField * fDisplayWidthLabel; - - IBOutlet NSTextField * fParWidthField; - IBOutlet NSTextField * fParHeightField; - IBOutlet NSTextField * fParWidthLabel; - IBOutlet NSTextField * fParHeightLabel; - - IBOutlet NSPopUpButton * fAnamorphicPopUp; - IBOutlet NSTextField * fSizeInfoField; /* Video Filters */ IBOutlet NSBox * fDetelecineBox; @@ -101,6 +73,7 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; if (self = [super initWithWindowNibName:@"PictureSettings"]) { _filters = [[HBFilters alloc] init]; + _picture = [[HBPicture alloc] init]; // NSWindowController likes to lazily load its window. However since // this controller tries to set all sorts of outlets before the window @@ -113,18 +86,15 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; [self window]; // Add the observers for the filters values - NSArray *observerdKeyPaths = @[@"filters.detelecine", @"filters.detelecineCustomString", - @"filters.deinterlace", @"filters.deinterlaceCustomString", - @"filters.decomb", @"filters.decombCustomString", - @"filters.denoise", @"filters.denoisePreset", - @"filters.denoiseTune", @"filters.denoiseCustomString", - @"filters.deblock", @"filters.grayscale", @"filters.useDecomb"]; + NSArray *observerdKeyPaths = @[@"self.filters.useDecomb", @"self.filters.deblock", + @"self.filters.denoise", @"self.filters.denoisePreset"]; for (NSString *keyPath in observerdKeyPaths) { [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionInitial context:HBPictureControllerContext]; } - fPreviewController = [[HBPreviewController alloc] init]; + [self addObserver:self forKeyPath:@"self.picture.anamorphicMode" options:NSKeyValueObservingOptionInitial context:HBPictureControllerContext]; + [self addObserver:self forKeyPath:@"self.picture.modulus" options:NSKeyValueObservingOptionInitial context:HBPictureControllerContext]; } return self; @@ -132,12 +102,8 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; - (void) dealloc { - NSArray *observerdKeyPaths = @[@"filters.detelecine", @"filters.detelecineCustomString", - @"filters.deinterlace", @"filters.deinterlaceCustomString", - @"filters.decomb", @"filters.decombCustomString", - @"filters.denoise", @"filters.denoisePreset", - @"filters.denoiseTune", @"filters.denoiseCustomString", - @"filters.deblock", @"filters.grayscale", @"filters.useDecomb"]; + NSArray *observerdKeyPaths = @[@"self.filters.useDecomb", @"self.filters.deblock", + @"self.filters.denoise", @"self.filters.denoisePreset"]; @try { for (NSString *keyPath in observerdKeyPaths) { @@ -146,8 +112,9 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; } @catch (NSException * __unused exception) {} - [_filters release]; - [fPreviewController release]; + self.filters = nil; + self.picture = nil; + [super dealloc]; } @@ -161,157 +128,14 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; [self.window setAppearance:[NSClassFromString(@"NSAppearance") appearanceNamed:@"NSAppearanceNameAqua"]]; } - /* Populate the user interface */ - [fWidthStepper setValueWraps: NO]; - [fHeightStepper setValueWraps: NO]; - - [fCropTopStepper setIncrement: 2]; - [fCropTopStepper setMinValue: 0]; - [fCropBottomStepper setIncrement: 2]; - [fCropBottomStepper setMinValue: 0]; - [fCropLeftStepper setIncrement: 2]; - [fCropLeftStepper setMinValue: 0]; - [fCropRightStepper setIncrement: 2]; - [fCropRightStepper setMinValue: 0]; - /* Populate the Anamorphic NSPopUp button here */ [fAnamorphicPopUp removeAllItems]; [fAnamorphicPopUp addItemsWithTitles:@[@"None", @"Strict", @"Loose", @"Custom"]]; - /* populate the modulus popup here */ - [fModulusPopUp removeAllItems]; - [fModulusPopUp addItemsWithTitles:@[@"16", @"8", @"4", @"2"]]; - [self resizeInspectorForTab:nil]; [self adjustSizingDisplay:nil]; } -- (void) setHandle: (hb_handle_t *) handle -{ - [fPreviewController setHandle: handle]; - [fPreviewController setDelegate:(HBController *)self.delegate]; -} - -- (void) setTitle: (hb_title_t *) title -{ - fTitle = title; - - if (!title) { - [fPreviewController setTitle:NULL]; - return; - } - - hb_job_t * job = title->job; - - fTitle = title; - - [fAnamorphicPopUp selectItemAtIndex: job->anamorphic.mode]; - if (job->anamorphic.mode == HB_ANAMORPHIC_STRICT) - { - [fWidthStepper setEnabled: NO]; - [fHeightStepper setEnabled: NO]; - [fWidthField setEditable:NO]; - [fHeightField setEditable:NO]; - } - else - { - [fWidthStepper setEnabled: YES]; - [fHeightStepper setEnabled: YES]; - [fWidthField setEditable:YES]; - [fHeightField setEditable:YES]; - } - if (job->anamorphic.mode == HB_ANAMORPHIC_STRICT || - job->anamorphic.mode == HB_ANAMORPHIC_LOOSE) - { - job->anamorphic.keep_display_aspect = 1; - [fRatioCheck setState: NSOnState]; - [fRatioCheck setEnabled: NO]; - } - else - { - [fRatioCheck setEnabled: YES]; - [fRatioCheck setState: job->anamorphic.keep_display_aspect ? - NSOnState : NSOffState]; - } - [fParWidthField setEnabled: !job->anamorphic.keep_display_aspect]; - [fParHeightField setEnabled: !job->anamorphic.keep_display_aspect]; - [fDisplayWidthField setEnabled: !job->anamorphic.keep_display_aspect]; - - if (job->modulus) - { - [fModulusPopUp selectItemWithTitle: [NSString stringWithFormat:@"%d",job->modulus]]; - [fWidthStepper setIncrement: job->modulus]; - [fHeightStepper setIncrement: job->modulus]; - } - else - { - [fModulusPopUp selectItemAtIndex: 0]; - [fWidthStepper setIncrement: 16]; - [fHeightStepper setIncrement: 16]; - } - - if (self.autoCrop) - { - [fCropMatrix selectCellAtRow: 0 column:0]; - - /* If auto, lets set the crop steppers according to - * current fTitle->crop values */ - memcpy( job->crop, fTitle->crop, 4 * sizeof( int ) ); - [fCropTopStepper setIntValue: fTitle->crop[0]]; - [fCropTopField setIntValue: fTitle->crop[0]]; - [fCropBottomStepper setIntValue: fTitle->crop[1]]; - [fCropBottomField setIntValue: fTitle->crop[1]]; - [fCropLeftStepper setIntValue: fTitle->crop[2]]; - [fCropLeftField setIntValue: fTitle->crop[2]]; - [fCropRightStepper setIntValue: fTitle->crop[3]]; - [fCropRightField setIntValue: fTitle->crop[3]]; - } - else - { - [fCropMatrix selectCellAtRow: 1 column:0]; - [fCropTopStepper setIntValue: job->crop[0]]; - [fCropTopField setIntValue: job->crop[0]]; - [fCropBottomStepper setIntValue: job->crop[1]]; - [fCropBottomField setIntValue: job->crop[1]]; - [fCropLeftStepper setIntValue: job->crop[2]]; - [fCropLeftField setIntValue: job->crop[2]]; - [fCropRightStepper setIntValue: job->crop[3]]; - [fCropRightField setIntValue: job->crop[3]]; - } - - [fCropTopStepper setEnabled: !self.autoCrop]; - [fCropBottomStepper setEnabled: !self.autoCrop]; - [fCropLeftStepper setEnabled: !self.autoCrop]; - [fCropRightStepper setEnabled: !self.autoCrop]; - - [fCropTopField setEditable: !self.autoCrop]; - [fCropBottomField setEditable: !self.autoCrop]; - [fCropLeftField setEditable: !self.autoCrop]; - [fCropRightField setEditable: !self.autoCrop]; - - [fWidthStepper setMaxValue: title->geometry.width - job->crop[2] - job->crop[3]]; - [fWidthStepper setIntValue: job->width]; - [fWidthField setIntValue: job->width]; - [fHeightStepper setMaxValue: title->geometry.height - job->crop[0] - job->crop[1]]; - [fHeightStepper setIntValue: job->height]; - [fHeightField setIntValue: job->height]; - [fCropTopStepper setMaxValue: title->geometry.height/2-2]; - [fCropBottomStepper setMaxValue: title->geometry.height/2-2]; - [fCropLeftStepper setMaxValue: title->geometry.width/2-2]; - [fCropRightStepper setMaxValue: title->geometry.width/2-2]; - - [fParWidthField setIntValue: job->par.num]; - [fParHeightField setIntValue: job->par.den]; - - int display_width; - display_width = job->width * job->par.num / job->par.den; - [fDisplayWidthField setIntValue: display_width]; - - [fPreviewController setTitle:title]; - - [self settingsChanged:nil]; -} - #pragma mark - KVO - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context @@ -320,8 +144,18 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; { // We use KVO to update the panel // and notify the main controller of the changes - // in the filters settings. - if ([keyPath isEqualToString:@"filters.useDecomb"]) + // in the filters and picture settings. + + if ([keyPath isEqualToString:@"self.picture.anamorphicMode"]) + { + [self adjustSizingDisplay:nil]; + } + else if ([keyPath isEqualToString:@"self.picture.modulus"]) + { + [fWidthStepper setIncrement:self.picture.modulus]; + [fHeightStepper setIncrement:self.picture.modulus]; + } + else if ([keyPath isEqualToString:@"self.filters.useDecomb"]) { if (self.filters.useDecomb) { @@ -334,7 +168,7 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; [fDeinterlaceBox setHidden:NO]; } } - else if ([keyPath isEqualToString:@"filters.deblock"]) + else if ([keyPath isEqualToString:@"self.filters.deblock"]) { // The minimum deblock value is 5, // set it to 0 if the value is @@ -349,32 +183,10 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; [fDeblockField setStringValue:[NSString stringWithFormat: @"%.0ld", (long)self.filters.deblock]]; } } - else if ([keyPath isEqualToString:@"filters.deinterlace"] || [keyPath isEqualToString:@"filters.decomb"]) - { - // Might need to update the preview images with - // the new deinterlace/decomb setting. - if ((self.filters.deinterlace && !self.filters.useDecomb) || - (self.filters.decomb && self.filters.useDecomb)) - { - fPreviewController.deinterlacePreview = YES; - } - else - { - fPreviewController.deinterlacePreview = NO; - } - [fPreviewController reload]; - } - else if ([keyPath isEqualToString:@"filters.denoise"] || [keyPath isEqualToString:@"filters.denoisePreset"]) + else if ([keyPath isEqualToString:@"self.filters.denoise"] || [keyPath isEqualToString:@"self.filters.denoisePreset"]) { [self validateDenoiseUI]; } - - // If one of the filters properties changes - // update the UI in the main window - if ([keyPath hasPrefix:@"filters"]) - { - [self.delegate pictureSettingsDidChange]; - } } else { @@ -430,6 +242,14 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; #pragma mark Interface Resize /** + * This method is used to detect clicking on a tab in fSizeFilterView + */ +- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem +{ + [self resizeInspectorForTab:nil]; +} + +/** * resizeInspectorForTab is called at launch, and each time either the * Size or Filters tab is clicked. Size gives a horizontally oriented * inspector and Filters is a vertically aligned inspector. @@ -491,26 +311,10 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; if ([fAnamorphicPopUp indexOfSelectedItem] == HB_ANAMORPHIC_CUSTOM) { // custom / power user jamboree pictureSizingBoxSize.width = 350; - - /* Set visibility of capuj widgets */ - [fParWidthField setHidden: NO]; - [fParHeightField setHidden: NO]; - [fParWidthLabel setHidden: NO]; - [fParHeightLabel setHidden: NO]; - [fDisplayWidthField setHidden: NO]; - [fDisplayWidthLabel setHidden: NO]; } else { pictureSizingBoxSize.width = 200; - - /* Set visibility of capuj widgets */ - [fParWidthField setHidden: YES]; - [fParHeightField setHidden: YES]; - [fParWidthLabel setHidden: YES]; - [fParHeightLabel setHidden: YES]; - [fDisplayWidthField setHidden: YES]; - [fDisplayWidthLabel setHidden: YES]; } /* Check to see if we have changed the size from current */ @@ -541,17 +345,12 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; [self resizeInspectorForTab:nil]; } -- (NSString *) pictureSizeInfoString -{ - return [fSizeInfoField stringValue]; -} - #pragma mark - /** * Displays and brings the picture window to the front */ -- (IBAction) showPictureWindow: (id) sender +- (void)showPictureWindow { if ([[self window] isVisible]) { @@ -559,15 +358,8 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; } else { - [self showWindow:sender]; + [self showWindow:self]; [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PictureSizeWindowIsOpen"]; - /* Set the window back to Floating Window mode - * This will put the window always on top, but - * since we have Hide on Deactivate set in our - * xib, if other apps are put in focus we will - * hide properly to stay out of the way - */ - [[self window] setLevel:NSFloatingWindowLevel]; } [self resizeInspectorForTab:nil]; @@ -576,8 +368,7 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; - (IBAction) showPreviewWindow: (id) sender { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PreviewWindowIsOpen"]; - [fPreviewController showWindow:sender]; + [self.delegate showPreviewWindow:sender]; } - (void) windowWillClose: (NSNotification *)aNotification @@ -585,285 +376,4 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PictureSizeWindowIsOpen"]; } -/** - * This method is used to detect clicking on a tab in fSizeFilterView - */ -- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem -{ - [self resizeInspectorForTab:nil]; -} - -#pragma mark - Picture Update Logic - -- (IBAction) settingsChanged: (id) sender -{ - if (!fTitle) - return; - - hb_job_t * job = fTitle->job; - int keep = 0, dar_updated = 0; - - if (sender == fAnamorphicPopUp) - { - job->anamorphic.mode = (int)[fAnamorphicPopUp indexOfSelectedItem]; - if (job->anamorphic.mode == HB_ANAMORPHIC_STRICT) - { - [fModulusLabel setHidden: YES]; - [fModulusPopUp setHidden: YES]; - [fWidthStepper setEnabled: NO]; - [fHeightStepper setEnabled: NO]; - [fWidthField setEditable:NO]; - [fHeightField setEditable:NO]; - } - else - { - [fModulusLabel setHidden: NO]; - [fModulusPopUp setHidden: NO]; - [fWidthStepper setEnabled: YES]; - [fHeightStepper setEnabled: YES]; - [fWidthField setEditable:YES]; - [fHeightField setEditable:YES]; - } - if (job->anamorphic.mode == HB_ANAMORPHIC_STRICT || - job->anamorphic.mode == HB_ANAMORPHIC_LOOSE) - { - job->anamorphic.keep_display_aspect = 1; - [fRatioCheck setState: NSOnState]; - [fRatioCheck setEnabled: NO]; - } - else - { - [fRatioCheck setEnabled: YES]; - [fRatioCheck setState: job->anamorphic.keep_display_aspect ? - NSOnState : NSOffState]; - } - } - else if (sender == fModulusPopUp) - { - job->modulus = [[fModulusPopUp titleOfSelectedItem] intValue]; - [fWidthStepper setIncrement: job->modulus]; - [fHeightStepper setIncrement: job->modulus]; - } - - if (sender == fRatioCheck) - { - job->anamorphic.keep_display_aspect = [fRatioCheck state] == NSOnState; - [fParWidthField setEnabled: !job->anamorphic.keep_display_aspect]; - [fParHeightField setEnabled: !job->anamorphic.keep_display_aspect]; - [fDisplayWidthField setEnabled: !job->anamorphic.keep_display_aspect]; - } - - if (sender == fHeightStepper || sender == fHeightField) - { - keep |= HB_KEEP_HEIGHT; - - if (sender == fHeightStepper) - job->height = [fHeightStepper intValue]; - else - job->height = [fHeightField intValue]; - } - - if (sender == fWidthStepper || sender == fWidthField) - { - keep |= HB_KEEP_WIDTH; - - if (sender == fWidthStepper) - job->width = [fWidthStepper intValue]; - else - job->width = [fWidthField intValue]; - } - - if (sender == fParWidthField || sender == fParHeightField) - { - job->par.num = [fParWidthField intValue]; - job->par.den = [fParHeightField intValue]; - } - - if (sender == fDisplayWidthField) - { - dar_updated = 1; - job->par.num = [fDisplayWidthField intValue]; - job->par.den = [fWidthField intValue]; - } - - if (sender == fCropMatrix) - { - if (self.autoCrop != ( [fCropMatrix selectedRow] == 0 )) - { - self.autoCrop = !self.autoCrop; - if (self.autoCrop) - { - /* If auto, lets set the crop steppers according to - * current fTitle->crop values */ - memcpy( job->crop, fTitle->crop, 4 * sizeof( int ) ); - [fCropTopStepper setIntValue: fTitle->crop[0]]; - [fCropTopField setIntValue: fTitle->crop[0]]; - [fCropBottomStepper setIntValue: fTitle->crop[1]]; - [fCropBottomField setIntValue: fTitle->crop[1]]; - [fCropLeftStepper setIntValue: fTitle->crop[2]]; - [fCropLeftField setIntValue: fTitle->crop[2]]; - [fCropRightStepper setIntValue: fTitle->crop[3]]; - [fCropRightField setIntValue: fTitle->crop[3]]; - } - [fCropTopStepper setEnabled: !self.autoCrop]; - [fCropBottomStepper setEnabled: !self.autoCrop]; - [fCropLeftStepper setEnabled: !self.autoCrop]; - [fCropRightStepper setEnabled: !self.autoCrop]; - - [fCropTopField setEditable: !self.autoCrop]; - [fCropBottomField setEditable: !self.autoCrop]; - [fCropLeftField setEditable: !self.autoCrop]; - [fCropRightField setEditable: !self.autoCrop]; - } - } - if (sender == fCropTopStepper) - { - job->crop[0] = [fCropTopStepper intValue]; - [fCropTopField setIntValue: job->crop[0]]; - [fHeightStepper setMaxValue: fTitle->geometry.height - job->crop[0] - job->crop[1]]; - } - if (sender == fCropBottomStepper) - { - job->crop[1] = [fCropBottomStepper intValue]; - [fCropBottomField setIntValue: job->crop[1]]; - [fHeightStepper setMaxValue: fTitle->geometry.height - job->crop[0] - job->crop[1]]; - } - if (sender == fCropLeftStepper) - { - job->crop[2] = [fCropLeftStepper intValue]; - [fCropLeftField setIntValue: job->crop[2]]; - [fWidthStepper setMaxValue: fTitle->geometry.width - job->crop[2] - job->crop[3]]; - } - if (sender == fCropRightStepper) - { - job->crop[3] = [fCropRightStepper intValue]; - [fCropRightField setIntValue: job->crop[3]]; - [fWidthStepper setMaxValue: fTitle->geometry.width - job->crop[2] - job->crop[3]]; - } - - if (sender == fCropTopField) - { - int cropValue = [fCropTopField intValue]; - if (cropValue >= 0 && (cropValue <= fTitle->geometry.height/2-2)) - { - job->crop[0] = cropValue; - [fCropTopStepper setIntValue:cropValue]; - [fHeightStepper setMaxValue: fTitle->geometry.height - job->crop[0] - job->crop[1]]; - } - else - { - [fCropLeftField setIntValue:job->crop[0]]; - } - } - else if (sender == fCropBottomField) - { - int cropValue = [fCropBottomField intValue]; - if (cropValue >= 0 && (cropValue <= fTitle->geometry.height/2-2)) - { - job->crop[1] = cropValue; - [fCropBottomStepper setIntValue:cropValue]; - [fHeightStepper setMaxValue: fTitle->geometry.height - job->crop[0] - job->crop[1]]; - } - else - { - [fCropLeftField setIntValue:job->crop[1]]; - } - } - else if (sender == fCropLeftField) - { - int cropValue = [fCropLeftField intValue]; - if (cropValue >= 0 && (cropValue <= fTitle->geometry.width/2-2)) - { - job->crop[2] = cropValue; - [fCropLeftStepper setIntValue:cropValue]; - [fWidthStepper setMaxValue: fTitle->geometry.width - job->crop[2] - job->crop[3]]; - } - else - { - [fCropLeftField setIntValue:job->crop[2]]; - } - } - else if (sender == fCropRightField) - { - int cropValue = [fCropRightField intValue]; - if (cropValue >= 0 && (cropValue <= fTitle->geometry.width/2-2)) - { - job->crop[3] = cropValue; - [fCropRightStepper setIntValue:cropValue]; - [fWidthStepper setMaxValue: fTitle->geometry.width - job->crop[2] - job->crop[3]]; - } - else - { - [fCropLeftField setIntValue:job->crop[3]]; - } - } - - keep |= !!job->anamorphic.keep_display_aspect * HB_KEEP_DISPLAY_ASPECT; - - hb_geometry_t srcGeo, resultGeo; - hb_geometry_settings_t uiGeo; - - srcGeo.width = fTitle->geometry.width; - srcGeo.height = fTitle->geometry.height; - srcGeo.par = fTitle->geometry.par; - - uiGeo.mode = job->anamorphic.mode; - uiGeo.keep = keep; - uiGeo.itu_par = 0; - uiGeo.modulus = job->modulus; - memcpy(uiGeo.crop, job->crop, sizeof(int[4])); - uiGeo.geometry.width = job->width; - uiGeo.geometry.height = job->height; - /* Modulus added to maxWidth/maxHeight to allow a small amount of - * upscaling to the next mod boundary. - */ - uiGeo.maxWidth = fTitle->geometry.width - job->crop[2] - job->crop[3] + job->modulus - 1; - uiGeo.maxHeight = fTitle->geometry.height - job->crop[0] - job->crop[1] + job->modulus - 1; - uiGeo.geometry.par = job->par; - if (job->anamorphic.mode == HB_ANAMORPHIC_CUSTOM && dar_updated) - { - uiGeo.geometry.par.num = [fDisplayWidthField intValue]; - uiGeo.geometry.par.den = uiGeo.geometry.width; - } - hb_set_anamorphic_size2(&srcGeo, &uiGeo, &resultGeo); - - job->width = resultGeo.width; - job->height = resultGeo.height; - job->par = resultGeo.par; - - int display_width; - display_width = resultGeo.width * resultGeo.par.num / resultGeo.par.den; - - [fWidthStepper setIntValue: resultGeo.width]; - [fWidthField setIntValue: resultGeo.width]; - [fHeightStepper setIntValue: resultGeo.height]; - [fHeightField setIntValue: resultGeo.height]; - [fParWidthField setIntValue: resultGeo.par.num]; - [fParHeightField setIntValue: resultGeo.par.den]; - [fDisplayWidthField setIntValue: display_width]; - - /* - * Sanity-check here for previews < 16 pixels to avoid crashing - * hb_get_preview(). In fact, let's get previews at least 64 pixels in both - * dimensions; no human can see any meaningful detail below that. - */ - if (job->width >= 64 && job->height >= 64) - { - [fPreviewController reload]; - } - - /* we get the sizing info to display from fPreviewController */ - [fSizeInfoField setStringValue: [fPreviewController pictureSizeInfoString]]; - - if (sender != nil) - { - [self.delegate pictureSettingsDidChange]; - } - - if ([[self window] isVisible]) - { - [self adjustSizingDisplay:nil]; - } -} - @end |