Focus selected line after layout change + go to video pos if coming from layout without video - thx Dave :)

This commit is contained in:
Nikolaj Olsson 2024-03-17 09:35:47 +01:00
parent 87fc742c75
commit 99b843c2f0
2 changed files with 16 additions and 6 deletions

View File

@ -25018,6 +25018,7 @@ namespace Nikse.SubtitleEdit.Forms
SubtitleListview1.Items.Clear(); // for performance SubtitleListview1.Items.Clear(); // for performance
} }
var oldLayout = LayoutManager.LastLayout;
LayoutManager.SetLayout(layout, this, panelVideoPlayer, SubtitleListview1, groupBoxVideo, groupBoxEdit, SplitContainerListViewAndTextSplitterMoved); LayoutManager.SetLayout(layout, this, panelVideoPlayer, SubtitleListview1, groupBoxVideo, groupBoxEdit, SplitContainerListViewAndTextSplitterMoved);
if (isLarge) if (isLarge)
@ -25034,6 +25035,15 @@ namespace Nikse.SubtitleEdit.Forms
{ {
TryToFindAndOpenVideoFile(Utilities.GetPathAndFileNameWithoutExtension(_fileName)); TryToFindAndOpenVideoFile(Utilities.GetPathAndFileNameWithoutExtension(_fileName));
} }
if (_subtitleListViewIndex >= 0)
{
SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex, true);
if (layout != LayoutManager.LayoutNoVideo && oldLayout == LayoutManager.LayoutNoVideo)
{
GotoSubPosAndPause();
}
}
} }
public void ShowEarlierOrLater(double adjustMilliseconds, SelectionChoice selection) public void ShowEarlierOrLater(double adjustMilliseconds, SelectionChoice selection)

View File

@ -17,7 +17,7 @@ namespace Nikse.SubtitleEdit.Logic
public const int WaveformPanelMinimumHeight = 124; public const int WaveformPanelMinimumHeight = 124;
public static SplitContainer MainSplitContainer { get; set; } public static SplitContainer MainSplitContainer { get; set; }
private static int _lastLayout = -1; public static int LastLayout = -1;
private static Dictionary<int, string> LayoutInMemory { get; set; } private static Dictionary<int, string> LayoutInMemory { get; set; }
public static void SetLayout(int layout, Form form, Control videoPlayer, SubtitleListView subtitleListView, GroupBox groupBoxWaveform, GroupBox groupBoxEdit, SplitterEventHandler splitMoved) public static void SetLayout(int layout, Form form, Control videoPlayer, SubtitleListView subtitleListView, GroupBox groupBoxWaveform, GroupBox groupBoxEdit, SplitterEventHandler splitMoved)
@ -32,14 +32,14 @@ namespace Nikse.SubtitleEdit.Logic
LayoutInMemory = new Dictionary<int, string>(); LayoutInMemory = new Dictionary<int, string>();
} }
if (_lastLayout >= 0) if (LastLayout >= 0)
{ {
if (LayoutInMemory.ContainsKey(_lastLayout)) if (LayoutInMemory.ContainsKey(LastLayout))
{ {
LayoutInMemory.Remove(_lastLayout); LayoutInMemory.Remove(LastLayout);
} }
LayoutInMemory.Add(_lastLayout, SaveLayout()); LayoutInMemory.Add(LastLayout, SaveLayout());
} }
switch (layout) switch (layout)
@ -87,7 +87,7 @@ namespace Nikse.SubtitleEdit.Logic
RestoreLayout(LayoutInMemory[layout]); RestoreLayout(LayoutInMemory[layout]);
} }
_lastLayout = layout; LastLayout = layout;
} }
// default layout (video right) // default layout (video right)