public override void Update(GameTime elapsedTime) { base.Update(elapsedTime); var collapseValue = collapseAnim.CurrentValue; if (Collapsed) { collapseAnim.Direction = AnimationDirection.Forward; collapseAnim.Update(elapsedTime); } else { collapseAnim.Direction = AnimationDirection.Backward; collapseAnim.Update(elapsedTime); } if (Math.Abs(collapseValue - collapseAnim.CurrentValue) > 0.0005) { InvalidateLayout(); } splitterBar.Update(elapsedTime); FirstPane?.Update(elapsedTime); SecondPane?.Update(elapsedTime); }
protected override void DrawChildren(IBatchedDrawingService drawingService) { splitterBar.Draw(drawingService); if (displayFirstPane && FirstPane != null) { var clipping = FirstPaneClippingRect(); drawingService.PushScissorRectangle(clipping); FirstPane.Draw(drawingService); drawingService.PopScissorRectangle(); } if (displaySecondPane && SecondPane != null) { drawingService.PushScissorRectangle(SecondPaneClippingRect()); SecondPane.Draw(drawingService); drawingService.PopScissorRectangle(); } }
protected override Size MeasureOverride(Size availableSize) { splitterBar.Measure(availableSize); var firstComponentSize = new Size(); var secondComponentSize = new Size(); if (Direction.IsHorizontal()) { if (float.IsInfinity(availableSize.Width)) { firstComponentSize.Width = float.PositiveInfinity; secondComponentSize.Width = float.PositiveInfinity; } else { var firstComponentConsumedSpace = Math.Max(Math.Min(availableSize.Width, SplitterOffset), FirstPaneMinSize); var remainingSpace = Math.Max(0, availableSize.Width - firstComponentConsumedSpace - splitterBar.DesiredSize.Width); firstComponentSize.Width = firstComponentConsumedSpace; secondComponentSize.Width = Math.Max(remainingSpace, SecondPaneMinSize); } firstComponentSize.Height = availableSize.Height; secondComponentSize.Height = availableSize.Height; } else { firstComponentSize.Width = availableSize.Width; secondComponentSize.Width = availableSize.Width; if (float.IsInfinity(availableSize.Height)) { firstComponentSize.Height = float.PositiveInfinity; secondComponentSize.Height = float.PositiveInfinity; } else { var firstComponentConsumedSpace = Math.Max(Math.Min(availableSize.Height, SplitterOffset), FirstPaneMinSize); var remainingSpace = Math.Max(0, availableSize.Height - firstComponentConsumedSpace - splitterBar.DesiredSize.Height); firstComponentSize.Height = firstComponentConsumedSpace; secondComponentSize.Height = Math.Max(remainingSpace, SecondPaneMinSize); } } FirstPane?.Measure(firstComponentSize); SecondPane?.Measure(secondComponentSize); firstComponentSize = FirstPane?.DesiredSize ?? new Size(); secondComponentSize = SecondPane?.DesiredSize ?? new Size(); switch (Direction) { case Direction.Left: { SplitterOffset = Math.Max(SplitterOffset, FirstPaneMinSize); var collapsedSplitterOffset = (int)Math.Max(0, (1f - collapseAnim.CurrentValue) * SplitterOffset); var secondPaneWidth = Math.Max(SecondPaneMinSize, SecondPane?.DesiredSize.Width ?? 0); var width = secondPaneWidth + splitterBar.DesiredSize.Width + collapsedSplitterOffset; return(new Size(width, Math.Max(splitterBar.DesiredSize.Height, Math.Max(firstComponentSize.Height, secondComponentSize.Height)))); } case Direction.Right: { SplitterOffset = Math.Max(SplitterOffset, SecondPaneMinSize); var collapsedSplitterOffset = (int)Math.Max(0, (1f - collapseAnim.CurrentValue) * SplitterOffset); var firstPaneWidth = Math.Max(FirstPaneMinSize, FirstPane?.DesiredSize.Width ?? 0); var width = firstPaneWidth + splitterBar.DesiredSize.Width + collapsedSplitterOffset; return(new Size(width, Math.Max(splitterBar.DesiredSize.Height, Math.Max(firstComponentSize.Height, secondComponentSize.Height)))); } case Direction.Up: { SplitterOffset = Math.Max(SplitterOffset, FirstPaneMinSize); var collapsedSplitterOffset = (int)Math.Max(0, (1f - collapseAnim.CurrentValue) * SplitterOffset); var secondPaneHeight = Math.Max(SecondPaneMinSize, SecondPane?.DesiredSize.Height ?? 0); var height = secondPaneHeight + splitterBar.DesiredSize.Height + collapsedSplitterOffset; return(new Size(Math.Max(splitterBar.DesiredSize.Width, Math.Max(firstComponentSize.Width, secondComponentSize.Width)), height)); } case Direction.Down: { SplitterOffset = Math.Max(SplitterOffset, SecondPaneMinSize); var collapsedSplitterOffset = (int)Math.Max(0, (1f - collapseAnim.CurrentValue) * SplitterOffset); var firstPaneHeight = Math.Max(FirstPaneMinSize, FirstPane?.DesiredSize.Height ?? 0); var height = firstPaneHeight + splitterBar.DesiredSize.Height + collapsedSplitterOffset; return(new Size(Math.Max(splitterBar.DesiredSize.Width, Math.Max(firstComponentSize.Width, secondComponentSize.Width)), height)); } default: throw new ArgumentOutOfRangeException(); } }