draw with wife
This commit is contained in:
@@ -389,7 +389,7 @@ void Tree::draw(person_id focused) const
|
||||
|
||||
U16 drawY = 0/* (LINES) / 2 */;
|
||||
U16 drawX = 0/* (COLS) / 2 */;
|
||||
drawLine(focused, drawY, drawX);
|
||||
drawLineWithWives(focused, drawY, drawX);
|
||||
/* people[0].draw(drawY, drawY); */
|
||||
/* for(U32 i=0; i<relations[0].gNum(); ++i) */
|
||||
/* { */
|
||||
@@ -559,40 +559,48 @@ I16 Tree::drawLine(person_id id, I16 drawY, I16 drawX) const
|
||||
return drawX + people[id].boxWidth() + dist_between;
|
||||
}
|
||||
|
||||
I16 Tree::drawLineWithWives(person_id id, I16 drawY, I16 drawX) const
|
||||
I16 Tree::drawLineWithWives(person_id id, I16 drawY, const I16 drawX) const
|
||||
{
|
||||
/* const auto& rels = relations[id]; */
|
||||
/* /\* const auto& rels = relations[id]; *\/ */
|
||||
const Person& person = people[id];
|
||||
const auto& rels = relations[id];
|
||||
|
||||
/* people[id].draw(drawY, drawX); */
|
||||
person.draw(drawY, drawX);
|
||||
|
||||
person_id spouse = Nobody;
|
||||
std::vector<person_id> children;
|
||||
for(person_id i = 0; i < rels.gNum(); ++i)
|
||||
{
|
||||
if(rels[i].type == RelType::Parent)
|
||||
children.push_back(rels[i].id);
|
||||
|
||||
else if(rels[i].type == RelType::Spouse && spouse == Nobody)
|
||||
spouse = rels[i].id;
|
||||
}
|
||||
|
||||
/* /\* for(U32 i = 0; i < re *\/ */
|
||||
U16 spouse_width = 0;
|
||||
if(spouse != Nobody)
|
||||
{
|
||||
people[spouse].draw(drawY, drawX + person.boxWidth() + spouse_dist);
|
||||
spouse_width = spouse_dist + people[spouse].boxWidth();
|
||||
}
|
||||
|
||||
/* std::vector<person_id> children; */
|
||||
/* for(U32 i=0; i<relations[id].gNum(); ++i) */
|
||||
/* { */
|
||||
/* if(relations[id][i] == RelType::Parent) */
|
||||
/* children.push_back(relatives[id][i]); */
|
||||
/* } */
|
||||
auto childX = drawX;
|
||||
if(!children.empty())
|
||||
{
|
||||
auto prevX = childX;
|
||||
drawY += BOX_HEIGHT;
|
||||
|
||||
/* if(!children.empty()) */
|
||||
/* { */
|
||||
/* auto prevX = drawX; */
|
||||
/* drawY += BOX_HEIGHT; */
|
||||
auto lnHt = linkToFirstBorn(drawY, childX); /* Link height */
|
||||
childX = drawLineWithWives(children[0], drawY + lnHt, childX);
|
||||
|
||||
/* auto lnHt = linkToFirstBorn(drawY, drawX); /\* Link height *\/ */
|
||||
/* drawX = drawLine(children[0], drawY + lnHt, drawX); */
|
||||
for(size_t j = 1; j < children.size(); ++j)
|
||||
{
|
||||
lnHt = linkToChild(drawY+1, prevX+1, childX+1);
|
||||
prevX = childX;
|
||||
childX = drawLineWithWives(children[j], drawY + lnHt, childX);
|
||||
}
|
||||
}
|
||||
|
||||
/* for(size_t j = 1; j < children.size(); ++j) */
|
||||
/* { */
|
||||
/* lnHt = linkToChild(drawY+1, prevX+1, drawX+1); */
|
||||
/* prevX = drawX; */
|
||||
/* drawX = drawLine(children[j], drawY + lnHt, drawX); */
|
||||
/* } */
|
||||
/* return drawX; */
|
||||
/* } */
|
||||
|
||||
/* return drawX + people[id].boxWidth() + dist_between; */
|
||||
return max(drawX + person.boxWidth() + dist_between + spouse_width,
|
||||
childX);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user