From b112da5b9825262b3b779bd699a4cf4bca8b6d01 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Wed, 26 Aug 2026 17:58:15 -0400 Subject: Rough cmc UI tweaking Signed-off-by: Andrew Opalach --- src/fruits/cmc/ui/widgets/now_playing.c | 42 ++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'src/fruits/cmc/ui/widgets') diff --git a/src/fruits/cmc/ui/widgets/now_playing.c b/src/fruits/cmc/ui/widgets/now_playing.c index 9edf6ca..56405b3 100644 --- a/src/fruits/cmc/ui/widgets/now_playing.c +++ b/src/fruits/cmc/ui/widgets/now_playing.c @@ -140,32 +140,46 @@ void cmc_now_playing_render(struct cmc_now_playing *np, struct cmc_list_entry *e ncplane_set_fg_default(np->n); char timestr[16] = { 0 }; // max = 829128280:01:49\0 - s32 offset = camu_print_time(timestr, sizeof(timestr), pos, true, 4); + s32 width1 = camu_print_time(timestr, sizeof(timestr), pos, true, 3); ncplane_putstr_yx(np->n, 1, 4, timestr); - ncplane_putstr_yx(np->n, 1, 4 + offset, "⎹"); - - if (entry) { - char *c_str = al_str_to_c_str(&entry->brief); - ncplane_putnstr_yx(np->n, 1, 6 + offset, MIN(al_strlen(c_str), (size_t)60), c_str); - al_free(c_str); - } + ncplane_putstr_yx(np->n, 1, 4 + width1, "⎹"); + s32 width2; bool show_remaining = false; if (show_remaining) { - offset = camu_print_time(timestr, sizeof(timestr), remaining, true, 4); + width2 = camu_print_time(timestr, sizeof(timestr), remaining, true, 3); } else { - offset = camu_print_time(timestr, sizeof(timestr), duration, true, 4); + width2 = camu_print_time(timestr, sizeof(timestr), duration, true, 3); } - ncplane_putstr_yx(np->n, 1, width - 4 - offset, "⎸"); + s32 x1 = width - 4 - width2; + ncplane_putstr_yx(np->n, 1, x1, "⎸"); // "=" Duration, "+" Segment, "-" Remaining. if (show_remaining) { - ncplane_putstr_yx(np->n, 1, width - 3 - offset, "-"); + ncplane_putstr_yx(np->n, 1, x1 + 1, "-"); } else { - ncplane_putstr_yx(np->n, 1, width - 3 - offset, "="); + ncplane_putstr_yx(np->n, 1, x1 + 1, "="); } - ncplane_putstr_yx(np->n, 1, width - 2 - offset, timestr); + ncplane_putstr_yx(np->n, 1, x1 + 2, timestr); if (entry) { + u32 rslash = al_str_rfind(&entry->brief, '/'); + str part; + if (rslash != AL_STR_NO_POS) { + part = al_str_substr(&entry->brief, rslash + 1, entry->brief.length); + } else { + part = entry->brief; + } + char *c_str = al_str_to_c_str(&part); + s32 x2 = 6 + width1; + // @TODO: Can mid be negative. + s32 mid = x1 - x2; + ncplane_putnstr_yx(np->n, 1, x2, MIN(al_strlen(c_str), (size_t)mid), c_str); + if (part.length >= mid) { + ncplane_putnstr_yx(np->n, 1, x2 + mid - 1, 1, "."); + ncplane_putnstr_yx(np->n, 1, x2 + mid - 2, 1, "."); + } + al_free(c_str); + bool visual_cached = false; struct cmc_now_playing_visual *visual; al_array_foreach_ptr(np->visuals, i, visual) { -- cgit v1.2.3-101-g0448