bar styling, state color

This commit is contained in:
Luka Jankovic 2025-06-24 23:26:14 +02:00
parent 10d243055d
commit b2a5ede334
4 changed files with 14 additions and 3 deletions

View file

@ -19,7 +19,8 @@
#include "kubo_bar.h"
static inline int push_text(int x, int y, const char *text) {
DrawText(text, x, y, KUBO_BAR_HEIGHT, WHITE);
DrawText(text, x, y + (KUBO_BAR_PADDING / 2),
KUBO_BAR_HEIGHT - KUBO_BAR_PADDING, WHITE);
return x + MeasureText(text, KUBO_BAR_HEIGHT);
}
@ -28,6 +29,8 @@ void kubo_bar_render(struct kubo_context *context) {
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, kubo_context_get_label(context->state));
DrawRectangle(0, bar_y, GetScreenWidth(), KUBO_BAR_HEIGHT,
kubo_context_get_color(context->state));
bar_text_x =
push_text(bar_text_x, bar_y, kubo_context_get_label(context->state));
}

View file

@ -20,6 +20,7 @@
#define KUBO_BAR_H
#define KUBO_BAR_HEIGHT 32
#define KUBO_BAR_PADDING 12
#include <raylib.h>

View file

@ -57,6 +57,10 @@ const char *kubo_context_get_label(enum kubo_context_state state) {
return kubo_context_labels[state];
}
Color kubo_context_get_color(enum kubo_context_state state) {
return kubo_context_colors[state];
}
struct kubo_wall *kubo_context_get_pending_wall(struct kubo_context *context) {
if (context->state != KUBO_CONTEXT_WALL_NEW) {

View file

@ -35,6 +35,8 @@ enum kubo_context_state {
static const char *kubo_context_labels[] = {"Wall New", "Wall Select"};
static const Color kubo_context_colors[] = {BLACK, BLUE};
struct kubo_context {
bool exit_pending;
struct kubo_wall_arr walls;
@ -50,6 +52,7 @@ void kubo_context_cleanup(struct kubo_context *context);
void kubo_context_set_state(struct kubo_context *context,
enum kubo_context_state state);
const char *kubo_context_get_label(enum kubo_context_state state);
Color kubo_context_get_color(enum kubo_context_state state);
struct kubo_wall *kubo_context_get_pending_wall(struct kubo_context *context);