Question
I have an EDC file with both text and image parts. For text parts, I can easily modify the content at runtime using elm_object_part_text_set(watchface_layout, "txt_title", "Change text").
However, I need to perform similar modifications for image parts - specifically to rotate images or change their opacity. The image part is defined in the EDC file as follows:
part {
name: "image_example";
type: IMAGE;
scale: 1.0;
description {
state: "default" 0.0;
visible: 1;
max: 360 360;
image.normal: "example.png";
align: 0.5 0.5;
rel1.relative: 0.00 0.00;
rel2.relative: 1.00 1.00;
map {
on: 1;
rotation {
x: 0.0;
y: 0.0;
z: 0.0;
}
}
}
}
How can I get a handle to this image defined in the EDC file to modify its properties during runtime? I've only found methods to manipulate images created during runtime, not those defined in EDC files.
Answer
Problem Understanding
The user wants to manipulate image parts defined in EDC files at runtime, similar to how text parts can be modified using elm_object_part_text_set(). Specifically, they need to rotate images and change their opacity.
Solution Methods
-
Using Elementary Image API:
- You can access and manipulate image parts using the Elementary Image API functions.
- First, get the image object using
elm_object_part_content_get(). - Then apply transformations using appropriate API functions.
-
Rotation Example:
Evas_Object *img = elm_object_part_content_get(watchface_layout, "image_example"); if (img) { elm_image_orient_set(img, ELM_IMAGE_ROTATE_90); } -
Opacity Example:
Evas_Object *img = elm_object_part_content_get(watchface_layout, "image_example"); if (img) { evas_object_color_set(img, 255, 255, 255, 128); // 50% opacity }
Code Examples
Complete example for rotating an image:
Evas_Object *img = elm_object_part_content_get(watchface_layout, "image_example");
if (img) {
// Rotate 90 degrees clockwise
elm_image_orient_set(img, ELM_IMAGE_ROTATE_90);
// Set 50% opacity
evas_object_color_set(img, 255, 255, 255, 128);
}
Additional Tips
- Remember to check if the image object is valid before applying transformations.
- For more advanced image manipulation, consider using Evas Object functions.
- The Elementary Image API provides additional functions for scaling, flipping, and other transformations.