Skip to content

Commit ba9e40a

Browse files
If the Work Orders list in the Help from (F1) is larger than the form and scroll bar was used to scroll down, status changes make the Work Orders tab go to the top again. Disturbing... This fix makes the form stay at the current scroll position. Also the case when switching tabs.
1 parent 84f72b8 commit ba9e40a

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Source/RunActivity/Viewer3D/Popups/HelpWindow.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,18 @@ public override void TabAction()
11601160

11611161
protected override ControlLayout Layout(ControlLayout layout)
11621162
{
1163+
int scrollPosition = 0;
1164+
if (Tabs[ActiveTab].Vbox != null)
1165+
{
1166+
foreach (var control in Tabs[ActiveTab].Vbox.Controls)
1167+
{
1168+
if (control is ControlLayoutScrollboxVertical controlLayoutScrollboxVertical)
1169+
{
1170+
scrollPosition = controlLayoutScrollboxVertical.GetScrollPosition();
1171+
}
1172+
}
1173+
}
1174+
11631175
var vbox = base.Layout(layout).AddLayoutVertical();
11641176

11651177
if (Tabs.Count > 0)
@@ -1175,8 +1187,17 @@ protected override ControlLayout Layout(ControlLayout layout)
11751187
}
11761188
vbox.AddHorizontalSeparator();
11771189
Tabs[ActiveTab].Layout(vbox);
1190+
1191+
foreach (var control in vbox.Controls)
1192+
{
1193+
if (control is ControlLayoutScrollboxVertical controlLayoutScrollboxVertical)
1194+
{
1195+
controlLayoutScrollboxVertical.SetScrollPosition(scrollPosition);
1196+
}
1197+
}
11781198
}
11791199

1200+
Tabs[ActiveTab].Vbox = vbox;
11801201
return vbox;
11811202
}
11821203

@@ -1202,12 +1223,14 @@ class TabData
12021223
public readonly Tab Tab;
12031224
public readonly string TabLabel;
12041225
public readonly Action<ControlLayout> Layout;
1226+
public Orts.Viewer3D.Popups.ControlLayoutVertical Vbox;
12051227

12061228
public TabData(Tab tab, string tabLabel, Action<ControlLayout> layout)
12071229
{
12081230
Tab = tab;
12091231
TabLabel = tabLabel;
12101232
Layout = layout;
1233+
Vbox = null;
12111234
}
12121235
}
12131236

Source/RunActivity/Viewer3D/Popups/WindowControls.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ protected ControlLayoutScrollbox(int width, int height)
587587

588588
public abstract int ScrollSize { get; }
589589

590+
public abstract int GetScrollPosition();
590591
public abstract void SetScrollPosition(int position);
591592

592593
internal RasterizerState ScissorTestEnable = new RasterizerState { ScissorTestEnable = true };
@@ -707,6 +708,11 @@ public override int ScrollSize
707708
}
708709
}
709710

711+
public override int GetScrollPosition()
712+
{
713+
return ScrollPosition;
714+
}
715+
710716
public override void SetScrollPosition(int position)
711717
{
712718
position = Math.Max(0, Math.Min(Math.Max(0, ScrollSize), position));
@@ -841,6 +847,11 @@ public override int ScrollSize
841847
}
842848
}
843849

850+
public override int GetScrollPosition()
851+
{
852+
return(ScrollPosition);
853+
}
854+
844855
public override void SetScrollPosition(int position)
845856
{
846857
position = Math.Max(0, Math.Min(Math.Max(0, ScrollSize), position));

0 commit comments

Comments
 (0)