From 945cce88b9b26e88a08feeea6e5ea767ba0a72c7 Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 19 Mar 2008 21:29:22 +0000 Subject: WinGui: - The x264 tab has been replaced by a completely new panel with widgets for many of the available x264 options. It operates in a similar way to the macgui's panel. (It however will not disable widgets based on selections on other widgets yet(like the macgui does) this will come later when the bugs have been worked out. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1347 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Functions/Common.cs | 4 +- win/C#/Functions/x264Panel.cs | 1002 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1004 insertions(+), 2 deletions(-) create mode 100644 win/C#/Functions/x264Panel.cs (limited to 'win/C#/Functions') diff --git a/win/C#/Functions/Common.cs b/win/C#/Functions/Common.cs index 7100eb58d..0541fbb99 100644 --- a/win/C#/Functions/Common.cs +++ b/win/C#/Functions/Common.cs @@ -323,7 +323,7 @@ namespace Handbrake.Functions // H264 Tab & Preset Name #region other - mainWindow.rtf_h264advanced.Text = presetQuery.H264Query; + mainWindow.rtf_x264Query.Text = presetQuery.H264Query; // Set the preset name mainWindow.groupBox_output.Text = "Output Settings (Preset: " + name + ")"; @@ -782,7 +782,7 @@ namespace Handbrake.Functions // H264 Tab #region H264 Tab - string h264Advanced = mainWindow.rtf_h264advanced.Text; + string h264Advanced = mainWindow.rtf_x264Query.Text; if ((h264Advanced == "")) h264Advanced = ""; diff --git a/win/C#/Functions/x264Panel.cs b/win/C#/Functions/x264Panel.cs new file mode 100644 index 000000000..b781a8aad --- /dev/null +++ b/win/C#/Functions/x264Panel.cs @@ -0,0 +1,1002 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace Handbrake.Functions +{ + class x264Panel + { + Boolean NoWidgetUpdate = false; + + /// + /// Reset all components to defaults and clears the x264 rtf box + /// + public void reset2Defaults(frmMain mainWindow) + { + mainWindow.check_8x8DCT.CheckState = CheckState.Unchecked; + mainWindow.check_bFrameDistortion.CheckState = CheckState.Unchecked; + mainWindow.check_BidirectionalRefinement.CheckState = CheckState.Unchecked; + mainWindow.check_Cabac.CheckState = CheckState.Checked; + mainWindow.check_mixedReferences.CheckState = CheckState.Unchecked; + mainWindow.check_noDCTDecimate.CheckState = CheckState.Unchecked; + mainWindow.check_noFastPSkip.CheckState = CheckState.Unchecked; + mainWindow.check_pyrmidalBFrames.CheckState = CheckState.Unchecked; + mainWindow.check_weightedBFrames.CheckState = CheckState.Unchecked; + mainWindow.drop_analysis.SelectedIndex = 0; + mainWindow.drop_bFrames.SelectedIndex = 0; + mainWindow.drop_deblockAlpha.SelectedIndex = 0; + mainWindow.drop_deblockBeta.SelectedIndex = 0; + mainWindow.drop_directPrediction.SelectedIndex = 0; + mainWindow.drop_MotionEstimationMethod.SelectedIndex = 0; + mainWindow.drop_MotionEstimationRange.SelectedIndex = 0; + mainWindow.drop_refFrames.SelectedIndex = 0; + mainWindow.drop_subpixelMotionEstimation.SelectedIndex = 0; + mainWindow.drop_trellis.SelectedIndex = 0; + + mainWindow.rtf_x264Query.Text = ""; + } + + /// + /// Update GUI componets from the current x264 rtf string + /// + public void X264_SetCurrentSettingsInPanel(frmMain mainWindow) + { + // When the widgets are changed, we don't want them to update the text box again. No Need. + // This boolean controls the Widget Change function + + + /* Set widgets depending on the opt string in field */ + String thisOpt; // The separated option such as "bframes=3" + String optName = ""; // The option name such as "bframes" + String optValue = "";// The option value such as "3" + String[] currentOptsArray; + + //Set currentOptString to the contents of the text box. + String currentOptString = mainWindow.rtf_x264Query.Text.Replace("\n", ""); + + /*verify there is an opt string to process */ + if (currentOptString.Contains("=")) + { + /*Put individual options into an array based on the ":" separator for processing, result is "="*/ + currentOptsArray = currentOptString.Split(':'); + + /*iterate through the array and get and and + /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box + /// + public void X264_StandardizeOptString(frmMain mainWindow) + { + /* Set widgets depending on the opt string in field */ + String thisOpt; // The separated option such as "bframes=3" + String optName = ""; // The option name such as "bframes" + String optValue = "";// The option value such as "3" + String changedOptString = ""; + String[] currentOptsArray; + + /*First, we get an opt string to process */ + String currentOptString = mainWindow.rtf_x264Query.Text; + + /*verify there is an opt string to process */ + if (currentOptString.Contains("=")) + { + /*Put individual options into an array based on the ":" separator for processing, result is "="*/ + currentOptsArray = currentOptString.Split(':'); + + /*iterate through the array and get and + /// This function will update the X264 Query when one of the GUI widgets changes. + /// + public void on_x264_WidgetChange(string sender, frmMain mainWindow) + { + if (NoWidgetUpdate == false) + { + String optNameToChange = sender; + String currentOptString = mainWindow.rtf_x264Query.Text; + + /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after + the first character of the opt string (hence the ":") */ + String checkOptNameToChange = ":" + optNameToChange + "="; + String checkOptNameToChangeBegin = optNameToChange + "="; + + // IF the current H264 Option String Contains Multiple Items or Just 1 Item + if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin))) + hasFullOption(currentOptString, optNameToChange, mainWindow); + else // IF there is no options in the rich text box! + hasNoOptions(optNameToChange, mainWindow); + } + else + { + NoWidgetUpdate = false; + } + } + + + #region Some Private Functions used by the above Public Functions + /* + * Used by on_x264_WidgetChange() + * Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by : + * Basically, it updates the current option that the widget corrosponds to, if it is already in thes string + * otherwise, it adds it to the string. + */ + private void hasFullOption(string currentOptString, string optNameToChange, frmMain mainWindow) + { + String thisOpt; // The separated option such as "bframes=3" + String optName = ""; // The option name such as "bframes" + String optValue = ""; // The option value such as "3" + String[] currentOptsArray; + + /* Create new empty opt string*/ + String changedOptString = ""; + + /*Put individual options into an array based on the ":" separator for processing, result is "="*/ + currentOptsArray = currentOptString.Split(':'); + + /*iterate through the array and get and