From 85ca8ca9325e10aff5e40d96e3f0d4163f66b917 Mon Sep 17 00:00:00 2001 From: sr55 Date: Thu, 11 Jun 2009 16:55:17 +0000 Subject: [PATCH] WinGui: - Fixed Keep AR disabled leaded to Aspect ratio being kept for width. - Fixed Max Width / Height display and issues in Query Generator. - Fixed some issues in the Preset Loader. - Crop values are always mod 2 now. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2512 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Controls/PictureSettings.Designer.cs | 56 +++++++++++++------ win/C#/Controls/PictureSettings.cs | 59 ++++++++++++++------- win/C#/Functions/PresetLoader.cs | 34 ++++++------ win/C#/Functions/QueryGenerator.cs | 4 +- win/C#/frmMain.cs | 4 -- 5 files changed, 99 insertions(+), 58 deletions(-) diff --git a/win/C#/Controls/PictureSettings.Designer.cs b/win/C#/Controls/PictureSettings.Designer.cs index f3250f901..609633ab5 100644 --- a/win/C#/Controls/PictureSettings.Designer.cs +++ b/win/C#/Controls/PictureSettings.Designer.cs @@ -135,7 +135,7 @@ namespace Handbrake.Controls // lbl_max // this.lbl_max.AutoSize = true; - this.lbl_max.Location = new System.Drawing.Point(273, 80); + this.lbl_max.Location = new System.Drawing.Point(279, 61); this.lbl_max.Name = "lbl_max"; this.lbl_max.Size = new System.Drawing.Size(34, 13); this.lbl_max.TabIndex = 47; @@ -167,7 +167,7 @@ namespace Handbrake.Controls this.label6.AutoSize = true; this.label6.BackColor = System.Drawing.Color.Transparent; this.label6.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label6.Location = new System.Drawing.Point(13, 91); + this.label6.Location = new System.Drawing.Point(14, 120); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(80, 13); this.label6.TabIndex = 45; @@ -183,7 +183,7 @@ namespace Handbrake.Controls "Strict", "Loose", "Custom"}); - this.drp_anamorphic.Location = new System.Drawing.Point(109, 88); + this.drp_anamorphic.Location = new System.Drawing.Point(110, 117); this.drp_anamorphic.Name = "drp_anamorphic"; this.drp_anamorphic.Size = new System.Drawing.Size(110, 21); this.drp_anamorphic.TabIndex = 46; @@ -239,7 +239,7 @@ namespace Handbrake.Controls this.lbl_modulus.AutoSize = true; this.lbl_modulus.BackColor = System.Drawing.Color.Transparent; this.lbl_modulus.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbl_modulus.Location = new System.Drawing.Point(13, 118); + this.lbl_modulus.Location = new System.Drawing.Point(14, 147); this.lbl_modulus.Name = "lbl_modulus"; this.lbl_modulus.Size = new System.Drawing.Size(58, 13); this.lbl_modulus.TabIndex = 51; @@ -255,14 +255,14 @@ namespace Handbrake.Controls "8", "4", "2"}); - this.drop_modulus.Location = new System.Drawing.Point(109, 115); + this.drop_modulus.Location = new System.Drawing.Point(110, 144); this.drop_modulus.Name = "drop_modulus"; this.drop_modulus.Size = new System.Drawing.Size(110, 21); this.drop_modulus.TabIndex = 52; // // txt_displayWidth // - this.txt_displayWidth.Location = new System.Drawing.Point(109, 142); + this.txt_displayWidth.Location = new System.Drawing.Point(110, 171); this.txt_displayWidth.Name = "txt_displayWidth"; this.txt_displayWidth.Size = new System.Drawing.Size(100, 20); this.txt_displayWidth.TabIndex = 53; @@ -274,7 +274,7 @@ namespace Handbrake.Controls this.lbl_displayWidth.AutoSize = true; this.lbl_displayWidth.BackColor = System.Drawing.Color.Transparent; this.lbl_displayWidth.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbl_displayWidth.Location = new System.Drawing.Point(13, 145); + this.lbl_displayWidth.Location = new System.Drawing.Point(14, 174); this.lbl_displayWidth.Name = "lbl_displayWidth"; this.lbl_displayWidth.Size = new System.Drawing.Size(90, 13); this.lbl_displayWidth.TabIndex = 54; @@ -285,7 +285,7 @@ namespace Handbrake.Controls this.lbl_parWidth.AutoSize = true; this.lbl_parWidth.BackColor = System.Drawing.Color.Transparent; this.lbl_parWidth.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbl_parWidth.Location = new System.Drawing.Point(13, 171); + this.lbl_parWidth.Location = new System.Drawing.Point(14, 200); this.lbl_parWidth.Name = "lbl_parWidth"; this.lbl_parWidth.Size = new System.Drawing.Size(71, 13); this.lbl_parWidth.TabIndex = 56; @@ -293,7 +293,7 @@ namespace Handbrake.Controls // // txt_parWidth // - this.txt_parWidth.Location = new System.Drawing.Point(109, 168); + this.txt_parWidth.Location = new System.Drawing.Point(110, 197); this.txt_parWidth.Name = "txt_parWidth"; this.txt_parWidth.Size = new System.Drawing.Size(100, 20); this.txt_parWidth.TabIndex = 55; @@ -305,7 +305,7 @@ namespace Handbrake.Controls this.lbl_parHeight.AutoSize = true; this.lbl_parHeight.BackColor = System.Drawing.Color.Transparent; this.lbl_parHeight.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbl_parHeight.Location = new System.Drawing.Point(13, 197); + this.lbl_parHeight.Location = new System.Drawing.Point(14, 226); this.lbl_parHeight.Name = "lbl_parHeight"; this.lbl_parHeight.Size = new System.Drawing.Size(75, 13); this.lbl_parHeight.TabIndex = 58; @@ -313,7 +313,7 @@ namespace Handbrake.Controls // // txt_parHeight // - this.txt_parHeight.Location = new System.Drawing.Point(109, 194); + this.txt_parHeight.Location = new System.Drawing.Point(110, 223); this.txt_parHeight.Name = "txt_parHeight"; this.txt_parHeight.Size = new System.Drawing.Size(100, 20); this.txt_parHeight.TabIndex = 57; @@ -323,11 +323,11 @@ namespace Handbrake.Controls // check_KeepAR // this.check_KeepAR.AutoSize = true; - this.check_KeepAR.Location = new System.Drawing.Point(276, 60); + this.check_KeepAR.Location = new System.Drawing.Point(68, 85); this.check_KeepAR.Name = "check_KeepAR"; - this.check_KeepAR.Size = new System.Drawing.Size(69, 17); + this.check_KeepAR.Size = new System.Drawing.Size(115, 17); this.check_KeepAR.TabIndex = 59; - this.check_KeepAR.Text = "Keep AR"; + this.check_KeepAR.Text = "Keep Aspect Ratio"; this.check_KeepAR.UseVisualStyleBackColor = true; this.check_KeepAR.CheckedChanged += new System.EventHandler(this.check_KeepAR_CheckedChanged); // @@ -358,6 +358,11 @@ namespace Handbrake.Controls // crop_bottom // this.crop_bottom.Enabled = false; + this.crop_bottom.Increment = new decimal(new int[] { + 2, + 0, + 0, + 0}); this.crop_bottom.Location = new System.Drawing.Point(467, 146); this.crop_bottom.Maximum = new decimal(new int[] { 1080, @@ -367,10 +372,16 @@ namespace Handbrake.Controls this.crop_bottom.Name = "crop_bottom"; this.crop_bottom.Size = new System.Drawing.Size(44, 20); this.crop_bottom.TabIndex = 67; + this.crop_bottom.ValueChanged += new System.EventHandler(this.crop_bottom_ValueChanged); // // crop_top // this.crop_top.Enabled = false; + this.crop_top.Increment = new decimal(new int[] { + 2, + 0, + 0, + 0}); this.crop_top.Location = new System.Drawing.Point(467, 100); this.crop_top.Maximum = new decimal(new int[] { 1080, @@ -380,10 +391,16 @@ namespace Handbrake.Controls this.crop_top.Name = "crop_top"; this.crop_top.Size = new System.Drawing.Size(44, 20); this.crop_top.TabIndex = 64; + this.crop_top.ValueChanged += new System.EventHandler(this.crop_top_ValueChanged); // // crop_left // this.crop_left.Enabled = false; + this.crop_left.Increment = new decimal(new int[] { + 2, + 0, + 0, + 0}); this.crop_left.Location = new System.Drawing.Point(416, 122); this.crop_left.Maximum = new decimal(new int[] { 1920, @@ -393,10 +410,16 @@ namespace Handbrake.Controls this.crop_left.Name = "crop_left"; this.crop_left.Size = new System.Drawing.Size(44, 20); this.crop_left.TabIndex = 62; + this.crop_left.ValueChanged += new System.EventHandler(this.crop_left_ValueChanged); // // crop_right // this.crop_right.Enabled = false; + this.crop_right.Increment = new decimal(new int[] { + 2, + 0, + 0, + 0}); this.crop_right.Location = new System.Drawing.Point(518, 122); this.crop_right.Maximum = new decimal(new int[] { 1920, @@ -406,6 +429,7 @@ namespace Handbrake.Controls this.crop_right.Name = "crop_right"; this.crop_right.Size = new System.Drawing.Size(44, 20); this.crop_right.TabIndex = 65; + this.crop_right.ValueChanged += new System.EventHandler(this.crop_right_ValueChanged); // // label8 // @@ -467,7 +491,7 @@ namespace Handbrake.Controls this.lbl_anamorphic.AutoSize = true; this.lbl_anamorphic.BackColor = System.Drawing.Color.Transparent; this.lbl_anamorphic.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbl_anamorphic.Location = new System.Drawing.Point(107, 222); + this.lbl_anamorphic.Location = new System.Drawing.Point(108, 251); this.lbl_anamorphic.Name = "lbl_anamorphic"; this.lbl_anamorphic.Size = new System.Drawing.Size(72, 12); this.lbl_anamorphic.TabIndex = 74; @@ -477,7 +501,7 @@ namespace Handbrake.Controls // this.lbl_anamprohicLbl.AutoSize = true; this.lbl_anamprohicLbl.BackColor = System.Drawing.Color.Transparent; - this.lbl_anamprohicLbl.Location = new System.Drawing.Point(13, 221); + this.lbl_anamprohicLbl.Location = new System.Drawing.Point(14, 250); this.lbl_anamprohicLbl.Name = "lbl_anamprohicLbl"; this.lbl_anamprohicLbl.Size = new System.Drawing.Size(66, 13); this.lbl_anamprohicLbl.TabIndex = 73; diff --git a/win/C#/Controls/PictureSettings.cs b/win/C#/Controls/PictureSettings.cs index 7704a366a..88f0e8f41 100644 --- a/win/C#/Controls/PictureSettings.cs +++ b/win/C#/Controls/PictureSettings.cs @@ -6,18 +6,16 @@ using Handbrake.Parsing; namespace Handbrake.Controls { // TODO - - // - Fix MAX Width / Height Code. // - Tie in the cropping controls. public partial class PictureSettings : UserControl { // Globals - int maxWidth, maxHeight; + public int maxWidth, maxHeight; int widthVal, heightVal; private double darValue; - private double storageAspect = 0; // Storage Aspect Cache for current source and title - public Title selectedTitle { get; set; } + private double storageAspect; // Storage Aspect Cache for current source and title + public Title selectedTitle { private get; set; } private Boolean heightChangeGuard; private Boolean looseAnamorphicHeightGuard; private Boolean heightModJumpGaurd; @@ -61,14 +59,14 @@ namespace Handbrake.Controls text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value; } - - if (drp_anamorphic.SelectedIndex == 3) { txt_parWidth.Text = selectedTitle.ParVal.Width.ToString(); txt_parHeight.Text = selectedTitle.ParVal.Height.ToString(); txt_displayWidth.Text = displayWidth().ToString(); } + + setMax(); } public void setMax() { @@ -83,6 +81,9 @@ namespace Handbrake.Controls // Basic Picture Setting Controls private void text_width_ValueChanged(object sender, EventArgs e) { + maxWidth = 0; + setMax(); + // Get the Modulus int mod; int.TryParse(drop_modulus.SelectedItem.ToString(), out mod); @@ -94,7 +95,7 @@ namespace Handbrake.Controls switch (drp_anamorphic.SelectedIndex) { case 0: - if (calculateUnchangeValue(true) != -1) + if (calculateUnchangeValue(true) != -1 && check_KeepAR.Checked) text_height.Value = calculateUnchangeValue(true); break; case 1: @@ -111,6 +112,9 @@ namespace Handbrake.Controls } private void text_height_ValueChanged(object sender, EventArgs e) { + maxHeight = 0; + setMax(); + // Get the Modulus int mod; int.TryParse(drop_modulus.SelectedItem.ToString(), out mod); @@ -176,22 +180,21 @@ namespace Handbrake.Controls switch (drp_anamorphic.SelectedIndex) { case 0: // None - text_height.BackColor = Color.White; - text_width.BackColor = Color.White; text_height.Enabled = true; text_width.Enabled = true; check_KeepAR.CheckState = CheckState.Checked; check_KeepAR.Enabled = true; disableCustomAnaControls(); - text_width.Text = widthVal.ToString(); - text_height.Text = heightVal.ToString(); + if (selectedTitle != null) + { + text_width.Value = selectedTitle.Resolution.Width; + text_height.Value = selectedTitle.Resolution.Height; + } check_KeepAR.Enabled = true; lbl_anamorphic.Text = ""; lbl_anamprohicLbl.Visible = false; break; case 1: // Strict - text_height.BackColor = Color.LightGray; - text_width.BackColor = Color.LightGray; if (selectedTitle != null) { heightModJumpGaurd = true; @@ -210,13 +213,11 @@ namespace Handbrake.Controls disableCustomAnaControls(); storageAspect = 0; text_height.Enabled = false; - text_height.BackColor = Color.LightGray; text_width.Enabled = true; - text_width.BackColor = Color.White; if (selectedTitle != null) { heightModJumpGaurd = true; - text_width.Value = selectedTitle.Resolution.Width - (int) crop_left.Value - (int) crop_right.Value; + text_width.Value = selectedTitle.Resolution.Width; text_height.Value = selectedTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value; } lbl_anamorphic.Text = looseAnamorphic(); @@ -226,8 +227,6 @@ namespace Handbrake.Controls // Display Elements enableCustomAnaControls(); - text_height.BackColor = Color.White; - text_width.BackColor = Color.White; text_height.Enabled = true; text_width.Enabled = true; @@ -270,7 +269,7 @@ namespace Handbrake.Controls customAnamorphic(txt_parWidth); } - // Cropping Control + // Cropping Controls private void check_autoCrop_CheckedChanged(object sender, EventArgs e) { crop_left.Enabled = false; @@ -299,6 +298,26 @@ namespace Handbrake.Controls crop_bottom.Text = "0"; } } + private void crop_left_ValueChanged(object sender, EventArgs e) + { + if (crop_left.Value % 2 != 0) + crop_left.Value++; + } + private void crop_right_ValueChanged(object sender, EventArgs e) + { + if (crop_right.Value % 2 != 0) + crop_right.Value++; + } + private void crop_top_ValueChanged(object sender, EventArgs e) + { + if (crop_top.Value % 2 != 0) + crop_top.Value++; + } + private void crop_bottom_ValueChanged(object sender, EventArgs e) + { + if (crop_bottom.Value % 2 != 0) + crop_bottom.Value++; + } // Custom Anamorphic Code private void customAnamorphic(Control control) diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs index f0c522348..7d5e479c1 100644 --- a/win/C#/Functions/PresetLoader.cs +++ b/win/C#/Functions/PresetLoader.cs @@ -88,41 +88,43 @@ namespace Handbrake.Functions mainWindow.pictureSettings.crop_left.Value = left; mainWindow.pictureSettings.crop_right.Value = right; } - - if (presetQuery.Width != 0) - mainWindow.pictureSettings.text_width.Text = presetQuery.Width.ToString(); - - if (presetQuery.Height != 0) - mainWindow.pictureSettings.text_height.Text = presetQuery.Height.ToString(); } // Set the anamorphic mode 0,1,2,3 mainWindow.pictureSettings.drp_anamorphic.SelectedIndex = presetQuery.AnamorphicMode; - // Custom Anamorphic Controls mainWindow.pictureSettings.check_KeepAR.CheckState = presetQuery.keepDisplayAsect ? CheckState.Checked : CheckState.Unchecked; - mainWindow.pictureSettings.txt_displayWidth.Text = presetQuery.displayWidthValue.ToString(); mainWindow.pictureSettings.txt_parWidth.Text = presetQuery.pixelAspectWidth.ToString(); mainWindow.pictureSettings.txt_parHeight.Text = presetQuery.pixelAspectHeight.ToString(); mainWindow.pictureSettings.drop_modulus.SelectedItem = presetQuery.AnamorphicModulus; - - // Set the public max width and max height varibles in frmMain - // These are used by the query generator to determine if it should use -X or -w / -Y or -h + + // Reset maxWidth and MaxHeight to 0 + mainWindow.pictureSettings.maxWidth = 0; + mainWindow.pictureSettings.maxHeight = 0; + + // Set the width and height + if (presetQuery.Width != 0) + mainWindow.pictureSettings.text_width.Value = presetQuery.Width; + + if (presetQuery.Height != 0) + mainWindow.pictureSettings.text_height.Value = presetQuery.Height; + + // Max Width/Height override Width/Height if (presetQuery.MaxWidth != 0) { - mainWindow.pictureSettings.text_width.Text = presetQuery.MaxWidth.ToString(); - mainWindow.maxWidth = presetQuery.MaxWidth; + mainWindow.pictureSettings.text_width.Value = presetQuery.MaxWidth; + mainWindow.pictureSettings.maxWidth = presetQuery.MaxWidth; } if (presetQuery.MaxHeight != 0) { - mainWindow.pictureSettings.text_height.Text = presetQuery.MaxHeight.ToString(); - mainWindow.maxHeight = presetQuery.MaxHeight; + mainWindow.pictureSettings.text_height.Value = presetQuery.MaxHeight; + mainWindow.pictureSettings.maxHeight = presetQuery.MaxHeight; } - + mainWindow.pictureSettings.setMax(); #endregion diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs index 16b2ace3f..595c9c175 100644 --- a/win/C#/Functions/QueryGenerator.cs +++ b/win/C#/Functions/QueryGenerator.cs @@ -118,7 +118,7 @@ namespace Handbrake.Functions #region Picture Settings Tab // Use MaxWidth for built-in presets and width for user settings. - if (mainWindow.maxWidth == 0) + if (mainWindow.pictureSettings.maxWidth == 0) { if (mainWindow.pictureSettings.text_width.Text != "") @@ -132,7 +132,7 @@ namespace Handbrake.Functions } // Use MaxHeight for built-in presets and height for user settings. - if (mainWindow.maxHeight == 0) + if (mainWindow.pictureSettings.maxHeight == 0) { if (mainWindow.pictureSettings.text_height.Text != "") if (mainWindow.pictureSettings.drp_anamorphic.SelectedIndex == 0 || mainWindow.pictureSettings.drp_anamorphic.SelectedIndex == 3) // Prevent usage for strict anamorphic diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 4a57fe2b8..f62519d04 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -31,8 +31,6 @@ namespace Handbrake private frmQueue queueWindow; private frmPreview qtpreview; private Form splash; - public int maxWidth; - public int maxHeight; // Delegates ********************************************************** private delegate void UpdateWindowHandler(); @@ -483,8 +481,6 @@ namespace Handbrake // The x264 widgets will need updated, so do this now: x264Panel.X264_StandardizeOptString(); x264Panel.X264_SetCurrentSettingsInPanel(); - - pictureSettings.setMax(); } } } -- 2.40.0