In issue number #119 LV_BTN_STYLE_REL is given as a way to create transparent button style. However compiler can’t find the definition for this constant (also mentioned in lv_obj.c line 3271)
What MCU/Processor/Board and compiler are you using?
simulator and STM32F769I-DISCO
What LVGL version are you using?
7.5.0
What do you want to achieve?
A clickable image as described in issue #119
What have you tried so far?
tryed to compile the example from issue #119
Code to reproduce
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
lv_btn_set_fit(btn1, true, true); /*Automatically increase the size to involve all children (now only the image)*/
lv_btn_set_style(btn1, LV_BTN_STYLE_REL, &lv_style_transp_tight); /*Transparent style for released button*/
lv_btn_set_style(btn1, LV_BTN_STYLE_PR, &lv_style_transp_tight); /*Transparent style for pressed button*/
lv_btn_set_action(btn1, LV_BTN_ACTION_CLICK, lpr_test);
lv_obj_t * img = lv_img_create(btn1, NULL); /*Create the image on 'btn1'*/
lv_obj_set_click(img, false); /*Don't let to click to the image (click the background button instead)*/
/*...and finally set a file for the image...*/
Hi
I don’t know where is issue #119, (which would be better to be linked to.)
But the problem is, you are using codes compatible with ver 6. So otherwise use the LVGL ver 6, or better use example codes for ver 7.
I think an update to the example you referenced would look something like this for V7+:
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
lv_btn_set_fit(btn1, LV_FIT_TIGHT); /*Automatically increase the size to involve all children (now only the image)*/
lv_obj_set_pos(btn1, 20, 20);
lv_obj_set_style_local_bg_opa(btn1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_obj_set_style_local_bg_opa(btn1, LV_BTN_PART_MAIN, LV_STATE_PRESSED, LV_OPA_TRANSP);
lv_obj_t * img = lv_img_create(btn1, NULL); /*Create the image on 'btn1'*/
lv_obj_set_click(img, false); /*Don't let to click to the image (click the background button instead)*/
lv_img_set_src(img, LV_SYMBOL_OK "Accept");