elementary/icon - Add an explained example.

SVN revision: 61482
This commit is contained in:
Rafael Antognolli 2011-07-18 18:08:39 +00:00
parent af5fe8ef30
commit 9d42d9f16b
5 changed files with 3252 additions and 0 deletions

View File

@ -2124,6 +2124,72 @@
* @example image_example_01.c
*/
/**
* @page tutorial_icon Icon example
* @dontinclude icon_example_01.c
*
* This example is as simple as possible. An icon object will be added to the
* window over a white background, and set to be resizeable 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 and its background:
*
* @skip int
* @until show(bg)
*
* Now we create the icon object, and set lookup order of the icon, and choose
* the "home" icon:
*
* @until home
*
* An intersting 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:
*
* @until printf
*
* We can now go setting our options.
*
* elm_icon_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_icon_scale_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_elm_icon_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_icon_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:
*
* @until fill_outside
*
* 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:
*
* @until ELM_MAIN
*
* This example will look like this:
*
* @image html screenshots/icon_example_01.png
* @image latex screenshots/icon_example_01.eps
*
* @example icon_example_01.c
*/
/**
* @page tutorial_hoversel Hoversel example
* @dontinclude hoversel_example_01.c

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -60,6 +60,7 @@ SRCS = \
conformant_example_01.c \
conformant_example_02.c \
image_example_01.c \
icon_example_01.c \
flipselector_example.c \
fileselector_example.c \
fileselector_button_example.c \
@ -120,6 +121,7 @@ pkglib_PROGRAMS += \
image_example_01 \
diskselector_example_01 \
diskselector_example_02 \
icon_example_01 \
flipselector_example \
fileselector_example \
fileselector_button_example \
@ -156,6 +158,7 @@ SCREENSHOTS = \
image_example_01:image_example_01.png:0.0 \
diskselector_example_01:diskselector_example_01.png:0.2 \
diskselector_example_02:diskselector_example_02.png:0.2 \
icon_example_01:icon_example_01.png:0.0 \
flipselector_example:flipselector_example.png:0.0 \
fileselector_example:fileselector_example.png:0.0

View File

@ -0,0 +1,59 @@
//Compile with:
//gcc -g `pkg-config --cflags --libs elementary` image_example_01.c -o image_example_01
#include <Elementary.h>
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#else
# define __UNUSED__
# define PACKAGE_DATA_DIR "."
#endif
int
elm_main(int argc __UNUSED__, char **argv __UNUSED__)
{
Evas_Object *win, *bg, *icon;
const char *path, *group, *name;
win = elm_win_add(NULL, "icon", ELM_WIN_BASIC);
elm_win_title_set(win, "Icon");
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
elm_win_autodel_set(win, 1);
bg = elm_bg_add(win);
elm_bg_color_set(bg, 255,255 ,255);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
icon = elm_icon_add(win);
elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_THEME_FDO);
elm_icon_standard_set(icon, "home");
path = NULL;
group = NULL;
name = NULL;
elm_icon_file_get(icon, &path, &group);
name = elm_icon_standard_get(icon);
printf("path = %s, group = %s, name = %s\n", path, group, name);
elm_icon_no_scale_set(icon, EINA_TRUE);
elm_icon_scale_set(icon, EINA_FALSE, EINA_TRUE);
elm_icon_smooth_set(icon, EINA_FALSE);
elm_icon_fill_outside_set(icon, EINA_TRUE);
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_size_hint_min_set(bg, 160, 160);
evas_object_size_hint_max_set(bg, 640, 640);
evas_object_resize(win, 320, 320);
evas_object_show(win);
elm_run();
return 0;
}
ELM_MAIN()