forked from enlightenment/efl
Removed C-style code from C++ example
This commit is contained in:
parent
aea51868e3
commit
b546141396
|
@ -28,45 +28,48 @@
|
||||||
#include <elm_box.eo.hh>
|
#include <elm_box.eo.hh>
|
||||||
#include <elm_button.eo.hh>
|
#include <elm_button.eo.hh>
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Eina_List *transitions;
|
efl::eo::wref<elm_box> box;
|
||||||
Evas_Object *box;
|
std::deque<Evas_Object_Box_Layout> transitions;
|
||||||
Evas_Object_Box_Layout last_layout;
|
Evas_Object_Box_Layout last_layout;
|
||||||
} Transitions_Data;
|
} Transitions_Data;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_add_cb(void *data, Evas_Object *obj, void *ev)
|
_add_cb(void *data, Evas_Object *obj, void *ev)
|
||||||
{
|
{
|
||||||
Evas_Object *btn;
|
|
||||||
Eina_List *children;
|
Eina_List *children;
|
||||||
Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
|
Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
|
||||||
|
|
||||||
btn = elm_button_add(tdata->box);
|
if(efl::eina::optional<elm_box> box = tdata->box.lock())
|
||||||
elm_object_text_set(btn, "I do nothing");
|
{
|
||||||
children = (Eina_List *)elm_box_children_get(tdata->box);
|
elm_button btn ( efl::eo::parent = *box );
|
||||||
if (children)
|
btn.text_set("I do nothing");
|
||||||
{
|
efl::eina::list<efl::eo::base> childrens (box->children_get());
|
||||||
elm_box_pack_after(tdata->box, btn, (Evas_Object *)children->data);
|
if (!children.empty())
|
||||||
eina_list_free(children);
|
{
|
||||||
}
|
box->pack_after(btn._eo_ptr(), childrens.front());
|
||||||
else
|
}
|
||||||
elm_box_pack_end(tdata->box, btn);
|
else
|
||||||
evas_object_show(btn);
|
box->pack_end(btn._eo_ptr());
|
||||||
|
btn.visibility_set(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_clear_cb(void *data, Evas_Object *obj, void *ev)
|
_clear_cb(void *data, Evas_Object *obj, void *ev)
|
||||||
{
|
{
|
||||||
Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
|
Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
|
||||||
elm_box_clear(tdata->box);
|
tdata->box.lock()->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_unpack_cb(void *data, Evas_Object *obj, void *ev)
|
_unpack_cb(void *data, Evas_Object *obj, void *ev)
|
||||||
{
|
{
|
||||||
Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
|
Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
|
||||||
elm_box_unpack(tdata->box, obj);
|
tdata->box.lock()->unpack(obj);
|
||||||
evas_object_move(obj, 0, 50);
|
evas_object_move(obj, 0, 50);
|
||||||
evas_object_color_set(obj, 128, 64, 0, 128);
|
evas_object_color_set(obj, 128, 64, 0, 128);
|
||||||
}
|
}
|
||||||
|
@ -78,122 +81,107 @@ _test_box_transition_change(void *data)
|
||||||
Elm_Box_Transition *layout_data;
|
Elm_Box_Transition *layout_data;
|
||||||
Evas_Object_Box_Layout next_layout;
|
Evas_Object_Box_Layout next_layout;
|
||||||
|
|
||||||
if (!data) return;
|
assert (!!data);
|
||||||
next_layout = reinterpret_cast<Evas_Object_Box_Layout>(eina_list_data_get(tdata->transitions));
|
assert (!tdata->transitions.empty());
|
||||||
layout_data = elm_box_transition_new(2.0, tdata->last_layout,
|
|
||||||
NULL, NULL, next_layout, NULL, NULL,
|
|
||||||
_test_box_transition_change, tdata);
|
|
||||||
elm_box_layout_set(tdata->box, elm_box_layout_transition, layout_data,
|
|
||||||
elm_box_transition_free);
|
|
||||||
tdata->last_layout = next_layout;
|
|
||||||
|
|
||||||
tdata->transitions = eina_list_demote_list(tdata->transitions,
|
if(efl::eina::optional<elm_box> box = tdata->box.lock())
|
||||||
tdata->transitions);
|
{
|
||||||
|
next_layout = tdata->transitions.front();
|
||||||
|
layout_data = elm_box_transition_new(2.0, tdata->transitions.back(),
|
||||||
|
nullptr, nullptr, next_layout, nullptr, nullptr,
|
||||||
|
_test_box_transition_change, tdata);
|
||||||
|
box->layout_set(elm_box_layout_transition, layout_data,
|
||||||
|
elm_box_transition_free);
|
||||||
|
tdata->last_layout = next_layout;
|
||||||
|
|
||||||
|
tdata->transitions.push_back(tdata->transitions[0]);
|
||||||
|
tdata->transitions.pop_front();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI_MAIN int
|
EAPI_MAIN int
|
||||||
elm_main(int argc, char *argv[])
|
elm_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
static Transitions_Data tdata = {
|
|
||||||
.transitions = NULL,
|
|
||||||
.box = NULL,
|
|
||||||
.last_layout = NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||||
|
|
||||||
{
|
Transitions_Data tdata
|
||||||
::elm_win win ( ::eo_ref( elm_win_util_standard_add("box-transition", "Box Transition") ));
|
{
|
||||||
elm_win_autodel_set(win._eo_ptr(), EINA_TRUE);
|
elm_box{nullptr}
|
||||||
|
, {}
|
||||||
elm_box bigbox ( ::eo_ref( elm_box_add(win._eo_ptr()) ));
|
, nullptr
|
||||||
bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
};
|
||||||
win.resize_object_add(bigbox._eo_ptr());
|
|
||||||
bigbox.visibility_set(true);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
elm_box bx ( ::eo_ref( elm_box_add(win._eo_ptr()) ));
|
::elm_win win (elm_win_util_standard_add("box-transition", "Box Transition"));
|
||||||
bx.horizontal_set(EINA_TRUE);
|
win.autodel_set(true);
|
||||||
bigbox.pack_end(bx._eo_ptr());
|
|
||||||
bx.visibility_set(true);
|
|
||||||
|
|
||||||
{
|
elm_box bigbox ( efl::eo::parent = win );
|
||||||
elm_button bt ( ::eo_ref(elm_button_add(win._eo_ptr()) ));
|
bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
bt.text_set("Add");
|
win.resize_object_add(bigbox._eo_ptr());
|
||||||
bx.pack_end(bt._eo_ptr());
|
bigbox.visibility_set(true);
|
||||||
bt.visibility_set(true);
|
|
||||||
evas_object_smart_callback_add(bt._eo_ptr(), "clicked", _add_cb, &tdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
elm_box buttons ( efl::eo::parent = win );
|
||||||
elm_button bt ( ::eo_ref(elm_button_add(win._eo_ptr())));
|
buttons.horizontal_set(EINA_TRUE);
|
||||||
bt.text_set("Clear");
|
bigbox.pack_end(buttons._eo_ptr());
|
||||||
bx.pack_end(bt._eo_ptr());
|
buttons.visibility_set(true);
|
||||||
bt.visibility_set(true);
|
|
||||||
evas_object_smart_callback_add(bt._eo_ptr(), "clicked", _clear_cb, &tdata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
elm_button add ( efl::eo::parent = win );
|
||||||
elm_box bx ( ::eo_ref( elm_box_add(win._eo_ptr())));
|
add.text_set("Add");
|
||||||
bx.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
buttons.pack_end(add._eo_ptr());
|
||||||
bx.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
|
add.visibility_set(true);
|
||||||
bigbox.pack_end(bx._eo_ptr());
|
evas_object_smart_callback_add(add._eo_ptr(), "clicked", _add_cb, &tdata);
|
||||||
bx.visibility_set(true);
|
|
||||||
|
|
||||||
{
|
elm_button clear ( efl::eo::parent = win );
|
||||||
elm_button bt ( ::eo_ref( elm_button_add(win._eo_ptr()) ));
|
clear.text_set("Clear");
|
||||||
bt.text_set("Button 1");
|
buttons.pack_end(clear._eo_ptr());
|
||||||
evas_object_smart_callback_add(bt._eo_ptr(), "clicked", _unpack_cb, &tdata);
|
clear.visibility_set(true);
|
||||||
bt.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_smart_callback_add(clear._eo_ptr(), "clicked", _clear_cb, &tdata);
|
||||||
bt.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
||||||
bx.pack_end(bt._eo_ptr());
|
|
||||||
bt.visibility_set(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
elm_box dynamic ( efl::eo::parent = win );
|
||||||
elm_button bt ( ::eo_ref( elm_button_add(win._eo_ptr()) ));
|
dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
bt.text_set("Button 2");
|
dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
bt.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0);
|
bigbox.pack_end(dynamic._eo_ptr());
|
||||||
bt.size_hint_align_set(1.0, 0.5);
|
dynamic.visibility_set(true);
|
||||||
evas_object_smart_callback_add(bt._eo_ptr(), "clicked", _unpack_cb, &tdata);
|
|
||||||
bx.pack_end(bt._eo_ptr());
|
|
||||||
bt.visibility_set(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
elm_button bt1 ( efl::eo::parent = win );
|
||||||
elm_button bt ( ::eo_ref(elm_button_add(win._eo_ptr())));
|
bt1.text_set("Button 1");
|
||||||
bt.text_set("Button 3");
|
evas_object_smart_callback_add(bt1._eo_ptr(), "clicked", _unpack_cb, &tdata);
|
||||||
evas_object_smart_callback_add(bt._eo_ptr(), "clicked", _unpack_cb, &tdata);
|
bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
bx.pack_end(bt._eo_ptr());
|
bt1.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
bt.visibility_set(true);
|
dynamic.pack_end(bt1._eo_ptr());
|
||||||
}
|
bt1.visibility_set(true);
|
||||||
|
|
||||||
tdata.box = bx._eo_ptr();
|
elm_button bt2 ( efl::eo::parent = win );
|
||||||
|
bt2.text_set("Button 2");
|
||||||
|
bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0);
|
||||||
|
bt2.size_hint_align_set(1.0, 0.5);
|
||||||
|
evas_object_smart_callback_add(bt2._eo_ptr(), "clicked", _unpack_cb, &tdata);
|
||||||
|
dynamic.pack_end(bt2._eo_ptr());
|
||||||
|
bt2.visibility_set(true);
|
||||||
|
|
||||||
|
elm_button bt3 ( efl::eo::parent = win );
|
||||||
|
bt3.text_set("Button 3");
|
||||||
|
evas_object_smart_callback_add(bt3._eo_ptr(), "clicked", _unpack_cb, &tdata);
|
||||||
|
dynamic.pack_end(bt3._eo_ptr());
|
||||||
|
bt3.visibility_set(true);
|
||||||
|
|
||||||
|
tdata.box = dynamic;
|
||||||
tdata.last_layout = evas_object_box_layout_horizontal;
|
tdata.last_layout = evas_object_box_layout_horizontal;
|
||||||
tdata.transitions =
|
tdata.transitions.push_back(evas_object_box_layout_vertical);
|
||||||
(eina_list_append(tdata.transitions, (void*)evas_object_box_layout_vertical));
|
tdata.transitions.push_back(evas_object_box_layout_horizontal);
|
||||||
tdata.transitions =
|
tdata.transitions.push_back(evas_object_box_layout_stack);
|
||||||
(eina_list_append(tdata.transitions, (void*)evas_object_box_layout_horizontal));
|
tdata.transitions.push_back(evas_object_box_layout_homogeneous_vertical);
|
||||||
tdata.transitions =
|
tdata.transitions.push_back(evas_object_box_layout_homogeneous_horizontal);
|
||||||
(eina_list_append(tdata.transitions, (void*)evas_object_box_layout_stack));
|
tdata.transitions.push_back(evas_object_box_layout_flow_vertical);
|
||||||
tdata.transitions =
|
tdata.transitions.push_back(evas_object_box_layout_flow_horizontal);
|
||||||
(eina_list_append(tdata.transitions, (void*)evas_object_box_layout_homogeneous_vertical));
|
tdata.transitions.push_back(evas_object_box_layout_stack);
|
||||||
tdata.transitions =
|
|
||||||
(eina_list_append(tdata.transitions, (void*)evas_object_box_layout_homogeneous_horizontal));
|
|
||||||
tdata.transitions =
|
|
||||||
(eina_list_append(tdata.transitions, (void*)evas_object_box_layout_flow_vertical));
|
|
||||||
tdata.transitions =
|
|
||||||
(eina_list_append(tdata.transitions, (void*)evas_object_box_layout_flow_horizontal));
|
|
||||||
tdata.transitions =
|
|
||||||
(eina_list_append(tdata.transitions, (void*)evas_object_box_layout_stack));
|
|
||||||
|
|
||||||
bx.layout_set(evas_object_box_layout_horizontal, NULL, NULL);
|
dynamic.layout_set(evas_object_box_layout_horizontal, nullptr, nullptr);
|
||||||
_test_box_transition_change(&tdata);
|
_test_box_transition_change(&tdata);
|
||||||
}
|
|
||||||
|
|
||||||
win.size_set(300, 320);
|
win.size_set(300, 320);
|
||||||
win.visibility_set(true);
|
win.visibility_set(true);
|
||||||
|
win._release();
|
||||||
}
|
}
|
||||||
|
|
||||||
elm_run();
|
elm_run();
|
||||||
|
|
Loading…
Reference in New Issue