diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-06 21:51:28 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-06 21:51:28 +0300 |
commit | 7e63a70bc30173d2e15fda77777aef3caf0cc76c (patch) | |
tree | 470b981a44d346997a7ed7f33111d2bbfc245efb /src | |
parent | 0f47f2f20dd5e6f098f4358cdfea50cf2e87bc56 (diff) |
DocumentWidget: Adjusted document borders
Diffstat (limited to 'src')
-rw-r--r-- | src/gmdocument.c | 8 | ||||
-rw-r--r-- | src/gmdocument.h | 2 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 8 |
3 files changed, 15 insertions, 3 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 9b7bd630..5f5e8ad0 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -857,6 +857,14 @@ iInt2 size_GmDocument(const iGmDocument *d) { | |||
857 | return d->size; | 857 | return d->size; |
858 | } | 858 | } |
859 | 859 | ||
860 | iBool hasSiteBanner_GmDocument(const iGmDocument *d) { | ||
861 | if (isEmpty_Array(&d->layout)) { | ||
862 | return iFalse; | ||
863 | } | ||
864 | const iGmRun *first = constFront_Array(&d->layout); | ||
865 | return (first->flags & siteBanner_GmRunFlag) != 0; | ||
866 | } | ||
867 | |||
860 | iRangecc findText_GmDocument(const iGmDocument *d, const iString *text, const char *start) { | 868 | iRangecc findText_GmDocument(const iGmDocument *d, const iString *text, const char *start) { |
861 | const char * src = constBegin_String(&d->source); | 869 | const char * src = constBegin_String(&d->source); |
862 | const size_t startPos = (start ? start - src : 0); | 870 | const size_t startPos = (start ? start - src : 0); |
diff --git a/src/gmdocument.h b/src/gmdocument.h index 42639357..7a0f21ee 100644 --- a/src/gmdocument.h +++ b/src/gmdocument.h | |||
@@ -75,7 +75,7 @@ typedef void (*iGmDocumentRenderFunc)(void *, const iGmRun *); | |||
75 | 75 | ||
76 | void render_GmDocument (const iGmDocument *, iRangei visRangeY, iGmDocumentRenderFunc render, void *); | 76 | void render_GmDocument (const iGmDocument *, iRangei visRangeY, iGmDocumentRenderFunc render, void *); |
77 | iInt2 size_GmDocument (const iGmDocument *); | 77 | iInt2 size_GmDocument (const iGmDocument *); |
78 | iInt2 sizeWithoutBanner_GmDocument (const iGmDocument *); | 78 | iBool hasSiteBanner_GmDocument(const iGmDocument *); |
79 | 79 | ||
80 | iRangecc findText_GmDocument (const iGmDocument *, const iString *text, const char *start); | 80 | iRangecc findText_GmDocument (const iGmDocument *, const iString *text, const char *start); |
81 | iRangecc findTextBefore_GmDocument (const iGmDocument *, const iString *text, const char *before); | 81 | iRangecc findTextBefore_GmDocument (const iGmDocument *, const iString *text, const char *before); |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 3455db64..6d9c3451 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -168,8 +168,12 @@ static iRect documentBounds_DocumentWidget_(const iDocumentWidget *d) { | |||
168 | iRect rect; | 168 | iRect rect; |
169 | rect.size.x = documentWidth_DocumentWidget_(d); | 169 | rect.size.x = documentWidth_DocumentWidget_(d); |
170 | rect.pos.x = bounds.size.x / 2 - rect.size.x / 2; | 170 | rect.pos.x = bounds.size.x / 2 - rect.size.x / 2; |
171 | rect.pos.y = top_Rect(bounds) + margin; | 171 | rect.pos.y = top_Rect(bounds); |
172 | rect.size.y = height_Rect(bounds) - 2 * margin; | 172 | rect.size.y = height_Rect(bounds) - margin; |
173 | if (!hasSiteBanner_GmDocument(d->doc)) { | ||
174 | rect.pos.y += margin; | ||
175 | rect.size.y -= margin; | ||
176 | } | ||
173 | iInt2 docSize = addY_I2(size_GmDocument(d->doc), 0 /*-lineHeight_Text(banner_FontId) * 2*/); | 177 | iInt2 docSize = addY_I2(size_GmDocument(d->doc), 0 /*-lineHeight_Text(banner_FontId) * 2*/); |
174 | if (docSize.y < rect.size.y) { | 178 | if (docSize.y < rect.size.y) { |
175 | /* Center vertically if short. */ | 179 | /* Center vertically if short. */ |