From b73efc27df4788439f9087c19ea701967261b6c7 Mon Sep 17 00:00:00 2001 From: Gabor Date: Fri, 6 Jan 2017 13:37:25 +0100 Subject: [PATCH] lv_objx: minor fixes --- lv_objx/lv_cb.c | 30 ++++++++++++++++++++---------- lv_objx/lv_mbox.c | 8 +++----- lv_objx/lv_rect.c | 3 ++- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lv_objx/lv_cb.c b/lv_objx/lv_cb.c index 068933b7e..3f374e489 100644 --- a/lv_objx/lv_cb.c +++ b/lv_objx/lv_cb.c @@ -22,16 +22,14 @@ /********************** * STATIC PROTOTYPES **********************/ -#if 0 /*The ancestor design function is used */ static bool lv_cb_design(lv_obj_t * cb, const area_t * mask, lv_design_mode_t mode); -#endif static void lv_cbs_init(void); /********************** * STATIC VARIABLES **********************/ static lv_cbs_t lv_cbs_def; - +static lv_design_f_t ancestor_design_f; /********************** * MACROS **********************/ @@ -61,7 +59,10 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy) ext->bullet = NULL; ext->label = NULL; + if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_cb); + lv_obj_set_signal_f(new_cb, lv_cb_signal); + lv_obj_set_design_f(new_cb, lv_cb_design); /*Init the new checkbox object*/ if(copy == NULL) { @@ -207,7 +208,6 @@ lv_cbs_t * lv_cbs_get(lv_cbs_builtin_t style, lv_cbs_t * copy) * STATIC FUNCTIONS **********************/ -#if 0 /*The ancestor design function is used */ /** * Handle the drawing related tasks of the check boxes * @param cb pointer to an object @@ -222,14 +222,23 @@ static bool lv_cb_design(lv_obj_t * cb, const area_t * mask, lv_design_mode_t mo { if(mode == LV_DESIGN_COVER_CHK) { /*Return false if the object is not covers the mask_p area*/ - return false; + return ancestor_design_f(cb, mask, mode); + } else if(mode == LV_DESIGN_DRAW_MAIN || mode == LV_DESIGN_DRAW_POST) { + lv_cb_ext_t * cb_ext = lv_obj_get_ext(cb); + lv_btn_ext_t * bullet_ext = lv_obj_get_ext(cb_ext->bullet); + + /*Be sure he state of the bullet is the same as the parent button*/ + bullet_ext->state = cb_ext->bg_btn.state; + + return ancestor_design_f(cb, mask, mode); + } /*Draw the object*/ return true; } -#endif + /** * Initialize the rectangle styles */ @@ -239,8 +248,8 @@ static void lv_cbs_init(void) /*Bg style*/ lv_btns_get(LV_RECTS_TRANSP, &lv_cbs_def.bg); - lv_cbs_def.bg.rects.hpad = 0 * LV_DOWNSCALE; - lv_cbs_def.bg.rects.vpad = 0 * LV_DOWNSCALE; + lv_cbs_def.bg.rects.hpad = 6 * LV_DOWNSCALE; + lv_cbs_def.bg.rects.vpad = 6 * LV_DOWNSCALE; lv_cbs_def.bg.rects.opad = 5 * LV_DOWNSCALE; /*Bullet style*/ @@ -259,12 +268,12 @@ static void lv_cbs_init(void) lv_cbs_def.bullet.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x20, 0x30, 0x40); lv_cbs_def.bullet.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x10, 0x20, 0x30); lv_cbs_def.bullet.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_WHITE; - lv_cbs_def.bullet.flags[LV_BTN_STATE_TGL_REL].light_en = 0; + lv_cbs_def.bullet.flags[LV_BTN_STATE_TGL_REL].light_en = 1; lv_cbs_def.bullet.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x50, 0x70, 0x90); lv_cbs_def.bullet.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x20, 0x30, 0x40); lv_cbs_def.bullet.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_WHITE; - lv_cbs_def.bullet.flags[LV_BTN_STATE_TGL_PR].light_en = 0; + lv_cbs_def.bullet.flags[LV_BTN_STATE_TGL_PR].light_en = 1; lv_cbs_def.bullet.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER; lv_cbs_def.bullet.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY; @@ -273,6 +282,7 @@ static void lv_cbs_init(void) lv_cbs_def.bullet.rects.bwidth = 2 * LV_DOWNSCALE; lv_cbs_def.bullet.rects.bopa = 70; + lv_cbs_def.bullet.rects.light = 6 * LV_DOWNSCALE; lv_cbs_def.bullet.rects.empty = 0; lv_cbs_def.bullet.rects.round = LV_OBJ_DEF_WIDTH / 3 / 4; lv_cbs_def.bullet.rects.hpad = 0 * LV_DOWNSCALE; diff --git a/lv_objx/lv_mbox.c b/lv_objx/lv_mbox.c index 841edc5a2..dd97a3c37 100644 --- a/lv_objx/lv_mbox.c +++ b/lv_objx/lv_mbox.c @@ -27,7 +27,7 @@ #if 0 /*Unused*/ static bool lv_mbox_design(lv_obj_t * mbox, const area_t * mask, lv_design_mode_t mode); #endif -static void lv_temps_init(void); +static void lv_mboxs_init(void); static void lv_mbox_realign(lv_obj_t * mbox); /********************** @@ -318,7 +318,7 @@ lv_mboxs_t * lv_mboxs_get(lv_mboxs_builtin_t style, lv_mboxs_t * copy) /*Make the style initialization if it is not done yet*/ if(style_inited == false) { - lv_temps_init(); + lv_mboxs_init(); style_inited = true; } @@ -378,7 +378,7 @@ static bool lv_mbox_design(lv_obj_t * mbox, const area_t * mask, lv_design_mode_ /** * Initialize the message box styles */ -static void lv_temps_init(void) +static void lv_mboxs_init(void) { /*Default style*/ lv_rects_get(LV_RECTS_DEF, &lv_mboxs_def.bg); @@ -417,6 +417,4 @@ static void lv_mbox_realign(lv_obj_t * mbox) lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); } - - #endif diff --git a/lv_objx/lv_rect.c b/lv_objx/lv_rect.c index 2a5a9e811..5189f577e 100644 --- a/lv_objx/lv_rect.c +++ b/lv_objx/lv_rect.c @@ -345,7 +345,7 @@ static void lv_rect_draw_light(lv_obj_t * rect, const area_t * mask) light_style.empty = 1; light_style.bwidth = light_size; - light_style.round = style->round + light_size; + light_style.round = style->round + light_size + 1; light_style.bcolor = style->lcolor; light_style.bopa = 100; @@ -411,6 +411,7 @@ static void lv_rect_layout_col(lv_obj_t * rect) switch(type) { case LV_RECT_LAYOUT_COL_L: + hpad_corr = style->hpad; align = LV_ALIGN_IN_TOP_LEFT; break; case LV_RECT_LAYOUT_COL_M: