Make sliders show their number value
Some checks failed
Build coop / build-ubuntu (push) Has been cancelled
Build coop / build-windows (push) Has been cancelled
Build coop / build-macos-arm (push) Has been cancelled
Build coop / build-macos-intel (push) Has been cancelled

This commit is contained in:
Agent X 2025-03-18 23:07:03 -04:00
parent 2479eaabfb
commit 64ef23ba6a
3 changed files with 7 additions and 2 deletions

View file

@ -38,6 +38,9 @@ void djui_slider_update_value(struct DjuiBase* base) {
u32 max = slider->max;
u32* value = slider->value;
djui_base_set_size(&slider->rectValue->base, ((f32)*value - min) / ((f32)max - min), 1.0f);
char message[128];
snprintf(message, 128, "%s - %d", slider->message, *value);
djui_text_set_text(slider->text, message);
}
static void djui_slider_get_cursor_hover_location(struct DjuiBase* base, f32* x, f32* y) {
@ -109,6 +112,7 @@ struct DjuiSlider* djui_slider_create(struct DjuiBase* parent, const char* messa
slider->value = value;
slider->min = min;
slider->max = max;
slider->message = message;
slider->updateRectValueColor = true;

View file

@ -10,6 +10,7 @@ struct DjuiSlider {
unsigned int min;
unsigned int max;
bool updateRectValueColor;
const char* message;
};
struct DjuiSlider* djui_slider_create(struct DjuiBase* parent, const char* message, unsigned int* value, unsigned int min, unsigned int max, void (*on_value_change)(struct DjuiBase*));

View file

@ -1,7 +1,7 @@
#ifndef GFX_SCREEN_CONFIG_H
#define GFX_SCREEN_CONFIG_H
#define DESIRED_SCREEN_WIDTH 800
#define DESIRED_SCREEN_HEIGHT 600
#define DESIRED_SCREEN_WIDTH 1024
#define DESIRED_SCREEN_HEIGHT 768
#endif