41 .background = 0x3A2A3AE0,
44 .focussed = {.scale = 1.03, .border = 0xAA77AAFF},
45 .active = {.scale = 0.97, .border = 0x7F4F7FFF},
48 .knob_border = 0x6F3F6FFF,
68 double *value,
double *anim) {
76 if (anim != NULL && (*anim > 1 || *anim < 0))
83 int active = enabled &&
gm_mouse.down && hovered;
104 double sw = width * scale;
105 double sh = height * scale;
111 double track_w = sw -
gmwScale.border_width * 2;
112 double track_h = sh -
gmwScale.border_width * 2;
118 int horizontal = (width >= height);
123 double left = x - width * 0.5 +
gmwScale.border_width;
134 double bottom = y - height * 0.5 +
gmwScale.border_width;
148 double knob_size = (horizontal ? sh : sw) * 1.5;
149 double knob_x, knob_y;
152 double left = x - sw * 0.5 + knob_size * 0.5;
153 double right = x + sw * 0.5 - knob_size * 0.5;
154 knob_x = left + (*anim) * (right - left);
157 double bottom = y - sh * 0.5 + knob_size * 0.5;
158 double top = y + sh * 0.5 - knob_size * 0.5;
159 knob_y = bottom + (*anim) * (top - bottom);
165 knob_size +
gmwScale.border_width * 2,
186static inline int gmw_scale(
double x,
double y,
double width,
double height,
Functions for animating values with various easing functions.
void gm_anim_ease_out_quad(double *value, const double target, double t)
Starts fast and decelerates quadratically to the target. More pronounced than spring.
Definition animate.h:45
int gm_mouse_in_rect(const double x, const double y, const double w, const double h)
Definition collision.h:102
unsigned int gmColor
Type definition for color values in RGBA format.
Definition color.h:8
Functions for drawing shapes, text, and images.
int32_t gm_draw_rectangle(double x, double y, double w, double h, gmColor c)
Draws a rectangle.
Definition draw.h:47
struct _gmMouse gm_mouse
Definition gapi.h:19
int gmw_scale_anim(double x, double y, double width, double height, double *value, double *anim)
Creates and renders an animated scale (slider) widget that can be manipulated with the mouse.
Definition scale.h:67
gmwScaleTheme gmwScale
Global scale theme instance with default values.
Definition scale.h:38
Structure defining the visual theme for a scale (slider) widget.
Definition scale.h:10
gmColor knob_border
Definition scale.h:29
gmColor border
Definition scale.h:16
gmColor background
Definition scale.h:15
double step
Definition scale.h:32
int enabled
Definition scale.h:11
double border_width
Definition scale.h:31
gmColor knob
Definition scale.h:28
double scale
Definition scale.h:13