]> granicus.if.org Git - handbrake/commitdiff
WinGui: Improve the SourceMax / Custom Picture Settings modes. Fixes a numer of edge...
authorsr55 <sr55.hb@outlook.com>
Mon, 2 Jan 2017 13:59:32 +0000 (13:59 +0000)
committersr55 <sr55.hb@outlook.com>
Mon, 2 Jan 2017 14:00:17 +0000 (14:00 +0000)
win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs

index 2facf2c66c8e0f89cb85c57a1785e3ea8e7a29cd..52877f61ffaeed3b124ba0b9c474b1b6f24e49d4 100644 (file)
@@ -238,8 +238,8 @@ namespace HandBrakeWPF.ViewModels
 \r
             if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.SourceMaximum)\r
             {\r
-                this.Preset.Task.MaxWidth = selectedTitle.Resolution.Width;\r
-                this.Preset.Task.MaxHeight = selectedTitle.Resolution.Height;\r
+                this.Preset.Task.MaxHeight = null;\r
+                this.Preset.Task.MaxWidth = null;\r
             }\r
 \r
             // Add the Preset\r
index e4e8e0075fde1eb3dfe2fe9bfced858c730216c8..a428144c0fa9ea6c2f541fb828dfb3dae3387493 100644 (file)
@@ -643,8 +643,8 @@ namespace HandBrakeWPF.ViewModels
                     }             \r
 \r
                     // Set the width, then check the height doesn't breach the max height and correct if necessary.\r
-                    int width = this.GetModulusValue(this.GetRes((this.sourceResolution.Width - this.CropLeft - this.CropRight), preset.Task.MaxWidth));\r
-                    int height = this.GetModulusValue(this.GetRes((this.sourceResolution.Height - this.CropTop - this.CropBottom), preset.Task.MaxHeight));\r
+                    int width = this.GetModulusValue(this.GetRes((this.sourceResolution.Width - this.CropLeft - this.CropRight), this.MaxWidth));\r
+                    int height = this.GetModulusValue(this.GetRes((this.sourceResolution.Height - this.CropTop - this.CropBottom), this.MaxHeight));\r
 \r
                     // Set the backing fields to avoid triggering recalulation until both are set.\r
                     this.Task.Width = width;\r
@@ -663,6 +663,14 @@ namespace HandBrakeWPF.ViewModels
                     this.MaxWidth = this.sourceResolution.Width;\r
                     this.MaxHeight = this.sourceResolution.Height;\r
                     this.SelectedAnamorphicMode = preset.Task.Anamorphic;\r
+\r
+                    if (this.Width > this.MaxWidth)\r
+                    {\r
+                        // Trigger a Recalc\r
+                        this.Task.Width = this.GetModulusValue(this.GetRes((this.sourceResolution.Width - this.CropLeft - this.CropRight), this.MaxWidth));\r
+                        this.RecaulcatePictureSettingsProperties(ChangedPictureField.Width);\r
+                    }\r
+\r
                     break;\r
             }\r
 \r
@@ -754,43 +762,42 @@ namespace HandBrakeWPF.ViewModels
                     this.IsCustomCrop = true;\r
                 }\r
 \r
+                // Set the Max Width / Height available to the user controls.\r
+                // Preset Max is null for None / SourceMax\r
+                this.MaxWidth = preset.Task.MaxWidth ?? this.sourceResolution.Width;\r
+                if (this.sourceResolution.Width < this.MaxWidth)\r
+                {\r
+                    this.MaxWidth = this.sourceResolution.Width;\r
+                }\r
+\r
+                this.MaxHeight = preset.Task.MaxHeight ?? this.sourceResolution.Height;\r
+                if (this.sourceResolution.Height < this.MaxHeight)\r
+                {\r
+                    this.MaxHeight = this.sourceResolution.Height;\r
+                }\r
+\r
+                // Set the W/H\r
                 if (preset.PictureSettingsMode == PresetPictureSettingsMode.None)\r
                 {\r
-                    // We have no instructions, so simply set it to the source.\r
                     this.Task.Width = this.GetModulusValue(this.sourceResolution.Width - this.CropLeft - this.CropRight);\r
                     this.Task.Height = this.GetModulusValue(this.sourceResolution.Height - this.CropTop - this.CropBottom);\r
-                    this.MaintainAspectRatio = true;\r
                 }\r
-                else\r
+                else if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)\r
+                {\r
+                    this.Task.Width = this.GetModulusValue(this.sourceResolution.Width - this.CropLeft - this.CropRight);\r
+                    this.Task.Height = this.GetModulusValue(this.sourceResolution.Height - this.CropTop - this.CropBottom);\r
+                    this.MaintainAspectRatio = preset.Task.KeepDisplayAspect;\r
+                }\r
+                else // Custom\r
                 {\r
-                    // Set the Max Width / Height available to the user controls.\r
-                    this.MaxWidth = preset.Task.MaxWidth ?? this.sourceResolution.Width;\r
-                    if (this.sourceResolution.Width < this.MaxWidth)\r
-                    {\r
-                        this.MaxWidth = this.sourceResolution.Width;\r
-                    }\r
-\r
-                    this.MaxHeight = preset.Task.MaxHeight ?? this.sourceResolution.Height;\r
-                    if (this.sourceResolution.Height < this.MaxHeight)\r
-                    {\r
-                        this.MaxHeight = this.sourceResolution.Height;\r
-                    }\r
-\r
                     // Set the Width, and Maintain Aspect ratio. That should calc the Height for us.\r
-                    if (this.SelectedAnamorphicMode == Anamorphic.None)\r
+                    this.Task.Width = this.GetModulusValue(this.MaxWidth - this.CropLeft - this.CropRight);\r
+\r
+                    if (this.SelectedAnamorphicMode != Anamorphic.Loose)\r
                     {\r
-                        this.Task.Width = preset.Task.Width ?? this.GetModulusValue(this.MaxWidth - this.CropLeft - this.CropRight);\r
                         this.Task.Height = this.GetModulusValue(this.MaxHeight - this.CropTop - this.CropBottom);\r
-                        // Note: This will be auto-corrected in the property if it's too large.\r
-                    }\r
-                    else\r
-                    {\r
-                        this.Task.Width = preset.Task.Width ?? this.MaxWidth;\r
-\r
-                        int cropHeight = this.Task.Cropping.Top + this.Task.Cropping.Bottom;\r
-                        this.Task.Height = (preset.Task.Height ?? this.MaxHeight) - cropHeight;\r
                     }\r
-\r
\r
                     // If our height is too large, let it downscale the width for us by setting the height to the lower value.\r
                     if (!this.MaintainAspectRatio && this.Height > this.MaxHeight)\r
                     {\r