mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Updating control size flags now notifies parent container.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -9,6 +9,7 @@ using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.Interfaces.UserInterface;
|
||||
using Robust.Client.ResourceManagement.ResourceTypes;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Interfaces.Reflection;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -72,6 +73,8 @@ namespace Robust.Client.UserInterface
|
||||
public event Action<Control> OnVisibilityChanged;
|
||||
|
||||
private int _uniqueChildId;
|
||||
private SizeFlags _sizeFlagsHorizontal = SizeFlags.Fill;
|
||||
private SizeFlags _sizeFlagsVertical = SizeFlags.Fill;
|
||||
|
||||
/// <summary>
|
||||
/// The name of this control.
|
||||
@@ -630,13 +633,37 @@ namespace Robust.Client.UserInterface
|
||||
/// Horizontal size flags for container layout.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public SizeFlags SizeFlagsHorizontal { get; set; } = SizeFlags.Fill;
|
||||
public SizeFlags SizeFlagsHorizontal
|
||||
{
|
||||
get => _sizeFlagsHorizontal;
|
||||
set
|
||||
{
|
||||
_sizeFlagsHorizontal = value;
|
||||
|
||||
if (Parent is Container container)
|
||||
{
|
||||
container.SortChildren();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vertical size flags for container layout.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public SizeFlags SizeFlagsVertical { get; set; } = SizeFlags.Fill;
|
||||
public SizeFlags SizeFlagsVertical
|
||||
{
|
||||
get => _sizeFlagsVertical;
|
||||
set
|
||||
{
|
||||
_sizeFlagsVertical = value;
|
||||
|
||||
if (Parent is Container container)
|
||||
{
|
||||
container.SortChildren();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stretch ratio used to give shared of the available space in case multiple siblings are set to expand
|
||||
@@ -656,8 +683,11 @@ namespace Robust.Client.UserInterface
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value, "Value must be greater than zero.");
|
||||
}
|
||||
|
||||
// TODO: Notify parent container.
|
||||
_sizeFlagsStretchRatio = value;
|
||||
if (Parent is Container container)
|
||||
{
|
||||
container.SortChildren();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public int? SeparationOverride { get; set; }
|
||||
|
||||
protected override void SortChildren()
|
||||
protected internal override void SortChildren()
|
||||
{
|
||||
var separation = (int) (ActualSeparation * UIScale);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
[ControlWrap("CenterContainer")]
|
||||
public class CenterContainer : Container
|
||||
{
|
||||
protected override void SortChildren()
|
||||
protected internal override void SortChildren()
|
||||
{
|
||||
foreach (var child in Children)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
/// <summary>
|
||||
/// Called when the container should re-sort its children.
|
||||
/// </summary>
|
||||
protected virtual void SortChildren()
|
||||
protected internal virtual void SortChildren()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
return totalMinSize / UIScale;
|
||||
}
|
||||
|
||||
protected override void SortChildren()
|
||||
protected internal override void SortChildren()
|
||||
{
|
||||
var rows = Rows;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
public int? MarginRightOverride { get; set; }
|
||||
public int? MarginLeftOverride { get; set; }
|
||||
|
||||
protected override void SortChildren()
|
||||
protected internal override void SortChildren()
|
||||
{
|
||||
var top = MarginTopOverride ?? 0;
|
||||
var bottom = MarginBottomOverride ?? 0;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
style?.Draw(handle, PixelSizeBox);
|
||||
}
|
||||
|
||||
protected override void SortChildren()
|
||||
protected internal override void SortChildren()
|
||||
{
|
||||
base.SortChildren();
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
_vScrollBar.OnValueChanged += ev;
|
||||
}
|
||||
|
||||
protected override void SortChildren()
|
||||
protected internal override void SortChildren()
|
||||
{
|
||||
if (_vScrollBar?.Parent == null || _hScrollBar?.Parent == null)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
private protected abstract bool Vertical { get; }
|
||||
|
||||
protected override void SortChildren()
|
||||
protected internal override void SortChildren()
|
||||
{
|
||||
base.SortChildren();
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
FitChildInPixelBox(child, _getContentBox());
|
||||
}
|
||||
|
||||
protected override void SortChildren()
|
||||
protected internal override void SortChildren()
|
||||
{
|
||||
base.SortChildren();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user