From 83e936f53d3129433edfdb229a2faf78e48687b1 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 24 Feb 2021 12:41:46 +0200 Subject: GmDocument: Media type flexibility Allow defining new inline media types. --- src/gmdocument.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/gmdocument.c') diff --git a/src/gmdocument.c b/src/gmdocument.c index e33be932..5e762dff 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c @@ -285,7 +285,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { 0.0f, 0.333f, 1.0f, 0.5f, 2.0f, 1.5f, 1.0f, 0.25f }; static const float bottomMargin[max_GmLineType] = { - 0.0f, 0.333f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f + 0.0f, 0.333f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f, 0.25f }; static const char *arrow = "\u27a4"; static const char *envelope = "\U0001f4e7"; @@ -578,15 +578,17 @@ static void doLayout_GmDocument_(iGmDocument *d) { const iInt2 maxSize = mulf_I2(img.size, get_Window()->pixelRatio); if (width_Rect(run.visBounds) > maxSize.x) { /* Don't scale the image up. */ - run.visBounds.size.y = run.visBounds.size.y * maxSize.x / width_Rect(run.visBounds); + run.visBounds.size.y = + run.visBounds.size.y * maxSize.x / width_Rect(run.visBounds); run.visBounds.size.x = maxSize.x; - run.visBounds.pos.x = run.bounds.size.x / 2 - width_Rect(run.visBounds) / 2; - run.bounds.size.y = run.visBounds.size.y; + run.visBounds.pos.x = run.bounds.size.x / 2 - width_Rect(run.visBounds) / 2; + run.bounds.size.y = run.visBounds.size.y; } - run.text = iNullRange; - run.font = 0; - run.color = 0; - run.imageId = imageId; + run.text = iNullRange; + run.font = 0; + run.color = 0; + run.mediaType = image_GmRunMediaType; + run.mediaId = imageId; pushBack_Array(&d->layout, &run); pos.y += run.bounds.size.y + margin; } @@ -608,7 +610,8 @@ static void doLayout_GmDocument_(iGmDocument *d) { run.visBounds = run.bounds; run.text = iNullRange; run.color = 0; - run.audioId = audioId; + run.mediaType = audio_GmRunMediaType; + run.mediaId = audioId; pushBack_Array(&d->layout, &run); pos.y += run.bounds.size.y + margin; } -- cgit v1.2.3