// 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)
if (n > pivotStack.Length)
{
- if (mainAxis.point != CellUndefined)
+ if (mainAxis.point != AutoColumn && mainAxis.point != AutoRow)
mainPivot = mainAxis.point;
else
mainPivot = 0;
/// 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
/// 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
[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;
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);
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);