summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-03 17:13:03 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-10 10:08:09 +0200
commit9ef36176d3ffe9e5cc9ec80484736573be5d0c6b (patch)
tree2f3e0138581a33e0c9719e0603a687479f34eab1
parent1080d43145b52d483bf8cbf8221a542fbf938041 (diff)
support grids in the example
-rw-r--r--src/examples/elementary/efl_ui_collection_view_example_1.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/examples/elementary/efl_ui_collection_view_example_1.c b/src/examples/elementary/efl_ui_collection_view_example_1.c
index 5e856c3fef..ba564188bf 100644
--- a/src/examples/elementary/efl_ui_collection_view_example_1.c
+++ b/src/examples/elementary/efl_ui_collection_view_example_1.c
@@ -45,7 +45,6 @@ static Efl_Model*
45_make_model(Evas_Object *win) 45_make_model(Evas_Object *win)
46{ 46{
47 Eina_Value vtext; 47 Eina_Value vtext;
48 Eina_Value w, h;
49 Efl_Generic_Model *model, *child; 48 Efl_Generic_Model *model, *child;
50 unsigned int i, s; 49 unsigned int i, s;
51 char buf[256]; 50 char buf[256];
@@ -53,11 +52,6 @@ _make_model(Evas_Object *win)
53 model = efl_add(EFL_GENERIC_MODEL_CLASS, win); 52 model = efl_add(EFL_GENERIC_MODEL_CLASS, win);
54 eina_value_setup(&vtext, EINA_VALUE_TYPE_STRING); 53 eina_value_setup(&vtext, EINA_VALUE_TYPE_STRING);
55 54
56 w = eina_value_int_init(91);
57 h = eina_value_int_init(18);
58 efl_model_property_set(model, "item.width", &w);
59 efl_model_property_set(model, "item.height", &h);
60
61 for (i = 0; i < (NUM_ITEMS); i++) 55 for (i = 0; i < (NUM_ITEMS); i++)
62 { 56 {
63 s = i%2; 57 s = i%2;
@@ -80,6 +74,9 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
80 Evas_Object *win, *li; 74 Evas_Object *win, *li;
81 Eo *model; 75 Eo *model;
82 Efl_Select_Model *selmodel; 76 Efl_Select_Model *selmodel;
77 Eina_Value w, h;
78 Eo *position_manager;
79 const Efl_Class *item_class;
83 80
84 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC)); 81 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC));
85 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 82 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
@@ -87,19 +84,39 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
87 elm_win_autodel_set(win, EINA_TRUE); 84 elm_win_autodel_set(win, EINA_TRUE);
88 85
89 model = _make_model(win); 86 model = _make_model(win);
87
88 if (argc > 1 && eina_streq(argv[1], "grid"))
89 {
90 w = eina_value_int_init(50);
91 h = eina_value_int_init(50);
92 position_manager = efl_new(EFL_UI_POSITION_MANAGER_GRID_CLASS);
93 item_class = EFL_UI_GRID_DEFAULT_ITEM_CLASS;
94 }
95 else
96 {
97 w = eina_value_int_init(91);
98 h = eina_value_int_init(18);
99 position_manager = efl_new(EFL_UI_POSITION_MANAGER_LIST_CLASS);
100 item_class = EFL_UI_LIST_DEFAULT_ITEM_CLASS;
101 }
102
103
104 efl_model_property_set(model, "item.width", &w);
105 efl_model_property_set(model, "item.height", &h);
106
90 selmodel = efl_add(EFL_SELECT_MODEL_CLASS, efl_main_loop_get() 107 selmodel = efl_add(EFL_SELECT_MODEL_CLASS, efl_main_loop_get()
91 , efl_ui_view_model_set(efl_added, model) 108 , efl_ui_view_model_set(efl_added, model)
92 ); 109 );
93 110
94 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win); 111 factory = efl_add(EFL_UI_LAYOUT_FACTORY_CLASS, win);
95 efl_ui_widget_factory_item_class_set(factory, EFL_UI_LIST_DEFAULT_ITEM_CLASS); 112 efl_ui_widget_factory_item_class_set(factory, item_class);
96 efl_ui_property_bind(factory, "signal/efl,state,%v", "odd_style"); 113 efl_ui_property_bind(factory, "signal/efl,state,%v", "odd_style");
97 efl_ui_property_bind(factory, "signal/efl,state,%{selected;unselected}", "selected"); 114 efl_ui_property_bind(factory, "signal/efl,state,%{selected;unselected}", "selected");
98 efl_ui_property_bind(factory, "text", "title"); 115 efl_ui_property_bind(factory, "text", "title");
99 116
100 Eo *lst = efl_new(EFL_UI_POSITION_MANAGER_LIST_CLASS); 117
101 li = efl_add(EFL_UI_COLLECTION_VIEW_CLASS, win, 118 li = efl_add(EFL_UI_COLLECTION_VIEW_CLASS, win,
102 efl_ui_collection_view_position_manager_set(efl_added, lst), 119 efl_ui_collection_view_position_manager_set(efl_added, position_manager),
103 efl_ui_view_model_set(efl_added, selmodel), 120 efl_ui_view_model_set(efl_added, selmodel),
104 efl_ui_collection_view_factory_set(efl_added, factory)); 121 efl_ui_collection_view_factory_set(efl_added, factory));
105 122