zooming
This commit is contained in:
@@ -52,6 +52,13 @@ Make sure you satisfy the dependencies and have permissons and execute:
|
|||||||
HOW TO USE:
|
HOW TO USE:
|
||||||
tft ${MY_TFT_FILE}
|
tft ${MY_TFT_FILE}
|
||||||
|
|
||||||
|
Navigation:
|
||||||
|
arrows - move the camera
|
||||||
|
h, j, k, l - move around the tree
|
||||||
|
Enter, Space - display the selected person's tree
|
||||||
|
+ - show full names
|
||||||
|
- - show first names only
|
||||||
|
|
||||||
TFT FORMAT:
|
TFT FORMAT:
|
||||||
- All spaces are ignored e.g.: Adam 0 and Adam0 are equivalent
|
- All spaces are ignored e.g.: Adam 0 and Adam0 are equivalent
|
||||||
- '_' in names is converted to ' '
|
- '_' in names is converted to ' '
|
||||||
|
|||||||
+31
-8
@@ -7,6 +7,7 @@
|
|||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
static WINDOW* info_tab;
|
static WINDOW* info_tab;
|
||||||
|
|
||||||
@@ -141,10 +142,10 @@ static U16 strUtf8Symbols(const std::string& str)
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
U16 Person::boxWidth() const
|
/* U16 Person::boxWidth() const */
|
||||||
{
|
/* { */
|
||||||
return strUtf8Symbols(name) + 4;
|
/* return strUtf8Symbols(name) + 4; */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
|
|
||||||
/* WINDOW* Person::createPad()const */
|
/* WINDOW* Person::createPad()const */
|
||||||
@@ -158,9 +159,30 @@ U16 Person::boxWidth() const
|
|||||||
/* return pad; */
|
/* return pad; */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
void Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse, bool isSpouse, bool hasKids) const
|
U16 Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse,
|
||||||
|
bool hasParents, bool hasKids, bool wholeName) const
|
||||||
{
|
{
|
||||||
const U16 width = boxWidth(); /* pad width */
|
string display_name; /* todo remove? */
|
||||||
|
if(wholeName)
|
||||||
|
{
|
||||||
|
display_name = name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t space = name.find(' ');
|
||||||
|
if(space != string::npos)
|
||||||
|
{
|
||||||
|
/* name[space] = '\0'; */
|
||||||
|
display_name = name.substr(0, space);
|
||||||
|
/* name[space] = ' '; */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
display_name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const U16 width = strUtf8Symbols(display_name) + 4; /* pad width */
|
||||||
|
|
||||||
if(willBeVisible(drawY, drawX, BOX_HEIGHT, width))
|
if(willBeVisible(drawY, drawX, BOX_HEIGHT, width))
|
||||||
{
|
{
|
||||||
@@ -173,14 +195,15 @@ void Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpous
|
|||||||
/* wattron(pad, color_pair); */
|
/* wattron(pad, color_pair); */
|
||||||
|
|
||||||
wborder(pad, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
|
wborder(pad, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
|
||||||
isSpouse ? ACS_TTEE : ACS_LTEE, hasSpouse ? ACS_TTEE : ACS_URCORNER,
|
hasParents ? ACS_LTEE : ACS_TTEE, hasSpouse ? ACS_TTEE : ACS_URCORNER,
|
||||||
hasKids ? ACS_LTEE : ACS_LLCORNER, ACS_LRCORNER );
|
hasKids ? ACS_LTEE : ACS_LLCORNER, ACS_LRCORNER );
|
||||||
|
|
||||||
mvwaddstr(pad, 2, 2, name.data());
|
mvwaddstr(pad, 2, 2, display_name.data());
|
||||||
|
|
||||||
/* wattroff(pad, color_pair); */
|
/* wattroff(pad, color_pair); */
|
||||||
|
|
||||||
drawpad(pad, drawY, drawX);
|
drawpad(pad, drawY, drawX);
|
||||||
delwin(pad);
|
delwin(pad);
|
||||||
}
|
}
|
||||||
|
return width;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -55,12 +55,14 @@ public:
|
|||||||
void displayInfo() const;
|
void displayInfo() const;
|
||||||
|
|
||||||
const EventTime& birth() const { return birth_; };
|
const EventTime& birth() const { return birth_; };
|
||||||
U16 boxWidth() const;
|
/* U16 boxWidth(bool wholeName) const; */
|
||||||
|
|
||||||
/* Draw a Person's box on the terminal
|
/* Draw a Person's box on the terminal
|
||||||
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)
|
||||||
|
hasSpouse, hasSpouse, hasChildren - wheather the person has them on display
|
||||||
returns the width of the box*/
|
returns the width of the box*/
|
||||||
void draw(I16 drawY, I16 drawX, bool selected, bool hasSpouse, bool isSpouse, bool hasChildren=false) const;
|
U16 draw(I16 drawY, I16 drawX, bool selected, bool hasSpouse,
|
||||||
|
bool hasParents, bool hasChildren=false, bool wholeName=true) const;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
EventTime birth_;
|
EventTime birth_;
|
||||||
|
|||||||
+27
-18
@@ -436,7 +436,6 @@ static void displayHelp()
|
|||||||
werase(help_tab);
|
werase(help_tab);
|
||||||
wrefresh(help_tab); /* todo: dont update */
|
wrefresh(help_tab); /* todo: dont update */
|
||||||
delwin(help_tab);
|
delwin(help_tab);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tree::display()
|
void Tree::display()
|
||||||
@@ -446,7 +445,7 @@ void Tree::display()
|
|||||||
I32 c;
|
I32 c;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
c = std::toupper(getch());
|
c = getch();
|
||||||
|
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
@@ -456,8 +455,9 @@ void Tree::display()
|
|||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
case '\n':
|
case '\n':
|
||||||
/* focused_ = selected_; */
|
|
||||||
focused_ = findRootAncestor(selected_);
|
focused_ = findRootAncestor(selected_);
|
||||||
|
offsetX_ = 0;
|
||||||
|
offsetY_ = 0;
|
||||||
draw();
|
draw();
|
||||||
break;
|
break;
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
@@ -476,26 +476,35 @@ void Tree::display()
|
|||||||
++offsetY_;
|
++offsetY_;
|
||||||
draw();
|
draw();
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case '=':
|
||||||
|
case '+':
|
||||||
|
zoom_ = 1;
|
||||||
|
draw();
|
||||||
|
break;
|
||||||
|
case '-':
|
||||||
|
zoom_ = 0;
|
||||||
|
draw();
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
selectLeft();
|
selectLeft();
|
||||||
break;
|
break;
|
||||||
case 'J':
|
case 'j':
|
||||||
selectDown();
|
selectDown();
|
||||||
break;
|
break;
|
||||||
case 'K':
|
case 'k':
|
||||||
selectUp();
|
selectUp();
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'l':
|
||||||
selectRight();
|
selectRight();
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'i':
|
||||||
people[selected_].displayInfo();
|
people[selected_].displayInfo();
|
||||||
draw();
|
draw();
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(c != 'W');
|
while(c != 'w');
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tree::updateRels(person_id id)
|
void Tree::updateRels(person_id id)
|
||||||
@@ -535,8 +544,8 @@ void Tree::draw() const
|
|||||||
erase(); //Clear the screen
|
erase(); //Clear the screen
|
||||||
wnoutrefresh(stdscr);
|
wnoutrefresh(stdscr);
|
||||||
|
|
||||||
I16 drawY = offsetY_/* (LINES) / 2 */;
|
I16 drawY = offsetY_;
|
||||||
I16 drawX = offsetX_/* (COLS) / 2 */;
|
I16 drawX = offsetX_;
|
||||||
drawLineWithWives(focused_, drawY, drawX);
|
drawLineWithWives(focused_, drawY, drawX);
|
||||||
|
|
||||||
doupdate();
|
doupdate();
|
||||||
@@ -710,15 +719,15 @@ I16 Tree::drawLineWithWives(const person_id id, I16 drawY, const I16 drawX) cons
|
|||||||
spouse = rel.id;
|
spouse = rel.id;
|
||||||
}
|
}
|
||||||
const size_t numKids = children.size();
|
const size_t numKids = children.size();
|
||||||
person.draw(drawY, drawX,
|
U16 person_w = person.draw(drawY, drawX,
|
||||||
id == selected_, spouse!=Nobody, false, numKids!=0);
|
id == selected_, spouse!=Nobody, true, numKids!=0, zoom_==1);
|
||||||
|
|
||||||
U16 spouse_width = 0;
|
U16 spouse_w = 0;
|
||||||
if (spouse != Nobody)
|
if (spouse != Nobody)
|
||||||
{
|
{
|
||||||
people[spouse].draw(drawY, drawX + person.boxWidth() + spouse_dist_,
|
U16 spouse_box = people[spouse].draw(drawY, drawX + person_w + spouse_dist_,
|
||||||
spouse == selected_, false, true);
|
spouse == selected_, false, false, false, zoom_==1);
|
||||||
spouse_width = spouse_dist_ + people[spouse].boxWidth();
|
spouse_w = spouse_dist_ + spouse_box;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto childX = drawX;
|
auto childX = drawX;
|
||||||
@@ -740,7 +749,7 @@ I16 Tree::drawLineWithWives(const person_id id, I16 drawY, const I16 drawX) cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return max(drawX + person.boxWidth() + dist_between_ + spouse_width,
|
return max(drawX + person_w + dist_between_ + spouse_w,
|
||||||
childX);
|
childX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ private:
|
|||||||
person_id selected_ = 0;
|
person_id selected_ = 0;
|
||||||
I16 offsetX_ = 0; /* offset of the tree in relation to the screen*/
|
I16 offsetX_ = 0; /* offset of the tree in relation to the screen*/
|
||||||
I16 offsetY_ = 0;
|
I16 offsetY_ = 0;
|
||||||
|
U8 zoom_ = 0;
|
||||||
U8 dist_between_ = 1; /* distance between people */
|
U8 dist_between_ = 1; /* distance between people */
|
||||||
U8 spouse_dist_ = 0; /* distance between spouses */
|
U8 spouse_dist_ = 0; /* distance between spouses */
|
||||||
//Search, ect.
|
//Search, ect.
|
||||||
|
|||||||
Reference in New Issue
Block a user