OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 8 Jun 2009 16:18:38 +0000 (16:18 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 8 Jun 2009 16:18:38 +0000 (16:18 +0000)
- Fixes some crashes in the new picture settings panel and hooks up the presetLoader and query parser so they work with the new options.

git-svn-id: svn://localhost/HandBrake/trunk@2502 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Controls/PictureSettings.Designer.cs
win/C#/Controls/PictureSettings.cs
win/C#/Functions/PresetLoader.cs
win/C#/Functions/QueryParser.cs
win/C#/frmTestWindow.cs

index a5a79d8..c033f74 100644 (file)
@@ -63,7 +63,7 @@ namespace Handbrake.Controls
             this.Label51 = new System.Windows.Forms.Label();\r
             this.Label15 = new System.Windows.Forms.Label();\r
             this.lbl_anamorphic = new System.Windows.Forms.Label();\r
-            this.label3 = new System.Windows.Forms.Label();\r
+            this.lbl_anamprohicLbl = new System.Windows.Forms.Label();\r
             ((System.ComponentModel.ISupportInitialize)(this.text_height)).BeginInit();\r
             ((System.ComponentModel.ISupportInitialize)(this.text_width)).BeginInit();\r
             ((System.ComponentModel.ISupportInitialize)(this.crop_bottom)).BeginInit();\r
@@ -468,21 +468,21 @@ namespace Handbrake.Controls
             this.lbl_anamorphic.TabIndex = 74;\r
             this.lbl_anamorphic.Text = "Select a Title";\r
             // \r
-            // label3\r
+            // lbl_anamprohicLbl\r
             // \r
-            this.label3.AutoSize = true;\r
-            this.label3.BackColor = System.Drawing.Color.Transparent;\r
-            this.label3.Location = new System.Drawing.Point(13, 221);\r
-            this.label3.Name = "label3";\r
-            this.label3.Size = new System.Drawing.Size(66, 13);\r
-            this.label3.TabIndex = 73;\r
-            this.label3.Text = "Anamorphic:";\r
+            this.lbl_anamprohicLbl.AutoSize = true;\r
+            this.lbl_anamprohicLbl.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_anamprohicLbl.Location = new System.Drawing.Point(13, 221);\r
+            this.lbl_anamprohicLbl.Name = "lbl_anamprohicLbl";\r
+            this.lbl_anamprohicLbl.Size = new System.Drawing.Size(66, 13);\r
+            this.lbl_anamprohicLbl.TabIndex = 73;\r
+            this.lbl_anamprohicLbl.Text = "Anamorphic:";\r
             // \r
             // PictureSettings\r
             // \r
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;\r
             this.Controls.Add(this.lbl_anamorphic);\r
-            this.Controls.Add(this.label3);\r
+            this.Controls.Add(this.lbl_anamprohicLbl);\r
             this.Controls.Add(this.check_customCrop);\r
             this.Controls.Add(this.check_autoCrop);\r
             this.Controls.Add(this.crop_bottom);\r
@@ -563,7 +563,7 @@ namespace Handbrake.Controls
         internal System.Windows.Forms.TextBox txt_parHeight;\r
         internal System.Windows.Forms.CheckBox check_KeepAR;\r
         internal System.Windows.Forms.Label lbl_anamorphic;\r
-        internal System.Windows.Forms.Label label3;\r
+        internal System.Windows.Forms.Label lbl_anamprohicLbl;\r
 \r
     }\r
 }\r
index 1563e86..b9626f1 100644 (file)
@@ -13,8 +13,6 @@ namespace Handbrake.Controls
      *  - Code needs cleaned up and a ton of bugs probably need fixed.\r
      */ \r
 \r
