From 191d98d306d48ba36d5a5a2eb3583b805a03b2c3 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Tue, 18 Mar 2025 10:56:12 -0400 Subject: Cleanup Signed-off-by: Andrew Opalach --- src/fruits/cmc/ui/ext.h | 20 ++++++++++++++++++++ src/fruits/cmc/ui/pane_list.c | 3 ++- src/fruits/cmc/ui/pane_search.c | 2 ++ src/fruits/cmc/ui/ui.c | 9 +++++---- 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/fruits/cmc/ui/ext.h (limited to 'src/fruits/cmc/ui') diff --git a/src/fruits/cmc/ui/ext.h b/src/fruits/cmc/ui/ext.h new file mode 100644 index 0000000..b09754e --- /dev/null +++ b/src/fruits/cmc/ui/ext.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +// Copy-paste from notcurses.h +static inline s32 ncplane_light_box(struct ncplane *n, u16 attr, u64 channels, s32 ystop, s32 xstop, u32 ctlword) +{ + s32 ret = 0; + nccell ul = NCCELL_TRIVIAL_INITIALIZER, ur = NCCELL_TRIVIAL_INITIALIZER; + nccell ll = NCCELL_TRIVIAL_INITIALIZER, lr = NCCELL_TRIVIAL_INITIALIZER; + nccell hl = NCCELL_TRIVIAL_INITIALIZER, vl = NCCELL_TRIVIAL_INITIALIZER; + if((ret = nccells_light_box(n, attr, channels, &ul, &ur, &ll, &lr, &hl, &vl)) == 0){ + ret = ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop, ctlword); + } + nccell_release(n, &ul); nccell_release(n, &ur); + nccell_release(n, &ll); nccell_release(n, &lr); + nccell_release(n, &hl); nccell_release(n, &vl); + return ret; +} diff --git a/src/fruits/cmc/ui/pane_list.c b/src/fruits/cmc/ui/pane_list.c index 9a04211..5fc9f81 100644 --- a/src/fruits/cmc/ui/pane_list.c +++ b/src/fruits/cmc/ui/pane_list.c @@ -5,6 +5,7 @@ #include "../cmc.h" #include "ui.h" +#include "ext.h" void cmc_lp_init(struct cmc_ui *ui) { @@ -137,7 +138,7 @@ static void render_now_playing(struct cmc_ui *ui, struct cmc_list_tab *tab, u32 u64 c = 0; ncchannels_set_fg_default(&c); ncplane_cursor_move_yx(ui->lp.n, y, 0); - ncplane_rounded_box(ui->lp.n, NCSTYLE_NONE, c, height - 1, width - 1, 0); + ncplane_light_box(ui->lp.n, NCSTYLE_NONE, c, height - 1, width - 1, 0); } void cmc_lp_render(struct cmc_ui *ui) diff --git a/src/fruits/cmc/ui/pane_search.c b/src/fruits/cmc/ui/pane_search.c index e273504..3b427ce 100644 --- a/src/fruits/cmc/ui/pane_search.c +++ b/src/fruits/cmc/ui/pane_search.c @@ -2,6 +2,8 @@ #include "ui.h" +AL_ASSERT_TYPE_SIZE(wchar_t, 4); + void cmc_sp_init(struct cmc_ui *ui) { al_array_init(ui->sp.tabs); diff --git a/src/fruits/cmc/ui/ui.c b/src/fruits/cmc/ui/ui.c index 84e514e..9931620 100644 --- a/src/fruits/cmc/ui/ui.c +++ b/src/fruits/cmc/ui/ui.c @@ -1,6 +1,7 @@ #include #include "ui.h" +#include "ext.h" void cmc_ui_putnwstr_yx(struct ncplane *n, u32 y, u32 x, u32 width, wstr *w) { @@ -67,7 +68,7 @@ void cmc_ui_queue_render(struct cmc_ui *ui) ncplane_erase(ui->oln); } - notcurses_render(ui->nc); + //notcurses_render(ui->nc); switch (ui->pane) { case CMC_PANE_LIST: @@ -92,7 +93,7 @@ void cmc_ui_queue_render(struct cmc_ui *ui) u64 c = 0; ncchannels_set_fg_default(&c); ncplane_cursor_move_yx(ui->oln, 0, 0); - ncplane_rounded_box(ui->oln, NCSTYLE_NONE, c, height - 1, width - 1, 0); + ncplane_light_box(ui->oln, NCSTYLE_NONE, c, height - 1, width - 1, 0); } notcurses_render(ui->nc); @@ -190,8 +191,8 @@ static bool relayout(struct cmc_ui *ui) if (ui->oln) ncplane_destroy(ui->oln); u32 width = ncplane_dim_x(ui->n); u32 height = ncplane_dim_y(ui->n); - nopts.margin_r = MAX(6u, (u32)(width / 1.5)); - nopts.margin_b = MAX(2u, height / 3); + nopts.margin_r = MAX(6u, width / 2); + nopts.margin_b = MAX(2u, height / 2); nopts.x = nopts.margin_r / 2; nopts.y = nopts.margin_b / 2; ui->oln = ncplane_create(ui->n, &nopts); -- cgit v1.2.3-101-g0448