summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2014-07-21 13:35:11 -0300
committerSavio Sena <savio@expertisesolutions.com.br>2014-07-21 20:53:12 -0300
commit089029a68fec6d989e138a8a76da34007caf3153 (patch)
tree503ddaffe2fbf82e4d6158ae66d1dbfc345751b8
parent24b191a738e750b97ebc468d24ef68093db1858e (diff)
cxx: refreshed example
-rw-r--r--src/examples/box_cxx_example_02.cc132
-rw-r--r--src/lib/elm_box.eo2
2 files changed, 78 insertions, 56 deletions
diff --git a/src/examples/box_cxx_example_02.cc b/src/examples/box_cxx_example_02.cc
index b1f7bc951..10fcb0cc0 100644
--- a/src/examples/box_cxx_example_02.cc
+++ b/src/examples/box_cxx_example_02.cc
@@ -16,6 +16,8 @@
16#define ELM_INTERFACE_ATSPI_IMAGE_PROTECTED 16#define ELM_INTERFACE_ATSPI_IMAGE_PROTECTED
17#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED 17#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
18 18
19#include <iostream>
20
19#include <Elementary.h> 21#include <Elementary.h>
20 22
21#include <Eo.h> 23#include <Eo.h>
@@ -32,39 +34,45 @@
32 34
33#include <deque> 35#include <deque>
34 36
35// static void 37struct Transitions_Data
36// _test_box_transition_change(void *data) 38{
37// { 39 efl::eo::wref<elm_box> box;
38// Transitions_Data *tdata = static_cast<Transitions_Data*>(data); 40 std::deque<Evas_Object_Box_Layout> transitions;
39// Elm_Box_Transition *layout_data; 41 Evas_Object_Box_Layout last_layout;
40// Evas_Object_Box_Layout next_layout; 42};
41 43
42// assert (!!data); 44static void
43// assert (!tdata->transitions.empty()); 45_test_box_transition_change(void *data)
44 46{
45// if(efl::eina::optional<elm_box> box = tdata->box.lock()) 47 Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
46// { 48 Elm_Box_Transition *layout_data;
47// next_layout = tdata->transitions.front(); 49 Evas_Object_Box_Layout next_layout;
48// layout_data = elm_box_transition_new(2.0, tdata->transitions.back(), 50
49// nullptr, nullptr, next_layout, nullptr, nullptr, 51 assert (!!data);
50// _test_box_transition_change, tdata); 52 assert (!tdata->transitions.empty());
51// box->layout_set(elm_box_layout_transition, layout_data, 53
52// elm_box_transition_free); 54 if(efl::eina::optional<elm_box> box = tdata->box.lock())
53// tdata->last_layout = next_layout; 55 {
56 next_layout = tdata->transitions.front();
57 layout_data = elm_box_transition_new(2.0, tdata->transitions.back(),
58 nullptr, nullptr, next_layout, nullptr, nullptr,
59 _test_box_transition_change, tdata);
60 box->layout_set(elm_box_layout_transition, layout_data,
61 elm_box_transition_free);
62 tdata->last_layout = next_layout;
54 63
55// tdata->transitions.push_back(tdata->transitions[0]); 64 tdata->transitions.push_back(tdata->transitions[0]);
56// tdata->transitions.pop_front(); 65 tdata->transitions.pop_front();
57// } 66 }
58// } 67}
59 68
60EAPI_MAIN int 69EAPI_MAIN int
61elm_main(int argc, char *argv[]) 70elm_main(int argc, char *argv[])
62{ 71{
63 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 72 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
64 73
65 efl::eo::wref<elm_box> weak_box; 74 Transitions_Data tdata;
66 std::deque<Evas_Object_Box_Layout> transitions; 75 Eo* test;
67 Evas_Object_Box_Layout last_layout;
68 76
69 { 77 {
70 ::elm_win win (elm_win_util_standard_add("box-transition", "Box Transition")); 78 ::elm_win win (elm_win_util_standard_add("box-transition", "Box Transition"));
@@ -72,52 +80,52 @@ elm_main(int argc, char *argv[])
72 80
73 elm_box bigbox ( efl::eo::parent = win ); 81 elm_box bigbox ( efl::eo::parent = win );
74 bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 82 bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 win.resize_object_add(bigbox._eo_ptr()); 83 win.resize_object_add(bigbox);
76 bigbox.visibility_set(true); 84 bigbox.visibility_set(true);
77 85
78 elm_box buttons ( efl::eo::parent = win ); 86 elm_box buttons ( efl::eo::parent = win );
79 buttons.horizontal_set(EINA_TRUE); 87 buttons.horizontal_set(EINA_TRUE);
80 bigbox.pack_end(buttons._eo_ptr()); 88 bigbox.pack_end(buttons);
81 buttons.visibility_set(true); 89 buttons.visibility_set(true);
82 90
83 elm_button add ( efl::eo::parent = win ); 91 elm_button add ( efl::eo::parent = win );
84 add.text_set("Add"); 92 add.text_set("Add");
85 buttons.pack_end(add._eo_ptr()); 93 buttons.pack_end(add);
86 add.visibility_set(true); 94 add.visibility_set(true);
87 add.event_clicked_callback_add 95 add.event_clicked_callback_add
88 (std::bind([&weak_box] 96 (std::bind([&tdata]
89 { 97 {
90 if(efl::eina::optional<elm_box> box = weak_box.lock()) 98 if(efl::eina::optional<elm_box> box = tdata.box.lock())
91 { 99 {
92 elm_button btn ( efl::eo::parent = *box ); 100 elm_button btn ( efl::eo::parent = *box );
93 btn.text_set("I do nothing"); 101 btn.text_set("I do nothing");
94 efl::eina::range_list<efl::eo::base> childrens (box->children_get()); 102 efl::eina::list<evas::object> childrens = box->children_get();
95 if (!childrens.empty()) 103 if (!childrens.empty())
96 { 104 {
97 box->pack_after(btn._eo_ptr(), childrens.front()._eo_ptr()); 105 box->pack_after(btn, childrens.front());
98 } 106 }
99 else 107 else
100 box->pack_end(btn._eo_ptr()); 108 box->pack_end(btn);
101 btn.visibility_set(true); 109 btn.visibility_set(true);
102 } 110 }
103 })); 111 }));
104 112
105 elm_button clear ( efl::eo::parent = win ); 113 elm_button clear ( efl::eo::parent = win );
106 clear.text_set("Clear"); 114 clear.text_set("Clear");
107 buttons.pack_end(clear._eo_ptr()); 115 buttons.pack_end(clear);
108 clear.visibility_set(true); 116 clear.visibility_set(true);
109 clear.event_clicked_callback_add(std::bind([&weak_box] { weak_box.lock()->clear(); })); 117 clear.event_clicked_callback_add(std::bind([&tdata] { tdata.box.lock()->clear(); }));
110 118
111 elm_box dynamic ( efl::eo::parent = win ); 119 elm_box dynamic ( efl::eo::parent = win );
112 dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 120 dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
113 dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); 121 dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
114 bigbox.pack_end(dynamic._eo_ptr()); 122 bigbox.pack_end(dynamic);
115 dynamic.visibility_set(true); 123 dynamic.visibility_set(true);
116 124
117 auto unpack = std::bind([&weak_box] (evas::clickable_interface obj) 125 auto unpack = std::bind([&tdata] (evas::clickable_interface obj)
118 { 126 {
119 weak_box.lock()->unpack(obj._eo_ptr());
120 elm_button btn = efl::eo::downcast<elm_button>(obj); 127 elm_button btn = efl::eo::downcast<elm_button>(obj);
128 tdata.box.lock()->unpack(btn);
121 btn.position_set(0, 50); 129 btn.position_set(0, 50);
122 btn.color_set(128, 64, 0, 128); 130 btn.color_set(128, 64, 0, 128);
123 }, std::placeholders::_1) 131 }, std::placeholders::_1)
@@ -128,7 +136,7 @@ elm_main(int argc, char *argv[])
128 bt1.event_clicked_callback_add(unpack); 136 bt1.event_clicked_callback_add(unpack);
129 bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 137 bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
130 bt1.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); 138 bt1.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
131 dynamic.pack_end(bt1._eo_ptr()); 139 dynamic.pack_end(bt1);
132 bt1.visibility_set(true); 140 bt1.visibility_set(true);
133 141
134 elm_button bt2 ( efl::eo::parent = win ); 142 elm_button bt2 ( efl::eo::parent = win );
@@ -136,34 +144,48 @@ elm_main(int argc, char *argv[])
136 bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0); 144 bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0);
137 bt2.size_hint_align_set(1.0, 0.5); 145 bt2.size_hint_align_set(1.0, 0.5);
138 bt2.event_clicked_callback_add(unpack); 146 bt2.event_clicked_callback_add(unpack);
139 dynamic.pack_end(bt2._eo_ptr()); 147 dynamic.pack_end(bt2);
140 bt2.visibility_set(true); 148 bt2.visibility_set(true);
141 149
142 elm_button bt3 ( efl::eo::parent = win ); 150 elm_button bt3 ( efl::eo::parent = win );
143 bt3.text_set("Button 3"); 151 bt3.text_set("Button 3");
144 bt3.event_clicked_callback_add(unpack); 152 bt3.event_clicked_callback_add(unpack);
145 dynamic.pack_end(bt3._eo_ptr()); 153 dynamic.pack_end(bt3);
146 bt3.visibility_set(true); 154 bt3.visibility_set(true);
147 155
148 weak_box = dynamic; 156 tdata.box = dynamic;
149 last_layout = evas_object_box_layout_horizontal; 157 tdata.last_layout = evas_object_box_layout_horizontal;
150 transitions.push_back(evas_object_box_layout_vertical); 158 tdata.transitions.push_back(evas_object_box_layout_vertical);
151 transitions.push_back(evas_object_box_layout_horizontal); 159 tdata.transitions.push_back(evas_object_box_layout_horizontal);
152 transitions.push_back(evas_object_box_layout_stack); 160 tdata.transitions.push_back(evas_object_box_layout_stack);
153 transitions.push_back(evas_object_box_layout_homogeneous_vertical); 161 tdata.transitions.push_back(evas_object_box_layout_homogeneous_vertical);
154 transitions.push_back(evas_object_box_layout_homogeneous_horizontal); 162 tdata.transitions.push_back(evas_object_box_layout_homogeneous_horizontal);
155 transitions.push_back(evas_object_box_layout_flow_vertical); 163 tdata.transitions.push_back(evas_object_box_layout_flow_vertical);
156 transitions.push_back(evas_object_box_layout_flow_horizontal); 164 tdata.transitions.push_back(evas_object_box_layout_flow_horizontal);
157 transitions.push_back(evas_object_box_layout_stack); 165 tdata.transitions.push_back(evas_object_box_layout_stack);
158 166
159 dynamic.layout_set(evas_object_box_layout_horizontal, nullptr, nullptr); 167 dynamic.layout_set(evas_object_box_layout_horizontal, nullptr, nullptr);
160 // _test_box_transition_change(&tdata); 168 _test_box_transition_change(&tdata);
161 169
162 win.size_set(300, 320); 170 win.size_set(300, 320);
163 win.visibility_set(true); 171 win.visibility_set(true);
164 win._release(); 172
173 // bigbox._release();
174 // buttons._release();
175 // add._release();
176 // clear._release();
177 // dynamic._release();
178 // bt1._release();
179 // bt2._release();
180 // bt3._release();
181
182
183 std::cout << "references to win " << win.ref_get() << std::endl;
184 test = win._eo_ptr();
185 //win._release();
165 } 186 }
166 187 std::cout << "references to win " << ::eo_ref_get(test) << std::endl;
188
167 elm_run(); 189 elm_run();
168 elm_shutdown(); 190 elm_shutdown();
169 191
diff --git a/src/lib/elm_box.eo b/src/lib/elm_box.eo
index b0e37a441..2aee46df1 100644
--- a/src/lib/elm_box.eo
+++ b/src/lib/elm_box.eo
@@ -149,7 +149,7 @@ class Elm_Box (Elm_Widget)
149 You must free this list with eina_list_free() once you are done with it. 149 You must free this list with eina_list_free() once you are done with it.
150 150
151 @ingroup Box */ 151 @ingroup Box */
152 return Eina_List *; 152 return own(Eina_List *)<Evas_Object *>;
153 } 153 }
154 } 154 }
155 } 155 }