diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-07 13:14:59 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-07 13:14:59 +0300 |
commit | ab893836d09a178460b9e64e76e42c89836e5721 (patch) | |
tree | 4f802d963792fb8692dad8d61a0010b12d1210a8 /src/gmdocument.c | |
parent | c3e5a0c2d4168515804dc0823c93d0522982108c (diff) |
Added image colorization preference
Option to colorize images to grayscale, text color, or preformatted color.
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r-- | src/gmdocument.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 75f6f06b..4e92c89c 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -464,6 +464,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
464 | const iBool isNarrow = d->size.x < 90 * gap_Text; | 464 | const iBool isNarrow = d->size.x < 90 * gap_Text; |
465 | const iBool isVeryNarrow = d->size.x <= 70 * gap_Text; | 465 | const iBool isVeryNarrow = d->size.x <= 70 * gap_Text; |
466 | const iBool isExtremelyNarrow = d->size.x <= 60 * gap_Text; | 466 | const iBool isExtremelyNarrow = d->size.x <= 60 * gap_Text; |
467 | const iBool isFullWidthImages = (d->outsideMargin < 5 * gap_UI); | ||
467 | const iBool isDarkBg = isDark_GmDocumentTheme( | 468 | const iBool isDarkBg = isDark_GmDocumentTheme( |
468 | isDark_ColorTheme(colorTheme_App()) ? prefs->docThemeDark : prefs->docThemeLight); | 469 | isDark_ColorTheme(colorTheme_App()) ? prefs->docThemeDark : prefs->docThemeLight); |
469 | /* TODO: Collect these parameters into a GmTheme. */ | 470 | /* TODO: Collect these parameters into a GmTheme. */ |
@@ -817,7 +818,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
817 | rts.layoutWidth = d->size.x; | 818 | rts.layoutWidth = d->size.x; |
818 | rts.indent = indent * gap_Text; | 819 | rts.indent = indent * gap_Text; |
819 | /* The right margin is used for balancing lines horizontally. */ | 820 | /* The right margin is used for balancing lines horizontally. */ |
820 | if (isVeryNarrow) { | 821 | if (isVeryNarrow || isFullWidthImages) { |
821 | rts.rightMargin = 0; | 822 | rts.rightMargin = 0; |
822 | } | 823 | } |
823 | else { | 824 | else { |
@@ -900,14 +901,15 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
900 | pos.y += margin; | 901 | pos.y += margin; |
901 | run.bounds.pos = pos; | 902 | run.bounds.pos = pos; |
902 | run.bounds.size.x = d->size.x; | 903 | run.bounds.size.x = d->size.x; |
904 | const float aspect = (float) imgSize.y / (float) imgSize.x; | ||
905 | run.bounds.size.y = d->size.x * aspect; | ||
903 | /* Extend the image to full width, including outside margin, if the viewport | 906 | /* Extend the image to full width, including outside margin, if the viewport |
904 | is narrow enough. */ | 907 | is narrow enough. */ |
905 | if (d->outsideMargin < 5 * gap_UI) { | 908 | if (isFullWidthImages) { |
906 | run.bounds.size.x += d->outsideMargin * 2; | 909 | run.bounds.size.x += d->outsideMargin * 2; |
910 | run.bounds.size.y += d->outsideMargin * 2 * aspect; | ||
907 | run.bounds.pos.x -= d->outsideMargin; | 911 | run.bounds.pos.x -= d->outsideMargin; |
908 | } | 912 | } |
909 | const float aspect = (float) imgSize.y / (float) imgSize.x; | ||
910 | run.bounds.size.y = d->size.x * aspect; | ||
911 | run.visBounds = run.bounds; | 913 | run.visBounds = run.bounds; |
912 | const iInt2 maxSize = mulf_I2(imgSize, get_Window()->pixelRatio); | 914 | const iInt2 maxSize = mulf_I2(imgSize, get_Window()->pixelRatio); |
913 | if (width_Rect(run.visBounds) > maxSize.x) { | 915 | if (width_Rect(run.visBounds) > maxSize.x) { |