50 .background = 0x2A1E2AE0,
53 .knob_border = 0x5F4F5FFF,
59 .background = 0x4A2A4AE8,
62 .knob_border = 0xAA77AAFF,
79 .border_width = 0.01};
98 int clicked = enabled &&
gm_mouse.pressed && hovered;
112 knob_pos = (double)(*value);
114 int on = *value != 0;
130 double sw = width * scale;
131 double sh = height * scale;
135 sh +
gmwSwitch.border_width * 2, border);
141 double knob_size = sh * 0.8;
142 double knob_x_offset = (knob_pos * 2 - 1) *
143 (sw * 0.5 - knob_size * 0.5 -
gmwSwitch.border_width);
147 knob_size +
gmwSwitch.border_width * 2, knob_b);
164int gmw_switch(
double x,
double y,
double width,
double height,
int *value) {
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
Structure defining the visual theme for a switch widget.
Definition switch.h:10
double scale
Definition switch.h:13
gmColor knob
Definition switch.h:18
gmColor knob_border
Definition switch.h:19
double border_width
Definition switch.h:39
gmColor border
Definition switch.h:17
int enabled
Definition switch.h:11
gmColor background
Definition switch.h:16
int gmw_switch(double x, double y, double width, double height, int *value)
Creates and renders a switch widget that toggles on click.
Definition switch.h:164
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:92
gmwSwitchTheme gmwSwitch
Global switch theme instance with default values.
Definition switch.h:45