summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-06-17 20:19:28 +0000
committersr55 <[email protected]>2012-06-17 20:19:28 +0000
commit0ad93d9a7cc5e51d302fdb0c57d1573ae9d435fb (patch)
treef80448600bd62b5da8ea4c9caa9be97e9cc5dfc0 /win
parent77a10cca0461c6d24b5a58b01d6d2e1dbcbab4c8 (diff)
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
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs132
1 files changed, 125 insertions, 7 deletions
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
/// </summary>
private bool showDisplaySize;
+ /// <summary>
+ /// Backing field for max height
+ /// </summary>
+ private int maxHeight;
+
+ /// <summary>
+ /// Backing field for max width
+ /// </summary>
+ 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
@@ -492,6 +507,38 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Gets or sets MaxHeight.
+ /// </summary>
+ public int MaxHeight
+ {
+ get
+ {
+ return this.maxHeight;
+ }
+ set
+ {
+ this.maxHeight = value;
+ this.NotifyOfPropertyChange(() => this.MaxHeight);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets MinHeight.
+ /// </summary>
+ public int MaxWidth
+ {
+ get
+ {
+ return this.maxWidth;
+ }
+ set
+ {
+ this.maxWidth = value;
+ this.NotifyOfPropertyChange(() => this.MaxWidth);
+ }
+ }
+
+ /// <summary>
/// Gets SourceAspect.
/// </summary>
private Size 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
}
}
+ /// <summary>
+ /// Quick function to get the max resolution value
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="max">
+ /// The max.
+ /// </param>
+ /// <returns>
+ /// An Int
+ /// </returns>
+ private int getRes(int value, int max)
+ {
+ if (value > max)
+ {
+ return max;
+ }
+ else
+ {
+ return value;
+ }
+
+ return 0;
+ }
+
#endregion
}
} \ No newline at end of file