From 07b10a92a467a8a2ceb045e5eae37a1be440a1ca Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sat, 25 Jul 2020 17:29:51 +0300 Subject: DocumentWidget: Center vertically if document is short --- src/ui/documentwidget.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index aa24be48..2a3a2509 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -87,6 +87,12 @@ static iRect documentBounds_DocumentWidget_(const iDocumentWidget *d) { rect.pos.x = bounds.size.x / 2 - rect.size.x / 2; rect.pos.y = top_Rect(bounds) + margin; rect.size.y = height_Rect(bounds) - 2 * margin; + if (size_GmDocument(d->doc).y < rect.size.y) { + /* Center vertically if short. */ + int offset = (rect.size.y - size_GmDocument(d->doc).y) / 2; + rect.pos.y += offset; + rect.size.y = size_GmDocument(d->doc).y; + } return rect; } -- cgit v1.2.3