WinGui: Basic support for PGS subtitles in the forms UI.
authorsr55 <sr55.hb@outlook.com>
Sun, 29 Apr 2012 00:33:13 +0000 (00:33 +0000)
committersr55 <sr55.hb@outlook.com>
Sun, 29 Apr 2012 00:33:13 +0000 (00:33 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4612 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/Controls/Subtitles.cs
win/CS/HandBrake.ApplicationServices/Model/Encoding/SubtitleType.cs
win/CS/HandBrake.ApplicationServices/Parsing/Subtitle.cs
win/CS/frmMain.Designer.cs
win/CS/frmMain.cs

index 1775f3b6ec6ac0bf4e5a5979700864ccb5ce3998..88e97b7fb27f61f2ed777712b154e0835d88d84f 100644 (file)
@@ -16,6 +16,7 @@ namespace Handbrake.Controls
 \r
     using HandBrake.ApplicationServices;\r
     using HandBrake.ApplicationServices.Model.Encoding;\r
+    using HandBrake.ApplicationServices.Parsing;\r
     using HandBrake.ApplicationServices.Services.Interfaces;\r
     using HandBrake.ApplicationServices.Utilities;\r
 \r
@@ -46,6 +47,10 @@ namespace Handbrake.Controls
         /// </summary>\r
         private static readonly IUserSettingService UserSettingService = ServiceManager.UserSettingService;\r
 \r
+        /// <summary>\r
+        /// The current output extension\r
+        /// </summary>\r
+        private string currentOutputExtension;\r
         #endregion\r
 \r
         /// <summary>\r
@@ -190,6 +195,17 @@ namespace Handbrake.Controls
             return this.subList.Any(track => track.SubtitleType != SubtitleType.VobSub);\r
         }\r
 \r
+        /// <summary>\r
+        /// Set the current extension to allow this window to behave correctly based on extension.\r
+        /// </summary>\r
+        /// <param name="extension">\r
+        /// The extension.\r
+        /// </param>\r
+        public void SetExtension(string extension)\r
+        {\r
+            currentOutputExtension = extension.Replace(".", string.Empty);\r
+        }\r
+\r
         /// <summary>\r
         /// Automatically setup the subtitle tracks.\r
         /// This handles the automatic setup of subitles which the user can control from the program options\r
@@ -401,6 +417,24 @@ namespace Handbrake.Controls
                 SrtFileName = srtFile\r
             };\r
 \r
+            track.SubtitleType = ((Subtitle)drp_subtitleTracks.SelectedItem).SubtitleType;\r
+\r
+            if (currentOutputExtension.Equals("mp4", StringComparison.InvariantCultureIgnoreCase) ||\r
+                currentOutputExtension.Equals("m4v", StringComparison.CurrentCultureIgnoreCase))\r
+            {\r
+                // Default it to burned as mp4 doesn't allow PGS\r
+                track.Burned = true;\r
+\r
+                // Check to make sure we don't have more than one PGS. Fail if we do.\r
+                if (this.subList.Any(item => item.SubtitleType == SubtitleType.PGS))\r
+                {\r
+                    MessageBox.Show(\r
+                        "You can only burn-in one PGS subtitle track into an MP4 file. You must first remove the current track to add a new one.",\r
+                        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                    return;\r
+                }\r
+            }\r
+\r
             lv_subList.Items.Add(track.ListView);\r
             subList.Add(track);\r
         }\r
@@ -417,14 +451,35 @@ namespace Handbrake.Controls
         private void mnu_AddAll_Click(object sender, EventArgs e)\r
         {\r
             // TODO - Might need to be a bit more clever with this. Will wait and see if this causes any problems.\r
+            bool addedPGS = false;\r
             foreach (object item in drp_subtitleTracks.Items)\r
             {\r
+                Subtitle sub = item as Subtitle;\r
+\r
+                // PGS Handling.\r
+                if (addedPGS)\r
+                {\r
+                    // Skip over any pgs tracks after we've added the first.\r
+                    continue;\r
+                }\r
+\r
+                if (currentOutputExtension.Equals("mp4", StringComparison.InvariantCultureIgnoreCase) ||\r
+                    currentOutputExtension.Equals("m4v", StringComparison.CurrentCultureIgnoreCase))\r
+                {\r
+                    if (sub != null && sub.SubtitleType == SubtitleType.PGS)\r
+                    {\r
+                        addedPGS = true;\r
+                    }\r
+                }\r
+\r
                 if (!item.ToString().Contains("Foreign Audio Search"))\r
                 {\r
                     drp_subtitleTracks.SelectedItem = item;\r
                     btn_addSubtitleTrack_Click(this, EventArgs.Empty);\r
                 }\r
             }\r
+\r
+\r
         }\r
 \r
         /// <summary>\r
