mirror of
https://github.com/lvgl/lvgl.git
synced 2024-11-24 02:03:53 +08:00
lv_rect renamed to lv_cont (container)
This commit is contained in:
parent
092c0da4b5
commit
d93844bdd8
@ -257,7 +257,7 @@ lv_obj_t * lv_app_sc_open(lv_app_inst_t * app)
|
||||
lv_obj_set_free_p(app->sc, app);
|
||||
lv_btn_set_styles(app->sc, &app_style.sc_rel, &app_style.sc_pr, NULL, NULL, NULL);
|
||||
lv_obj_set_size(app->sc, LV_APP_SC_WIDTH, LV_APP_SC_HEIGHT);
|
||||
lv_rect_set_layout(app->sc, LV_RECT_LAYOUT_OFF);
|
||||
lv_cont_set_layout(app->sc, LV_CONT_LAYOUT_OFF);
|
||||
lv_btn_set_rel_action(app->sc, lv_app_sc_rel_action);
|
||||
lv_btn_set_lpr_action(app->sc, lv_app_sc_lpr_action);
|
||||
|
||||
@ -545,23 +545,23 @@ lv_app_style_t * lv_app_style_get(void)
|
||||
static void lv_app_init_desktop(void)
|
||||
{
|
||||
/*Menu on the top*/
|
||||
menuh = lv_rect_create(lv_scr_act(), NULL);
|
||||
menuh = lv_cont_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_width(menuh, LV_HOR_RES);
|
||||
lv_rect_set_fit(menuh, false, true);
|
||||
lv_cont_set_fit(menuh, false, true);
|
||||
lv_obj_set_style(menuh, &app_style.menu);
|
||||
|
||||
app_btn = lv_btn_create(menuh, NULL);
|
||||
lv_btn_set_styles(app_btn, &app_style.menu_btn_rel, &app_style.menu_btn_pr, NULL, NULL, NULL);
|
||||
lv_rect_set_fit(app_btn, true, true);
|
||||
lv_cont_set_fit(app_btn, true, true);
|
||||
lv_btn_set_rel_action(app_btn, lv_app_menu_rel_action);
|
||||
lv_obj_t * app_label = lv_label_create(app_btn, NULL);
|
||||
lv_label_set_text(app_label, "Apps");
|
||||
lv_obj_set_pos(app_btn, 0, 0);
|
||||
lv_obj_set_pos(menuh, 0, 0);
|
||||
/*
|
||||
sys_apph = lv_rect_create(menuh, NULL);
|
||||
lv_rect_set_layout(sys_apph, LV_RECT_LAYOUT_ROW_M);
|
||||
lv_rect_set_fit(sys_apph, true, false);
|
||||
sys_apph = lv_cont_create(menuh, NULL);
|
||||
lv_cont_set_layout(sys_apph, LV_CONT_LAYOUT_ROW_M);
|
||||
lv_cont_set_fit(sys_apph, true, false);
|
||||
lv_obj_set_style(sys_apph, lv_rects_get(LV_RECTS_TRANSP, NULL));
|
||||
lv_obj_t * clock = lv_label_create(sys_apph, NULL);
|
||||
lv_obj_set_style(clock, &app_style.menu_btn_label);
|
||||
@ -576,8 +576,8 @@ static void lv_app_init_desktop(void)
|
||||
lv_obj_set_size(sc_page, LV_HOR_RES, LV_VER_RES - lv_obj_get_height(menuh));
|
||||
lv_obj_set_pos(sc_page, 0, lv_obj_get_height(menuh));
|
||||
lv_obj_set_width(lv_page_get_scrl(sc_page), LV_HOR_RES - 20);
|
||||
lv_rect_set_fit(lv_page_get_scrl(sc_page), false, true);
|
||||
lv_rect_set_layout(lv_page_get_scrl(sc_page), LV_RECT_LAYOUT_GRID);
|
||||
lv_cont_set_fit(lv_page_get_scrl(sc_page), false, true);
|
||||
lv_cont_set_layout(lv_page_get_scrl(sc_page), LV_CONT_LAYOUT_GRID);
|
||||
lv_page_set_rel_action(sc_page, lv_app_sc_page_rel_action);
|
||||
lv_page_set_sb_mode(sc_page, LV_PAGE_SB_MODE_AUTO);
|
||||
|
||||
@ -849,7 +849,7 @@ static lv_action_res_t lv_app_win_conf_action(lv_obj_t * set_btn, lv_dispi_t * d
|
||||
sprintf(buf, "%s settings", app->dsc->name);
|
||||
lv_win_set_title(app->conf_win, buf);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(app->conf_win);
|
||||
lv_rect_set_layout(scrl, LV_RECT_LAYOUT_COL_L);
|
||||
lv_cont_set_layout(scrl, LV_CONT_LAYOUT_COL_L);
|
||||
|
||||
lv_win_add_ctrl_btn(app->conf_win, "U:/icon_close" ,lv_win_close_action);
|
||||
|
||||
|
@ -91,7 +91,6 @@ void lv_app_fsel_open(const char * path, const char * filter, void * param, void
|
||||
if(fsel_filter == NULL) fsel_filter = "";
|
||||
|
||||
/*Create a window for the File selector*/
|
||||
lv_app_style_t * app_style = lv_app_style_get();
|
||||
fsel_win = lv_win_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(fsel_win, LV_HOR_RES, LV_VER_RES);
|
||||
|
||||
@ -142,7 +141,7 @@ static void fsel_refr(void)
|
||||
//TODO lv_obj_set_style(fsel_list, lv_lists_get(LV_LISTS_TRANSP, NULL));
|
||||
lv_obj_set_drag_parent(fsel_list, true);
|
||||
lv_obj_set_drag_parent(lv_page_get_scrl(fsel_list), true);
|
||||
lv_rect_set_fit(fsel_list, false, true);
|
||||
lv_cont_set_fit(fsel_list, false, true);
|
||||
|
||||
fs_res_t res = FS_RES_OK;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "lv_app_notice.h"
|
||||
#if LV_APP_ENABLE != 0
|
||||
|
||||
#include "lvgl/lv_objx/lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lvgl/lv_objx/lv_label.h"
|
||||
|
||||
#include "lvgl/lv_misc/anim.h"
|
||||
@ -56,12 +56,12 @@ static lv_obj_t * notice_h;
|
||||
*/
|
||||
void lv_app_notice_init(void)
|
||||
{
|
||||
notice_h = lv_rect_create(lv_scr_act(), NULL);
|
||||
notice_h = lv_cont_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(notice_h, LV_HOR_RES, LV_VER_RES - LV_DPI);
|
||||
lv_obj_set_y(notice_h, LV_DPI);
|
||||
lv_obj_set_click(notice_h, false);
|
||||
lv_obj_set_style(notice_h, lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
lv_rect_set_layout(notice_h, LV_RECT_LAYOUT_COL_R);
|
||||
lv_cont_set_layout(notice_h, LV_CONT_LAYOUT_COL_R);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,11 +299,11 @@ static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
|
||||
|
||||
/*Create a text area to type chunk size*/
|
||||
lv_obj_t * val_set_h;
|
||||
val_set_h = lv_rect_create(conf_win, NULL);
|
||||
val_set_h = lv_cont_create(conf_win, NULL);
|
||||
lv_obj_set_style(val_set_h, lv_style_get(LV_STYLE_PLAIN_COLOR, NULL));
|
||||
lv_obj_set_click(val_set_h, false);
|
||||
lv_rect_set_fit(val_set_h, true, true);
|
||||
lv_rect_set_layout(val_set_h, LV_RECT_LAYOUT_ROW_M);
|
||||
lv_cont_set_fit(val_set_h, true, true);
|
||||
lv_cont_set_layout(val_set_h, LV_CONT_LAYOUT_ROW_M);
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(val_set_h, NULL);
|
||||
@ -312,7 +312,7 @@ static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
|
||||
lv_obj_t * ta;
|
||||
char buf[32];
|
||||
ta = lv_ta_create(val_set_h, NULL);
|
||||
lv_rect_set_fit(ta, false, true);
|
||||
lv_cont_set_fit(ta, false, true);
|
||||
lv_obj_set_free_num(ta, SEND_SETTINGS_CHUNK_SIZE);
|
||||
lv_obj_set_free_p(ta, app);
|
||||
lv_page_set_rel_action(ta, win_send_settings_element_rel_action);
|
||||
@ -320,7 +320,7 @@ static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
|
||||
lv_ta_set_text(ta, buf);
|
||||
|
||||
/*Create a text area to type the chunk delay*/
|
||||
val_set_h = lv_rect_create(conf_win, val_set_h);
|
||||
val_set_h = lv_cont_create(conf_win, val_set_h);
|
||||
|
||||
label = lv_label_create(val_set_h, NULL);
|
||||
lv_label_set_text(label, "Inter-chunk delay");
|
||||
@ -353,8 +353,8 @@ static void win_create_list(lv_app_inst_t * app)
|
||||
//TODO lv_obj_set_style(win_data->file_list, lv_lists_get(LV_LISTS_TRANSP, NULL));
|
||||
lv_obj_set_drag_parent(win_data->file_list, true);
|
||||
lv_obj_set_drag_parent(lv_page_get_scrl(win_data->file_list), true);
|
||||
lv_rect_set_fit(win_data->file_list, false, true);
|
||||
lv_rect_set_layout(lv_page_get_scrl(win_data->file_list), LV_RECT_LAYOUT_COL_L);
|
||||
lv_cont_set_fit(win_data->file_list, false, true);
|
||||
lv_cont_set_layout(lv_page_get_scrl(win_data->file_list), LV_CONT_LAYOUT_COL_L);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,8 +308,7 @@ static void sysmon_task(void * param)
|
||||
static bool mem_warn_report = false;
|
||||
if(mem_mon.size_free < LV_APP_SYSMON_MEM_WARN && mem_warn_report == false) {
|
||||
mem_warn_report = true;
|
||||
lv_obj_t * not = lv_app_notice_add("Critically low memory");
|
||||
//TODO lv_obj_set_style(not, lv_mboxs_get(LV_MBOXS_WARN, NULL));
|
||||
lv_app_notice_add("Critically low memory");
|
||||
}
|
||||
|
||||
if(mem_mon.size_free > LV_APP_SYSMON_MEM_WARN) mem_warn_report = false;
|
||||
@ -318,8 +317,7 @@ static void sysmon_task(void * param)
|
||||
if(mem_mon.pct_frag > LV_APP_SYSMON_FRAG_WARN) {
|
||||
if(frag_warn_report == false) {
|
||||
frag_warn_report = true;
|
||||
lv_obj_t * not =lv_app_notice_add("Critical memory\nfragmentation");
|
||||
//TODO lv_obj_set_style(not, lv_mboxs_get(LV_MBOXS_WARN, NULL));
|
||||
lv_app_notice_add("Critical memory\nfragmentation");
|
||||
|
||||
dm_defrag(); /*Defrag. if the fragmentation is critical*/
|
||||
}
|
||||
|
@ -12,10 +12,10 @@
|
||||
#include <lvgl/lv_obj/lv_dispi.h>
|
||||
#include <lvgl/lv_obj/lv_obj.h>
|
||||
#include <lvgl/lv_objx/lv_btn.h>
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include <lvgl/lv_objx/lv_ddlist.h>
|
||||
#include <lvgl/lv_objx/lv_label.h>
|
||||
#include <lvgl/lv_objx/lv_page.h>
|
||||
#include <lvgl/lv_objx/lv_rect.h>
|
||||
#include <lvgl/lv_objx/lv_ta.h>
|
||||
#include <misc/others/color.h>
|
||||
#include <stdbool.h>
|
||||
@ -263,7 +263,7 @@ static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
|
||||
/*Create a clear button*/
|
||||
win_data->clear_btn = lv_btn_create(win, NULL);
|
||||
lv_rect_set_fit(win_data->clear_btn, true, true);
|
||||
lv_cont_set_fit(win_data->clear_btn, true, true);
|
||||
lv_obj_set_free_p(win_data->clear_btn, app);
|
||||
lv_btn_set_rel_action(win_data->clear_btn, win_clear_rel_action);
|
||||
lv_obj_t * btn_label = lv_label_create(win_data->clear_btn, NULL);
|
||||
|
@ -43,12 +43,12 @@ typedef enum
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if USE_LV_RECT != 0
|
||||
static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style);
|
||||
static void lv_draw_rect_main_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p);
|
||||
static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p);
|
||||
static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style);
|
||||
static void lv_draw_rect_shadow(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style);
|
||||
static uint16_t lv_draw_rect_radius_corr(uint16_t r, cord_t w, cord_t h);
|
||||
static void lv_draw_cont_main_mid(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style);
|
||||
static void lv_draw_cont_main_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p);
|
||||
static void lv_draw_cont_border_straight(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p);
|
||||
static void lv_draw_cont_border_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style);
|
||||
static void lv_draw_cont_shadow(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style);
|
||||
static uint16_t lv_draw_cont_radius_corr(uint16_t r, cord_t w, cord_t h);
|
||||
#endif /*USE_LV_RECT != 0*/
|
||||
|
||||
|
||||
@ -90,23 +90,23 @@ void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_style_
|
||||
if(area_get_height(cords_p) < 1 || area_get_width(cords_p) < 1) return;
|
||||
|
||||
if(style_p->empty == 0){
|
||||
lv_draw_rect_main_mid(cords_p, mask_p, style_p);
|
||||
lv_draw_cont_main_mid(cords_p, mask_p, style_p);
|
||||
|
||||
if(style_p->radius != 0) {
|
||||
lv_draw_rect_main_corner(cords_p, mask_p, style_p);
|
||||
lv_draw_cont_main_corner(cords_p, mask_p, style_p);
|
||||
}
|
||||
}
|
||||
|
||||
if(style_p->bwidth != 0) {
|
||||
lv_draw_rect_border_straight(cords_p, mask_p, style_p);
|
||||
lv_draw_cont_border_straight(cords_p, mask_p, style_p);
|
||||
|
||||
if(style_p->radius != 0) {
|
||||
lv_draw_rect_border_corner(cords_p, mask_p, style_p);
|
||||
lv_draw_cont_border_corner(cords_p, mask_p, style_p);
|
||||
}
|
||||
}
|
||||
|
||||
if(style_p->swidth != 0) {
|
||||
lv_draw_rect_shadow(cords_p, mask_p, style_p);
|
||||
lv_draw_cont_shadow(cords_p, mask_p, style_p);
|
||||
}
|
||||
}
|
||||
#endif /*USE_LV_RECT != 0*/
|
||||
@ -573,7 +573,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
* @param mask_p the rectangle will be drawn only on this area
|
||||
* @param rects_p pointer to a rectangle style
|
||||
*/
|
||||
static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
||||
static void lv_draw_cont_main_mid(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
||||
{
|
||||
uint16_t radius = style->radius;
|
||||
|
||||
@ -584,7 +584,7 @@ static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p,
|
||||
cord_t height = area_get_height(cords_p);
|
||||
cord_t width = area_get_width(cords_p);
|
||||
|
||||
radius = lv_draw_rect_radius_corr(radius, width, height);
|
||||
radius = lv_draw_cont_radius_corr(radius, width, height);
|
||||
|
||||
/*If the radius is too big then there is no body*/
|
||||
if(radius > height / 2) return;
|
||||
@ -623,7 +623,7 @@ static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p,
|
||||
* @param mask_p the rectangle will be drawn only on this area
|
||||
* @param rects_p pointer to a rectangle style
|
||||
*/
|
||||
static void lv_draw_rect_main_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p)
|
||||
static void lv_draw_cont_main_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p)
|
||||
{
|
||||
uint16_t radius = style_p->radius;
|
||||
|
||||
@ -635,7 +635,7 @@ static void lv_draw_rect_main_corner(const area_t * cords_p, const area_t * mask
|
||||
cord_t height = area_get_height(cords_p);
|
||||
cord_t width = area_get_width(cords_p);
|
||||
|
||||
radius = lv_draw_rect_radius_corr(radius, width, height);
|
||||
radius = lv_draw_cont_radius_corr(radius, width, height);
|
||||
|
||||
point_t lt_origo; /*Left Top origo*/
|
||||
point_t lb_origo; /*Left Bottom origo*/
|
||||
@ -794,7 +794,7 @@ if(edge_top_area.y1 != mid_top_area.y1) {
|
||||
* @param mask_p the rectangle will be drawn only on this area
|
||||
* @param rects_p pointer to a rectangle style
|
||||
*/
|
||||
static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p)
|
||||
static void lv_draw_cont_border_straight(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p)
|
||||
{
|
||||
uint16_t radius = style_p->radius;
|
||||
|
||||
@ -809,7 +809,7 @@ static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t *
|
||||
/*the 0 px border width drawn as 1 px, so decrement the b_width*/
|
||||
bwidth--;
|
||||
|
||||
radius = lv_draw_rect_radius_corr(radius, width, height);
|
||||
radius = lv_draw_cont_radius_corr(radius, width, height);
|
||||
|
||||
if(radius < bwidth) {
|
||||
length_corr = bwidth - radius;
|
||||
@ -910,7 +910,7 @@ static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t *
|
||||
* @param rects_p pointer to a rectangle style
|
||||
* @param opa opacity of the rectangle (0..255)
|
||||
*/
|
||||
static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
||||
static void lv_draw_cont_border_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
||||
{
|
||||
uint16_t radius = style->radius;
|
||||
uint16_t bwidth = style->bwidth;
|
||||
@ -923,7 +923,7 @@ static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * ma
|
||||
cord_t width = area_get_width(cords_p);
|
||||
cord_t height = area_get_height(cords_p);
|
||||
|
||||
radius = lv_draw_rect_radius_corr(radius, width, height);
|
||||
radius = lv_draw_cont_radius_corr(radius, width, height);
|
||||
|
||||
point_t lt_origo; /*Left Top origo*/
|
||||
point_t lb_origo; /*Left Bottom origo*/
|
||||
@ -1045,7 +1045,7 @@ static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * ma
|
||||
* @param rect pointer to rectangle object
|
||||
* @param mask pointer to a mask area (from the design functions)
|
||||
*/
|
||||
static void lv_draw_rect_shadow(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
||||
static void lv_draw_cont_shadow(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
||||
{
|
||||
cord_t swidth = style->swidth;
|
||||
if(swidth == 0) return;
|
||||
@ -1061,7 +1061,7 @@ static void lv_draw_rect_shadow(const area_t * cords_p, const area_t * mask_p, c
|
||||
shadow_style.empty = 1;
|
||||
shadow_style.bwidth = swidth;
|
||||
shadow_style.radius = style->radius;
|
||||
if(shadow_style.radius == LV_RECT_CIRCLE) {
|
||||
if(shadow_style.radius == LV_CONT_CIRCLE) {
|
||||
shadow_style.radius = MATH_MIN(area_get_width(cords_p), area_get_height(cords_p));
|
||||
}
|
||||
shadow_style.radius += swidth + 1;
|
||||
@ -1077,8 +1077,8 @@ static void lv_draw_rect_shadow(const area_t * cords_p, const area_t * mask_p, c
|
||||
shadow_style.opa = style->opa / (swidth / res);
|
||||
|
||||
for(i = 1; i < swidth; i += res) {
|
||||
lv_draw_rect_border_straight(&shadow_area, mask_p, &shadow_style);
|
||||
lv_draw_rect_border_corner(&shadow_area, mask_p, &shadow_style);
|
||||
lv_draw_cont_border_straight(&shadow_area, mask_p, &shadow_style);
|
||||
lv_draw_cont_border_corner(&shadow_area, mask_p, &shadow_style);
|
||||
shadow_style.radius -= res;
|
||||
shadow_style.bwidth -= res;
|
||||
shadow_area.x1 += res;
|
||||
@ -1089,7 +1089,7 @@ static void lv_draw_rect_shadow(const area_t * cords_p, const area_t * mask_p, c
|
||||
}
|
||||
|
||||
|
||||
static uint16_t lv_draw_rect_radius_corr(uint16_t r, cord_t w, cord_t h)
|
||||
static uint16_t lv_draw_cont_radius_corr(uint16_t r, cord_t w, cord_t h)
|
||||
{
|
||||
if(r >= (w >> 1)){
|
||||
r = (w >> 1);
|
||||
|
@ -16,7 +16,7 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_RECT_CIRCLE ((cord_t)-1) /*A very big radius to always draw as circle*/
|
||||
#define LV_CONT_CIRCLE ((cord_t)-1) /*A very big radius to always draw as circle*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
@ -1440,7 +1440,7 @@ static bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode
|
||||
|
||||
uint16_t r = style->radius;
|
||||
|
||||
if(r == LV_RECT_CIRCLE) return false;
|
||||
if(r == LV_CONT_CIRCLE) return false;
|
||||
|
||||
area_t area_tmp;
|
||||
|
||||
|
@ -67,7 +67,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->act_value = 0;
|
||||
ext->style_indic = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
||||
|
||||
/* Save the rectangle design function.
|
||||
/* Save the ancient design function.
|
||||
* It will be used in the bar design function*/
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_bar);
|
||||
|
||||
@ -106,7 +106,7 @@ bool lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_rect_signal(bar, sign, param);
|
||||
valid = lv_cont_signal(bar, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
|
@ -22,7 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lv_btn.h"
|
||||
#include "lv_label.h"
|
||||
|
||||
|
@ -55,7 +55,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
lv_obj_t * new_btn;
|
||||
|
||||
new_btn = lv_rect_create(par, copy);
|
||||
new_btn = lv_cont_create(par, copy);
|
||||
dm_assert(new_btn);
|
||||
/*Allocate the extended data*/
|
||||
lv_btn_ext_t * ext = lv_obj_alloc_ext(new_btn, sizeof(lv_btn_ext_t));
|
||||
@ -77,7 +77,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*If no copy do the basic initialization*/
|
||||
if(copy == NULL) {
|
||||
lv_rect_set_layout(new_btn, LV_RECT_LAYOUT_CENTER);
|
||||
lv_cont_set_layout(new_btn, LV_CONT_LAYOUT_CENTER);
|
||||
lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]);
|
||||
}
|
||||
/*Copy 'copy'*/
|
||||
@ -113,7 +113,7 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_rect_signal(btn, sign, param);
|
||||
valid = lv_cont_signal(btn, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
|
@ -17,7 +17,7 @@
|
||||
#error "lv_btn: lv_rect is required. Enable it in lv_conf.h (USE_LV_RECT 1) "
|
||||
#endif
|
||||
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "../lv_obj/lv_dispi.h"
|
||||
|
||||
/*********************
|
||||
@ -42,7 +42,7 @@ typedef enum
|
||||
/*Data of button*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t rect; /*Ext. of ancestor*/
|
||||
lv_cont_ext_t cont; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_action_t pr_action; /*A function to call when the button is pressed (NULL if unused)*/
|
||||
lv_action_t rel_action; /*A function to call when the button is released (NULL if unused)*/
|
||||
|
@ -61,7 +61,7 @@ static lv_design_f_t ancestor_design_f;
|
||||
lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor object*/
|
||||
lv_obj_t * new_btnm = lv_rect_create(par, copy);
|
||||
lv_obj_t * new_btnm = lv_cont_create(par, copy);
|
||||
dm_assert(new_btnm);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
@ -106,7 +106,7 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_rect_signal(btnm, sign, param);
|
||||
valid = lv_cont_signal(btnm, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
|
@ -23,7 +23,7 @@
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lv_label.h"
|
||||
#include "lv_btn.h"
|
||||
|
||||
@ -43,7 +43,7 @@ typedef lv_action_res_t (*lv_btnm_callback_t) (lv_obj_t *, uint16_t);
|
||||
/*Data of button matrix*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t bg; /*Ext. of ancestor*/
|
||||
lv_cont_ext_t bg; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
const char ** map_p; /*Pointer to the current map*/
|
||||
area_t * btn_areas; /*Array of areas for the buttons (Handled by the library)*/
|
||||
|
@ -68,8 +68,8 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_btn_set_styles(new_cb, lv_style_get(LV_STYLE_TRANSP, NULL), lv_style_get(LV_STYLE_TRANSP, NULL),
|
||||
lv_style_get(LV_STYLE_TRANSP, NULL), lv_style_get(LV_STYLE_TRANSP, NULL),
|
||||
lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
lv_rect_set_layout(new_cb, LV_RECT_LAYOUT_ROW_M);
|
||||
lv_rect_set_fit(new_cb, true, true);
|
||||
lv_cont_set_layout(new_cb, LV_CONT_LAYOUT_ROW_M);
|
||||
lv_cont_set_fit(new_cb, true, true);
|
||||
lv_btn_set_tgl(new_cb, true);
|
||||
|
||||
lv_obj_set_click(ext->bullet, false);
|
||||
|
@ -484,32 +484,32 @@ static void lv_chart_draw_points(lv_obj_t * chart, const area_t * mask)
|
||||
int32_t y_tmp;
|
||||
lv_chart_dl_t * dl;
|
||||
uint8_t dl_cnt = 0;
|
||||
lv_style_t rects;
|
||||
lv_style_get(LV_STYLE_PLAIN, &rects);
|
||||
lv_style_t style_point;
|
||||
lv_style_get(LV_STYLE_PLAIN, &style_point);
|
||||
|
||||
rects.bwidth = 0;
|
||||
rects.empty = 0;
|
||||
rects.radius = LV_RECT_CIRCLE;
|
||||
rects.opa = (uint16_t)((uint16_t)style->opa * ext->data_opa) >> 8;
|
||||
style_point.bwidth = 0;
|
||||
style_point.empty = 0;
|
||||
style_point.radius = LV_CONT_CIRCLE;
|
||||
style_point.opa = (uint16_t)((uint16_t)style->opa * ext->data_opa) >> 8;
|
||||
|
||||
/*Go through all data lines*/
|
||||
LL_READ_BACK(ext->dl_ll, dl) {
|
||||
rects.radius = dl->width;
|
||||
rects.mcolor = dl->color;
|
||||
rects.gcolor = color_mix(COLOR_BLACK, dl->color, ext->dark_eff);
|
||||
style_point.radius = dl->width;
|
||||
style_point.mcolor = dl->color;
|
||||
style_point.gcolor = color_mix(COLOR_BLACK, dl->color, ext->dark_eff);
|
||||
|
||||
for(i = 0; i < ext->pnum; i ++) {
|
||||
cir_a.x1 = ((w * i) / (ext->pnum - 1)) + x_ofs;
|
||||
cir_a.x2 = cir_a.x1 + rects.radius;
|
||||
cir_a.x1 -= rects.radius;
|
||||
cir_a.x2 = cir_a.x1 + style_point.radius;
|
||||
cir_a.x1 -= style_point.radius;
|
||||
|
||||
y_tmp = (int32_t)((int32_t) dl->points[i] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
cir_a.y1 = h - y_tmp + y_ofs;
|
||||
cir_a.y2 = cir_a.y1 + rects.radius;
|
||||
cir_a.y1 -= rects.radius;
|
||||
cir_a.y2 = cir_a.y1 + style_point.radius;
|
||||
cir_a.y1 -= style_point.radius;
|
||||
|
||||
lv_draw_rect(&cir_a, mask, &rects);
|
||||
lv_draw_rect(&cir_a, mask, &style_point);
|
||||
}
|
||||
dl_cnt++;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lv_line.h"
|
||||
|
||||
/*********************
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_draw/lv_draw_vbasic.h"
|
||||
#include "../lv_misc/area.h"
|
||||
@ -36,16 +36,16 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if 0
|
||||
static bool lv_rect_design(lv_obj_t * rect, const area_t * mask, lv_design_mode_t mode);
|
||||
static bool lv_cont_design(lv_obj_t * cont, const area_t * mask, lv_design_mode_t mode);
|
||||
#endif
|
||||
|
||||
static void lv_rect_refr_layout(lv_obj_t * rect);
|
||||
static void lv_rect_layout_col(lv_obj_t * rect);
|
||||
static void lv_rect_layout_row(lv_obj_t * rect);
|
||||
static void lv_rect_layout_center(lv_obj_t * rect);
|
||||
static void lv_rect_layout_pretty(lv_obj_t * rect);
|
||||
static void lv_rect_layout_grid(lv_obj_t * rect);
|
||||
static void lv_rect_refr_autofit(lv_obj_t * rect);
|
||||
static void lv_cont_refr_layout(lv_obj_t * cont);
|
||||
static void lv_cont_layout_col(lv_obj_t * cont);
|
||||
static void lv_cont_layout_row(lv_obj_t * cont);
|
||||
static void lv_cont_layout_center(lv_obj_t * cont);
|
||||
static void lv_cont_layout_pretty(lv_obj_t * cont);
|
||||
static void lv_cont_layout_grid(lv_obj_t * cont);
|
||||
static void lv_cont_refr_autofit(lv_obj_t * cont);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -64,32 +64,32 @@ static void lv_rect_refr_autofit(lv_obj_t * rect);
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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_rect_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create a basic object*/
|
||||
lv_obj_t * new_rect = lv_obj_create(par, copy);
|
||||
dm_assert(new_rect);
|
||||
lv_obj_alloc_ext(new_rect, sizeof(lv_rect_ext_t));
|
||||
lv_rect_ext_t * ext = lv_obj_get_ext(new_rect);
|
||||
lv_obj_alloc_ext(new_rect, sizeof(lv_cont_ext_t));
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(new_rect);
|
||||
dm_assert(ext);
|
||||
ext->hpad_en = 0;
|
||||
ext->vpad_en = 0;
|
||||
ext->layout = LV_RECT_LAYOUT_OFF;
|
||||
ext->layout = LV_CONT_LAYOUT_OFF;
|
||||
|
||||
lv_obj_set_signal_f(new_rect, lv_rect_signal);
|
||||
lv_obj_set_signal_f(new_rect, lv_cont_signal);
|
||||
|
||||
/*Init the new rectangle*/
|
||||
/*Init the new container*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_rect, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_rect_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_cont_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->hpad_en = copy_ext->hpad_en;
|
||||
ext->vpad_en = copy_ext->vpad_en;
|
||||
ext->layout = copy_ext->layout;
|
||||
@ -103,38 +103,38 @@ 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
|
||||
* Signal function of the container
|
||||
* @param cont pointer to a container 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 * rect, lv_signal_t sign, void * param)
|
||||
bool lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_obj_signal(rect, sign, param);
|
||||
valid = lv_obj_signal(cont, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
|
||||
lv_style_t * style = lv_obj_get_style(rect);
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_STYLE_CHG: /*Recalculate the padding if the style changed*/
|
||||
lv_rect_refr_layout(rect);
|
||||
lv_rect_refr_autofit(rect);
|
||||
lv_cont_refr_layout(cont);
|
||||
lv_cont_refr_autofit(cont);
|
||||
break;
|
||||
case LV_SIGNAL_CHILD_CHG:
|
||||
lv_rect_refr_layout(rect);
|
||||
lv_rect_refr_autofit(rect);
|
||||
lv_cont_refr_layout(cont);
|
||||
lv_cont_refr_autofit(cont);
|
||||
break;
|
||||
case LV_SIGNAL_CORD_CHG:
|
||||
if(lv_obj_get_width(rect) != area_get_width(param) ||
|
||||
lv_obj_get_height(rect) != area_get_height(param)) {
|
||||
lv_rect_refr_layout(rect);
|
||||
lv_rect_refr_autofit(rect);
|
||||
if(lv_obj_get_width(cont) != area_get_width(param) ||
|
||||
lv_obj_get_height(cont) != area_get_height(param)) {
|
||||
lv_cont_refr_layout(cont);
|
||||
lv_cont_refr_autofit(cont);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -150,36 +150,36 @@ bool lv_rect_signal(lv_obj_t * rect, lv_signal_t sign, void * param)
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the layout on a rectangle
|
||||
* @param rect pointer to a rectangle object
|
||||
* @param layout a layout from 'lv_rect_layout_t'
|
||||
* Set the layout on a container
|
||||
* @param cont pointer to a container object
|
||||
* @param layout a layout from 'lv_cont_layout_t'
|
||||
*/
|
||||
void lv_rect_set_layout(lv_obj_t * rect, lv_rect_layout_t layout)
|
||||
void lv_cont_set_layout(lv_obj_t * cont, lv_cont_layout_t layout)
|
||||
{
|
||||
lv_rect_ext_t * ext = lv_obj_get_ext(rect);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
ext->layout = layout;
|
||||
|
||||
/*Send a signal to refresh the layout*/
|
||||
rect->signal_f(rect, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
cont->signal_f(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* The container size will be set to involve the children horizontally or vertically.
|
||||
* @param cont pointer to a container 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)
|
||||
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
|
||||
{
|
||||
lv_obj_inv(rect);
|
||||
lv_rect_ext_t * ext = lv_obj_get_ext(rect);
|
||||
lv_obj_inv(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
ext->hpad_en = hor_en == false ? 0 : 1;
|
||||
ext->vpad_en = ver_en == false ? 0 : 1;
|
||||
|
||||
/*Send a signal to set a new size*/
|
||||
rect->signal_f(rect, LV_SIGNAL_CORD_CHG, rect);
|
||||
cont->signal_f(cont, LV_SIGNAL_CORD_CHG, cont);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -187,48 +187,46 @@ 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'
|
||||
* Get the layout of a container
|
||||
* @param cont pointer to container object
|
||||
* @return the layout from 'lv_cont_layout_t'
|
||||
*/
|
||||
lv_rect_layout_t lv_rect_get_layout(lv_obj_t * rect)
|
||||
lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont)
|
||||
{
|
||||
lv_rect_ext_t * ext = lv_obj_get_ext(rect);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
return ext->layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get horizontal fit enable attribute of a rectangle
|
||||
* @param rect pointer to a rectangle object
|
||||
* Get horizontal fit enable attribute of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: horizontal padding is enabled
|
||||
*/
|
||||
bool lv_rect_get_hfit(lv_obj_t * rect)
|
||||
bool lv_cont_get_hfit(lv_obj_t * cont)
|
||||
{
|
||||
lv_rect_ext_t * ext = lv_obj_get_ext(rect);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
return ext->hpad_en == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vertical fit enable attribute of a rectangle
|
||||
* @param obj pointer to a rectangle object
|
||||
* Get vertical fit enable attribute of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: vertical padding is enabled
|
||||
*/
|
||||
bool lv_rect_get_vfit(lv_obj_t * rect)
|
||||
bool lv_cont_get_vfit(lv_obj_t * cont)
|
||||
{
|
||||
lv_rect_ext_t * ext = lv_obj_get_ext(rect);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
return ext->vpad_en == 0 ? false : true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
#if 0
|
||||
/**
|
||||
* Handle the drawing related tasks of the rectangles
|
||||
* @param rect pointer to an object
|
||||
* Handle the drawing related tasks of the containers
|
||||
* @param cont 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)
|
||||
@ -236,7 +234,7 @@ bool lv_rect_get_vfit(lv_obj_t * rect)
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_rect_design(lv_obj_t * rect, const area_t * mask, lv_design_mode_t mode)
|
||||
static bool lv_cont_design(lv_obj_t * cont, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
|
||||
@ -253,55 +251,55 @@ static bool lv_rect_design(lv_obj_t * rect, const area_t * mask, lv_design_mode_
|
||||
|
||||
|
||||
/**
|
||||
* Refresh the layout of a rectangle
|
||||
* @param rect pointer to an object which layout should be refreshed
|
||||
* Refresh the layout of a container
|
||||
* @param cont pointer to an object which layout should be refreshed
|
||||
*/
|
||||
static void lv_rect_refr_layout(lv_obj_t * rect)
|
||||
static void lv_cont_refr_layout(lv_obj_t * cont)
|
||||
{
|
||||
lv_rect_layout_t type = lv_rect_get_layout(rect);
|
||||
lv_cont_layout_t type = lv_cont_get_layout(cont);
|
||||
|
||||
/*'rect' has to be at least 1 child*/
|
||||
if(lv_obj_get_child(rect, NULL) == NULL) return;
|
||||
if(lv_obj_get_child(cont, NULL) == NULL) return;
|
||||
|
||||
if(type == LV_RECT_LAYOUT_OFF) return;
|
||||
if(type == LV_CONT_LAYOUT_OFF) return;
|
||||
|
||||
if(type == LV_RECT_LAYOUT_CENTER) {
|
||||
lv_rect_layout_center(rect);
|
||||
} else if(type == LV_RECT_LAYOUT_COL_L || type == LV_RECT_LAYOUT_COL_M || type == LV_RECT_LAYOUT_COL_R) {
|
||||
lv_rect_layout_col(rect);
|
||||
} else if(type == LV_RECT_LAYOUT_ROW_T || type == LV_RECT_LAYOUT_ROW_M || type == LV_RECT_LAYOUT_ROW_B) {
|
||||
lv_rect_layout_row(rect);
|
||||
} else if(type == LV_RECT_LAYOUT_PRETTY) {
|
||||
lv_rect_layout_pretty(rect);
|
||||
} else if(type == LV_RECT_LAYOUT_GRID) {
|
||||
lv_rect_layout_grid(rect);
|
||||
if(type == LV_CONT_LAYOUT_CENTER) {
|
||||
lv_cont_layout_center(cont);
|
||||
} else if(type == LV_CONT_LAYOUT_COL_L || type == LV_CONT_LAYOUT_COL_M || type == LV_CONT_LAYOUT_COL_R) {
|
||||
lv_cont_layout_col(cont);
|
||||
} else if(type == LV_CONT_LAYOUT_ROW_T || type == LV_CONT_LAYOUT_ROW_M || type == LV_CONT_LAYOUT_ROW_B) {
|
||||
lv_cont_layout_row(cont);
|
||||
} else if(type == LV_CONT_LAYOUT_PRETTY) {
|
||||
lv_cont_layout_pretty(cont);
|
||||
} else if(type == LV_CONT_LAYOUT_GRID) {
|
||||
lv_cont_layout_grid(cont);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle column type layouts
|
||||
* @param rect pointer to an object which layout should be handled
|
||||
* @param cont pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_rect_layout_col(lv_obj_t * rect)
|
||||
static void lv_cont_layout_col(lv_obj_t * cont)
|
||||
{
|
||||
lv_rect_layout_t type = lv_rect_get_layout(rect);
|
||||
lv_cont_layout_t type = lv_cont_get_layout(cont);
|
||||
lv_obj_t * child;
|
||||
|
||||
/*Adjust margin and get the alignment type*/
|
||||
lv_align_t align;
|
||||
lv_style_t * style = lv_obj_get_style(rect);
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
cord_t hpad_corr;
|
||||
|
||||
switch(type) {
|
||||
case LV_RECT_LAYOUT_COL_L:
|
||||
case LV_CONT_LAYOUT_COL_L:
|
||||
hpad_corr = style->hpad;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
case LV_RECT_LAYOUT_COL_M:
|
||||
case LV_CONT_LAYOUT_COL_M:
|
||||
hpad_corr = 0;
|
||||
align = LV_ALIGN_IN_TOP_MID;
|
||||
break;
|
||||
case LV_RECT_LAYOUT_COL_R:
|
||||
case LV_CONT_LAYOUT_COL_R:
|
||||
hpad_corr = -style->hpad;
|
||||
align = LV_ALIGN_IN_TOP_RIGHT;
|
||||
break;
|
||||
@ -313,44 +311,44 @@ static void lv_rect_layout_col(lv_obj_t * rect)
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(rect, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
/* Align the children */
|
||||
cord_t last_cord = style->vpad;
|
||||
LL_READ_BACK(rect->child_ll, child) {
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
lv_obj_align(child, rect, align, hpad_corr , last_cord);
|
||||
lv_obj_align(child, cont, align, hpad_corr , last_cord);
|
||||
last_cord += lv_obj_get_height(child) + style->opad;
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(rect, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle row type layouts
|
||||
* @param rect pointer to an object which layout should be handled
|
||||
* @param cont pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_rect_layout_row(lv_obj_t * rect)
|
||||
static void lv_cont_layout_row(lv_obj_t * cont)
|
||||
{
|
||||
lv_rect_layout_t type = lv_rect_get_layout(rect);
|
||||
lv_cont_layout_t type = lv_cont_get_layout(cont);
|
||||
lv_obj_t * child;
|
||||
|
||||
/*Adjust margin and get the alignment type*/
|
||||
lv_align_t align;
|
||||
lv_style_t * style = lv_obj_get_style(rect);
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
cord_t vpad_corr = style->vpad;
|
||||
|
||||
switch(type) {
|
||||
case LV_RECT_LAYOUT_ROW_T:
|
||||
case LV_CONT_LAYOUT_ROW_T:
|
||||
vpad_corr = style->vpad;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
case LV_RECT_LAYOUT_ROW_M:
|
||||
case LV_CONT_LAYOUT_ROW_M:
|
||||
vpad_corr = 0;
|
||||
align = LV_ALIGN_IN_LEFT_MID;
|
||||
break;
|
||||
case LV_RECT_LAYOUT_ROW_B:
|
||||
case LV_CONT_LAYOUT_ROW_B:
|
||||
vpad_corr = -style->vpad;
|
||||
align = LV_ALIGN_IN_BOTTOM_LEFT;
|
||||
break;
|
||||
@ -362,33 +360,33 @@ static void lv_rect_layout_row(lv_obj_t * rect)
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(rect, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
/* Align the children */
|
||||
cord_t last_cord = style->hpad;
|
||||
LL_READ_BACK(rect->child_ll, child) {
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
lv_obj_align(child, rect, align, last_cord, vpad_corr);
|
||||
lv_obj_align(child, cont, align, last_cord, vpad_corr);
|
||||
last_cord += lv_obj_get_width(child) + style->opad;
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(rect, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the center layout
|
||||
* @param rect pointer to an object which layout should be handled
|
||||
* @param cont pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_rect_layout_center(lv_obj_t * rect)
|
||||
static void lv_cont_layout_center(lv_obj_t * cont)
|
||||
{
|
||||
lv_obj_t * child;
|
||||
lv_style_t * style = lv_obj_get_style(rect);
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
uint32_t obj_num = 0;
|
||||
cord_t h_tot = 0;
|
||||
|
||||
LL_READ(rect->child_ll, child) {
|
||||
LL_READ(cont->child_ll, child) {
|
||||
h_tot += lv_obj_get_height(child) + style->opad;
|
||||
obj_num ++;
|
||||
}
|
||||
@ -399,41 +397,41 @@ static void lv_rect_layout_center(lv_obj_t * rect)
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(rect, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
/* Align the children */
|
||||
cord_t last_cord = - (h_tot / 2);
|
||||
LL_READ_BACK(rect->child_ll, child) {
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
lv_obj_align(child, rect, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2);
|
||||
lv_obj_align(child, cont, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2);
|
||||
last_cord += lv_obj_get_height(child) + style->opad;
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(rect, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the pretty layout. Put as many object as possible in row
|
||||
* then begin a new row
|
||||
* @param rect pointer to an object which layout should be handled
|
||||
* @param cont pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_rect_layout_pretty(lv_obj_t * rect)
|
||||
static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
{
|
||||
lv_obj_t * child_rs; /* Row starter child */
|
||||
lv_obj_t * child_rc; /* Row closer child */
|
||||
lv_obj_t * child_tmp; /* Temporary child */
|
||||
lv_style_t * style = lv_obj_get_style(rect);
|
||||
cord_t w_obj = lv_obj_get_width(rect);
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
cord_t w_obj = lv_obj_get_width(cont);
|
||||
cord_t act_y = style->vpad;
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
|
||||
child_rs = ll_get_tail(&rect->child_ll); /*Set the row starter child*/
|
||||
child_rs = ll_get_tail(&cont->child_ll); /*Set the row starter child*/
|
||||
if(child_rs == NULL) return; /*Return if no child*/
|
||||
|
||||
lv_obj_set_protect(rect, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
child_rc = child_rs; /*Initially the the row starter and closer is the same*/
|
||||
while(child_rs != NULL) {
|
||||
@ -450,23 +448,23 @@ static void lv_rect_layout_pretty(lv_obj_t * rect)
|
||||
h_row = MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/
|
||||
obj_num ++;
|
||||
}
|
||||
child_rc = ll_get_prev(&rect->child_ll, child_rc); /*Load the next object*/
|
||||
child_rc = ll_get_prev(&cont->child_ll, child_rc); /*Load the next object*/
|
||||
if(obj_num == 0) child_rs = child_rc; /*If the first object was hidden (or too long) then set the next as first */
|
||||
}while(child_rc != NULL);
|
||||
|
||||
/*Step back one child because the last is already not fit*/
|
||||
if(child_rc != NULL && obj_num != 0) child_rc = ll_get_next(&rect->child_ll, child_rc);
|
||||
if(child_rc != NULL && obj_num != 0) child_rc = ll_get_next(&cont->child_ll, child_rc);
|
||||
|
||||
/*If the object is too long then align it to the middle*/
|
||||
if(obj_num == 0) {
|
||||
if(child_rc != NULL) {
|
||||
h_row = lv_obj_get_height(child_rc);
|
||||
lv_obj_align(child_rc, rect, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
lv_obj_align(child_rc, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
}
|
||||
}
|
||||
/*If here is only one object in the row then align it to the left*/
|
||||
else if (obj_num == 1) {
|
||||
lv_obj_align(child_rs, rect, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
lv_obj_align(child_rs, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
}
|
||||
/* Align the children (from child_rs to child_rc)*/
|
||||
else {
|
||||
@ -477,33 +475,33 @@ static void lv_rect_layout_pretty(lv_obj_t * rect)
|
||||
do{
|
||||
if(lv_obj_get_hidden(child_tmp) == false &&
|
||||
lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) {
|
||||
lv_obj_align(child_tmp, rect, LV_ALIGN_IN_TOP_LEFT, act_x, act_y);
|
||||
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x, act_y);
|
||||
act_x += lv_obj_get_width(child_tmp) + new_opad;
|
||||
}
|
||||
child_tmp = ll_get_prev(&rect->child_ll, child_tmp);
|
||||
child_tmp = ll_get_prev(&cont->child_ll, child_tmp);
|
||||
}while(child_tmp != child_rc);
|
||||
|
||||
}
|
||||
|
||||
if(child_rc == NULL) break;
|
||||
act_y += style->opad + h_row; /*y increment*/
|
||||
child_rs = ll_get_prev(&rect->child_ll, child_rc); /*Go to the next object*/
|
||||
child_rs = ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/
|
||||
child_rc = child_rs;
|
||||
}
|
||||
lv_obj_clr_protect(rect, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the grid layout. Align same-sized objects in a grid
|
||||
* @param rect pointer to an object which layout should be handled
|
||||
* @param cont pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_rect_layout_grid(lv_obj_t * rect)
|
||||
static void lv_cont_layout_grid(lv_obj_t * cont)
|
||||
{
|
||||
lv_obj_t * child;
|
||||
lv_style_t * style = lv_obj_get_style(rect);
|
||||
cord_t w_tot = lv_obj_get_width(rect);
|
||||
cord_t w_obj = lv_obj_get_width(lv_obj_get_child(rect, NULL));
|
||||
cord_t h_obj = lv_obj_get_height(lv_obj_get_child(rect, NULL));
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
cord_t w_tot = lv_obj_get_width(cont);
|
||||
cord_t w_obj = lv_obj_get_width(lv_obj_get_child(cont, NULL));
|
||||
cord_t h_obj = lv_obj_get_height(lv_obj_get_child(cont, NULL));
|
||||
uint16_t obj_row = (w_tot - (2 * style->hpad)) / (w_obj + style->opad); /*Obj. num. in a row*/
|
||||
cord_t x_ofs;
|
||||
if(obj_row > 1) {
|
||||
@ -515,13 +513,13 @@ static void lv_rect_layout_grid(lv_obj_t * rect)
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(rect, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
/* Align the children */
|
||||
cord_t act_x = style->hpad;
|
||||
cord_t act_y = style->vpad;
|
||||
uint16_t obj_cnt = 0;
|
||||
LL_READ_BACK(rect->child_ll, child) {
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
@ -540,16 +538,16 @@ static void lv_rect_layout_grid(lv_obj_t * rect)
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(rect, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle auto fit. Set the size of the object to involve all children.
|
||||
* @param rect pointer to an object which size will be modified
|
||||
* @param cont pointer to an object which size will be modified
|
||||
*/
|
||||
static void lv_rect_refr_autofit(lv_obj_t * rect)
|
||||
static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
{
|
||||
lv_rect_ext_t * ext = lv_obj_get_ext(rect);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
|
||||
if(ext->hpad_en == 0 &&
|
||||
ext->vpad_en == 0) {
|
||||
@ -558,21 +556,21 @@ static void lv_rect_refr_autofit(lv_obj_t * rect)
|
||||
|
||||
area_t new_cords;
|
||||
area_t ori;
|
||||
lv_style_t * style = lv_obj_get_style(rect);
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_obj_t * i;
|
||||
cord_t hpad = style->hpad;
|
||||
cord_t vpad = style->vpad;
|
||||
|
||||
/*Search the side coordinates of the children*/
|
||||
lv_obj_get_cords(rect, &ori);
|
||||
lv_obj_get_cords(rect, &new_cords);
|
||||
lv_obj_get_cords(cont, &ori);
|
||||
lv_obj_get_cords(cont, &new_cords);
|
||||
|
||||
new_cords.x1 = LV_CORD_MAX;
|
||||
new_cords.y1 = LV_CORD_MAX;
|
||||
new_cords.x2 = LV_CORD_MIN;
|
||||
new_cords.y2 = LV_CORD_MIN;
|
||||
|
||||
LL_READ(rect->child_ll, i) {
|
||||
LL_READ(cont->child_ll, i) {
|
||||
if(lv_obj_get_hidden(i) != false) continue;
|
||||
new_cords.x1 = MATH_MIN(new_cords.x1, i->cords.x1);
|
||||
new_cords.y1 = MATH_MIN(new_cords.y1, i->cords.y1);
|
||||
@ -586,33 +584,33 @@ static void lv_rect_refr_autofit(lv_obj_t * rect)
|
||||
new_cords.x1 -= hpad;
|
||||
new_cords.x2 += hpad;
|
||||
} else {
|
||||
new_cords.x1 = rect->cords.x1;
|
||||
new_cords.x2 = rect->cords.x2;
|
||||
new_cords.x1 = cont->cords.x1;
|
||||
new_cords.x2 = cont->cords.x2;
|
||||
}
|
||||
if(ext->vpad_en != 0) {
|
||||
new_cords.y1 -= vpad;
|
||||
new_cords.y2 += vpad;
|
||||
} else {
|
||||
new_cords.y1 = rect->cords.y1;
|
||||
new_cords.y2 = rect->cords.y2;
|
||||
new_cords.y1 = cont->cords.y1;
|
||||
new_cords.y2 = cont->cords.y2;
|
||||
}
|
||||
|
||||
/*Do nothing if the coordinates are not changed*/
|
||||
if(rect->cords.x1 != new_cords.x1 ||
|
||||
rect->cords.y1 != new_cords.y1 ||
|
||||
rect->cords.x2 != new_cords.x2 ||
|
||||
rect->cords.y2 != new_cords.y2) {
|
||||
if(cont->cords.x1 != new_cords.x1 ||
|
||||
cont->cords.y1 != new_cords.y1 ||
|
||||
cont->cords.x2 != new_cords.x2 ||
|
||||
cont->cords.y2 != new_cords.y2) {
|
||||
|
||||
lv_obj_inv(rect);
|
||||
area_cpy(&rect->cords, &new_cords);
|
||||
lv_obj_inv(rect);
|
||||
lv_obj_inv(cont);
|
||||
area_cpy(&cont->cords, &new_cords);
|
||||
lv_obj_inv(cont);
|
||||
|
||||
/*Notify the object about its new coordinates*/
|
||||
rect->signal_f(rect, LV_SIGNAL_CORD_CHG, &ori);
|
||||
cont->signal_f(cont, LV_SIGNAL_CORD_CHG, &ori);
|
||||
|
||||
/*Inform the parent about the new coordinates*/
|
||||
lv_obj_t * par = lv_obj_get_parent(rect);
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, rect);
|
||||
lv_obj_t * par = lv_obj_get_parent(cont);
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, cont);
|
||||
}
|
||||
}
|
||||
}
|
114
lv_objx/lv_cont.h
Normal file
114
lv_objx/lv_cont.h
Normal file
@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @file lv_cont.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CONT_H
|
||||
#define LV_CONT_H
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_RECT != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "../lv_obj/lv_dispi.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Layout options*/
|
||||
typedef enum
|
||||
{
|
||||
LV_CONT_LAYOUT_OFF = 0,
|
||||
LV_CONT_LAYOUT_CENTER,
|
||||
LV_CONT_LAYOUT_COL_L, /*Column left align*/
|
||||
LV_CONT_LAYOUT_COL_M, /*Column middle align*/
|
||||
LV_CONT_LAYOUT_COL_R, /*Column right align*/
|
||||
LV_CONT_LAYOUT_ROW_T, /*Row left align*/
|
||||
LV_CONT_LAYOUT_ROW_M, /*Row middle align*/
|
||||
LV_CONT_LAYOUT_ROW_B, /*Row right align*/
|
||||
LV_CONT_LAYOUT_PRETTY, /*Put as many object as possible in row and begin a new row*/
|
||||
LV_CONT_LAYOUT_GRID, /*Align same-sized object into a grid*/
|
||||
}lv_cont_layout_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint8_t layout :5; /*Set a layout from 'lv_cont_layout_t' enum*/
|
||||
uint8_t hpad_en :1; /*Enable horizontal padding according to the children*/
|
||||
uint8_t vpad_en :1; /*Enable horizontal padding according to the children*/
|
||||
}lv_cont_ext_t;
|
||||
|
||||
/**********************
|
||||
* 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, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the container
|
||||
* @param cont pointer to a container object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the layout on a container
|
||||
* @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_cont_layout_t layout);
|
||||
|
||||
/**
|
||||
* Enable the horizontal or vertical fit.
|
||||
* The container size will be set to involve the children horizontally or vertically.
|
||||
* @param cont pointer to a container object
|
||||
* @param hor_en true: enable the horizontal padding
|
||||
* @param ver_en true: enable the vertical padding
|
||||
*/
|
||||
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en);
|
||||
|
||||
/**
|
||||
* Get the layout of a container
|
||||
* @param cont pointer to container object
|
||||
* @return the layout from 'lv_cont_layout_t'
|
||||
*/
|
||||
lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont);
|
||||
|
||||
/**
|
||||
* Get horizontal fit enable attribute of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: horizontal padding is enabled
|
||||
*/
|
||||
bool lv_cont_get_hfit(lv_obj_t * cont);
|
||||
|
||||
/**
|
||||
* Get vertical fit enable attribute of a container
|
||||
* @param obj pointer to a container object
|
||||
* @return true: vertical padding is enabled
|
||||
*/
|
||||
bool lv_cont_get_vfit(lv_obj_t * cont);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -86,7 +86,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
ext->opt_label = lv_label_create(new_ddlist, NULL);
|
||||
lv_obj_set_style(ext->opt_label, NULL); /*Inherit the style*/
|
||||
lv_rect_set_fit(new_ddlist, true, false);
|
||||
lv_cont_set_fit(new_ddlist, true, false);
|
||||
lv_page_set_rel_action(new_ddlist, lv_ddlist_rel_action);
|
||||
lv_page_set_sb_mode(new_ddlist, LV_PAGE_SB_MODE_DRAG);
|
||||
lv_obj_set_style(new_ddlist, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
|
@ -24,6 +24,7 @@
|
||||
#define LV_GAUGE_DEF_WIDTH (3 * LV_DPI)
|
||||
#define LV_GAUGE_DEF_HEIGHT (3 * LV_DPI)
|
||||
#define LV_GAUGE_DEF_NEEDLE_COLOR COLOR_RED
|
||||
#define LV_GAUGE_DEF_ANGLE 220
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@ -61,7 +62,7 @@ static lv_design_f_t ancestor_design_f = NULL;
|
||||
lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor gauge*/
|
||||
lv_obj_t * new_gauge = lv_rect_create(par, copy);
|
||||
lv_obj_t * new_gauge = lv_cont_create(par, copy);
|
||||
dm_assert(new_gauge);
|
||||
|
||||
/*Allocate the gauge type specific extended data*/
|
||||
@ -75,7 +76,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->values = NULL;
|
||||
ext->needle_color = NULL;
|
||||
ext->low_critical = 0;
|
||||
ext->scale_angle = 120;
|
||||
ext->scale_angle = LV_GAUGE_DEF_ANGLE;
|
||||
ext->scale_label_num = 6;
|
||||
ext->style_critical = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
||||
|
||||
@ -123,7 +124,7 @@ bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param)
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_rect_signal(gauge, sign, param);
|
||||
valid = lv_cont_signal(gauge, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
@ -457,7 +458,7 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style
|
||||
lv_style_get(LV_STYLE_PLAIN, &style_neddle_mid);
|
||||
style_neddle_mid.mcolor = style->bcolor;
|
||||
style_neddle_mid.gcolor = style->bcolor;
|
||||
style_neddle_mid.radius = LV_RECT_CIRCLE;
|
||||
style_neddle_mid.radius = LV_CONT_CIRCLE;
|
||||
|
||||
area_t nm_cord;
|
||||
nm_cord.x1 = x_ofs - style->opad;
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lv_label.h"
|
||||
#include "lv_line.h"
|
||||
|
||||
|
@ -49,7 +49,7 @@ static bool lv_img_is_symbol(const char * txt);
|
||||
/**
|
||||
* Create an image objects
|
||||
* @param par pointer to an object, it will be the parent of the new button
|
||||
* @param copy pointer to a rectangle object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a image object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created image
|
||||
*/
|
||||
lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_LED != 0
|
||||
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lv_led.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
@ -56,7 +56,7 @@ static lv_design_f_t ancestor_design_f;
|
||||
lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor basic object*/
|
||||
lv_obj_t * new_led = lv_rect_create(par, copy);
|
||||
lv_obj_t * new_led = lv_cont_create(par, copy);
|
||||
dm_assert(new_led);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
@ -98,7 +98,7 @@ bool lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param)
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_rect_signal(led, sign, param);
|
||||
valid = lv_cont_signal(led, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
|
@ -30,7 +30,7 @@
|
||||
/*Data of led*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t bg_rect; /*Ext. of ancestor*/
|
||||
lv_cont_ext_t bg_rect; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint8_t bright; /*Current brightness of the LED (0..255)*/
|
||||
}lv_led_ext_t;
|
||||
|
@ -58,7 +58,7 @@ lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_t * new_line = lv_obj_create(par, copy);
|
||||
dm_assert(new_line);
|
||||
|
||||
/*Extend the basic object to rectangle object*/
|
||||
/*Extend the basic object to line object*/
|
||||
lv_line_ext_t * ext = lv_obj_alloc_ext(new_line, sizeof(lv_line_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->point_num = 0;
|
||||
@ -70,7 +70,7 @@ lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_set_design_f(new_line, lv_line_design);
|
||||
lv_obj_set_signal_f(new_line, lv_line_signal);
|
||||
|
||||
/*Init the new rectangle*/
|
||||
/*Init the new line*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_line, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
}
|
||||
|
@ -10,13 +10,13 @@
|
||||
#if USE_LV_LIST != 0
|
||||
|
||||
#include "lv_list.h"
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_LIST_LAYOUT_DEF LV_RECT_LAYOUT_COL_M
|
||||
#define LV_LIST_LAYOUT_DEF LV_CONT_LAYOUT_COL_M
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -71,7 +71,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Init the new list object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size_us(new_list, 2 * LV_DPI, 3 * LV_DPI);
|
||||
lv_rect_set_layout(ext->page.scrl, LV_LIST_LAYOUT_DEF);
|
||||
lv_cont_set_layout(ext->page.scrl, LV_LIST_LAYOUT_DEF);
|
||||
lv_obj_set_style(new_list, lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
lv_obj_set_style(lv_page_get_scrl(new_list), lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_page_set_sb_mode(new_list, LV_PAGE_SB_MODE_AUTO);
|
||||
@ -121,8 +121,8 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, l
|
||||
|
||||
lv_btn_set_rel_action(liste, rel_action);
|
||||
lv_page_glue_obj(liste, true);
|
||||
lv_rect_set_layout(liste, LV_RECT_LAYOUT_ROW_M);
|
||||
lv_rect_set_fit(liste, false, true);
|
||||
lv_cont_set_layout(liste, LV_CONT_LAYOUT_ROW_M);
|
||||
lv_cont_set_fit(liste, false, true);
|
||||
|
||||
if(img_fn != NULL && img_fn[0] != '\0') {
|
||||
lv_obj_t * img = lv_img_create(liste, NULL);
|
||||
|
@ -59,7 +59,7 @@ static void lv_mbox_disable_fit(lv_obj_t * mbox);
|
||||
lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor message box*/
|
||||
lv_obj_t * new_mbox = lv_rect_create(par, copy);
|
||||
lv_obj_t * new_mbox = lv_cont_create(par, copy);
|
||||
dm_assert(new_mbox);
|
||||
|
||||
/*Allocate the message box type specific extended data*/
|
||||
@ -78,8 +78,8 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*Init the new message box message box*/
|
||||
if(copy == NULL) {
|
||||
lv_rect_set_layout(new_mbox, LV_RECT_LAYOUT_COL_L);
|
||||
lv_rect_set_fit(new_mbox, true, true);
|
||||
lv_cont_set_layout(new_mbox, LV_CONT_LAYOUT_COL_L);
|
||||
lv_cont_set_fit(new_mbox, true, true);
|
||||
|
||||
ext->txt = lv_label_create(new_mbox, NULL);
|
||||
lv_label_set_text(ext->txt, "Text of the message box");
|
||||
@ -126,7 +126,7 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_rect_signal(mbox, sign, param);
|
||||
valid = lv_cont_signal(mbox, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
@ -201,11 +201,11 @@ lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t re
|
||||
|
||||
/*Create a button if it is not existed yet*/
|
||||
if(ext->btnh == NULL) {
|
||||
ext->btnh = lv_rect_create(mbox, NULL);
|
||||
ext->btnh = lv_cont_create(mbox, NULL);
|
||||
lv_obj_set_style(ext->btnh, lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
lv_obj_set_click(ext->btnh, false);
|
||||
lv_rect_set_fit(ext->btnh, false, true);
|
||||
lv_rect_set_layout(ext->btnh, LV_RECT_LAYOUT_PRETTY);
|
||||
lv_cont_set_fit(ext->btnh, false, true);
|
||||
lv_cont_set_layout(ext->btnh, LV_CONT_LAYOUT_PRETTY);
|
||||
}
|
||||
|
||||
lv_obj_t * btn;
|
||||
@ -214,7 +214,7 @@ lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t re
|
||||
lv_btn_set_styles(btn, ext->styles_btn[LV_BTN_STATE_REL], ext->styles_btn[LV_BTN_STATE_PR],
|
||||
ext->styles_btn[LV_BTN_STATE_TREL], ext->styles_btn[LV_BTN_STATE_TPR],
|
||||
ext->styles_btn[LV_BTN_STATE_INA]);
|
||||
lv_rect_set_fit(btn, true, true);
|
||||
lv_cont_set_fit(btn, true, true);
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(btn, NULL);
|
||||
@ -405,7 +405,7 @@ static void lv_mbox_realign(lv_obj_t * mbox)
|
||||
*/
|
||||
static void lv_mbox_disable_fit(lv_obj_t * mbox)
|
||||
{
|
||||
lv_rect_set_fit(mbox, false, false);
|
||||
lv_cont_set_fit(mbox, false, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lv_btn.h"
|
||||
#include "lv_label.h"
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
/*Data of message box*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t bg; /*Ext. of ancestor*/
|
||||
lv_cont_ext_t bg; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * txt; /*Text of the message box*/
|
||||
lv_obj_t * btnh; /*Holder of the buttons*/
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "misc/math/math_base.h"
|
||||
#include "../lv_objx/lv_page.h"
|
||||
#include "../lv_objx/lv_rect.h"
|
||||
#include "../lv_objx/lv_cont.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_obj/lv_refr.h"
|
||||
#include "../lv_misc/anim.h"
|
||||
@ -61,7 +61,7 @@ static lv_design_f_t ancestor_design_f;
|
||||
lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor object*/
|
||||
lv_obj_t * new_page = lv_rect_create(par, copy);
|
||||
lv_obj_t * new_page = lv_cont_create(par, copy);
|
||||
dm_assert(new_page);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
@ -81,12 +81,12 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Init the new page object*/
|
||||
if(copy == NULL) {
|
||||
lv_style_t * style = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
||||
ext->scrl = lv_rect_create(new_page, NULL);
|
||||
ext->scrl = lv_cont_create(new_page, NULL);
|
||||
lv_obj_set_signal_f(ext->scrl, lv_scrl_signal);
|
||||
lv_obj_set_drag(ext->scrl, true);
|
||||
lv_obj_set_drag_throw(ext->scrl, true);
|
||||
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT);
|
||||
lv_rect_set_fit(ext->scrl, true, true);
|
||||
lv_cont_set_fit(ext->scrl, true, true);
|
||||
lv_obj_set_style(ext->scrl, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
@ -96,7 +96,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_set_style(new_page, style);
|
||||
} else {
|
||||
lv_page_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->scrl = lv_rect_create(new_page, copy_ext->scrl);
|
||||
ext->scrl = lv_cont_create(new_page, copy_ext->scrl);
|
||||
lv_obj_set_signal_f(ext->scrl, lv_scrl_signal);
|
||||
|
||||
lv_page_set_pr_action(new_page, copy_ext->pr_action);
|
||||
@ -128,7 +128,7 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
bool obj_valid = true;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
obj_valid = lv_rect_signal(page, sign, param);
|
||||
obj_valid = lv_cont_signal(page, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
@ -209,7 +209,7 @@ static bool lv_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void* param)
|
||||
bool obj_valid = true;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
obj_valid = lv_rect_signal(scrl, sign, param);
|
||||
obj_valid = lv_cont_signal(scrl, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
@ -480,7 +480,7 @@ 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
|
||||
* @return pointer to a container which is the scrollable part of the page
|
||||
*/
|
||||
lv_obj_t * lv_page_get_scrl(lv_obj_t * page)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -34,13 +34,13 @@ typedef enum
|
||||
LV_PAGE_SB_MODE_OFF, /*Never show scrollbars*/
|
||||
LV_PAGE_SB_MODE_ON, /*Always show scrollbars*/
|
||||
LV_PAGE_SB_MODE_DRAG, /*Show scrollbars when page is being dragged*/
|
||||
LV_PAGE_SB_MODE_AUTO, /*Show scrollbars when the scrollable rect. is large enough to be scrolled*/
|
||||
LV_PAGE_SB_MODE_AUTO, /*Show scrollbars when the scrollable container is large enough to be scrolled*/
|
||||
}lv_page_sb_mode_t;
|
||||
|
||||
/*Data of page*/
|
||||
typedef struct
|
||||
{
|
||||
lv_rect_ext_t bg_rect; /*Ext. of ancestor*/
|
||||
lv_cont_ext_t bg_rect; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * scrl; /*The scrollable object on the background*/
|
||||
lv_action_t rel_action; /*Function to call when the page is released*/
|
||||
@ -110,7 +110,7 @@ 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
|
||||
* @return pointer to container which is the scrollable part of the page
|
||||
*/
|
||||
lv_obj_t * lv_page_get_scrl(lv_obj_t * page);
|
||||
|
||||
|
@ -1,114 +0,0 @@
|
||||
/**
|
||||
* @file lv_rect.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_RECT_H
|
||||
#define LV_RECT_H
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_RECT != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "../lv_obj/lv_dispi.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Layout options*/
|
||||
typedef enum
|
||||
{
|
||||
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*/
|
||||
LV_RECT_LAYOUT_ROW_T, /*Row left align*/
|
||||
LV_RECT_LAYOUT_ROW_M, /*Row middle align*/
|
||||
LV_RECT_LAYOUT_ROW_B, /*Row right align*/
|
||||
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*/
|
||||
}lv_rect_layout_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint8_t layout :5; /*Set a layout from 'lv_rect_layout_t' enum*/
|
||||
uint8_t hpad_en :1; /*Enable horizontal padding according to the children*/
|
||||
uint8_t vpad_en :1; /*Enable horizontal padding according to the children*/
|
||||
}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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
bool lv_rect_signal(lv_obj_t * rect, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the layout on a rectangle
|
||||
* @param rect pointer to a rectangle object
|
||||
* @param layout a layout from 'lv_rect_layout_t'
|
||||
*/
|
||||
void lv_rect_set_layout(lv_obj_t * rect, lv_rect_layout_t layout);
|
||||
|
||||
/**
|
||||
* 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'
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
bool lv_rect_get_vfit(lv_obj_t * rect);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -80,7 +80,8 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Copy an existing slider*/
|
||||
else {
|
||||
lv_slider_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
|
||||
ext->style_knob = copy_ext->style_knob;
|
||||
ext->cb = copy_ext->cb;
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_slider);
|
||||
}
|
||||
|
@ -79,12 +79,12 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_page_set_sb_mode(ext->page, LV_PAGE_SB_MODE_AUTO);
|
||||
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
|
||||
lv_rect_set_fit(scrl, false, true);
|
||||
lv_cont_set_fit(scrl, false, true);
|
||||
lv_obj_set_style(scrl, lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
|
||||
/*Create a holder for the header*/
|
||||
ext->header = lv_rect_create(new_win, NULL);
|
||||
lv_rect_set_fit(ext->header, false, true);
|
||||
ext->header = lv_cont_create(new_win, NULL);
|
||||
lv_cont_set_fit(ext->header, false, true);
|
||||
/*Move back the header because it is automatically moved to the scrollable */
|
||||
lv_obj_set_protect(ext->header, LV_PROTECT_PARENT);
|
||||
lv_obj_set_parent(ext->header, new_win);
|
||||
@ -95,10 +95,10 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_label_set_text(ext->title,"My title");
|
||||
|
||||
/*Create a holder for the control buttons*/
|
||||
ext->btnh = lv_rect_create(ext->header, NULL);
|
||||
lv_rect_set_fit(ext->btnh, true, false);
|
||||
ext->btnh = lv_cont_create(ext->header, NULL);
|
||||
lv_cont_set_fit(ext->btnh, true, false);
|
||||
lv_obj_set_style(ext->btnh, lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
lv_rect_set_layout(ext->btnh, LV_RECT_LAYOUT_ROW_M);
|
||||
lv_cont_set_layout(ext->btnh, LV_CONT_LAYOUT_ROW_M);
|
||||
|
||||
lv_obj_set_signal_f(new_win, lv_win_signal);
|
||||
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
|
||||
@ -107,13 +107,13 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
else {
|
||||
lv_win_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
/*Create the objects*/
|
||||
ext->header = lv_rect_create(new_win, copy_ext->header);
|
||||
ext->header = lv_cont_create(new_win, copy_ext->header);
|
||||
/*Move back the header because it is automatically moved to the scrollable */
|
||||
lv_obj_set_protect(ext->header, LV_PROTECT_PARENT);
|
||||
lv_obj_set_parent(ext->header, new_win);
|
||||
|
||||
ext->title = lv_label_create(ext->header, copy_ext->title);
|
||||
ext->btnh = lv_rect_create(ext->header, copy_ext->btnh);
|
||||
ext->btnh = lv_cont_create(ext->header, copy_ext->btnh);
|
||||
|
||||
/*Copy the control buttons*/
|
||||
lv_obj_t * child;
|
||||
|
@ -38,7 +38,7 @@
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_rect.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lv_btn.h"
|
||||
#include "lv_label.h"
|
||||
#include "lv_img.h"
|
||||
@ -58,10 +58,10 @@ typedef struct
|
||||
/*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * page;
|
||||
lv_obj_t * header; /*Pointer to the header rectangle of the window*/
|
||||
lv_obj_t * header; /*Pointer to the header container of the window*/
|
||||
lv_obj_t * title; /*Pointer to the title label of the window*/
|
||||
lv_obj_t * btnh; /*Pointer to the control button holder rectangle of the window*/
|
||||
lv_style_t * style_header; /*Style of the header rectangle*/
|
||||
lv_obj_t * btnh; /*Pointer to the control button holder container of the window*/
|
||||
lv_style_t * style_header; /*Style of the header container*/
|
||||
lv_style_t * style_cbtn_rel; /*Control button releases style*/
|
||||
lv_style_t * style_cbtn_pr; /*Control button pressed style*/
|
||||
cord_t cbtn_size; /*Size of the control buttons (square)*/
|
||||
|
Loading…
Reference in New Issue
Block a user