]> granicus.if.org Git - handbrake/commitdiff
WinGui: Fix a couple of the issues with the Picture settings view with regard to...
authorsr55 <sr55.hb@outlook.com>
Sun, 17 Jun 2012 20:19:28 +0000 (20:19 +0000)
committersr55 <sr55.hb@outlook.com>
Sun, 17 Jun 2012 20:19:28 +0000 (20:19 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4747 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs

index eff48d0e580ac6ce3985ff017e40379b3d0a2ea2..006e8373a0ec8c527e7d3a266114cc8a558ee906 100644 (file)
@@ -32,8 +32,9 @@ namespace HandBrakeWPF.ViewModels
     {\r
         /*\r
          * TODO:\r
-         * Handle Presets when a new title is set\r
-         * Handle changes in cropping affecting the resolution calcuation.\r
+         * - We are not handling cropping correctly within the UI.\r
+         * - The Height is not correctly set when using no Anamorphic\r
+         * - Maintain Aspect ratio needs corrected.\r
          * \r
          */\r
         #region Constants and Fields\r
@@ -88,6 +89,16 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         private bool showDisplaySize;\r
 \r
+        /// <summary>\r
+        /// Backing field for max height\r
+        /// </summary>\r
+        private int maxHeight;\r
+\r
+        /// <summary>\r
+        /// Backing field for max width\r
+        /// </summary>\r
+        private int maxWidth;\r
+\r
         #endregion\r
 \r
         #region Constructors and Destructors\r
@@ -106,6 +117,10 @@ namespace HandBrakeWPF.ViewModels
             this.Task = new EncodeTask();\r
             this.SelectedModulus = 16;\r
             this.MaintainAspectRatio = true;\r
+\r
+            // Default the Max Width / Height to 1080p format\r
+            this.MaxHeight = 1080;\r
+            this.MaxWidth = 1920;\r
         }\r
 \r
         #endregion\r
@@ -491,6 +506,38 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Gets or sets MaxHeight.\r
+        /// </summary>\r
+        public int MaxHeight\r
+        {\r
+            get\r
+            {\r
+                return this.maxHeight;\r
+            }\r
+            set\r
+            {\r
+                this.maxHeight = value;\r
+                this.NotifyOfPropertyChange(() => this.MaxHeight);\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Gets or sets MinHeight.\r
+        /// </summary>\r
+        public int MaxWidth\r
+        {\r
+            get\r
+            {\r
+                return this.maxWidth;\r
+            }\r
+            set\r
+            {\r
+                this.maxWidth = value;\r
+                this.NotifyOfPropertyChange(() => this.MaxWidth);\r
+            }\r
+        }\r
+\r
         /// <summary>\r
         /// Gets SourceAspect.\r
         /// </summary>\r
@@ -527,19 +574,45 @@ namespace HandBrakeWPF.ViewModels
             // TODO: These all need to be handled correctly.\r
             this.SelectedAnamorphicMode = preset.Task.Anamorphic;\r
 \r
-            if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)\r
+            // Set the limits on the UI Controls.\r
+            this.MaxWidth = preset.Task.MaxWidth ?? sourceResolution.Width;\r
+            this.MaxHeight = preset.Task.MaxHeight ?? sourceResolution.Height;\r
+            this.Task.MaxWidth = preset.Task.MaxWidth;\r
+            this.Task.MaxHeight = preset.Task.MaxHeight;\r
+\r
+            if (preset.Task.MaxWidth.HasValue)\r
+            {\r
+                if (this.Width > this.MaxWidth)\r
+                {\r
+                    this.Width = this.MaxWidth;\r
+                } \r
+                else\r
+                {\r
+                    this.Width = preset.Task.Width ?? this.getRes((sourceResolution.Width - this.CropLeft - this.CropRight), this.MaxWidth);\r
+                }\r
+            } \r
+            else\r
             {\r
-                this.Task.MaxWidth = preset.Task.MaxWidth;\r
-                this.Task.MaxHeight = preset.Task.MaxHeight;\r
                 this.Width = preset.Task.Width ?? (sourceResolution.Width - this.CropLeft - this.CropRight);\r
-                this.Height = preset.Task.Height ?? (sourceResolution.Height - this.CropTop - this.CropBottom);\r
             }\r
+\r
+            if (preset.Task.MaxHeight.HasValue)\r
+            {\r
+                if (this.Height > this.MaxHeight)\r
+                {\r
+                    this.Height = this.MaxHeight;\r
+                }\r
+                else\r
+                {\r
+                    this.Height = preset.Task.Height ?? this.getRes((sourceResolution.Height - this.CropTop - this.CropBottom), this.MaxHeight);\r
+                }\r
+            } \r
             else\r
             {\r
-                this.Width = preset.Task.Width ?? (sourceResolution.Width - this.CropLeft - this.CropRight);\r
                 this.Height = preset.Task.Height ?? (sourceResolution.Height - this.CropTop - this.CropBottom);\r
             }\r
 \r
+            // Anamorphic\r
             if (preset.Task.Anamorphic == Anamorphic.Custom)\r
             {\r
                 this.DisplayWidth = preset.Task.DisplayWidth != null ? int.Parse(preset.Task.DisplayWidth.ToString()) : 0;\r
@@ -588,6 +661,25 @@ namespace HandBrakeWPF.ViewModels
                 this.sourceParValues = title.ParVal;\r
                 this.sourceResolution = title.Resolution;\r
 \r
+                // Set the Max Width / Height available to the user controls\r
+                if (sourceResolution.Width < this.MaxWidth)\r
+                {\r
+                    this.MaxWidth = sourceResolution.Width;\r
+                } \r
+                else if (sourceResolution.Width > this.MaxWidth)\r
+                {\r
+                    this.MaxWidth = preset.Task.MaxWidth ?? sourceResolution.Width;\r
+                }\r
+\r
+                if (sourceResolution.Height < this.MaxHeight)\r
+                {\r
+                    this.MaxHeight = sourceResolution.Height;\r
+                }\r
+                else if (sourceResolution.Height > this.MaxHeight)\r
+                {\r
+                    this.MaxHeight = preset.Task.MaxHeight ?? sourceResolution.Height;\r
+                }\r
+\r
                 // Set Screen Controls\r
                 this.SourceInfo = string.Format(\r
                     "{0}x{1}, Aspect Ratio: {2:0.00}", \r
@@ -937,6 +1029,32 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Quick function to get the max resolution value\r
+        ///  </summary>\r
+        /// <param name="value">\r
+        /// The value.\r
+        /// </param>\r
+        /// <param name="max">\r
+        /// The max.\r
+        /// </param>\r
+        /// <returns>\r
+        /// An Int\r
+        /// </returns>\r
+        private int getRes(int value, int max)\r
+        {\r
+            if (value > max)\r
+            {\r
+                return max;\r
+            }\r
+            else\r
+            {\r
+                return value;\r
+            }\r
+\r
+            return 0;\r
+        }\r
+\r
         #endregion\r
     }\r
 }
\ No newline at end of file