diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-14 15:14:12 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-14 15:14:12 +0200 |
commit | 056b79839f7b0ecb503f223e483d97841c917bc8 (patch) | |
tree | e3784c46dcd1701919a28e7cc7a7b9c548496cb5 | |
parent | f81dcd10b9c09524a00b3b819679eca1d7ad6bf5 (diff) |
DocumentWidget: Alignment excludes banner
Short pages are vertically centered, but the site banner should be excluded from this because it is not part of the actual page contents.
-rw-r--r-- | src/ui/documentwidget.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 6ec76c0a..e9753fec 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -327,14 +327,18 @@ static iRect documentBounds_DocumentWidget_(const iDocumentWidget *d) { | |||
327 | rect.pos.x = mid_Rect(bounds).x - rect.size.x / 2; | 327 | rect.pos.x = mid_Rect(bounds).x - rect.size.x / 2; |
328 | rect.pos.y = top_Rect(bounds); | 328 | rect.pos.y = top_Rect(bounds); |
329 | rect.size.y = height_Rect(bounds) - margin; | 329 | rect.size.y = height_Rect(bounds) - margin; |
330 | if (!hasSiteBanner_GmDocument(d->doc)) { | 330 | const iGmRun *banner = siteBanner_GmDocument(d->doc); |
331 | if (!banner) { | ||
331 | rect.pos.y += margin; | 332 | rect.pos.y += margin; |
332 | rect.size.y -= margin; | 333 | rect.size.y -= margin; |
333 | } | 334 | } |
334 | const iInt2 docSize = size_GmDocument(d->doc); | 335 | const iInt2 docSize = size_GmDocument(d->doc); |
335 | if (docSize.y < rect.size.y) { | 336 | if (docSize.y < rect.size.y) { |
336 | /* Center vertically if short. */ | 337 | /* Center vertically if short. There is one empty paragraph line's worth of margin |
337 | int offset = (rect.size.y - docSize.y) / 2; | 338 | between the banner and the page contents. */ |
339 | const int bannerHeight = banner ? height_Rect(banner->visBounds) : 0; | ||
340 | int offset = iMax(0, (rect.size.y + margin - docSize.y - bannerHeight - | ||
341 | lineHeight_Text(paragraph_FontId)) / 2); | ||
338 | rect.pos.y += offset; | 342 | rect.pos.y += offset; |
339 | rect.size.y = docSize.y; | 343 | rect.size.y = docSize.y; |
340 | } | 344 | } |