Description
What MCU/Processor/Board and compiler are you using?
VS 2015
What do you experience?
I add a child control to the list control, and set the position of the child control according to the order of each addition, but after calling lv_obj_set_pos(), the printed position information is not the set value
What do you expect?
E.g:
lv_obj_set_pos(obj, 0, 20);
std::cout << lv_obj_get_y(obj) << std::endl;
I think it should output: 20, but it actually outputs: 0.
Code to reproduce
void AddElementToList(uint8_t alarmLevel, const void * pImgSrc, const char * pTxt)
{
lv_obj_t* pObj = lv_list_add_btn(m_pAlarmInfoList, NULL, NULL);
if (nullptr == pObj)
{
return;
}
lv_obj_set_size(pObj, 370, 74);
lv_obj_set_style_local_border_color(pObj, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, g_AlarmColorArrary[alarmLevel]);
lv_obj_set_style_local_border_color(pObj, LV_BTN_PART_MAIN, LV_STATE_FOCUSED, g_AlarmColorArrary[alarmLevel]);
lv_obj_set_style_local_border_side(pObj, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL);
lv_obj_set_style_local_border_width(pObj, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 1);
lv_obj_set_style_local_border_width(pObj, LV_BTN_PART_MAIN, LV_STATE_FOCUSED, 3);
lv_obj_set_style_local_outline_opa(pObj, LV_BTN_PART_MAIN, LV_STATE_FOCUSED, LV_OPA_0);
lv_obj_set_style_local_bg_opa(pObj, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
lv_obj_set_style_local_text_color(pObj, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, g_AlarmColorArrary[alarmLevel]);
lv_btn_set_layout(pObj, LV_LAYOUT_OFF);
if (pImgSrc != nullptr)
{
lv_obj_t* pAlarmImg = lv_img_create(pObj, NULL);
lv_img_set_src(pAlarmImg, pImgSrc);
lv_obj_align(pAlarmImg, pObj, LV_ALIGN_IN_LEFT_MID, 40, 0);
}
if (pTxt != nullptr)
{
lv_obj_t* pAlarmInfo = lv_label_create(pObj, NULL);
lv_label_set_text(pAlarmInfo, pTxt);
lv_obj_set_style_local_text_font(pAlarmInfo, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &font_source_han_sans_cn_regular_18);
lv_obj_align(pAlarmInfo, pObj, LV_ALIGN_IN_LEFT_MID, 94, 10);
}
lv_obj_t* pPreBtn = lv_list_get_prev_btn(m_pAlarmInfoList, pObj);
static int index(0);
if (nullptr != pPreBtn)
{
lv_obj_set_pos(pObj, 0, lv_obj_get_y(pPreBtn) + 74 + 3);
std::cout << "Index: " << index++ << " x: 0" << " y:" << lv_obj_get_y(pObj) << std::endl;
}
else
{
lv_obj_set_pos(pObj, 0, 20);
std::cout << "Index: " << index++ << " x: 0" << " y:" << lv_obj_get_y(pObj) << std::endl;
lv_list_focus_btn(m_pAlarmInfoList, pObj);
}
}