Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stripe overflowing rounded corners #537

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions app/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function addPersonLabel(string $pid, string $out, SharedNoteList $sharedn
default:
$border_colour = $this->dot->settings["border_col"];
}
$out .= "<TD COLOR=\"" . $border_colour . "\" BORDER=\"1\" CELLPADDING=\"0\" PORT=\"" . $pid . "\">";
$out .= "<TD COLOR=\"" . $border_colour . "\" BORDER=\"1\" " . ($pid == "I_N" ? "COLSPAN=\"2\" WIDTH=\"50\"" : "") . " CELLPADDING=\"0\" PORT=\"" . $pid . "\">";
$out .= $this->printPersonLabel($pid, $sharednotes, $related);
$out .= "</TD>";
return $out;
Expand Down Expand Up @@ -300,8 +300,10 @@ function printPersonLabel(string $pid, SharedNoteList $sharednotes, bool $relate
// Draw table
if ($this->dot->settings["diagram_type"] == "combined") {
$out .= "<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"0\" BGCOLOR=\"" . $indi_bg_colour . "\" $href>";
$rounded = false;
} else {
$style = ($this->shouldBeRounded($i, $this->dot->settings['indi_tile_shape']) ? 'STYLE="ROUNDED" ' : '');
$rounded = $this->shouldBeRounded($i, $this->dot->settings['indi_tile_shape']);
$style = ($rounded ? 'STYLE="ROUNDED" ' : '');
$out .= "<TABLE " . $style . "COLOR=\"" . $border_colour . "\" BORDER=\"1\" CELLBORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"0\" BGCOLOR=\"" . $indi_bg_colour . "\" $href>";
}
$birthData = " $birthdate " . (empty($birthplace) ? "" : "($birthplace)");
Expand Down Expand Up @@ -331,11 +333,19 @@ function printPersonLabel(string $pid, SharedNoteList $sharednotes, bool $relate
$stripe_colour = '';
}
if ($stripe_colour !== '') {
$out .= "<TR><TD COLSPAN=\"6\" CELLPADDING=\"2\" BGCOLOR=\"$stripe_colour\" PORT=\"nam\" $size></TD></TR>";
if ($rounded) {
$out .= "<TR><TD WIDTH=\"7\"></TD><TD COLSPAN=\"6\" CELLPADDING=\"2\" BGCOLOR=\"$stripe_colour\" PORT=\"nam\" $size></TD><TD WIDTH=\"7\"></TD></TR>";
} else {
$out .= "<TR><TD COLSPAN=\"6\" CELLPADDING=\"2\" BGCOLOR=\"$stripe_colour\" PORT=\"nam\" $size></TD></TR>";
}
}
// Second row (photo, name, birth, death & burial data)
if ($detailsExist || $this->dot->isPhotoRequired()) {
$out .= "<TR>";
if ($rounded || $pid == "I_N") {
$out .= "<TD></TD>";
}

// Show photo
$out .= $this->getFactImage($pid, $detailsExist, "pic");
if ($detailsExist) {
Expand Down Expand Up @@ -381,7 +391,10 @@ function printPersonLabel(string $pid, SharedNoteList $sharednotes, bool $relate
$out .= $this->getFactImage($pid, $detailsExist, "pic_birth_first");
$out .= $this->getFactImage($pid, $detailsExist, "pic_death_first");
$out .= $this->getFactImage($pid, $detailsExist, "pic_burial_first");
$out .= "<TD CELLPADDING=\"10\"></TD></TR>";
if ($rounded) {
$out .= "<TD WIDTH=\"7\"></TD>";
}
$out .= "</TR>";
}
// Close table
$out .= "</TABLE>";
Expand All @@ -393,12 +406,12 @@ function printPersonLabel(string $pid, SharedNoteList $sharednotes, bool $relate
public function getFactImage(string $pid, bool $detailsExist, string $id) : string {
$out = "";
// Show photo
if (($detailsExist) && ($this->dot->isPhotoRequired())) {
if (($detailsExist || $pid == "I_N") && ($this->dot->isPhotoRequired())) {
if (isset($this->dot->individuals[$pid][$id]) && !empty($this->dot->individuals[$pid][$id])) {
$photo_size = floatval($this->dot->settings["photo_size"]) / 100;
$padding = $this->getPhotoPaddingSize();
if ($this->dot->settings["add_links"]) {
$out .= "<TD ROWSPAN=\"2\" CELLPADDING=\"$padding\" PORT=\"pic\" WIDTH=\"" . ($this->dot->settings["font_size"] * 4 * $photo_size) . "\" HEIGHT=\"" . ($this->dot->settings["font_size"] * 4 * $photo_size) . "\" FIXEDSIZE=\"true\" ALIGN=\"CENTER\" VALIGN=\"MIDDLE\"" . ($id != 'pic' ? " HREF=\"".$this->dot->convertToHTMLSC( $this->dot->individuals[$pid][$id . "_link"])."\"" : '') . "><IMG SCALE=\"true\" SRC=\"" . $this->dot->individuals[$pid][$id] . "\" ALT=\"" . $this->dot->individuals[$pid][$id . "_title"] . "\" /></TD>";
$out .= "<TD ROWSPAN=\"2\" COLSPAN=\"2\" CELLPADDING=\"$padding\" PORT=\"pic\" WIDTH=\"" . ($this->dot->settings["font_size"] * 4 * $photo_size) . "\" HEIGHT=\"" . ($this->dot->settings["font_size"] * 4 * $photo_size) . "\" FIXEDSIZE=\"true\" ALIGN=\"CENTER\" VALIGN=\"MIDDLE\"" . ($id != 'pic' ? " HREF=\"".$this->dot->convertToHTMLSC( $this->dot->individuals[$pid][$id . "_link"])."\"" : '') . "><IMG SCALE=\"true\" SRC=\"" . $this->dot->individuals[$pid][$id] . "\" ALT=\"" . $this->dot->individuals[$pid][$id . "_title"] . "\" /></TD>";
} else {
$out .= "<TD ROWSPAN=\"2\" CELLPADDING=\"$padding\" PORT=\"pic\" WIDTH=\"" . ($this->dot->settings["font_size"] * 4 * $photo_size) . "\" HEIGHT=\"" . ($this->dot->settings["font_size"] * 4 * $photo_size) . "\" FIXEDSIZE=\"true\" ALIGN=\"CENTER\" VALIGN=\"MIDDLE\"><IMG SCALE=\"true\" SRC=\"" . $this->dot->individuals[$pid][$id] . "\" ALT=\"" . $this->dot->individuals[$pid][$id . "_title"] . "\" /></TD>";
}
Expand Down Expand Up @@ -601,7 +614,7 @@ private function shouldBeRounded(Individual $i, int $option): bool
case 0:
default;
return false;
case 10:
case Person::TILE_SHAPE_ROUNDED:
return true;
case Person::TILE_SHAPE_SEX:
switch ($i->sex()) {
Expand Down
Loading