From 1e9a05078d0c874d978c1a4660fd75b2d91ebc5e Mon Sep 17 00:00:00 2001 From: dynaflash Date: Tue, 8 May 2007 17:16:20 +0000 Subject: macGui: Advanced Tab - Initial Implementation - add gui "widgets" to control the x264 advanced option string. - Not all options are "widgetized" yet. - Modifies those it has widgets for, leaves the rest of the string intact. - This rev, only sets opts that have an integer value. - Adding widgets requires adding values to controller.h as well as these methods in controller.mm: -X264AdvancedOptionsSet: adds the actual values for the given outlet in the nib -X264AdvancedOptionsStandardizeOptNames: standardizes the opt names that have multiple connotations -X264AdvancedOptionsSetCurrentSettings: Reads and sets the widgets according to the current string whether pasted in by user, set by preset, or set by field in preferences -X264AdvancedOptionsChanged: Changes the string based on the widget used, including "Unspecified" which just removes it from the string altogether. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@571 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/Controller.mm | 351 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 344 insertions(+), 7 deletions(-) (limited to 'macosx/Controller.mm') diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 871dfae31..d17bcfbbc 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -1863,16 +1863,354 @@ the user is using "Custom" settings by determining the sender*/ /* Lets check to see there is a specified string in the prefs, and use that if need be */ if ([[NSUserDefaults standardUserDefaults] stringForKey:@"DefAdvancedx264Flags"] != @"") { - [fDisplayX264Options setStringValue: [NSString stringWithFormat:[[NSUserDefaults standardUserDefaults] stringForKey:@"DefAdvancedx264Flags"]]]; + [fDisplayX264Options setStringValue: [NSString stringWithFormat:[[NSUserDefaults standardUserDefaults] stringForKey:@"DefAdvancedx264Flags"]]]; } } else { - /* Empty the field to display custom x264 preset options*/ - [fDisplayX264Options setStringValue: @""]; + /* Empty the field to display custom x264 preset options*/ + [fDisplayX264Options setStringValue: @""]; } } + [self X264AdvancedOptionsSet:NULL]; +} + +- (IBAction) X264AdvancedOptionsSet: (id) sender +{ + /*Set opt widget values here*/ + + /*B-Frames fX264optBframesPopUp*/ + int i; + [fX264optBframesPopUp removeAllItems]; + [fX264optBframesPopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<17;i++) + { + [fX264optBframesPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*Reference Frames fX264optRefPopUp*/ + [fX264optRefPopUp removeAllItems]; + [fX264optRefPopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<17;i++) + { + [fX264optRefPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*No Fast P-Skip fX264optNfpskipPopUp BOOLEAN*/ + [fX264optNfpskipPopUp removeAllItems]; + [fX264optNfpskipPopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<2;i++) + { + if (i==0) + { + [fX264optNfpskipPopUp addItemWithTitle:[NSString stringWithFormat:@"No"]]; + } + else + { + [fX264optNfpskipPopUp addItemWithTitle:[NSString stringWithFormat:@"Yes"]]; + } + } + + /*No Dict Decimate fX264optNodctdcmtPopUp BOOLEAN*/ + [fX264optNodctdcmtPopUp removeAllItems]; + [fX264optNodctdcmtPopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<2;i++) + { + if (i==0) + { + [fX264optNodctdcmtPopUp addItemWithTitle:[NSString stringWithFormat:@"No"]]; + } + else + { + [fX264optNodctdcmtPopUp addItemWithTitle:[NSString stringWithFormat:@"Yes"]]; + } + } + + /*Sub Me fX264optSubmePopUp*/ + [fX264optSubmePopUp removeAllItems]; + [fX264optSubmePopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<8;i++) + { + [fX264optSubmePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*Trellis fX264optTrellisPopUp*/ + [fX264optTrellisPopUp removeAllItems]; + [fX264optTrellisPopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<3;i++) + { + [fX264optTrellisPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + /* Standardize the option string */ + [self X264AdvancedOptionsStandardizeOptString: NULL]; + /* Set Current GUI Settings based on newly standardized string */ + [self X264AdvancedOptionsSetCurrentSettings: NULL]; + +} + +- (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender +{ + /* Set widgets depending on the opt string in field */ + NSString * thisOpt; // The separated option such as "bframes=3" + NSString * optName = @""; // The option name such as "bframes" + NSString * optValue = @"";// The option value such as "3" + NSString * changedOptString = @""; + NSArray *currentOptsArray; + /*First, we get an opt string to process */ + NSString *currentOptString = [fDisplayX264Options stringValue]; + /*verify there is an opt string to process */ + NSRange currentOptRange = [currentOptString rangeOfString:@"="]; + if (currentOptRange.location != NSNotFound) + { + /*Put individual options into an array based on the ":" separator for processing, result is "="*/ + currentOptsArray = [currentOptString componentsSeparatedByString:@":"]; + /*iterate through the array and get and ="*/ + currentOptsArray = [currentOptString componentsSeparatedByString:@":"]; + /*iterate through the array and get and and ="*/ + currentOptsArray = [currentOptString componentsSeparatedByString:@":"]; + /*iterate through the array and get and 0) - { - [fDisplayX264Options setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]]; - } + [fDisplayX264Options setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]]; + + [self X264AdvancedOptionsSet:NULL]; /* Lets run through the following functions to get variables set there */ [self EncoderPopUpChanged: NULL]; -- cgit v1.2.3