BigW Consortium Gitlab

Commit aca65294 by Kiss-Vamosi Gabor

lv_list basic implementetion

parent 451a30cf
......@@ -25,7 +25,7 @@
* STATIC PROTOTYPES
**********************/
static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
static void lv_btn_style_load(lv_obj_t * obj_dp);
static void lv_btn_style_load(lv_obj_t * obj_dp, lv_rects_t * rects_p);
/**********************
* STATIC VARIABLES
......@@ -148,11 +148,6 @@ bool lv_btn_signal(lv_obj_t * obj_dp, lv_signal_t sign, void* param)
{
bool valid;
/*Be sure the corresponding style is loaded*/
if(sign == LV_SIGNAL_STYLE_CHG) {
lv_btn_style_load(obj_dp);
}
/* Include the ancient signal function */
valid = lv_rect_signal(obj_dp, sign, param);
......@@ -225,10 +220,6 @@ bool lv_btn_signal(lv_obj_t * obj_dp, lv_signal_t sign, void* param)
valid = btn_ext_dp->lpr_action(obj_dp, param);
}
break;
case LV_SIGNAL_STYLE_CHG:
/*Load the currently active style*/
lv_btn_style_load(obj_dp);
break;
default:
/*Do nothing*/
break;
......@@ -264,7 +255,6 @@ void lv_btn_set_state(lv_obj_t* obj_dp, lv_btn_state_t state)
lv_btn_ext_t * btn_p = lv_obj_get_ext(obj_dp);
btn_p->state = state;
lv_btn_style_load(obj_dp);
lv_obj_inv(obj_dp);
}
......@@ -405,8 +395,12 @@ static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
area_t area;
lv_obj_get_cords(obj_dp, &area);
lv_rects_t rects_tmp;
lv_btn_style_load(obj_dp, &rects_tmp);
/*Draw the rectangle*/
lv_draw_rect(&area, mask_p, &btns_p->rects, opa);
lv_draw_rect(&area, mask_p, &rects_tmp, opa);
return true;
}
......@@ -415,15 +409,16 @@ static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
* Load the corresponding style according to the state to 'rects' in 'lv_btns_t'
* @param obj_dp pointer to a button object
*/
static void lv_btn_style_load(lv_obj_t * obj_dp)
static void lv_btn_style_load(lv_obj_t * obj_dp, lv_rects_t * rects_p)
{
lv_btn_state_t state = lv_btn_get_state(obj_dp);
lv_btns_t * btns_p = lv_obj_get_style(obj_dp);
/*Init the style*/
btns_p->rects.objs.color = btns_p->mcolor[state];
btns_p->rects.gcolor = btns_p->gcolor[state];
btns_p->rects.bcolor = btns_p->bcolor[state];
/*Load the style*/
memcpy(rects_p, &btns_p->rects, sizeof(lv_rects_t));
rects_p->objs.color = btns_p->mcolor[state];
rects_p->gcolor = btns_p->gcolor[state];
rects_p->bcolor = btns_p->bcolor[state];
}
#endif
/**
* @file lv_list.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_LIST != 0
#include "lv_list.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static bool lv_list_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
/**********************
* STATIC VARIABLES
**********************/
static lv_lists_t lv_lists_def =
{
/*Page style*/
.pages.bg_rects.objs.color = COLOR_WHITE, .pages.bg_rects.gcolor = COLOR_SILVER, .pages.bg_rects.bcolor = COLOR_GRAY,
.pages.bg_rects.bopa = 50, .pages.bg_rects.bwidth = 0 * LV_STYLE_MULT, .pages.bg_rects.round = 2 * LV_STYLE_MULT,
.pages.bg_rects.empty = 0, .pages.bg_rects.hpad = 0, .pages.bg_rects.vpad = 0,
.pages.sb_rects.objs.color = COLOR_BLACK, .pages.sb_rects.gcolor = COLOR_BLACK, .pages.sb_rects.bcolor = COLOR_WHITE,
.pages.sb_rects.bopa = 50, .pages.sb_rects.bwidth = 1 * LV_STYLE_MULT, .pages.sb_rects.round = 5 * LV_STYLE_MULT,
.pages.sb_rects.empty = 0, .pages.sb_width= 8 * LV_STYLE_MULT, .pages.sb_opa=50, .pages.sb_mode = LV_PAGE_SB_MODE_ON,
.pages.margin_hor = 0 * LV_STYLE_MULT, .pages.margin_ver = 0 * LV_STYLE_MULT,
/*List style*/
.list_layout = LV_LAYOUT_COL_M, .list_layout_space = 0 * LV_STYLE_MULT,
/*List element style*/
.liste_btns.mcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0xa0, 0xa0, 0xa0), .liste_btns.gcolor[LV_BTN_STATE_REL] = COLOR_WHITE, .liste_btns.bcolor[LV_BTN_STATE_REL] = COLOR_WHITE,
.liste_btns.mcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x60, 0x80, 0xa0), .liste_btns.gcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0xd0, 0xd0, 0xd0), .liste_btns.bcolor[LV_BTN_STATE_PR] = COLOR_WHITE,
.liste_btns.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x80,0x00,0x00), .liste_btns.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x20, 0x20, 0x20), .liste_btns.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_WHITE,
.liste_btns.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0xf0, 0x26, 0x26), .liste_btns.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x40, 0x40, 0x40), .liste_btns.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_WHITE,
.liste_btns.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER, .liste_btns.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY, .liste_btns.bcolor[LV_BTN_STATE_INA] = COLOR_WHITE,
.liste_btns.rects.bwidth = 2 * LV_STYLE_MULT, .liste_btns.rects.bopa = 50,
.liste_btns.rects.empty = 0, .liste_btns.rects.round = 4 * LV_STYLE_MULT,
.liste_btns.rects.hpad = 10 * LV_STYLE_MULT, .liste_btns.rects.vpad = 15 * LV_STYLE_MULT,
.liste_layout = LV_LAYOUT_ROW_M, .liste_layout_space = 50 * LV_STYLE_MULT,
};
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a list objects
* @param par_dp pointer to an object, it will be the parent of the new list
* @param copy_dp pointer to a list object, if not NULL then the new object will be copied from it
* @return pointer to the created list
*/
lv_obj_t* lv_list_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
{
/*Create the ancestor basic object*/
lv_obj_t * new_obj_dp = lv_page_create(par_dp, NULL);
dm_assert(new_obj_dp);
/*Init the new list object*/
lv_obj_set_style(new_obj_dp, &lv_lists_def.pages);
lv_obj_set_layout(new_obj_dp, lv_lists_def.list_layout);
lv_obj_set_layout_space(new_obj_dp, lv_lists_def.list_layout_space);
return new_obj_dp;
}
/**
* Signal function of the list
* @param obj_dp pointer to a list object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_list_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
valid = lv_list_signal(obj_dp, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
switch(sign) {
default:
break;
}
}
return valid;
}
void lv_list_add(lv_obj_t * obj_dp)
{
lv_obj_t * liste;
liste = lv_btn_create(obj_dp, NULL);
lv_obj_set_style(liste, &lv_lists_def.liste_btns);
lv_page_glue_obj(liste, true);
}
/**
* Return with a pointer to a built-in style and/or copy it to a variable
* @param style a style name from lv_lists_builtin_t enum
* @param copy_p copy the style to this variable. (NULL if unused)
* @return pointer to an lv_lists_t style
*/
lv_lists_t * lv_lists_get(lv_lists_builtin_t style, lv_lists_t * copy_p)
{
lv_lists_t *style_p;
switch(style) {
case LV_LISTS_DEF:
style_p = &lv_lists_def;
break;
default:
style_p = &lv_lists_def;
}
if(copy_p != NULL) {
if(style_p != NULL) memcpy(copy_p, style_p, sizeof(lv_lists_t));
else memcpy(copy_p, &lv_lists_def, sizeof(lv_lists_t));
}
return style_p;
}
/*=====================
* Setter functions
*====================*/
/*=====================
* Getter functions
*====================*/
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Handle the drawing related tasks of the lists
* @param obj_dp pointer to an object
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* @param return true/false, depends on 'mode'
*/
static bool lv_list_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
{
if(mode == LV_DESIGN_COVER_CHK) {
/*Return false if the object is not covers the mask_p area*/
return false;
}
/*Draw the object*/
return true;
}
#endif
/**
* @file lv_list.h
*
*/
#ifndef LV_LIST_H
#define LV_LIST_H
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_LIST != 0
#include "../lv_obj/lv_obj.h"
#include "lv_page.h"
#include "lv_btn.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Style of LIST*/
typedef struct
{
/*Ancestor page style*/
lv_pages_t pages;
/*List style*/
lv_layout_t list_layout;
cord_t list_layout_space;
/*List element style*/
lv_btns_t liste_btns;
lv_layout_t liste_layout;
cord_t liste_layout_space;
}lv_lists_t;
/*Built-in styles of LISTATE*/
typedef enum
{
LV_LISTS_DEF,
}lv_lists_builtin_t;
/*Data of LIST*/
typedef struct
{
lv_page_ext_t page_ext;
}lv_list_ext_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
lv_obj_t* lv_list_create(lv_obj_t* par_dp, lv_obj_t * copy_dp);
bool lv_list_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
void lv_list_add(lv_obj_t * obj_dp);
lv_lists_t * lv_lists_get(lv_lists_builtin_t style, lv_lists_t * copy_p);
/**********************
* MACROS
**********************/
#endif
#endif
/**
* @file lv_temp.c
* @file lv_templ.c
*
*/
/*Search an replace: templ -> object short name (e.g. btn, label etc)
* TEMPLATE -> object normal name (e.g. button, label etc.)
*Modify USE_LV_TEMPL by hand */
/*Search an replace: templ -> object short name with lower case(e.g. btn, label etc)
* TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.)
* template -> object normal name with lower case (e.g. button, label etc.)
*/
/*********************
* INCLUDES
......@@ -47,32 +48,34 @@ static lv_templs_t lv_templs_def =
*-----------------*/
/**
* Create a TEMPLATE objects
* @param par_dp pointer to an object, it will be the parent of the new label
* @return pointer to the created label
* Create a template objects
* @param par_dp pointer to an object, it will be the parent of the new template
* @param copy_dp pointer to a template object, if not NULL then the new object will be copied from it
* @return pointer to the created template
*/
lv_obj_t* lv_templ_create(lv_obj_t* par_dp)
lv_obj_t* lv_templ_create(lv_obj_t* par_dp, , lv_obj_t * copy_dp);
{
/*Create a basic object*/
lv_obj_t* new_obj = lv_obj_create(par_dp);
dm_assert(new_obj);
/*Create the ancestor basic object*/
lv_obj_t* new_obj_dp = lv_obj_create(par_dp);
dm_assert(new_obj_dp);
/*Init the new TEMPLATE object*/
/*Init the new template object*/
return new_obj;
return new_obj_dp;
}
/**
* Signal function of the TEMPLATE
* @param obj_dp pointer to a TEMPLATE object
* Signal function of the template
* @param obj_dp pointer to a template object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_rect_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
bool lv_templ_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
/* TODO update it to the ancient signal function*/
valid = lv_obj_signal(obj_dp, sign, param);
/* The object can be deleted so check its validity and then
......@@ -89,31 +92,25 @@ bool lv_rect_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
/**
* 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 style a style name from lv_templs_builtin_t enum
* @param copy_p copy the style to this variable. (NULL if unused)
* @return pointer to an lv_templs_t style
*/
lv_templs_t * lv_rects_get(lv_templs_builtin_t style, lv_templs_t * copy_p)
lv_templs_t * lv_templs_get(lv_templs_builtin_t style, lv_templs_t * copy_p)
{
lv_rects_t *style_p;
lv_templs_t *style_p;
switch(style) {
case LV_RECTS_DEF:
style_p = &lv_rects_def;
break;
case LV_RECTS_BORDER:
style_p = &lv_rects_border;
break;
case LV_RECTS_TRANSP:
style_p = &lv_rects_transp;
case LV_TEMPLS_DEF:
style_p = &lv_templs_def;
break;
default:
style_p = NULL;
style_p = &lv_templs_def;
}
if(copy_p != NULL) {
if(style_p != NULL) memcpy(copy_p, style_p, sizeof(lv_templs_t));
else memcpy(copy_p, &lv_rects_def, sizeof(lv_templs_t));
else memcpy(copy_p, &lv_templs_def, sizeof(lv_templs_t));
}
return style_p;
......@@ -133,7 +130,7 @@ lv_templs_t * lv_rects_get(lv_templs_builtin_t style, lv_templs_t * copy_p)
/**
* Handle the drawing related tasks of the TEMPLATEs
* Handle the drawing related tasks of the templates
* @param obj_dp pointer to an object
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
......@@ -141,10 +138,9 @@ lv_templs_t * lv_rects_get(lv_templs_builtin_t style, lv_templs_t * copy_p)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* @param return true/false, depends on 'mode'
*/
static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
static bool lv_templ_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
{
if(mode == LV_DESIGN_COVER_CHK) {
/*Return false if the object is not covers the mask_p area*/
return false;
}
......
/**
* @file lv_rect.h
* @file lv_templ.h
*
*/
#ifndef LV_RECT_H
#define LV_RECT_H
#ifndef LV_TEMPL_H
#define LV_TEMPL_H
/*********************
* INCLUDES
......@@ -22,32 +22,30 @@
* TYPEDEFS
**********************/
/*Style of TEMPLATE*/
/*Style of TEMPL*/
typedef struct
{
}lv_templs_t;
/*Built-in styles of TEMPLATE*/
/*Built-in styles of TEMPL*/
typedef enum
{
LV_RECTS_DEF,
LV_RECTS_TRANSP,
LV_RECTS_BORDER,
LV_TEMPLS_DEF,
}lv_templs_builtin_t;
/*Data of TEMPLATE*/
/*Data of TEMPL*/
typedef struct
{
}lv_templ_t;
}lv_templ_ext_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
lv_obj_t* lv_templ_create(lv_obj_t* par_dp);
lv_obj_t* lv_templ_create(lv_obj_t* par_dp, lv_obj_t * copy_dp);
bool lv_templ_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
lv_templs_t * lv_templs_get(lv_templs_builtin_t style, lv_templs_t * copy_p);
......
......@@ -56,8 +56,6 @@ static lv_pages_t lv_pages_def =
.margin_hor = 10 * LV_STYLE_MULT,
.margin_ver = 10 * LV_STYLE_MULT,
.padding_hor = 10 * LV_STYLE_MULT,
.padding_ver = 10 * LV_STYLE_MULT,
};
......@@ -87,8 +85,6 @@ static lv_pages_t lv_pages_paper =
.margin_hor = 15 * LV_STYLE_MULT,
.margin_ver = 15 * LV_STYLE_MULT,
.padding_hor = 10 * LV_STYLE_MULT,
.padding_ver = 10 * LV_STYLE_MULT,
};
static lv_pages_t lv_pages_transp =
......
......@@ -36,8 +36,6 @@ typedef struct
cord_t sb_width;
cord_t margin_hor; /*Extra size between the parent and the page horizontally*/
cord_t margin_ver; /*Extra size between the parent and the page vertically*/
cord_t padding_hor; /*Extra size on page horizontally*/
cord_t padding_ver; /*Extra size on page vertically*/
lv_page_sb_mode_t sb_mode;
uint8_t sb_opa;
}lv_pages_t;
......
......@@ -16,6 +16,7 @@
#include "lv_objx/lv_line.h"
#include "lv_objx/lv_page.h"
#include "lv_objx/lv_rect.h"
#include "lv_objx/lv_list.h"
/*********************
* DEFINES
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment