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
|
|
|
|
*********************/
|
2018-07-07 12:21:36 +02:00
|
|
|
#ifdef LV_CONF_INCLUDE_SIMPLE
|
2018-07-07 11:53:22 +02:00
|
|
|
#include "lv_conf.h"
|
|
|
|
#else
|
2017-11-26 23:57:39 +01:00
|
|
|
#include "../../lv_conf.h"
|
2018-07-07 11:53:22 +02:00
|
|
|
#endif
|
|
|
|
|
2019-03-07 00:05:16 +01:00
|
|
|
#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
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/*Layout options*/
|
2018-09-18 13:59:40 +02:00
|
|
|
enum
|
2017-04-13 16:12:03 +02:00
|
|
|
{
|
2018-06-19 09:49:58 +02:00
|
|
|
LV_LAYOUT_OFF = 0,
|
|
|
|
LV_LAYOUT_CENTER,
|
|
|
|
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*/
|
2018-09-18 13:59:40 +02:00
|
|
|
};
|
|
|
|
typedef uint8_t lv_layout_t;
|
2017-04-13 16:12:03 +02:00
|
|
|
|
2019-02-24 06:24:36 +01:00
|
|
|
|
|
|
|
typedef enum {
|
2019-02-24 06:41:00 +01:00
|
|
|
LV_FIT_NONE, /*Do not change the size automatically*/
|
|
|
|
LV_FIT_TIGHT, /*Involve 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 involve it*/
|
2019-02-24 06:24:36 +01:00
|
|
|
}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-02-24 06:24:36 +01:00
|
|
|
uint8_t layout :4; /*A layout from 'lv_layout_t' enum*/
|
|
|
|
uint8_t fit_left :2; /*A fit type from `lv_fit_t` enum */
|
|
|
|
uint8_t fit_right :2; /*A fit type from `lv_fit_t` enum */
|
|
|
|
uint8_t fit_top :2; /*A fit type from `lv_fit_t` enum */
|
|
|
|
uint8_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
|
|
|
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* 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
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
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'
|
|
|
|
*/
|
2017-11-17 15:43:08 +01:00
|
|
|
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout);
|
2017-04-13 16:12:03 +02:00
|
|
|
|
2019-02-24 06:24:36 +01: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`
|
|
|
|
* @param top bottom fit policy from `lv_fit_t`
|
|
|
|
* @param bottom bottom fit policy from `lv_fit_t`
|
|
|
|
*/
|
|
|
|
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
|
|
|
/**
|
2019-02-24 06:24:36 +01:00
|
|
|
* Set the fit policy horizontally and vertically separately.
|
|
|
|
* It tell how to change the container's size automatically.
|
2017-04-13 16:12:03 +02:00
|
|
|
* @param cont pointer to a container object
|
2019-02-24 06:24:36 +01:00
|
|
|
* @param hot horizontal fit policy from `lv_fit_t`
|
|
|
|
* @param ver vertical fit policy from `lv_fit_t`
|
2017-04-13 16:12:03 +02:00
|
|
|
*/
|
2019-02-24 06:24:36 +01: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the fit policyin all 4 direction at once.
|
|
|
|
* It tell 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-04-13 16:12:03 +02:00
|
|
|
|
2017-11-10 15:01:40 +01:00
|
|
|
/**
|
|
|
|
* Set the style of a container
|
|
|
|
* @param cont pointer to a container object
|
|
|
|
* @param style pointer to the new style
|
|
|
|
*/
|
|
|
|
static inline void lv_cont_set_style(lv_obj_t *cont, lv_style_t * style)
|
|
|
|
{
|
|
|
|
lv_obj_set_style(cont, style);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=====================
|
|
|
|
* 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'
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_layout_t lv_cont_get_layout(const lv_obj_t * cont);
|
2017-04-13 16:12:03 +02:00
|
|
|
|
|
|
|
/**
|
2019-02-24 06:24:36 +01: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
|
2019-02-24 06:24:36 +01:00
|
|
|
* @return an element of `lv_fit_t`
|
2017-04-13 16:12:03 +02:00
|
|
|
*/
|
2019-02-24 06:24:36 +01:00
|
|
|
lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont);
|
2017-04-13 16:12:03 +02:00
|
|
|
|
|
|
|
/**
|
2019-02-24 06:24:36 +01:00
|
|
|
* Get bottom fit mode of a container
|
2017-11-05 00:48:57 +01:00
|
|
|
* @param cont pointer to a container object
|
2019-02-24 06:24:36 +01:00
|
|
|
* @return an element of `lv_fit_t`
|
2017-11-05 00:48:57 +01:00
|
|
|
*/
|
2019-02-24 06:24:36 +01:00
|
|
|
lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont);
|
2017-11-05 00:48:57 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the style of a container
|
|
|
|
* @param cont pointer to a container object
|
|
|
|
* @return pointer to the container's style
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
static inline lv_style_t * lv_cont_get_style(const lv_obj_t *cont)
|
2017-11-05 00:48:57 +01:00
|
|
|
{
|
2017-11-07 16:18:38 +01:00
|
|
|
return lv_obj_get_style(cont);
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
2017-04-13 16:12:03 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2019-03-07 00:05:16 +01: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
|
|
|
|
|
|
|
#endif /*LV_CONT_H*/
|