#include "ui/tui.h" #include #include bool is_clicked = false; void on_button_click(MOUSE_ACTION mouse_action) { is_clicked = !is_clicked; } WIDGET *ui_build(TUI *tui) { 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() { TUI *tui = tui_init(); tui_start_app(tui, ui_build); tui_delete(tui); return 0; }