2 //gcc -g box_example_02.c -o box_example_02 `pkg-config --cflags --libs elementary`
9 # include <elementary_config.h>
12 #define ELM_INTERNAL_API_ARGESFSDFEFC
13 #define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
14 #define ELM_INTERFACE_ATSPI_COMPONENT_PROTECTED
15 #define ELM_INTERFACE_ATSPI_ACTION_PROTECTED
16 #define ELM_INTERFACE_ATSPI_VALUE_PROTECTED
17 #define ELM_INTERFACE_ATSPI_EDITABLE_TEXT_PROTECTED
18 #define ELM_INTERFACE_ATSPI_TEXT_PROTECTED
19 #define ELM_INTERFACE_ATSPI_SELECTION_PROTECTED
20 #define ELM_INTERFACE_ATSPI_IMAGE_PROTECTED
21 #define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
23 #include <Elementary.h>
27 #include <Elementary.h>
28 #include <elm_widget.h>
30 #include "elm_interface_atspi_accessible.h"
31 #include "elm_interface_atspi_accessible.eo.h"
33 #include "elm_interface_atspi_widget_action.h"
34 #include "elm_interface_atspi_widget_action.eo.h"
39 #include <elm_win.eo.hh>
40 #include <elm_box.eo.hh>
41 #include <elm_button.eo.hh>
47 struct Transitions_Data
49 efl::eo::wref<elm_box> box;
50 std::deque<Evas_Object_Box_Layout> transitions;
51 Evas_Object_Box_Layout last_layout;
55 _test_box_transition_change(void *data)
57 Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
58 Elm_Box_Transition *layout_data;
59 Evas_Object_Box_Layout next_layout;
62 assert (!tdata->transitions.empty());
64 if(efl::eina::optional<elm_box> box = tdata->box.lock())
66 next_layout = tdata->transitions.front();
67 layout_data = elm_box_transition_new(2.0, tdata->transitions.back(),
68 nullptr, nullptr, next_layout, nullptr, nullptr,
69 _test_box_transition_change, tdata);
70 box->layout_set(elm_box_layout_transition, layout_data,
71 elm_box_transition_free);
72 tdata->last_layout = next_layout;
74 tdata->transitions.push_back(tdata->transitions[0]);
75 tdata->transitions.pop_front();
81 clean_ref(efl::eo::base base)
82 : _ref(base._eo_ptr())
86 void operator()(T const&, Eo_Event_Description const&, void*) const
96 elm_main(int argc, char *argv[])
98 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
100 Transitions_Data tdata;
104 ::elm_win win (elm_win_util_standard_add("box-transition", "Box Transition"));
105 win.autodel_set(true);
107 elm_box bigbox ( efl::eo::parent = win );
108 bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
109 win.resize_object_add(bigbox);
110 bigbox.visibility_set(true);
111 win.callback_del_add(clean_ref(bigbox));
113 elm_box buttons ( efl::eo::parent = win );
114 buttons.horizontal_set(EINA_TRUE);
115 bigbox.pack_end(buttons);
116 buttons.visibility_set(true);
117 win.callback_del_add(clean_ref(buttons));
119 elm_button add ( efl::eo::parent = win );
120 add.text_set("elm.text", "Add");
121 buttons.pack_end(add);
122 add.visibility_set(true);
123 add.callback_clicked_add
126 if(efl::eina::optional<elm_box> box = tdata.box.lock())
128 elm_button btn ( efl::eo::parent = *box );
129 btn.text_set("elm.text", "I do nothing");
130 efl::eina::list<evas::object> childrens(box->children_get());
131 if (!childrens.empty())
133 box->pack_after(btn, childrens.front());
137 btn.visibility_set(true);
140 win.callback_del_add(clean_ref(add));
142 elm_button clear ( efl::eo::parent = win );
143 clear.text_set("elm.text", "Clear");
144 buttons.pack_end(clear);
145 clear.visibility_set(true);
146 clear.callback_clicked_add(std::bind([&tdata] { tdata.box.lock()->clear(); }));
147 win.callback_del_add(clean_ref(clear));
149 elm_box dynamic ( efl::eo::parent = win );
150 dynamic.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
151 dynamic.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
152 bigbox.pack_end(dynamic);
153 dynamic.visibility_set(true);
154 win.callback_del_add(clean_ref(dynamic));
156 auto unpack = std::bind([&tdata] (evas::clickable_interface obj)
158 elm_button btn = efl::eo::downcast<elm_button>(obj);
159 tdata.box.lock()->unpack(btn);
160 btn.position_set(0, 50);
161 btn.color_set(128, 64, 0, 128);
162 }, std::placeholders::_1)
165 elm_button bt1 ( efl::eo::parent = win );
166 bt1.text_set("elm.text", "Button 1");
167 bt1.callback_clicked_add(unpack);
168 bt1.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
169 bt1.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
170 dynamic.pack_end(bt1);
171 bt1.visibility_set(true);
172 win.callback_del_add(clean_ref(bt1));
174 elm_button bt2 ( efl::eo::parent = win );
175 bt2.text_set("elm.text", "Button 2");
176 bt2.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0);
177 bt2.size_hint_align_set(1.0, 0.5);
178 bt2.callback_clicked_add(unpack);
179 dynamic.pack_end(bt2);
180 bt2.visibility_set(true);
181 win.callback_del_add(clean_ref(bt2));
183 elm_button bt3 ( efl::eo::parent = win );
184 bt3.text_set("elm.text", "Button 3");
185 bt3.callback_clicked_add(unpack);
186 dynamic.pack_end(bt3);
187 bt3.visibility_set(true);
188 win.callback_del_add(clean_ref(bt3));
191 tdata.last_layout = evas_object_box_layout_horizontal;
192 tdata.transitions.push_back(evas_object_box_layout_vertical);
193 tdata.transitions.push_back(evas_object_box_layout_horizontal);
194 tdata.transitions.push_back(evas_object_box_layout_stack);
195 tdata.transitions.push_back(evas_object_box_layout_homogeneous_vertical);
196 tdata.transitions.push_back(evas_object_box_layout_homogeneous_horizontal);
197 tdata.transitions.push_back(evas_object_box_layout_flow_vertical);
198 tdata.transitions.push_back(evas_object_box_layout_flow_horizontal);
199 tdata.transitions.push_back(evas_object_box_layout_stack);
201 dynamic.layout_set(evas_object_box_layout_horizontal, nullptr, nullptr);
202 _test_box_transition_change(&tdata);
204 win.size_set(300, 320);
205 win.visibility_set(true);
207 std::cout << "references to win " << win.ref_get() << std::endl;
208 test = win._eo_ptr();
211 std::cout << "references to win " << ::eo_ref_get(test) << std::endl;