Open PeturDarriPeturs opened 3 years ago
I managed to "fix" this with a custom stack node view that overrides OnCustomStyleResolved
to replace the ICustomStyle
with my own that has the fixed values for height and extent, while falling back on the original ICustomStyle
for everything else.
I wanted to fix this with a custom style sheet, but the separator elements are positioned absolutely and so their height and offset from the top are calculated in code.
[CustomStackNodeView(typeof(BaseStackNodeView))]
public class FixedStackNodeView : BaseStackNodeView
{
private static readonly FixedStyle _fixedStyle = new FixedStyle();
protected override void OnCustomStyleResolved(ICustomStyle styles)
{
_fixedStyle.Parent = styles;
base.OnCustomStyleResolved(_fixedStyle);
}
public FixedStackNodeView(BaseStackNode stackNode) : base(stackNode)
{
}
private class FixedStyle : ICustomStyle
{
public ICustomStyle Parent;
public bool TryGetValue(CustomStyleProperty<float> property, out float value)
{
switch (property.name)
{
case "--separator-height":
value = 4f;
return true;
case "--separator-extent":
value = 4f;
return true;
default:
return Parent.TryGetValue(property, out value);
}
}
public bool TryGetValue(CustomStyleProperty<int> property, out int value) => Parent.TryGetValue(property, out value);
public bool TryGetValue(CustomStyleProperty<bool> property, out bool value) => Parent.TryGetValue(property, out value);
public bool TryGetValue(CustomStyleProperty<Color> property, out Color value) => Parent.TryGetValue(property, out value);
public bool TryGetValue(CustomStyleProperty<Texture2D> property, out Texture2D value) => Parent.TryGetValue(property, out value);
public bool TryGetValue(CustomStyleProperty<VectorImage> property, out VectorImage value) => Parent.TryGetValue(property, out value);
public bool TryGetValue(CustomStyleProperty<string> property, out string value) => Parent.TryGetValue(property, out value);
}
}
It overlaps a good bit on the top and bottom of every node and makes it difficult to interact with them.