From 3e22cb42d56aec3075c3ee77f5ff4fca2ab41813 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sun, 4 Apr 2021 08:12:21 +0300 Subject: GmDocument: Fixed list item overdraw Bullet icon backgrounds were overlapping the bullet text, causing them to be overdrawn. --- src/gmdocument.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/gmdocument.c') diff --git a/src/gmdocument.c b/src/gmdocument.c index 8361e77b..c086898f 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c @@ -314,22 +314,25 @@ static enum iGmDocumentTheme currentTheme_(void) { static void alignDecoration_GmRun_(iGmRun *run, iBool isCentered) { const iRect visBounds = visualBounds_Text(run->font, run->text); const int visWidth = width_Rect(visBounds); + int xAdjust = 0; if (!isCentered) { /* Keep the icon aligned to the left edge. */ - run->visBounds.pos.x -= left_Rect(visBounds); + xAdjust -= left_Rect(visBounds); if (visWidth > width_Rect(run->visBounds)) { /* ...unless it's a wide icon, in which case move it to the left. */ - run->visBounds.pos.x -= visWidth - width_Rect(run->visBounds); + xAdjust -= visWidth - width_Rect(run->visBounds); } else if (visWidth < width_Rect(run->visBounds) * 3 / 4) { /* ...or a narrow icon, which needs to be centered but leave a gap. */ - run->visBounds.pos.x += (width_Rect(run->visBounds) * 3 / 4 - visWidth) / 2; + xAdjust += (width_Rect(run->visBounds) * 3 / 4 - visWidth) / 2; } } else { /* Centered. */ - run->visBounds.pos.x += (width_Rect(run->visBounds) - visWidth) / 2; + xAdjust += (width_Rect(run->visBounds) - visWidth) / 2; } + run->visBounds.pos.x += xAdjust; + run->visBounds.size.x -= xAdjust; } static void doLayout_GmDocument_(iGmDocument *d) { -- cgit v1.2.3