diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-09 21:43:23 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-10 06:29:31 +0300 |
commit | b257fc841afa92676a16a4c7ac58f0512561cfd5 (patch) | |
tree | 14cdf661c211167364952aaf73442a2616ef4877 /src | |
parent | f9ef1545a644b3f39d300c5a51cb0d8804e6fa09 (diff) |
GmDocument: Very narrow layout
The right margin is collapsed if the layout is very narrow, for example a zoomed phone.
Diffstat (limited to 'src')
-rw-r--r-- | src/gmdocument.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 7ee7839e..e756a9d9 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -340,6 +340,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
340 | const iPrefs *prefs = prefs_App(); | 340 | const iPrefs *prefs = prefs_App(); |
341 | const iBool isMono = isForcedMonospace_GmDocument_(d); | 341 | const iBool isMono = isForcedMonospace_GmDocument_(d); |
342 | const iBool isNarrow = d->size.x < 90 * gap_Text; | 342 | const iBool isNarrow = d->size.x < 90 * gap_Text; |
343 | const iBool isVeryNarrow = d->size.x <= 65 * gap_Text; | ||
343 | const iBool isDarkBg = isDark_GmDocumentTheme( | 344 | const iBool isDarkBg = isDark_GmDocumentTheme( |
344 | isDark_ColorTheme(colorTheme_App()) ? prefs->docThemeDark : prefs->docThemeLight); | 345 | isDark_ColorTheme(colorTheme_App()) ? prefs->docThemeDark : prefs->docThemeLight); |
345 | /* TODO: Collect these parameters into a GmTheme. */ | 346 | /* TODO: Collect these parameters into a GmTheme. */ |
@@ -685,8 +686,15 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
685 | if (!prefs->quoteIcon && type == quote_GmLineType) { | 686 | if (!prefs->quoteIcon && type == quote_GmLineType) { |
686 | run.flags |= quoteBorder_GmRunFlag; | 687 | run.flags |= quoteBorder_GmRunFlag; |
687 | } | 688 | } |
688 | rightMargin = (type == text_GmLineType || type == bullet_GmLineType || | 689 | /* The right margin is used for balancing lines horizontally. */ |
689 | type == quote_GmLineType ? 4 : 0); | 690 | if (isVeryNarrow) { |
691 | rightMargin = 0; | ||
692 | } | ||
693 | else { | ||
694 | rightMargin = (type == text_GmLineType || type == bullet_GmLineType || | ||
695 | type == quote_GmLineType ? 4 : 0); | ||
696 | } | ||
697 | |||
690 | const iBool isWordWrapped = | 698 | const iBool isWordWrapped = |
691 | (d->format == plainText_GmDocumentFormat ? prefs->plainTextWrap : !isPreformat); | 699 | (d->format == plainText_GmDocumentFormat ? prefs->plainTextWrap : !isPreformat); |
692 | if (isPreformat && d->format != plainText_GmDocumentFormat) { | 700 | if (isPreformat && d->format != plainText_GmDocumentFormat) { |