All pastes #938629 Raw Edit

Advanced hiding widgets

public diff v1 · immutable
·published 2008-03-11 19:36 UTC
rendered paste body
Index: macosx/HBAdvancedController.h===================================================================--- macosx/HBAdvancedController.h	(revision 1335)+++ macosx/HBAdvancedController.h	(working copy)@@ -62,6 +62,7 @@ - (void) setOptions: (NSString *)string; - (void) enableUI: (bool) b; - (void) setHidden: (BOOL) hide;+- (IBAction) X264AdvancedOptionsAnimate: (id) sender; - (IBAction) X264AdvancedOptionsSet: (id) sender; - (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender; - (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender;Index: macosx/HBAdvancedController.m===================================================================--- macosx/HBAdvancedController.m	(revision 1335)+++ macosx/HBAdvancedController.m	(working copy)@@ -89,6 +89,9 @@         [controls[i] setEnabled: b];      }+    +    [fX264optView setWantsLayer:YES];+     }  - (void)dealloc@@ -141,9 +144,12 @@     {         [fX264optTrellisPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];     }+    [fX264optTrellisPopUp setWantsLayer:YES];     +         /*Mixed-references fX264optMixedRefsSwitch BOOLEAN*/     [fX264optMixedRefsSwitch setState:0];+    [fX264optMixedRefsSwitch setWantsLayer:YES];          /*Motion Estimation fX264optMotionEstPopUp*/     [fX264optMotionEstPopUp removeAllItems];@@ -163,15 +169,20 @@          /*Weighted B-Frame Prediction fX264optWeightBSwitch BOOLEAN*/     [fX264optWeightBSwitch setState:0];+    [fX264optWeightBSwitch setWantsLayer:YES];          /*B-Frame Rate Distortion Optimization fX264optBRDOSwitch BOOLEAN*/     [fX264optBRDOSwitch setState:0];+    [fX264optBRDOSwitch setWantsLayer:YES];     +         /*B-frame Pyramids fX264optBPyramidSwitch BOOLEAN*/     [fX264optBPyramidSwitch setState:0];+    [fX264optBPyramidSwitch setWantsLayer:YES];          /*Bidirectional Motion Estimation Refinement fX264optBiMESwitch BOOLEAN*/     [fX264optBiMESwitch setState:0];+    [fX264optBiMESwitch setWantsLayer:YES];          /*Direct B-Frame Prediction Mode fX264optDirectPredPopUp*/     [fX264optDirectPredPopUp removeAllItems];@@ -180,6 +191,7 @@     [fX264optDirectPredPopUp addItemWithTitle:@"Spatial"];     [fX264optDirectPredPopUp addItemWithTitle:@"Temporal"];     [fX264optDirectPredPopUp addItemWithTitle:@"Automatic"];+    [fX264optDirectPredPopUp setWantsLayer:YES];          /*Alpha Deblock*/     [fX264optAlphaDeblockPopUp removeAllItems];@@ -205,6 +217,7 @@                      /* 8x8 DCT fX264op8x8dctSwitch */     [fX264opt8x8dctSwitch setState:0];+    [fX264opt8x8dctSwitch setWantsLayer:YES];          /* CABAC fX264opCabacSwitch */     [fX264optCabacSwitch setState:1];@@ -214,6 +227,9 @@      /* Set Current GUI Settings based on newly standardized string */     [self X264AdvancedOptionsSetCurrentSettings: NULL];+    +    /* Fade out options that don't apply */+    [self X264AdvancedOptionsAnimate: sender]; }  /**@@ -365,6 +381,161 @@ }  /**+ * Fades options in and out depending on whether they're available..+ */+- (IBAction) X264AdvancedOptionsAnimate: (id) sender+{+    /* Lots of situations to cover.+       - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)+       - CABAC (when 0 turn off trellis)+       - subme  (if under 6 turn off brdo)+       - analysis (if none, turn off 8x8dct and direct pred)+       - refs (under 2, disable mixed-refs)+    */+  +    if ( [fX264optBframesPopUp indexOfSelectedItem ] < 2)+    {+        /* If the b-frame widget is at 0 or 1, the user has chosen+           not to use b-frames at all. So disable the options+           that can only be used when b-frames are enabled.        */+        [[fX264optWeightBSwitch animator] setHidden:YES];+        [[fX264optWeightBLabel animator] setHidden:YES];++        [[fX264optBRDOSwitch animator] setHidden:YES];+        [[fX264optBRDOLabel animator] setHidden:YES];++        [[fX264optBPyramidSwitch animator] setHidden:YES];+        [[fX264optBPyramidLabel animator] setHidden:YES];++        [[fX264optBiMESwitch animator] setHidden:YES];+        [[fX264optBiMELabel animator] setHidden:YES];++        [[fX264optDirectPredPopUp animator] setHidden:YES];+        [[fX264optDirectPredLabel animator] setHidden:YES];+    }+    else if ( [fX264optBframesPopUp indexOfSelectedItem ] == 2)+    {+        /* Only 1 b-frame? Disable b-pyramid. */+        [[fX264optBPyramidSwitch animator] setHidden:YES];+        [[fX264optBPyramidLabel animator] setHidden:YES];++        [[fX264optWeightBSwitch animator] setHidden:NO];+        [[fX264optWeightBLabel animator] setHidden:NO];++        [[fX264optBiMESwitch animator] setHidden:NO];+        [[fX264optBiMELabel animator] setHidden:NO];+                +        if ( [fX264optSubmePopUp indexOfSelectedItem] >= 7)+        {+            /* Only show B-RDO if both bframes and subme allow it. */+            [[fX264optBRDOSwitch animator] setHidden:NO];+            [[fX264optBRDOLabel animator] setHidden:NO];+        }+        +        if ( [fX264optAnalysePopUp indexOfSelectedItem] != 1)+        {+            /* Only show direct pred when allowed by both bframes and analysis.*/+            [[fX264optDirectPredPopUp animator] setHidden:NO];+            [[fX264optDirectPredLabel animator] setHidden:NO];+        }+    }+    else+    {+        [[fX264optWeightBSwitch animator] setHidden:NO];+        [[fX264optWeightBLabel animator] setHidden:NO];++        [[fX264optBPyramidSwitch animator] setHidden:NO];+        [[fX264optBPyramidLabel animator] setHidden:NO];++        [[fX264optBiMESwitch animator] setHidden:NO];+        [[fX264optBiMELabel animator] setHidden:NO];++        if ( [fX264optSubmePopUp indexOfSelectedItem] >= 7)+        {+            /* Only show B-RDO if both bframes and subme allow it. */+            [[fX264optBRDOSwitch animator] setHidden:NO];+            [[fX264optBRDOLabel animator] setHidden:NO];+        }++        if ( [fX264optAnalysePopUp indexOfSelectedItem] != 1)+        {+            /* Only show direct pred when allowed by both bframes and analysis.*/+            [[fX264optDirectPredPopUp animator] setHidden:NO];+            [[fX264optDirectPredLabel animator] setHidden:NO];+        }+    }+    +    if ( [fX264optCabacSwitch state] == false)+    {+        /* Without CABAC entropy coding, trellis doesn't run. */+        +        /* For testing purposes, lets not hide trellis popup so we can verify+        That the popup is being correctly set to and reflected in the opt string */+        [[fX264optTrellisPopUp animator] setHidden:YES];+        [[fX264optTrellisLabel animator] setHidden:YES];+        /* We set trellis to 0 here */+        [fX264optTrellisPopUp selectItemAtIndex:1];+        if (sender != fX264optTrellisPopUp)+        [[fX264optTrellisPopUp cell] performClick:self];++    }+    else+    {+        [[fX264optTrellisPopUp animator] setHidden:NO];+        [[fX264optTrellisLabel animator] setHidden:NO];+    }+    +    if ( [fX264optSubmePopUp indexOfSelectedItem] < 7)+    {+        /* When subme < 6, B-RDO doesn't work. */+        [[fX264optBRDOSwitch animator] setHidden:YES];+        [[fX264optBRDOLabel animator] setHidden:YES];+    }+    else if ( [fX264optBframesPopUp indexOfSelectedItem ] >= 2 )+    {+        /* Make sure to only display B-RDO if allowed by both+           the subme and bframe option settings.               */+        [[fX264optBRDOSwitch animator] setHidden:NO]; +        [[fX264optBRDOLabel animator] setHidden:NO]; +    }+    +    if ( [fX264optAnalysePopUp indexOfSelectedItem] == 1)+    {+        /* No analysis? Disable 8x8dct and direct pred */+        [[fX264opt8x8dctSwitch animator] setHidden:YES];+        [[fX264opt8x8dctLabel animator] setHidden:YES];++        [[fX264optDirectPredPopUp animator] setHidden:YES];+        [[fX264optDirectPredLabel animator] setHidden:YES];+    }+    else+    {+        [[fX264opt8x8dctSwitch animator] setHidden:NO];+        [[fX264opt8x8dctLabel animator] setHidden:NO];++        if ( [fX264optBframesPopUp indexOfSelectedItem ] >= 2)+        {+            /* Onlt show direct pred when allowed by both analysis and bframes */+            [[fX264optDirectPredPopUp animator] setHidden:NO];+            [[fX264optDirectPredLabel animator] setHidden:NO];+        }+    }+    +    if ( [fX264optRefPopUp indexOfSelectedItem] < 3)+    {+        /* Only do mixed-refs when there are at least 2 refs to mix. */+        [[fX264optMixedRefsSwitch animator] setHidden:YES];+        [[fX264optMixedRefsLabel animator] setHidden:YES];+    }+    else+    {+        [[fX264optMixedRefsSwitch animator] setHidden:NO];+        [[fX264optMixedRefsLabel animator] setHidden:NO];+    }+}+++/**  * Resets the GUI widgets to the contents of the option string.  */ - (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender@@ -1172,7 +1343,7 @@     }          /* We now need to reset the opt widgets since we changed some stuff */        -    [self X264AdvancedOptionsSet:NULL];        +    [self X264AdvancedOptionsSet:sender];         }  @end