58 .background = 0x2A1E2AE0,
61 .knob_border = 0x5F4F5FFF,
67 .background = 0x4A2A4AE8,
70 .knob_border = 0xAA77AAFF,
87 .border_width = 0.01};
111 int clicked = enabled &&
gm_mouse.clicked && hovered;
125 knob_pos = (double)(*value);
127 int on = *value != 0;
143 double sw = width * scale;
144 double sh = height * scale;
148 sh +
gmwSwitch.border_width * 2, border);
154 double knob_size = sh * 0.8;
155 double knob_x_offset = (knob_pos * 2 - 1) *
156 (sw * 0.5 - knob_size * 0.5 -
gmwSwitch.border_width);
160 knob_size +
gmwSwitch.border_width * 2, knob_b);
182int gmw_switch(
double x,
double y,
double width,
double height,
int *value) {
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
Structure defining the visual theme for a switch widget.
Definition switch.h:18
double scale
Definition switch.h:21
gmColor knob
Definition switch.h:26
gmColor knob_border
Definition switch.h:27
double border_width
Definition switch.h:47
gmColor border
Definition switch.h:25
int enabled
Definition switch.h:19
gmColor background
Definition switch.h:24
int gmw_switch(double x, double y, double width, double height, int *value)
Creates and renders a switch widget that toggles on click (non-animated version).
Definition switch.h:182
int gmw_switch_anim(double x, double y, double width, double height, int *value, double *anim)
Creates and renders an animated switch widget that toggles on click.
Definition switch.h:105
gmwSwitchTheme gmwSwitch
Global switch theme instance with default values.
Definition switch.h:53