Skip to content

Add a layer for layout application #4

@Hermanest

Description

@Hermanest

The problem

Currently layout is designed the way that controllers are responsible for layout application. This approach allows the system to be simple, but disables a lot of capabilities.

The solution

Shift the responsibility by making ILayoutItem accept the dimensions instead of exposing the entire RectTransform instance.
Current variant:

public interface ILayoutItem : ILayoutRecalculationSource {
    //...

    RectTransform BeginApply();
    void EndApply();
}

Replace with:

struct LayoutDimensions {
    public float TopOffset;
    public float LeftOffset;
    public float Width;
    public float Height;
}

public interface ILayoutItem : ILayoutRecalculationSource {
    //...

    void Apply(LayoutDimensions dimensions);
}

This approach enables us to implement an intermediate layer for animations, allowing lerping between states without knowing the exact values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions