1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/src/lv_widgets/lv_spinner.h

181 lines
4.2 KiB
C
Raw Normal View History

2018-06-09 08:47:09 +02:00
/**
* @file lv_spinner.h
2018-06-19 09:49:58 +02:00
*
2018-06-09 08:47:09 +02:00
*/
#ifndef LV_SPINNER_H
#define LV_SPINNER_H
2018-06-09 08:47:09 +02:00
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_SPINNER != 0
2018-06-09 08:47:09 +02:00
/*Testing of dependencies*/
#if LV_USE_ARC == 0
#error "lv_spinner: lv_arc is required. Enable it in lv_conf.h (LV_USE_ARC 1) "
#endif
#if LV_USE_ANIMATION == 0
#error "lv_spinner: animations are required. Enable it in lv_conf.h (LV_USE_ANIMATION 1) "
#endif
2018-06-09 08:47:09 +02:00
#include "../lv_core/lv_obj.h"
#include "../lv_misc/lv_anim.h"
2018-06-09 08:47:09 +02:00
#include "lv_arc.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
2019-06-27 18:07:26 -04:00
/**
* Type of spinner.
2019-06-27 18:07:26 -04:00
*/
2018-09-18 13:59:40 +02:00
enum {
LV_SPINNER_TYPE_SPINNING_ARC,
LV_SPINNER_TYPE_FILLSPIN_ARC,
LV_SPINNER_TYPE_CONSTANT_ARC,
2018-09-18 13:59:40 +02:00
};
typedef uint8_t lv_spinner_type_t;
2018-06-09 08:47:09 +02:00
2019-06-27 18:07:26 -04:00
/**
* Direction the spinner should spin.
2019-06-27 18:07:26 -04:00
*/
enum {
LV_SPINNER_DIR_FORWARD,
LV_SPINNER_DIR_BACKWARD,
};
typedef uint8_t lv_spinner_dir_t;
/*Data of spinner*/
2020-02-26 19:48:27 +01:00
typedef struct {
2018-06-09 08:47:09 +02:00
lv_arc_ext_t arc; /*Ext. of ancestor*/
/*New data for this type */
2019-06-06 06:05:40 +02:00
lv_anim_value_t arc_length; /*Length of the spinning indicator in degree*/
uint16_t time; /*Time of one round*/
lv_spinner_type_t anim_type : 2; /*Type of the arc animation*/
lv_spinner_dir_t anim_dir : 1; /*Animation Direction*/
} lv_spinner_ext_t;
2018-06-09 08:47:09 +02:00
/*Parts of the spinner*/
2018-09-18 13:59:40 +02:00
enum {
LV_SPINNER_PART_BG = LV_ARC_PART_BG,
2020-03-09 15:19:23 +01:00
LV_SPINNER_PART_INDIC = LV_ARC_PART_INDIC,
_LV_SPINNER_PART_VIRTUAL_LAST,
_LV_SPINNER_PART_REAL_LAST = _LV_ARC_PART_REAL_LAST,
2018-09-18 13:59:40 +02:00
};
typedef uint8_t lv_spinner_style_t;
2018-06-09 08:47:09 +02:00
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a spinner object
* @param par pointer to an object, it will be the parent of the new spinner
* @param copy pointer to a spinner object, if not NULL then the new object will be copied from
2019-04-04 07:15:40 +02:00
* it
* @return pointer to the created spinner
2018-06-09 08:47:09 +02:00
*/
lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy);
2018-06-09 08:47:09 +02:00
/*======================
* Add/remove functions
*=====================*/
2018-06-11 10:36:36 +02:00
/**
* Set the length of the spinning arc in degrees
* @param spinner pointer to a spinner object
2018-06-11 10:36:36 +02:00
* @param deg length of the arc
*/
void lv_spinner_set_arc_length(lv_obj_t * spinner, lv_anim_value_t deg);
2018-06-11 10:36:36 +02:00
/**
* Set the spin time of the arc
* @param spinner pointer to a spinner object
2018-06-11 10:36:36 +02:00
* @param time time of one round in milliseconds
*/
void lv_spinner_set_spin_time(lv_obj_t * spinner, uint16_t time);
2018-06-09 08:47:09 +02:00
/*=====================
* Setter functions
*====================*/
/**
* Set the animation type of a spinner.
* @param spinner pointer to spinner object
* @param type animation type of the spinner
* */
void lv_spinner_set_type(lv_obj_t * spinner, lv_spinner_type_t type);
/**
* Set the animation direction of a spinner
* @param spinner pointer to spinner object
* @param direction animation direction of the spinner
*/
void lv_spinner_set_dir(lv_obj_t * spinner, lv_spinner_dir_t dir);
2018-06-09 08:47:09 +02:00
/*=====================
* Getter functions
*====================*/
2018-06-11 10:36:36 +02:00
/**
* Get the arc length [degree] of the a spinner
* @param spinner pointer to a spinner object
2018-06-11 10:36:36 +02:00
*/
lv_anim_value_t lv_spinner_get_arc_length(const lv_obj_t * spinner);
2018-06-11 10:36:36 +02:00
/**
* Get the spin time of the arc
* @param spinner pointer to a spinner object [milliseconds]
2018-06-11 10:36:36 +02:00
*/
uint16_t lv_spinner_get_spin_time(const lv_obj_t * spinner);
2018-06-11 10:36:36 +02:00
/**
* Get the animation type of a spinner.
* @param spinner pointer to spinner object
* @return animation type
* */
lv_spinner_type_t lv_spinner_get_type(lv_obj_t * spinner);
/**
* Get the animation direction of a spinner
* @param spinner pointer to spinner object
* @return animation direction
*/
lv_spinner_dir_t lv_spinner_get_dir(lv_obj_t * spinner);
2018-06-09 08:47:09 +02:00
/*=====================
* Other functions
*====================*/
/**
2019-06-20 06:20:23 +02:00
* Animator function (exec_cb) to rotate the arc of spinner.
* @param ptr pointer to spinner
2019-06-20 06:20:23 +02:00
* @param val the current desired value [0..360]
*/
void lv_spinner_anim_cb(void * ptr, lv_anim_value_t val);
2018-06-09 08:47:09 +02:00
/**********************
* MACROS
**********************/
#endif /*LV_USE_SPINNER*/
2018-06-09 08:47:09 +02:00
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_SPINNER_H*/