crude feedback gain control
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user