diff options
author | sr55 <sr55.hb@outlook.com> | 2010-02-25 20:45:44 +0000 |
---|---|---|
committer | sr55 <sr55.hb@outlook.com> | 2010-02-25 20:45:44 +0000 |
commit | 8c3709d289a996567d459a92d64378ddebb7d2f9 (patch) | |
tree | 13936b652aee6a05466e1c2d14b9b4a62bf263e9 /win/C#/Controls | |
parent | 4de954484ea3b2bac3d48e502acb616e2b6779c1 (diff) |
WinGui:
- Make the picture settings panel work more like the macgui.
No longer uses -X Max Width but instead does all the logic in-gui so it's less confusing to the user.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3139 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Controls')
-rw-r--r-- | win/C#/Controls/PictureSettings.Designer.cs | 50 | ||||
-rw-r--r-- | win/C#/Controls/PictureSettings.cs | 170 |
2 files changed, 82 insertions, 138 deletions
diff --git a/win/C#/Controls/PictureSettings.Designer.cs b/win/C#/Controls/PictureSettings.Designer.cs index 96953ac53..83dfc9baf 100644 --- a/win/C#/Controls/PictureSettings.Designer.cs +++ b/win/C#/Controls/PictureSettings.Designer.cs @@ -42,11 +42,8 @@ namespace Handbrake.Controls this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.label7 = new System.Windows.Forms.Label();
this.lbl_src_res = new System.Windows.Forms.Label();
- this.Label91 = new System.Windows.Forms.Label();
- this.lbl_Aspect = new System.Windows.Forms.Label();
this.Label55 = new System.Windows.Forms.Label();
this.text_width = new System.Windows.Forms.NumericUpDown();
- this.lbl_max = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.text_height = new System.Windows.Forms.NumericUpDown();
this.check_KeepAR = new System.Windows.Forms.CheckBox();
@@ -280,11 +277,8 @@ namespace Handbrake.Controls this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.Controls.Add(this.label7, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.lbl_src_res, 1, 0);
- this.tableLayoutPanel2.Controls.Add(this.Label91, 2, 0);
- this.tableLayoutPanel2.Controls.Add(this.lbl_Aspect, 3, 0);
this.tableLayoutPanel2.Controls.Add(this.Label55, 0, 1);
this.tableLayoutPanel2.Controls.Add(this.text_width, 1, 1);
- this.tableLayoutPanel2.Controls.Add(this.lbl_max, 4, 1);
this.tableLayoutPanel2.Controls.Add(this.label4, 2, 1);
this.tableLayoutPanel2.Controls.Add(this.text_height, 3, 1);
this.tableLayoutPanel2.Controls.Add(this.check_KeepAR, 1, 2);
@@ -323,32 +317,6 @@ namespace Handbrake.Controls this.lbl_src_res.TabIndex = 77;
this.lbl_src_res.Text = "--";
//
- // Label91
- //
- this.Label91.Anchor = System.Windows.Forms.AnchorStyles.Left;
- this.Label91.AutoSize = true;
- this.Label91.BackColor = System.Drawing.Color.Transparent;
- this.Label91.ImeMode = System.Windows.Forms.ImeMode.NoControl;
- this.Label91.Location = new System.Drawing.Point(120, 3);
- this.Label91.Margin = new System.Windows.Forms.Padding(3);
- this.Label91.Name = "Label91";
- this.Label91.Size = new System.Drawing.Size(72, 13);
- this.Label91.TabIndex = 78;
- this.Label91.Text = "Aspect Ratio:";
- //
- // lbl_Aspect
- //
- this.lbl_Aspect.Anchor = System.Windows.Forms.AnchorStyles.Left;
- this.lbl_Aspect.AutoSize = true;
- this.lbl_Aspect.BackColor = System.Drawing.Color.Transparent;
- this.lbl_Aspect.ImeMode = System.Windows.Forms.ImeMode.NoControl;
- this.lbl_Aspect.Location = new System.Drawing.Point(198, 3);
- this.lbl_Aspect.Margin = new System.Windows.Forms.Padding(3);
- this.lbl_Aspect.Name = "lbl_Aspect";
- this.lbl_Aspect.Size = new System.Drawing.Size(15, 13);
- this.lbl_Aspect.TabIndex = 79;
- this.lbl_Aspect.Text = "--";
- //
// Label55
//
this.Label55.Anchor = System.Windows.Forms.AnchorStyles.Left;
@@ -376,19 +344,6 @@ namespace Handbrake.Controls this.text_width.TabIndex = 85;
this.text_width.ValueChanged += new System.EventHandler(this.TextWidthValueChanged);
//
- // lbl_max
- //
- this.lbl_max.Anchor = System.Windows.Forms.AnchorStyles.Left;
- this.lbl_max.AutoSize = true;
- this.lbl_max.ImeMode = System.Windows.Forms.ImeMode.NoControl;
- this.lbl_max.Location = new System.Drawing.Point(268, 26);
- this.lbl_max.Margin = new System.Windows.Forms.Padding(3);
- this.lbl_max.Name = "lbl_max";
- this.lbl_max.Size = new System.Drawing.Size(15, 13);
- this.lbl_max.TabIndex = 83;
- this.lbl_max.Text = "--";
- this.lbl_max.DoubleClick += new System.EventHandler(this.LblMaxDoubleClick);
- //
// label4
//
this.label4.Anchor = System.Windows.Forms.AnchorStyles.Left;
@@ -405,7 +360,7 @@ namespace Handbrake.Controls //
// text_height
//
- this.text_height.Location = new System.Drawing.Point(198, 22);
+ this.text_height.Location = new System.Drawing.Point(168, 22);
this.text_height.Maximum = new decimal(new int[] {
2560,
0,
@@ -705,10 +660,7 @@ namespace Handbrake.Controls private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
internal System.Windows.Forms.Label label7;
internal System.Windows.Forms.Label lbl_src_res;
- internal System.Windows.Forms.Label Label91;
- internal System.Windows.Forms.Label lbl_Aspect;
internal System.Windows.Forms.Label Label55;
- private System.Windows.Forms.Label lbl_max;
internal System.Windows.Forms.Label label4;
internal System.Windows.Forms.CheckBox check_KeepAR;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
diff --git a/win/C#/Controls/PictureSettings.cs b/win/C#/Controls/PictureSettings.cs index 44de20038..b9a0bf040 100644 --- a/win/C#/Controls/PictureSettings.cs +++ b/win/C#/Controls/PictureSettings.cs @@ -1,8 +1,7 @@ /* PictureSetting.cs $
-
- This file is part of the HandBrake source code.
- Homepage: <http://handbrake.fr>.
- It may be used under the terms of the GNU General Public License. */
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
namespace Handbrake.Controls
{
@@ -13,17 +12,16 @@ namespace Handbrake.Controls using Parsing;
using Presets;
+ /// <summary>
+ /// The Picture Settings Panel
+ /// </summary>
public partial class PictureSettings : UserControl
{
private readonly CultureInfo culture = new CultureInfo("en-US", false);
- public event EventHandler PictureSettingsChanged;
-
private bool preventChangingWidth;
private bool preventChangingHeight;
private bool preventChangingCustom;
private bool preventChangingDisplayWidth;
- private int presetMaximumWidth;
- private int presetMaximumHeight;
private double cachedDar;
private Title sourceTitle;
@@ -40,11 +38,20 @@ namespace Handbrake.Controls }
/// <summary>
+ /// Picture Settings Changed Event Handler
+ /// </summary>
+ public event EventHandler PictureSettingsChanged;
+
+ /// <summary>
/// Gets or sets the source media used by this control.
/// </summary>
public Title Source
{
- private get { return sourceTitle; }
+ private get
+ {
+ return sourceTitle;
+ }
+
set
{
sourceTitle = value;
@@ -54,7 +61,7 @@ namespace Handbrake.Controls }
/// <summary>
- /// Which preset is currently selected by the user.
+ /// Gets or sets the currently selected preset.
/// </summary>
public Preset CurrentlySelectedPreset { get; set; }
@@ -62,29 +69,14 @@ namespace Handbrake.Controls /// Gets or sets the maximum allowable size for the encoded resolution. Set a value to
/// "0" if the maximum does not matter.
/// </summary>
- public Size PresetMaximumResolution
- {
- get { return new Size(presetMaximumWidth, presetMaximumHeight); }
- set
- {
- presetMaximumWidth = value.Width;
- presetMaximumHeight = value.Height;
-
- if (value.Width != 0 && value.Height != 0)
- lbl_max.Text = "Max Width / Height";
- else if (value.Width != 0)
- lbl_max.Text = "Max Width";
- else if (value.Height != 0)
- lbl_max.Text = "Max Height";
- else
- lbl_max.Text = string.Empty;
- }
- }
+ public Size PresetMaximumResolution { get; set; }
/// <summary>
/// Set the Preset Crop Warning Label
/// </summary>
- /// <param name="selectedPreset"></param>
+ /// <param name="selectedPreset">
+ /// The Selected preset
+ /// </param>
public void SetPresetCropWarningLabel(Preset selectedPreset)
{
lbl_presetCropWarning.Visible = true;
@@ -100,12 +92,10 @@ namespace Handbrake.Controls private void NewSourceSet()
{
// Set the Aspect Ratio
- lbl_Aspect.Text = sourceTitle.AspectRatio.ToString(culture);
lbl_src_res.Text = sourceTitle.Resolution.Width + " x " + sourceTitle.Resolution.Height;
// Set the Recommended Cropping values, but only if a preset doesn't have hard set picture settings.
- if ((CurrentlySelectedPreset != null && CurrentlySelectedPreset.PictureSettings == false) ||
- CurrentlySelectedPreset == null)
+ if ((CurrentlySelectedPreset != null && CurrentlySelectedPreset.PictureSettings == false) || CurrentlySelectedPreset == null)
{
crop_top.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[0]);
crop_bottom.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[1]);
@@ -118,19 +108,28 @@ namespace Handbrake.Controls // Set the Resolution Boxes
if (drp_anamorphic.SelectedIndex == 0)
{
- if (text_width.Value == 0) // Only update the values if the fields don't already have values.
- text_width.Value = sourceTitle.Resolution.Width;
+ int width = sourceTitle.Resolution.Width;
+
+ if (width > PresetMaximumResolution.Width && PresetMaximumResolution.Width != 0) // If the preset has a Max width set, don't use a width larger than it.
+ width = PresetMaximumResolution.Width;
+
+ if (text_width.Value == 0 || (text_width.Value > PresetMaximumResolution.Width && PresetMaximumResolution.Width != 0)) // Only update the values if the fields don't already have values.
+ text_width.Value = width;
check_KeepAR.Checked = true; // Forces Resolution to be correct.
}
else
{
- if (text_width.Value == 0 && text_height.Value == 0)
- // Only update the values if the fields don't already have values.
- {
- text_width.Value = sourceTitle.Resolution.Width;
- text_height.Value = sourceTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
- }
+ int width = sourceTitle.Resolution.Width;
+ if (width > PresetMaximumResolution.Width && PresetMaximumResolution.Width != 0) // If the preset has a Max width set, don't use a width larger than it.
+ width = PresetMaximumResolution.Width;
+
+ int height = sourceTitle.Resolution.Height;
+ if (height > PresetMaximumResolution.Height && PresetMaximumResolution.Height != 0) // If the preset has a Max height set, don't use a width larger than it.
+ height = PresetMaximumResolution.Height;
+
+ text_width.Value = width;
+ text_height.Value = height - (int)crop_top.Value - (int)crop_bottom.Value;
labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;
}
@@ -139,7 +138,7 @@ namespace Handbrake.Controls updownParHeight.Value = sourceTitle.ParVal.Height;
Size croppedDar = CalculateAnamorphicSizes();
- cachedDar = (double) croppedDar.Width/croppedDar.Height;
+ cachedDar = (double)croppedDar.Width / croppedDar.Height;
updownDisplayWidth.Value = croppedDar.Width;
}
@@ -164,17 +163,17 @@ namespace Handbrake.Controls {
preventChangingHeight = true;
- int width = (int) text_width.Value;
+ int width = (int)text_width.Value;
- double crop_width = Source.Resolution.Width - (int) crop_left.Value - (int) crop_right.Value;
- double crop_height = Source.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
+ double crop_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
+ double crop_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
if (SourceAspect.Width == 0 && SourceAspect.Height == 0)
break;
- double newHeight = ((double) width*Source.Resolution.Width*SourceAspect.Height*crop_height)/
- (Source.Resolution.Height*SourceAspect.Width*crop_width);
- text_height.Value = (decimal) GetModulusValue(newHeight);
+ double newHeight = ((double)width * Source.Resolution.Width * SourceAspect.Height * crop_height) /
+ (Source.Resolution.Height * SourceAspect.Width * crop_width);
+ text_height.Value = (decimal)GetModulusValue(newHeight);
preventChangingHeight = false;
}
@@ -186,7 +185,7 @@ namespace Handbrake.Controls break;
preventChangingDisplayWidth = true;
- updownDisplayWidth.Value = text_width.Value*updownParWidth.Value/updownParHeight.Value;
+ updownDisplayWidth.Value = text_width.Value * updownParWidth.Value / updownParHeight.Value;
preventChangingDisplayWidth = false;
labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value;
@@ -225,14 +224,14 @@ namespace Handbrake.Controls {
preventChangingWidth = true;
- double crop_width = Source.Resolution.Width - (int) crop_left.Value - (int) crop_right.Value;
- double crop_height = Source.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
+ double crop_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
+ double crop_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
- double new_width = ((double) text_height.Value*Source.Resolution.Height*SourceAspect.Width*
- crop_width)/
- (Source.Resolution.Width*SourceAspect.Height*crop_height);
+ double new_width = ((double)text_height.Value * Source.Resolution.Height * SourceAspect.Width *
+ crop_width) /
+ (Source.Resolution.Width * SourceAspect.Height * crop_height);
- text_width.Value = (decimal) GetModulusValue(new_width);
+ text_width.Value = (decimal)GetModulusValue(new_width);
preventChangingWidth = false;
}
@@ -247,12 +246,12 @@ namespace Handbrake.Controls // - Changes PIXEL HEIGHT to STORAGE WIDTH
// DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification)
- double rawCalculatedDisplayWidth = (double) text_height.Value*cachedDar;
+ double rawCalculatedDisplayWidth = (double)text_height.Value * cachedDar;
preventChangingDisplayWidth = true; // Start Guards
preventChangingWidth = true;
- updownDisplayWidth.Value = (decimal) rawCalculatedDisplayWidth;
+ updownDisplayWidth.Value = (decimal)rawCalculatedDisplayWidth;
updownParWidth.Value = updownDisplayWidth.Value;
updownParHeight.Value = text_width.Value;
@@ -315,12 +314,12 @@ namespace Handbrake.Controls if (!int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus))
modulus = 16;
- int rawCalculatedHeight = (int) ((int) updownDisplayWidth.Value/cachedDar);
- int modulusHeight = rawCalculatedHeight - (rawCalculatedHeight%modulus);
+ int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / cachedDar);
+ int modulusHeight = rawCalculatedHeight - (rawCalculatedHeight % modulus);
// Update value
preventChangingHeight = true;
- text_height.Value = (decimal) modulusHeight;
+ text_height.Value = (decimal)modulusHeight;
updownParWidth.Value = updownDisplayWidth.Value;
updownParHeight.Value = text_width.Value;
preventChangingHeight = false;
@@ -339,8 +338,9 @@ namespace Handbrake.Controls SetCustomAnamorphicOptionsVisible(false);
labelStaticDisplaySize.Visible = false;
- labelDisplaySize.Visible = true;
+ labelDisplaySize.Visible = false;
drp_modulus.Visible = true;
+ lbl_modulus.Visible = true;
// check_KeepAR.Checked = true;
@@ -401,8 +401,8 @@ namespace Handbrake.Controls preventChangingWidth = true;
preventChangingHeight = true;
- text_width.Value = (decimal) GetModulusValue((double) text_width.Value);
- text_height.Value = (decimal) GetModulusValue((double) text_height.Value);
+ text_width.Value = (decimal)GetModulusValue((double)text_width.Value);
+ text_height.Value = (decimal)GetModulusValue((double)text_height.Value);
preventChangingWidth = false;
preventChangingHeight = false;
@@ -456,8 +456,8 @@ namespace Handbrake.Controls get
{
if (Source != null) // display aspect = (width * par_width) / (height * par_height)
- return new Size((Source.ParVal.Width*Source.Resolution.Width),
- (Source.ParVal.Height*Source.Resolution.Height));
+ return new Size((Source.ParVal.Width * Source.Resolution.Width),
+ (Source.ParVal.Height * Source.Resolution.Height));
return new Size(0, 0); // Fall over to 16:9 and hope for the best
}
@@ -468,12 +468,12 @@ namespace Handbrake.Controls if (Source != null)
{
/* Set up some variables to make the math easier to follow. */
- int croppedWidth = Source.Resolution.Width - (int) crop_left.Value - (int) crop_right.Value;
- int croppedHeight = Source.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
- double storageAspect = (double) croppedWidth/croppedHeight;
+ int croppedWidth = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value;
+ int croppedHeight = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
+ double storageAspect = (double)croppedWidth / croppedHeight;
/* Figure out what width the source would display at. */
- double sourceDisplayWidth = (double) croppedWidth*Source.ParVal.Width/Source.ParVal.Height;
+ double sourceDisplayWidth = (double)croppedWidth * Source.ParVal.Width / Source.ParVal.Height;
/*
3 different ways of deciding output dimensions:
@@ -487,31 +487,31 @@ namespace Handbrake.Controls default:
case 1:
/* Strict anamorphic */
- double displayWidth = ((double) croppedWidth*Source.ParVal.Width/Source.ParVal.Height);
+ double displayWidth = ((double)croppedWidth * Source.ParVal.Width / Source.ParVal.Height);
displayWidth = Math.Round(displayWidth, 0);
- Size output = new Size((int) displayWidth, croppedHeight);
+ Size output = new Size((int)displayWidth, croppedHeight);
return output;
case 2:
/* "Loose" anamorphic.
- Uses mod16-compliant dimensions,
- Allows users to set the width
*/
- width = (int) text_width.Value;
+ width = (int)text_width.Value;
width = GetModulusValue(width); /* Time to get picture width that divide cleanly.*/
- height = (width/storageAspect) + 0.5;
+ height = (width / storageAspect) + 0.5;
height = GetModulusValue(height); /* Time to get picture height that divide cleanly.*/
/* The film AR is the source's display width / cropped source height.
The output display width is the output height * film AR.
The output PAR is the output display width / output storage width. */
- double pixelAspectWidth = height*sourceDisplayWidth/croppedHeight;
+ double pixelAspectWidth = height * sourceDisplayWidth / croppedHeight;
double pixelAspectHeight = width;
- double disWidthLoose = (width*pixelAspectWidth/pixelAspectHeight);
+ double disWidthLoose = (width * pixelAspectWidth / pixelAspectHeight);
if (double.IsNaN(disWidthLoose))
disWidthLoose = 0;
- return new Size((int) disWidthLoose, (int) height);
+ return new Size((int)disWidthLoose, (int)height);
case 3:
// Get the User Interface Values
@@ -519,12 +519,12 @@ namespace Handbrake.Controls double.TryParse(updownDisplayWidth.Text, out UIdisplayWidth);
/* Anamorphic 3: Power User Jamboree - Set everything based on specified values */
- height = GetModulusValue((double) text_height.Value);
+ height = GetModulusValue((double)text_height.Value);
if (check_KeepAR.Checked)
- return new Size((int) Math.Truncate(UIdisplayWidth), (int) height);
+ return new Size((int)Math.Truncate(UIdisplayWidth), (int)height);
- return new Size((int) Math.Truncate(UIdisplayWidth), (int) height);
+ return new Size((int)Math.Truncate(UIdisplayWidth), (int)height);
}
}
@@ -535,27 +535,19 @@ namespace Handbrake.Controls private double GetModulusValue(double value)
{
int mod = int.Parse(drp_modulus.SelectedItem.ToString());
- double remainder = value%mod;
+ double remainder = value % mod;
if (remainder == 0)
return value;
- return remainder >= ((double) mod/2) ? value + (mod - remainder) : value - remainder;
+ return remainder >= ((double)mod / 2) ? value + (mod - remainder) : value - remainder;
}
private static int GetCropMod2Clean(int value)
{
- int remainder = value%2;
+ int remainder = value % 2;
if (remainder == 0) return value;
return (value + remainder);
}
-
- // Hidden UI feature to drop the MaxWidth / Height with the MaxWidth/Height label is double clicked
- private void LblMaxDoubleClick(object sender, EventArgs e)
- {
- PresetMaximumResolution = new Size(0, 0);
- if (PictureSettingsChanged != null)
- PictureSettingsChanged(this, new EventArgs());
- }
}
}
\ No newline at end of file |