summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2014-12-16 18:46:34 -0200
committerLarry Jr <larry.olj@gmail.com>2015-03-19 15:34:51 -0300
commitb588e13b8946fbfefac2d92a8c881b50278e1ceb (patch)
tree7949378d49372704553b6e848a5a21b9bace7719
parent209cd09036d4e84ba71a61282c25eb1aba51c25b (diff)
cxx: Updated box_cxx_example_02.cc to use autohide instead of autodel
-rw-r--r--src/examples/box_cxx_example_02.cc227
1 files changed, 98 insertions, 129 deletions
diff --git a/src/examples/box_cxx_example_02.cc b/src/examples/box_cxx_example_02.cc
index 28950f4d6..ecfb9eb05 100644
--- a/src/examples/box_cxx_example_02.cc
+++ b/src/examples/box_cxx_example_02.cc
@@ -76,142 +76,111 @@ _test_box_transition_change(void *data)
76 } 76 }
77} 77}
78 78
79struct clean_ref
80{
81 clean_ref(efl::eo::base base)
82 : _ref(base._eo_ptr())
83 {}
84
85 template <typename T>
86 void operator()(T const&, Eo_Event_Description const&, void*) const
87 {
88 if(_ref)
89 eo_unref(_ref);
90 }
91
92 Eo* _ref;
93};
94
95EAPI_MAIN int 79EAPI_MAIN int
96elm_main(int argc, char *argv[]) 80elm_main(int argc, char *argv[])
97{ 81{
98 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 82 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
99 83
100 Transitions_Data tdata; 84 Transitions_Data tdata;
101 Eo* test; 85
102 86 ::elm_win win (elm_win_util_standard_add("box-transition", "Box Transition"));
103 { 87 win.autohide_set(true);
104 ::elm_win win (elm_win_util_standard_add("box-transition", "Box Transition")); 88
105 win.autodel_set(true); 89 elm_box bigbox ( efl::eo::parent = win );
106 90 bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
107 elm_box bigbox ( efl::eo::parent = win ); 91 win.resize_object_add(bigbox);
108 bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 92 bigbox.visibility_set(true);
109 win.resize_object_add(bigbox); 93
110 bigbox.visibility_set(true); 94 elm_box buttons ( efl::eo::parent = win );
111 win.callback_del_add(clean_ref(bigbox)); 95 buttons.horizontal_set(EINA_TRUE);
112 96 bigbox.pack_end(buttons);
113 elm_box buttons ( efl::eo::parent = win ); 97 buttons.visibility_set(true);
114 buttons.horizontal_set(EINA_TRUE); 98
115 bigbox.pack_end(buttons); 99 elm_button add ( efl::eo::parent = win );
116 buttons.visibility_set(true); 100 add.text_set("elm.text", "Add");
117 win.callback_del_add(clean_ref(buttons)); 101 buttons.pack_end(add);
118 102 add.visibility_set(true);
119 elm_button add ( efl::eo::parent = win ); 103 add.callback_clicked_add
120 add.text_set("elm.text", "Add"); 104 (std::bind([&tdata]
121 buttons.pack_end(add); 105 {
122 add.visibility_set(true); 106 if(efl::eina::optional<elm_box> box = tdata.box.lock())
123 add.callback_clicked_add
124 (std::bind([&tdata]
125 { 107 {
126 if(efl::eina::optional<elm_box> box = tdata.box.lock()) 108 elm_button btn ( efl::eo::parent = *box );
127 { 109 btn.text_set("elm.text", "I do nothing");
128 elm_button btn ( efl::eo::parent = *box ); 110 efl::eina::list<evas::object> childrens(box->children_get());
129 btn.text_set("elm.text", "I do nothing"); 111 if (!childrens.empty())
130 efl::eina::list<evas::object> childrens(box->children_get()); 112 {
131 if (!childrens.empty()) 113 box->pack_after(btn, childrens.front());
132 { 114 }
133 box->pack_after(btn, childrens.front()); 115 else
134 } 116 box->pack_end(btn);
135 else 117 btn.visibility_set(true);
136 box->pack_end(btn); 118 }
137 btn.visibility_set(true); 119 }));
138 } 120
139 })); 121 elm_button clear ( efl::eo::parent = win );
140 win.callback_del_add(clean_ref(add)); 122 clear.text_set("elm.text", "Clear");
141 123 buttons.pack_end(clear);
142 elm_button clear ( efl::eo::parent = win ); 124 clear.visibility_set(true);
143 clear.text_set("elm.text", "Clear"); 125 clear.callback_clicked_add(std::bind([&tdata] { tdata.box.lock()->clear(); }));
144 buttons.pack_end(clear); 126
145 clear.visibility_set(true); 127 elm_box dynamic ( efl::eo::parent = win );
146 clear.callback_clicked_add(std::bind([&tdata] { tdata.box.lock()->clear(); })); 128 dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
147 win.callback_del_add(clean_ref(clear)); 129 dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
148 130 bigbox.pack_end(dynamic);
149 elm_box dynamic ( efl::eo::parent = win ); 131 dynamic.visibility_set(true);
150 dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 132
151 dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); 133 auto unpack = std::bind([&tdata] (evas::clickable_interface obj)
152 bigbox.pack_end(dynamic); 134 {
153 dynamic.visibility_set(true); 135 elm_button btn = efl::eo::downcast<elm_button>(obj);
154 win.callback_del_add(clean_ref(dynamic)); 136 tdata.box.lock()->unpack(btn);
155 137 btn.position_set(0, 50);
156 auto unpack = std::bind([&tdata] (evas::clickable_interface obj) 138 btn.color_set(128, 64, 0, 128);
157 { 139 }, std::placeholders::_1)
158 elm_button btn = efl::eo::downcast<elm_button>(obj); 140 ;
159 tdata.box.lock()->unpack(btn); 141
160 btn.position_set(0, 50); 142 elm_button bt1 ( efl::eo::parent = win );
161 btn.color_set(128, 64, 0, 128); 143 bt1.text_set("elm.text", "Button 1");
162 }, std::placeholders::_1) 144 bt1.callback_clicked_add(unpack);
163 ; 145 bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
164 146 bt1.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
165 elm_button bt1 ( efl::eo::parent = win ); 147 dynamic.pack_end(bt1);
166 bt1.text_set("elm.text", "Button 1"); 148 bt1.visibility_set(true);
167 bt1.callback_clicked_add(unpack); 149
168 bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 150 elm_button bt2 ( efl::eo::parent = win );
169 bt1.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); 151 bt2.text_set("elm.text", "Button 2");
170 dynamic.pack_end(bt1); 152 bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0);
171 bt1.visibility_set(true); 153 bt2.size_hint_align_set(1.0, 0.5);
172 win.callback_del_add(clean_ref(bt1)); 154 bt2.callback_clicked_add(unpack);
173 155 dynamic.pack_end(bt2);
174 elm_button bt2 ( efl::eo::parent = win ); 156 bt2.visibility_set(true);
175 bt2.text_set("elm.text", "Button 2"); 157
176 bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0); 158 elm_button bt3 ( efl::eo::parent = win );
177 bt2.size_hint_align_set(1.0, 0.5); 159 bt3.text_set("elm.text", "Button 3");
178 bt2.callback_clicked_add(unpack); 160 bt3.callback_clicked_add(unpack);
179 dynamic.pack_end(bt2); 161 dynamic.pack_end(bt3);
180 bt2.visibility_set(true); 162 bt3.visibility_set(true);
181 win.callback_del_add(clean_ref(bt2)); 163
182 164 tdata.box = dynamic;
183 elm_button bt3 ( efl::eo::parent = win ); 165 tdata.last_layout = evas_object_box_layout_horizontal;
184 bt3.text_set("elm.text", "Button 3"); 166 tdata.transitions.push_back(evas_object_box_layout_vertical);
185 bt3.callback_clicked_add(unpack); 167 tdata.transitions.push_back(evas_object_box_layout_horizontal);
186 dynamic.pack_end(bt3); 168 tdata.transitions.push_back(evas_object_box_layout_stack);
187 bt3.visibility_set(true); 169 tdata.transitions.push_back(evas_object_box_layout_homogeneous_vertical);
188 win.callback_del_add(clean_ref(bt3)); 170 tdata.transitions.push_back(evas_object_box_layout_homogeneous_horizontal);
189 171 tdata.transitions.push_back(evas_object_box_layout_flow_vertical);
190 tdata.box = dynamic; 172 tdata.transitions.push_back(evas_object_box_layout_flow_horizontal);
191 tdata.last_layout = evas_object_box_layout_horizontal; 173 tdata.transitions.push_back(evas_object_box_layout_stack);
192 tdata.transitions.push_back(evas_object_box_layout_vertical); 174
193 tdata.transitions.push_back(evas_object_box_layout_horizontal); 175 dynamic.layout_set(evas_object_box_layout_horizontal, nullptr, nullptr);
194 tdata.transitions.push_back(evas_object_box_layout_stack); 176 _test_box_transition_change(&tdata);
195 tdata.transitions.push_back(evas_object_box_layout_homogeneous_vertical); 177
196 tdata.transitions.push_back(evas_object_box_layout_homogeneous_horizontal); 178 win.size_set(300, 320);
197 tdata.transitions.push_back(evas_object_box_layout_flow_vertical); 179 win.visibility_set(true);
198 tdata.transitions.push_back(evas_object_box_layout_flow_horizontal); 180
199 tdata.transitions.push_back(evas_object_box_layout_stack); 181 std::cout << "references to win " << win.ref_get() << std::endl;
200 182
201 dynamic.layout_set(evas_object_box_layout_horizontal, nullptr, nullptr);
202 _test_box_transition_change(&tdata);
203
204 win.size_set(300, 320);
205 win.visibility_set(true);
206
207 std::cout << "references to win " << win.ref_get() << std::endl;
208 test = win._eo_ptr();
209 win._release();
210 }
211 std::cout << "references to win " << ::eo_ref_get(test) << std::endl;
212
213 elm_run(); 183 elm_run();
214 elm_shutdown();
215 184
216 return 0; 185 return 0;
217} 186}