summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-25 12:09:28 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-25 12:09:28 +0200
commit45049903a304a6762d5656890213c8ad5a1db3c3 (patch)
tree11335323e83e268120d69434d14298f6dadf7a2d /src/gmdocument.c
parentd8b789caf6f5c2ab6ce435f51075a4a4cc83db4b (diff)
Consolidating media handling
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 5e762dff..72bd0f33 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -559,8 +559,9 @@ static void doLayout_GmDocument_(iGmDocument *d) {
559 const iMediaId imageId = findLinkImage_Media(d->media, run.linkId); 559 const iMediaId imageId = findLinkImage_Media(d->media, run.linkId);
560 const iMediaId audioId = !imageId ? findLinkAudio_Media(d->media, run.linkId) : 0; 560 const iMediaId audioId = !imageId ? findLinkAudio_Media(d->media, run.linkId) : 0;
561 if (imageId) { 561 if (imageId) {
562 iGmImageInfo img; 562 iGmMediaInfo img;
563 imageInfo_Media(d->media, imageId, &img); 563 imageInfo_Media(d->media, imageId, &img);
564 const iInt2 imgSize = imageSize_Media(d->media, imageId);
564 /* Mark the link as having content. */ { 565 /* Mark the link as having content. */ {
565 iGmLink *link = at_PtrArray(&d->links, run.linkId - 1); 566 iGmLink *link = at_PtrArray(&d->links, run.linkId - 1);
566 link->flags |= content_GmLinkFlag; 567 link->flags |= content_GmLinkFlag;
@@ -572,10 +573,10 @@ static void doLayout_GmDocument_(iGmDocument *d) {
572 pos.y += margin; 573 pos.y += margin;
573 run.bounds.pos = pos; 574 run.bounds.pos = pos;
574 run.bounds.size.x = d->size.x; 575 run.bounds.size.x = d->size.x;
575 const float aspect = (float) img.size.y / (float) img.size.x; 576 const float aspect = (float) imgSize.y / (float) imgSize.x;
576 run.bounds.size.y = d->size.x * aspect; 577 run.bounds.size.y = d->size.x * aspect;
577 run.visBounds = run.bounds; 578 run.visBounds = run.bounds;
578 const iInt2 maxSize = mulf_I2(img.size, get_Window()->pixelRatio); 579 const iInt2 maxSize = mulf_I2(imgSize, get_Window()->pixelRatio);
579 if (width_Rect(run.visBounds) > maxSize.x) { 580 if (width_Rect(run.visBounds) > maxSize.x) {
580 /* Don't scale the image up. */ 581 /* Don't scale the image up. */
581 run.visBounds.size.y = 582 run.visBounds.size.y =
@@ -593,7 +594,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
593 pos.y += run.bounds.size.y + margin; 594 pos.y += run.bounds.size.y + margin;
594 } 595 }
595 else if (audioId) { 596 else if (audioId) {
596 iGmAudioInfo info; 597 iGmMediaInfo info;
597 audioInfo_Media(d->media, audioId, &info); 598 audioInfo_Media(d->media, audioId, &info);
598 /* Mark the link as having content. */ { 599 /* Mark the link as having content. */ {
599 iGmLink *link = at_PtrArray(&d->links, run.linkId - 1); 600 iGmLink *link = at_PtrArray(&d->links, run.linkId - 1);