diff --git a/geneit_app/src/widgets/simple_family_tree/SimpleFamilyTree.tsx b/geneit_app/src/widgets/simple_family_tree/SimpleFamilyTree.tsx index 8f3d00b..b771a26 100644 --- a/geneit_app/src/widgets/simple_family_tree/SimpleFamilyTree.tsx +++ b/geneit_app/src/widgets/simple_family_tree/SimpleFamilyTree.tsx @@ -254,6 +254,7 @@ function NodeArea(p: { let pers2 = p.node.spouse?.member; let didSwap = false; + // Show male of the left (all the time) if (pers2?.sex === "M") { let s = pers1; pers1 = pers2; @@ -293,10 +294,37 @@ function NodeArea(p: { let childrenLinkX: number; let childrenLinkY: number; - if (p.node.spouse) { + // If the father is the father of all the children, while the + // mother is not the mother of any of the children + if ( + pers2 && + p.node.down.every( + (n) => n.member.father === pers1.id && n.member.mother !== pers2!.id + ) + ) { + childrenLinkX = parent_x_offset + Math.floor(memberCardWidth(pers1) / 2); + childrenLinkY = p.y + CARD_HEIGHT + 2; + } + // If the mother is the mother of all the children, while the + // father is not the father of any of the children + if ( + pers2 && + p.node.down.every( + (n) => n.member.father !== pers1.id && n.member.mother === pers2!.id + ) + ) { + childrenLinkX = beginSecondFaceX! + Math.floor(memberCardWidth(pers2) / 2); + childrenLinkY = p.y + CARD_HEIGHT + 2; + } + + // Normal couple + else if (p.node.spouse) { childrenLinkX = Math.floor((endFirstFaceX + beginSecondFaceX!) / 2); childrenLinkY = middleParentFaceY; - } else { + } + + // Single person + else { childrenLinkX = parent_x_offset + Math.floor(memberCardWidth(pers1) / 2); childrenLinkY = p.y + CARD_HEIGHT + 2; }