|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
slider.h — the slider element: an integer value in [minimum, maximum] shown as a thumb travelling a track, with optional detent notches. More...
#include <stddef.h>#include <stdint.h>#include "fb.h"#include "geom.h"#include "input.h"#include "style.h"#include "draw_target.h"Data Structures | |
| struct | rmgui_slider_t |
| Retained slider state. More... | |
Functions | |
| int | rmgui_slider_init (rmgui_slider_t *self, int64_t minimum, int64_t maximum, int64_t value) |
| Initializes self to value in [minimum, maximum] with an empty state set and no capture. | |
| rmgui_size_t | rmgui_slider_measure (const rmgui_style_resolved_t *rs) |
| Minimum outer size of a slider: {2 * thumb_width, max(thumb_width, track_height) + 4}, so the thumb travels at least its own width, stands at least as tall as it is wide inside its 2-pixel top and bottom margins, and the detent ticks (track_height + 4 tall) fit. | |
| rmgui_rect_t | rmgui_slider_thumb_rect (const rmgui_slider_t *self, const rmgui_style_resolved_t *rs, rmgui_rect_t rect) |
| The thumb's rect for self's value in the slider arranged at rect: with track_x = rect.x + thumb_width / 2 and track_w = max(0, rect.w - thumb_width), its centre column is thumb_x = track_x + (value - minimum) * track_w / (maximum - minimum) (int64_t, truncating), its rect {thumb_x - thumb_width / 2, rect.y + 2, thumb_width, max(0, rect.h - 4)}. | |
| void | rmgui_slider_paint (rmgui_fb_t *fb, const rmgui_style_resolved_t *rs, rmgui_rect_t rect, rmgui_rect_t clip, const rmgui_slider_t *self, const int64_t *detents, size_t detent_count) |
| Paints the slider arranged at rect: the track (rs->background, track_w wide, rs->track_height tall, centred vertically), the filled part from track_x up to the thumb column (rs->track_filled), one rs->tick mark per detent (1 pixel wide, track_height + 4 tall, at the detent's thumb column; detents outside [minimum, maximum] are skipped), then the thumb (rmgui_slider_thumb_rect, rs->thumb with a rs->border stroke). | |
| rmgui_input_result_t | rmgui_slider_input (rmgui_slider_t *self, const rmgui_style_resolved_t *rs, rmgui_rect_t rect, const rmgui_input_t *in) |
| Applies one event to the slider arranged at rect (rs resolved for SLIDER). | |
| void | rmgui_slider_paint_to (rmgui_target_t *, const rmgui_style_resolved_t *, rmgui_rect_t, rmgui_rect_t, const rmgui_slider_t *, const int64_t *, size_t) |
| Explicit slider destination with identical detents and skin dispatch. | |
slider.h — the slider element: an integer value in [minimum, maximum] shown as a thumb travelling a track, with optional detent notches.
| int rmgui_slider_init | ( | rmgui_slider_t * | self, |
| int64_t | minimum, | ||
| int64_t | maximum, | ||
| int64_t | value ) |
Initializes self to value in [minimum, maximum] with an empty state set and no capture.
Returns 0, or -1 with self unchanged when self is NULL, minimum >= maximum, or value lies outside the range.
| rmgui_size_t rmgui_slider_measure | ( | const rmgui_style_resolved_t * | rs | ) |
Minimum outer size of a slider: {2 * thumb_width, max(thumb_width, track_height) + 4}, so the thumb travels at least its own width, stands at least as tall as it is wide inside its 2-pixel top and bottom margins, and the detent ticks (track_height + 4 tall) fit.
rs is resolved for SLIDER; NULL yields {0, 0}.
| rmgui_rect_t rmgui_slider_thumb_rect | ( | const rmgui_slider_t * | self, |
| const rmgui_style_resolved_t * | rs, | ||
| rmgui_rect_t | rect ) |
The thumb's rect for self's value in the slider arranged at rect: with track_x = rect.x + thumb_width / 2 and track_w = max(0, rect.w - thumb_width), its centre column is thumb_x = track_x + (value - minimum) * track_w / (maximum - minimum) (int64_t, truncating), its rect {thumb_x - thumb_width / 2, rect.y + 2, thumb_width, max(0, rect.h - 4)}.
A value outside the range is clamped; a state with minimum >= maximum places the thumb at track_x. NULL rs or self yields a zero rect.
| void rmgui_slider_paint | ( | rmgui_fb_t * | fb, |
| const rmgui_style_resolved_t * | rs, | ||
| rmgui_rect_t | rect, | ||
| rmgui_rect_t | clip, | ||
| const rmgui_slider_t * | self, | ||
| const int64_t * | detents, | ||
| size_t | detent_count ) |
Paints the slider arranged at rect: the track (rs->background, track_w wide, rs->track_height tall, centred vertically), the filled part from track_x up to the thumb column (rs->track_filled), one rs->tick mark per detent (1 pixel wide, track_height + 4 tall, at the detent's thumb column; detents outside [minimum, maximum] are skipped), then the thumb (rmgui_slider_thumb_rect, rs->thumb with a rs->border stroke).
Writes only pixels inside the intersection of rect and clip. NULL fb, rs or self paints nothing; detents may be NULL only when detent_count is 0.
| rmgui_input_result_t rmgui_slider_input | ( | rmgui_slider_t * | self, |
| const rmgui_style_resolved_t * | rs, | ||
| rmgui_rect_t | rect, | ||
| const rmgui_input_t * | in ) |
Applies one event to the slider arranged at rect (rs resolved for SLIDER).
The pointer maps to value = minimum + (clamp(x - track_x, 0, track_w) * (maximum - minimum)
| void rmgui_slider_paint_to | ( | rmgui_target_t * | , |
| const rmgui_style_resolved_t * | , | ||
| rmgui_rect_t | , | ||
| rmgui_rect_t | , | ||
| const rmgui_slider_t * | , | ||
| const int64_t * | , | ||
| size_t | ) |
Explicit slider destination with identical detents and skin dispatch.
RECORD pins sheets and appends bounded value commands; failures latch.