tizentizen-wearable-sdktizen-native-appefl

Can I change the image file of an existing Evas_Object?


I am developing a watch face with Tizen Native using the EFL libraries. After creating many objects with:

Evas_Object *view_create_parts(Evas_Object *parent, const char *image_path,
    int position_x, int position_y, int size_w, int size_h) {
    Evas_Object *parts = NULL;

    parts = elm_image_add(parent);

    elm_image_file_set(parts, image_path, NULL);

    evas_object_move(parts, position_x, position_y);
    evas_object_resize(parts, size_w, size_h);

    evas_object_show(parts);

    return parts;
}

I would like to change the image of some of the existing objects later on as needed. Is this possible? I know that I could also load all possible variants as individual objects and show/hide the objects accordingly. But I find it way simpler and elegant to just change the image of an existing object. Plus, this probably uses less resources too.

I tried to do this:

elm_image_file_set(<part_I_want_to_change_its_image>, "images/newimage.png", NULL));

But instead of changing to the correct image, the object just disappears. Any ideas?


Solution

  • I finally found out what I was doing wrong. I was not aware of how the image path has to be formed. Nonworking method:

    elm_image_file_set(s_info.hand_hour, "images/new_image.png", NULL);
    

    Working method:

    char image_path[PATH_MAX] = { 0, };
    data_get_resource_path("images/new_image.png", image_path, sizeof(image_path));
    elm_image_file_set(s_info.hand_hour, image_path, NULL);