1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/lv_objx/lv_btn.h

88 lines
2.0 KiB
C
Raw Normal View History

2016-06-08 07:25:08 +02:00
/**
* @file lv_btn.h
*
*/
#ifndef LV_BTN_H
#define LV_BTN_H
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
2016-06-08 07:25:08 +02:00
#if USE_LV_BTN != 0
#include "lv_rect.h"
#include "../lv_obj/lv_dispi.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef enum
{
2016-06-15 09:38:20 +02:00
LV_BTN_STATE_PR,
LV_BTN_STATE_REL,
LV_BTN_STATE_TGL_PR,
LV_BTN_STATE_TGL_REL,
LV_BTN_STATE_INA,
LV_BTN_STATE_NUM,
2016-06-08 07:25:08 +02:00
}lv_btn_state_t;
typedef struct
{
2016-06-15 09:38:20 +02:00
lv_rects_t rects; /*To be compatible with the ancestor*/
color_t mcolor[LV_BTN_STATE_NUM];
color_t gcolor[LV_BTN_STATE_NUM];
color_t bcolor[LV_BTN_STATE_NUM];
2016-06-08 07:25:08 +02:00
}lv_btns_t;
typedef enum
{
LV_BTNS_DEF,
LV_BTNS_TRANSP,
LV_BTNS_BORDER,
}lv_btns_builtin_t;
typedef struct
{
2016-06-15 09:38:20 +02:00
lv_rect_ext_t rect_ext;
2016-06-08 07:25:08 +02:00
bool (*pr_action)(lv_obj_t*, lv_dispi_t *);
bool (*rel_action)(lv_obj_t*, lv_dispi_t *);
bool (*lpr_action)(lv_obj_t*, lv_dispi_t *);
lv_btn_state_t state;
uint8_t tgl :1; /*1: Toggle enabled*/
uint8_t lpr_exec :1; /*1: long press action executed (Not for user)*/
}lv_btn_ext_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/*Create function*/
lv_obj_t* lv_btn_create(lv_obj_t* par_dp, lv_obj_t * c_dp);
bool lv_btn_signal(lv_obj_t * obj_dp, lv_signal_t sign, void * param);
lv_btns_t * lv_btns_get(lv_btns_builtin_t style, lv_btns_t * copy_p);
void lv_btn_set_tgl(lv_obj_t* obj_dp, bool tgl);
void lv_btn_set_state(lv_obj_t* obj_dp, lv_btn_state_t state);
void lv_btn_set_pr_action(lv_obj_t* obi_p, bool (*pr_action)(lv_obj_t*, lv_dispi_t *));
void lv_btn_set_rel_action(lv_obj_t* obj_dp, bool (*rel_action)(lv_obj_t*, lv_dispi_t *));
void lv_btn_set_lpr_action(lv_obj_t* obj_dp, bool (*lpr_action)(lv_obj_t*, lv_dispi_t *));
bool lv_btn_get_tgl(lv_obj_t* obj_dp);
lv_btn_state_t lv_btn_get_state(lv_obj_t* obj_dp);
/**********************
* MACROS
**********************/
#endif
#endif