OSDN Git Service

macGui: Advanced Tab - Initial Implementation
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 8 May 2007 17:16:20 +0000 (17:16 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 8 May 2007 17:16:20 +0000 (17:16 +0000)
- 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://localhost/HandBrake/trunk@571 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.h
macosx/Controller.mm
macosx/English.lproj/MainMenu.nib/classes.nib
macosx/English.lproj/MainMenu.nib/info.nib
macosx/English.lproj/MainMenu.nib/keyedobjects.nib

index 8c78471..1ed6f16 100644 (file)
     IBOutlet NSButton            * fPauseButton;
     IBOutlet NSButton            * fRipButton;
 
+       /* Advanced Tab for opts */
+       IBOutlet NSPopUpButton       * fX264optBframesPopUp;
+       IBOutlet NSPopUpButton       * fX264optRefPopUp;
+       IBOutlet NSPopUpButton       * fX264optNfpskipPopUp;
+       IBOutlet NSPopUpButton       * fX264optNodctdcmtPopUp;
+       IBOutlet NSPopUpButton       * fX264optSubmePopUp;
+       IBOutlet NSPopUpButton       * fX264optTrellisPopUp;
+
        /* User Preset variables here fPresetNewPicSettingsApply*/
        
        IBOutlet NSDrawer            * fPresetDrawer;
 - (IBAction) OpenForums:   (id) sender;
 - (IBAction) OpenUserGuide:   (id) sender;
 
+// x264 Advanced Panel Methods
+- (IBAction) X264AdvancedOptionsSet: (id) sender;
+- (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender;
+- (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender;
+- (NSString *)  X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString;
+- (IBAction) X264AdvancedOptionsChanged: (id) sender;
+
 // Preset Methods Here
 - (IBAction) CustomSettingUsed: (id) sender;
 - (IBAction) ShowAddPresetPanel: (id) sender;
index 871dfae..d17bcfb 100644 (file)
@@ -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 "<opt>=<value>"*/
+                       currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
+                       /*iterate through the array and get <opts> and <values*/
+                       //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];
+                       int loopcounter;
+                       int currentOptsArrayCount = [currentOptsArray count];
+                       for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
+                       {
+                               thisOpt = [currentOptsArray objectAtIndex:loopcounter];
+                               NSRange splitOptRange = [thisOpt rangeOfString:@"="];
+                               if (splitOptRange.location != NSNotFound)
+                               {
+                                       optName = [thisOpt substringToIndex:splitOptRange.location];
+                                       optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
+                                       /* Standardize the names here depending on whats in the string */
+                                       optName = [self X264AdvancedOptionsStandardizeOptNames:optName];
+                    thisOpt = [NSString stringWithFormat:@"%@=%@",optName,optValue];   
+                               }
+                               else // No value given so we use a default of "1"
+                               {
+                                       optName = thisOpt;
+                                       /* Standardize the names here depending on whats in the string */
+                                       optName = [self X264AdvancedOptionsStandardizeOptNames:optName];
+                                       thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
+                }
+                               
+                               /* Construct New String for opts here */
+                               if ([thisOpt isEqualToString:@""])
+                               {
+                                       
+                                       changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt];
+                               }
+                               else
+                               {
+                                       if ([changedOptString isEqualToString:@""])
+                                       {
+                                               changedOptString = [NSString stringWithFormat:@"%@",thisOpt];
+                                       }
+                                       else
+                                       {
+                                               changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt];
+                                       }
+                               }
+                               
+                       }       
+               }
+               /* Change the option string to reflect the new standardized option string */
+               [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];
+               
+}
+
+- (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString
+{
+       if ([cleanOptNameString isEqualToString:@"ref"] || [cleanOptNameString isEqualToString:@"frameref"])
+       {
+               cleanOptNameString = @"ref";
+       }
+       /*No Fast PSkip nofast_pskip*/
+       if ([cleanOptNameString isEqualToString:@"no-fast-pskip"] || [cleanOptNameString isEqualToString:@"no_fast_pskip"] || [cleanOptNameString isEqualToString:@"nofast_pskip"])
+       {
+               cleanOptNameString = @"no-fast-pskip";
+       }
+       /*No Dict Decimate*/
+       if ([cleanOptNameString isEqualToString:@"no-dct-decimate"] || [cleanOptNameString isEqualToString:@"no_dct_decimate"] || [cleanOptNameString isEqualToString:@"nodct_decimate"])
+       {
+               cleanOptNameString = @"no-dct-decimate";
+       }
+       return cleanOptNameString;      
+}
+
+               
+- (IBAction) X264AdvancedOptionsSetCurrentSettings: (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"
+       NSArray *currentOptsArray;
+               /*First, we get an opt string to process */
+               //NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
+               NSString *currentOptString = [fDisplayX264Options stringValue];
+               /*verify there is an opt string to process */
+               NSRange currentOptRange = [currentOptString rangeOfString:@"="];
+               if (currentOptRange.location != NSNotFound)
+               {
+                       /* lets clean the opt string here to standardize any names*/
+                       /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
+                       currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
+                       /*iterate through the array and get <opts> and <values*/
+                       //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];
+                       int loopcounter;
+                       int currentOptsArrayCount = [currentOptsArray count];
+                       /*iterate through the array and get <opts> and <values*/
+                       for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
+                       {
+                               thisOpt = [currentOptsArray objectAtIndex:loopcounter];
+                               NSRange splitOptRange = [thisOpt rangeOfString:@"="];
+                               if (splitOptRange.location != NSNotFound)
+                               {
+                                       optName = [thisOpt substringToIndex:splitOptRange.location];
+                                       optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
+                                       
+                                       /*Run through the available widgets for x264 opts and set them, as you add widgets, 
+                                               they need to be added here. This should be moved to its own method probably*/
+                                       
+                                       /*bframes NSPopUpButton*/
+                                       if ([optName isEqualToString:@"bframes"])
+                                       {
+                                               [fX264optBframesPopUp selectItemAtIndex:[optValue intValue]+1];
+                                       }
+                                       /*ref NSPopUpButton*/
+                                       if ([optName isEqualToString:@"ref"])
+                                       {
+                                               [fX264optRefPopUp selectItemAtIndex:[optValue intValue]+1];
+                                       }
+                                       /*No Fast PSkip NSPopUpButton*/
+                                       if ([optName isEqualToString:@"no-fast-pskip"])
+                                       {
+                                               [fX264optNfpskipPopUp selectItemAtIndex:[optValue intValue]+1];
+                                       }
+                                       /*No Dict Decimate NSPopUpButton*/
+                                       if ([optName isEqualToString:@"no-dct-decimate"])
+                                       {
+                                               [fX264optNodctdcmtPopUp selectItemAtIndex:[optValue intValue]+1];
+                                       }
+                                       /*Sub Me NSPopUpButton*/
+                                       if ([optName isEqualToString:@"subme"])
+                                       {
+                                               [fX264optSubmePopUp selectItemAtIndex:[optValue intValue]+1];
+                                       }
+                                       /*Trellis NSPopUpButton*/
+                                       if ([optName isEqualToString:@"trellis"])
+                                       {
+                                               [fX264optTrellisPopUp selectItemAtIndex:[optValue intValue]+1];
+                                       }
+                    
+                               }
+                       }
+               }
+               
+}
+
+- (IBAction) X264AdvancedOptionsChanged: (id) sender
+{
+       /*Determine which outlet is being used and set optName to process accordingly */
+       NSString * optNameToChange = @""; // The option name such as "bframes"
+       if (sender == fX264optBframesPopUp)
+       {
+               optNameToChange = @"bframes";
+       }
+       if (sender == fX264optRefPopUp)
+       {
+               optNameToChange = @"ref";
+       }
+       if (sender == fX264optNfpskipPopUp)
+       {
+               optNameToChange = @"no-fast-pskip";
+       }
+       if (sender == fX264optNodctdcmtPopUp)
+       {
+               optNameToChange = @"no-dct-decimate";
+       }
+       if (sender == fX264optSubmePopUp)
+       {
+               optNameToChange = @"subme";
+       }
+       if (sender == fX264optTrellisPopUp)
+       {
+               optNameToChange = @"trellis";
+       }
+       /* 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"
+               NSArray *currentOptsArray;
+               /*First, we get an opt string to process */
+               //NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
+               NSString *currentOptString = [fDisplayX264Options stringValue];
+               /*verify there is an occurrence of the opt specified by the sender to change */
+               /*take care of any multi-value opt names here. This is extremely kludgy, but test for functionality
+               and worry about pretty later */
+               
+               NSRange currentOptRange = [currentOptString rangeOfString:optNameToChange];
+               if (currentOptRange.location != NSNotFound)
+               {
+                       /* Create new empty opt string*/
+                       NSString *changedOptString = @"";
+                       /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
+                       currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
+                       /*iterate through the array and get <opts> and <values*/
+                       int loopcounter;
+                       int currentOptsArrayCount = [currentOptsArray count];
+                       for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
+                       {
+                               thisOpt = [currentOptsArray objectAtIndex:loopcounter];
+                               NSRange splitOptRange = [thisOpt rangeOfString:@"="];
+                               if (splitOptRange.location != NSNotFound)
+                               {
+                                       optName = [thisOpt substringToIndex:splitOptRange.location];
+                                       optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
+                                       
+                                       /*Run through the available widgets for x264 opts and set them, as you add widgets, 
+                                               they need to be added here. This should be moved to its own method probably*/
+                                       
+                                       /*If the optNameToChange is found, appropriately change the value or delete it if
+                                               "Unspecified" is set.*/
+                                       if ([optName isEqualToString:optNameToChange])
+                                       {
+                                               if ([sender indexOfSelectedItem] == 0) // means that "unspecified" is chosen, lets then remove it from the string
+                                               {
+                                                       thisOpt = @"";
+                                               }
+                                               else // we have a valid value to change, so change it
+                                               {
+                                                       thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]-1];
+                                                       
+                                               }
+                                       }
+                               
+                               }
+                               /* Construct New String for opts here */
+                               if ([thisOpt isEqualToString:@""])
+                               {
+                                       changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt];
+                               }
+                               else
+                               {
+                                       if ([changedOptString isEqualToString:@""])
+                                       {
+                                               changedOptString = [NSString stringWithFormat:@"%@",thisOpt];
+                                       }
+                                       else
+                                       {
+                                               changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt];
+                                       }
+                               }
+                                       
+                       }
+                       /* Change the option string to reflect the new mod settings */
+               [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];      
+               }
+               else // if none exists, add it to the string
+               {
+                       [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], 
+                               [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
+               }
+               /* We now need to reset the opt widgets since we changed some stuff */          
+               [self X264AdvancedOptionsSet:NULL];             
 }
 
 
