summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-20 07:11:52 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-20 07:12:05 +0300
commit060666530935528610fceeadb7ee1b613587c888 (patch)
treecfa05219a7baa695906055b18dd8de632f24f509 /src
parent28fe175dc86efedf4415bba4d0c93d58ec643228 (diff)
GmDocument: Collapse margins in narrow layout
Diffstat (limited to 'src')
-rw-r--r--src/gmdocument.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index da369c8c..14065fa1 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -340,7 +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 isVeryNarrow = d->size.x <= 75 * gap_Text;
344 const iBool isDarkBg = isDark_GmDocumentTheme( 344 const iBool isDarkBg = isDark_GmDocumentTheme(
345 isDark_ColorTheme(colorTheme_App()) ? prefs->docThemeDark : prefs->docThemeLight); 345 isDark_ColorTheme(colorTheme_App()) ? prefs->docThemeDark : prefs->docThemeLight);
346 /* TODO: Collect these parameters into a GmTheme. */ 346 /* TODO: Collect these parameters into a GmTheme. */
@@ -367,9 +367,15 @@ static void doLayout_GmDocument_(iGmDocument *d) {
367 tmHeading3_ColorId, 367 tmHeading3_ColorId,
368 tmLinkText_ColorId, 368 tmLinkText_ColorId,
369 }; 369 };
370 const float indents[max_GmLineType] = { 370 float indents[max_GmLineType] = {
371 5, 10, 5, isNarrow ? 5 : 10, 0, 0, 0, 5 371 5, 10, 5, isNarrow ? 5 : 10, 0, 0, 0, 5
372 }; 372 };
373 if (isVeryNarrow) {
374 /* Further reduce the margins. */
375 indents[text_GmLineType] -= 5;
376 indents[bullet_GmLineType] -= 5;
377 indents[preformatted_GmLineType] -= 5;
378 }
373 static const float topMargin[max_GmLineType] = { 379 static const float topMargin[max_GmLineType] = {
374 0.0f, 0.333f, 1.0f, 0.5f, 2.0f, 1.5f, 1.25f, 0.25f 380 0.0f, 0.333f, 1.0f, 0.5f, 2.0f, 1.5f, 1.25f, 0.25f
375 }; 381 };
@@ -694,20 +700,15 @@ static void doLayout_GmDocument_(iGmDocument *d) {
694 rightMargin = (type == text_GmLineType || type == bullet_GmLineType || 700 rightMargin = (type == text_GmLineType || type == bullet_GmLineType ||
695 type == quote_GmLineType ? 4 : 0); 701 type == quote_GmLineType ? 4 : 0);
696 } 702 }
697
698 const iBool isWordWrapped = 703 const iBool isWordWrapped =
699 (d->format == plainText_GmDocumentFormat ? prefs->plainTextWrap : !isPreformat); 704 (d->format == plainText_GmDocumentFormat ? prefs->plainTextWrap : !isPreformat);
700 if (isPreformat && d->format != plainText_GmDocumentFormat) { 705 if (isPreformat && d->format != plainText_GmDocumentFormat) {
701 /* Remember the top left coordinates of the block (first line of block). */ 706 /* Remember the top left coordinates of the block (first line of block). */
702 iGmPreMeta *meta = at_Array(&d->preMeta, preId - 1); 707 iGmPreMeta *meta = at_Array(&d->preMeta, preId - 1);
703 if (~meta->flags & topLeft_GmPreMetaFlag) { 708 if (~meta->flags & topLeft_GmPreMetaFlag) {
704 meta->pixelRect.pos = pos; //, indent * gap_Text); 709 meta->pixelRect.pos = pos;
705 meta->flags |= topLeft_GmPreMetaFlag; 710 meta->flags |= topLeft_GmPreMetaFlag;
706 } 711 }
707 /* Collapse indentation if too wide. */
708 if (width_Rect(meta->pixelRect) > d->size.x - (indent + rightMargin) * gap_Text) {
709 indent = 0;
710 }
711 } 712 }
712 iAssert(!isEmpty_Range(&runLine)); /* must have something at this point */ 713 iAssert(!isEmpty_Range(&runLine)); /* must have something at this point */
713 while (!isEmpty_Range(&runLine)) { 714 while (!isEmpty_Range(&runLine)) {