ScrollContainer niceties (#4940)

- If scroll is not visible we don't handle it. This means nested containers don't interfere with their parents anymore.
- Fallback to Y-scrolling for H-scroll only containers.
This commit is contained in:
metalgearsloth
2024-03-06 09:32:22 +11:00
committed by GitHub
parent 108366152b
commit 558f4b5b16

View File

@@ -20,6 +20,11 @@ namespace Robust.Client.UserInterface.Controls
private bool _suppressScrollValueChanged;
/// <summary>
/// If true then if we have a y-axis scroll it will convert it to an x-axis scroll.
/// </summary>
public bool FallbackDeltaScroll { get; set; } = true;
public int ScrollSpeedX { get; set; } = 50;
public int ScrollSpeedY { get; set; } = 50;
@@ -246,9 +251,19 @@ namespace Robust.Client.UserInterface.Controls
if (_hScrollEnabled)
{
_hScrollBar.ValueTarget += args.Delta.X * ScrollSpeedX;
var delta =
args.Delta.X == 0f &&
!_vScrollEnabled &&
FallbackDeltaScroll ?
-args.Delta.Y :
args.Delta.X;
_hScrollBar.ValueTarget += delta * ScrollSpeedX;
}
if (!_vScrollVisible && !_hScrollVisible)
return;
args.Handle();
}