summaryrefslogtreecommitdiff
path: root/src/examples/elementary/efl_ui_list_view_example_1.c
diff options
context:
space:
mode:
authorSangHyeon Jade Lee <sh10233.lee@samsung.com>2018-11-05 14:27:05 +0900
committerHermet Park <hermetpark@gmail.com>2018-11-05 14:27:05 +0900
commite97b6b72bebfc91f44c4ab98f3ff1b7920344c07 (patch)
tree9e1d059c319b9208114b05df5356961d81ff06a0 /src/examples/elementary/efl_ui_list_view_example_1.c
parentc4e0d3f69d8203ad3ff4f3fdeb0a0adfaffdd1cd (diff)
efl_ui : change efl_ui_view_list to efl_ui_list_view.
Summary: View is not a namespace, but an interface, So, View_List cannot be under the view namespace for now. it looks more suite to be end as View than List on this widget name. Firstly, it follows our common naming rules of class. Also, List_View is commonly presentable name on most UI frameworks, so it is very easy to understand what this widget can do for the user. Test Plan: Make works. Example is not works for now til stable model interface. Reviewers: felipealmeida, woohyun, cedric, Hermet Reviewed By: Hermet Subscribers: larryolj, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7234
Diffstat (limited to 'src/examples/elementary/efl_ui_list_view_example_1.c')
-rw-r--r--src/examples/elementary/efl_ui_list_view_example_1.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/examples/elementary/efl_ui_list_view_example_1.c b/src/examples/elementary/efl_ui_list_view_example_1.c
new file mode 100644
index 0000000000..e0dc27f11c
--- /dev/null
+++ b/src/examples/elementary/efl_ui_list_view_example_1.c
@@ -0,0 +1,111 @@
1// gcc -o efl_ui_list_view_example_1 efl_ui_list_view_example_1.c `pkg-config --cflags --libs elementary`
2
3#ifdef HAVE_CONFIG_H
4# include "elementary_config.h"
5#else
6# define EFL_BETA_API_SUPPORT 1
7# define EFL_EO_API_SUPPORT 1
8#endif
9
10#include <Elementary.h>
11#include <Efl.h>
12#include <Eio.h>
13#include <stdio.h>
14
15#define NUM_ITEMS 400
16
17const char *styles[] = {
18 "odd",
19 "even"
20 };
21
22char edj_path[PATH_MAX];
23
24static void
25_realized_cb(void *data, const Efl_Event *event)
26{
27 Efl_Ui_List_View_Item_Event *ie = event->info;
28 if (!ie->layout) return;
29
30 Efl_Ui_Layout_Object *layout = ie->layout;
31 elm_object_focus_allow_set(layout, EINA_TRUE);
32}
33
34/*
35static void
36_unrealized_cb(void *data EINA_UNUSED, const Efl_Event *event)
37{
38 Efl_Ui_List_View_Item_Event *ie = event->info;
39
40 efl_ui_view_model_set(ie->layout, NULL);
41 efl_del(ie->layout);
42}
43*/
44static Efl_Model*
45_make_model(Evas_Object *win)
46{
47 Eina_Value vtext;
48 Efl_Model_Item *model, *child;
49 unsigned int i, s;
50 char buf[256];
51
52 model = efl_add(EFL_MODEL_ITEM_CLASS, win);
53 eina_value_setup(&vtext, EINA_VALUE_TYPE_STRING);
54
55 for (i = 0; i < (NUM_ITEMS); i++)
56 {
57 s = i%2;
58 child = efl_model_child_add(model);
59 eina_value_set(&vtext, styles[s]);
60 efl_model_property_set(child, "odd_style", &vtext);
61
62 snprintf(buf, sizeof(buf), "Item # %i", i);
63 eina_value_set(&vtext, buf);
64 efl_model_property_set(child, "name", &vtext);
65 }
66
67 eina_value_flush(&vtext);
68 return model;
69}
70
71EAPI_MAIN int
72elm_main(int argc, char **argv)
73{
74 Efl_Ui_Layout_Factory *factory;
75 Evas_Object *win, *li;
76 Eo *model;
77
78 win = elm_win_util_standard_add("list_view", "List_View");
79 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
80
81 elm_win_autodel_set(win, EINA_TRUE);
82
83 model = _make_model(win);
84
85 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
86 efl_ui_model_connect(factory, "signal/elm,state,%v", "odd_style");
87 efl_ui_model_connect(factory, "efl.text", "name");
88 efl_ui_layout_factory_theme_config(factory, "list_item", NULL, "default");
89
90 li = efl_add(EFL_UI_LIST_VIEW_CLASS, win);
91 efl_ui_list_view_layout_factory_set(li, factory);
92 efl_ui_view_model_set(li, model);
93
94 efl_event_callback_add(li, EFL_UI_LIST_VIEW_EVENT_ITEM_REALIZED, _realized_cb, NULL);
95// efl_event_callback_add(li, EFL_UI_LIST_VIEW_EVENT_ITEM_UNREALIZED, _unrealized_cb, NULL);
96
97 elm_win_resize_object_add(win, li);
98 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
99 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
100
101 //showall
102 evas_object_show(li);
103 evas_object_resize(win, 320, 320);
104 evas_object_show(win);
105
106 elm_run();
107 efl_unref(model);
108
109 return 0;
110}
111ELM_MAIN()