diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-06 10:52:10 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-06 10:52:10 +0200 |
commit | 24afe73aae2cedfb43345f014c601539161dded6 (patch) | |
tree | 3e4243196a9d40efd4e36e43dd09fc83e4cf07bf | |
parent | a73b54d8ab2164984c884caafb2e8f53d6557133 (diff) |
GmDocument: Narrow layout; indentation
Adjusted indentation for narrow (phone) layout.
-rw-r--r-- | src/gmdocument.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 5273f61c..e518b60c 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -277,6 +277,7 @@ static iBool isNormalized_GmDocument_(const iGmDocument *d) { | |||
277 | 277 | ||
278 | static void doLayout_GmDocument_(iGmDocument *d) { | 278 | static void doLayout_GmDocument_(iGmDocument *d) { |
279 | const iBool isMono = isForcedMonospace_GmDocument_(d); | 279 | const iBool isMono = isForcedMonospace_GmDocument_(d); |
280 | const iBool isNarrow = d->size.x < 90 * gap_Text; | ||
280 | /* TODO: Collect these parameters into a GmTheme. */ | 281 | /* TODO: Collect these parameters into a GmTheme. */ |
281 | const int fonts[max_GmLineType] = { | 282 | const int fonts[max_GmLineType] = { |
282 | isMono ? regularMonospace_FontId : paragraph_FontId, | 283 | isMono ? regularMonospace_FontId : paragraph_FontId, |
@@ -298,8 +299,8 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
298 | tmHeading3_ColorId, | 299 | tmHeading3_ColorId, |
299 | tmLinkText_ColorId, | 300 | tmLinkText_ColorId, |
300 | }; | 301 | }; |
301 | static const int indents[max_GmLineType] = { | 302 | const float indents[max_GmLineType] = { |
302 | 5, 10, 5, 10, 0, 0, 0, 5 | 303 | 5, 10, 5, isNarrow ? 5 : 10, 0, 0, 2.5f, 5 |
303 | }; | 304 | }; |
304 | static const float topMargin[max_GmLineType] = { | 305 | static const float topMargin[max_GmLineType] = { |
305 | 0.0f, 0.333f, 1.0f, 0.5f, 2.0f, 1.5f, 1.0f, 0.25f | 306 | 0.0f, 0.333f, 1.0f, 0.5f, 2.0f, 1.5f, 1.0f, 0.25f |
@@ -345,7 +346,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
345 | iRangecc line = contentLine; /* `line` will be trimmed later; would confuse nextSplit */ | 346 | iRangecc line = contentLine; /* `line` will be trimmed later; would confuse nextSplit */ |
346 | iGmRun run = { .color = white_ColorId }; | 347 | iGmRun run = { .color = white_ColorId }; |
347 | enum iGmLineType type; | 348 | enum iGmLineType type; |
348 | int indent = 0; | 349 | float indent = 0.0f; |
349 | int rightMargin = 0; | 350 | int rightMargin = 0; |
350 | /* Detect the type of the line. */ | 351 | /* Detect the type of the line. */ |
351 | if (!isPreformat) { | 352 | if (!isPreformat) { |
@@ -360,7 +361,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
360 | preFont = preformatted_FontId; | 361 | preFont = preformatted_FontId; |
361 | /* Use a smaller font if the block contents are wide. */ | 362 | /* Use a smaller font if the block contents are wide. */ |
362 | if (measurePreformattedBlock_GmDocument_(d, line.start, preFont).x > | 363 | if (measurePreformattedBlock_GmDocument_(d, line.start, preFont).x > |
363 | d->size.x - indents[preformatted_GmLineType]) { | 364 | d->size.x - indents[preformatted_GmLineType] * gap_Text) { |
364 | preFont = preformattedSmall_FontId; | 365 | preFont = preformattedSmall_FontId; |
365 | } | 366 | } |
366 | trimLine_Rangecc_(&line, type); | 367 | trimLine_Rangecc_(&line, type); |
@@ -494,7 +495,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
494 | quoteRun.visBounds.size = advance_Text(quoteRun.font, quote); | 495 | quoteRun.visBounds.size = advance_Text(quoteRun.font, quote); |
495 | quoteRun.visBounds.pos = | 496 | quoteRun.visBounds.pos = |
496 | add_I2(pos, | 497 | add_I2(pos, |
497 | init_I2(indents[text_GmLineType] * gap_Text, | 498 | init_I2((indents[quote_GmLineType] - 5) * gap_Text, |
498 | lineHeight_Text(quote_FontId) / 2 - bottom_Rect(vis))); | 499 | lineHeight_Text(quote_FontId) / 2 - bottom_Rect(vis))); |
499 | quoteRun.bounds = zero_Rect(); /* just visual */ | 500 | quoteRun.bounds = zero_Rect(); /* just visual */ |
500 | quoteRun.flags |= decoration_GmRunFlag; | 501 | quoteRun.flags |= decoration_GmRunFlag; |