From 55d29d0df8681efe01e88e0475c8512c44ec4bc4 Mon Sep 17 00:00:00 2001 From: A404M Date: Tue, 24 Dec 2024 01:23:24 +0330 Subject: fixed some bugs --- src/main.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 2515014..549ddf5 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,10 @@ #include "ui/color.h" #include "ui/tui.h" +constexpr COLOR BACKGROUND_COLOR = color_hex(0xFF2B2A33); +constexpr COLOR COLOR_FPS_BACK = color_hex(0xFFCCCCCC); +constexpr COLOR COLOR_FPS_TEXT = color_hex(0xFF000000); + WIDGET *search_box() { return tui_make_padding( tui_make_box(MAX_WIDTH, 1, @@ -18,19 +22,29 @@ WIDGET *search_box() { 1, 1, 10, 10); } -WIDGET *search_header() {} +// WIDGET *search_header() {} + +WIDGET *fps_counter(uint64_t last_frame) { + char fps_text[3 + 1 + 20 + 1]; + sprintf(fps_text, "fps %ld", + (last_frame == 0) ? 0 : (NANO_TO_SECOND / last_frame)); + return tui_make_padding( + tui_make_box(MIN_WIDTH, 1, tui_make_text(fps_text, COLOR_FPS_TEXT), + COLOR_FPS_BACK), + 0, 0, 2, 2); +} WIDGET *ui_build(TUI *tui) { return tui_make_box( MAX_WIDTH, MAX_HEIGHT, tui_make_column(tui_make_widget_array( - search_box(), - tui_make_row(tui_make_widget_array(tui_make_center( - tui_make_box(MIN_WIDTH, 3, - tui_make_center(tui_make_text( - "Hi here", color_init(0xFF0000FF))), - color_init(0xFFFFFFFF))))))), - color_init(0xFF2B2A33)); + fps_counter(tui->last_frame), search_box(), + tui_make_row(tui_make_widget_array(tui_make_center(tui_make_box( + MIN_WIDTH, MIN_HEIGHT, + tui_make_padding(tui_make_text("Hi here", color_init(0xFF0000FF)), + 2, 2, 2, 2), + color_init(0xFFFFFFFF))))))), + BACKGROUND_COLOR); } int main() { -- cgit v1.2.3