Merge pull request #6999 from JonSchram/main

Adds ability to set layer for the current subtitle.
This commit is contained in:
Nikolaj Olsson 2023-06-17 01:00:38 -04:00 committed by GitHub
commit 7584918f62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 1 deletions

View File

@ -1474,6 +1474,7 @@ To use an API key, go to "Options -> Settings -> Tools" to enter your Goog
<Next>Next &gt;</Next>
<AutoBreak>Auto &amp;br</AutoBreak>
<Unbreak>Unbreak</Unbreak>
<SetLayer>Set layer</SetLayer>
</Controls>
<VideoControls>
<Translate>Translate</Translate>

View File

@ -465,6 +465,8 @@ namespace Nikse.SubtitleEdit.Forms
this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.imageListBookmarks = new System.Windows.Forms.ImageList(this.components);
this.groupBoxEdit = new System.Windows.Forms.GroupBox();
this.numericUpDownLayer = new System.Windows.Forms.NumericUpDown();
this.labelLayer = new System.Windows.Forms.Label();
this.panelBookmark = new System.Windows.Forms.Panel();
this.labelBookmark = new System.Windows.Forms.Label();
this.textBoxListViewText = new Nikse.SubtitleEdit.Controls.SETextBox();
@ -607,6 +609,7 @@ namespace Nikse.SubtitleEdit.Forms
this.splitContainerListViewAndText.Panel2.SuspendLayout();
this.splitContainerListViewAndText.SuspendLayout();
this.groupBoxEdit.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownLayer)).BeginInit();
this.panelBookmark.SuspendLayout();
this.contextMenuStripTextBoxListView.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBookmark)).BeginInit();
@ -4527,6 +4530,8 @@ namespace Nikse.SubtitleEdit.Forms
//
// groupBoxEdit
//
this.groupBoxEdit.Controls.Add(this.numericUpDownLayer);
this.groupBoxEdit.Controls.Add(this.labelLayer);
this.groupBoxEdit.Controls.Add(this.panelBookmark);
this.groupBoxEdit.Controls.Add(this.textBoxListViewText);
this.groupBoxEdit.Controls.Add(this.labelOriginalSingleLinePixels);
@ -4562,6 +4567,33 @@ namespace Nikse.SubtitleEdit.Forms
this.groupBoxEdit.TabIndex = 1;
this.groupBoxEdit.TabStop = false;
//
// numericUpDownLayer
//
this.numericUpDownLayer.Location = new System.Drawing.Point(44, 113);
this.numericUpDownLayer.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.numericUpDownLayer.Minimum = new decimal(new int[] {
-2147483648,
0,
0,
-2147483648});
this.numericUpDownLayer.Name = "numericUpDownLayer";
this.numericUpDownLayer.Size = new System.Drawing.Size(37, 20);
this.numericUpDownLayer.TabIndex = 46;
this.numericUpDownLayer.ValueChanged += new System.EventHandler(this.NumericUpDownLayer_ValueChanged);
//
// labelLayer
//
this.labelLayer.AutoSize = true;
this.labelLayer.Location = new System.Drawing.Point(9, 115);
this.labelLayer.Name = "labelLayer";
this.labelLayer.Size = new System.Drawing.Size(33, 13);
this.labelLayer.TabIndex = 45;
this.labelLayer.Text = "Layer";
//
// panelBookmark
//
this.panelBookmark.BackColor = System.Drawing.Color.LemonChiffon;
@ -5660,6 +5692,7 @@ namespace Nikse.SubtitleEdit.Forms
this.splitContainerListViewAndText.ResumeLayout(false);
this.groupBoxEdit.ResumeLayout(false);
this.groupBoxEdit.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownLayer)).EndInit();
this.panelBookmark.ResumeLayout(false);
this.panelBookmark.PerformLayout();
this.contextMenuStripTextBoxListView.ResumeLayout(false);
@ -6207,5 +6240,7 @@ namespace Nikse.SubtitleEdit.Forms
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportTtmlImage;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4Extend;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetLayer;
private System.Windows.Forms.NumericUpDown numericUpDownLayer;
private System.Windows.Forms.Label labelLayer;
}
}

View File

@ -10768,6 +10768,25 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void NumericUpDownLayer_ValueChanged(object sender, EventArgs e)
{
var idx = _subtitleListViewIndex;
var p = _subtitle.GetParagraphOrDefault(idx);
if (p == null)
{
return;
}
var format = GetCurrentSubtitleFormat();
bool isAssa = format.GetType() == typeof(AdvancedSubStationAlpha);
if (isAssa)
{
int layer = (int)numericUpDownLayer.Value;
MakeHistoryForUndo(LanguageSettings.Current.Main.Controls.SetLayer + ": " + layer);
p.Layer = layer;
}
}
public Point GetPositionInForm(Control ctrl)
{
Point p = ctrl.Location;
@ -12906,6 +12925,17 @@ namespace Nikse.SubtitleEdit.Forms
textBoxListViewText.TextChanged += TextBoxListViewTextTextChanged;
_listViewTextUndoLast = p.Text;
var format = GetCurrentSubtitleFormat();
bool isAssa = format.GetType() == typeof(AdvancedSubStationAlpha);
numericUpDownLayer.Visible = isAssa;
labelLayer.Visible = isAssa;
if (isAssa)
{
numericUpDownLayer.ValueChanged -= NumericUpDownLayer_ValueChanged;
numericUpDownLayer.Value = p.Layer;
numericUpDownLayer.ValueChanged += NumericUpDownLayer_ValueChanged;
}
timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged;
timeUpDownStartTime.TimeCode = p.StartTime;
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged;

View File

@ -2040,7 +2040,8 @@ namespace Nikse.SubtitleEdit.Logic
Previous = "< Prev",
Next = "Next >",
AutoBreak = "Auto &br",
Unbreak = "Unbreak"
Unbreak = "Unbreak",
SetLayer = "Set Layer"
},
VideoControls = new LanguageStructure.Main.MainVideoControls

View File

@ -1898,6 +1898,7 @@ namespace Nikse.SubtitleEdit.Logic
public string Next { get; set; }
public string AutoBreak { get; set; }
public string Unbreak { get; set; }
public string SetLayer { get; set; }
}
public class MainVideoControls