Merge pull request #837 from pozzif/Fix-FlexPanel-items-order
Fixed the order of the items in the FlexPanel
This commit is contained in:
1 file changed
+11
-6
@@ -193,7 +193,7 @@ namespace HandyControl.Controls
|
|||||||
curLineSize = sz;
|
curLineSize = sz;
|
||||||
_lineCount++;
|
_lineCount++;
|
||||||
|
|
||||||
if (MathHelper.GreaterThan(sz.U, _uvConstraint.U)) //the element is wider then the constrint - give it a separate line
|
if (MathHelper.GreaterThan(sz.U, _uvConstraint.U)) //the element is wider then the constrint - give it a separate line
|
||||||
{
|
{
|
||||||
panelSize.U = Math.Max(sz.U, panelSize.U);
|
panelSize.U = Math.Max(sz.U, panelSize.U);
|
||||||
panelSize.V += sz.V;
|
panelSize.V += sz.V;
|
||||||
@@ -260,7 +260,7 @@ namespace HandyControl.Controls
|
|||||||
lineIndex++;
|
lineIndex++;
|
||||||
curLineSizeArr[lineIndex] = sz;
|
curLineSizeArr[lineIndex] = sz;
|
||||||
|
|
||||||
if (MathHelper.GreaterThan(sz.U, uvFinalSize.U)) //the element is wider then the constraint - give it a separate line
|
if (MathHelper.GreaterThan(sz.U, uvFinalSize.U)) //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
|
||||||
lastInLineArr[lineIndex] = i;
|
lastInLineArr[lineIndex] = i;
|
||||||
@@ -399,7 +399,7 @@ 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
|
||||||
@@ -507,7 +507,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
flexGrowItem = constraintFreeU / flexGrowSum;
|
flexGrowItem = constraintFreeU / flexGrowSum;
|
||||||
lineInfo.ScaleU = 1;
|
lineInfo.ScaleU = 1;
|
||||||
lineFreeU = 0; //line free U was used up
|
lineFreeU = 0; //line free U was used up
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < itemCount; i++)
|
for (var i = 0; i < itemCount; i++)
|
||||||
@@ -543,7 +543,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
flexShrinkItem = constraintFreeU / flexShrinkSum;
|
flexShrinkItem = constraintFreeU / flexShrinkSum;
|
||||||
lineInfo.ScaleU = 1;
|
lineInfo.ScaleU = 1;
|
||||||
lineFreeU = 0; //line free U was used up
|
lineFreeU = 0; //line free U was used up
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < itemCount; i++)
|
for (var i = 0; i < itemCount; i++)
|
||||||
@@ -648,7 +648,12 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
|
|
||||||
public int CompareTo(FlexItemInfo other) => Order.CompareTo(other.Order);
|
public int CompareTo(FlexItemInfo other)
|
||||||
|
{
|
||||||
|
var orderCompare = Order.CompareTo(other.Order);
|
||||||
|
if (orderCompare != 0) return orderCompare;
|
||||||
|
return Index.CompareTo(other.Index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct FlexLineInfo
|
private struct FlexLineInfo
|
||||||
|
|||||||
Reference in new issue
Block a user