diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-24 10:20:57 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-24 10:20:57 +0200 |
commit | 8f104a9916070fceb53aa5e3f4ad8dfecc40055d (patch) | |
tree | f846818c2b13ede9630e98b35f9b2842160d71c3 /src/ui/documentwidget.c | |
parent | ec826e393ad5feba5960662a75b62adafc7b6673 (diff) |
DocumentWidget: Expand/shrink page margin
Based on the width of the document, make the horizontal margins larger or smaller.
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 0722976a..92966538 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -351,10 +351,14 @@ static void requestFinished_DocumentWidget_(iAnyObject *obj) { | |||
351 | } | 351 | } |
352 | 352 | ||
353 | static int documentWidth_DocumentWidget_(const iDocumentWidget *d) { | 353 | static int documentWidth_DocumentWidget_(const iDocumentWidget *d) { |
354 | const iWidget *w = constAs_Widget(d); | 354 | const iWidget *w = constAs_Widget(d); |
355 | const iRect bounds = bounds_Widget(w); | 355 | const iRect bounds = bounds_Widget(w); |
356 | const iPrefs * prefs = prefs_App(); | 356 | const iPrefs * prefs = prefs_App(); |
357 | return iMini(iMax(50 * gap_UI, bounds.size.x - gap_UI * d->pageMargin * 2), | 357 | const int minWidth = 50 * gap_UI; /* lines must fit a word at least */ |
358 | const float adjust = iClamp((float) bounds.size.x / gap_UI / 11 - 12, | ||
359 | -2.0f, 10.0f); /* adapt to width */ | ||
360 | //printf("%f\n", adjust); fflush(stdout); | ||
361 | return iMini(iMax(minWidth, bounds.size.x - gap_UI * (d->pageMargin + adjust) * 2), | ||
358 | fontSize_UI * prefs->lineWidth * prefs->zoomPercent / 100); | 362 | fontSize_UI * prefs->lineWidth * prefs->zoomPercent / 100); |
359 | } | 363 | } |
360 | 364 | ||