Files
lvgl/lv_objx/lv_page.h
2017-01-13 23:27:49 +01:00

145 lines
3.6 KiB
C

/**
* @file lv_page.h
*
*/
#ifndef LV_PAGE_H
#define LV_PAGE_H
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_PAGE != 0
/*Testing of dependencies*/
#if USE_LV_RECT == 0
#error "lv_page: lv_rect is required. Enable it in lv_conf.h (USE_LV_RECT 1) "
#endif
#include "../lv_obj/lv_obj.h"
#include "lv_rect.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef enum
{
LV_PAGE_SB_MODE_OFF,
LV_PAGE_SB_MODE_ON,
LV_PAGE_SB_MODE_DRAG,
LV_PAGE_SB_MODE_AUTO,
}lv_page_sb_mode_t;
/*Style of page*/
typedef struct
{
lv_rects_t bg_rects; /*Style of ancestor*/
/*New style element for this type */
lv_rects_t scrl_rects;
lv_rects_t sb_rects;
cord_t sb_width;
lv_page_sb_mode_t sb_mode;
uint8_t sb_opa;
}lv_pages_t;
/*Built-in styles of page*/
typedef enum
{
LV_PAGES_DEF,
LV_PAGES_SIMPLE,
LV_PAGES_TRANSP,
}lv_pages_builtin_t;
/*Data of page*/
typedef struct
{
lv_rect_ext_t rect_ext; /*Ext. of ancestor*/
/*New data for this type */
lv_obj_t * scrl; /*The scrollable object on the background*/
lv_action_t rel_action;
lv_action_t pr_action;
area_t sbh; /*Horizontal scrollbar*/
area_t sbv; /*Vertical scrollbar*/
uint8_t sbh_draw :1; /*1: horizontal scrollbar is visible now*/
uint8_t sbv_draw :1; /*1: vertical scrollbar is visible now*/
}lv_page_ext_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a page objects
* @param par pointer to an object, it will be the parent of the new page
* @param copy pointer to a page object, if not NULL then the new object will be copied from it
* @return pointer to the created page
*/
lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the page
* @param page pointer to a page object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
/**
* Set a release action for the page
* @param page pointer to a page object
* @param rel_action a function to call when the page is released
*/
void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action);
/**
* Set a press action for the page
* @param page pointer to a page object
* @param pr_action a function to call when the page is pressed
*/
void lv_page_set_pr_action(lv_obj_t * page, lv_action_t pr_action);
/**
* Glue the object to the page. After it the page can be moved (dragged) with this object too.
* @param obj pointer to an object on a page
* @param glue true: enable glue, false: disable glue
*/
void lv_page_glue_obj(lv_obj_t * obj, bool glue);
/**
* Focus on an object. It ensures that the object will be visible on the page.
* @param page pointer to a page object
* @param obj pointer to an object to focus (must be on the page)
* @param anim_en true: scroll with animation
*/
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, bool anim_en);
/**
* Get the scrollable object of a page-
* @param page pointer to page object
* @return pointer to rectangle which is the scrollable part of the page
*/
lv_obj_t * lv_page_get_scrl(lv_obj_t * page);
/**
* Return with a pointer to a built-in style and/or copy it to a variable
* @param style a style name from lv_pages_builtin_t enum
* @param copy copy the style to this variable. (NULL if unused)
* @return pointer to an lv_pages_t style
*/
lv_pages_t * lv_pages_get(lv_pages_builtin_t style, lv_pages_t * copy);
/**********************
* MACROS
**********************/
#endif
#endif