lvgl/src/lv_objx/lv_imgbtn.c
/**
 * Create a image button object
 * @param par pointer to an object, it will be the parent of the new image button
 * @param copy pointer to a image button object, if not NULL then the new object will be copied from
 * it
 * @return pointer to the created image button
 */
Create a image button object
@param par pointer to an object, it will be the parent of the new image button
@param copy pointer to a image button object, if not NULL then the new object will be copied from
it
@return pointer to the created image button
Create a image button object @param par pointer to an object it will be the parent of the new image button @param copy pointer to a image button object if not NULL then the new object will be copied from it @return pointer to the created image button
lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
{
    LV_LOG_TRACE("image button create started");
    lv_obj_t * new_imgbtn = lv_btn_create(par, copy);
    LV_ASSERT_MEM(new_imgbtn);
    if(new_imgbtn == NULL) return NULL;
    lv_imgbtn_ext_t * ext = lv_obj_allocate_ext_attr(new_imgbtn, sizeof(lv_imgbtn_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;
    if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_imgbtn);
    if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_imgbtn);
#if LV_IMGBTN_TILED == 0
    memset((void*)ext->img_src, 0, sizeof(ext->img_src));
#else
    memset(ext->img_src_left, 0, sizeof(ext->img_src_left));
    memset(ext->img_src_mid, 0, sizeof(ext->img_src_mid));
    memset(ext->img_src_right, 0, sizeof(ext->img_src_right));
#endif
    ext->act_cf = LV_IMG_CF_UNKNOWN;
    lv_obj_set_signal_cb(new_imgbtn, lv_imgbtn_signal);
    lv_obj_set_design_cb(new_imgbtn, lv_imgbtn_design);
    if(copy == NULL) {
    }
    else {
        lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
#if LV_IMGBTN_TILED == 0
        memcpy((void*)ext->img_src, copy_ext->img_src, sizeof(ext->img_src));
#else
        memcpy((void*)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left));
        memcpy((void*)ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid));
        memcpy((void*)ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right));
#endif
        lv_obj_refresh_style(new_imgbtn);
    }
    LV_LOG_INFO("image button created");
    return new_imgbtn;
}
lv_obj_t * lv_imgbtn_create ( lv_obj_t * par , const lv_obj_t * copy ) { LV_LOG_TRACE ( " " ) ; lv_obj_t * new_imgbtn = lv_btn_create ( par , copy ) ; LV_ASSERT_MEM ( new_imgbtn ) ; if ( new_imgbtn == NULL ) return NULL ; lv_imgbtn_ext_t * ext = lv_obj_allocate_ext_attr ( new_imgbtn , sizeof ( lv_imgbtn_ext_t ) ) ; LV_ASSERT_MEM ( ext ) ; if ( ext == NULL ) return NULL ; if ( ancestor_signal == NULL ) ancestor_signal = lv_obj_get_signal_cb ( new_imgbtn ) ; if ( ancestor_design == NULL ) ancestor_design = lv_obj_get_design_cb ( new_imgbtn ) ; #if LV_IMGBTN_TILED == 0 memset ( ( void * ) ext -> img_src , 0 , sizeof ( ext -> img_src ) ) ; #else memset ( ext -> img_src_left , 0 , sizeof ( ext -> img_src_left ) ) ; memset ( ext -> img_src_mid , 0 , sizeof ( ext -> img_src_mid ) ) ; memset ( ext -> img_src_right , 0 , sizeof ( ext -> img_src_right ) ) ; #endif ext -> act_cf = LV_IMG_CF_UNKNOWN ; lv_obj_set_signal_cb ( new_imgbtn , lv_imgbtn_signal ) ; lv_obj_set_design_cb ( new_imgbtn , lv_imgbtn_design ) ; if ( copy == NULL ) { } else { lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr ( copy ) ; #if LV_IMGBTN_TILED == 0 memcpy ( ( void * ) ext -> img_src , copy_ext -> img_src , sizeof ( ext -> img_src ) ) ; #else memcpy ( ( void * ) ext -> img_src_left , copy_ext -> img_src_left , sizeof ( ext -> img_src_left ) ) ; memcpy ( ( void * ) ext -> img_src_mid , copy_ext -> img_src_mid , sizeof ( ext -> img_src_mid ) ) ; memcpy ( ( void * ) ext -> img_src_right , copy_ext -> img_src_right , sizeof ( ext -> img_src_right ) ) ; #endif lv_obj_refresh_style ( new_imgbtn ) ; } LV_LOG_INFO ( " " ) ; return new_imgbtn ; }
Create a image button object
 @param par pointer to an object, it will be the parent of the new image button
 @param copy pointer to a image button object, if not NULL then the new object will be copied from
 it
 @return pointer to the created image button
Create a image button object @param par pointer to an object it will be the parent of the new image button @param copy pointer to a image button object if not NULL then the new object will be copied from it @return pointer to the created image button
/*Create the ancestor of image button*/ /*Allocate the image button type specific extended data*/ /*Initialize the allocated 'ext' */ /*The signal and design functions are not copied so set them here*/ /*Init the new image button image button*/ /*Copy an existing image button*/ /*Refresh the style with new signal function*/