-\r
-\r
     /*\r
      * DISPLAY WIDTH       STORAGE WIDTH   PIXEL WIDTH\r
      * HEIGHT              KEEP ASPECT     PIXEL HEIGHT\r
@@ -202,6 +200,7 @@ namespace Handbrake.Controls
                     text_height.Text = heightVal.ToString();\r
                     check_KeepAR.Enabled = true;\r
                     lbl_anamorphic.Text = "";\r
+                    lbl_anamprohicLbl.Visible = false;\r
                     break;\r
                 case 1: // Strict\r
                     text_height.BackColor = Color.LightGray;\r
@@ -214,17 +213,22 @@ namespace Handbrake.Controls
                     check_KeepAR.Enabled = false;\r
                     disableCustomAnaControls();\r
                     lbl_anamorphic.Text = strictAnamorphic();\r
+                    lbl_anamprohicLbl.Visible = true;\r
                     break;\r
                 case 2: // Loose\r
                     storageAspect = 0;\r
-                    text_width.Text = widthVal.ToString();\r
-                    text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;\r
+                    if (selectedTitle != null)\r
+                    {\r
+                        text_width.Value = selectedTitle.Resolution.Width - (int) crop_left.Value - (int) crop_right.Value;\r
+                        text_height.Value = selectedTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;\r
+                    }\r
                     text_height.Enabled = false;\r
                     text_height.BackColor = Color.LightGray;\r
                     text_width.Enabled = true;\r
                     text_width.BackColor = Color.White;\r
                     disableCustomAnaControls();\r
                     lbl_anamorphic.Text = looseAnamorphic();\r
+                    lbl_anamprohicLbl.Visible = true;\r
                     break;\r
                 case 3: // Custom\r
 \r
@@ -235,19 +239,22 @@ namespace Handbrake.Controls
                     text_height.Enabled = true;\r
                     text_width.Enabled = true;\r
 \r
-                    // Actual Work                \r
-                    text_width.Text = widthVal.ToString();\r
-                    text_height.Text = cacluateHeight(widthVal).ToString(); // Bug here\r
-\r
-                    txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();\r
-                    txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();\r
-                    txt_displayWidth.Text = displayWidth().ToString();\r
-\r
+                    // Actual Work  \r
+                    if (selectedTitle != null)\r
+                    {\r
+                        widthVal = selectedTitle.Resolution.Width;\r
+                        text_width.Text = widthVal.ToString();\r
+                        text_height.Text = cacluateHeight(widthVal).ToString();\r
+                        txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();\r
+                        txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();\r
+                        txt_displayWidth.Text = displayWidth().ToString();\r
+                    }\r
+   \r
                     darValue = calculateDar();\r
 \r
                     check_KeepAR.CheckState = CheckState.Checked;\r
                     check_KeepAR.Enabled = true;\r
-\r
+                    lbl_anamprohicLbl.Visible = true;\r
 \r
                     break;\r
             }\r
@@ -573,40 +580,45 @@ namespace Handbrake.Controls
         }\r
         private int cacluateHeight(int width)\r
         {\r
-            int aw = 0;\r
-            int ah = 0;\r
-            if (selectedTitle.AspectRatio.ToString() == "1.78")\r
-            {\r
-                aw = 16;\r
-                ah = 9;\r
-            }\r
-            else if (selectedTitle.AspectRatio.ToString() == "1.33")\r
-            {\r
-                aw = 4;\r
-                ah = 3;\r
-            }\r
-\r
-            if (aw != 0)\r
+            if (selectedTitle != null)\r
             {\r
-                // Crop_Width = Title->Width - crop_Left - crop_right\r
-                // Crop_Height = Title->Height - crop_top - crop_bottom\r
-                double crop_width = selectedTitle.Resolution.Width - (double)crop_left.Value - (double)crop_right.Value;\r
-                double crop_height = selectedTitle.Resolution.Height - (double)crop_top.Value - (double)crop_bottom.Value;\r
-\r
-                double new_height = (width * selectedTitle.Resolution.Width * ah * crop_height) /\r
-                                    (selectedTitle.Resolution.Height * aw * crop_width);\r
-\r
-                if (drp_anamorphic.SelectedIndex == 3)\r
-                    new_height = getModulusAuto(int.Parse(drop_modulus.SelectedItem.ToString()), new_height);\r
-                else\r
-                    new_height = getModulusAuto(16, new_height);\r
+                int aw = 0;\r
+                int ah = 0;\r
+                if (selectedTitle.AspectRatio.ToString() == "1.78")\r
+                {\r
+                    aw = 16;\r
+                    ah = 9;\r
+                }\r
+                else if (selectedTitle.AspectRatio.ToString() == "1.33")\r
+                {\r
+                    aw = 4;\r
+                    ah = 3;\r
+                }\r
 \r
-                //16 * (421 / 16)\r
-                //double z = ( 16 * (( y + 8 ) / 16 ) );\r
-                int x = int.Parse(new_height.ToString());\r
-                if (x < 64)\r
-                    x = 64;\r
-                return x;\r
+                if (aw != 0)\r
+                {\r
+                    // Crop_Width = Title->Width - crop_Left - crop_right\r
+                    // Crop_Height = Title->Height - crop_top - crop_bottom\r
+                    double crop_width = selectedTitle.Resolution.Width - (double) crop_left.Value -\r
+                                        (double) crop_right.Value;\r
+                    double crop_height = selectedTitle.Resolution.Height - (double) crop_top.Value -\r
+                                         (double) crop_bottom.Value;\r
+\r
+                    double new_height = (width*selectedTitle.Resolution.Width*ah*crop_height)/\r
+                                        (selectedTitle.Resolution.Height*aw*crop_width);\r
+\r
+                    if (drp_anamorphic.SelectedIndex == 3)\r
+                        new_height = getModulusAuto(int.Parse(drop_modulus.SelectedItem.ToString()), new_height);\r
+                    else\r
+                        new_height = getModulusAuto(16, new_height);\r
+\r
+                    //16 * (421 / 16)\r
+                    //double z = ( 16 * (( y + 8 ) / 16 ) );\r
+                    int x = int.Parse(new_height.ToString());\r
+                    if (x < 64)\r
+                        x = 64;\r
+                    return x;\r
+                }\r
             }\r
             return 0;\r
         }\r
@@ -683,6 +695,9 @@ namespace Handbrake.Controls
                 double hcalc = (actualWidth / storageAspect) + 0.5;\r
                 double newHeight = getModulusAuto(16, hcalc);\r
                 looseAnamorphicHeightGuard = true;\r
+\r
+                if (newHeight < 64)\r
+                    newHeight = 64;\r
                 text_height.Value = (decimal)newHeight;   // BUG Out of Range Exception with Width too low here.\r
 \r
                 // Calculate the anamorphic width\r
index 2434ad4..dd5fa7c 100644 (file)
@@ -99,16 +99,19 @@ namespace Handbrake.Functions
                     mainWindow.pictureSettings.text_height.Text = presetQuery.Height.ToString();\r
             }\r
 \r
-            mainWindow.pictureSettings.drp_anamorphic.SelectedIndex = presetQuery.Anamorphic ? 1 : 0;\r
+            // Set the anamorphic mode 0,1,2,3\r
+            mainWindow.pictureSettings.drp_anamorphic.SelectedIndex = presetQuery.AnamorphicMode;\r
 \r
-            if (presetQuery.LooseAnamorphic)\r
-                mainWindow.pictureSettings.drp_anamorphic.SelectedIndex = 2;\r
-            else\r
-            {\r
-                if (presetQuery.Anamorphic != true)\r
-                    mainWindow.pictureSettings.drp_anamorphic.SelectedIndex = 0;\r
-            }\r
 \r
+            // Custom Anamorphic Controls\r
+            mainWindow.pictureSettings.check_KeepAR.CheckState = presetQuery.keepDisplayAsect ? CheckState.Checked : CheckState.Unchecked;\r
+\r
+            mainWindow.pictureSettings.txt_displayWidth.Text = presetQuery.displayWidthValue.ToString();\r
+            mainWindow.pictureSettings.txt_parWidth.Text = presetQuery.pixelAspectWidth.ToString();\r
+            mainWindow.pictureSettings.txt_parHeight.Text = presetQuery.pixelAspectHeight.ToString();\r
+            mainWindow.pictureSettings.drop_modulus.SelectedItem = presetQuery.AnamorphicModulus;\r
+\r
\r
             // Set the public max width and max height varibles in frmMain\r
             // These are used by the query generator to determine if it should use -X or -w  / -Y or -h\r
             if (presetQuery.MaxWidth != 0)\r
index ff621c6..659073a 100644 (file)
@@ -41,8 +41,12 @@ namespace Handbrake.Functions
         public string CropBottom { get; private set; }\r
         public string CropLeft { get; private set; }\r
         public string CropRight { get; private set; }\r
-        public Boolean Anamorphic { get; private set; }\r
-        public Boolean LooseAnamorphic { get; private set; }\r
+        public int AnamorphicMode { get; private set; }\r
+        public Boolean keepDisplayAsect { get; private set; }\r
+        public double displayWidthValue { get; private set; }\r
+        public int pixelAspectWidth { get; private set; }\r
+        public int pixelAspectHeight { get; private set; }\r
+        public int AnamorphicModulus { get; private set; }\r
         #endregion\r
 \r
         #region Video Filters\r
@@ -113,8 +117,15 @@ namespace Handbrake.Functions
             Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");\r
             Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");\r
             Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");\r
-            Match lanamorphic = Regex.Match(input, @" -P");\r
-            Match anamorphic = Regex.Match(input, @" -p ");\r
+\r
+            Match looseAnamorphic = Regex.Match(input, @"--loose-anamorphic");\r
+            Match strictAnamorphic = Regex.Match(input, @"--strict-anamorphic");\r
+            Match customAnamorphic = Regex.Match(input, @"--custom-anamorphic");\r
+\r
+            Match keepDisplayAsect = Regex.Match(input, @"--keep-display-aspect");\r
+            Match displayWidth = Regex.Match(input, @"--display-width ([0-9*])");\r
+            Match pixelAspect = Regex.Match(input, @"--pixel-aspect ([0-9]*):([0-9]*)");\r
+            Match modulus = Regex.Match(input, @"--modulus ([0-9*])");\r
 \r
             // Picture Settings - Filters\r
             Match decomb = Regex.Match(input, @" --decomb");\r
@@ -196,16 +207,16 @@ namespace Handbrake.Functions
                 #region Picture Tab\r
 \r
                 if (width.Success)\r
-                    thisQuery.Width = int.Parse(width.ToString().Replace("-w ", ""));\r
-\r
+                    thisQuery.Width = int.Parse(width.Groups[0].Value.Replace("-w ", ""));\r
+                                                              \r
                 if (height.Success)\r
-                    thisQuery.Height = int.Parse(height.ToString().Replace("-l ", ""));\r
+                    thisQuery.Height = int.Parse(height.Groups[0].Value.Replace("-l ", ""));\r
 \r
                 if (maxWidth.Success)\r
-                    thisQuery.MaxWidth = int.Parse(maxWidth.ToString().Replace("-X ", ""));\r
+                    thisQuery.MaxWidth = int.Parse(maxWidth.Groups[0].Value.Replace("-X ", ""));\r
 \r
                 if (maxHeight.Success)\r
-                    thisQuery.MaxHeight = int.Parse(maxHeight.ToString().Replace("-Y ", ""));\r
+                    thisQuery.MaxHeight = int.Parse(maxHeight.Groups[0].Value.Replace("-Y ", ""));\r
 \r
                 if (crop.Success)\r
                 {\r
@@ -217,8 +228,29 @@ namespace Handbrake.Functions
                     thisQuery.CropRight = actCropValues[3];\r
                 }\r
 \r
-                thisQuery.Anamorphic = anamorphic.Success;\r
-                thisQuery.LooseAnamorphic = lanamorphic.Success;\r
+                if (strictAnamorphic.Success)\r
+                    thisQuery.AnamorphicMode = 1;\r
+                else if (looseAnamorphic.Success)\r
+                    thisQuery.AnamorphicMode = 2;\r
+                else if (customAnamorphic.Success)\r
+                    thisQuery.AnamorphicMode = 3;\r
+                else\r
+                    thisQuery.AnamorphicMode = 0;\r
+\r
+                thisQuery.keepDisplayAsect = keepDisplayAsect.Success;\r
+\r
+                if (displayWidth.Success)\r
+                    thisQuery.displayWidthValue = double.Parse(displayWidth.Groups[0].Value.Replace("--display-width ", ""));\r
+\r
+                if (pixelAspect.Success)\r
+                    thisQuery.pixelAspectWidth = int.Parse(pixelAspect.Groups[0].Value.Replace("--pixel-aspect ", ""));\r
+\r
+                if (pixelAspect.Success)\r
+                    thisQuery.pixelAspectHeight = int.Parse(pixelAspect.Groups[1].Value.Replace("--pixel-aspect ", ""));\r
+\r
+                if (modulus.Success)\r
+                    thisQuery.AnamorphicModulus = int.Parse(modulus.Groups[0].Value.Replace("--modulus ", ""));\r
+\r
 \r
                 #endregion\r
 \r
@@ -400,7 +432,6 @@ namespace Handbrake.Functions
 \r
             return thisQuery;\r
         }\r
-\r
         private static string getMixDown(string mixdown)\r
         {\r
             switch (mixdown.Trim())\r
index 1606a77..a7dd567 100644 (file)
@@ -49,10 +49,7 @@ namespace Handbrake.Functions
                 rtf_testContent.Text += "Max Width: " + parsed.MaxWidth + Environment.NewLine;\r
             if (parsed.MaxHeight != 0)\r
                 rtf_testContent.Text += "Max Height: " + parsed.MaxHeight + Environment.NewLine;\r
-            if (parsed.Anamorphic)\r
-                rtf_testContent.Text += "Anamorphic: " + parsed.Anamorphic + Environment.NewLine;\r
-            if (parsed.LooseAnamorphic)\r
-                rtf_testContent.Text += "Loose Anamorphic: " + parsed.LooseAnamorphic + Environment.NewLine;\r
+            rtf_testContent.Text += "Anamorphic Mode: " + parsed.AnamorphicMode + Environment.NewLine;\r
 \r
             //Picture Settings - Filters\r
             rtf_testContent.Text += Environment.NewLine + "## Filters " + Environment.NewLine;\r