Browse Source

Add anchor and pivot to UIElement.

ninjastone 9 years ago
parent
commit
68f4657528

+ 2 - 0
Source/Urho3D/AngelScript/SceneAPI.cpp

@@ -50,6 +50,8 @@ static void RegisterSerializable(asIScriptEngine* engine)
     engine->RegisterEnumValue("AutoRemoveMode", "REMOVE_COMPONENT", REMOVE_COMPONENT);
     engine->RegisterEnumValue("AutoRemoveMode", "REMOVE_COMPONENT", REMOVE_COMPONENT);
     engine->RegisterEnumValue("AutoRemoveMode", "REMOVE_NODE", REMOVE_NODE);
     engine->RegisterEnumValue("AutoRemoveMode", "REMOVE_NODE", REMOVE_NODE);
 
 
+    engine->RegisterGlobalProperty("const uint AM_FILEREADONLY", (void*)&AM_FILEREADONLY);
+    
     RegisterSerializable<Serializable>(engine, "Serializable");
     RegisterSerializable<Serializable>(engine, "Serializable");
 }
 }
 
 

+ 2 - 0
Source/Urho3D/Core/Attribute.h

@@ -46,6 +46,8 @@ static const unsigned AM_NODEID = 0x10;
 static const unsigned AM_COMPONENTID = 0x20;
 static const unsigned AM_COMPONENTID = 0x20;
 /// Attribute is a node ID vector where first element is the amount of nodes.
 /// Attribute is a node ID vector where first element is the amount of nodes.
 static const unsigned AM_NODEIDVECTOR = 0x40;
 static const unsigned AM_NODEIDVECTOR = 0x40;
+/// Attribute is readonly.
+static const unsigned AM_FILEREADONLY= 0x81;
 
 
 class Serializable;
 class Serializable;
 
 

+ 3 - 3
Source/Urho3D/Scene/Serializable.cpp

