diff options
Diffstat (limited to 'src/ui/mediaui.c')
-rw-r--r-- | src/ui/mediaui.c | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/src/ui/mediaui.c b/src/ui/mediaui.c index ac9475dd..d85d0df9 100644 --- a/src/ui/mediaui.c +++ b/src/ui/mediaui.c | |||
@@ -279,85 +279,3 @@ void draw_DownloadUI(const iDownloadUI *d, iPaint *p) { | |||
279 | translateCStr_Lang("\u2014 ${mb.per.sec}")); | 279 | translateCStr_Lang("\u2014 ${mb.per.sec}")); |
280 | } | 280 | } |
281 | } | 281 | } |
282 | |||
283 | /*----------------------------------------------------------------------------------------------*/ | ||
284 | |||
285 | static iMenuItem action_FontpackUI_(const iFontpackUI *d) { | ||
286 | if (d->info.isInstalled) { | ||
287 | return (iMenuItem){ d->info.isDisabled ? "${media.fontpack.enable}" | ||
288 | : close_Icon " ${media.fontpack.disable}", | ||
289 | 0, 0, format_CStr("media.fontpack.enable arg:%d", d->info.isDisabled) }; | ||
290 | } | ||
291 | return (iMenuItem){ d->info.isInstalled ? close_Icon " ${media.fontpack.disable}" | ||
292 | : "${media.fontpack.install}", | ||
293 | 0, 0, | ||
294 | d->info.isInstalled ? "media.fontpack.enable arg:0" : "media.fontpack.install" }; | ||
295 | } | ||
296 | |||
297 | void init_FontpackUI(iFontpackUI *d, const iMedia *media, uint16_t mediaId, iRect bounds) { | ||
298 | d->media = media; | ||
299 | d->mediaId = mediaId; | ||
300 | fontpackInfo_Media(d->media, (iMediaId){ fontpack_MediaType, d->mediaId }, &d->info); | ||
301 | d->bounds = bounds; | ||
302 | iMenuItem action = action_FontpackUI_(d); | ||
303 | d->buttonRect.size = add_I2(measure_Text(uiLabel_FontId, action.label).bounds.size, | ||
304 | muli_I2(gap2_UI, 3)); | ||
305 | d->buttonRect.pos.x = right_Rect(d->bounds) - gap_UI - d->buttonRect.size.x; | ||
306 | d->buttonRect.pos.y = mid_Rect(d->bounds).y - d->buttonRect.size.y / 2; | ||
307 | } | ||
308 | |||
309 | iBool processEvent_FontpackUI(iFontpackUI *d, const SDL_Event *ev) { | ||
310 | switch (ev->type) { | ||
311 | case SDL_MOUSEBUTTONDOWN: | ||
312 | case SDL_MOUSEBUTTONUP: { | ||
313 | const iInt2 pos = init_I2(ev->button.x, ev->button.y); | ||
314 | if (contains_Rect(d->buttonRect, pos)) { | ||
315 | if (ev->type == SDL_MOUSEBUTTONUP) { | ||
316 | postCommandf_App("%s media:%p mediaid:%u packid:%s", | ||
317 | action_FontpackUI_(d).command, | ||
318 | d->media, d->mediaId, cstr_String(d->info.packId.id)); | ||
319 | } | ||
320 | return iTrue; | ||
321 | } | ||
322 | break; | ||
323 | } | ||
324 | case SDL_MOUSEMOTION: | ||
325 | if (contains_Rect(d->bounds, init_I2(ev->motion.x, ev->motion.y))) { | ||
326 | return iTrue; | ||
327 | } | ||
328 | break; | ||
329 | } | ||
330 | return iFalse; | ||
331 | } | ||
332 | |||
333 | int height_FontpackUI(const iMedia *media, uint16_t mediaId, int width) { | ||
334 | const iStringList *names; | ||
335 | iFontpackMediaInfo info; | ||
336 | fontpackInfo_Media(media, (iMediaId){ fontpack_MediaType, mediaId }, &info); | ||
337 | return lineHeight_Text(uiContent_FontId) + | ||
338 | lineHeight_Text(uiLabel_FontId) * (1 + size_StringList(info.names)); | ||
339 | } | ||
340 | |||
341 | void draw_FontpackUI(const iFontpackUI *d, iPaint *p) { | ||
342 | /* Draw a background box. */ | ||
343 | fillRect_Paint(p, d->bounds, uiBackground_ColorId); | ||
344 | drawRect_Paint(p, d->bounds, uiSeparator_ColorId); | ||
345 | iInt2 pos = topLeft_Rect(d->bounds); | ||
346 | const char *checks[] = { "\u2610", "\u2611" }; | ||
347 | draw_Text(uiContentBold_FontId, pos, | ||
348 | d->info.isDisabled ? uiText_ColorId : uiHeading_ColorId, "\"%s\" v%d", | ||
349 | cstr_String(d->info.packId.id), d->info.packId.version); | ||
350 | pos.y += lineHeight_Text(uiContentBold_FontId); | ||
351 | draw_Text(uiLabelBold_FontId, pos, uiText_ColorId, "%.1f MB, %d fonts %s %s %s", | ||
352 | d->info.sizeInBytes / 1.0e6, size_StringList(d->info.names), | ||
353 | // checks[info.isValid], info.isValid ? "No errors" : "Errors detected", | ||
354 | checks[d->info.isInstalled], d->info.isInstalled ? "Installed" : "Not installed", | ||
355 | d->info.isReadOnly ? "Read-Only" : ""); | ||
356 | pos.y += lineHeight_Text(uiLabelBold_FontId); | ||
357 | iConstForEach(StringList, i, d->info.names) { | ||
358 | drawRange_Text(uiLabel_FontId, pos, uiText_ColorId, range_String(i.value)); | ||
359 | pos.y += lineHeight_Text(uiLabel_FontId); | ||
360 | } | ||
361 | /* Buttons. */ | ||
362 | drawInlineButton_(p, d->buttonRect, action_FontpackUI_(d).label, uiLabel_FontId); | ||
363 | } | ||