/* * Copyright Luka Jankovic 2025 * * This file is part of Kubo. * * Kubo is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * Kubo is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * Kubo. If not, see . */ #include "kubo_bar.h" const char *snap_text_on = "Snap enabled"; const char *snap_text_off = "Snap disabled"; static inline int push_text(int x, int y, const char *text, Color bg_color); void kubo_bar_render(struct kubo_context *context, bool snap_enabled) { const int bar_y = GetScreenHeight() - KUBO_BAR_HEIGHT; int bar_text_x = 10; DrawRectangle(0, bar_y, GetScreenWidth(), KUBO_BAR_HEIGHT, BLACK); bar_text_x = push_text(bar_text_x, bar_y, context->state.label, context->state.color); bar_text_x += 2 * KUBO_BAR_PADDING; const char *snap_text = snap_enabled ? snap_text_on : snap_text_off; switch (context->state.id) { case KUBO_CONTEXT_COMMAND: kubo_command_bar_render(bar_text_x, bar_y + (KUBO_BAR_PADDING / 2), KUBO_BAR_HEIGHT - KUBO_BAR_PADDING); break; case KUBO_CONTEXT_WALL_NEW: bar_text_x += push_text(bar_text_x, bar_y, snap_text, BLACK); break; default: break; } } static inline int push_text(int x, int y, const char *text, Color bg_color) { int font_size = KUBO_BAR_HEIGHT - KUBO_BAR_PADDING; int text_width = MeasureText(text, font_size); DrawRectangle(x - KUBO_BAR_PADDING, y, text_width + (2 * KUBO_BAR_PADDING), KUBO_BAR_HEIGHT, bg_color); DrawText(text, x, y + (KUBO_BAR_PADDING / 2), font_size, WHITE); return x + text_width; }