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

185 lines
5.0 KiB
C
Raw Normal View History

2017-04-13 16:12:03 +02:00
/**
* @file lv_cont.h
2018-06-19 09:49:58 +02:00
*
2017-04-13 16:12:03 +02:00
*/
#ifndef LV_CONT_H
#define LV_CONT_H
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2017-04-13 16:12:03 +02:00
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_CONT != 0
2017-04-13 16:12:03 +02:00
2017-11-30 11:35:33 +01:00
#include "../lv_core/lv_obj.h"
2017-04-13 16:12:03 +02:00
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
2019-06-27 18:07:26 -04:00
/** Container layout options*/
2019-04-04 07:15:40 +02:00
enum {
2019-06-27 18:07:26 -04:00
LV_LAYOUT_OFF = 0, /**< No layout */
LV_LAYOUT_CENTER, /**< Center objects */
LV_LAYOUT_COL_L, /**< Column left align*/
LV_LAYOUT_COL_M, /**< Column middle align*/
LV_LAYOUT_COL_R, /**< Column right align*/
LV_LAYOUT_ROW_T, /**< Row top align*/
LV_LAYOUT_ROW_M, /**< Row middle align*/
LV_LAYOUT_ROW_B, /**< Row bottom align*/
LV_LAYOUT_PRETTY, /**< Put as many object as possible in row and begin a new row*/
LV_LAYOUT_GRID, /**< Align same-sized object into a grid*/
2019-06-27 07:16:15 +02:00
_LV_LAYOUT_NUM
2018-09-18 13:59:40 +02:00
};
typedef uint8_t lv_layout_t;
2017-04-13 16:12:03 +02:00
2019-06-27 18:07:26 -04:00
/**
* How to resize the container around the children.
*/
enum {
2019-06-27 18:07:26 -04:00
LV_FIT_NONE, /**< Do not change the size automatically*/
LV_FIT_TIGHT, /**< Shrink wrap around the children */
LV_FIT_FLOOD, /**< Align the size to the parent's edge*/
LV_FIT_FILL, /**< Align the size to the parent's edge first but if there is an object out of it
then get larger */
2019-06-27 07:16:15 +02:00
_LV_FIT_NUM
};
typedef uint8_t lv_fit_t;
2017-04-13 16:12:03 +02:00
typedef struct
{
/*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/
/*New data for this type */
2019-09-06 19:53:39 +02:00
lv_layout_t layout : 4; /*A layout from 'lv_layout_t' enum*/
lv_fit_t fit_left : 2; /*A fit type from `lv_fit_t` enum */
lv_fit_t fit_right : 2; /*A fit type from `lv_fit_t` enum */
lv_fit_t fit_top : 2; /*A fit type from `lv_fit_t` enum */
lv_fit_t fit_bottom : 2; /*A fit type from `lv_fit_t` enum */
2018-10-05 17:22:49 +02:00
} lv_cont_ext_t;
2017-04-13 16:12:03 +02:00
/*Styles*/
enum {
LV_CONT_PART_MAIN = LV_OBJ_PART_MAIN,
_LV_CONT_PART_VIRTUAL_LAST = _LV_OBJ_PART_VIRTUAL_LAST,
_LV_CONT_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST,
};
typedef uint8_t lv_cont_part_t;
2017-04-13 16:12:03 +02:00
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a container objects
* @param par pointer to an object, it will be the parent of the new container
* @param copy pointer to a container object, if not NULL then the new object will be copied from it
* @return pointer to the created container
*/
lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy);
2017-04-13 16:12:03 +02:00
2017-11-10 15:01:40 +01:00
/*=====================
* Setter functions
*====================*/
2017-04-13 16:12:03 +02:00
/**
2017-11-10 15:01:40 +01:00
* Set a layout on a container
2017-04-13 16:12:03 +02:00
* @param cont pointer to a container object
* @param layout a layout from 'lv_cont_layout_t'
*/
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout);
2017-04-13 16:12:03 +02:00
/**
* Set the fit policy in all 4 directions separately.
* It tell how to change the container's size automatically.
* @param cont pointer to a container object
* @param left left fit policy from `lv_fit_t`
* @param right right fit policy from `lv_fit_t`
2019-07-10 11:56:36 +02:00
* @param top top fit policy from `lv_fit_t`
* @param bottom bottom fit policy from `lv_fit_t`
*/
2019-06-06 06:05:40 +02:00
void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom);
2017-11-10 15:01:40 +01:00
2017-04-13 16:12:03 +02:00
/**
* Set the fit policy horizontally and vertically separately.
2019-07-10 11:56:36 +02:00
* It tells how to change the container's size automatically.
2017-04-13 16:12:03 +02:00
* @param cont pointer to a container object
2019-07-10 11:56:36 +02:00
* @param hor horizontal fit policy from `lv_fit_t`
* @param ver vertical fit policy from `lv_fit_t`
2017-04-13 16:12:03 +02:00
*/
static inline void lv_cont_set_fit2(lv_obj_t * cont, lv_fit_t hor, lv_fit_t ver)
{
lv_cont_set_fit4(cont, hor, hor, ver, ver);
}
/**
2019-07-10 11:56:36 +02:00
* Set the fit policy in all 4 direction at once.
* It tells how to change the container's size automatically.
* @param cont pointer to a container object
* @param fit fit policy from `lv_fit_t`
*/
static inline void lv_cont_set_fit(lv_obj_t * cont, lv_fit_t fit)
{
lv_cont_set_fit4(cont, fit, fit, fit, fit);
}
2017-11-10 15:01:40 +01:00
/*=====================
* Getter functions
*====================*/
2017-04-13 16:12:03 +02:00
/**
* Get the layout of a container
* @param cont pointer to container object
* @return the layout from 'lv_cont_layout_t'
*/
lv_layout_t lv_cont_get_layout(const lv_obj_t * cont);
2017-04-13 16:12:03 +02:00
/**
* Get left fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_left(const lv_obj_t * cont);
/**
* Get right fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_right(const lv_obj_t * cont);
/**
* Get top fit mode of a container
2017-04-13 16:12:03 +02:00
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
2017-04-13 16:12:03 +02:00
*/
lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont);
2017-04-13 16:12:03 +02:00
/**
* Get bottom fit mode of a container
* @param cont pointer to a container object
* @return an element of `lv_fit_t`
*/
lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont);
2017-04-13 16:12:03 +02:00
/**********************
* MACROS
**********************/
2019-04-04 07:15:40 +02:00
#endif /*LV_USE_CONT*/
2017-04-13 16:12:03 +02:00
2017-07-09 15:32:49 +02:00
#ifdef __cplusplus
} /* extern "C" */
2017-04-13 16:12:03 +02:00
#endif
2017-07-09 15:32:49 +02:00
2019-04-04 07:15:40 +02:00
#endif /*LV_CONT_H*/