index 5a69d010573eefce1d25b5f7c6aef69d883d27d0..5b533f8291330b6fb0d908b1eb38d4ad8ca52075 100644 (file)
@@ -24,6 +24,8 @@ namespace HandBrake.ApplicationServices.Model.Encoding
         UTF8Sub,\r
         [Description("TX3G")]\r
         TX3G,\r
+        [Description("PGS")]\r
+        PGS,\r
         [Description("Unknown")]\r
         Unknown\r
     }\r
index 5e7b89a10f56d836dabb06bab63bb499b547645b..d42cb0c22bb5af7cfecec8c8d2a735f83f75f17a 100644 (file)
@@ -126,6 +126,9 @@ namespace HandBrake.ApplicationServices.Parsing
                     case "SSA":\r
                         thisSubtitle.SubtitleType = SubtitleType.SSA;\r
                         break;\r
+                    case "PGS":\r
+                        thisSubtitle.SubtitleType = SubtitleType.PGS;\r
+                        break;\r
                     default:\r
                         thisSubtitle.SubtitleType = SubtitleType.Unknown;\r
                         break;\r
index 6a481b8ccef8fabad323eb8a95bdb3e4b9255cda..430440cc2ec7ba3abe1a3c8955beacfd30494f78 100644 (file)
@@ -247,8 +247,8 @@ namespace Handbrake
             // \r
             // text_destination\r
             // \r
-            this.text_destination.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \r
-            | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.text_destination.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
             this.text_destination.Location = new System.Drawing.Point(36, 3);\r
             this.text_destination.Name = "text_destination";\r
             this.text_destination.Size = new System.Drawing.Size(603, 21);\r
@@ -283,7 +283,7 @@ namespace Handbrake
             this.check_largeFile.TabIndex = 2;\r
             this.check_largeFile.Text = "Large file size";\r
             this.ToolTip.SetToolTip(this.check_largeFile, "Caution: This option will likely break device compatibility with all but the Appl" +\r
-        "eTV Take 2.\r\nChecking this box enables a 64bit mp4 file which can be over 4GB.");\r
+                    "eTV Take 2.\r\nChecking this box enables a 64bit mp4 file which can be over 4GB.");\r
             this.check_largeFile.UseVisualStyleBackColor = false;\r
             // \r
             // check_turbo\r
@@ -293,7 +293,7 @@ namespace Handbrake
             this.check_turbo.Enabled = false;\r
             this.check_turbo.Location = new System.Drawing.Point(495, 134);\r
             this.check_turbo.Name = "check_turbo";\r
-            this.check_turbo.Size = new System.Drawing.Size(101, 17);\r
+            this.check_turbo.Size = new System.Drawing.Size(99, 17);\r
             this.check_turbo.TabIndex = 9;\r
             this.check_turbo.Text = "Turbo first Pass";\r
             this.ToolTip.SetToolTip(this.check_turbo, "Makes the first pass of a 2 pass encode faster.");\r
@@ -357,8 +357,8 @@ namespace Handbrake
             this.check_optimiseMP4.TabIndex = 3;\r
             this.check_optimiseMP4.Text = "Web optimized";\r
             this.ToolTip.SetToolTip(this.check_optimiseMP4, "MP4 files can be optimized for progressive downloads over the Web,\r\nbut note that" +\r
-        " QuickTime can only read the files as long as the file extension is .mp4\r\nCan on" +\r
-        "ly be used with H.264 ");\r
+                    " QuickTime can only read the files as long as the file extension is .mp4\r\nCan on" +\r
+                    "ly be used with H.264 ");\r
             this.check_optimiseMP4.UseVisualStyleBackColor = false;\r
             // \r
             // check_iPodAtom\r
@@ -372,7 +372,7 @@ namespace Handbrake
             this.check_iPodAtom.TabIndex = 4;\r
             this.check_iPodAtom.Text = "iPod 5G support";\r
             this.ToolTip.SetToolTip(this.check_iPodAtom, "Support for legacy 5th Generation iPods.\r\nEncodes will not sync if this option is" +\r
-        " not enabled for H.264 encodes.");\r
+                    " not enabled for H.264 encodes.");\r
             this.check_iPodAtom.UseVisualStyleBackColor = false;\r
             // \r
             // data_chpt\r
