crude feedback gain control

This commit is contained in:
veclavtalica
2024-06-29 18:33:59 +03:00
parent 12189efe88
commit 974b2ac941
2 changed files with 43 additions and 7 deletions

View File

@ -1,3 +1,8 @@
#if defined(STFU_MAIN) && !defined(STFU_SLIDER)
#define STFU_SLIDER
#include <stdbool.h>
#include "../config.h"
#include "border.c"
@ -8,6 +13,7 @@ struct stfu_slider {
float width, height;
float r, g, b;
float min, max, cur;
bool integeric;
};
static void stfu_draw_slider(struct stfu_slider slider) {
@ -36,3 +42,21 @@ static void stfu_draw_slider(struct stfu_slider slider) {
sgl_end();
}
}
static struct stfu_slider stfu_press_slider(struct stfu_slider slider, float x,
float y) {
if (x < slider.x || x > slider.x + slider.width)
return slider;
if (y < slider.y || y > slider.y + slider.height)
return slider;
slider.cur = slider.min +
((x - slider.x) / (slider.width)) * (slider.max - slider.min);
if (slider.integeric)
slider.cur = floorf(slider.cur);
return slider;
}
#endif