Browse Source

Update documentation on UI element anchoring.

Lasse Öörni 9 years ago
parent
commit
ab5cdf9da7

+ 4 - 0
Docs/Reference.dox

@@ -2181,6 +2181,10 @@ Left, top, right & bottom border widths and spacing between elements can also be
 
 
 Use the functions \ref UIElement::SetLayout "SetLayout()" or \ref UIElement::SetLayoutMode "SetLayoutMode()" to control the layouting.
 Use the functions \ref UIElement::SetLayout "SetLayout()" or \ref UIElement::SetLayoutMode "SetLayoutMode()" to control the layouting.
 
 
+\section UI_Anchoring Child element anchoring
+
+A separate mechanism from layouting that allows automatically adjusting %UI hierarchies is to use anchoring. First enable anchoring in a child element with \ref UIElement::SetEnableAnchor "SetEnableAnchor()", after which the top-left and bottom-right corners in relation to the parent's size (range 0-1) can be set with \ref UIElement::SetMinAnchor "SetMinAnchor()" and \ref UIElement::SetMaxAnchor "SetMaxAnchor()". The corners can further be offset in pixels by calling \ref UIElement::SetMinOffset "SetMinOffset()" and \ref UIElement::SetMaxOffset "SetMaxOffset()". Finally note that instead of just setting horizontal / vertical alignment, the child element's pivot can also be expressed in a 0-1 range relative to its size by calling \ref UIElement::SetPivot "SetPivot()".
+
 \section UI_Fonts Fonts
 \section UI_Fonts Fonts
 
 
 Urho3D supports both FreeType (.ttf, .otf) and \ref http://www.angelcode.com/products/bmfont/ "bitmap" fonts.
 Urho3D supports both FreeType (.ttf, .otf) and \ref http://www.angelcode.com/products/bmfont/ "bitmap" fonts.

+ 4 - 2
Source/Urho3D/LuaScript/pkgs/UI/UIElement.pkg

@@ -5,14 +5,16 @@ enum HorizontalAlignment
 {
 {
     HA_LEFT = 0,
     HA_LEFT = 0,
     HA_CENTER,
     HA_CENTER,
-    HA_RIGHT
+    HA_RIGHT,
+    HA_CUSTOM
 };
 };
 
 
 enum VerticalAlignment
 enum VerticalAlignment
 {
 {
     VA_TOP = 0,
     VA_TOP = 0,
     VA_CENTER,
     VA_CENTER,
-    VA_BOTTOM
+    VA_BOTTOM,
+    VA_CUSTOM
 };
 };
 
 
 enum Corner
 enum Corner

+ 3 - 3
Source/Urho3D/UI/UIElement.h

@@ -248,7 +248,7 @@ public:
     void SetHorizontalAlignment(HorizontalAlignment align);
     void SetHorizontalAlignment(HorizontalAlignment align);
     /// Set vertical alignment.
     /// Set vertical alignment.
     void SetVerticalAlignment(VerticalAlignment align);
     void SetVerticalAlignment(VerticalAlignment align);
-    /// Enable anchor positioning & sizing of element using min/max anchor and min/max offset. Default false.
+    /// Enable automatic positioning & sizing of the element relative to its parent using min/max anchor and min/max offset. Default false.
     void SetEnableAnchor(bool enable);
     void SetEnableAnchor(bool enable);
     /// Set minimum (top left) anchor in relation to the parent element (from 0 to 1.) No effect when anchor is not enabled.
     /// Set minimum (top left) anchor in relation to the parent element (from 0 to 1.) No effect when anchor is not enabled.
     void SetMinAnchor(const Vector2& anchor);
     void SetMinAnchor(const Vector2& anchor);
@@ -436,10 +436,10 @@ public:
     /// Return child element offset.
     /// Return child element offset.
     const IntVector2& GetChildOffset() const { return childOffset_; }
     const IntVector2& GetChildOffset() const { return childOffset_; }
 
 
-    /// Return horizontal alignment.
+    /// Return horizontal alignment. If pivot has been adjusted to a custom horizontal setting, returns HA_CUSTOM.
     HorizontalAlignment GetHorizontalAlignment() const;
     HorizontalAlignment GetHorizontalAlignment() const;
 
 
-    /// Return vertical alignment.
+    /// Return vertical alignment. If pivot has been adjusted to a custom vertical setting, returns VA_CUSTOM.
     VerticalAlignment GetVerticalAlignment() const;
     VerticalAlignment GetVerticalAlignment() const;
 
 
     /// Return whether anchor positioning & sizing is enabled.
     /// Return whether anchor positioning & sizing is enabled.