@@ -489,8 +489,8 @@ namespace Handbrake
             this.drp_dvdtitle.Size = new System.Drawing.Size(119, 21);\r
             this.drp_dvdtitle.TabIndex = 1;\r
             this.ToolTip.SetToolTip(this.drp_dvdtitle, "Select the title you wish to encode.\r\n\r\nWhen a DVD is in use, HandBrake will try " +\r
-        "to determine the \"Main Feature\" title automatically.\r\nPlease note, this is not a" +\r
-        "lways accurate and should be checked.");\r
+                    "to determine the \"Main Feature\" title automatically.\r\nPlease note, this is not a" +\r
+                    "lways accurate and should be checked.");\r
             this.drp_dvdtitle.SelectedIndexChanged += new System.EventHandler(this.drp_dvdtitle_SelectedIndexChanged);\r
             this.drp_dvdtitle.Click += new System.EventHandler(this.drp_dvdtitle_Click);\r
             // \r
@@ -548,8 +548,8 @@ namespace Handbrake
             this.btn_generate_Query.TabIndex = 2;\r
             this.btn_generate_Query.Text = "Generate Query";\r
             this.ToolTip.SetToolTip(this.btn_generate_Query, "This will allow you to override the generated query.\r\nNote, The query in the box " +\r
-        "below will always override any automatically generated query, even if you change" +\r
-        " title or source.");\r
+                    "below will always override any automatically generated query, even if you change" +\r
+                    " title or source.");\r
             this.btn_generate_Query.UseVisualStyleBackColor = true;\r
             this.btn_generate_Query.Click += new System.EventHandler(this.btn_generate_Query_Click);\r
             // \r
@@ -559,7 +559,7 @@ namespace Handbrake
             this.radio_cq.BackColor = System.Drawing.Color.Transparent;\r
             this.radio_cq.Location = new System.Drawing.Point(366, 37);\r
             this.radio_cq.Name = "radio_cq";\r
-            this.radio_cq.Size = new System.Drawing.Size(110, 17);\r
+            this.radio_cq.Size = new System.Drawing.Size(105, 17);\r
             this.radio_cq.TabIndex = 3;\r
             this.radio_cq.Text = "Constant Quality:";\r
             this.ToolTip.SetToolTip(this.radio_cq, resources.GetString("radio_cq.ToolTip"));\r
@@ -573,7 +573,7 @@ namespace Handbrake
             this.radio_avgBitrate.Checked = true;\r
             this.radio_avgBitrate.Location = new System.Drawing.Point(367, 108);\r
             this.radio_avgBitrate.Name = "radio_avgBitrate";\r
-            this.radio_avgBitrate.Size = new System.Drawing.Size(116, 17);\r
+            this.radio_avgBitrate.Size = new System.Drawing.Size(112, 17);\r
             this.radio_avgBitrate.TabIndex = 4;\r
             this.radio_avgBitrate.TabStop = true;\r
             this.radio_avgBitrate.Text = "Avg Bitrate (kbps):";\r
@@ -587,7 +587,7 @@ namespace Handbrake
             this.check_2PassEncode.BackColor = System.Drawing.Color.Transparent;\r
             this.check_2PassEncode.Location = new System.Drawing.Point(385, 134);\r
             this.check_2PassEncode.Name = "check_2PassEncode";\r
-            this.check_2PassEncode.Size = new System.Drawing.Size(104, 17);\r
+            this.check_2PassEncode.Size = new System.Drawing.Size(106, 17);\r
             this.check_2PassEncode.TabIndex = 10;\r
             this.check_2PassEncode.Text = "2-Pass Encoding";\r
             this.ToolTip.SetToolTip(this.check_2PassEncode, resources.GetString("check_2PassEncode.ToolTip"));\r
@@ -840,6 +840,7 @@ namespace Handbrake
             allowedPassthru1.AudioAllowDTSPass = true;\r
             allowedPassthru1.AudioAllowMP3Pass = true;\r
             allowedPassthru1.AudioEncoderFallback = HandBrake.Interop.Model.Encoding.AudioEncoder.Ac3;\r
+            allowedPassthru1.IsEnabled = false;\r
             this.AudioSettings.PassthruSettings = allowedPassthru1;\r
             this.AudioSettings.Size = new System.Drawing.Size(720, 310);\r
             this.AudioSettings.TabIndex = 0;\r
