From 2659b80cc0d4e078db19436f4f144b50525f2983 Mon Sep 17 00:00:00 2001 From: ritsuka Date: Thu, 14 May 2015 19:37:49 +0000 Subject: MacGui: use libhb built-in presets and validation functions. Update the format and save the presets in UserPresets.json, the old presets are automatically imported if the new presets file is not found. The mac gui now requires 10.7 or later. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7181 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/HBPicture.m | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) (limited to 'macosx/HBPicture.m') diff --git a/macosx/HBPicture.m b/macosx/HBPicture.m index 8ebfb8477..9a0b7f931 100644 --- a/macosx/HBPicture.m +++ b/macosx/HBPicture.m @@ -305,7 +305,7 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification"; } } -- (void)setKeepDisplayAspect:(int)keepDisplayAspect +- (void)setKeepDisplayAspect:(BOOL)keepDisplayAspect { _keepDisplayAspect = keepDisplayAspect; if (!self.isValidating) @@ -564,7 +564,25 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification"; - (void)writeToPreset:(NSMutableDictionary *)preset { preset[@"PictureKeepRatio"] = @(self.keepDisplayAspect); - preset[@"PicturePAR"] = @(self.anamorphicMode); + + switch (self.anamorphicMode) { + case HB_ANAMORPHIC_NONE: + preset[@"PicturePAR"] = @"none"; + break; + case HB_ANAMORPHIC_LOOSE: + preset[@"PicturePAR"] = @"loose"; + break; + case HB_ANAMORPHIC_STRICT: + preset[@"PicturePAR"] = @"strict"; + break; + case HB_ANAMORPHIC_CUSTOM: + preset[@"PicturePAR"] = @"custom"; + break; + default: + preset[@"PicturePAR"] = @"loose"; + break; + } + preset[@"PictureModulus"] = @(self.modulus); // Set crop settings @@ -597,7 +615,7 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification"; { // If Cropping is set to custom, then recall all four crop values from // when the preset was created and apply them - if ([preset[@"PictureAutoCrop"] intValue] == 0) + if ([preset[@"PictureAutoCrop"] intValue] == 0) { self.autocrop = NO; @@ -632,17 +650,33 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification"; } // Assume max picture settings initially. - self.keepDisplayAspect = [preset[@"PictureKeepRatio"] intValue]; - self.anamorphicMode = [preset[@"PicturePAR"] intValue]; + self.keepDisplayAspect = [preset[@"PictureKeepRatio"] boolValue]; + + if ([preset[@"PicturePAR"] isEqualToString:@"none"]) + { + self.anamorphicMode = HB_ANAMORPHIC_NONE; + } + else if ([preset[@"PicturePAR"] isEqualToString:@"strict"]) + { + self.anamorphicMode = HB_ANAMORPHIC_STRICT; + } + else if ([preset[@"PicturePAR"] isEqualToString:@"custom"]) + { + self.anamorphicMode = HB_ANAMORPHIC_CUSTOM; + } + else + { + self.anamorphicMode = HB_ANAMORPHIC_LOOSE; + } + self.width = self.sourceWidth - self.cropLeft - self.cropRight; self.height = self.sourceHeight - self.cropTop - self.cropBottom; - // Check to see if the objectForKey:@"UsesPictureSettings" is 2, + // Check to see if the "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 ([preset[@"UsesPictureSettings"] intValue] != 2 && - [preset[@"UsesMaxPictureSettings"] intValue] != 1) + if ([preset[@"UsesPictureSettings"] intValue] != 2) { // if the preset specifies neither max. width nor height // (both are 0), use the max. picture size @@ -653,7 +687,7 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification"; { jobMaxWidth = [preset[@"PictureWidth"] intValue]; } - if ([preset[@"PictureHeight"] intValue] > 0) + if ([preset[@"PictureHeight"] intValue] > 0) { jobMaxHeight = [preset[@"PictureHeight"] intValue]; } -- cgit v1.2.3