using UnityEngine; using System.Collections.Generic; namespace Flexalon { /// Represents a node in the Flexalon layout tree. public interface FlexalonNode { /// The GameObject associated with this node. GameObject GameObject{ get; } /// Marks this node and its parents as dirty, so they will be updated by the Flexalon component. void MarkDirty(); /// True if this node is dirty. bool Dirty { get; } /// Forces this node, its parent nodes, and its children nodes to update immediately. void ForceUpdate(); /// The parent layout node of this node. FlexalonNode Parent { get; } /// The children of this layout node. IReadOnlyList Children { get; } /// The index of this node in its parent's Children list. int Index { get; } /// Adds a child to this layout node. /// The child to add. void AddChild(FlexalonNode child); /// Inserts a child into this layout node. /// The child to insert. /// The index to insert the child at. void InsertChild(FlexalonNode child, int index); /// Returns the child of this layout node. /// The index of the child to return. /// The child at the given index. FlexalonNode GetChild(int index); /// Removes this node from its parent layout node. void Detach(); /// Removes all children from this layout node. void DetachAllChildren(); /// Assigns a layout method to this node. void SetMethod(Layout method); /// Returns the layout method of this node. Layout Method { get; } /// Assigns a transform updater to this node. void SetTransformUpdater(TransformUpdater updater); /// Returns the FlexalonObject of this node. FlexalonObject FlexalonObject { get; } /// Returns true if FlexalonObject is set. bool HasFlexalonObject { get; } /// Assigns a FlexalonObject to this node. void SetFlexalonObject(FlexalonObject obj); /// Returns the assigned fixed size of this node. Vector3 Size { get; } /// Returns the assigned size factor of this node relative to the available space. Vector3 SizeOfParent { get; } /// Returns the assigned offset of this node relative to its layout position. Vector3 Offset { get; } /// Returns the assigned SizeType of this node. /// The axis to get the SizeType of. /// The SizeType of the given axis. SizeType GetSizeType(Axis axis); /// Returns the assigned SizeType of this node. /// The axis to get the SizeType of. /// The SizeType of the given axis. SizeType GetSizeType(int axis); /// Returns true if this node is not filling this axis and has a min size set. bool CanShrink(int axis); /// Returns the assigned relative scale of this node. Vector3 Scale { get; } /// Returns the assigned relative rotation of this node. Quaternion Rotation { get; } /// Returns the assigned margin of this node. Directions Margin { get; } /// Returns the assigned padding of this node. Directions Padding { get; } /// Returns the computed size of this node during the measure step. Vector3 GetMeasureSize(Vector3 layoutSize); /// Returns the computed size of this node during the measure step. float GetMeasureSize(int axis, float layoutSize); /// Returns the min size of this node, including margin. Vector3 GetMinSize(Vector3 parentSize); /// Returns the min size of this node, including margin. float GetMinSize(int axis, float parentSize); /// Returns the max size of this node, including margin. float GetMaxSize(int axis, float parentSize); /// Returns the computed size of this node during the arrange step. Vector3 GetArrangeSize(); /// Returns the world position of the layout box. Used for gizmos. Vector3 GetWorldBoxPosition(Vector3 scale, bool includePadding); /// Returns the world scale of the layout box. Used for gizmos. Vector3 GetWorldBoxScale(bool includeLocalScale); /// Has layout ever run on this node? bool HasResult { get; } /// Returns the result of the last layout run. FlexalonResult Result { get; } /// Sets the space a child should shrink or fill. void SetShrinkFillSize(Vector3 childSize, Vector3 layoutSize, bool includesSizeOfParent = false); /// Sets the space a child should shrink or fill. void SetShrinkFillSize(int axis, float childSize, float layoutSize, bool includesSizeOfParent = false); /// Set the position result from a layout arrange step. void SetPositionResult(Vector3 position); /// Set the rotation result from a layout arrange step. void SetRotationResult(Quaternion quaternion); /// Constrains this node to the given target node. void SetConstraint(Constraint constraint, FlexalonNode target); /// Returns the constraint of this node. Constraint Constraint { get; } /// Returns the active adapter for this node. Adapter Adapter { get; } /// Overrides the default adapter for this node. void SetAdapter(Adapter adapter); /// Only applies rotation and scale changes to the node. Faster than marking it dirty. void ApplyScaleAndRotation(); /// Returns the set of modifiers that apply to layout results. IReadOnlyList Modifiers { get; } /// Adds a modifier to this node. void AddModifier(FlexalonModifier modifier); /// Removes a modifier from this node. void RemoveModifier(FlexalonModifier modifier); /// Event invoked when layout results change. event System.Action ResultChanged; /// True when this node is being dragged. bool IsDragging { get; set; } /// True when this node should not skipped when performing layout. bool SkipLayout { get; } } }