@@ -891,7 +892,7 @@ namespace Handbrake
             this.radio_constantFramerate.Checked = true;\r
             this.radio_constantFramerate.Location = new System.Drawing.Point(0, 0);\r
             this.radio_constantFramerate.Name = "radio_constantFramerate";\r
-            this.radio_constantFramerate.Size = new System.Drawing.Size(122, 17);\r
+            this.radio_constantFramerate.Size = new System.Drawing.Size(117, 17);\r
             this.radio_constantFramerate.TabIndex = 17;\r
             this.radio_constantFramerate.TabStop = true;\r
             this.radio_constantFramerate.Text = "Constant Framerate";\r
@@ -903,7 +904,7 @@ namespace Handbrake
             this.radio_peakAndVariable.BackColor = System.Drawing.Color.Transparent;\r
             this.radio_peakAndVariable.Location = new System.Drawing.Point(0, 23);\r
             this.radio_peakAndVariable.Name = "radio_peakAndVariable";\r
-            this.radio_peakAndVariable.Size = new System.Drawing.Size(116, 17);\r
+            this.radio_peakAndVariable.Size = new System.Drawing.Size(113, 17);\r
             this.radio_peakAndVariable.TabIndex = 19;\r
             this.radio_peakAndVariable.Text = "Variable Framerate";\r
             this.radio_peakAndVariable.UseVisualStyleBackColor = false;\r
@@ -982,7 +983,7 @@ namespace Handbrake
             this.Check_ChapterMarkers.BackColor = System.Drawing.Color.Transparent;\r
             this.Check_ChapterMarkers.Location = new System.Drawing.Point(16, 32);\r
             this.Check_ChapterMarkers.Name = "Check_ChapterMarkers";\r
-            this.Check_ChapterMarkers.Size = new System.Drawing.Size(140, 17);\r
+            this.Check_ChapterMarkers.Size = new System.Drawing.Size(136, 17);\r
             this.Check_ChapterMarkers.TabIndex = 4;\r
             this.Check_ChapterMarkers.Text = "Create chapter markers";\r
             this.Check_ChapterMarkers.UseVisualStyleBackColor = false;\r
@@ -1333,8 +1334,8 @@ namespace Handbrake
             this.btn_dvd_source.Image = global::Handbrake.Properties.Resources.folder;\r
             this.btn_dvd_source.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.btn_dvd_source.Name = "btn_dvd_source";\r
-            this.btn_dvd_source.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) \r
-            | System.Windows.Forms.Keys.O)));\r
+            this.btn_dvd_source.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)\r
+                        | System.Windows.Forms.Keys.O)));\r
             this.btn_dvd_source.Size = new System.Drawing.Size(182, 22);\r
             this.btn_dvd_source.Text = "Folder";\r
             this.btn_dvd_source.Click += new System.EventHandler(this.BtnFolderScanClicked);\r
@@ -1406,7 +1407,7 @@ namespace Handbrake
             this.mnu_AddAllTitles.Size = new System.Drawing.Size(192, 22);\r
             this.mnu_AddAllTitles.Text = "Add All (Experimental)";\r
             this.mnu_AddAllTitles.ToolTipText = "Add all titles to the queue.\r\nUse caution with this feature as incorrect usage ma" +\r
-    "y result in a queue of failed encodes.";\r
+                "y result in a queue of failed encodes.";\r
             this.mnu_AddAllTitles.Click += new System.EventHandler(this.mnu_AddAllTitles_Click);\r
             // \r
             // mnu_AddTittleRange\r
@@ -1452,7 +1453,7 @@ namespace Handbrake
             this.btn_ActivityWindow.Size = new System.Drawing.Size(130, 36);\r
             this.btn_ActivityWindow.Text = "Activity Window";\r
             this.btn_ActivityWindow.ToolTipText = "Displays the activity window which displays the log of the last completed or curr" +\r
-    "ently running encode.";\r
+                "ently running encode.";\r
             this.btn_ActivityWindow.Click += new System.EventHandler(this.btn_ActivityWindow_Click);\r
             // \r
             // toolStripSeparator8\r
index 9b7d5540be977f61c52c68cfa1b3d03c85c3e3af..acb71fb40cbc708f6c5a5f7f89b9c936a3138e99 100644 (file)
@@ -1829,6 +1829,8 @@ namespace Handbrake
 \r
             if (Path.HasExtension(newExtension))\r
                 text_destination.Text = Path.ChangeExtension(text_destination.Text, newExtension);\r
+\r
+            this.Subtitles.SetExtension(newExtension);\r
         }\r
 \r
         // Video Tab\r