summaryrefslogtreecommitdiff
path: root/src/fruits/cmc/ui/panes
diff options
context:
space:
mode:
Diffstat (limited to 'src/fruits/cmc/ui/panes')
-rw-r--r--src/fruits/cmc/ui/panes/list.c244
1 files changed, 5 insertions, 239 deletions
diff --git a/src/fruits/cmc/ui/panes/list.c b/src/fruits/cmc/ui/panes/list.c
index 34e18f9..15554b6 100644
--- a/src/fruits/cmc/ui/panes/list.c
+++ b/src/fruits/cmc/ui/panes/list.c
@@ -265,15 +265,16 @@ static void render_list_entries(struct cmc_list_pane *lp, struct cmc_list_tab *t
ncplane_set_fg_palindex(n, 4);
}
s32 y = i - top;
- u32 length = entry->name.length;
+ char *c_str = al_str_to_c_str(&entry->brief);
if (tab->move.active && i == tracked) {
- cmc_ui_putnwstr_yx(n, y, 0, length, &entry->name);
+ ncplane_putstr_yx(n, y, 0, c_str);
} else if (on_current) {
ncplane_putchar_yx(n, y, 1, '>');
- cmc_ui_putnwstr_yx(n, y, 3, length, &entry->name);
+ ncplane_putstr_yx(n, y, 3, c_str);
} else {
- cmc_ui_putnwstr_yx(n, y, 1, length, &entry->name);
+ ncplane_putstr_yx(n, y, 1, c_str);
}
+ al_free(c_str);
if (styled) {
ncplane_set_styles(n, NCSTYLE_NONE);
ncplane_set_fg_default(n);
@@ -291,229 +292,6 @@ void cmc_list_pane_render(struct cmc_list_pane *lp)
cmc_now_playing_render(&lp->np, tab_current_entry(tab));
}
-//void cmc_lp_init(struct cmc_ui *ui)
-//{
-// al_array_init(ui->lp.tabs);
-// ui->lp.current = 0;
-//}
-//
-//void cmc_lp_layout(struct cmc_ui *ui, struct ncplane *parent)
-//{
-// if (ui->lp.n) ncplane_destroy(ui->lp.n);
-// struct ncplane_options nopts = { 0 };
-// nopts.rows = ncplane_dim_y(parent);
-// nopts.cols = ncplane_dim_x(parent);
-// ui->lp.n = ncplane_create(parent, &nopts);
-//}
-//
-//void cmc_lp_add_list(struct cmc_ui *ui, struct cmc_list *list)
-//{
-// struct cmc_list_tab tab = {
-// .list = list,
-// .selected = list->current,
-// .leader_pressed = false
-// };
-// al_array_push(ui->lp.tabs, tab);
-//}
-//
-//bool cmc_lp_handle_input(struct cmc_ui *ui, struct ncinput *input)
-//{
-// if (!ui->lp.tabs.count) return false;
-//
-// struct cmc_list_tab *tab = &al_array_at(ui->lp.tabs, ui->lp.current);
-// s32 count = (s32)tab->list->entries.count;
-// bool leader = tab->leader_pressed;
-// if (cmc_ui_consider_input(input, false)) {
-// tab->leader_pressed = false;
-// }
-//
-// switch (input->id) {
-// case 'g':
-// CONSIDER_INPUT();
-// if (leader) {
-// if (tab->move.active) {
-// tab->move.offset = -tab->move.selected;
-// } else {
-// tab->selected = 0;
-// }
-// } else {
-// tab->leader_pressed = true;
-// }
-// break;
-// case 'G':
-// CONSIDER_INPUT();
-// if (tab->move.active) {
-// tab->move.offset = count - 1 - tab->move.selected;
-// } else {
-// tab->selected = count - 1;
-// }
-// break;
-// case 'f':
-// //CONSIDER_INPUT_MOD_CTRL();
-// CONSIDER_INPUT_REPEAT();
-// if (tab->move.active) {
-// if (tab->selected + tab->move.offset < count - tab->page_length) {
-// tab->move.offset += tab->page_length;
-// } else {
-// tab->move.offset = count - 1 - tab->move.selected;
-// }
-// } else {
-// if (tab->selected < count - tab->page_length) {
-// tab->selected += tab->page_length;
-// } else {
-// tab->selected = count - 1;
-// }
-// }
-// break;
-// case 'b':
-// //CONSIDER_INPUT_MOD_CTRL();
-// CONSIDER_INPUT_REPEAT();
-// if (tab->move.active) {
-// if (tab->selected + tab->move.offset > tab->page_length) {
-// tab->move.offset -= tab->page_length;
-// } else {
-// tab->move.offset = -tab->selected;
-// }
-// } else {
-// if (tab->selected > tab->page_length) {
-// tab->selected -= tab->page_length;
-// } else {
-// tab->selected = 0;
-// }
-// }
-// break;
-// case 'j':
-// CONSIDER_INPUT_REPEAT();
-// if (tab->move.active) {
-// if (tab->selected + tab->move.offset < count - 1) {
-// tab->move.offset++;
-// }
-// } else {
-// if (tab->selected < count - 1) {
-// tab->selected++;
-// }
-// }
-// break;
-// case 'k':
-// CONSIDER_INPUT_REPEAT();
-// if (tab->move.active) {
-// if (tab->selected + tab->move.offset > 0) {
-// tab->move.offset--;
-// }
-// } else {
-// if (tab->selected > 0) {
-// tab->selected--;
-// }
-// }
-// break;
-// case 'i':
-// CONSIDER_INPUT();
-// if (!tab->move.active) {
-// tab->move.active = true;
-// tab->move.selected = tab->selected;
-// tab->move.offset = 0;
-// }
-// break;
-// case NCKEY_ESC:
-// CONSIDER_INPUT();
-// if (tab->move.active) {
-// tab->move.active = false;
-// }
-// break;
-// case NCKEY_RETURN:
-// CONSIDER_INPUT();
-// if (tab->move.active) {
-// tab->move.active = false;
-// } else if (tab->selected != tab->list->current) {
-// camu_client_skipto(&ui->c->client, &tab->list->name, tab->selected);
-// }
-// break;
-// case NCKEY_BUTTON1:
-// CONSIDER_INPUT();
-// if (input->x < 0 || input->y < 0) return false;
-// u32 x = (u32)input->x;
-// u32 y = (u32)input->y;
-// ui->last_mouse_x = x;
-// ui->last_mouse_y = y;
-// u64 now = nn_get_timestamp();
-// u64 last = ui->last_mouse_ts;
-// if (last != (u64)-1 && now - last < 100000) {
-// return false;
-// }
-// ui->last_mouse_ts = now;
-// u32 width = ncplane_dim_x(ui->lp.n);
-// u32 height = ncplane_dim_y(ui->lp.n);
-// if (x >= 2 && x <= width && y > height - 3) { // @TODO: Make this defined, more to nowplaying.
-// struct cmc_list_entry *entry = al_array_at(tab->list->entries, tab->list->current);
-// u64 pos = ((x - 2) / (f64)(width - 2)) * entry->duration;
-// camu_client_seek(&ui->c->client, &tab->list->name, entry->id, pos);
-// }
-// break;
-// }
-//
-// return true;
-//}
-//
-//void cmc_lp_erase(struct cmc_ui *ui)
-//{
-// ncplane_erase(ui->lp.n);
-//}
-//
-//static void render_list_entries(struct cmc_ui *ui, struct cmc_list_tab *tab, s32 max_height)
-//{
-// struct cmc_list *list = tab->list;
-// struct ncplane *n = ui->lp.n;
-// s32 tracked = tab->move.active ? tab->move.selected + tab->move.offset : tab->selected;
-// s32 count = (s32)list->entries.count;
-// s32 midpoint = max_height / 2;
-// s32 rounded = (max_height + 1) / 2;
-// s32 top, end;
-// if (tracked < midpoint) {
-// top = 0;
-// end = MIN(top + max_height, count);
-// } else if (tracked + rounded >= count) {
-// top = count - max_height;
-// end = count;
-// } else {
-// top = tracked - midpoint;
-// end = tracked + rounded;
-// }
-// s32 index;
-// struct cmc_list_entry *entry;
-// for (s32 i = top; i < end; i++) {
-// index = i;
-// if (tab->move.active) {
-// if (index == tracked) {
-// index = tab->move.selected;
-// } else {
-// if (index > tracked) index--;
-// if (index >= tab->move.selected) index++;
-// }
-// }
-// entry = al_array_at(list->entries, index);
-// bool on_current = list->current >= 0 && index == list->current;
-// bool styled = i == tracked;
-// if (styled) {
-// ncplane_set_styles(n, NCSTYLE_BOLD);
-// ncplane_set_fg_palindex(n, 4);
-// }
-// s32 y = i - top;
-// u32 length = entry->name.length;
-// if (tab->move.active && i == tracked) {
-// cmc_ui_putnwstr_yx(n, y, 0, length, &entry->name);
-// } else if (on_current) {
-// ncplane_putchar_yx(n, y, 1, '>');
-// cmc_ui_putnwstr_yx(n, y, 3, length, &entry->name);
-// } else {
-// cmc_ui_putnwstr_yx(n, y, 1, length, &entry->name);
-// }
-// if (styled) {
-// ncplane_set_styles(n, NCSTYLE_NONE);
-// ncplane_set_fg_default(n);
-// }
-// }
-//}
-//
//static void render_now_playing(struct cmc_ui *ui, struct cmc_list_tab *tab, u32 y, u32 height)
//{
// struct ncplane *n = ui->lp.n;
@@ -676,15 +454,3 @@ void cmc_list_pane_render(struct cmc_list_pane *lp)
// ncplane_cursor_move_yx(n, y, 0);
// ncplane_light_box(n, NCSTYLE_NONE, c, height - 1, width - 1, 0);
//}
-//
-//void cmc_lp_render(struct cmc_ui *ui)
-//{
-// u32 height = ncplane_dim_y(ui->lp.n);
-//
-// if (ui->lp.tabs.count <= ui->lp.current) return;
-// struct cmc_list_tab *tab = &al_array_at(ui->lp.tabs, ui->lp.current);
-//
-// tab->page_length = height - 9;
-// render_list_entries(ui, tab, tab->page_length);
-// render_now_playing(ui, tab, tab->page_length, height);
-//}