rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
ui_slider.c File Reference

The draggable value with presets. See ui_slider.h. More...

#include "ui_slider.h"
#include <string.h>
#include "ui_theme.h"
#include "ui_widgets.h"

Macros

#define SLIDER_SHADOW_DROP   2

Functions

static float clampf (float v, float lo, float hi)
void ui_slider_init (ui_slider_t *s, gfx_rect_t track, float min, float max, gfx_color_t color)
void ui_slider_set_ticks (ui_slider_t *s, int n)
void ui_slider_set_presets (ui_slider_t *s, const float *values, const char *const *labels, int count, gfx_rect_t row)
 Sets the presets, laid out in a row inside row with 4px gaps.
void ui_slider_set (ui_slider_t *s, float value)
void ui_slider_set_tap_to_set (ui_slider_t *s, bool on)
void ui_slider_release (ui_slider_t *s)
static bool by_delta (ui_slider_t *s, int x)
bool ui_slider_event (ui_slider_t *s, const touch_event_t *evt)
gfx_rect_t ui_slider_painted_rect (const ui_slider_t *s)
void ui_slider_render (const ui_slider_t *s, gfx_canvas_t *c)

Detailed Description

The draggable value with presets. See ui_slider.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ ui_slider_event()

bool ui_slider_event ( ui_slider_t * s,
const touch_event_t * evt )

Returns true when the value changed as a result of this event.

◆ ui_slider_painted_rect()

gfx_rect_t ui_slider_painted_rect ( const ui_slider_t * s)

Every pixel ui_slider_render may touch, the thumb's overhang and its shadow included. A caller that repaints the slider without repainting everything around it clears this and not the track, or the thumb's old positions stay on the screen.

◆ ui_slider_release()

void ui_slider_release ( ui_slider_t * s)

Abandon a drag that will get no release, on leaving a screen.

◆ ui_slider_set_presets()

void ui_slider_set_presets ( ui_slider_t * s,
const float * values,
const char *const * labels,
int count,
gfx_rect_t row )

Sets the presets, laid out in a row inside row with 4px gaps.

Parameters
sthe slider
valuesthe presets' values
labelstheir labels
counthow many
rowthe row they take

◆ ui_slider_set_tap_to_set()

void ui_slider_set_tap_to_set ( ui_slider_t * s,
bool on )

Let a press set the value under it. Off by default; a throttle must not take a value from one contact.

◆ ui_slider_set_ticks()

void ui_slider_set_ticks ( ui_slider_t * s,
int n )

Draw n scale divisions across the track. 0 turns them off.