Initial commit: AetherBags + KamiToolKit for FC Gitea
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using System.Linq;
|
||||
using KamiToolKit.Enums;
|
||||
|
||||
namespace KamiToolKit.Nodes;
|
||||
|
||||
public class HorizontalFlexNode : LayoutListNode {
|
||||
|
||||
public FlexFlags AlignmentFlags { get; set; } = FlexFlags.FitContentHeight;
|
||||
|
||||
public float FitPadding { get; set; } = 4.0f;
|
||||
|
||||
public override float Width {
|
||||
get => base.Width;
|
||||
set {
|
||||
base.Width = value;
|
||||
RecalculateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRecalculateLayout() {
|
||||
var step = Width / NodeList.Count;
|
||||
|
||||
if (NodeList.Count != 0 && AlignmentFlags.HasFlag(FlexFlags.FitContentHeight)) {
|
||||
Height = NodeList.Max(node => node.Height);
|
||||
}
|
||||
|
||||
foreach (var index in Enumerable.Range(0, NodeList.Count)) {
|
||||
|
||||
if (AlignmentFlags.HasFlag(FlexFlags.CenterHorizontally)) {
|
||||
NodeList[index].X = step * index + step / 2.0f - NodeList[index].Width / 2.0f;
|
||||
}
|
||||
else {
|
||||
NodeList[index].X = step * index;
|
||||
}
|
||||
|
||||
if (AlignmentFlags.HasFlag(FlexFlags.FitHeight)) {
|
||||
NodeList[index].Height = Height;
|
||||
}
|
||||
|
||||
if (AlignmentFlags.HasFlag(FlexFlags.CenterVertically)) {
|
||||
NodeList[index].Y = Height / 2 - NodeList[index].Height / 2;
|
||||
}
|
||||
|
||||
if (AlignmentFlags.HasFlag(FlexFlags.FitWidth)) {
|
||||
NodeList[index].Width = step - FitPadding;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user