Delight icon indicating copy to clipboard operation
Delight copied to clipboard

Incorrect layout when using both left & right margin?

Open KarimLUCCIN opened this issue 4 years ago • 2 comments

https://github.com/delight-dev/Delight/blob/698e660073ff492d0091571fc9a311f62e37a73c/UnityProject/Delight/Assets/Delight/Content/Views/UI/UIView.cs#L408

Should RectTransform.offsetMax actually read like this instead? RectTransform.offsetMax = new Vector2( offsetMaxX + margin.Left.Pixels - margin.Right.Pixels + offset.Left.Pixels - offset.Right.Pixels + offsetFromParent.Left.Pixels - offsetFromParent.Right.Pixels, offsetMaxY + margin.Bottom.Pixels - margin.Top.Pixels - offset.Top.Pixels + offset.Bottom.Pixels - offsetFromParent.Top.Pixels + offsetFromParent.Bottom.Pixels);

As in, adding margin.Left.Pixels and margin.Bottom.Pixels, otherwise setting a left margin on a rect with a fixed size within a group shrinks it instead of moving to the right.

Example: <Group Id="MainMenu" Alignment="Left" Orientation="Horizontal" Width="300" Height="100%"> <Region Id="Meme" BackgroundColor="Red" Width="10" Height="100%" Alignment="Left" Margin="105,0,0,0"/> </Group>

KarimLUCCIN avatar Apr 11 '21 20:04 KarimLUCCIN

Hmm it breaks the case where Width=100%. For that to work, I'm guessing the percentage should be applied after the margin is computed.

KarimLUCCIN avatar Apr 11 '21 20:04 KarimLUCCIN

Which ... I guess you can't do because UpdateRectTransform doesn't have the size of the parent as an argument

KarimLUCCIN avatar Apr 11 '21 22:04 KarimLUCCIN