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

95 lines
2.2 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;
2016-10-07 11:15:46 +02:00
/*Style of button*/
2016-06-08 07:25:08 +02:00
typedef struct
{
2016-10-07 11:15:46 +02:00
lv_rects_t rects; /*Style of ancestor*/
/*New style element for this type */
2016-06-15 09:38:20 +02:00
color_t mcolor[LV_BTN_STATE_NUM];
color_t gcolor[LV_BTN_STATE_NUM];
color_t bcolor[LV_BTN_STATE_NUM];
color_t lcolor[LV_BTN_STATE_NUM];
uint8_t light_en[LV_BTN_STATE_NUM];
2016-06-08 07:25:08 +02:00
}lv_btns_t;
2016-10-07 11:15:46 +02:00
/*Built-in styles of button*/
2016-06-08 07:25:08 +02:00
typedef enum
{
LV_BTNS_DEF,
LV_BTNS_TRANSP,
LV_BTNS_BORDER,
}lv_btns_builtin_t;
2016-10-07 11:15:46 +02:00
/*Data of button*/
2016-06-08 07:25:08 +02:00
typedef struct
{
2016-10-07 11:15:46 +02:00
lv_rect_ext_t rect_ext; /*Ext. of ancestor*/
/*New data for this type */
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 *);
2016-06-08 07:25:08 +02:00
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*/
2016-10-07 11:15:46 +02:00
lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy);
2016-06-08 07:25:08 +02:00
2016-10-07 11:15:46 +02:00
bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param);
lv_btns_t * lv_btns_get(lv_btns_builtin_t style, lv_btns_t * copy);
2016-06-08 07:25:08 +02:00
2016-10-07 11:15:46 +02:00
void lv_btn_set_tgl(lv_obj_t * btn, bool tgl);
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state);
void lv_btn_set_pr_action(lv_obj_t * btn, bool (*pr_action)(lv_obj_t *, lv_dispi_t *));
void lv_btn_set_rel_action(lv_obj_t * btn, bool (*rel_action)(lv_obj_t *, lv_dispi_t *));
void lv_btn_set_lpr_action(lv_obj_t * btn, bool (*lpr_action)(lv_obj_t *, lv_dispi_t *));
2016-06-08 07:25:08 +02:00
2016-10-07 11:15:46 +02:00
bool lv_btn_get_tgl(lv_obj_t * btn);
lv_btn_state_t lv_btn_get_state(lv_obj_t * btn);
2016-06-08 07:25:08 +02:00
/**********************
* MACROS
**********************/
#endif
#endif