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

179 lines
4.4 KiB
C
Raw Normal View History

2018-11-25 12:02:16 +01:00
/**
* @file lv_tileview.h
*
*/
#ifndef LV_TILEVIEW_H
#define LV_TILEVIEW_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
2019-03-17 08:33:03 +01:00
#include "../../../lv_conf.h"
2018-11-25 12:02:16 +01:00
#endif
#if LV_USE_TILEVIEW != 0
2018-11-25 12:02:16 +01:00
#include "../lv_objx/lv_page.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of tileview*/
2019-04-04 07:15:40 +02:00
typedef struct
{
2018-11-25 12:02:16 +01:00
lv_page_ext_t page;
/*New data for this type */
const lv_point_t * valid_pos;
2019-06-20 14:28:25 +02:00
uint16_t valid_pos_cnt;
#if LV_USE_ANIMATION
2018-11-25 12:02:16 +01:00
uint16_t anim_time;
#endif
2018-11-25 12:02:16 +01:00
lv_point_t act_id;
2019-04-04 07:15:40 +02:00
uint8_t drag_top_en : 1;
uint8_t drag_bottom_en : 1;
uint8_t drag_left_en : 1;
uint8_t drag_right_en : 1;
uint8_t drag_hor : 1;
uint8_t drag_ver : 1;
2018-11-25 12:02:16 +01:00
} lv_tileview_ext_t;
/*Styles*/
enum {
2019-06-20 14:28:25 +02:00
LV_TILEVIEW_STYLE_MAIN,
2018-11-25 12:02:16 +01:00
};
typedef uint8_t lv_tileview_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a tileview objects
* @param par pointer to an object, it will be the parent of the new tileview
* @param copy pointer to a tileview object, if not NULL then the new object will be copied from it
* @return pointer to the created tileview
*/
lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy);
/*======================
* Add/remove functions
*=====================*/
/**
* Register an object on the tileview. The register object will able to slide the tileview
2019-03-15 05:45:27 +01:00
* @param tileview pointer to a Tileview object
2018-11-25 12:02:16 +01:00
* @param element pointer to an object
*/
2019-03-15 05:45:27 +01:00
void lv_tileview_add_element(lv_obj_t * tileview, lv_obj_t * element);
2018-11-25 12:02:16 +01:00
/*=====================
* Setter functions
*====================*/
/**
* Set the valid position's indices. The scrolling will be possible only to these positions.
* @param tileview pointer to a Tileview object
2019-06-20 14:28:25 +02:00
* @param valid_pos array width the indices. E.g. `lv_point_t p[] = {{0,0}, {1,0}, {1,1}`. Only the
2019-04-04 07:15:40 +02:00
* pointer is saved so can't be a local variable.
2019-06-20 14:28:25 +02:00
* @param valid_pos_cnt numner of elements in `valid_pos` array
2018-11-25 12:02:16 +01:00
*/
2019-06-20 14:28:25 +02:00
void lv_tileview_set_valid_positions(lv_obj_t * tileview, const lv_point_t * valid_pos, uint16_t valid_pos_cnt);
2018-11-25 12:02:16 +01:00
/**
* Set the tile to be shown
* @param tileview pointer to a tileview object
* @param x column id (0, 1, 2...)
* @param y line id (0, 1, 2...)
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
2018-11-25 12:02:16 +01:00
*/
2019-06-11 13:51:14 +02:00
void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim);
2018-11-25 12:02:16 +01:00
/**
* Enable the edge flash effect. (Show an arc when the an edge is reached)
* @param tileview pointer to a Tileview
* @param en true or false to enable/disable end flash
*/
static inline void lv_tileview_set_edge_flash(lv_obj_t * tileview, bool en)
{
lv_page_set_edge_flash(tileview, en);
}
2019-06-20 14:28:25 +02:00
/**
* Set the animation time for the Tile view
* @param tileview pointer to a page object
* @param anim_time animation time in milliseconds
*/
static inline void lv_tileview_set_anim_time(lv_obj_t * tileview, uint16_t anim_time)
{
lv_page_set_anim_time(tileview, anim_time);
}
2018-11-25 12:02:16 +01:00
/**
* Set a style of a tileview.
* @param tileview pointer to tileview object
* @param type which style should be set
* @param style pointer to a style
*/
2019-04-11 19:59:55 +08:00
void lv_tileview_set_style(lv_obj_t * tileview, lv_tileview_style_t type, const lv_style_t * style);
2018-11-25 12:02:16 +01:00
/*=====================
* Getter functions
*====================*/
/**
* Get the scroll propagation property
* @param tileview pointer to a Tileview
* @return true or false
*/
static inline bool lv_tileview_get_edge_flash(lv_obj_t * tileview)
{
return lv_page_get_edge_flash(tileview);
}
2019-06-20 14:28:25 +02:00
/**
* Get the animation time for the Tile view
* @param tileview pointer to a page object
* @return animation time in milliseconds
*/
static inline uint16_t lv_tileview_get_anim_time(lv_obj_t * tileview)
{
return lv_page_get_anim_time(tileview);
}
2018-11-25 12:02:16 +01:00
/**
* Get style of a tileview.
* @param tileview pointer to tileview object
* @param type which style should be get
* @return style pointer to the style
*/
2019-04-11 19:59:55 +08:00
const lv_style_t * lv_tileview_get_style(const lv_obj_t * tileview, lv_tileview_style_t type);
2018-11-25 12:02:16 +01:00
/*=====================
* Other functions
*====================*/
/**********************
* MACROS
**********************/
2019-04-04 07:15:40 +02:00
#endif /*LV_USE_TILEVIEW*/
2018-11-25 12:02:16 +01:00
#ifdef __cplusplus
} /* extern "C" */
#endif
2019-04-04 07:15:40 +02:00
#endif /*LV_TILEVIEW_H*/