completed the branch
This commit is contained in:
1 parent
0cc7c097da
commit
d07e1a3d87
1 file changed
+147
-50
@@ -6,6 +6,7 @@ using System.Windows.Media;
|
|||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
using HandyControl.Expression.Drawing;
|
using HandyControl.Expression.Drawing;
|
||||||
using HandyControl.Tools;
|
using HandyControl.Tools;
|
||||||
|
using HandyControl.Tools.Extension;
|
||||||
|
|
||||||
namespace HandyControl.Controls
|
namespace HandyControl.Controls
|
||||||
{
|
{
|
||||||
@@ -20,7 +21,8 @@ namespace HandyControl.Controls
|
|||||||
#region Item
|
#region Item
|
||||||
|
|
||||||
public static readonly DependencyProperty OrderProperty = DependencyProperty.RegisterAttached(
|
public static readonly DependencyProperty OrderProperty = DependencyProperty.RegisterAttached(
|
||||||
"Order", typeof(int), typeof(FlexPanel), new FrameworkPropertyMetadata(ValueBoxes.Int0Box, OnItemPropertyChanged));
|
"Order", typeof(int), typeof(FlexPanel),
|
||||||
|
new FrameworkPropertyMetadata(ValueBoxes.Int0Box, OnItemPropertyChanged));
|
||||||
|
|
||||||
public static void SetOrder(DependencyObject element, int value)
|
public static void SetOrder(DependencyObject element, int value)
|
||||||
=> element.SetValue(OrderProperty, value);
|
=> element.SetValue(OrderProperty, value);
|
||||||
@@ -29,7 +31,9 @@ namespace HandyControl.Controls
|
|||||||
=> (int)element.GetValue(OrderProperty);
|
=> (int)element.GetValue(OrderProperty);
|
||||||
|
|
||||||
public static readonly DependencyProperty FlexGrowProperty = DependencyProperty.RegisterAttached(
|
public static readonly DependencyProperty FlexGrowProperty = DependencyProperty.RegisterAttached(
|
||||||
"FlexGrow", typeof(double), typeof(FlexPanel), new FrameworkPropertyMetadata(ValueBoxes.Double0Box, OnItemPropertyChanged), ValidateHelper.IsInRangeOfPosDoubleIncludeZero);
|
"FlexGrow", typeof(double), typeof(FlexPanel),
|
||||||
|
new FrameworkPropertyMetadata(ValueBoxes.Double0Box, OnItemPropertyChanged),
|
||||||
|
ValidateHelper.IsInRangeOfPosDoubleIncludeZero);
|
||||||
|
|
||||||
public static void SetFlexGrow(DependencyObject element, double value)
|
public static void SetFlexGrow(DependencyObject element, double value)
|
||||||
=> element.SetValue(FlexGrowProperty, value);
|
=> element.SetValue(FlexGrowProperty, value);
|
||||||
@@ -38,7 +42,9 @@ namespace HandyControl.Controls
|
|||||||
=> (double)element.GetValue(FlexGrowProperty);
|
=> (double)element.GetValue(FlexGrowProperty);
|
||||||
|
|
||||||
public static readonly DependencyProperty FlexShrinkProperty = DependencyProperty.RegisterAttached(
|
public static readonly DependencyProperty FlexShrinkProperty = DependencyProperty.RegisterAttached(
|
||||||
"FlexShrink", typeof(double), typeof(FlexPanel), new FrameworkPropertyMetadata(ValueBoxes.Double1Box, OnItemPropertyChanged));
|
"FlexShrink", typeof(double), typeof(FlexPanel),
|
||||||
|
new FrameworkPropertyMetadata(ValueBoxes.Double1Box, OnItemPropertyChanged),
|
||||||
|
ValidateHelper.IsInRangeOfPosDoubleIncludeZero);
|
||||||
|
|
||||||
public static void SetFlexShrink(DependencyObject element, double value)
|
public static void SetFlexShrink(DependencyObject element, double value)
|
||||||
=> element.SetValue(FlexShrinkProperty, value);
|
=> element.SetValue(FlexShrinkProperty, value);
|
||||||
@@ -47,7 +53,8 @@ namespace HandyControl.Controls
|
|||||||
=> (double)element.GetValue(FlexShrinkProperty);
|
=> (double)element.GetValue(FlexShrinkProperty);
|
||||||
|
|
||||||
public static readonly DependencyProperty FlexBasisProperty = DependencyProperty.RegisterAttached(
|
public static readonly DependencyProperty FlexBasisProperty = DependencyProperty.RegisterAttached(
|
||||||
"FlexBasis", typeof(double), typeof(FlexPanel), new FrameworkPropertyMetadata(double.NaN, OnItemPropertyChanged));
|
"FlexBasis", typeof(double), typeof(FlexPanel),
|
||||||
|
new FrameworkPropertyMetadata(double.NaN, OnItemPropertyChanged));
|
||||||
|
|
||||||
public static void SetFlexBasis(DependencyObject element, double value)
|
public static void SetFlexBasis(DependencyObject element, double value)
|
||||||
=> element.SetValue(FlexBasisProperty, value);
|
=> element.SetValue(FlexBasisProperty, value);
|
||||||
@@ -56,7 +63,8 @@ namespace HandyControl.Controls
|
|||||||
=> (double)element.GetValue(FlexBasisProperty);
|
=> (double)element.GetValue(FlexBasisProperty);
|
||||||
|
|
||||||
public static readonly DependencyProperty AlignSelfProperty = DependencyProperty.RegisterAttached(
|
public static readonly DependencyProperty AlignSelfProperty = DependencyProperty.RegisterAttached(
|
||||||
"AlignSelf", typeof(FlexItemAlignment), typeof(FlexPanel), new FrameworkPropertyMetadata(default(FlexItemAlignment), OnItemPropertyChanged));
|
"AlignSelf", typeof(FlexItemAlignment), typeof(FlexPanel),
|
||||||
|
new FrameworkPropertyMetadata(default(FlexItemAlignment), OnItemPropertyChanged));
|
||||||
|
|
||||||
public static void SetAlignSelf(DependencyObject element, FlexItemAlignment value)
|
public static void SetAlignSelf(DependencyObject element, FlexItemAlignment value)
|
||||||
=> element.SetValue(AlignSelfProperty, value);
|
=> element.SetValue(AlignSelfProperty, value);
|
||||||
@@ -69,7 +77,8 @@ namespace HandyControl.Controls
|
|||||||
=> (FlexItemAlignment)element.GetValue(AlignSelfProperty);
|
=> (FlexItemAlignment)element.GetValue(AlignSelfProperty);
|
||||||
|
|
||||||
public static readonly DependencyProperty FlexDirectionProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty FlexDirectionProperty = DependencyProperty.Register(
|
||||||
"FlexDirection", typeof(FlexDirection), typeof(FlexPanel), new FrameworkPropertyMetadata(default(FlexDirection), FrameworkPropertyMetadataOptions.AffectsMeasure));
|
"FlexDirection", typeof(FlexDirection), typeof(FlexPanel),
|
||||||
|
new FrameworkPropertyMetadata(default(FlexDirection), FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||||
|
|
||||||
public FlexDirection FlexDirection
|
public FlexDirection FlexDirection
|
||||||
{
|
{
|
||||||
@@ -78,7 +87,8 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty FlexWrapProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty FlexWrapProperty = DependencyProperty.Register(
|
||||||
"FlexWrap", typeof(FlexWrap), typeof(FlexPanel), new FrameworkPropertyMetadata(default(FlexWrap), FrameworkPropertyMetadataOptions.AffectsMeasure));
|
"FlexWrap", typeof(FlexWrap), typeof(FlexPanel),
|
||||||
|
new FrameworkPropertyMetadata(default(FlexWrap), FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||||
|
|
||||||
public FlexWrap FlexWrap
|
public FlexWrap FlexWrap
|
||||||
{
|
{
|
||||||
@@ -87,7 +97,9 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty JustifyContentProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty JustifyContentProperty = DependencyProperty.Register(
|
||||||
"JustifyContent", typeof(FlexContentJustify), typeof(FlexPanel), new FrameworkPropertyMetadata(default(FlexContentJustify), FrameworkPropertyMetadataOptions.AffectsMeasure));
|
"JustifyContent", typeof(FlexContentJustify), typeof(FlexPanel),
|
||||||
|
new FrameworkPropertyMetadata(default(FlexContentJustify),
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||||
|
|
||||||
public FlexContentJustify JustifyContent
|
public FlexContentJustify JustifyContent
|
||||||
{
|
{
|
||||||
@@ -96,7 +108,9 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty AlignItemsProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty AlignItemsProperty = DependencyProperty.Register(
|
||||||
"AlignItems", typeof(FlexItemsAlignment), typeof(FlexPanel), new FrameworkPropertyMetadata(default(FlexItemsAlignment), FrameworkPropertyMetadataOptions.AffectsMeasure));
|
"AlignItems", typeof(FlexItemsAlignment), typeof(FlexPanel),
|
||||||
|
new FrameworkPropertyMetadata(default(FlexItemsAlignment),
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||||
|
|
||||||
public FlexItemsAlignment AlignItems
|
public FlexItemsAlignment AlignItems
|
||||||
{
|
{
|
||||||
@@ -105,7 +119,9 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty AlignContentProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty AlignContentProperty = DependencyProperty.Register(
|
||||||
"AlignContent", typeof(FlexContentAlignment), typeof(FlexPanel), new FrameworkPropertyMetadata(default(FlexContentAlignment), FrameworkPropertyMetadataOptions.AffectsMeasure));
|
"AlignContent", typeof(FlexContentAlignment), typeof(FlexPanel),
|
||||||
|
new FrameworkPropertyMetadata(default(FlexContentAlignment),
|
||||||
|
FrameworkPropertyMetadataOptions.AffectsMeasure));
|
||||||
|
|
||||||
public FlexContentAlignment AlignContent
|
public FlexContentAlignment AlignContent
|
||||||
{
|
{
|
||||||
@@ -143,6 +159,7 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
_orderList.Add(new FlexItemInfo(i, GetOrder(child)));
|
_orderList.Add(new FlexItemInfo(i, GetOrder(child)));
|
||||||
}
|
}
|
||||||
|
|
||||||
_orderList.Sort();
|
_orderList.Sort();
|
||||||
|
|
||||||
for (var i = 0; i < children.Count; i++)
|
for (var i = 0; i < children.Count; i++)
|
||||||
@@ -150,6 +167,11 @@ namespace HandyControl.Controls
|
|||||||
var child = children[_orderList[i].Index];
|
var child = children[_orderList[i].Index];
|
||||||
if (child == null) continue;
|
if (child == null) continue;
|
||||||
|
|
||||||
|
var flexBasis = GetFlexBasis(child);
|
||||||
|
if (!flexBasis.IsNaN())
|
||||||
|
{
|
||||||
|
child.SetCurrentValue(WidthProperty, flexBasis);
|
||||||
|
}
|
||||||
child.Measure(childConstraint);
|
child.Measure(childConstraint);
|
||||||
|
|
||||||
var sz = new UVSize(FlexDirection, child.DesiredSize);
|
var sz = new UVSize(FlexDirection, child.DesiredSize);
|
||||||
@@ -260,6 +282,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
freeV -= flexSize.V;
|
freeV -= flexSize.V;
|
||||||
}
|
}
|
||||||
|
|
||||||
var freeItemV = freeV;
|
var freeItemV = freeV;
|
||||||
|
|
||||||
// calculate status
|
// calculate status
|
||||||
@@ -277,13 +300,10 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V - lineFreeVArr[0] : 0;
|
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V - lineFreeVArr[0] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FlexContentAlignment.FlexStart:
|
case FlexContentAlignment.FlexStart:
|
||||||
if (FlexWrap == FlexWrap.WrapReverse)
|
wrapReverseAdd = FlexWrap == FlexWrap.WrapReverse ? 0 : 1;
|
||||||
{
|
|
||||||
wrapReverseAdd = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_lineCount > 1)
|
if (_lineCount > 1)
|
||||||
{
|
{
|
||||||
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V : 0;
|
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V : 0;
|
||||||
@@ -292,13 +312,10 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
wrapReverseAdd = 0;
|
wrapReverseAdd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FlexContentAlignment.FlexEnd:
|
case FlexContentAlignment.FlexEnd:
|
||||||
if (FlexWrap != FlexWrap.WrapReverse)
|
wrapReverseAdd = FlexWrap == FlexWrap.WrapReverse ? 1 : 0;
|
||||||
{
|
|
||||||
wrapReverseAdd = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_lineCount > 1)
|
if (_lineCount > 1)
|
||||||
{
|
{
|
||||||
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V - freeV : freeV;
|
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V - freeV : freeV;
|
||||||
@@ -307,12 +324,14 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
wrapReverseAdd = 0;
|
wrapReverseAdd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FlexContentAlignment.Center:
|
case FlexContentAlignment.Center:
|
||||||
if (_lineCount > 1)
|
if (_lineCount > 1)
|
||||||
{
|
{
|
||||||
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V - freeV * 0.5 : freeV * 0.5;
|
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V - freeV * 0.5 : freeV * 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FlexContentAlignment.SpaceBetween:
|
case FlexContentAlignment.SpaceBetween:
|
||||||
if (_lineCount > 1)
|
if (_lineCount > 1)
|
||||||
@@ -325,6 +344,7 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V : 0;
|
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FlexContentAlignment.SpaceAround:
|
case FlexContentAlignment.SpaceAround:
|
||||||
if (_lineCount > 1)
|
if (_lineCount > 1)
|
||||||
@@ -337,6 +357,7 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V - freeItemV : freeItemV;
|
accumulatedV = FlexWrap == FlexWrap.WrapReverse ? uvFinalSize.V - curLineSizeArr[0].V - freeItemV : freeItemV;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +392,8 @@ namespace HandyControl.Controls
|
|||||||
lineIndex++;
|
lineIndex++;
|
||||||
itemsU = 0;
|
itemsU = 0;
|
||||||
|
|
||||||
if (i >= lastInLineArr[lineIndex]) //the element is wider then the constraint - give it a separate line
|
if (i >= lastInLineArr[lineIndex]
|
||||||
|
) //the element is wider then the constraint - give it a separate line
|
||||||
{
|
{
|
||||||
//switch to next line which only contain one element
|
//switch to next line which only contain one element
|
||||||
ArrangeLine(new FlexLineInfo
|
ArrangeLine(new FlexLineInfo
|
||||||
@@ -390,6 +412,7 @@ namespace HandyControl.Controls
|
|||||||
lineIndex++;
|
lineIndex++;
|
||||||
itemsU = 0;
|
itemsU = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
firstInLine = i;
|
firstInLine = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -420,6 +443,10 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
var isHorizontal = FlexDirection == FlexDirection.Row || FlexDirection == FlexDirection.RowReverse;
|
var isHorizontal = FlexDirection == FlexDirection.Row || FlexDirection == FlexDirection.RowReverse;
|
||||||
var isReverse = FlexDirection == FlexDirection.RowReverse || FlexDirection == FlexDirection.ColumnReverse;
|
var isReverse = FlexDirection == FlexDirection.RowReverse || FlexDirection == FlexDirection.ColumnReverse;
|
||||||
|
var itemCount = lineInfo.ItemEndIndex - lineInfo.ItemStartIndex;
|
||||||
|
var children = InternalChildren;
|
||||||
|
var lineFreeU = lineInfo.LineU - lineInfo.ItemsU;
|
||||||
|
var constraintFreeU = _uvConstraint.U - lineInfo.ItemsU;
|
||||||
|
|
||||||
// calculate initial u
|
// calculate initial u
|
||||||
var u = .0;
|
var u = .0;
|
||||||
@@ -439,43 +466,120 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
u = JustifyContent switch
|
u = JustifyContent switch
|
||||||
{
|
{
|
||||||
FlexContentJustify.FlexEnd => lineInfo.LineU - lineInfo.ItemsU,
|
FlexContentJustify.FlexEnd => lineFreeU,
|
||||||
FlexContentJustify.Center => (lineInfo.LineU - lineInfo.ItemsU) * 0.5,
|
FlexContentJustify.Center => lineFreeU * 0.5,
|
||||||
_ => u
|
_ => u
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
u *= lineInfo.ScaleU;
|
u *= lineInfo.ScaleU;
|
||||||
|
|
||||||
// calculate offset u
|
// apply FlexGrow
|
||||||
var itemCount = lineInfo.ItemEndIndex - lineInfo.ItemStartIndex;
|
var flexGrowUArr = new double[itemCount];
|
||||||
var offsetUArr = new double[itemCount];
|
if (constraintFreeU > 0)
|
||||||
if (JustifyContent == FlexContentJustify.SpaceBetween)
|
|
||||||
{
|
{
|
||||||
var freeItemU = (lineInfo.LineU - lineInfo.ItemsU) / (itemCount - 1);
|
var ignoreFlexGrow = true;
|
||||||
for (var i = 1; i < itemCount; i++)
|
var flexGrowSum = .0;
|
||||||
|
|
||||||
|
for (var i = 0; i < itemCount; i++)
|
||||||
{
|
{
|
||||||
offsetUArr[i] = freeItemU;
|
var flexGrow = GetFlexGrow(children[_orderList[i].Index]);
|
||||||
|
ignoreFlexGrow &= MathHelper.IsVerySmall(flexGrow);
|
||||||
|
flexGrowUArr[i] = flexGrow;
|
||||||
|
flexGrowSum += flexGrow;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (JustifyContent == FlexContentJustify.SpaceAround)
|
if (!ignoreFlexGrow)
|
||||||
{
|
|
||||||
var freeItemU = (lineInfo.LineU - lineInfo.ItemsU) / itemCount * 0.5;
|
|
||||||
offsetUArr[0] = freeItemU;
|
|
||||||
for (var i = 1; i < itemCount; i++)
|
|
||||||
{
|
{
|
||||||
offsetUArr[i] = freeItemU * 2;
|
var flexGrowItem = .0;
|
||||||
|
if (flexGrowSum > 0)
|
||||||
|
{
|
||||||
|
flexGrowItem = constraintFreeU / flexGrowSum;
|
||||||
|
lineInfo.ScaleU = 1;
|
||||||
|
lineFreeU = 0; //line free U was used up
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < itemCount; i++)
|
||||||
|
{
|
||||||
|
flexGrowUArr[i] *= flexGrowItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flexGrowUArr = new double[itemCount];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var children = InternalChildren;
|
// apply FlexShrink
|
||||||
|
var flexShrinkUArr = new double[itemCount];
|
||||||
|
if (constraintFreeU < 0)
|
||||||
|
{
|
||||||
|
var ignoreFlexShrink = true;
|
||||||
|
var flexShrinkSum = .0;
|
||||||
|
|
||||||
|
for (var i = 0; i < itemCount; i++)
|
||||||
|
{
|
||||||
|
var flexShrink = GetFlexShrink(children[_orderList[i].Index]);
|
||||||
|
ignoreFlexShrink &= MathHelper.IsVerySmall(flexShrink - 1);
|
||||||
|
flexShrinkUArr[i] = flexShrink;
|
||||||
|
flexShrinkSum += flexShrink;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ignoreFlexShrink)
|
||||||
|
{
|
||||||
|
var flexShrinkItem = .0;
|
||||||
|
if (flexShrinkSum > 0)
|
||||||
|
{
|
||||||
|
flexShrinkItem = constraintFreeU / flexShrinkSum;
|
||||||
|
lineInfo.ScaleU = 1;
|
||||||
|
lineFreeU = 0; //line free U was used up
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < itemCount; i++)
|
||||||
|
{
|
||||||
|
flexShrinkUArr[i] *= flexShrinkItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flexShrinkUArr = new double[itemCount];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate offset u
|
||||||
|
var offsetUArr = new double[itemCount];
|
||||||
|
if (lineFreeU > 0)
|
||||||
|
{
|
||||||
|
if (JustifyContent == FlexContentJustify.SpaceBetween)
|
||||||
|
{
|
||||||
|
var freeItemU = lineFreeU / (itemCount - 1);
|
||||||
|
for (var i = 1; i < itemCount; i++)
|
||||||
|
{
|
||||||
|
offsetUArr[i] = freeItemU;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (JustifyContent == FlexContentJustify.SpaceAround)
|
||||||
|
{
|
||||||
|
var freeItemU = lineFreeU / itemCount * 0.5;
|
||||||
|
offsetUArr[0] = freeItemU;
|
||||||
|
for (var i = 1; i < itemCount; i++)
|
||||||
|
{
|
||||||
|
offsetUArr[i] = freeItemU * 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// arrange item
|
||||||
for (int i = lineInfo.ItemStartIndex, j = 0; i < lineInfo.ItemEndIndex; i++, j++)
|
for (int i = lineInfo.ItemStartIndex, j = 0; i < lineInfo.ItemEndIndex; i++, j++)
|
||||||
{
|
{
|
||||||
var child = children[_orderList[i].Index];
|
var child = children[_orderList[i].Index];
|
||||||
if (child == null) continue;
|
if (child == null) continue;
|
||||||
|
|
||||||
var childSize = new UVSize(FlexDirection, isHorizontal ?
|
var childSize = new UVSize(FlexDirection, isHorizontal
|
||||||
new Size(child.DesiredSize.Width * lineInfo.ScaleU, child.DesiredSize.Height) :
|
? new Size(child.DesiredSize.Width * lineInfo.ScaleU, child.DesiredSize.Height)
|
||||||
new Size(child.DesiredSize.Width, child.DesiredSize.Height * lineInfo.ScaleU));
|
: new Size(child.DesiredSize.Width, child.DesiredSize.Height * lineInfo.ScaleU));
|
||||||
|
|
||||||
|
childSize.U += flexGrowUArr[j] + flexShrinkUArr[j];
|
||||||
|
|
||||||
if (isReverse)
|
if (isReverse)
|
||||||
{
|
{
|
||||||
@@ -489,15 +593,7 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
var v = lineInfo.OffsetV;
|
var v = lineInfo.OffsetV;
|
||||||
var alignSelf = GetAlignSelf(child);
|
var alignSelf = GetAlignSelf(child);
|
||||||
FlexItemsAlignment alignment;
|
var alignment = alignSelf == FlexItemAlignment.Auto ? AlignItems : (FlexItemsAlignment)alignSelf;
|
||||||
if (alignSelf == FlexItemAlignment.Auto)
|
|
||||||
{
|
|
||||||
alignment = AlignItems;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
alignment = (FlexItemsAlignment)alignSelf;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (alignment)
|
switch (alignment)
|
||||||
{
|
{
|
||||||
@@ -510,6 +606,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
childSize.V = lineInfo.LineV;
|
childSize.V = lineInfo.LineV;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FlexItemsAlignment.FlexEnd:
|
case FlexItemsAlignment.FlexEnd:
|
||||||
v += lineInfo.LineV - childSize.V;
|
v += lineInfo.LineV - childSize.V;
|
||||||
|
|||||||
Reference in new issue
Block a user