diff options
author | Vitor Sousa <vitorsousasilva@gmail.com> | 2014-12-16 18:46:34 -0200 |
---|---|---|
committer | Larry Jr <larry.olj@gmail.com> | 2015-03-19 15:34:51 -0300 |
commit | b588e13b8946fbfefac2d92a8c881b50278e1ceb (patch) | |
tree | 7949378d49372704553b6e848a5a21b9bace7719 | |
parent | 209cd09036d4e84ba71a61282c25eb1aba51c25b (diff) | |
download | elementary-b588e13b8946fbfefac2d92a8c881b50278e1ceb.tar.gz |
cxx: Updated box_cxx_example_02.cc to use autohide instead of autodel
-rw-r--r-- | src/examples/box_cxx_example_02.cc | 227 |
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) } } -struct clean_ref -{ - clean_ref(efl::eo::base base) - : _ref(base._eo_ptr()) - {} - - template <typename T> - void operator()(T const&, Eo_Event_Description const&, void*) const - { - if(_ref) - eo_unref(_ref); - } - - Eo* _ref; -}; - EAPI_MAIN int elm_main(int argc, char *argv[]) { - elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); + elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN); Transitions_Data tdata; - Eo* test; - - { - ::elm_win win (elm_win_util_standard_add("box-transition", "Box Transition")); - win.autodel_set(true); - - elm_box bigbox ( efl::eo::parent = win ); - bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - win.resize_object_add(bigbox); - bigbox.visibility_set(true); - win.callback_del_add(clean_ref(bigbox)); - - elm_box buttons ( efl::eo::parent = win ); - buttons.horizontal_set(EINA_TRUE); - bigbox.pack_end(buttons); - buttons.visibility_set(true); - win.callback_del_add(clean_ref(buttons)); - - elm_button add ( efl::eo::parent = win ); - add.text_set("elm.text", "Add"); - buttons.pack_end(add); - add.visibility_set(true); - add.callback_clicked_add - (std::bind([&tdata] + + ::elm_win win (elm_win_util_standard_add("box-transition", "Box Transition")); + win.autohide_set(true); + + elm_box bigbox ( efl::eo::parent = win ); + bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + win.resize_object_add(bigbox); + bigbox.visibility_set(true); + + elm_box buttons ( efl::eo::parent = win ); + buttons.horizontal_set(EINA_TRUE); + bigbox.pack_end(buttons); + buttons.visibility_set(true); + + elm_button add ( efl::eo::parent = win ); + add.text_set("elm.text", "Add"); + buttons.pack_end(add); + add.visibility_set(true); + add.callback_clicked_add + (std::bind([&tdata] + { + if(efl::eina::optional<elm_box> box = tdata.box.lock()) { - if(efl::eina::optional<elm_box> box = tdata.box.lock()) - { - elm_button btn ( efl::eo::parent = *box ); - btn.text_set("elm.text", "I do nothing"); - efl::eina::list<evas::object> childrens(box->children_get()); - if (!childrens.empty()) - { - box->pack_after(btn, childrens.front()); - } - else - box->pack_end(btn); - btn.visibility_set(true); - } - })); - win.callback_del_add(clean_ref(add)); - - elm_button clear ( efl::eo::parent = win ); - clear.text_set("elm.text", "Clear"); - buttons.pack_end(clear); - clear.visibility_set(true); - clear.callback_clicked_add(std::bind([&tdata] { tdata.box.lock()->clear(); })); - win.callback_del_add(clean_ref(clear)); - - elm_box dynamic ( efl::eo::parent = win ); - dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); - bigbox.pack_end(dynamic); - dynamic.visibility_set(true); - win.callback_del_add(clean_ref(dynamic)); - - auto unpack = std::bind([&tdata] (evas::clickable_interface obj) - { - elm_button btn = efl::eo::downcast<elm_button>(obj); - tdata.box.lock()->unpack(btn); - btn.position_set(0, 50); - btn.color_set(128, 64, 0, 128); - }, std::placeholders::_1) - ; - - elm_button bt1 ( efl::eo::parent = win ); - bt1.text_set("elm.text", "Button 1"); - bt1.callback_clicked_add(unpack); - bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - bt1.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); - dynamic.pack_end(bt1); - bt1.visibility_set(true); - win.callback_del_add(clean_ref(bt1)); - - elm_button bt2 ( efl::eo::parent = win ); - bt2.text_set("elm.text", "Button 2"); - bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0); - bt2.size_hint_align_set(1.0, 0.5); - bt2.callback_clicked_add(unpack); - dynamic.pack_end(bt2); - bt2.visibility_set(true); - win.callback_del_add(clean_ref(bt2)); - - elm_button bt3 ( efl::eo::parent = win ); - bt3.text_set("elm.text", "Button 3"); - bt3.callback_clicked_add(unpack); - dynamic.pack_end(bt3); - bt3.visibility_set(true); - win.callback_del_add(clean_ref(bt3)); - - tdata.box = dynamic; - tdata.last_layout = evas_object_box_layout_horizontal; - tdata.transitions.push_back(evas_object_box_layout_vertical); - tdata.transitions.push_back(evas_object_box_layout_horizontal); - tdata.transitions.push_back(evas_object_box_layout_stack); - tdata.transitions.push_back(evas_object_box_layout_homogeneous_vertical); - tdata.transitions.push_back(evas_object_box_layout_homogeneous_horizontal); - tdata.transitions.push_back(evas_object_box_layout_flow_vertical); - tdata.transitions.push_back(evas_object_box_layout_flow_horizontal); - tdata.transitions.push_back(evas_object_box_layout_stack); - - dynamic.layout_set(evas_object_box_layout_horizontal, nullptr, nullptr); - _test_box_transition_change(&tdata); - - win.size_set(300, 320); - win.visibility_set(true); - - std::cout << "references to win " << win.ref_get() << std::endl; - test = win._eo_ptr(); - win._release(); - } - std::cout << "references to win " << ::eo_ref_get(test) << std::endl; - + elm_button btn ( efl::eo::parent = *box ); + btn.text_set("elm.text", "I do nothing"); + efl::eina::list<evas::object> childrens(box->children_get()); + if (!childrens.empty()) + { + box->pack_after(btn, childrens.front()); + } + else + box->pack_end(btn); + btn.visibility_set(true); + } + })); + + elm_button clear ( efl::eo::parent = win ); + clear.text_set("elm.text", "Clear"); + buttons.pack_end(clear); + clear.visibility_set(true); + clear.callback_clicked_add(std::bind([&tdata] { tdata.box.lock()->clear(); })); + + elm_box dynamic ( efl::eo::parent = win ); + dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); + bigbox.pack_end(dynamic); + dynamic.visibility_set(true); + + auto unpack = std::bind([&tdata] (evas::clickable_interface obj) + { + elm_button btn = efl::eo::downcast<elm_button>(obj); + tdata.box.lock()->unpack(btn); + btn.position_set(0, 50); + btn.color_set(128, 64, 0, 128); + }, std::placeholders::_1) + ; + + elm_button bt1 ( efl::eo::parent = win ); + bt1.text_set("elm.text", "Button 1"); + bt1.callback_clicked_add(unpack); + bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + bt1.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL); + dynamic.pack_end(bt1); + bt1.visibility_set(true); + + elm_button bt2 ( efl::eo::parent = win ); + bt2.text_set("elm.text", "Button 2"); + bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0); + bt2.size_hint_align_set(1.0, 0.5); + bt2.callback_clicked_add(unpack); + dynamic.pack_end(bt2); + bt2.visibility_set(true); + + elm_button bt3 ( efl::eo::parent = win ); + bt3.text_set("elm.text", "Button 3"); + bt3.callback_clicked_add(unpack); + dynamic.pack_end(bt3); + bt3.visibility_set(true); + + tdata.box = dynamic; + tdata.last_layout = evas_object_box_layout_horizontal; + tdata.transitions.push_back(evas_object_box_layout_vertical); + tdata.transitions.push_back(evas_object_box_layout_horizontal); + tdata.transitions.push_back(evas_object_box_layout_stack); + tdata.transitions.push_back(evas_object_box_layout_homogeneous_vertical); + tdata.transitions.push_back(evas_object_box_layout_homogeneous_horizontal); + tdata.transitions.push_back(evas_object_box_layout_flow_vertical); + tdata.transitions.push_back(evas_object_box_layout_flow_horizontal); + tdata.transitions.push_back(evas_object_box_layout_stack); + + dynamic.layout_set(evas_object_box_layout_horizontal, nullptr, nullptr); + _test_box_transition_change(&tdata); + + win.size_set(300, 320); + win.visibility_set(true); + + std::cout << "references to win " << win.ref_get() << std::endl; + elm_run(); - elm_shutdown(); return 0; } |