summaryrefslogtreecommitdiff
path: root/src/fruits/cmc/ui/widgets/now_playing.c
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-08-26 17:58:15 -0400
committerAndrew Opalach <andrew@akon.city> 2026-08-26 17:58:15 -0400
commitb112da5b9825262b3b779bd699a4cf4bca8b6d01 (patch)
tree7742d66d3aac6bc007c638377f81da738e9886be /src/fruits/cmc/ui/widgets/now_playing.c
parent197d41a3e23cab35848f623c6133baccc62aacbe (diff)
downloadcamu-b112da5b9825262b3b779bd699a4cf4bca8b6d01.tar.gz
camu-b112da5b9825262b3b779bd699a4cf4bca8b6d01.tar.bz2
camu-b112da5b9825262b3b779bd699a4cf4bca8b6d01.zip
Rough cmc UI tweaking
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/fruits/cmc/ui/widgets/now_playing.c')
-rw-r--r--src/fruits/cmc/ui/widgets/now_playing.c42
1 files changed, 28 insertions, 14 deletions
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) {