1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/lv_objx/lv_rect.h

149 lines
4.0 KiB
C
Raw Normal View History

2016-06-08 07:25:08 +02:00
/**
* @file lv_rect.h
*
*/
#ifndef LV_RECT_H
#define LV_RECT_H
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
2016-06-08 07:25:08 +02:00
#if USE_LV_RECT != 0
#include "../lv_obj/lv_obj.h"
#include "../lv_obj/lv_dispi.h"
/*********************
* DEFINES
*********************/
2016-08-09 12:24:03 +02:00
#define LV_RECT_CIRCLE 0xFFFF /*A very big radius to always draw as circle*/
2016-06-08 07:25:08 +02:00
/**********************
* TYPEDEFS
**********************/
2016-06-22 20:39:07 +02:00
typedef enum
{
2016-06-22 21:52:39 +02:00
LV_RECT_LAYOUT_OFF = 0,
LV_RECT_LAYOUT_CENTER,
LV_RECT_LAYOUT_COL_L, /*Column left align*/
LV_RECT_LAYOUT_COL_M, /*Column middle align*/
LV_RECT_LAYOUT_COL_R, /*Column right align*/
2016-12-15 10:31:30 +01:00
LV_RECT_LAYOUT_ROW_T, /*Row left align*/
LV_RECT_LAYOUT_ROW_M, /*Row middle align*/
LV_RECT_LAYOUT_ROW_B, /*Row right align*/
2016-12-17 10:50:28 +01:00
LV_RECT_LAYOUT_PRETTY, /*Put as many object as possible in row and begin a new row*/
LV_RECT_LAYOUT_GRID, /*Align same-sized object into a grid*/
2016-06-22 21:52:39 +02:00
}lv_rect_layout_t;
2016-06-22 20:39:07 +02:00
2016-12-15 10:31:30 +01:00
/*Style of rectangle*/
2016-06-08 07:25:08 +02:00
typedef struct
{
2016-10-07 11:15:46 +02:00
lv_objs_t objs; /*Style of ancestor*/
/*New style element for this type */
color_t gcolor; /*Gradient color*/
color_t bcolor; /*Border color*/
color_t lcolor; /*Light color*/
2016-12-15 10:31:30 +01:00
uint16_t bwidth;/*Border width*/
uint16_t round; /*Radius on the corners*/
cord_t hpad; /*Horizontal padding when horizontal fit is enabled*/
cord_t vpad; /*Vertical padding when vertical fit is enabled*/
cord_t opad; /*Object padding with fit*/
cord_t light; /*Light size*/
2016-12-15 10:31:30 +01:00
uint8_t bopa; /*Border opacity*/
uint8_t empty :1; /*1: Do not draw the body of the rectangle*/
2016-06-08 07:25:08 +02:00
}lv_rects_t;
2016-12-15 10:31:30 +01:00
/*Built-in styles of rectangle*/
2016-10-07 11:15:46 +02:00
typedef enum
{
LV_RECTS_DEF,
LV_RECTS_TRANSP,
LV_RECTS_BORDER,
}lv_rects_builtin_t;
2016-06-08 07:25:08 +02:00
typedef struct
{
2016-10-07 11:15:46 +02:00
/*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/
/*New data for this type */
2016-06-22 21:52:39 +02:00
uint8_t layout :5;
uint8_t hfit_en :1;
uint8_t vfit_en :1;
2016-06-08 07:25:08 +02:00
}lv_rect_ext_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a rectangle objects
* @param par pointer to an object, it will be the parent of the new rectangle
* @param copy pointer to a rectangle object, if not NULL then the new object will be copied from it
* @return pointer to the created rectangle
*/
2016-10-07 11:15:46 +02:00
lv_obj_t * lv_rect_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the rectangle
* @param rect pointer to a rectangle object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
2016-10-07 11:15:46 +02:00
bool lv_rect_signal(lv_obj_t * rect, lv_signal_t sign, void * param);
2016-06-15 09:38:20 +02:00
/**
* Set the layout on a rectangle
* @param rect pointer to a rectangle object
* @param layout a layout from 'lv_rect_layout_t'
*/
2016-10-07 11:15:46 +02:00
void lv_rect_set_layout(lv_obj_t * rect, lv_rect_layout_t layout);
2016-06-15 09:38:20 +02:00
/**
* Enable the horizontal or vertical fit.
* The rectangle size will be set to involve the children horizontally or vertically.
* @param rect pointer to a rectangle object
* @param hor_en true: enable the horizontal padding
* @param ver_en true: enable the vertical padding
*/
void lv_rect_set_fit(lv_obj_t * rect, bool hor_en, bool ver_en);
/**
* Get the layout of a rectangle
* @param rect pointer to rectangle object
* @return the layout from 'lv_rect_layout_t'
*/
2016-10-07 11:15:46 +02:00
lv_rect_layout_t lv_rect_get_layout(lv_obj_t * rect);
/**
* Get horizontal fit enable attribute of a rectangle
* @param rect pointer to a rectangle object
* @return true: horizontal padding is enabled
*/
2016-10-07 11:15:46 +02:00
bool lv_rect_get_hfit(lv_obj_t * rect);
/**
* Get vertical fit enable attribute of a rectangle
* @param obj pointer to a rectangle object
* @return true: vertical padding is enabled
*/
2016-10-07 11:15:46 +02:00
bool lv_rect_get_vfit(lv_obj_t * rect);
/**
* Return with a pointer to a built-in style and/or copy it to a variable
* @param style a style name from lv_rects_builtin_t enum
* @param copy copy the style to this variable. (NULL if unused)
* @return pointer to an lv_rects_t style
*/
2016-10-07 11:15:46 +02:00
lv_rects_t * lv_rects_get(lv_rects_builtin_t style, lv_rects_t * copy);
2016-06-08 07:25:08 +02:00
/**********************
* MACROS
**********************/
#endif
#endif