[NUI] change Column, Row default value from -1 to AutoColumn, AutoRow (#2180)
authorYeongJong Lee <cleanlyj@naver.com>
Thu, 19 Nov 2020 02:41:09 +0000 (11:41 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 19 Nov 2020 09:36:46 +0000 (18:36 +0900)
ArgumentException will be thrown when column,row is a negative value
other than AutoColumn/AutoRow.

src/Tizen.NUI/src/internal/Layouting/GridLocations.cs
src/Tizen.NUI/src/public/Layouting/GridLayout.cs

index 8f45302..4cf885f 100755 (executable)
@@ -214,14 +214,14 @@ namespace Tizen.NUI
 
                 // assign column/row depending on GridOrientation. The main axis count(Columns on Horizontal, Rows otherwise) won't be exceeded
                 // explicit column(row) count which is assigned by Columns(Rows). but, cross axis count(Rows(Columns)) can be increased by sub axis count.
-                if (column == CellUndefined || row == CellUndefined)
+                if (column == AutoColumn || row == AutoRow)
                 {
                     (int point, int span) mainAxis = isHorizontal ? (column, columnSpan) : (row, rowSpan);
                     (int point, int span) subAxis = isHorizontal ? (row, rowSpan) : (column, columnSpan);
 
-                    if (subAxis.point != CellUndefined)
+                    if (subAxis.point != AutoColumn && subAxis.point != AutoRow)
                         subPivot = subAxis.point;
-                    if (mainAxis.point != CellUndefined)
+                    if (mainAxis.point != AutoColumn && mainAxis.point != AutoRow)
                         mainPivot = mainAxis.point;
 
                     if (mainPivot + mainAxis.span > pivotStack.Length)
@@ -239,7 +239,7 @@ namespace Tizen.NUI
 
                             if (n > pivotStack.Length)
                             {
-                                if (mainAxis.point != CellUndefined)
+                                if (mainAxis.point != AutoColumn && mainAxis.point != AutoRow)
                                     mainPivot = mainAxis.point;
                                 else
                                     mainPivot = 0;
index 04f639e..2fad169 100755 (executable)
@@ -30,7 +30,7 @@ namespace Tizen.NUI
         /// ColumnProperty
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public static readonly BindableProperty ColumnProperty = BindableProperty.CreateAttached("Column", typeof(int), typeof(GridLayout), CellUndefined, validateValue: (bindable, value) => (int)value >= 0, propertyChanged: OnChildPropertyChanged);
+        public static readonly BindableProperty ColumnProperty = BindableProperty.CreateAttached("Column", typeof(int), typeof(GridLayout), AutoColumn, validateValue: (bindable, value) => (int)value >= 0 || (int)value == AutoColumn, propertyChanged: OnChildPropertyChanged);
 
         /// <summary>
         /// ColumnSpanProperty
@@ -42,7 +42,7 @@ namespace Tizen.NUI
         /// RowProperty
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public static readonly BindableProperty RowProperty = BindableProperty.CreateAttached("Row", typeof(int), typeof(GridLayout), CellUndefined, validateValue: (bindable, value) => (int)value >= 0, propertyChanged: OnChildPropertyChanged);
+        public static readonly BindableProperty RowProperty = BindableProperty.CreateAttached("Row", typeof(int), typeof(GridLayout), AutoRow, validateValue: (bindable, value) => (int)value >= 0 || (int)value == AutoRow, propertyChanged: OnChildPropertyChanged);
 
         /// <summary>
         /// RowSpanProperty
@@ -74,7 +74,12 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly BindableProperty VerticalAlignmentProperty = BindableProperty.CreateAttached("VerticalAlignment", typeof(Alignment), typeof(GridLayout), Alignment.Start, validateValue: ValidateEnum((int)Alignment.Start, (int)Alignment.End), propertyChanged: OnChildPropertyChanged);
 
-        private const int CellUndefined = -1;
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public const int AutoColumn = int.MinValue;
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public const int AutoRow = int.MinValue;
+
         private Orientation gridOrientation = Orientation.Horizontal;
         private int columns = 1;
         private int rows = 1;
@@ -170,12 +175,13 @@ namespace Tizen.NUI
         public static Alignment GetVerticalAlignment(View view) => GetAttachedValue<Alignment>(view, VerticalAlignmentProperty);
 
         /// <summary>
-        /// Sets the column index the child occupies. the default value is -1.
+        /// Sets the column index the child occupies. A default column is <see cref="AutoColumn"/>.<br/>
+        /// If column is a <see cref="AutoColumn"/>, child will be automatically laid out depending on <see cref="GridOrientation"/>.
         /// </summary>
         /// <param name="view">The child view.</param>
         /// <param name="value">The column index of <paramref name="view"/>.</param>
         /// <exception cref="ArgumentNullException">The <paramref name="view"/> cannot be null.</exception>
-        /// <exception cref="ArgumentException">The <paramref name="value"/> cannot be less than 0.</exception>
+        /// <exception cref="ArgumentException">The <paramref name="value"/> cannot be a negative value other than <see cref="AutoColumn"/>.</exception>
         /// <since_tizen> 8 </since_tizen>
         public static void SetColumn(View view, int value) => SetAttachedValue(view, ColumnProperty, value);
 
@@ -190,12 +196,13 @@ namespace Tizen.NUI
         public static void SetColumnSpan(View view, int value) => SetAttachedValue(view, ColumnSpanProperty, value);
 
         /// <summary>
-        /// Sets the row index the child occupies. the default value is -1.
+        /// Sets the row index the child occupies. A default row index is <see cref="AutoRow"/>.<br/>
+        /// If row is a <see cref="AutoRow"/>, child will be automatically laid out depending on <see cref="GridOrientation"/>.
         /// </summary>
         /// <param name="view">The child view.</param>
         /// <param name="value">The row index of <paramref name="view"/>.</param>
         /// <exception cref="ArgumentNullException">The <paramref name="view"/> cannot be null.</exception>
-        /// <exception cref="ArgumentException">The <paramref name="value"/> cannot be less than 0.</exception>
+        /// <exception cref="ArgumentException">The <paramref name="value"/> cannot be a negative value other than <see cref="AutoRow"/>.</exception>
         /// <since_tizen> 8 </since_tizen>
         public static void SetRow(View view, int value) => SetAttachedValue(view, RowProperty, value);