Use new engine APIs for setting the scroll target of views (#35401)
This commit is contained in:
committed by
GitHub
parent
3192914fc5
commit
cbecc4cc4b
@@ -512,39 +512,15 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
|
|||||||
if (scroll == null)
|
if (scroll == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!TryGetVerticalScrollbar(scroll, out var vScrollbar))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!TryGetNextScrollPosition(out float? nextScrollPosition))
|
if (!TryGetNextScrollPosition(out float? nextScrollPosition))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vScrollbar.ValueTarget = nextScrollPosition.Value;
|
scroll.VScrollTarget = nextScrollPosition.Value;
|
||||||
|
|
||||||
if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
|
if (MathHelper.CloseToPercent(scroll.VScroll, scroll.VScrollTarget))
|
||||||
_autoScrollActive = false;
|
_autoScrollActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
|
|
||||||
{
|
|
||||||
vScrollBar = null;
|
|
||||||
|
|
||||||
foreach (var child in scroll.Children)
|
|
||||||
{
|
|
||||||
if (child is not VScrollBar)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var castChild = child as VScrollBar;
|
|
||||||
|
|
||||||
if (castChild != null)
|
|
||||||
{
|
|
||||||
vScrollBar = castChild;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
|
private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
|
||||||
{
|
{
|
||||||
nextScrollPosition = null;
|
nextScrollPosition = null;
|
||||||
|
|||||||
@@ -350,35 +350,15 @@ public sealed partial class AtmosMonitoringConsoleWindow : FancyWindow
|
|||||||
if (scroll == null)
|
if (scroll == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!TryGetVerticalScrollbar(scroll, out var vScrollbar))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!TryGetNextScrollPosition(out float? nextScrollPosition))
|
if (!TryGetNextScrollPosition(out float? nextScrollPosition))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vScrollbar.ValueTarget = nextScrollPosition.Value;
|
scroll.VScrollTarget = nextScrollPosition.Value;
|
||||||
|
|
||||||
if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
|
if (MathHelper.CloseToPercent(scroll.VScroll, scroll.VScrollTarget))
|
||||||
_autoScrollActive = false;
|
_autoScrollActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
|
|
||||||
{
|
|
||||||
vScrollBar = null;
|
|
||||||
|
|
||||||
foreach (var control in scroll.Children)
|
|
||||||
{
|
|
||||||
if (control is not VScrollBar)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
vScrollBar = (VScrollBar)control;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
|
private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
|
||||||
{
|
{
|
||||||
nextScrollPosition = null;
|
nextScrollPosition = null;
|
||||||
|
|||||||
@@ -372,14 +372,11 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
|
|||||||
if (!_tryToScrollToListFocus)
|
if (!_tryToScrollToListFocus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!TryGetVerticalScrollbar(SensorScroller, out var vScrollbar))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (TryGetNextScrollPosition(out float? nextScrollPosition))
|
if (TryGetNextScrollPosition(out float? nextScrollPosition))
|
||||||
{
|
{
|
||||||
vScrollbar.ValueTarget = nextScrollPosition.Value;
|
SensorScroller.VScrollTarget = nextScrollPosition.Value;
|
||||||
|
|
||||||
if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
|
if (MathHelper.CloseToPercent(SensorScroller.VScroll, SensorScroller.VScrollTarget))
|
||||||
{
|
{
|
||||||
_tryToScrollToListFocus = false;
|
_tryToScrollToListFocus = false;
|
||||||
return;
|
return;
|
||||||
@@ -387,22 +384,6 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
|
|
||||||
{
|
|
||||||
vScrollBar = null;
|
|
||||||
|
|
||||||
foreach (var child in scroll.Children)
|
|
||||||
{
|
|
||||||
if (child is not VScrollBar)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
vScrollBar = (VScrollBar) child;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
|
private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
|
||||||
{
|
{
|
||||||
nextScrollPosition = 0;
|
nextScrollPosition = 0;
|
||||||
|
|||||||
@@ -269,27 +269,6 @@ public sealed partial class PowerMonitoringWindow
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
|
|
||||||
{
|
|
||||||
vScrollBar = null;
|
|
||||||
|
|
||||||
foreach (var child in scroll.Children)
|
|
||||||
{
|
|
||||||
if (child is not VScrollBar)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var castChild = child as VScrollBar;
|
|
||||||
|
|
||||||
if (castChild != null)
|
|
||||||
{
|
|
||||||
vScrollBar = castChild;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AutoScrollToFocus()
|
private void AutoScrollToFocus()
|
||||||
{
|
{
|
||||||
if (!_autoScrollActive)
|
if (!_autoScrollActive)
|
||||||
@@ -299,15 +278,12 @@ public sealed partial class PowerMonitoringWindow
|
|||||||
if (scroll == null)
|
if (scroll == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!TryGetVerticalScrollbar(scroll, out var vScrollbar))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!TryGetNextScrollPosition(out float? nextScrollPosition))
|
if (!TryGetNextScrollPosition(out float? nextScrollPosition))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vScrollbar.ValueTarget = nextScrollPosition.Value;
|
scroll.VScrollTarget = nextScrollPosition.Value;
|
||||||
|
|
||||||
if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
|
if (MathHelper.CloseToPercent(scroll.VScroll, scroll.VScrollTarget))
|
||||||
_autoScrollActive = false;
|
_autoScrollActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user