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

194 lines
4.8 KiB
C
Raw Normal View History

2016-08-04 11:33:35 +02:00
/**
2017-04-11 10:50:57 +02:00
* @file lv_bar.h
2018-06-19 09:49:58 +02:00
*
2016-08-04 11:33:35 +02:00
*/
2017-04-11 10:50:57 +02:00
#ifndef LV_BAR_H
#define LV_BAR_H
2016-08-04 11:33:35 +02:00
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2016-08-04 11:33:35 +02:00
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
2019-03-17 08:33:03 +01:00
#include "../../../lv_conf.h"
#endif
#if LV_USE_BAR != 0
2016-08-04 11:33:35 +02:00
2017-11-30 11:35:33 +01:00
#include "../lv_core/lv_obj.h"
#include "../lv_misc/lv_anim.h"
#include "lv_cont.h"
2017-02-03 12:48:22 +01:00
#include "lv_btn.h"
2016-08-04 11:33:35 +02:00
#include "lv_label.h"
/*********************
* DEFINES
*********************/
2019-06-24 05:59:43 +02:00
/** Bar animation start value. (Not the real value of the Bar just indicates process animation)*/
2019-04-04 07:15:40 +02:00
#define LV_BAR_ANIM_STATE_START 0
2019-06-24 05:59:43 +02:00
/** Bar animation end value. (Not the real value of the Bar just indicates process animation)*/
2019-04-04 07:15:40 +02:00
#define LV_BAR_ANIM_STATE_END 256
2019-06-24 05:59:43 +02:00
/** Mark no animation is in progress */
2019-04-04 07:15:40 +02:00
#define LV_BAR_ANIM_STATE_INV -1
2019-06-24 05:59:43 +02:00
/** log2(LV_BAR_ANIM_STATE_END) used to normalize data*/
#define LV_BAR_ANIM_STATE_NORM 8
2016-08-04 11:33:35 +02:00
LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_START);
LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_END);
LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_INV);
LV_EXPORT_CONST_INT(LV_BAR_ANIM_STATE_NORM);
2016-08-04 11:33:35 +02:00
/**********************
* TYPEDEFS
**********************/
2019-06-24 05:59:43 +02:00
/** Data of bar*/
typedef struct
{
2019-06-24 05:59:43 +02:00
/*No inherited ext, derived from the base object */
/*New data for this type */
2019-04-04 07:15:40 +02:00
int16_t cur_value; /*Current value of the bar*/
int16_t min_value; /*Minimum value of the bar*/
int16_t max_value; /*Maximum value of the bar*/
#if LV_USE_ANIMATION
lv_anim_value_t anim_start;
lv_anim_value_t anim_end;
lv_anim_value_t anim_state;
lv_anim_value_t anim_time;
#endif
2019-04-11 19:59:55 +08:00
uint8_t sym : 1; /*Symmetric: means the center is around zero value*/
const lv_style_t * style_indic; /*Style of the indicator*/
2018-06-19 09:49:58 +02:00
} lv_bar_ext_t;
2019-06-27 18:07:26 -04:00
/** Bar styles. */
2018-09-18 13:59:40 +02:00
enum {
2019-06-27 18:07:26 -04:00
LV_BAR_STYLE_BG, /** Bar background style. */
LV_BAR_STYLE_INDIC, /** Bar fill area style. */
2018-09-18 13:59:40 +02:00
};
typedef uint8_t lv_bar_style_t;
2016-08-04 11:33:35 +02:00
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
2017-04-21 09:15:39 +02:00
* Create a bar objects
* @param par pointer to an object, it will be the parent of the new bar
* @param copy pointer to a bar object, if not NULL then the new object will be copied from it
* @return pointer to the created bar
*/
lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy);
2017-11-10 15:01:40 +01:00
/*=====================
* Setter functions
*====================*/
/**
2017-04-21 09:15:39 +02:00
* Set a new value on the bar
* @param bar pointer to a bar 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
*/
2019-06-11 13:51:14 +02:00
void lv_bar_set_value(lv_obj_t * bar, int16_t value, lv_anim_enable_t anim);
2017-11-10 15:01:40 +01:00
/**
2017-04-21 09:15:39 +02:00
* Set minimum and the maximum values of a bar
2017-11-10 15:01:40 +01:00
* @param bar pointer to the bar object
* @param min minimum value
* @param max maximum value
*/
2017-04-11 10:50:57 +02:00
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max);
/**
2019-04-04 07:15:40 +02:00
* Make the bar symmetric to zero. The indicator will grow from zero instead of the minimum
* position.
* @param bar pointer to a bar object
* @param en true: enable disable symmetric behavior; false: disable
*/
void lv_bar_set_sym(lv_obj_t * bar, bool en);
2019-06-17 16:05:30 +02:00
/**
* Set the animation time of the bar
* @param bar pointer to a bar object
* @param anim_time the animation time in milliseconds.
*/
void lv_bar_set_anim_time(lv_obj_t * bar, uint16_t anim_time);
/**
* Set a style of a bar
2017-04-21 09:15:39 +02:00
* @param bar pointer to a bar object
* @param type which style should be set
* @param style pointer to a style
*/
2019-04-11 19:59:55 +08:00
void lv_bar_set_style(lv_obj_t * bar, lv_bar_style_t type, const lv_style_t * style);
2017-11-10 15:01:40 +01:00
/*=====================
* Getter functions
*====================*/
/**
2017-04-21 09:15:39 +02:00
* Get the value of a bar
* @param bar pointer to a bar object
* @return the value of the bar
*/
int16_t lv_bar_get_value(const lv_obj_t * bar);
2017-04-21 09:15:39 +02:00
/**
* Get the minimum value of a bar
* @param bar pointer to a bar object
* @return the minimum value of the bar
*/
int16_t lv_bar_get_min_value(const lv_obj_t * bar);
2017-04-21 09:15:39 +02:00
/**
* Get the maximum value of a bar
* @param bar pointer to a bar object
* @return the maximum value of the bar
*/
int16_t lv_bar_get_max_value(const lv_obj_t * bar);
2017-04-21 09:15:39 +02:00
/**
* Get whether the bar is symmetric or not.
* @param bar pointer to a bar object
* @return true: symmetric is enabled; false: disable
*/
bool lv_bar_get_sym(lv_obj_t * bar);
2017-04-21 09:15:39 +02:00
2019-06-17 16:05:30 +02:00
/**
* Get the animation time of the bar
* @param bar pointer to a bar object
* @return the animation time in milliseconds.
*/
2019-06-19 00:40:20 +02:00
uint16_t lv_bar_get_anim_time(lv_obj_t * bar);
2019-06-17 16:05:30 +02:00
2017-11-10 15:01:40 +01:00
/**
* Get a style of a bar
2017-11-10 15:01:40 +01:00
* @param bar pointer to a bar object
* @param type which style should be get
* @return style pointer to a style
2017-11-10 15:01:40 +01:00
*/
2019-04-11 19:59:55 +08:00
const lv_style_t * lv_bar_get_style(const lv_obj_t * bar, lv_bar_style_t type);
2017-11-10 15:01:40 +01:00
2016-08-04 11:33:35 +02:00
/**********************
* MACROS
**********************/
2019-04-04 07:15:40 +02:00
#endif /*LV_USE_BAR*/
2016-08-04 11:33:35 +02:00
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
} /* extern "C" */
2016-08-04 11:33:35 +02:00
#endif
2017-07-09 15:32:49 +02:00
#endif /*LV_BAR_H*/