From 86fb0b3918dca172ce1ce0c1c5fffd039f824a15 Mon Sep 17 00:00:00 2001 From: A404M Date: Wed, 28 Aug 2024 13:58:53 +0330 Subject: now \n works in text changed bool size changed example --- src/main.c | 57 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 20 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index ace9802..1a4ce8a 100644 --- a/src/main.c +++ b/src/main.c @@ -2,28 +2,45 @@ #include #include -void on_button_click(MOUSE_ACTION mouse_action) { - printf("hello"); - sleep(1); -} +bool is_clicked = false; + +void on_button_click(MOUSE_ACTION mouse_action) { is_clicked = !is_clicked; } WIDGET *ui_build(TUI *tui) { - return tui_make_box( - -1, -1, - tui_make_row(tui_make_widget_array( - 3, - tui_make_box( - 8, 2, - tui_make_button(tui_make_text("Hello, World!", COLOR_BLUE), - on_button_click), - COLOR_YELLOW), - tui_make_box( - 8, 2, - tui_make_button(tui_make_text("Hello, World!", COLOR_RED), - on_button_click), - COLOR_BLUE), - tui_make_text("Hello, World!", COLOR_RED), 1)), - COLOR_MAGENTA); + if (is_clicked) { + return tui_make_box( + -1, -1, + tui_make_column(tui_make_widget_array( + 2, tui_make_box(0, 12, NULL, COLOR_NO_COLOR), + tui_make_row(tui_make_widget_array( + 2, tui_make_box(50, 0, NULL, COLOR_NO_COLOR), + tui_make_box( + 20, 3, + tui_make_column(tui_make_widget_array( + 2, + tui_make_text( + "This is the second page", + COLOR_BLUE), + tui_make_button(tui_make_text(" Back", COLOR_RED), + on_button_click))), + + COLOR_WHITE))))), + COLOR_MAGENTA); + } else { + return tui_make_box( + -1, -1, + tui_make_column(tui_make_widget_array( + 2, tui_make_box(0, 12, NULL, COLOR_NO_COLOR), + tui_make_row(tui_make_widget_array( + 2, tui_make_box(50, 0, NULL, COLOR_NO_COLOR), + tui_make_button( + tui_make_box( + 16, 3, + tui_make_text("\nClick here", COLOR_BLUE), + COLOR_WHITE), + on_button_click))))), + COLOR_MAGENTA); + } } int main() { -- cgit v1.2.3