49 .background = 0x3A2A3AE0,
52 .focussed = {.scale = 1.03, .border = 0xAA77AAFF},
53 .active = {.scale = 0.97, .border = 0x7F4F7FFF},
56 .knob_border = 0x6F3F6FFF,
80 double *value,
double *anim) {
88 if (anim != NULL && (*anim > 1 || *anim < 0))
95 int active = enabled &&
gm_mouse.down && hovered;
108 }
else if (hovered) {
116 double sw = width * scale;
117 double sh = height * scale;
123 double track_w = sw -
gmwScale.border_width * 2;
124 double track_h = sh -
gmwScale.border_width * 2;
130 int horizontal = (width >= height);
135 double left = x - width * 0.5 +
gmwScale.border_width;
146 double bottom = y - height * 0.5 +
gmwScale.border_width;
160 double knob_size = (horizontal ? sh : sw) * 1.5;
161 double knob_x, knob_y;
164 double left = x - sw * 0.5 + knob_size * 0.5;
165 double right = x + sw * 0.5 - knob_size * 0.5;
166 knob_x = left + (*anim) * (right - left);
169 double bottom = y - sh * 0.5 + knob_size * 0.5;
170 double top = y + sh * 0.5 - knob_size * 0.5;
171 knob_y = bottom + (*anim) * (top - bottom);
177 knob_size +
gmwScale.border_width * 2,
203static inline int gmw_scale(
double x,
double y,
double width,
double height,
Provides utility functions for animating numerical values using various easing effects.
void gm_anim_ease_out_quad(double *value, const double target, double t)
Animates a value towards a target with a quadratic ease-out effect.
Definition animate.h:56
Defines collision structures and provides functions for 2D collision detection.
int gm_mouse_in_rect(const double x, const double y, const double w, const double h)
Checks if the mouse cursor is currently within a given rectangular area.
Definition collision.h:172
uint32_t gmColor
Type definition for color values, stored as a 32-bit unsigned integer. The color components are packe...
Definition color.h:13
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 centered at a point.
Definition draw.h:57
struct _gmMouse gm_mouse
Definition mouse.h:32
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:79
gmwScaleTheme gmwScale
Global scale theme instance with default values.
Definition scale.h:46
Structure defining the visual theme for a scale (slider) widget.
Definition scale.h:18
gmColor knob_border
Definition scale.h:37
gmColor border
Definition scale.h:24
gmColor background
Definition scale.h:23
double step
Definition scale.h:40
int enabled
Definition scale.h:19
double border_width
Definition scale.h:39
gmColor knob
Definition scale.h:36
double scale
Definition scale.h:21