diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-27 13:39:25 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-27 13:39:25 +0300 |
commit | b924ad8d8180306f18434882ab922f8c54da4f98 (patch) | |
tree | e05d84c294e3f4cc7d9f66535e80ddcfcee92d9e /src/ui/sidebarwidget.c | |
parent | c75d710f1b81e273d2d4d385ef765702de533f1b (diff) |
Fixed icon alignments
Some of the icons in the Bookmarks list and lookup results were misaligned.
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r-- | src/ui/sidebarwidget.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 950db596..395138bb 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -1680,7 +1680,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1680 | : uiText_ColorId; | 1680 | : uiText_ColorId; |
1681 | iString str; | 1681 | iString str; |
1682 | init_String(&str); | 1682 | init_String(&str); |
1683 | appendChar_String(&str, d->icon ? d->icon : 0x1f588); | 1683 | appendChar_String(&str, d->icon ? d->icon : 0x1f588); |
1684 | const iRect iconArea = { addX_I2(pos, gap_UI), | 1684 | const iRect iconArea = { addX_I2(pos, gap_UI), |
1685 | init_I2(1.75f * lineHeight_Text(font), itemHeight) }; | 1685 | init_I2(1.75f * lineHeight_Text(font), itemHeight) }; |
1686 | drawCentered_Text(font, | 1686 | drawCentered_Text(font, |
@@ -1694,9 +1694,13 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1694 | deinit_String(&str); | 1694 | deinit_String(&str); |
1695 | const iInt2 textPos = addY_I2(topRight_Rect(iconArea), (itemHeight - lineHeight_Text(font)) / 2); | 1695 | const iInt2 textPos = addY_I2(topRight_Rect(iconArea), (itemHeight - lineHeight_Text(font)) / 2); |
1696 | drawRange_Text(font, textPos, fg, range_String(&d->label)); | 1696 | drawRange_Text(font, textPos, fg, range_String(&d->label)); |
1697 | const int metaFont = default_FontId; | ||
1698 | const int metaIconWidth = 4.5f * gap_UI; | ||
1697 | const iInt2 metaPos = | 1699 | const iInt2 metaPos = |
1698 | init_I2(right_Rect(itemRect) - advanceRange_Text(font, range_String(&d->meta)).x - | 1700 | init_I2(right_Rect(itemRect) - |
1699 | 2 * gap_UI - (scrollBarWidth ? scrollBarWidth - gap_UI : 0), | 1701 | length_String(&d->meta) * |
1702 | metaIconWidth | ||
1703 | - 2 * gap_UI - (blankWidth ? blankWidth - 1.5f * gap_UI : (gap_UI / 2)), | ||
1700 | textPos.y); | 1704 | textPos.y); |
1701 | fillRect_Paint(p, | 1705 | fillRect_Paint(p, |
1702 | init_Rect(metaPos.x, | 1706 | init_Rect(metaPos.x, |
@@ -1704,10 +1708,22 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1704 | right_Rect(itemRect) - metaPos.x, | 1708 | right_Rect(itemRect) - metaPos.x, |
1705 | height_Rect(itemRect)), | 1709 | height_Rect(itemRect)), |
1706 | bg); | 1710 | bg); |
1707 | drawRange_Text(font, | 1711 | iInt2 mpos = metaPos; |
1708 | metaPos, | 1712 | iStringConstIterator iter; |
1709 | isHover && isPressing ? fg : uiTextCaution_ColorId, | 1713 | init_StringConstIterator(&iter, &d->meta); |
1710 | range_String(&d->meta)); | 1714 | iRangecc range = { cstr_String(&d->meta), iter.pos }; |
1715 | while (iter.value) { | ||
1716 | next_StringConstIterator(&iter); | ||
1717 | range.end = iter.pos; | ||
1718 | iRect iconArea = { mpos, init_I2(metaIconWidth, lineHeight_Text(metaFont)) }; | ||
1719 | iRect visBounds = visualBounds_Text(metaFont, range); | ||
1720 | drawRange_Text(metaFont, | ||
1721 | sub_I2(mid_Rect(iconArea), mid_Rect(visBounds)), | ||
1722 | isHover && isPressing ? fg : uiTextCaution_ColorId, | ||
1723 | range); | ||
1724 | mpos.x += metaIconWidth; | ||
1725 | range.start = range.end; | ||
1726 | } | ||
1711 | } | 1727 | } |
1712 | else if (sidebar->mode == history_SidebarMode) { | 1728 | else if (sidebar->mode == history_SidebarMode) { |
1713 | iBeginCollect(); | 1729 | iBeginCollect(); |