From: sr55 Date: Sun, 17 Jun 2012 20:19:28 +0000 (+0000) Subject: WinGui: Fix a couple of the issues with the Picture settings view with regard to... X-Git-Tag: 0.9.9~563 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ad93d9a7cc5e51d302fdb0c57d1573ae9d435fb;p=handbrake WinGui: Fix a couple of the issues with the Picture settings view with regard to max width / height settings stored in presets. There are still a number of issues around the calculation of width/height to be tidy'd up. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4747 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs index eff48d0e5..006e8373a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -32,8 +32,9 @@ namespace HandBrakeWPF.ViewModels { /* * TODO: - * Handle Presets when a new title is set - * Handle changes in cropping affecting the resolution calcuation. + * - We are not handling cropping correctly within the UI. + * - The Height is not correctly set when using no Anamorphic + * - Maintain Aspect ratio needs corrected. * */ #region Constants and Fields @@ -88,6 +89,16 @@ namespace HandBrakeWPF.ViewModels /// private bool showDisplaySize; + /// + /// Backing field for max height + /// + private int maxHeight; + + /// + /// Backing field for max width + /// + private int maxWidth; + #endregion #region Constructors and Destructors @@ -106,6 +117,10 @@ namespace HandBrakeWPF.ViewModels this.Task = new EncodeTask(); this.SelectedModulus = 16; this.MaintainAspectRatio = true; + + // Default the Max Width / Height to 1080p format + this.MaxHeight = 1080; + this.MaxWidth = 1920; } #endregion @@ -491,6 +506,38 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// Gets or sets MaxHeight. + /// + public int MaxHeight + { + get + { + return this.maxHeight; + } + set + { + this.maxHeight = value; + this.NotifyOfPropertyChange(() => this.MaxHeight); + } + } + + /// + /// Gets or sets MinHeight. + /// + public int MaxWidth + { + get + { + return this.maxWidth; + } + set + { + this.maxWidth = value; + this.NotifyOfPropertyChange(() => this.MaxWidth); + } + } + /// /// Gets SourceAspect. /// @@ -527,19 +574,45 @@ namespace HandBrakeWPF.ViewModels // TODO: These all need to be handled correctly. this.SelectedAnamorphicMode = preset.Task.Anamorphic; - if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum) + // Set the limits on the UI Controls. + this.MaxWidth = preset.Task.MaxWidth ?? sourceResolution.Width; + this.MaxHeight = preset.Task.MaxHeight ?? sourceResolution.Height; + this.Task.MaxWidth = preset.Task.MaxWidth; + this.Task.MaxHeight = preset.Task.MaxHeight; + + if (preset.Task.MaxWidth.HasValue) + { + if (this.Width > this.MaxWidth) + { + this.Width = this.MaxWidth; + } + else + { + this.Width = preset.Task.Width ?? this.getRes((sourceResolution.Width - this.CropLeft - this.CropRight), this.MaxWidth); + } + } + else { - this.Task.MaxWidth = preset.Task.MaxWidth; - this.Task.MaxHeight = preset.Task.MaxHeight; this.Width = preset.Task.Width ?? (sourceResolution.Width - this.CropLeft - this.CropRight); - this.Height = preset.Task.Height ?? (sourceResolution.Height - this.CropTop - this.CropBottom); } + + if (preset.Task.MaxHeight.HasValue) + { + if (this.Height > this.MaxHeight) + { + this.Height = this.MaxHeight; + } + else + { + this.Height = preset.Task.Height ?? this.getRes((sourceResolution.Height - this.CropTop - this.CropBottom), this.MaxHeight); + } + } else { - this.Width = preset.Task.Width ?? (sourceResolution.Width - this.CropLeft - this.CropRight); this.Height = preset.Task.Height ?? (sourceResolution.Height - this.CropTop - this.CropBottom); } + // Anamorphic if (preset.Task.Anamorphic == Anamorphic.Custom) { this.DisplayWidth = preset.Task.DisplayWidth != null ? int.Parse(preset.Task.DisplayWidth.ToString()) : 0; @@ -588,6 +661,25 @@ namespace HandBrakeWPF.ViewModels this.sourceParValues = title.ParVal; this.sourceResolution = title.Resolution; + // Set the Max Width / Height available to the user controls + if (sourceResolution.Width < this.MaxWidth) + { + this.MaxWidth = sourceResolution.Width; + } + else if (sourceResolution.Width > this.MaxWidth) + { + this.MaxWidth = preset.Task.MaxWidth ?? sourceResolution.Width; + } + + if (sourceResolution.Height < this.MaxHeight) + { + this.MaxHeight = sourceResolution.Height; + } + else if (sourceResolution.Height > this.MaxHeight) + { + this.MaxHeight = preset.Task.MaxHeight ?? sourceResolution.Height; + } + // Set Screen Controls this.SourceInfo = string.Format( "{0}x{1}, Aspect Ratio: {2:0.00}", @@ -937,6 +1029,32 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// Quick function to get the max resolution value + /// + /// + /// The value. + /// + /// + /// The max. + /// + /// + /// An Int + /// + private int getRes(int value, int max) + { + if (value > max) + { + return max; + } + else + { + return value; + } + + return 0; + } + #endregion } } \ No newline at end of file