diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-08 20:22:56 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-08 20:22:56 +0200 |
commit | 8f9e7eb9d9273d6c39fd2d6fa1f5dd3076840770 (patch) | |
tree | 640542646f37c6a360a06f14de4ba5fed975bfb4 | |
parent | f5d39a1487db6259cc7a99e98d2fe70e29c61c46 (diff) |
Show error placeholder if image is missing
IssueID #167
-rw-r--r-- | src/defs.h | 1 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 10 |
2 files changed, 10 insertions, 1 deletions
@@ -69,3 +69,4 @@ enum iFileVersion { | |||
69 | #define circle_Icon "\u25cf" | 69 | #define circle_Icon "\u25cf" |
70 | #define circleWhite_Icon "\u25cb" | 70 | #define circleWhite_Icon "\u25cb" |
71 | #define gear_Icon "\u2699" | 71 | #define gear_Icon "\u2699" |
72 | #define explosion_Icon "\U0001f4a5" | ||
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index f3083207..c9878f65 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -2844,12 +2844,20 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
2844 | const iInt2 origin = d->viewPos; | 2844 | const iInt2 origin = d->viewPos; |
2845 | if (run->mediaType == image_GmRunMediaType) { | 2845 | if (run->mediaType == image_GmRunMediaType) { |
2846 | SDL_Texture *tex = imageTexture_Media(media_GmDocument(d->widget->doc), run->mediaId); | 2846 | SDL_Texture *tex = imageTexture_Media(media_GmDocument(d->widget->doc), run->mediaId); |
2847 | const iRect dst = moved_Rect(run->visBounds, origin); | ||
2847 | if (tex) { | 2848 | if (tex) { |
2848 | const iRect dst = moved_Rect(run->visBounds, origin); | ||
2849 | fillRect_Paint(&d->paint, dst, tmBackground_ColorId); /* in case the image has alpha */ | 2849 | fillRect_Paint(&d->paint, dst, tmBackground_ColorId); /* in case the image has alpha */ |
2850 | SDL_RenderCopy(d->paint.dst->render, tex, NULL, | 2850 | SDL_RenderCopy(d->paint.dst->render, tex, NULL, |
2851 | &(SDL_Rect){ dst.pos.x, dst.pos.y, dst.size.x, dst.size.y }); | 2851 | &(SDL_Rect){ dst.pos.x, dst.pos.y, dst.size.x, dst.size.y }); |
2852 | } | 2852 | } |
2853 | else { | ||
2854 | drawRect_Paint(&d->paint, dst, tmQuoteIcon_ColorId); | ||
2855 | drawCentered_Text(uiLabel_FontId, | ||
2856 | dst, | ||
2857 | iFalse, | ||
2858 | tmQuote_ColorId, | ||
2859 | explosion_Icon " Error Loading Image"); | ||
2860 | } | ||
2853 | return; | 2861 | return; |
2854 | } | 2862 | } |
2855 | else if (run->mediaType) { | 2863 | else if (run->mediaType) { |