summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <juyung.seo@samsung.com>2013-05-10 13:19:19 +0900
committerDaniel Juyung Seo <juyung.seo@samsung.com>2013-05-10 13:19:19 +0900
commit6e65e3cb3acbb7a754ce1d2b0b48bb865f57b6d9 (patch)
treea6e95251c40033e1bf2b1fc3c2fc647fe383d1f8
parent0013fa5c06447d581c26d16d151c053918e8c588 (diff)
sample: added sample code written by Hermet.
-rw-r--r--sample/Makefile46
-rw-r--r--sample/data/edc/layout.edc146
-rw-r--r--sample/data/images/0.jpgbin0 -> 14177 bytes
-rw-r--r--sample/data/images/1.jpgbin0 -> 67424 bytes
-rw-r--r--sample/data/images/10.jpgbin0 -> 464980 bytes
-rw-r--r--sample/data/images/11.jpgbin0 -> 53748 bytes
-rw-r--r--sample/data/images/12.jpgbin0 -> 360282 bytes
-rw-r--r--sample/data/images/13.jpgbin0 -> 213600 bytes
-rw-r--r--sample/data/images/14.jpgbin0 -> 76123 bytes
-rw-r--r--sample/data/images/15.jpgbin0 -> 76072 bytes
-rw-r--r--sample/data/images/16.jpgbin0 -> 21337 bytes
-rw-r--r--sample/data/images/17.jpgbin0 -> 964427 bytes
-rw-r--r--sample/data/images/2.jpgbin0 -> 323378 bytes
-rw-r--r--sample/data/images/3.jpgbin0 -> 52815 bytes
-rw-r--r--sample/data/images/4.jpgbin0 -> 152631 bytes
-rw-r--r--sample/data/images/5.jpgbin0 -> 215426 bytes
-rw-r--r--sample/data/images/6.jpgbin0 -> 47551 bytes
-rw-r--r--sample/data/images/7.jpgbin0 -> 107635 bytes
-rw-r--r--sample/data/images/8.jpgbin0 -> 339192 bytes
-rw-r--r--sample/data/images/9.jpgbin0 -> 13522 bytes
-rw-r--r--sample/data/images/bg.jpgbin0 -> 60117 bytes
-rw-r--r--sample/data/images/icon_01.pngbin0 -> 11371 bytes
-rw-r--r--sample/data/images/icon_02.pngbin0 -> 12432 bytes
-rw-r--r--sample/data/images/icon_03.pngbin0 -> 15014 bytes
-rw-r--r--sample/data/images/icon_04.pngbin0 -> 7912 bytes
-rw-r--r--sample/data/images/icon_05.pngbin0 -> 1483 bytes
-rw-r--r--sample/data/images/icon_left_arrow.pngbin0 -> 1716 bytes
-rw-r--r--sample/data/images/icon_right_arrow.pngbin0 -> 1832 bytes
-rw-r--r--sample/src/main.c173
29 files changed, 365 insertions, 0 deletions
diff --git a/sample/Makefile b/sample/Makefile
new file mode 100644
index 0000000..9a07332
--- /dev/null
+++ b/sample/Makefile
@@ -0,0 +1,46 @@
1SRCDIR=src
2EDJDIR=data/edc
3OBJECTS=$(SRCDIR)/main.o
4EDJS=$(EDJDIR)/layout.edj
5BINARY=sample
6DIRNAME=sample
7
8PREFIX=/usr/local
9BINDIR=$(PREFIX)/bin
10DATADIR=$(PREFIX)/share/sample
11
12CC = gcc
13
14CFLAGS = `pkg-config --cflags elementary evas`
15CFLAGS += -g -W -Wextra #-Wall
16LDFLAGS = `pkg-config --libs elementary evas`
17
18EDJE_CC = edje_cc
19EDJE_FLAGS = -id data/images
20
21all: $(OBJECTS) $(BINARY) $(EDJS)
22
23%.o : %.c
24 @echo " Compilation of $(@D)/$(<F)"
25 @$(CC) -c $(CFLAGS) $< -o $@
26
27$(BINARY): $(OBJECTS)
28 @echo " Linking $(@F)"
29 @$(CC) -o $(BINARY) $(OBJECTS) $(LDFLAGS)
30
31$(EDJDIR)/layout.edj: $(EDJDIR)/layout.edc
32 @echo " Compilation of $(@D)/$(<F)"
33 @$(EDJE_CC) $(EDJE_FLAGS) $(EDJDIR)/layout.edc $(EDJDIR)/layout.edj
34
35install: $(BINARY) $(EDJDIR)/layout.edj
36 @echo "installation of executables"
37 @mkdir -p $(BINDIR)
38 @install -m 0755 $(BINARY) $(BINDIR)
39 @echo "installation of data"
40 @mkdir -p $(DATADIR)/edj
41 @install $(EDJDIR)/layout.edj $(DATADIR)/edj
42 @mkdir -p $(DATADIR)/images
43 @install data/images/* $(DATADIR)/images
44
45clean:
46 @rm -f *.o *.edj *~ $(BINARY)
diff --git a/sample/data/edc/layout.edc b/sample/data/edc/layout.edc
new file mode 100644
index 0000000..a110c2a
--- /dev/null
+++ b/sample/data/edc/layout.edc
@@ -0,0 +1,146 @@
1collections {
2 images {
3 image: "bg.jpg" COMP;
4 image: "icon_left_arrow.png" COMP;
5 image: "icon_right_arrow.png" COMP;
6 image: "icon_01.png" COMP;
7 image: "icon_02.png" COMP;
8 image: "icon_03.png" COMP;
9 image: "icon_04.png" COMP;
10 image: "icon_05.png" COMP;
11 }
12 group { name:"main";
13 parts {
14 part { name: "bg";
15 type: IMAGE;
16 description { state: "default" 0.0;
17 image.normal: "bg.jpg";
18 }
19 }
20 part { name: "elm.swallow.top";
21 type: SWALLOW;
22 description { state: "default" 0.0;
23 rel1.relative: 0.35 0.0;
24 rel2.relative: 0.65 0.15;
25 }
26 }
27 part { name: "elm.text.news";
28 type: TEXT;
29 scale: 1;
30 description { state: "default" 0.0;
31 rel1.relative: 0.05 0.1;
32 rel2.relative: 0.15 0.2;
33 align: 0 0;
34 color: 200 200 200 255;
35 text { font: "Sans:style=Bold";
36 size: 12;
37 min: 0 0;
38 max: 1 0;
39 align: 0.5 0.5;
40 ellipsis: 0.0;
41 text: "News";
42 }
43 }
44 }
45 part { name: "elm.swallow.middle";
46 type: SWALLOW;
47 description { state: "default" 0.0;
48 rel1.relative: 0.06 0.17;
49 rel2.relative: 0.94 0.85;
50 }
51 }
52 part { name: "elm.swallow.bottom";
53 type: SWALLOW;
54 description { state: "default" 0.0;
55 rel1.relative: 0.1 0.87;
56 rel2.relative: 0.9 1.0;
57 }
58 }
59 part { name: "elm.swallow.left_arrow";
60 type: SWALLOW;
61 scale: 1;
62 description { state: "default" 0.0;
63 rel1.relative: 0.0 0.5;
64 rel2.relative: 0.0 0.5;
65 min: 40 50;
66 fixed: 1 1;
67 align: 0.0 0.5;
68 }
69 }
70 part { name: "elm.swallow.right_arrow";
71 type: SWALLOW;
72 scale: 1;
73 description { state: "default" 0.0;
74 rel1.relative: 1.0 0.5;
75 rel2.relative: 1.0 0.5;
76 min: 40 50;
77 fixed: 1 1;
78 align: 1.0 0.5;
79 }
80 }
81 }
82 }
83 group { name:"left_arrow";
84 parts {
85 part { name: "base";
86 description {
87 image.normal: "icon_left_arrow.png";
88 }
89 }
90 }
91 }
92 group { name:"right_arrow";
93 parts {
94 part { name: "base";
95 description {
96 image.normal: "icon_right_arrow.png";
97 }
98 }
99 }
100 }
101 group { name:"icon0";
102 parts {
103 part { name: "base";
104 description {
105 image.normal: "icon_01.png";
106 }
107 }
108 }
109 }
110 group { name:"icon1";
111 parts {
112 part { name: "base";
113 description {
114 image.normal: "icon_02.png";
115 }
116 }
117 }
118 }
119 group { name:"icon2";
120 parts {
121 part { name: "base";
122 description {
123 image.normal: "icon_03.png";
124 }
125 }
126 }
127 }
128 group { name:"icon3";
129 parts {
130 part { name: "base";
131 description {
132 image.normal: "icon_04.png";
133 }
134 }
135 }
136 }
137 group { name:"icon4";
138 parts {
139 part { name: "base";
140 description {
141 image.normal: "icon_05.png";
142 }
143 }
144 }
145 }
146}
diff --git a/sample/data/images/0.jpg b/sample/data/images/0.jpg
new file mode 100644
index 0000000..492c207
--- /dev/null
+++ b/sample/data/images/0.jpg
Binary files differ
diff --git a/sample/data/images/1.jpg b/sample/data/images/1.jpg
new file mode 100644
index 0000000..9e91e1e
--- /dev/null
+++ b/sample/data/images/1.jpg
Binary files differ
diff --git a/sample/data/images/10.jpg b/sample/data/images/10.jpg
new file mode 100644
index 0000000..b6d4ea3
--- /dev/null
+++ b/sample/data/images/10.jpg
Binary files differ
diff --git a/sample/data/images/11.jpg b/sample/data/images/11.jpg
new file mode 100644
index 0000000..54ebab1
--- /dev/null
+++ b/sample/data/images/11.jpg
Binary files differ
diff --git a/sample/data/images/12.jpg b/sample/data/images/12.jpg
new file mode 100644
index 0000000..e253987
--- /dev/null
+++ b/sample/data/images/12.jpg
Binary files differ
diff --git a/sample/data/images/13.jpg b/sample/data/images/13.jpg
new file mode 100644
index 0000000..197da30
--- /dev/null
+++ b/sample/data/images/13.jpg
Binary files differ
diff --git a/sample/data/images/14.jpg b/sample/data/images/14.jpg
new file mode 100644
index 0000000..a556002
--- /dev/null
+++ b/sample/data/images/14.jpg
Binary files differ
diff --git a/sample/data/images/15.jpg b/sample/data/images/15.jpg
new file mode 100644
index 0000000..c70d897
--- /dev/null
+++ b/sample/data/images/15.jpg
Binary files differ
diff --git a/sample/data/images/16.jpg b/sample/data/images/16.jpg
new file mode 100644
index 0000000..7b19daf
--- /dev/null
+++ b/sample/data/images/16.jpg
Binary files differ
diff --git a/sample/data/images/17.jpg b/sample/data/images/17.jpg
new file mode 100644
index 0000000..3e1e7b8
--- /dev/null
+++ b/sample/data/images/17.jpg
Binary files differ
diff --git a/sample/data/images/2.jpg b/sample/data/images/2.jpg
new file mode 100644
index 0000000..de9c600
--- /dev/null
+++ b/sample/data/images/2.jpg
Binary files differ
diff --git a/sample/data/images/3.jpg b/sample/data/images/3.jpg
new file mode 100644
index 0000000..32cbdd9
--- /dev/null
+++ b/sample/data/images/3.jpg
Binary files differ
diff --git a/sample/data/images/4.jpg b/sample/data/images/4.jpg
new file mode 100644
index 0000000..018cfe0
--- /dev/null
+++ b/sample/data/images/4.jpg
Binary files differ
diff --git a/sample/data/images/5.jpg b/sample/data/images/5.jpg
new file mode 100644
index 0000000..a7852d0
--- /dev/null
+++ b/sample/data/images/5.jpg
Binary files differ
diff --git a/sample/data/images/6.jpg b/sample/data/images/6.jpg
new file mode 100644
index 0000000..b00242d
--- /dev/null
+++ b/sample/data/images/6.jpg
Binary files differ
diff --git a/sample/data/images/7.jpg b/sample/data/images/7.jpg
new file mode 100644
index 0000000..473bd04
--- /dev/null
+++ b/sample/data/images/7.jpg
Binary files differ
diff --git a/sample/data/images/8.jpg b/sample/data/images/8.jpg
new file mode 100644
index 0000000..bfd21be
--- /dev/null
+++ b/sample/data/images/8.jpg
Binary files differ
diff --git a/sample/data/images/9.jpg b/sample/data/images/9.jpg
new file mode 100644
index 0000000..8727f3a
--- /dev/null
+++ b/sample/data/images/9.jpg
Binary files differ
diff --git a/sample/data/images/bg.jpg b/sample/data/images/bg.jpg
new file mode 100644
index 0000000..96b022b
--- /dev/null
+++ b/sample/data/images/bg.jpg
Binary files differ
diff --git a/sample/data/images/icon_01.png b/sample/data/images/icon_01.png
new file mode 100644
index 0000000..faf524c
--- /dev/null
+++ b/sample/data/images/icon_01.png
Binary files differ
diff --git a/sample/data/images/icon_02.png b/sample/data/images/icon_02.png
new file mode 100644
index 0000000..592cb5a
--- /dev/null
+++ b/sample/data/images/icon_02.png
Binary files differ
diff --git a/sample/data/images/icon_03.png b/sample/data/images/icon_03.png
new file mode 100644
index 0000000..3d3063b
--- /dev/null
+++ b/sample/data/images/icon_03.png
Binary files differ
diff --git a/sample/data/images/icon_04.png b/sample/data/images/icon_04.png
new file mode 100644
index 0000000..454bd62
--- /dev/null
+++ b/sample/data/images/icon_04.png
Binary files differ
diff --git a/sample/data/images/icon_05.png b/sample/data/images/icon_05.png
new file mode 100644
index 0000000..bb81792
--- /dev/null
+++ b/sample/data/images/icon_05.png
Binary files differ
diff --git a/sample/data/images/icon_left_arrow.png b/sample/data/images/icon_left_arrow.png
new file mode 100644
index 0000000..0ec3008
--- /dev/null
+++ b/sample/data/images/icon_left_arrow.png
Binary files differ
diff --git a/sample/data/images/icon_right_arrow.png b/sample/data/images/icon_right_arrow.png
new file mode 100644
index 0000000..6bbb2c6
--- /dev/null
+++ b/sample/data/images/icon_right_arrow.png
Binary files differ
diff --git a/sample/src/main.c b/sample/src/main.c
new file mode 100644
index 0000000..50fe864
--- /dev/null
+++ b/sample/src/main.c
@@ -0,0 +1,173 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *
7create_button(Evas_Object *parent)
8{
9 Evas_Object *btn;
10 btn = elm_button_add(parent);
11 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
12 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
13 evas_object_show(btn);
14
15 return btn;
16}
17
18Evas_Object *
19create_image(Evas_Object *parent, char *path, char *group)
20{
21 Evas_Object *img;
22 img = elm_image_add(parent);
23 elm_image_file_set(img, path, group);
24 evas_object_show(img);
25
26 return img;
27}
28
29void
30btn_clicked(void *data, Evas_Object *obj, void *event_info)
31{
32 evas_object_raise(obj);
33
34 Elm_Transit *transit = elm_transit_add();
35 elm_transit_object_add(transit, obj);
36 elm_transit_duration_set(transit, 0.25);
37 elm_transit_auto_reverse_set(transit, EINA_TRUE);
38 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
39 elm_transit_smooth_set(transit, EINA_FALSE);
40 elm_transit_go(transit);
41}
42
43void
44toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
45{
46 Elm_Object_Item *it = event_info;
47 printf("%s\n", elm_object_item_text_get(it));
48}
49
50void
51init()
52{
53 Evas_Object *win, *layout, *table, *toolbar, *btn, *img, *label;
54 char buf[PATH_MAX], buf2[256];
55 int i, j;
56 Evas_Coord padding_size;
57
58 //Create a Window
59 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
60 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
61 elm_win_autodel_set(win, EINA_TRUE);
62 evas_object_show(win);
63
64 //Create a Layout
65 layout = elm_layout_add(win);
66 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", PACKAGE_DATA_DIR);
67 elm_layout_file_set(layout, buf, "main");
68 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
69 elm_win_resize_object_add(win, layout);
70 evas_object_show(layout);
71
72 //Create Top Contents
73 table = elm_table_add(layout);
74
75 for (i = 0; i < 5; i++)
76 {
77 btn = create_button(table);
78
79 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", PACKAGE_DATA_DIR);
80 snprintf(buf2, sizeof(buf2), "icon%d", i);
81 img = create_image(btn, buf, buf2);
82 elm_object_content_set(btn, img);
83
84 elm_table_pack(table, btn, i, 0, 1, 1);
85
86 label = elm_label_add(table);
87 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
88 elm_object_text_set(label, buf2);
89 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
90 evas_object_size_hint_align_set(label, 0.5, 0.5);
91 evas_object_show(label);
92
93 elm_table_pack(table, label, i, 1, 1, 1);
94 }
95
96 elm_object_part_content_set(layout, "elm.swallow.top", table);
97 evas_object_show(table);
98
99 //Create Middle Contents
100 table = elm_table_add(layout);
101 padding_size = 7 * elm_config_scale_get();
102 elm_table_padding_set(table, padding_size, padding_size);
103
104 for (i = 0; i < 3; i++)
105 {
106 for (j = 0; j < 6; j++)
107 {
108 btn = create_button(table);
109 evas_object_smart_callback_add(btn, "clicked", btn_clicked, NULL);
110 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", PACKAGE_DATA_DIR, ((i * 6) + j));
111 img = create_image(btn, buf, NULL);
112 elm_object_content_set(btn, img);
113 elm_table_pack(table, btn, j, i, 1, 1);
114 }
115 }
116
117 elm_object_part_content_set(layout, "elm.swallow.middle", table);
118 evas_object_show(table);
119
120 //Create a Left arrow
121 btn = create_button(table);
122 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", PACKAGE_DATA_DIR);
123 img = create_image(btn, buf, "left_arrow");
124 elm_object_content_set(btn, img);
125 elm_object_part_content_set(layout, "elm.swallow.left_arrow", btn);
126 evas_object_show(btn);
127
128 //Create a Right arrow
129 btn = create_button(table);
130 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", PACKAGE_DATA_DIR);
131 img = create_image(btn, buf, "right_arrow");
132 elm_object_content_set(btn, img);
133 elm_object_part_content_set(layout, "elm.swallow.right_arrow", btn);
134 evas_object_show(btn);
135
136 //Create Bottom Contents
137 toolbar = elm_toolbar_add(layout);
138 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
139 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
140 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE);
141 evas_object_size_hint_weight_set(toolbar, EVAS_HINT_EXPAND, 0);
142 evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, 0);
143
144 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, NULL);
145 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, NULL);
146 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, NULL);
147 elm_toolbar_item_append(toolbar, NULL, "Downloads", toolbar_it_cb, NULL);
148 elm_toolbar_item_append(toolbar, NULL, "Favorites", toolbar_it_cb, NULL);
149 elm_toolbar_item_append(toolbar, NULL, "YouTube", toolbar_it_cb, NULL);
150
151 elm_object_part_content_set(layout, "elm.swallow.bottom", toolbar);
152 evas_object_show(toolbar);
153}
154
155EAPI_MAIN int
156elm_main(int argc, char **argv)
157{
158 //Set App Directory
159 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
160 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
161 elm_app_info_set(elm_main, "sample", "images/kakaotalk_icon_s.png");
162
163 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
164
165 init();
166
167 elm_run();
168
169 elm_shutdown();
170
171 return 0;
172}
173ELM_MAIN()