From 5c91359f1c828784ff364ebc20257fa2a843c2d1 Mon Sep 17 00:00:00 2001 From: Timerix Date: Wed, 11 Feb 2026 15:29:55 +0500 Subject: [PATCH] figured out how to use buggy scroll_view --- dependencies/tim | 2 +- src/cli/ClientCLI/ClientCLI.c | 10 ++++++++-- src/cli/ClientCLI/ClientCLI.h | 3 ++- src/cli/ClientCLI/main_screen.c | 24 +++++++++++++++++------- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/dependencies/tim b/dependencies/tim index ee6375f..5ef7f91 160000 --- a/dependencies/tim +++ b/dependencies/tim @@ -1 +1 @@ -Subproject commit ee6375f553e13871a85c0a33567483dbbb39ef1c +Subproject commit 5ef7f91764ac1484530fd7fb00376cee5c3dbfa5 diff --git a/src/cli/ClientCLI/ClientCLI.c b/src/cli/ClientCLI/ClientCLI.c index 9b0b79e..051dc71 100644 --- a/src/cli/ClientCLI/ClientCLI.c +++ b/src/cli/ClientCLI/ClientCLI.c @@ -48,17 +48,23 @@ void ClientCLI_run(ClientCLI* self) { while(tim_run(FPS)){ switch(self->state){ - case ClientCLIState_Exit: - Return; default: assert(false && "invalid ClientCLI state"); break; + case ClientCLIState_Exit: + Return; case ClientCLIState_StartScreen: start_screen(&start_screen_ctx); break; case ClientCLIState_MainScreen: main_screen(&main_screen_ctx); break; + // case ClientCLIState_ListOfServers: + // break; + // case ClientCLIState_ServerChannels: + // break; + // case ClientCLIState_ChannelScreen: + // break; } } diff --git a/src/cli/ClientCLI/ClientCLI.h b/src/cli/ClientCLI/ClientCLI.h index 37c4cfd..23e0827 100644 --- a/src/cli/ClientCLI/ClientCLI.h +++ b/src/cli/ClientCLI/ClientCLI.h @@ -12,8 +12,9 @@ typedef enum ClientCLIState { ClientCLIState_StartScreen, ClientCLIState_Exit, ClientCLIState_MainScreen, + ClientCLIState_ListOfServers, ClientCLIState_ServerChannels, - ClientCLIState_ChannelChat, + ClientCLIState_ChannelScreen, } ClientCLIState; typedef struct ClientCLI { diff --git a/src/cli/ClientCLI/main_screen.c b/src/cli/ClientCLI/main_screen.c index ec67ba4..5b27149 100644 --- a/src/cli/ClientCLI/main_screen.c +++ b/src/cli/ClientCLI/main_screen.c @@ -52,7 +52,7 @@ void MainScreenContext_construct(MainScreenContext* ctx, ClientCLI* client){ // central_scroll_view // /////////////////////////////////////////////////////////////////////////// { - ctx->central_scroll_view.content_h = 50; + ctx->central_scroll_view.content_h = 48; ctx->central_scroll_view.data = ctx; ctx->central_scroll_view.draw = draw_central_panel; } @@ -63,18 +63,28 @@ void MainScreenContext_destroy(MainScreenContext* ctx){ } void main_screen(MainScreenContext* ctx){ + u8 fg = ctx->client->style.common.fg; + u8 bg = ctx->client->style.common.bg; + TimStyle style_inverted = {.bg = fg, .fg = bg, .brd = bg}; + // fill screen if (tim->event.type == TimEvent_Draw) { - tim_fill(tim_cell(" ", ctx->client->style.common.fg, ctx->client->style.common.bg), 0, 0, A, A); + tim_fill(tim_cell(" ", fg, bg), 0, 0, A, A); } + + tim_scroll_view(&ctx->central_scroll_view, 0, 2, ~0, ~0, ctx->client->style.common); - if(tim_button_noborder("[Esc/Q] Exit", 1, 0, 14, 1, ctx->client->style.common) - || tim_is_key_press('q') - || tim_is_key_press(TimKey_Escape)) + // paint over buggy items escaping from panel when it is scrolled down + if (tim->event.type == TimEvent_Draw) { + tim_draw_row(tim_cell(" ", fg, bg), 0, 0, A); + tim_draw_row(tim_cell("─", fg, bg), 0, 1, A); + } + + // upper buttons + if(tim_button_noborder("[Esc/Q] Exit", 0, 0, 14, 1, style_inverted) + || tim_is_key_press('q') || tim_is_key_press(TimKey_Escape)) { ctx->client->state = ClientCLIState_Exit; } - - tim_scroll_view(&ctx->central_scroll_view, 0, 1, ~0, ~0, ctx->client->style.common); } static void draw_test_label(void* data, TimRect place, bool is_selected){