2017-04-11 10:51:31 +02:00
|
|
|
/**
|
|
|
|
* @file lv_slider.h
|
2018-06-19 09:49:58 +02:00
|
|
|
*
|
2017-04-11 10:51:31 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_SLIDER_H
|
|
|
|
#define LV_SLIDER_H
|
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-04-11 10:51:31 +02:00
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2018-07-07 12:21:36 +02:00
|
|
|
#ifdef LV_CONF_INCLUDE_SIMPLE
|
2018-07-07 11:53:22 +02:00
|
|
|
#include "lv_conf.h"
|
|
|
|
#else
|
2019-03-17 08:33:03 +01:00
|
|
|
#include "../../../lv_conf.h"
|
2018-07-07 11:53:22 +02:00
|
|
|
#endif
|
|
|
|
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_SLIDER != 0
|
2017-04-11 10:51:31 +02:00
|
|
|
|
2018-01-19 15:40:22 +01:00
|
|
|
/*Testing of dependencies*/
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_BAR == 0
|
|
|
|
#error "lv_slider: lv_bar is required. Enable it in lv_conf.h (LV_USE_BAR 1) "
|
2018-01-19 15:40:22 +01:00
|
|
|
#endif
|
|
|
|
|
2017-11-30 11:35:33 +01:00
|
|
|
#include "../lv_core/lv_obj.h"
|
2017-04-11 10:51:31 +02:00
|
|
|
#include "lv_bar.h"
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
/*Data of slider*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2019-04-04 07:15:40 +02:00
|
|
|
lv_bar_ext_t bar; /*Ext. of ancestor*/
|
2017-04-11 10:51:31 +02:00
|
|
|
/*New data for this type */
|
2019-04-11 19:59:55 +08:00
|
|
|
const lv_style_t * style_knob; /*Style of the knob*/
|
2019-06-06 06:05:40 +02:00
|
|
|
int16_t drag_value; /*Store a temporal value during press until release (Handled by the library)*/
|
|
|
|
uint8_t knob_in : 1; /*1: Draw the knob inside the bar*/
|
2018-06-19 09:49:58 +02:00
|
|
|
} lv_slider_ext_t;
|
2017-04-11 10:51:31 +02:00
|
|
|
|
2019-06-27 18:07:26 -04:00
|
|
|
/** Built-in styles of slider*/
|
2019-04-04 07:15:40 +02:00
|
|
|
enum {
|
2019-06-27 18:07:26 -04:00
|
|
|
LV_SLIDER_STYLE_BG, /** Slider background style. */
|
|
|
|
LV_SLIDER_STYLE_INDIC, /** Slider indicator (filled area) style. */
|
|
|
|
LV_SLIDER_STYLE_KNOB, /** Slider knob style. */
|
2018-09-18 13:59:40 +02:00
|
|
|
};
|
|
|
|
typedef uint8_t lv_slider_style_t;
|
2017-04-11 10:51:31 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a slider objects
|
|
|
|
* @param par pointer to an object, it will be the parent of the new slider
|
|
|
|
* @param copy pointer to a slider object, if not NULL then the new object will be copied from it
|
|
|
|
* @return pointer to the created slider
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy);
|
2017-04-11 10:51:31 +02:00
|
|
|
|
2017-11-10 15:01:40 +01:00
|
|
|
/*=====================
|
|
|
|
* Setter functions
|
|
|
|
*====================*/
|
2017-11-03 13:39:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a new value on the slider
|
|
|
|
* @param slider pointer to a slider object
|
|
|
|
* @param value new value
|
2019-06-11 13:51:14 +02:00
|
|
|
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
|
2017-11-03 13:39:37 +01:00
|
|
|
*/
|
2019-06-11 13:51:14 +02:00
|
|
|
static inline void lv_slider_set_value(lv_obj_t * slider, int16_t value, lv_anim_enable_t anim)
|
2017-11-03 13:39:37 +01:00
|
|
|
{
|
2019-03-01 23:50:30 +01:00
|
|
|
lv_bar_set_value(slider, value, anim);
|
2017-11-03 13:39:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set minimum and the maximum values of a bar
|
|
|
|
* @param slider pointer to the slider object
|
|
|
|
* @param min minimum value
|
|
|
|
* @param max maximum value
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
static inline void lv_slider_set_range(lv_obj_t * slider, int16_t min, int16_t max)
|
2017-11-03 13:39:37 +01:00
|
|
|
{
|
|
|
|
lv_bar_set_range(slider, min, max);
|
|
|
|
}
|
|
|
|
|
2019-06-17 16:05:30 +02:00
|
|
|
/**
|
|
|
|
* Set the animation time of the slider
|
|
|
|
* @param slider pointer to a bar object
|
|
|
|
* @param anim_time the animation time in milliseconds.
|
|
|
|
*/
|
2019-06-17 16:07:34 +02:00
|
|
|
static inline void lv_slider_set_anim_time(lv_obj_t * slider, uint16_t anim_time)
|
2019-06-17 16:05:30 +02:00
|
|
|
{
|
|
|
|
lv_bar_set_anim_time(slider, anim_time);
|
|
|
|
}
|
|
|
|
|
2017-11-10 15:01:40 +01:00
|
|
|
/**
|
|
|
|
* Set the 'knob in' attribute of a slider
|
|
|
|
* @param slider pointer to slider object
|
|
|
|
* @param in true: the knob is drawn always in the slider;
|
|
|
|
* false: the knob can be out on the edges
|
|
|
|
*/
|
|
|
|
void lv_slider_set_knob_in(lv_obj_t * slider, bool in);
|
|
|
|
|
|
|
|
/**
|
2017-11-15 15:50:33 +01:00
|
|
|
* Set a style of a slider
|
2017-11-10 15:01:40 +01:00
|
|
|
* @param slider pointer to a slider object
|
2017-11-15 15:50:33 +01:00
|
|
|
* @param type which style should be set
|
|
|
|
* @param style pointer to a style
|
2017-11-10 15:01:40 +01:00
|
|
|
*/
|
2019-04-11 19:59:55 +08:00
|
|
|
void lv_slider_set_style(lv_obj_t * slider, lv_slider_style_t type, const lv_style_t * style);
|
2017-11-10 15:01:40 +01:00
|
|
|
|
|
|
|
/*=====================
|
|
|
|
* Getter functions
|
|
|
|
*====================*/
|
|
|
|
|
2017-11-03 13:39:37 +01:00
|
|
|
/**
|
|
|
|
* Get the value of a slider
|
|
|
|
* @param slider pointer to a slider object
|
|
|
|
* @return the value of the slider
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
int16_t lv_slider_get_value(const lv_obj_t * slider);
|
2017-11-03 13:39:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the minimum value of a slider
|
|
|
|
* @param slider pointer to a slider object
|
|
|
|
* @return the minimum value of the slider
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
static inline int16_t lv_slider_get_min_value(const lv_obj_t * slider)
|
2017-11-03 13:39:37 +01:00
|
|
|
{
|
|
|
|
return lv_bar_get_min_value(slider);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the maximum value of a slider
|
|
|
|
* @param slider pointer to a slider object
|
|
|
|
* @return the maximum value of the slider
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
static inline int16_t lv_slider_get_max_value(const lv_obj_t * slider)
|
2017-11-03 13:39:37 +01:00
|
|
|
{
|
|
|
|
return lv_bar_get_max_value(slider);
|
|
|
|
}
|
|
|
|
|
2017-11-10 15:01:40 +01:00
|
|
|
/**
|
2017-12-11 11:42:12 +01:00
|
|
|
* Give the slider is being dragged or not
|
2017-11-10 15:01:40 +01:00
|
|
|
* @param slider pointer to a slider object
|
2017-12-11 11:42:12 +01:00
|
|
|
* @return true: drag in progress false: not dragged
|
2017-11-10 15:01:40 +01:00
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
bool lv_slider_is_dragged(const lv_obj_t * slider);
|
2017-11-10 15:01:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the 'knob in' attribute of a slider
|
|
|
|
* @param slider pointer to slider object
|
|
|
|
* @return true: the knob is drawn always in the slider;
|
|
|
|
* false: the knob can be out on the edges
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
bool lv_slider_get_knob_in(const lv_obj_t * slider);
|
2017-11-03 13:39:37 +01:00
|
|
|
|
|
|
|
/**
|
2017-11-15 15:50:33 +01:00
|
|
|
* Get a style of a slider
|
|
|
|
* @param slider pointer to a slider object
|
|
|
|
* @param type which style should be get
|
|
|
|
* @return style pointer to a style
|
2017-11-03 13:39:37 +01:00
|
|
|
*/
|
2019-04-11 19:59:55 +08:00
|
|
|
const lv_style_t * lv_slider_get_style(const lv_obj_t * slider, lv_slider_style_t type);
|
2017-11-03 13:39:37 +01:00
|
|
|
|
2017-04-11 10:51:31 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2019-04-04 07:15:40 +02:00
|
|
|
#endif /*LV_USE_SLIDER*/
|
2017-04-11 10:51:31 +02:00
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
2017-04-11 10:51:31 +02:00
|
|
|
#endif
|
2017-07-09 15:32:49 +02:00
|
|
|
|
2019-04-04 07:15:40 +02:00
|
|
|
#endif /*LV_SLIDER_H*/
|