@@ -2378,10 +2716,9 @@ the user is using "Custom" settings by determining the sender*/
                
                /* We can show the preset options here in the gui if we want to
                        so we check to see it the user has specified it in the prefs */
-               if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefAdvancedx264FlagsShow"] > 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];
index b8f83a9..c154bbb 100644 (file)
@@ -33,6 +33,8 @@
                 ShowScanPanel = id; 
                 TitlePopUpChanged = id; 
                 VideoMatrixChanged = id; 
+                X264AdvancedOptionsChanged = id; 
+                X264AdvancedOptionsSet = id; 
                 tableViewSelected = id; 
             }; 
             CLASS = HBController; 
                 fVidTargetSizeField = NSTextField; 
                 fVidTwoPassCheck = NSButton; 
                 fWindow = NSWindow; 
+                fX264optBframesPopUp = NSPopUpButton; 
+                fX264optNfpskipPopUp = NSPopUpButton; 
+                fX264optNodctdcmtPopUp = NSPopUpButton; 
+                fX264optRefPopUp = NSPopUpButton; 
+                fX264optSubmePopUp = NSPopUpButton; 
+                fX264optTrellisPopUp = NSPopUpButton; 
                 tableView = NSTableView; 
             }; 
             SUPERCLASS = NSObject; 
index 70cd310..a14de9d 100644 (file)
@@ -3,7 +3,7 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>1644 129 630 601 1440 0 1280 1024 </string>
+       <string>26 277 630 601 0 0 1440 878 </string>
        <key>IBEditorPositions</key>
        <dict>
                <key>1843</key>
index 9261683..9fd4ea5 100644 (file)
Binary files a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib and b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib differ