From c958074ca8909c072dca17164c67f61b957de4d7 Mon Sep 17 00:00:00 2001 From: niksedk Date: Sun, 17 Sep 2023 06:18:37 +0200 Subject: [PATCH] Work on layout --- LanguageBaseEnglish.xml | 1 + src/ui/Forms/LayoutPicker.Designer.cs | 42 +++++++++++++++++++++++---- src/ui/Forms/LayoutPicker.cs | 20 +++++++++++-- src/ui/Forms/Main.cs | 13 +++++++-- src/ui/Logic/Language.cs | 1 + src/ui/Logic/LanguageDeserializer.cs | 3 ++ src/ui/Logic/LanguageStructure.cs | 1 + src/ui/Logic/LayoutManager.cs | 4 +-- 8 files changed, 73 insertions(+), 12 deletions(-) diff --git a/LanguageBaseEnglish.xml b/LanguageBaseEnglish.xml index 535b133c1..3c4810882 100644 --- a/LanguageBaseEnglish.xml +++ b/LanguageBaseEnglish.xml @@ -1940,6 +1940,7 @@ Download and continue? Subtitle Edit needs a video player. To use the recommended video player "mpv" click on the button below. Download and use "mpv" as video player + Choose layout Choose subtitle from Matroska file diff --git a/src/ui/Forms/LayoutPicker.Designer.cs b/src/ui/Forms/LayoutPicker.Designer.cs index cb8e9e241..839a60613 100644 --- a/src/ui/Forms/LayoutPicker.Designer.cs +++ b/src/ui/Forms/LayoutPicker.Designer.cs @@ -1,6 +1,6 @@ namespace Nikse.SubtitleEdit.Forms { - partial class LayoutPicker + sealed partial class LayoutPicker { /// /// Required designer variable. @@ -38,6 +38,8 @@ this.button7 = new System.Windows.Forms.Button(); this.button8 = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); + this.checkBoxHideVideoControls = new System.Windows.Forms.CheckBox(); + this.buttonOk = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 @@ -105,7 +107,7 @@ this.button5.FlatAppearance.BorderSize = 0; this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button5.Image = ((System.Drawing.Image)(resources.GetObject("button5.Image"))); - this.button5.Location = new System.Drawing.Point(13, 173); + this.button5.Location = new System.Drawing.Point(13, 169); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(195, 147); this.button5.TabIndex = 4; @@ -120,7 +122,7 @@ this.button6.FlatAppearance.BorderSize = 0; this.button6.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button6.Image = ((System.Drawing.Image)(resources.GetObject("button6.Image"))); - this.button6.Location = new System.Drawing.Point(220, 173); + this.button6.Location = new System.Drawing.Point(220, 169); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(195, 147); this.button6.TabIndex = 5; @@ -135,7 +137,7 @@ this.button7.FlatAppearance.BorderSize = 0; this.button7.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button7.Image = global::Nikse.SubtitleEdit.Properties.Resources.L7; - this.button7.Location = new System.Drawing.Point(428, 174); + this.button7.Location = new System.Drawing.Point(428, 170); this.button7.Name = "button7"; this.button7.Size = new System.Drawing.Size(195, 147); this.button7.TabIndex = 6; @@ -150,7 +152,7 @@ this.button8.FlatAppearance.BorderSize = 0; this.button8.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button8.Image = ((System.Drawing.Image)(resources.GetObject("button8.Image"))); - this.button8.Location = new System.Drawing.Point(635, 174); + this.button8.Location = new System.Drawing.Point(635, 170); this.button8.Name = "button8"; this.button8.Size = new System.Drawing.Size(195, 147); this.button8.TabIndex = 7; @@ -167,15 +169,39 @@ this.buttonCancel.Location = new System.Drawing.Point(740, 339); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(90, 23); - this.buttonCancel.TabIndex = 46; + this.buttonCancel.TabIndex = 101; this.buttonCancel.Text = "C&ancel"; this.buttonCancel.UseVisualStyleBackColor = true; // + // checkBoxHideVideoControls + // + this.checkBoxHideVideoControls.AutoSize = true; + this.checkBoxHideVideoControls.Location = new System.Drawing.Point(13, 337); + this.checkBoxHideVideoControls.Name = "checkBoxHideVideoControls"; + this.checkBoxHideVideoControls.Size = new System.Drawing.Size(161, 17); + this.checkBoxHideVideoControls.TabIndex = 47; + this.checkBoxHideVideoControls.Text = "checkBoxHideVideoControls"; + this.checkBoxHideVideoControls.UseVisualStyleBackColor = true; + // + // buttonOk + // + this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOk.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOk.Location = new System.Drawing.Point(644, 339); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(90, 23); + this.buttonOk.TabIndex = 100; + this.buttonOk.Text = "&OK"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); + // // LayoutPicker // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(842, 374); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.checkBoxHideVideoControls); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.button8); this.Controls.Add(this.button7); @@ -194,9 +220,11 @@ this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Choose layout"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.LayoutPicker_FormClosing); this.Shown += new System.EventHandler(this.LayoutPicker_Shown); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.LayoutPicker_KeyDown); this.ResumeLayout(false); + this.PerformLayout(); } @@ -211,5 +239,7 @@ private System.Windows.Forms.Button button7; private System.Windows.Forms.Button button8; private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.CheckBox checkBoxHideVideoControls; + private System.Windows.Forms.Button buttonOk; } } \ No newline at end of file diff --git a/src/ui/Forms/LayoutPicker.cs b/src/ui/Forms/LayoutPicker.cs index 7d99642cf..b91f0d366 100644 --- a/src/ui/Forms/LayoutPicker.cs +++ b/src/ui/Forms/LayoutPicker.cs @@ -6,7 +6,7 @@ using System.Windows.Forms; namespace Nikse.SubtitleEdit.Forms { - public partial class LayoutPicker : Form + public sealed partial class LayoutPicker : Form { private int _layout; @@ -21,13 +21,19 @@ namespace Nikse.SubtitleEdit.Forms private bool _loading = true; - public LayoutPicker(int initialLayout) + public bool ShowVideoControls { get; set; } + + public LayoutPicker(int initialLayout, bool showVideoControls) { UiUtil.PreInitialize(this); InitializeComponent(); UiUtil.FixFonts(this); + Text = LanguageSettings.Current.Main.ChooseLayout; buttonCancel.Text = LanguageSettings.Current.General.Cancel; + checkBoxHideVideoControls.Text = LanguageSettings.Current.Main.HideVideoControls; + checkBoxHideVideoControls.Checked = !showVideoControls; CancelButton = buttonCancel; + AcceptButton = buttonOk; _layout = initialLayout; UpdateButtons(initialLayout); } @@ -381,5 +387,15 @@ namespace Nikse.SubtitleEdit.Forms _loading = false; SelectLayout(_layout); } + + private void LayoutPicker_FormClosing(object sender, FormClosingEventArgs e) + { + ShowVideoControls = !checkBoxHideVideoControls.Checked; + } + + private void buttonOk_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } } } diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index 8635735cf..17f7ffab5 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -24460,12 +24460,21 @@ namespace Nikse.SubtitleEdit.Forms private void ToolStripButtonToggleWaveformClick(object sender, EventArgs e) { - using (var form = new LayoutPicker(_layout)) + using (var form = new LayoutPicker(_layout, Configuration.Settings.General.ShowVideoControls)) { if (form.ShowDialog(this) == DialogResult.OK) { + var oldLayout = _layout; _layout = form.GetLayout(); - LayoutManager.SetLayout(_layout, Controls, panelVideoPlayer, SubtitleListview1, groupBoxVideo, groupBoxEdit); + if (_layout != oldLayout) + { + LayoutManager.SetLayout(_layout, Controls, panelVideoPlayer, SubtitleListview1, groupBoxVideo, groupBoxEdit); + } + + if (Configuration.Settings.General.ShowVideoControls != form.ShowVideoControls) + { + ToggleVideoControlsOnOff(form.ShowVideoControls); + } } } } diff --git a/src/ui/Logic/Language.cs b/src/ui/Logic/Language.cs index 17cd20ecb..a8c2de4a0 100644 --- a/src/ui/Logic/Language.cs +++ b/src/ui/Logic/Language.cs @@ -1857,6 +1857,7 @@ namespace Nikse.SubtitleEdit.Logic SubtitleEditNeedsVideoPlayer = "Subtitle Edit needs a video player.", UseRecommendMpv = "To use the recommended video player \"mpv\" click on the button below.", DownloadAndUseMpv = "Download and use \"mpv\" as video player", + ChooseLayout = "Choose layout", Menu = new LanguageStructure.Main.MainMenu { diff --git a/src/ui/Logic/LanguageDeserializer.cs b/src/ui/Logic/LanguageDeserializer.cs index fda2e80bd..226f1dcd5 100644 --- a/src/ui/Logic/LanguageDeserializer.cs +++ b/src/ui/Logic/LanguageDeserializer.cs @@ -4270,6 +4270,9 @@ namespace Nikse.SubtitleEdit.Logic case "Main/DownloadAndUseMpv": language.Main.DownloadAndUseMpv = reader.Value; break; + case "Main/ChooseLayout": + language.Main.ChooseLayout = reader.Value; + break; case "Main/Menu/File/Title": language.Main.Menu.File.Title = reader.Value; break; diff --git a/src/ui/Logic/LanguageStructure.cs b/src/ui/Logic/LanguageStructure.cs index 19924a134..72a547a6c 100644 --- a/src/ui/Logic/LanguageStructure.cs +++ b/src/ui/Logic/LanguageStructure.cs @@ -1673,6 +1673,7 @@ public string SubtitleEditNeedsVideoPlayer { get; set; } public string UseRecommendMpv { get; set; } public string DownloadAndUseMpv { get; set; } + public string ChooseLayout { get; set; } public class MainMenu { diff --git a/src/ui/Logic/LayoutManager.cs b/src/ui/Logic/LayoutManager.cs index 4b4a03bda..e2615825f 100644 --- a/src/ui/Logic/LayoutManager.cs +++ b/src/ui/Logic/LayoutManager.cs @@ -11,7 +11,7 @@ namespace Nikse.SubtitleEdit.Logic public static int ToggleLayout(int layout, Control.ControlCollection controls, Control videoPlayer, SubtitleListView subtitleListView, GroupBox groupBoxWaveform, GroupBox groupBoxEdit) { layout++; - if (layout > 7 || layout < 0) + if (layout > LayoutNoVideo || layout < 0) { layout = 0; } @@ -22,7 +22,7 @@ namespace Nikse.SubtitleEdit.Logic public static void SetLayout(int layout, Control.ControlCollection controls, Control videoPlayer, SubtitleListView subtitleListView, GroupBox groupBoxWaveform, GroupBox groupBoxEdit) { - if (layout > 7 || layout < 0) + if (layout > LayoutNoVideo || layout < 0) { layout = 0; }