From 04da6153af1841effecc83b7e11c4e9ba1fb163a Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 18 Mar 2021 11:24:25 +0200 Subject: GmDocument: Trying out a footer Currently disabled. --- src/gmdocument.c | 9 +++++++++ src/gmdocument.h | 1 + src/ui/documentwidget.c | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/src/gmdocument.c b/src/gmdocument.c index 2c01290e..c3f0005c 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c @@ -702,6 +702,15 @@ static void doLayout_GmDocument_(iGmDocument *d) { prevNonBlankType = type; followsBlank = iFalse; } +#if 0 + /* Footer. */ + if (siteBanner_GmDocument(d)) { + iGmRun footer = { .flags = decoration_GmRunFlag | footer_GmRunFlag }; + footer.visBounds = (iRect){ pos, init_I2(d->size.x, lineHeight_Text(banner_FontId) * 1) }; + pushBack_Array(&d->layout, &footer); + pos.y += footer.visBounds.size.y; + } +#endif d->size.y = pos.y; /* Go over the preformatted blocks and mark them wide if at least one run is wide. */ { /* TODO: Store the dimensions and ranges for later access. */ diff --git a/src/gmdocument.h b/src/gmdocument.h index 05c6da09..840cf929 100644 --- a/src/gmdocument.h +++ b/src/gmdocument.h @@ -96,6 +96,7 @@ enum iGmRunFlags { siteBanner_GmRunFlag = iBit(4), /* area reserved for the site banner */ quoteBorder_GmRunFlag = iBit(5), wide_GmRunFlag = iBit(6), /* horizontally scrollable */ + footer_GmRunFlag = iBit(7), }; enum iGmRunMediaType { diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 83f270bd..72867133 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -2911,6 +2911,13 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { const iInt2 visPos = addX_I2(add_I2(run->visBounds.pos, origin), /* Preformatted runs can be scrolled. */ runOffset_DocumentWidget_(d->widget, run)); + if (run->flags & footer_GmRunFlag) { + iRect footerBack = + (iRect){ visPos, init_I2(width_Rect(d->widgetBounds), run->visBounds.size.y) }; + footerBack.pos.x = left_Rect(d->widgetBounds); + fillRect_Paint(&d->paint, footerBack, tmBackground_ColorId); + return; + } fillRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, tmBackground_ColorId); if (run->linkId && ~run->flags & decoration_GmRunFlag) { fg = linkColor_GmDocument(doc, run->linkId, isHover ? textHover_GmLinkPart : text_GmLinkPart); -- cgit v1.2.3