Tizen Native API  8.0
Icon example

This example is as simple as possible. An icon object will be added to the window over a white background, and set to be resizable together with the window. All the options set through the example will affect the behavior of this icon.

We start with the code for creating a window:

EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
   Evas_Object *win, *icon;
   const char *path, *group, *name;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add("icon", "Icon");
   elm_win_autodel_set(win, EINA_TRUE);

Now we create the icon object, and set lookup order of the icon, and choose the "home" icon:

   icon = elm_icon_add(win);
   elm_icon_standard_set(icon, "home");

An interesting thing is that after setting this, it's possible to check where in the filesystem is the theme used by this icon, and the name of the group used:

   path = NULL;
   group = NULL;
   name = NULL;
   elm_image_file_get(icon, &path, &group);
   name = elm_icon_standard_get(icon);
   printf("path = %s, group = %s, name = %s\n", path, group, name);

We can now go setting our options.

elm_image_no_scale_set() is used just to set this value to true (we don't want to scale our icon anyway, just resize it).

elm_image_resizable_set() is used to allow the icon to be resized to a size smaller than the original one, but not to a size bigger than it.

elm_image_smooth_set() will disable the smooth scaling, so the scale algorithm used to scale the icon to the new object size is going to be faster, but with a lower quality.

elm_image_fill_outside_set() is used to ensure that the icon will fill the entire area available to it, even if keeping the aspect ratio. The icon will overflow its width or height (any of them that is necessary) to the object area, instead of resizing the icon down until it can fit entirely in this area.

This is the code for setting these options:

However, if you try this example you may notice that this image is not being affected by all of these options. This happens because the used icon will be from elementary theme, and thus it has its own set of options like smooth scaling and fill_outside options. You can change the "home" icon to use some image (from your system) and see that then those options will be respected.

Now some last touches in our object size hints, window and background, to display this icon properly:

   evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(win, icon);
   evas_object_show(icon);

   evas_object_resize(win, 320, 320);
   evas_object_show(win);

   elm_run();

   return 0;
}
ELM_MAIN()