@@ -316,7 +316,7 @@ bool Serializable::Save(Serializer& dest) const
     for (unsigned i = 0; i < attributes->Size(); ++i)
     for (unsigned i = 0; i < attributes->Size(); ++i)
     {
     {
         const AttributeInfo& attr = attributes->At(i);
         const AttributeInfo& attr = attributes->At(i);
-        if (!(attr.mode_ & AM_FILE))
+        if (!(attr.mode_ & AM_FILE) || (attr.mode_ & AM_FILEREADONLY))
             continue;
             continue;
 
 
         OnGetAttribute(attr, value);
         OnGetAttribute(attr, value);
@@ -521,7 +521,7 @@ bool Serializable::SaveXML(XMLElement& dest) const
     for (unsigned i = 0; i < attributes->Size(); ++i)
     for (unsigned i = 0; i < attributes->Size(); ++i)
     {
     {
         const AttributeInfo& attr = attributes->At(i);
         const AttributeInfo& attr = attributes->At(i);
-        if (!(attr.mode_ & AM_FILE))
+        if (!(attr.mode_ & AM_FILE) || attr.mode_ & AM_FILEREADONLY)
             continue;
             continue;
 
 
         OnGetAttribute(attr, value);
         OnGetAttribute(attr, value);
@@ -558,7 +558,7 @@ bool Serializable::SaveJSON(JSONValue& dest) const
     for (unsigned i = 0; i < attributes->Size(); ++i)
     for (unsigned i = 0; i < attributes->Size(); ++i)
     {
     {
         const AttributeInfo& attr = attributes->At(i);
         const AttributeInfo& attr = attributes->At(i);
-        if (!(attr.mode_ & AM_FILE))
+        if (!(attr.mode_ & AM_FILE) || attr.mode_ & AM_FILEREADONLY)
             continue;
             continue;
 
 
         OnGetAttribute(attr, value);
         OnGetAttribute(attr, value);

+ 193 - 39
Source/Urho3D/UI/UIElement.cpp

@@ -44,6 +44,7 @@ const char* horizontalAlignments[] =
     "Left",
     "Left",
     "Center",
     "Center",
     "Right",
     "Right",
+    "Custom",
     0
     0
 };
 };
 
 
@@ -52,6 +53,7 @@ const char* verticalAlignments[] =
     "Top",
     "Top",
     "Center",
     "Center",
     "Bottom",
     "Bottom",
+    "Custom",
     0
     0
 };
 };
 
 
@@ -124,15 +126,18 @@ UIElement::UIElement(Context* context) :
     minSize_(IntVector2::ZERO),
     minSize_(IntVector2::ZERO),
     maxSize_(M_MAX_INT, M_MAX_INT),
     maxSize_(M_MAX_INT, M_MAX_INT),
     childOffset_(IntVector2::ZERO),
     childOffset_(IntVector2::ZERO),
-    horizontalAlignment_(HA_LEFT),
-    verticalAlignment_(VA_TOP),
     opacity_(1.0f),
     opacity_(1.0f),
     opacityDirty_(true),
     opacityDirty_(true),
     derivedColorDirty_(true),
     derivedColorDirty_(true),
     sortOrderDirty_(false),
     sortOrderDirty_(false),
     colorGradient_(false),
     colorGradient_(false),
     traversalMode_(TM_BREADTH_FIRST),
     traversalMode_(TM_BREADTH_FIRST),
-    elementEventSender_(false)
+    elementEventSender_(false),
+    maxOffset_(IntVector2::ZERO),
+    anchorMin_(0, 0),
+    anchorMax_(0, 0),
+    pivot_(0, 0),
+    recalcMaxOffset_(false)
 {
 {
     SetEnabled(false);
     SetEnabled(false);
 }
 }
@@ -153,13 +158,18 @@ void UIElement::RegisterObject(Context* context)
 
 
     URHO3D_ACCESSOR_ATTRIBUTE("Name", GetName, SetName, String, String::EMPTY, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Name", GetName, SetName, String, String::EMPTY, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Position", GetPosition, SetPosition, IntVector2, IntVector2::ZERO, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Position", GetPosition, SetPosition, IntVector2, IntVector2::ZERO, AM_FILE);
-    URHO3D_ACCESSOR_ATTRIBUTE("Size", GetSize, SetSize, IntVector2, IntVector2::ZERO, AM_FILE);
+    URHO3D_ACCESSOR_ATTRIBUTE("Size", GetSize, SetSize, IntVector2, IntVector2::ZERO, AM_FILEREADONLY);
+    URHO3D_ACCESSOR_ATTRIBUTE("Min Offset", GetPosition, SetMinOffset, IntVector2, IntVector2::ZERO, AM_EDIT);
+    URHO3D_ACCESSOR_ATTRIBUTE("Max Offset", GetMaxOffset, SetMaxOffset, IntVector2, IntVector2::ZERO, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Min Size", GetMinSize, SetMinSize, IntVector2, IntVector2::ZERO, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Min Size", GetMinSize, SetMinSize, IntVector2, IntVector2::ZERO, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Max Size", GetMaxSize, SetMaxSize, IntVector2, IntVector2(M_MAX_INT, M_MAX_INT), AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Max Size", GetMaxSize, SetMaxSize, IntVector2, IntVector2(M_MAX_INT, M_MAX_INT), AM_FILE);
     URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Horiz Alignment", GetHorizontalAlignment, SetHorizontalAlignment, HorizontalAlignment,
     URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Horiz Alignment", GetHorizontalAlignment, SetHorizontalAlignment, HorizontalAlignment,
-        horizontalAlignments, HA_LEFT, AM_FILE);
+        horizontalAlignments, HA_LEFT, AM_FILEREADONLY);
     URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Vert Alignment", GetVerticalAlignment, SetVerticalAlignment, VerticalAlignment, verticalAlignments,
     URHO3D_ENUM_ACCESSOR_ATTRIBUTE("Vert Alignment", GetVerticalAlignment, SetVerticalAlignment, VerticalAlignment, verticalAlignments,
-        VA_TOP, AM_FILE);
+        VA_TOP, AM_FILEREADONLY);
+    URHO3D_ACCESSOR_ATTRIBUTE("Min Anchor", GetMinAnchor, SetMinAnchor, Vector2, Vector2::ZERO, AM_FILE);
+    URHO3D_ACCESSOR_ATTRIBUTE("Max Anchor", GetMaxAnchor, SetMaxAnchor, Vector2, Vector2::ZERO, AM_FILE);
+    URHO3D_ACCESSOR_ATTRIBUTE("Pivot", GetPivot, SetPivot, Vector2, Vector2::ZERO, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Clip Border", GetClipBorder, SetClipBorder, IntRect, IntRect::ZERO, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Clip Border", GetClipBorder, SetClipBorder, IntRect, IntRect::ZERO, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Priority", GetPriority, SetPriority, int, 0, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Priority", GetPriority, SetPriority, int, 0, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Opacity", GetOpacity, SetOpacity, float, 1.0f, AM_FILE);
     URHO3D_ACCESSOR_ATTRIBUTE("Opacity", GetOpacity, SetOpacity, float, 1.0f, AM_FILE);
@@ -432,34 +442,10 @@ const IntVector2& UIElement::GetScreenPosition() const
         {
         {
             const IntVector2& parentScreenPos = parent->GetScreenPosition();
             const IntVector2& parentScreenPos = parent->GetScreenPosition();
 
 
-            switch (horizontalAlignment_)
-            {
-            case HA_LEFT:
-                pos.x_ += parentScreenPos.x_;
-                break;
-
-            case HA_CENTER:
-                pos.x_ += parentScreenPos.x_ + parent_->size_.x_ / 2 - size_.x_ / 2;
-                break;
-
-            case HA_RIGHT:
-                pos.x_ += parentScreenPos.x_ + parent_->size_.x_ - size_.x_;
-                break;
-            }
-            switch (verticalAlignment_)
-            {
-            case VA_TOP:
-                pos.y_ += parentScreenPos.y_;
-                break;
-
-            case VA_CENTER:
-                pos.y_ += parentScreenPos.y_ + parent_->size_.y_ / 2 - size_.y_ / 2;
-                break;
-
-            case VA_BOTTOM:
-                pos.y_ += parentScreenPos.y_ + parent_->size_.y_ - size_.y_;
-                break;
-            }
+            pos.x_ += parentScreenPos.x_ + (int)Lerp(0.0f, (float)parent->size_.x_, anchorMin_.x_);
+            pos.y_ += parentScreenPos.y_ + (int)Lerp(0.0f, (float)parent->size_.y_, anchorMin_.y_);
+            pos.x_ -= (int)(size_.x_ * pivot_.x_);
+            pos.y_ -= (int)(size_.y_ * pivot_.y_);
 
 
             pos += parent_->childOffset_;
             pos += parent_->childOffset_;
         }
         }
@@ -579,6 +565,7 @@ void UIElement::SetPosition(const IntVector2& position)
 {
 {
     if (position != position_)
     if (position != position_)
     {
     {
+        maxOffset_ += position - position_;
         position_ = position;
         position_ = position;
         OnPositionSet(position);
         OnPositionSet(position);
         MarkDirty();
         MarkDirty();
@@ -598,6 +585,73 @@ void UIElement::SetPosition(int x, int y)
     SetPosition(IntVector2(x, y));
     SetPosition(IntVector2(x, y));
 }
 }
 
 
+void UIElement::SetMinOffset(const IntVector2& position)
+{
+    if (position != position_)
+    {
+        position_ = position;
+        AdjustAnchoredSize();
+        OnPositionSet();
+        MarkDirty();
+
+        using namespace Positioned;
+
+        VariantMap& eventData = GetEventDataMap();
+        eventData[P_ELEMENT] = this;
+        eventData[P_X] = position_.x_;
+        eventData[P_Y] = position_.y_;
+        SendEvent(E_POSITIONED, eventData);
+    }
+}
+
+void UIElement::AdjustMaxOffset()
+{
+    if (parent_)
+    {
+        maxOffset_.x_ = anchorMin_.x_ * parent_->size_.x_ + size_.x_ + position_.x_ - anchorMax_.x_ * parent_->size_.x_;
+        maxOffset_.y_ = anchorMin_.y_ * parent_->size_.y_ + size_.y_ + position_.y_ - anchorMax_.y_ * parent_->size_.y_;
+    }
+    else
+    {
+        maxOffset_ = size_;
+    }
+}
+
+void UIElement::SetMaxOffset(const IntVector2& offset)
+{
+    if (maxOffset_ != offset)
+    {
+        maxOffset_ = offset;
+        AdjustAnchoredSize();
+        MarkDirty();
+    }
+}
+
+void UIElement::AdjustAnchoredSize()
+{
+    IntVector2 newSize = size_;
+
+    if (parent_)
+    {
+        if (anchorMin_.x_ < anchorMax_.x_)
+        {
+            newSize.x_ = (int)(parent_->size_.x_ * (anchorMax_.x_ - anchorMin_.x_)) + maxOffset_.x_ - position_.x_;
+        }
+
+        if (anchorMin_.y_ < anchorMax_.y_)
+        {
+            newSize.y_ = (int)(parent_->size_.y_ * (anchorMax_.y_ - anchorMin_.y_)) + maxOffset_.y_ - position_.y_;
+        }
+
+        if (size_ != newSize)
+        {
+            recalcMaxOffset_ = false;
+            SetSize(newSize);
+            recalcMaxOffset_ = true;
+        }
+    }
+}
+
 void UIElement::SetSize(const IntVector2& size)
 void UIElement::SetSize(const IntVector2& size)
 {
 {
     ++resizeNestingLevel_;
     ++resizeNestingLevel_;
@@ -612,6 +666,11 @@ void UIElement::SetSize(const IntVector2& size)
     {
     {
         size_ = validatedSize;
         size_ = validatedSize;
 
 
+        if (recalcMaxOffset_)
+        {
+            AdjustMaxOffset();
+        }
+
         if (resizeNestingLevel_ == 1)
         if (resizeNestingLevel_ == 1)
         {
         {
             // Check if parent element's layout needs to be updated first
             // Check if parent element's layout needs to be updated first
@@ -734,9 +793,31 @@ void UIElement::SetHorizontalAlignment(HorizontalAlignment align)
         align = HA_LEFT;
         align = HA_LEFT;
     }
     }
 
 
-    if (horizontalAlignment_ != align)
+    Vector2 min = anchorMin_;
+    Vector2 max = anchorMax_;
+    float pivot = pivot_.x_;
+
+    if (align == HA_CENTER)
     {
     {
-        horizontalAlignment_ = align;
+        min.x_ = max.x_ = 0.5f;
+        pivot = 0.5f;
+    }
+    else if (align == HA_LEFT)
+    {
+        min.x_ = max.x_ = 0.0f;
+        pivot = 0.0f;
+    }
+    else if (align == HA_RIGHT)
+    {
+        min.x_ = max.x_ = 1.0f;
+        pivot = 1.0f;
+    }
+
+    if (min.x_ != anchorMin_.x_ || max.x_ != anchorMax_.x_ || pivot != pivot_.x_)
+    {
+        anchorMin_.x_ = min.x_;
+        anchorMax_.x_ = max.x_;
+        pivot_.x_ = pivot;
         MarkDirty();
         MarkDirty();
     }
     }
 }
 }
@@ -749,13 +830,79 @@ void UIElement::SetVerticalAlignment(VerticalAlignment align)
         align = VA_TOP;
         align = VA_TOP;
     }
     }
 
 
-    if (verticalAlignment_ != align)
+    Vector2 min = anchorMin_;
+    Vector2 max = anchorMax_;
+    float pivot = pivot_.y_;
+
+    if (align == VA_CENTER)
+    {
+        min.y_ = max.y_ = 0.5f;
+        pivot = 0.5f;
+    }
+    else if (align == VA_TOP)
+    {
+        min.y_ = max.y_ = 0.0f;
+        pivot = 0.0f;
+    }
+    else if (align == VA_BOTTOM)
+    {
+        min.y_ = max.y_ = 1.0f;
+        pivot = 1.0f;
+    }
+
+    if (min.y_ != anchorMin_.y_ || max.y_ != anchorMax_.y_ || pivot != pivot_.y_)
+    {
+        anchorMin_.y_ = min.y_;
+        anchorMax_.y_ = max.y_;
+        pivot_.y_ = pivot;
+        MarkDirty();
+    }
+}
+
+void UIElement::SetMinAnchor(const Vector2& anchor)
+{
+    if (anchor != anchorMin_)
+    {
+        anchorMin_ = anchor;
+        MarkDirty();
+        AdjustAnchoredSize();
+    }
+}
+
+void UIElement::SetMinAnchor(float x, float y)
+{
+    SetMinAnchor(Vector2(x, y));
+}
+
+void UIElement::SetMaxAnchor(const Vector2& anchor)
+{
+    if (anchor != anchorMax_)
+    {
+        anchorMax_ = anchor;
+        MarkDirty();
+        AdjustAnchoredSize();
+    }
+}
+
+void UIElement::SetMaxAnchor(float x, float y)
+{
+    SetMaxAnchor(Vector2(x, y));
+}
+
+void UIElement::SetPivot(const Vector2& pivot)
+{
+    if (pivot != pivot_)
     {
     {
-        verticalAlignment_ = align;
+        pivot_ = pivot;
         MarkDirty();
         MarkDirty();
     }
     }
 }
 }
 
 
+void UIElement::SetPivot(float x, float y)
+{
+    SetPivot(Vector2(x, y));
+}
+
 void UIElement::SetClipBorder(const IntRect& rect)
 void UIElement::SetClipBorder(const IntRect& rect)
 {
 {
     clipBorder_.left_ = Max(rect.left_, 0);
     clipBorder_.left_ = Max(rect.left_, 0);
@@ -1036,7 +1183,7 @@ void UIElement::SetIndentSpacing(int indentSpacing)
 
 
 void UIElement::UpdateLayout()
 void UIElement::UpdateLayout()
 {
 {
-    if (layoutMode_ == LM_FREE || layoutNestingLevel_)
+    if (layoutNestingLevel_)
         return;
         return;
 
 
     // Prevent further updates while this update happens
     // Prevent further updates while this update happens
@@ -1128,6 +1275,13 @@ void UIElement::UpdateLayout()
             ++j;
             ++j;
         }
         }
     }
     }
+    else
+    {
+        for (unsigned i = 0; i < children_.Size(); ++i)
+        {
+            children_[i]->AdjustAnchoredSize();
+        }
+    }
 
 
     using namespace LayoutUpdated;
     using namespace LayoutUpdated;
 
 

+ 78 - 8
Source/Urho3D/UI/UIElement.h

@@ -35,7 +35,8 @@ enum HorizontalAlignment
 {
 {
     HA_LEFT = 0,
     HA_LEFT = 0,
     HA_CENTER,
     HA_CENTER,
-    HA_RIGHT
+    HA_RIGHT,
+    HA_CUSTOM
 };
 };
 
 
 /// %UI element vertical alignment.
 /// %UI element vertical alignment.
@@ -43,7 +44,8 @@ enum VerticalAlignment
 {
 {
     VA_TOP = 0,
     VA_TOP = 0,
     VA_CENTER,
     VA_CENTER,
-    VA_BOTTOM
+    VA_BOTTOM,
+    VA_CUSTOM
 };
 };
 
 
 /// %UI element corners.
 /// %UI element corners.
@@ -246,6 +248,22 @@ public:
     void SetHorizontalAlignment(HorizontalAlignment align);
     void SetHorizontalAlignment(HorizontalAlignment align);
     /// Set vertical alignment.
     /// Set vertical alignment.
     void SetVerticalAlignment(VerticalAlignment align);
     void SetVerticalAlignment(VerticalAlignment align);
+    /// Set minimum offset.
+    void SetMinOffset(const IntVector2& offset);
+    /// Set maximum offset.
+    void SetMaxOffset(const IntVector2& offset);
+    /// Set minimum anchor.
+    void SetMinAnchor(const Vector2& anchor);
+    /// Set minimum anchor.
+    void SetMinAnchor(float x, float y);
+    /// Set maximum anchor.
+    void SetMaxAnchor(const Vector2& anchor);
+    /// Set maximum anchor.
+    void SetMaxAnchor(float x, float y);
+    /// Set pivot.
+    void SetPivot(const Vector2& pivot);
+    /// Set pivot.
+    void SetPivot(float x, float y);
     /// Set child element clipping border.
     /// Set child element clipping border.
     void SetClipBorder(const IntRect& rect);
     void SetClipBorder(const IntRect& rect);
     /// Set color on all corners.
     /// Set color on all corners.
@@ -417,10 +435,52 @@ public:
     const IntVector2& GetChildOffset() const { return childOffset_; }
     const IntVector2& GetChildOffset() const { return childOffset_; }
 
 
     /// Return horizontal alignment.
     /// Return horizontal alignment.
-    HorizontalAlignment GetHorizontalAlignment() const { return horizontalAlignment_; }
+    HorizontalAlignment GetHorizontalAlignment() const 
+    {
+        if (anchorMin_.x_ == 0.0f && anchorMax_.x_ == 0.0f)
+        {
+            return HA_LEFT;
+        }
+        else if (anchorMin_.x_ == 0.5f && anchorMax_.x_ == 0.5f)
+        {
+            return HA_CENTER;
+        }
+        else if (anchorMin_.x_ == 1.0f && anchorMax_.x_ == 1.0f)
+        {
+            return HA_RIGHT;
+        }
+        return HA_CUSTOM;
+    }
 
 
     /// Return vertical alignment.
     /// Return vertical alignment.
-    VerticalAlignment GetVerticalAlignment() const { return verticalAlignment_; }
+    VerticalAlignment GetVerticalAlignment() const 
+    {
+        if (anchorMin_.y_ == 0.0f && anchorMax_.y_ == 0.0f)
+        {
+            return VA_TOP;
+        }
+        else if (anchorMin_.y_ == 0.5f && anchorMax_.y_ == 0.5f)
+        {
+            return VA_CENTER;
+        }
+        else if (anchorMin_.y_ == 1.0f && anchorMax_.y_ == 1.0f)
+        {
+            return VA_BOTTOM;
+        }
+        return VA_CUSTOM;
+    }
+
+    /// Return minimum anchor.
+    const Vector2& GetMinAnchor() const { return anchorMin_; }
+
+    /// Return maximum anchor.
+    const Vector2& GetMaxAnchor() const { return anchorMax_; }
+
+    // Return maximum offset.
+    const IntVector2& GetMaxOffset() const { return maxOffset_; }
+
+    /// Return pivot.
+    const Vector2& GetPivot() const { return pivot_; }
 
 
     /// Return child element clipping border.
     /// Return child element clipping border.
     const IntRect& GetClipBorder() const { return clipBorder_; }
     const IntRect& GetClipBorder() const { return clipBorder_; }
@@ -610,6 +670,10 @@ protected:
     bool FilterUIStyleAttributes(XMLElement& dest, const XMLElement& styleElem) const;
     bool FilterUIStyleAttributes(XMLElement& dest, const XMLElement& styleElem) const;
     /// Filter implicit attributes in serialization process.
     /// Filter implicit attributes in serialization process.
     virtual bool FilterImplicitAttributes(XMLElement& dest) const;
     virtual bool FilterImplicitAttributes(XMLElement& dest) const;
+    /// Recalculates maxOffset.
+    void AdjustMaxOffset();
+    /// Adjust size using anchor.
+    void AdjustAnchoredSize();
 
 
     /// Name.
     /// Name.
     String name_;
     String name_;
@@ -649,6 +713,8 @@ protected:
     bool hovering_;
     bool hovering_;
     /// Internally created flag.
     /// Internally created flag.
     bool internal_;
     bool internal_;
+    /// Recalculate maxOffset from size.
+    bool recalcMaxOffset_;
     /// Focus mode.
     /// Focus mode.
     FocusMode focusMode_;
     FocusMode focusMode_;
     /// Drag and drop flags.
     /// Drag and drop flags.
@@ -716,10 +782,14 @@ private:
     IntVector2 childOffset_;
     IntVector2 childOffset_;
     /// Parent's minimum size calculated by layout. Used internally.
     /// Parent's minimum size calculated by layout. Used internally.
     IntVector2 layoutMinSize_;
     IntVector2 layoutMinSize_;
-    /// Horizontal alignment.
-    HorizontalAlignment horizontalAlignment_;
-    /// Vertical alignment.
-    VerticalAlignment verticalAlignment_;
+    /// Relative size.
+    IntVector2 maxOffset_;
+    /// Anchor Minimum Position
+    Vector2 anchorMin_;
+    /// Anchor Maximum Position
+    Vector2 anchorMax_;
+    /// Pivot Position
+    Vector2 pivot_;
     /// Opacity.
     /// Opacity.
     float opacity_;
     float opacity_;
     /// Derived opacity.
     /// Derived opacity.