]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Sat, 9 Jan 2010 22:49:50 +0000 (22:49 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 9 Jan 2010 22:49:50 +0000 (22:49 +0000)
- If crop values are stored in the preset and the user has decided to enable them in the preset, the gui will not longer reset the crop panel on title change.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3062 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Controls/PictureSettings.cs
win/C#/Presets/PresetsHandler.cs
win/C#/frmMain.cs

index d46efb8f288f7d29cdb09e445efb6783731a7b20..a0c269f5ea11bda523d1d8ccffd7754bdcec4d2a 100644 (file)
@@ -4,6 +4,7 @@ using System.Drawing;
 using System.Globalization;\r
 using System.Windows.Forms;\r
 using Handbrake.Parsing;\r
+using Handbrake.Presets;\r
 \r
 namespace Handbrake.Controls\r
 {\r
@@ -42,11 +43,21 @@ namespace Handbrake.Controls
                 lbl_Aspect.Text = _sourceTitle.AspectRatio.ToString(Culture);\r
                 lbl_src_res.Text = _sourceTitle.Resolution.Width + " x " + _sourceTitle.Resolution.Height;\r
 \r
-                // Set the Recommended Cropping values\r
-                crop_top.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[0]);\r
-                crop_bottom.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[1]);\r
-                crop_left.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[2]);\r
-                crop_right.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[3]);\r
+                // Set the Recommended Cropping values, but only if a preset doesn't have hard set picture settings.\r
+                if (CurrentlySelectedPreset != null && CurrentlySelectedPreset.PictureSettings == false)\r
+                {\r
+                    crop_top.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[0]);\r
+                    crop_bottom.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[1]);\r
+                    crop_left.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[2]);\r
+                    crop_right.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[3]);\r
+                }\r
+                else if (CurrentlySelectedPreset == null )\r
+                {\r
+                    crop_top.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[0]);\r
+                    crop_bottom.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[1]);\r
+                    crop_left.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[2]);\r
+                    crop_right.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[3]);\r
+                }\r
 \r
                 // Set the Resolution Boxes\r
                 if (drp_anamorphic.SelectedIndex == 0)\r
@@ -74,11 +85,16 @@ namespace Handbrake.Controls
 \r
 \r
                 Size croppedDar = CalculateAnamorphicSizes();\r
-                _cachedDar = (double) croppedDar.Width/croppedDar.Height;\r
+                _cachedDar = (double)croppedDar.Width / croppedDar.Height;\r
                 updownDisplayWidth.Value = croppedDar.Width;\r
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Which preset is currently selected by the user.\r
+        /// </summary>\r
+        public Preset CurrentlySelectedPreset { get; set; }\r
+\r
         /// <summary>\r
         /// Gets or sets the maximum allowable size for the encoded resolution. Set a value to\r
         /// "0" if the maximum does not matter.\r
@@ -269,7 +285,7 @@ namespace Handbrake.Controls
 \r
                 // Calculate new Height Value\r
                 int modulus;\r
-                if(!int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus))\r
+                if (!int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus))\r
                     modulus = 16;\r
 \r
                 int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / _cachedDar);\r
@@ -451,7 +467,7 @@ namespace Handbrake.Controls
                             - Uses mod16-compliant dimensions,\r
                             - Allows users to set the width\r
                         */\r
-                        width = (int) text_width.Value;\r
+                        width = (int)text_width.Value;\r
                         width = GetModulusValue(width); /* Time to get picture width that divide cleanly.*/\r
 \r
                         height = (width / storage_aspect) + 0.5;\r
@@ -506,7 +522,7 @@ namespace Handbrake.Controls
         // Hidden UI feature to drop the MaxWidth / Height with the MaxWidth/Height label is double clicked\r
         private void lbl_max_DoubleClick(object sender, EventArgs e)\r
         {\r
-            PresetMaximumResolution = new Size(0,0);\r
+            PresetMaximumResolution = new Size(0, 0);\r
             if (PictureSettingsChanged != null)\r
                 PictureSettingsChanged(this, new EventArgs());\r
         }\r
index 05c0243ab837794e1b34076693357b8b193c11a9..a26538b73cf51dda8fbe1b74cf4c9891964d9b19 100644 (file)
@@ -167,13 +167,17 @@ namespace Handbrake.Presets
                         Regex r = new Regex("(:  )"); // Split on hyphens. \r
                         string[] presetName = r.Split(line);\r
 \r
+                        bool pic = false;\r
+                        if (presetName[2].Contains("crop"))\r
+                            pic = true;\r
+\r
                         Preset newPreset = new Preset\r
                                                {\r
                                                    Category = category,\r
                                                    Name = presetName[0].Replace("+", "").Trim(),\r
                                                    Query = presetName[2],\r
                                                    Version = Properties.Settings.Default.hb_version,\r
-                                                   PictureSettings = true\r
+                                                   PictureSettings = pic\r
                                                };\r
                         _presets.Add(newPreset);\r
                     }\r
index b6fda2d32d29fe4abd3dc21e944c1a479163c312..546ef4efb6ef8c8cc98e2c53421f855633e2b79d 100644 (file)
@@ -37,6 +37,7 @@ namespace Handbrake
         private SourceType selectedSourceType;\r
         private string dvdDrivePath;\r
         private string dvdDriveLabel;\r
+        private Preset CurrentlySelectedPreset;\r
 \r
         // Delegates **********************************************************\r
         private delegate void UpdateWindowHandler();\r
@@ -283,6 +284,7 @@ namespace Handbrake
         private void changePresetLabel(object sender, EventArgs e)\r
         {\r
             labelPreset.Text = "Output Settings (Preset: Custom)";\r
+            CurrentlySelectedPreset = null;\r
         }\r
 \r
         private static void frmMain_DragEnter(object sender, DragEventArgs e)\r
@@ -578,7 +580,8 @@ namespace Handbrake
             {\r
                 // Ok, so, we've selected a preset. Now we want to load it.\r
                 string presetName = treeView_presets.SelectedNode.Text;\r
-                if (presetHandler.GetPreset(presetName) != null)\r
+                Preset preset = presetHandler.GetPreset(presetName);\r
+                if (preset != null)\r
                 {\r
                     string query = presetHandler.GetPreset(presetName).Query;\r
                     Boolean loadPictureSettings = presetHandler.GetPreset(presetName).PictureSettings;\r
@@ -597,6 +600,9 @@ namespace Handbrake
                         // The x264 widgets will need updated, so do this now:\r
                         x264Panel.X264_StandardizeOptString();\r
                         x264Panel.X264_SetCurrentSettingsInPanel();\r
+\r
+                        // Finally, let this window have a copy of the preset settings.\r
+                        CurrentlySelectedPreset = preset;\r
                     }\r
                 }\r
             }\r
@@ -903,6 +909,7 @@ namespace Handbrake
             {\r
                 selectedTitle = drp_dvdtitle.SelectedItem as Title;\r
                 lbl_duration.Text = selectedTitle.Duration.ToString();\r
+                PictureSettings.CurrentlySelectedPreset = CurrentlySelectedPreset;\r
                 PictureSettings.Source = selectedTitle;  // Setup Picture Settings Tab Control\r
 \r
                 // Populate the Angles dropdown\r