diff options
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r-- | src/gmdocument.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index bec89ca0..29e97300 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
37 | #include <the_Foundation/intset.h> | 37 | #include <the_Foundation/intset.h> |
38 | #include <the_Foundation/ptrarray.h> | 38 | #include <the_Foundation/ptrarray.h> |
39 | #include <the_Foundation/regexp.h> | 39 | #include <the_Foundation/regexp.h> |
40 | #include <the_Foundation/stringarray.h> | ||
40 | #include <the_Foundation/stringset.h> | 41 | #include <the_Foundation/stringset.h> |
41 | 42 | ||
42 | #include <ctype.h> | 43 | #include <ctype.h> |
@@ -163,6 +164,7 @@ struct Impl_GmDocument { | |||
163 | iBool enableCommandLinks; /* `about:command?` only allowed on selected pages */ | 164 | iBool enableCommandLinks; /* `about:command?` only allowed on selected pages */ |
164 | iBool isLayoutInvalidated; | 165 | iBool isLayoutInvalidated; |
165 | iArray layout; /* contents of source, laid out in document space */ | 166 | iArray layout; /* contents of source, laid out in document space */ |
167 | iStringArray auxText; /* generated text that appears on the page but is not part of the source */ | ||
166 | iPtrArray links; | 168 | iPtrArray links; |
167 | iString title; /* the first top-level title */ | 169 | iString title; /* the first top-level title */ |
168 | iArray headings; | 170 | iArray headings; |
@@ -638,6 +640,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
638 | static const char *uploadArrow = upload_Icon; | 640 | static const char *uploadArrow = upload_Icon; |
639 | static const char *image = photo_Icon; | 641 | static const char *image = photo_Icon; |
640 | clear_Array(&d->layout); | 642 | clear_Array(&d->layout); |
643 | clear_StringArray(&d->auxText); | ||
641 | clearLinks_GmDocument_(d); | 644 | clearLinks_GmDocument_(d); |
642 | clear_Array(&d->headings); | 645 | clear_Array(&d->headings); |
643 | const iArray *oldPreMeta = collect_Array(copy_Array(&d->preMeta)); /* remember fold states */ | 646 | const iArray *oldPreMeta = collect_Array(copy_Array(&d->preMeta)); /* remember fold states */ |
@@ -1070,7 +1073,9 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
1070 | run.bounds.pos.x -= d->outsideMargin; | 1073 | run.bounds.pos.x -= d->outsideMargin; |
1071 | } | 1074 | } |
1072 | run.visBounds = run.bounds; | 1075 | run.visBounds = run.bounds; |
1073 | const iInt2 maxSize = mulf_I2(imgSize, get_Window()->pixelRatio); | 1076 | const iInt2 maxSize = mulf_I2( |
1077 | imgSize, | ||
1078 | get_Window()->pixelRatio * iMax(1.0f, (prefs_App()->zoomPercent / 100.0f))); | ||
1074 | if (width_Rect(run.visBounds) > maxSize.x) { | 1079 | if (width_Rect(run.visBounds) > maxSize.x) { |
1075 | /* Don't scale the image up. */ | 1080 | /* Don't scale the image up. */ |
1076 | run.visBounds.size.y = | 1081 | run.visBounds.size.y = |
@@ -1080,6 +1085,34 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
1080 | run.bounds.size.y = run.visBounds.size.y; | 1085 | run.bounds.size.y = run.visBounds.size.y; |
1081 | } | 1086 | } |
1082 | pushBack_Array(&d->layout, &run); | 1087 | pushBack_Array(&d->layout, &run); |
1088 | pos.y += run.bounds.size.y + margin / 2; | ||
1089 | /* Image metadata caption. */ { | ||
1090 | run.font = FONT_ID(documentBody_FontId, semiBold_FontStyle, contentSmall_FontSize); | ||
1091 | run.color = tmQuoteIcon_ColorId; | ||
1092 | run.flags = decoration_GmRunFlag; | ||
1093 | run.mediaId = 0; | ||
1094 | run.mediaType = 0; | ||
1095 | run.visBounds.pos.y = pos.y; | ||
1096 | run.visBounds.size.y = lineHeight_Text(run.font); | ||
1097 | run.bounds = zero_Rect(); | ||
1098 | iString caption; | ||
1099 | init_String(&caption); | ||
1100 | format_String(&caption, | ||
1101 | "%s \u2014 %d x %d \u2014 %.1f%s", | ||
1102 | info.type, | ||
1103 | imgSize.x, | ||
1104 | imgSize.y, | ||
1105 | info.numBytes / 1.0e6f, | ||
1106 | cstr_Lang("mb")); | ||
1107 | pushBack_StringArray(&d->auxText, &caption); | ||
1108 | run.text = range_String(&caption); | ||
1109 | /* Center it. */ | ||
1110 | run.visBounds.size.x = measureRange_Text(run.font, range_String(&caption)).bounds.size.x; | ||
1111 | run.visBounds.pos.x = d->size.x / 2 - run.visBounds.size.x / 2; | ||
1112 | deinit_String(&caption); | ||
1113 | pushBack_Array(&d->layout, &run); | ||
1114 | pos.y += run.visBounds.size.y + margin; | ||
1115 | } | ||
1083 | break; | 1116 | break; |
1084 | } | 1117 | } |
1085 | case audio_MediaType: { | 1118 | case audio_MediaType: { |
@@ -1152,6 +1185,7 @@ void init_GmDocument(iGmDocument *d) { | |||
1152 | d->enableCommandLinks = iFalse; | 1185 | d->enableCommandLinks = iFalse; |
1153 | d->isLayoutInvalidated = iFalse; | 1186 | d->isLayoutInvalidated = iFalse; |
1154 | init_Array(&d->layout, sizeof(iGmRun)); | 1187 | init_Array(&d->layout, sizeof(iGmRun)); |
1188 | init_StringArray(&d->auxText); | ||
1155 | init_PtrArray(&d->links); | 1189 | init_PtrArray(&d->links); |
1156 | init_String(&d->title); | 1190 | init_String(&d->title); |
1157 | init_Array(&d->headings, sizeof(iGmHeading)); | 1191 | init_Array(&d->headings, sizeof(iGmHeading)); |
@@ -1173,6 +1207,7 @@ void deinit_GmDocument(iGmDocument *d) { | |||
1173 | deinit_PtrArray(&d->links); | 1207 | deinit_PtrArray(&d->links); |
1174 | deinit_Array(&d->preMeta); | 1208 | deinit_Array(&d->preMeta); |
1175 | deinit_Array(&d->headings); | 1209 | deinit_Array(&d->headings); |
1210 | deinit_StringArray(&d->auxText); | ||
1176 | deinit_Array(&d->layout); | 1211 | deinit_Array(&d->layout); |
1177 | deinit_String(&d->localHost); | 1212 | deinit_String(&d->localHost); |
1178 | deinit_String(&d->url); | 1213 | deinit_String(&d->url); |