summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-08 18:59:45 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-08 18:59:45 +0200
commitf5d39a1487db6259cc7a99e98d2fe70e29c61c46 (patch)
treecb972fa0a163cc72a476985185476a98b0ee92ec /src/gmdocument.c
parenta31b3f27037cc75b733a34871cfadc9707055b16 (diff)
Improved custom link icons; link list spacing
Link lists and bullet lists are spaced the same way.
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 54b7ad56..660b05fd 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -469,10 +469,6 @@ static void doLayout_GmDocument_(iGmDocument *d) {
469 if (!isPreformat || (prevType != preformatted_GmLineType)) { 469 if (!isPreformat || (prevType != preformatted_GmLineType)) {
470 int required = 470 int required =
471 iMax(topMargin[type], bottomMargin[prevType]) * lineHeight_Text(paragraph_FontId); 471 iMax(topMargin[type], bottomMargin[prevType]) * lineHeight_Text(paragraph_FontId);
472 if (type == link_GmLineType && prevType == link_GmLineType) {
473 /* Reduced margin between consecutive links. */
474 required *= 0.75f;
475 }
476 if (type == quote_GmLineType && prevType == quote_GmLineType) { 472 if (type == quote_GmLineType && prevType == quote_GmLineType) {
477 /* No margin between consecutive quote lines. */ 473 /* No margin between consecutive quote lines. */
478 required = 0; 474 required = 0;
@@ -541,8 +537,19 @@ static void doLayout_GmDocument_(iGmDocument *d) {
541 icon.text = link->labelIcon; 537 icon.text = link->labelIcon;
542 } 538 }
543 icon.font = regular_FontId; 539 icon.font = regular_FontId;
544 if (link->flags & remote_GmLinkFlag) { 540 /* Center the icon within the indentation. */ {
545 icon.visBounds.pos.x -= gap_Text / 2; 541 const iRect visBounds = visualBounds_Text(icon.font, icon.text);
542 const int visWidth = width_Rect(visBounds);
543 /* Keep the icon aligned to the left edge. */
544 icon.visBounds.pos.x -= left_Rect(visBounds);
545 if (visWidth > width_Rect(icon.visBounds)) {
546 /* ...unless it's a wide icon, in which case move it to the left. */
547 icon.visBounds.pos.x -= visWidth - width_Rect(icon.visBounds);
548 }
549 else if (visWidth < width_Rect(icon.visBounds) * 3 / 4) {
550 /* ...or a narrow icon, which needs to be centered but leave a gap. */
551 icon.visBounds.pos.x += (width_Rect(icon.visBounds) * 3 / 4 - visWidth) / 2;
552 }
546 } 553 }
547 icon.color = linkColor_GmDocument(d, run.linkId, icon_GmLinkPart); 554 icon.color = linkColor_GmDocument(d, run.linkId, icon_GmLinkPart);
548 icon.flags |= decoration_GmRunFlag; 555 icon.flags |= decoration_GmRunFlag;
@@ -750,6 +757,8 @@ static void setDerivedThemeColors_(enum iGmDocumentTheme theme) {
750 addSatLum_HSLColor(get_HSLColor(tmParagraph_ColorId), 0.3f, -0.025f)); 757 addSatLum_HSLColor(get_HSLColor(tmParagraph_ColorId), 0.3f, -0.025f));
751 } 758 }
752 } 759 }
760 set_Color(tmLinkCustomIconVisited_ColorId,
761 mix_Color(get_Color(tmLinkIconVisited_ColorId), get_Color(tmLinkIcon_ColorId), 0.5f));
753#if 0 762#if 0
754 set_Color(tmOutlineHeadingAbove_ColorId, get_Color(white_ColorId)); 763 set_Color(tmOutlineHeadingAbove_ColorId, get_Color(white_ColorId));
755 set_Color(tmOutlineHeadingBelow_ColorId, get_Color(black_ColorId)); 764 set_Color(tmOutlineHeadingBelow_ColorId, get_Color(black_ColorId));
@@ -1471,8 +1480,8 @@ enum iColorId linkColor_GmDocument(const iGmDocument *d, iGmLinkId linkId, enum
1471 return tmBadLink_ColorId; 1480 return tmBadLink_ColorId;
1472 } 1481 }
1473 if (link->flags & iconFromLabel_GmLinkFlag) { 1482 if (link->flags & iconFromLabel_GmLinkFlag) {
1474 return link->flags & visited_GmLinkFlag ? tmLinkTextHover_ColorId 1483 return link->flags & visited_GmLinkFlag ? tmLinkCustomIconVisited_ColorId
1475 : tmLinkText_ColorId; 1484 : tmLinkIcon_ColorId;
1476 } 1485 }
1477 if (link->flags & visited_GmLinkFlag) { 1486 if (link->flags & visited_GmLinkFlag) {
1478 return link->flags & www_GmLinkFlag ? tmHypertextLinkIconVisited_ColorId 1487 return link->flags & www_GmLinkFlag ? tmHypertextLinkIconVisited_ColorId