summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac7
-rw-r--r--m4/efl_examples.m463
-rw-r--r--src/Makefile.am2
-rw-r--r--src/examples/Makefile.am31
-rw-r--r--src/examples/actionslider_example_01.c139
-rw-r--r--src/lib/Elementary.h.in102
6 files changed, 343 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index d77a258fc..bbf7cea59 100644
--- a/configure.ac
+++ b/configure.ac
@@ -518,6 +518,7 @@ src/modules/Makefile
518src/modules/test_entry/Makefile 518src/modules/test_entry/Makefile
519src/modules/test_map/Makefile 519src/modules/test_map/Makefile
520src/edje_externals/Makefile 520src/edje_externals/Makefile
521src/examples/Makefile
521data/Makefile 522data/Makefile
522data/themes/Makefile 523data/themes/Makefile
523data/images/Makefile 524data/images/Makefile
@@ -531,6 +532,10 @@ config/illume/Makefile
531$po_makefile_in 532$po_makefile_in
532]) 533])
533 534
535### Build and install examples
536EFL_CHECK_BUILD_EXAMPLES([enable_build_examples="yes"], [enable_build_examples="no"])
537EFL_CHECK_INSTALL_EXAMPLES([enable_install_examples="yes"], [enable_install_examples="no"])
538
534##################################################################### 539#####################################################################
535## Info 540## Info
536 541
@@ -562,6 +567,8 @@ echo " eet......................: ${eet_eet}"
562echo " edje_cc..................: ${edje_cc}" 567echo " edje_cc..................: ${edje_cc}"
563echo 568echo
564echo " Build elementary_test....: ${have_elementary_test}" 569echo " Build elementary_test....: ${have_elementary_test}"
570echo " Examples.............: ${enable_build_examples}"
571echo " Examples installed...: ${enable_install_examples}"
565echo " Build elementary_config..: ${have_elementary_config}" 572echo " Build elementary_config..: ${have_elementary_config}"
566echo 573echo
567echo "Compilation................: make (or gmake)" 574echo "Compilation................: make (or gmake)"
diff --git a/m4/efl_examples.m4 b/m4/efl_examples.m4
new file mode 100644
index 000000000..2a809adff
--- /dev/null
+++ b/m4/efl_examples.m4
@@ -0,0 +1,63 @@
1dnl Copyright (C) 2008 Vincent Torri <vtorri at univ-evry dot fr>
2dnl That code is public domain and can be freely used or copied.
3
4dnl Macro that check if building examples is wanted.
5
6dnl Usage: EFL_CHECK_BUILD_EXAMPLES([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
7dnl Defines the automake conditionnal EFL_ENABLE_BUILD_EXAMPLES
8
9AC_DEFUN([EFL_CHECK_BUILD_EXAMPLES],
10[
11
12dnl configure option
13
14AC_ARG_ENABLE([build-examples],
15 [AC_HELP_STRING([--enable-build-examples], [enable building examples @<:@default=disabled@:>@])],
16 [
17 if test "x${enableval}" = "xyes" ; then
18 _efl_enable_build_examples="yes"
19 else
20 _efl_enable_build_examples="no"
21 fi
22 ],
23 [_efl_enable_build_examples="no"])
24
25AC_MSG_CHECKING([whether examples are built])
26AC_MSG_RESULT([${_efl_enable_build_examples}])
27
28AM_CONDITIONAL(EFL_BUILD_EXAMPLES, test "x${_efl_enable_build_examples}" = "xyes")
29
30AS_IF([test "x$_efl_enable_build_examples" = "xyes"], [$1], [$2])
31])
32
33
34dnl Macro that check if installing examples is wanted.
35
36dnl Usage: EFL_CHECK_INSTALL_EXAMPLES([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
37dnl Defines the automake conditionnal EFL_ENABLE_INSTALL_EXAMPLES
38
39AC_DEFUN([EFL_CHECK_INSTALL_EXAMPLES],
40[
41
42dnl configure option
43
44AC_ARG_ENABLE([install-examples],
45 [AC_HELP_STRING([--enable-install-examples], [enable installing example source files @<:@default=disabled@:>@])],
46 [
47 if test "x${enableval}" = "xyes" ; then
48 _efl_enable_install_examples="yes"
49 else
50 _efl_enable_install_examples="no"
51 fi
52 ],
53 [_efl_enable_install_examples="no"])
54
55AC_MSG_CHECKING([whether examples are installed])
56AC_MSG_RESULT([${_efl_enable_install_examples}])
57
58AM_CONDITIONAL(EFL_INSTALL_EXAMPLES, test "x${_efl_enable_install_examples}" = "xyes")
59
60AS_IF([test "x$_efl_enable_install_examples" = "xyes"], [$1], [$2])
61])
62
63dnl End of efl_examples.m4
diff --git a/src/Makefile.am b/src/Makefile.am
index be7ccd90f..8c0d71693 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
1AUTOMAKE_OPTIONS = 1.4 foreign 1AUTOMAKE_OPTIONS = 1.4 foreign
2MAINTAINERCLEANFILES = Makefile.in 2MAINTAINERCLEANFILES = Makefile.in
3 3
4SUBDIRS = lib bin modules edje_externals 4SUBDIRS = lib bin modules edje_externals examples
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am
new file mode 100644
index 000000000..a0bf8fbf0
--- /dev/null
+++ b/src/examples/Makefile.am
@@ -0,0 +1,31 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3pkglibdir = $(datadir)/$(PACKAGE)/examples
4
5AM_CPPFLAGS = \
6-I. \
7-I$(top_srcdir)/src/lib \
8-I$(top_builddir)/src/lib \
9@ELEMENTARY_EDBUS_CFLAGS@ \
10@ELEMENTARY_EFREET_CFLAGS@ \
11@ELEMENTARY_ETHUMB_CFLAGS@ \
12@ELEMENTARY_CFLAGS@
13
14LDADD = \
15 $(top_builddir)/src/lib/libelementary.la
16
17SRCS = \
18 actionslider_example_01.c
19
20pkglib_PROGRAMS =
21
22if EFL_INSTALL_EXAMPLES
23filesdir = $(datadir)/$(PACKAGE)/examples
24files_DATA = $(SRCS)
25endif
26
27if EFL_BUILD_EXAMPLES
28pkglib_PROGRAMS += \
29 actionslider_example_01
30endif
31
diff --git a/src/examples/actionslider_example_01.c b/src/examples/actionslider_example_01.c
new file mode 100644
index 000000000..5b5f4a764
--- /dev/null
+++ b/src/examples/actionslider_example_01.c
@@ -0,0 +1,139 @@
1//Compile with:
2//gcc -g `pkg-config --cflags --libs elementary` actionslider_example_01.c -o actionslider_example_01
3
4#include <Elementary.h>
5
6static void _pos_selected_cb(void *data, Evas_Object *obj, void *event_info)
7{
8 printf("Selection: %s\n", (char *)event_info);
9 printf("Label selected: %s\n", elm_actionslider_selected_label_get(obj));
10}
11
12static void
13_position_change_magnetic_cb(void *data, Evas_Object * obj, void *event_info)
14{
15 if (!strcmp((char *)event_info, "left"))
16 elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_LEFT);
17 else if (!strcmp((char *)event_info, "right"))
18 elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_RIGHT);
19}
20
21static void
22_magnet_enable_disable_cb(void *data, Evas_Object *obj, void *event_info)
23{
24 if (!strcmp((char *)event_info, "left"))
25 elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_CENTER);
26 else if (!strcmp((char *)event_info, "right"))
27 elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_NONE);
28}
29
30static void
31on_done(void *data, Evas_Object *obj, void *event_info)
32{
33 elm_exit();
34}
35
36EAPI int
37elm_main(int argc, char **argv)
38{
39 Evas_Object *win, *bg, *bx, *as;
40
41 win = elm_win_add(NULL, "actionslider", ELM_WIN_BASIC);
42 elm_win_title_set(win, "Actionslider");
43 evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
44
45 bg = elm_bg_add(win);
46 elm_win_resize_object_add(win, bg);
47 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, 0);
48 evas_object_show(bg);
49
50 bx = elm_box_add(win);
51 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0);
52 elm_win_resize_object_add(win, bx);
53 evas_object_show(bx);
54
55 as = elm_actionslider_add(win);
56 evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
57 evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
58 elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
59 elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
60 elm_actionslider_labels_set(as, "Snooze", NULL, "Stop");
61 elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT |
62 ELM_ACTIONSLIDER_RIGHT);
63 evas_object_smart_callback_add(as, "pos_changed",
64 _position_change_magnetic_cb, NULL);
65 evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
66 evas_object_show(as);
67 elm_box_pack_end(bx, as);
68
69 as = elm_actionslider_add(win);
70 evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
71 evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
72 elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_CENTER);
73 elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER);
74 elm_actionslider_labels_set(as, "Snooze", NULL, "Stop");
75 elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT |
76 ELM_ACTIONSLIDER_RIGHT);
77 evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
78 evas_object_show(as);
79 elm_box_pack_end(bx, as);
80
81 as = elm_actionslider_add(win);
82 elm_object_style_set(as, "bar");
83 evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
84 evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
85 elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT);
86 elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER|
87 ELM_ACTIONSLIDER_RIGHT);
88 elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_CENTER |
89 ELM_ACTIONSLIDER_RIGHT);
90 elm_actionslider_labels_set(as, NULL, "Accept", "Reject");
91 evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
92 evas_object_show(as);
93 elm_box_pack_end(bx, as);
94
95 as = elm_actionslider_add(win);
96 elm_object_style_set(as, "bar");
97 evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
98 evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
99 elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT);
100 elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_LEFT);
101 elm_actionslider_labels_set(as, NULL, "Accept", "Reject");
102 elm_actionslider_indicator_label_set(as, "Go");
103 evas_object_smart_callback_add(as, "pos_changed",
104 _position_change_magnetic_cb, NULL);
105 evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
106 evas_object_show(as);
107 elm_box_pack_end(bx, as);
108
109
110 as = elm_actionslider_add(win);
111 evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
112 evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
113 elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT);
114 elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_ALL);
115 elm_actionslider_labels_set(as, "Left", "Center", "Right");
116 elm_actionslider_indicator_label_set(as, "Go");
117 evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
118 evas_object_show(as);
119 elm_box_pack_end(bx, as);
120
121 as = elm_actionslider_add(win);
122 evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
123 evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
124 elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_CENTER);
125 elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER);
126 elm_actionslider_labels_set(as, "Enable", "Magnet", "Disable");
127 evas_object_smart_callback_add(as, "pos_changed",
128 _magnet_enable_disable_cb, NULL);
129 evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
130 evas_object_show(as);
131 elm_box_pack_end(bx, as);
132
133 evas_object_resize(win, 320, 400);
134 evas_object_show(win);
135
136 elm_run();
137 return 0;
138}
139ELM_MAIN()
diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in
index e45bae41c..5d2b5e705 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/Elementary.h.in
@@ -1859,6 +1859,107 @@ extern "C" {
1859 */ 1859 */
1860 1860
1861 /** 1861 /**
1862 * @page actionslider_example_page Actionslider usage
1863 * @dontinclude actionslider_example_01.c
1864 *
1865 * For this example we are going to assume knowledge of evas smart callbacks
1866 * and some basic evas object functions. Elementary is not meant to be used
1867 * without evas, if you're not yet familiar with evas it probably is worth
1868 * checking that out.
1869 *
1870 * And now to the example, when using Elementary we start by including
1871 * Elementary.h:
1872 * @skipline #include
1873 *
1874 * Next we define some callbacks, they all share the same signature because
1875 * they are all to be used with evas_object_smart_callback_add().
1876 * The first one just prints the selected label(in two different ways):
1877 * @until }
1878 *
1879 * This next callback is a little more interesting, it makes the selected
1880 * label magnetic(except if it's the center label):
1881 * @until }
1882 *
1883 * This callback enables or disables the magnetic propertty of the center
1884 * label:
1885 * @until }
1886 *
1887 * And finally a callback to stop the main loop when the window is closed:
1888 * @until }
1889 *
1890 * To be able to create our actionsliders we need to do some setup, but this
1891 * isn't really relevant here, so if you want to know about that go @ref
1892 * Win "here".
1893 *
1894 * With all that boring stuff out of the way we can proceed to creating some
1895 * actionsliders.@n
1896 * All actionsliders are created the same way:
1897 * @skipline actionslider_add
1898 * Next we must choose where the indicator starts, and for this one we choose
1899 * the right, and set the right as magnetic:
1900 * @skipline indicator_pos_set
1901 * @until magnet_pos_set
1902 *
1903 * We then set the labels for the left and right, passing NULL as an argument
1904 * to any of the labels makes that position have no label.
1905 * @until Stop
1906 *
1907 * Furthermore we mark both left and right as enabled positions, if we didn't
1908 * do this all three positions would be enabled:
1909 * @until RIGHT
1910 *
1911 * Having the the enabled positions we now add a smart callback to change
1912 * which position is magnetic, so that only the last selected position is
1913 * magnetic:
1914 * @until NULL
1915 *
1916 * And finally we set our printing callback and show the actionslider:
1917 * @until object_show
1918 * @skip pack_end
1919 *
1920 * For our next actionslider we are going to do much as we did for the
1921 * previous except we are going to have the center as the magnet(and not
1922 * change it):
1923 * @skipline actionslider_add
1924 * @skipline indicator_pos_set
1925 * @until object_show
1926 *
1927 * And another actionslider, in this one the indicator starts on the left.
1928 * It has labels only in the center and right, and both bositions are
1929 * magnetic. Because the left doesn't have a label and is not magnetic once
1930 * the indicator leaves it can't return:
1931 * @skipline actionslider_add
1932 * @skipline indicator_pos_set
1933 * @until object_show
1934 * @note The greyed out area is a @ref Styles "style".
1935 *
1936 * And now an actionslider with a label in the indicator, and whose magnet
1937 * properties change based on what was last selected:
1938 * @skipline actionslider_add
1939 * @skipline indicator_pos_set
1940 * @until object_show
1941 * @note The greyed out area is a @ref Styles "style".
1942 *
1943 * We are almost done, this next one is just a actionslider with all
1944 * positions magnetized and having every possible label:
1945 * @skipline actionslider_add
1946 * @skipline indicator_pos_set
1947 * @until object_show
1948 *
1949 * And for our last actionslider we have one that turns the magnetic property
1950 * on and off:
1951 * @skipline actionslider_add
1952 * @skipline indicator_pos_set
1953 * @until object_show
1954 *
1955 * See the full source code @ref actionslider_example_01 "here"
1956 */
1957 /**
1958 * @page actionslider_example_01 Actionslider example
1959 * @include actionslider_example_01.c
1960 * @example actionslider_example_01.c
1961 */
1962 /**
1862 * @addtogroup Actionslider Actionslider 1963 * @addtogroup Actionslider Actionslider
1863 * 1964 *
1864 * A actionslider is a switcher for 2 or 3 labels with customizable magnet 1965 * A actionslider is a switcher for 2 or 3 labels with customizable magnet
@@ -1876,6 +1977,7 @@ extern "C" {
1876 * "pos_changed" - when the indicator reaches any of the positions("left", 1977 * "pos_changed" - when the indicator reaches any of the positions("left",
1877 * "right" or "center"). 1978 * "right" or "center").
1878 * 1979 *
1980 * See an example of actionslider usage @ref actionslider_example_page "here"
1879 * @{ 1981 * @{
1880 */ 1982 */
1881 typedef enum _Elm_Actionslider_Pos 1983 typedef enum _Elm_Actionslider_Pos