@@ -67,8 +67,11 @@ public float SplitCenter
6767 get => _splitStart + _splitWidth / 2 ;
6868 set
6969 {
70+ var args = new SplitCenterChangingEventArgs ( value , _dragging ) ;
71+ OnSplitCenterChanging ? . Invoke ( args ) ;
72+
7073 State = SplitState . Manual ;
71- _splitStart = value - _splitWidth / 2 ;
74+ _splitStart = args . SplitCenter - _splitWidth / 2 ;
7275 ClampSplitCenter ( ) ;
7376 InvalidateMeasure ( ) ;
7477 OnSplitResized ? . Invoke ( ) ;
@@ -95,6 +98,14 @@ public float SplitFraction
9598 }
9699 }
97100
101+ private float ? _pendingSplitFraction ;
102+
103+ public void SetSplitFractionOnNextArrange ( float fraction )
104+ {
105+ _pendingSplitFraction = fraction ;
106+ State = SplitState . Manual ;
107+ }
108+
98109 private SplitState _splitState = SplitState . Auto ;
99110 private SplitOrientation _orientation ;
100111 private SplitStretchDirection _stretchDirection = SplitStretchDirection . BottomRight ;
@@ -137,6 +148,7 @@ public Control? Second
137148
138149 public ( Control First , Control Second ) ? Splits => ChildCount < 3 ? null : ( GetChild ( 0 ) , GetChild ( 1 ) ) ;
139150
151+ public event Action < SplitCenterChangingEventArgs > ? OnSplitCenterChanging ;
140152 public event Action ? OnSplitResizeFinished ;
141153 public event Action ? OnSplitResized ;
142154
@@ -298,6 +310,12 @@ protected override Vector2 ArrangeOverride(Vector2 finalSize)
298310 var secondDesiredSize = Vertical ? second . DesiredSize . Y : second . DesiredSize . X ;
299311
300312 var size = Vertical ? finalSize . Y : finalSize . X ;
313+ if ( _pendingSplitFraction is { } pendingSplitFraction && size > 0 )
314+ {
315+ _splitStart = pendingSplitFraction * size - _splitWidth / 2 ;
316+ _pendingSplitFraction = null ;
317+ OnSplitResized ? . Invoke ( ) ;
318+ }
301319
302320 var ratio = first . SizeFlagsStretchRatio / ( first . SizeFlagsStretchRatio + second . SizeFlagsStretchRatio ) ;
303321
@@ -461,6 +479,18 @@ public enum SplitOrientation : byte
461479 Vertical
462480 }
463481
482+ public sealed class SplitCenterChangingEventArgs
483+ {
484+ public SplitCenterChangingEventArgs ( float splitCenter , bool dragging )
485+ {
486+ SplitCenter = splitCenter ;
487+ Dragging = dragging ;
488+ }
489+
490+ public float SplitCenter { get ; set ; }
491+ public bool Dragging { get ; }
492+ }
493+
464494 /// <summary>
465495 /// Specifies horizontal alignment modes.
466496 /// </summary>
0 commit comments