add indication for people with subtrees
This commit is contained in:
+28
-11
@@ -90,10 +90,29 @@ static U16 Utf8SymbolsCount(const string& str)
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
U16 Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse,
|
U16 Person::drawAsFocused(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse,
|
||||||
bool hasParents, bool hasKids, bool wholeName) const
|
bool hasKids, bool wholeName) const
|
||||||
{
|
{
|
||||||
string display_name; /* todo remove? */
|
auto topright = hasSpouse ? ACS_TTEE : ACS_URCORNER;
|
||||||
|
auto botleft = hasKids ? ACS_LTEE : ACS_LLCORNER;
|
||||||
|
|
||||||
|
return draw(drawY, drawX, selected, wholeName,
|
||||||
|
ACS_LTEE, topright,
|
||||||
|
botleft, ACS_LRCORNER );
|
||||||
|
}
|
||||||
|
|
||||||
|
U16 Person::drawAsSpouse(I16 drawY, I16 drawX, bool selected, bool hasTree, bool wholeName) const
|
||||||
|
{
|
||||||
|
auto topright = hasTree ? '@' : ACS_URCORNER;
|
||||||
|
return draw(drawY, drawX, selected, wholeName,
|
||||||
|
ACS_TTEE, topright,
|
||||||
|
ACS_LLCORNER, ACS_LRCORNER );
|
||||||
|
}
|
||||||
|
|
||||||
|
U16 Person::draw(I16 drawY, I16 drawX, bool selected, bool wholeName,
|
||||||
|
U32 topleft, U32 topright, U32 botleft, U32 botright) const
|
||||||
|
{
|
||||||
|
string display_name;
|
||||||
if(wholeName)
|
if(wholeName)
|
||||||
{
|
{
|
||||||
display_name = name;
|
display_name = name;
|
||||||
@@ -103,9 +122,7 @@ U16 Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse
|
|||||||
size_t space = name.find(' ');
|
size_t space = name.find(' ');
|
||||||
if(space != string::npos)
|
if(space != string::npos)
|
||||||
{
|
{
|
||||||
/* name[space] = '\0'; */
|
|
||||||
display_name = name.substr(0, space);
|
display_name = name.substr(0, space);
|
||||||
/* name[space] = ' '; */
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -113,7 +130,9 @@ U16 Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const U16 width = Utf8SymbolsCount(display_name) + 4; /* pad width */
|
|
||||||
|
/* pad width */
|
||||||
|
const U16 width = Utf8SymbolsCount(display_name) + 4;
|
||||||
|
|
||||||
if(willBeVisible(drawY, drawX, BOX_HEIGHT, width))
|
if(willBeVisible(drawY, drawX, BOX_HEIGHT, width))
|
||||||
{
|
{
|
||||||
@@ -125,12 +144,9 @@ U16 Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse
|
|||||||
wbkgd(pad, color_pair);
|
wbkgd(pad, color_pair);
|
||||||
/* wattron(pad, color_pair); */
|
/* wattron(pad, color_pair); */
|
||||||
|
|
||||||
auto top_left = hasParents ? ACS_LTEE : ACS_TTEE;
|
|
||||||
auto top_right = hasSpouse ? ACS_TTEE : ACS_URCORNER;
|
|
||||||
auto bot_left = hasKids ? ACS_LTEE : ACS_LLCORNER;
|
|
||||||
wborder(pad, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
|
wborder(pad, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
|
||||||
top_left, top_right,
|
topleft, topright,
|
||||||
bot_left, ACS_LRCORNER );
|
botleft, botright);
|
||||||
|
|
||||||
mvwaddstr(pad, 2, 2, display_name.data());
|
mvwaddstr(pad, 2, 2, display_name.data());
|
||||||
|
|
||||||
@@ -139,4 +155,5 @@ U16 Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse
|
|||||||
drawpad(pad, drawY, drawX);
|
drawpad(pad, drawY, drawX);
|
||||||
}
|
}
|
||||||
return width;
|
return width;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-3
@@ -51,15 +51,26 @@ public:
|
|||||||
|
|
||||||
void displayInfo() const;
|
void displayInfo() const;
|
||||||
|
|
||||||
/* Draw a Person's box on the terminal
|
/* Draw a Person's box on the terminal, as a part of the focused tree
|
||||||
drawY,drawX - top left coordinates where to draw (negative if outside the screen)
|
drawY,drawX - top left coordinates where to draw (negative if outside the screen)
|
||||||
|
partOfMain - is the person a decendant of the current root
|
||||||
hasSpouse, hasSpouse, hasChildren - wheather the person has them on display
|
hasSpouse, hasSpouse, hasChildren - wheather the person has them on display
|
||||||
returns the width of the box*/
|
returns the width of the box*/
|
||||||
U16 draw(I16 drawY, I16 drawX, bool selected, bool hasSpouse,
|
U16 drawAsFocused(I16 drawY, I16 drawX, bool selected, bool hasSpouse,
|
||||||
bool hasParents, bool hasChildren=false, bool wholeName=true) const;
|
bool hasChildren=false, bool wholeName=true) const;
|
||||||
|
|
||||||
|
/* Draw a Person's box on the terminal, as a spouse of someone in the focused tree
|
||||||
|
drawY,drawX - top left coordinates where to draw (negative if outside the screen)
|
||||||
|
hasTree - weather the spouse has a tree that can be displayed
|
||||||
|
returns the width of the box*/
|
||||||
|
U16 drawAsSpouse(I16 drawY, I16 drawX, bool selected, bool hasTree, bool wholeName=true) const;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
EventTime birth;
|
EventTime birth;
|
||||||
Sex sex;
|
Sex sex;
|
||||||
EventTime death;
|
EventTime death;
|
||||||
|
|
||||||
|
private:
|
||||||
|
U16 draw(I16 drawY, I16 drawX, bool selected, bool wholeName,
|
||||||
|
U32 topleft, U32 topright, U32 botleft, U32 botright) const;
|
||||||
};
|
};
|
||||||
|
|||||||
+11
-50
@@ -434,7 +434,7 @@ void Tree::draw(const person_id selected, const U8 zoom, const I16 offsetY, cons
|
|||||||
erase(); //Clear the screen
|
erase(); //Clear the screen
|
||||||
wnoutrefresh(stdscr);
|
wnoutrefresh(stdscr);
|
||||||
|
|
||||||
drawLineWithWives(focused_, offsetY, offsetX);
|
drawLineWithSpouses(focused_, offsetY, offsetX);
|
||||||
|
|
||||||
doupdate();
|
doupdate();
|
||||||
}
|
}
|
||||||
@@ -494,62 +494,23 @@ static U8 linkToChild(I16 startY, I16 startX, I16 endX, bool moreSiblings)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
I16 Tree::drawLineWithSpouses(const person_id id, I16 drawY, const I16 drawX) const
|
||||||
/* I16 Tree::drawLine(person_id id, I16 drawY, I16 drawX) const */
|
|
||||||
/* { */
|
|
||||||
/* people_[id].draw(drawY, drawX, true, false, true); */
|
|
||||||
|
|
||||||
/* vector<person_id> children; */
|
|
||||||
/* for(U32 i=0; i<relations_[id].size(); ++i) */
|
|
||||||
/* { */
|
|
||||||
/* if (relations_[id][i].type == RelType::Parent) */
|
|
||||||
/* children.push_back(relations_[id][i].id); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* if (!children.empty()) */
|
|
||||||
/* { */
|
|
||||||
/* auto prevX = drawX; */
|
|
||||||
/* drawY += BOX_HEIGHT; */
|
|
||||||
|
|
||||||
/* 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, drawX+1); */
|
|
||||||
/* prevX = drawX; */
|
|
||||||
/* drawX = drawLine(children[j], drawY + lnHt, drawX); */
|
|
||||||
/* } */
|
|
||||||
/* return drawX; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* return drawX + people_[id].boxWidth() + dist_between_; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
I16 Tree::drawLineWithWives(const person_id id, I16 drawY, const I16 drawX) const
|
|
||||||
{
|
{
|
||||||
const Person& person = people_[id];
|
const Person& person = people_[id];
|
||||||
const auto& rels = relations_[id];
|
|
||||||
|
|
||||||
person_id spouse = Nobody;
|
person_id spouse = findSpouse(id);
|
||||||
vector<person_id> children;
|
vector<person_id> children = findChildren(id);
|
||||||
for(const auto& rel: rels)
|
|
||||||
{
|
|
||||||
if (rel.type == RelType::Parent)
|
|
||||||
children.push_back(rel.id);
|
|
||||||
|
|
||||||
else if (rel.type == RelType::Spouse && spouse == Nobody)
|
|
||||||
spouse = rel.id;
|
|
||||||
}
|
|
||||||
const size_t numKids = children.size();
|
const size_t numKids = children.size();
|
||||||
U16 person_w = person.draw(drawY, drawX,
|
U16 person_w = person.drawAsFocused(drawY, drawX,
|
||||||
id == selected_, spouse!=Nobody, true, numKids!=0, zoom_==1);
|
id == selected_, spouse!=Nobody, numKids!=0, zoom_>=1);
|
||||||
|
|
||||||
U16 spouse_w = 0;
|
U16 spouse_w = 0;
|
||||||
if (spouse != Nobody)
|
if (spouse != Nobody)
|
||||||
{
|
{
|
||||||
U16 spouse_box = people_[spouse].draw(drawY, drawX + person_w + spouse_dist_,
|
bool spouse_has_tree = (findParent(spouse, M) != Nobody) || (findParent(spouse, F) != Nobody);
|
||||||
spouse == selected_, false, false, false, zoom_==1);
|
U16 spouse_box = people_[spouse].drawAsSpouse(drawY, drawX + person_w + spouse_dist_,
|
||||||
|
spouse == selected_, spouse_has_tree, zoom_>=1);
|
||||||
spouse_w = spouse_dist_ + spouse_box;
|
spouse_w = spouse_dist_ + spouse_box;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,7 +521,7 @@ I16 Tree::drawLineWithWives(const person_id id, I16 drawY, const I16 drawX) cons
|
|||||||
drawY += BOX_HEIGHT;
|
drawY += BOX_HEIGHT;
|
||||||
|
|
||||||
auto lnHt = linkToFirstBorn(drawY, childX, numKids > 1); /* Link height */
|
auto lnHt = linkToFirstBorn(drawY, childX, numKids > 1); /* Link height */
|
||||||
childX = drawLineWithWives(children[0], drawY + lnHt, childX);
|
childX = drawLineWithSpouses(children[0], drawY + lnHt, childX);
|
||||||
|
|
||||||
for(size_t j = 1; j < numKids; ++j)
|
for(size_t j = 1; j < numKids; ++j)
|
||||||
{
|
{
|
||||||
@@ -568,7 +529,7 @@ I16 Tree::drawLineWithWives(const person_id id, I16 drawY, const I16 drawX) cons
|
|||||||
lnHt = linkToChild(drawY+1, prevX+1, childX+1, j < numKids-1) + 1;
|
lnHt = linkToChild(drawY+1, prevX+1, childX+1, j < numKids-1) + 1;
|
||||||
|
|
||||||
prevX = childX;
|
prevX = childX;
|
||||||
childX = drawLineWithWives(children[j], drawY + lnHt, childX);
|
childX = drawLineWithSpouses(children[j], drawY + lnHt, childX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -87,8 +87,8 @@ private:
|
|||||||
void updateRels(person_id);
|
void updateRels(person_id);
|
||||||
|
|
||||||
/* draw a line of people starting from person with id
|
/* draw a line of people starting from person with id
|
||||||
return the farthest X that will be drawn */
|
return the farthest X on the screen where it will be drawn */
|
||||||
I16 drawLineWithWives(person_id, I16 drawY, I16 drawX) const;
|
I16 drawLineWithSpouses(person_id, I16 drawY, I16 drawX) const;
|
||||||
|
|
||||||
std::string treeName_;
|
std::string treeName_;
|
||||||
std::vector<Person> people_; //The data for each member
|
std::vector<Person> people_; //The data for each member
|
||||||
|
|||||||
Reference in New Issue
Block a user