diff options
author | jbrjake <[email protected]> | 2009-02-13 16:20:18 +0000 |
---|---|---|
committer | jbrjake <[email protected]> | 2009-02-13 16:20:18 +0000 |
commit | 531bed1892f2d098dfbe7184148cd45fe0899085 (patch) | |
tree | 71be1def3b3e449ae4995162a8f0e09cf9c20287 | |
parent | 95e73f83bdbf5ceb3c344e8368f6eff3374f2ac4 (diff) |
MacGui: Restructures that x264 advanced option widget hiding method so it sucks a bit less, is easier to read, and has a lower potential for nasty looping.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2159 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | macosx/HBAdvancedController.m | 353 |
1 files changed, 212 insertions, 141 deletions
diff --git a/macosx/HBAdvancedController.m b/macosx/HBAdvancedController.m index 0da805104..ef0aa80f4 100644 --- a/macosx/HBAdvancedController.m +++ b/macosx/HBAdvancedController.m @@ -401,196 +401,267 @@ - trellis (if 0, turn off psy-trel) */ - if ( [fX264optBframesPopUp indexOfSelectedItem ] < 2) + if( sender == fX264optBframesPopUp ) { - /* 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]; - if ( [fX264optWeightBSwitch state] == 1 && sender != fX264optWeightBSwitch && sender != fX264optBPyramidSwitch && sender != fX264optDirectPredPopUp && sender != fX264optBAdaptPopUp ) - [fX264optWeightBSwitch performClick:self]; - - [[fX264optBPyramidSwitch animator] setHidden:YES]; - [[fX264optBPyramidLabel animator] setHidden:YES]; - if ( [fX264optBPyramidSwitch state] == 1 && sender != fX264optWeightBSwitch && sender != fX264optBPyramidSwitch && sender != fX264optDirectPredPopUp && sender != fX264optBAdaptPopUp ) - [fX264optBPyramidSwitch performClick:self]; - - [[fX264optDirectPredPopUp animator] setHidden:YES]; - [[fX264optDirectPredLabel animator] setHidden:YES]; - if ( [fX264optDirectPredPopUp indexOfSelectedItem] > 0 && sender != fX264optWeightBSwitch && sender != fX264optBPyramidSwitch && sender != fX264optDirectPredPopUp && sender != fX264optBAdaptPopUp ) + if ( [fX264optBframesPopUp indexOfSelectedItem ] < 2) { - [fX264optDirectPredPopUp selectItemAtIndex: 0]; - [[fX264optDirectPredPopUp cell] performClick:self]; + /* 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. */ - } - - [[fX264optBAdaptPopUp animator] setHidden:YES]; - [[fX264optBAdaptLabel animator] setHidden:YES]; - if ( [fX264optBAdaptPopUp indexOfSelectedItem] > 0 && sender != fX264optWeightBSwitch && sender != fX264optBPyramidSwitch && sender != fX264optDirectPredPopUp && sender != fX264optBAdaptPopUp ) - { - [fX264optBAdaptPopUp selectItemAtIndex: 0]; - [[fX264optBAdaptPopUp cell] performClick:self]; - } - } - else if ( [fX264optBframesPopUp indexOfSelectedItem ] == 2) - { - /* Only 1 b-frame? Disable b-pyramid. */ - [[fX264optBPyramidSwitch animator] setHidden:YES]; - [[fX264optBPyramidLabel animator] setHidden:YES]; - if ( [fX264optBPyramidSwitch state] == 1 && sender != fX264optBPyramidSwitch) - [fX264optBPyramidSwitch performClick:self]; + if( [fX264optWeightBSwitch isHidden] == false) + { + [[fX264optWeightBSwitch animator] setHidden:YES]; + [[fX264optWeightBLabel animator] setHidden:YES]; + if ( [fX264optWeightBSwitch state] == 1 ) + [fX264optWeightBSwitch performClick:self]; + } - [[fX264optWeightBSwitch animator] setHidden:NO]; - [[fX264optWeightBLabel animator] setHidden:NO]; + if( [fX264optBPyramidSwitch isHidden] == false ) + { + [[fX264optBPyramidSwitch animator] setHidden:YES]; + [[fX264optBPyramidLabel animator] setHidden:YES]; + if ( [fX264optBPyramidSwitch state] == 1 ) + [fX264optBPyramidSwitch performClick:self]; + } - [[fX264optDirectPredPopUp animator] setHidden:NO]; - [[fX264optDirectPredLabel animator] setHidden:NO]; - - [[fX264optBAdaptPopUp animator] setHidden:NO]; - [[fX264optBAdaptLabel animator] setHidden:NO]; - } - else - { - [[fX264optWeightBSwitch animator] setHidden:NO]; - [[fX264optWeightBLabel animator] setHidden:NO]; + if( [fX264optDirectPredPopUp isHidden] == false ) + { + [[fX264optDirectPredPopUp animator] setHidden:YES]; + [[fX264optDirectPredLabel animator] setHidden:YES]; + if ( [fX264optDirectPredPopUp indexOfSelectedItem] > 0 ) + { + [fX264optDirectPredPopUp selectItemAtIndex: 0]; + [[fX264optDirectPredPopUp cell] performClick:self]; + } + } - [[fX264optBPyramidSwitch animator] setHidden:NO]; - [[fX264optBPyramidLabel animator] setHidden:NO]; + if( [fX264optBAdaptPopUp isHidden] == false ) + { + [[fX264optBAdaptPopUp animator] setHidden:YES]; + [[fX264optBAdaptLabel animator] setHidden:YES]; + if ( [fX264optBAdaptPopUp indexOfSelectedItem] > 0 ) + { + [fX264optBAdaptPopUp selectItemAtIndex: 0]; + [[fX264optBAdaptPopUp cell] performClick:self]; + } + } + } + else if ( [fX264optBframesPopUp indexOfSelectedItem ] == 2) + { + /* Only 1 b-frame? Disable b-pyramid. */ + if( [fX264optBPyramidSwitch isHidden] == false ) + { + [[fX264optBPyramidSwitch animator] setHidden:YES]; + [[fX264optBPyramidLabel animator] setHidden:YES]; + if ( [fX264optBPyramidSwitch state] == 1 ) + [fX264optBPyramidSwitch performClick:self]; + } - [[fX264optDirectPredPopUp animator] setHidden:NO]; - [[fX264optDirectPredLabel animator] setHidden:NO]; + if( [fX264optWeightBSwitch isHidden] == true ) + { + [[fX264optWeightBSwitch animator] setHidden:NO]; + [[fX264optWeightBLabel animator] setHidden:NO]; + } + + if( [fX264optDirectPredPopUp isHidden] == true ) + { + [[fX264optDirectPredPopUp animator] setHidden:NO]; + [[fX264optDirectPredLabel animator] setHidden:NO]; + } + + if( [fX264optBAdaptPopUp isHidden] == true ) + { + [[fX264optBAdaptPopUp animator] setHidden:NO]; + [[fX264optBAdaptLabel animator] setHidden:NO]; + } + } + else + { + if( [fX264optBPyramidSwitch isHidden] == true ) + { + [[fX264optBPyramidSwitch animator] setHidden:NO]; + [[fX264optBPyramidLabel animator] setHidden:NO]; + } - [[fX264optBAdaptPopUp animator] setHidden:NO]; - [[fX264optBAdaptLabel animator] setHidden:NO]; + if( [fX264optWeightBSwitch isHidden] == true ) + { + [[fX264optWeightBSwitch animator] setHidden:NO]; + [[fX264optWeightBLabel animator] setHidden:NO]; + } + + if( [fX264optDirectPredPopUp isHidden] == true ) + { + [[fX264optDirectPredPopUp animator] setHidden:NO]; + [[fX264optDirectPredLabel animator] setHidden:NO]; + } + + if( [fX264optBAdaptPopUp isHidden] == true ) + { + [[fX264optBAdaptPopUp animator] setHidden:NO]; + [[fX264optBAdaptLabel animator] setHidden:NO]; + } + } } - if ( [fX264optCabacSwitch state] == false) + if( sender == fX264optCabacSwitch ) { - if( [fX264optTrellisPopUp isHidden] == false ) + if ( [fX264optCabacSwitch state] == false) { - /* Without CABAC entropy coding, trellis doesn't run. */ - [[fX264optTrellisPopUp animator] setHidden:YES]; - [[fX264optTrellisLabel animator] setHidden:YES]; - [fX264optTrellisPopUp selectItemAtIndex:0]; - if ( (sender != fX264optTrellisPopUp) && (sender != fX264optPsyTrellisSlider) ) + if( [fX264optTrellisPopUp isHidden] == false ) { + /* Without CABAC entropy coding, trellis doesn't run. */ + [[fX264optTrellisPopUp animator] setHidden:YES]; + [[fX264optTrellisLabel animator] setHidden:YES]; + [fX264optTrellisPopUp selectItemAtIndex:0]; [[fX264optTrellisPopUp cell] performClick:self]; } } - } - else if( [fX264optTrellisPopUp isHidden] == true) - { - [[fX264optTrellisPopUp animator] setHidden:NO]; - [[fX264optTrellisLabel animator] setHidden:NO]; - } - - if ( [fX264optAnalysePopUp indexOfSelectedItem] == 1) - { - /* No analysis? Disable 8x8dct */ - [[fX264opt8x8dctSwitch animator] setHidden:YES]; - [[fX264opt8x8dctLabel animator] setHidden:YES]; - if ( [fX264opt8x8dctSwitch state] == 1 && sender != fX264opt8x8dctSwitch ) - [fX264opt8x8dctSwitch performClick:self]; - } - else - { - [[fX264opt8x8dctSwitch animator] setHidden:NO]; - [[fX264opt8x8dctLabel animator] setHidden:NO]; + else if( [fX264optTrellisPopUp isHidden] == true) + { + [[fX264optTrellisPopUp animator] setHidden:NO]; + [[fX264optTrellisLabel 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]; - if ( [fX264optMixedRefsSwitch state] == 1 && sender != fX264optMixedRefsSwitch ) - [fX264optMixedRefsSwitch performClick:self]; - } - else + if( sender == fX264optAnalysePopUp ) { - [[fX264optMixedRefsSwitch animator] setHidden:NO]; - [[fX264optMixedRefsLabel animator] setHidden:NO]; + if ( [fX264optAnalysePopUp indexOfSelectedItem] == 1) + { + /* No analysis? Disable 8x8dct */ + if( [fX264opt8x8dctSwitch isHidden] == false ) + { + [[fX264opt8x8dctSwitch animator] setHidden:YES]; + [[fX264opt8x8dctLabel animator] setHidden:YES]; + if ( [fX264opt8x8dctSwitch state] == 1 ) + [fX264opt8x8dctSwitch performClick:self]; + } + } + else + { + if( [fX264opt8x8dctSwitch isHidden] == true ) + { + [[fX264opt8x8dctSwitch animator] setHidden:NO]; + [[fX264opt8x8dctLabel animator] setHidden:NO]; + } + } } - if ( [fX264optMotionEstPopUp indexOfSelectedItem] < 3 ) + if( sender == fX264optRefPopUp ) { - /* ME-range can only be above 16 if me >= umh - and changing it to < 16 is idiotic so hide it . */ - [[fX264optMERangePopUp animator] setHidden:YES]; - [[fX264optMERangeLabel animator] setHidden:YES]; - if (sender != fX264optMERangePopUp && [fX264optMERangePopUp indexOfSelectedItem] > 0 ) + if ( [fX264optRefPopUp indexOfSelectedItem] < 3) { - [fX264optMERangePopUp selectItemAtIndex:0]; - [[fX264optMERangePopUp cell] performClick:self]; + if( [fX264optMixedRefsSwitch isHidden] == false ) + { + /* Only do mixed-refs when there are at least 2 refs to mix. */ + [[fX264optMixedRefsSwitch animator] setHidden:YES]; + [[fX264optMixedRefsLabel animator] setHidden:YES]; + if( [fX264optMixedRefsSwitch state] == 1 ) + [fX264optMixedRefsSwitch performClick:self]; + } + } + else + { + if( [fX264optMixedRefsSwitch isHidden] == true ) + { + [[fX264optMixedRefsSwitch animator] setHidden:NO]; + [[fX264optMixedRefsLabel animator] setHidden:NO]; + } } - } - else - { - [[fX264optMERangePopUp animator] setHidden:NO]; - [[fX264optMERangeLabel animator] setHidden:NO]; } - if( [fX264optSubmePopUp indexOfSelectedItem] != 0 && [fX264optSubmePopUp indexOfSelectedItem] < 7 ) + if( sender == fX264optMotionEstPopUp ) { - /* No Psy-RDO or Psy=trel if subme < 6. */ - if( [fX264optPsyRDSlider isHidden] == false ) + if ( [fX264optMotionEstPopUp indexOfSelectedItem] < 3 ) { - [[fX264optPsyRDSlider animator] setHidden:YES]; - [[fX264optPsyRDLabel animator] setHidden:YES]; - [[fX264optPsyRDSlider animator] setFloatValue:1]; - if ( (sender != fX264optPsyRDSlider) && (sender != fX264optPsyTrellisSlider) ) + /* ME-range can only be above 16 if me >= umh + and changing it to < 16 is idiotic so hide it . */ + if( [fX264optMERangePopUp isHidden] == false ) { - [[fX264optPsyRDSlider cell] performClick:self]; + [[fX264optMERangePopUp animator] setHidden:YES]; + [[fX264optMERangeLabel animator] setHidden:YES]; + if ( [fX264optMERangePopUp indexOfSelectedItem] > 0 ) + { + [fX264optMERangePopUp selectItemAtIndex:0]; + [[fX264optMERangePopUp cell] performClick:self]; + } } } - - if( [fX264optPsyTrellisSlider isHidden] == false) + else { - [[fX264optPsyTrellisSlider animator] setHidden:YES]; - [[fX264optPsyTrellisLabel animator] setHidden:YES]; - [[fX264optPsyTrellisSlider animator] setFloatValue:0]; - if ( (sender != fX264optPsyTrellisSlider) && (sender != fX264optPsyRDSlider) ) + if( [fX264optMERangePopUp isHidden] == false ) { - [[fX264optPsyTrellisSlider cell] performClick:self]; + [[fX264optMERangePopUp animator] setHidden:NO]; + [[fX264optMERangeLabel animator] setHidden:NO]; } } } - else + + if( sender == fX264optSubmePopUp ) { - if( [fX264optPsyRDSlider isHidden] == true ) + if( [fX264optSubmePopUp indexOfSelectedItem] != 0 && [fX264optSubmePopUp indexOfSelectedItem] < 7 ) { - [[fX264optPsyRDSlider animator] setHidden:NO]; - [[fX264optPsyRDLabel animator] setHidden:NO]; + /* No Psy-RDO or Psy=trel if subme < 6. */ + if( [fX264optPsyRDSlider isHidden] == false ) + { + [[fX264optPsyRDSlider animator] setHidden:YES]; + [[fX264optPsyRDLabel animator] setHidden:YES]; + [[fX264optPsyRDSlider animator] setFloatValue:1]; + if ( [fX264optPsyRDSlider floatValue] < 1.0 ) + { + [fX264optPsyRDSlider setFloatValue:1.0]; + [[fX264optPsyRDSlider cell] performClick:self]; + } + } + + if( [fX264optPsyTrellisSlider isHidden] == false) + { + [[fX264optPsyTrellisSlider animator] setHidden:YES]; + [[fX264optPsyTrellisLabel animator] setHidden:YES]; + [[fX264optPsyTrellisSlider animator] setFloatValue:0]; + if ( [fX264optPsyTrellisSlider floatValue] > 0.0 ) + { + [fX264optPsyTrellisSlider setFloatValue:0.0]; + [[fX264optPsyTrellisSlider cell] performClick:self]; + } + } } - - if( [fX264optTrellisPopUp indexOfSelectedItem] >= 2 && [fX264optCabacSwitch state] == true && [fX264optPsyTrellisSlider isHidden] == true ) + else { - [[fX264optPsyTrellisSlider animator] setHidden:NO]; - [[fX264optPsyTrellisLabel animator] setHidden:NO]; + if( [fX264optPsyRDSlider isHidden] == true ) + { + [[fX264optPsyRDSlider animator] setHidden:NO]; + [[fX264optPsyRDLabel animator] setHidden:NO]; + } + + if( [fX264optTrellisPopUp indexOfSelectedItem] >= 2 && [fX264optCabacSwitch state] == true && [fX264optPsyTrellisSlider isHidden] == true ) + { + [[fX264optPsyTrellisSlider animator] setHidden:NO]; + [[fX264optPsyTrellisLabel animator] setHidden:NO]; + } } } - if( [fX264optTrellisPopUp indexOfSelectedItem] < 2 ) + if( sender == fX264optTrellisPopUp ) { - if( [fX264optPsyTrellisSlider isHidden] == false ) + if( [fX264optTrellisPopUp indexOfSelectedItem] < 2 ) { - /* No Psy-trellis without trellis. */ - [[fX264optPsyTrellisSlider animator] setHidden:YES]; - [[fX264optPsyTrellisLabel animator] setHidden:YES]; - [[fX264optPsyTrellisSlider animator] setFloatValue:0]; - if (sender != fX264optPsyTrellisSlider ) + if( [fX264optPsyTrellisSlider isHidden] == false ) { - [[fX264optPsyTrellisSlider cell] performClick:self]; + /* No Psy-trellis without trellis. */ + [[fX264optPsyTrellisSlider animator] setHidden:YES]; + [[fX264optPsyTrellisLabel animator] setHidden:YES]; + [[fX264optPsyTrellisSlider animator] setFloatValue:0.0]; + [[fX264optPsyTrellisSlider cell] performClick:self]; } } - } - else - { - if( ( [fX264optSubmePopUp indexOfSelectedItem] == 0 || [fX264optSubmePopUp indexOfSelectedItem] >= 7 ) && [fX264optCabacSwitch state] == true && [fX264optPsyTrellisSlider isHidden] == true ) + else { - [[fX264optPsyTrellisSlider animator] setHidden:NO]; - [[fX264optPsyTrellisLabel animator] setHidden:NO]; + if( ( [fX264optSubmePopUp indexOfSelectedItem] == 0 || [fX264optSubmePopUp indexOfSelectedItem] >= 7 ) && [fX264optCabacSwitch state] == true && [fX264optPsyTrellisSlider isHidden] == true ) + { + [[fX264optPsyTrellisSlider animator] setHidden:NO]; + [[fX264optPsyTrellisLabel animator] setHidden:NO]; + } } } } |