2016-04-13 19:12:44 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
2016-04-19 01:43:28 -07:00
|
|
|
|
|
|
|
#define EFL_PACK_LAYOUT_PROTECTED
|
2016-04-13 19:12:44 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
|
|
|
|
static Evas_Object *objects[7] = {};
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
NONE,
|
|
|
|
NONE_BUT_FILL,
|
|
|
|
EQUAL,
|
|
|
|
ONE,
|
2016-04-18 04:17:24 -07:00
|
|
|
TWO,
|
|
|
|
CUSTOM
|
2016-04-13 19:12:44 -07:00
|
|
|
} Weight_Mode;
|
|
|
|
|
2016-04-18 04:17:24 -07:00
|
|
|
static void _custom_engine_layout_do(Eo *obj, void *pd, Efl_Pack *pack, const void *data);
|
|
|
|
|
|
|
|
/* Common Eo Class boilerplate. */
|
|
|
|
static const Eo_Op_Description custom_engine_op_desc[] = {
|
2016-04-19 01:43:28 -07:00
|
|
|
EO_OP_CLASS_FUNC_OVERRIDE(efl_pack_layout_do, _custom_engine_layout_do),
|
2016-04-18 04:17:24 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const Eo_Class_Description custom_engine_class_desc = {
|
|
|
|
EO_VERSION, "Custom Layout Engine", EO_CLASS_TYPE_INTERFACE,
|
|
|
|
EO_CLASS_DESCRIPTION_OPS(custom_engine_op_desc), NULL, 0, NULL, NULL
|
|
|
|
};
|
|
|
|
|
2016-04-19 01:43:28 -07:00
|
|
|
EO_DEFINE_CLASS(_test_ui_grid_custom_engine_class_get, &custom_engine_class_desc, EFL_PACK_LAYOUT_INTERFACE, NULL)
|
2016-04-18 04:17:24 -07:00
|
|
|
|
|
|
|
#define CUSTOM_ENGINE_CLASS _test_ui_grid_custom_engine_class_get()
|
2016-04-13 19:12:44 -07:00
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
weights_cb(void *data, const Eo_Event *event)
|
|
|
|
{
|
2016-05-18 08:17:36 -07:00
|
|
|
Weight_Mode mode = elm_radio_state_value_get(event->object);
|
2016-04-18 04:17:24 -07:00
|
|
|
Eo *grid = data;
|
|
|
|
|
|
|
|
if (mode != CUSTOM)
|
|
|
|
efl_pack_layout_engine_set(grid, NULL, NULL);
|
2016-04-13 19:12:44 -07:00
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case NONE:
|
2016-04-18 04:17:24 -07:00
|
|
|
evas_object_size_hint_align_set(grid, 0.5, 0.5);
|
2016-04-13 19:12:44 -07:00
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
evas_object_size_hint_weight_set(objects[i], 0, 0);
|
|
|
|
break;
|
|
|
|
case NONE_BUT_FILL:
|
2016-04-18 04:17:24 -07:00
|
|
|
evas_object_size_hint_align_set(grid, -1, -1);
|
2016-04-13 19:12:44 -07:00
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
evas_object_size_hint_weight_set(objects[i], 0, 0);
|
|
|
|
break;
|
|
|
|
case EQUAL:
|
2016-04-18 04:17:24 -07:00
|
|
|
evas_object_size_hint_align_set(grid, 0.5, 0.5);
|
2016-04-13 19:12:44 -07:00
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
evas_object_size_hint_weight_set(objects[i], 1, 1);
|
|
|
|
break;
|
|
|
|
case ONE:
|
2016-04-18 04:17:24 -07:00
|
|
|
evas_object_size_hint_align_set(grid, 0.5, 0.5);
|
2016-04-13 19:12:44 -07:00
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
evas_object_size_hint_weight_set(objects[i], 0, 0);
|
|
|
|
evas_object_size_hint_weight_set(objects[6], 1, 1);
|
|
|
|
break;
|
|
|
|
case TWO:
|
2016-04-18 04:17:24 -07:00
|
|
|
evas_object_size_hint_align_set(grid, 0.5, 0.5);
|
2016-04-13 19:12:44 -07:00
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
evas_object_size_hint_weight_set(objects[i], 0, 0);
|
|
|
|
evas_object_size_hint_weight_set(objects[5], 1, 1);
|
|
|
|
evas_object_size_hint_weight_set(objects[6], 1, 1);
|
|
|
|
break;
|
2016-04-18 04:17:24 -07:00
|
|
|
case CUSTOM:
|
|
|
|
efl_pack_layout_engine_set(grid, CUSTOM_ENGINE_CLASS, NULL);
|
|
|
|
break;
|
2016-04-13 19:12:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return EO_CALLBACK_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
request_slider_cb(void *data EINA_UNUSED, const Eo_Event *event)
|
|
|
|
{
|
2016-05-18 08:17:36 -07:00
|
|
|
int val = elm_slider_value_get(event->object);
|
2016-04-13 19:12:44 -07:00
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
evas_object_size_hint_request_set(objects[i], val, 0);
|
|
|
|
return EO_CALLBACK_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
padding_slider_cb(void *data, const Eo_Event *event)
|
|
|
|
{
|
2016-05-18 08:17:36 -07:00
|
|
|
int val = elm_slider_value_get(event->object);
|
2016-04-13 19:12:44 -07:00
|
|
|
efl_pack_padding_set(data, val, val, EINA_TRUE);
|
|
|
|
return EO_CALLBACK_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
margin_slider_cb(void *data, const Eo_Event *event)
|
|
|
|
{
|
2016-05-18 08:17:36 -07:00
|
|
|
int val = elm_slider_value_get(event->object);
|
2016-04-13 19:12:44 -07:00
|
|
|
evas_object_size_hint_padding_set(data, val, val, val, val);
|
|
|
|
return EO_CALLBACK_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
btnmargins_slider_cb(void *data, const Eo_Event *event)
|
|
|
|
{
|
2016-05-18 08:17:36 -07:00
|
|
|
int val = elm_slider_value_get(event->object);
|
2016-04-13 19:12:44 -07:00
|
|
|
for (int i = 1; i < 7; i++)
|
|
|
|
evas_object_size_hint_padding_set(data, val, val, val, val);
|
|
|
|
return EO_CALLBACK_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
static Eina_Bool
|
|
|
|
layout_updated_cb(void *data, const Eo_Event *event)
|
|
|
|
{
|
|
|
|
Elm_Label *o = data;
|
|
|
|
char buf[64];
|
|
|
|
int rows, cols, count;
|
|
|
|
|
2016-05-18 08:17:36 -07:00
|
|
|
efl_pack_grid_size_get(event->object, &cols, &rows);
|
|
|
|
count = efl_content_count(event->object);
|
2016-04-14 00:41:57 -07:00
|
|
|
sprintf(buf, "%d items (%dx%d)", count, cols, rows);
|
|
|
|
elm_object_text_set(o, buf);
|
|
|
|
|
|
|
|
return EO_CALLBACK_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
child_evt_cb(void *data, const Eo_Event *event)
|
|
|
|
{
|
|
|
|
Elm_Label *o = data;
|
2016-05-10 04:25:44 -07:00
|
|
|
Efl_Gfx *it = event->info;
|
2016-04-14 00:41:57 -07:00
|
|
|
int col, row, colspan, rowspan;
|
|
|
|
char buf[64];
|
|
|
|
|
2016-05-18 08:17:36 -07:00
|
|
|
efl_pack_grid_position_get(event->object, it, &col, &row, &colspan, &rowspan);
|
2016-04-19 22:55:26 -07:00
|
|
|
if (event->desc == EFL_CONTAINER_EVENT_CONTENT_ADDED)
|
2016-04-14 00:41:57 -07:00
|
|
|
sprintf(buf, "pack %d,%d %dx%d", col, row, colspan, rowspan);
|
|
|
|
else
|
|
|
|
sprintf(buf, "unpack %d,%d %dx%d", col, row, colspan, rowspan);
|
|
|
|
elm_object_text_set(o, buf);
|
|
|
|
|
|
|
|
return EO_CALLBACK_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2016-04-18 04:17:24 -07:00
|
|
|
static void
|
|
|
|
_custom_engine_layout_do(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED,
|
|
|
|
Efl_Pack *pack, const void *data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
/* Example custom layout for grid:
|
|
|
|
* divide space into regions of same size, place objects in center of their
|
|
|
|
* cells using their min size
|
|
|
|
* Note: This is a TERRIBLE layout function (disregards align, weight, ...)
|
|
|
|
*/
|
|
|
|
|
|
|
|
int rows, cols, gw, gh, gx, gy, c, r, cs, rs, gmw = 0, gmh = 0;
|
|
|
|
Eina_Iterator *it;
|
|
|
|
Eo *item;
|
|
|
|
|
|
|
|
efl_gfx_size_get(pack, &gw, &gh);
|
|
|
|
efl_gfx_position_get(pack, &gx, &gy);
|
|
|
|
|
|
|
|
efl_pack_grid_size_get(pack, &cols, &rows);
|
|
|
|
if (!cols || !rows) goto end;
|
|
|
|
|
2016-04-19 22:55:26 -07:00
|
|
|
it = efl_content_iterate(pack);
|
2016-04-18 04:17:24 -07:00
|
|
|
EINA_ITERATOR_FOREACH(it, item)
|
|
|
|
{
|
2016-04-25 23:21:21 -07:00
|
|
|
if (efl_pack_grid_position_get(pack, item, &c, &r, &cs, &rs))
|
2016-04-18 04:17:24 -07:00
|
|
|
{
|
|
|
|
int x, y, mw, mh;
|
|
|
|
|
2016-06-09 00:29:40 -07:00
|
|
|
efl_gfx_size_hint_combined_min_get(item, &mw, &mh);
|
2016-04-18 04:17:24 -07:00
|
|
|
x = gx + c * gw / cols + (cs * gw / cols - mw) / 2;
|
|
|
|
y = gy + r * gh / rows + (rs * gh / rows - mh) / 2;
|
|
|
|
efl_gfx_size_set(item, mw, mh);
|
|
|
|
efl_gfx_position_set(item, x, y);
|
|
|
|
|
|
|
|
gmw = MAX(gmw, mw);
|
|
|
|
gmh = MAX(gmh, mh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eina_iterator_free(it);
|
|
|
|
|
|
|
|
end:
|
|
|
|
evas_object_size_hint_min_set(pack, gmw * cols, gmh * rows);
|
|
|
|
}
|
|
|
|
|
2016-04-13 19:12:44 -07:00
|
|
|
void
|
|
|
|
test_ui_grid(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *win, *bx, *o, *vbox, *f, *hbox, *chk, *grid;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
win = elm_win_util_standard_add("ui-grid", "Efl.Ui.Grid");
|
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
|
|
|
efl_gfx_size_set(win, 600, 400);
|
|
|
|
|
|
|
|
vbox = eo_add(EFL_UI_BOX_CLASS, win);
|
|
|
|
efl_pack_padding_set(vbox, 10, 10, EINA_TRUE);
|
2016-06-02 23:55:29 -07:00
|
|
|
efl_orientation_set(vbox, EFL_ORIENT_DOWN);
|
2016-04-13 19:12:44 -07:00
|
|
|
evas_object_size_hint_weight_set(vbox, 1, 1);
|
|
|
|
evas_object_size_hint_padding_set(vbox, 5, 5, 5, 5);
|
|
|
|
elm_win_resize_object_add(win, vbox);
|
|
|
|
efl_gfx_visible_set(vbox, 1);
|
|
|
|
|
|
|
|
|
|
|
|
// create here to pass in cb
|
|
|
|
grid = eo_add(EFL_UI_GRID_CLASS, win);
|
|
|
|
|
|
|
|
|
|
|
|
/* controls */
|
|
|
|
f = elm_frame_add(win);
|
|
|
|
elm_object_text_set(f, "Controls");
|
|
|
|
evas_object_size_hint_align_set(f, -1, -1);
|
|
|
|
evas_object_size_hint_weight_set(f, 1, 0);
|
|
|
|
efl_pack(vbox, f);
|
|
|
|
efl_gfx_visible_set(f, 1);
|
|
|
|
|
|
|
|
hbox = eo_add(EFL_UI_BOX_CLASS, win);
|
|
|
|
elm_object_content_set(f, hbox);
|
|
|
|
efl_pack_padding_set(hbox, 10, 0, EINA_TRUE);
|
|
|
|
efl_gfx_visible_set(hbox, 1);
|
|
|
|
|
|
|
|
|
|
|
|
/* weights radio group */
|
|
|
|
bx = eo_add(EFL_UI_BOX_CLASS, win,
|
2016-06-02 23:55:29 -07:00
|
|
|
efl_orientation_set(eo_self, EFL_ORIENT_DOWN));
|
2016-04-13 19:12:44 -07:00
|
|
|
evas_object_size_hint_align_set(bx, 0, -1);
|
|
|
|
efl_pack(hbox, bx);
|
|
|
|
efl_gfx_visible_set(bx, 1);
|
|
|
|
|
|
|
|
chk = o = elm_radio_add(win);
|
|
|
|
elm_object_text_set(o, "No weight");
|
|
|
|
eo_event_callback_add(o, ELM_RADIO_EVENT_CHANGED, weights_cb, grid);
|
|
|
|
evas_object_size_hint_align_set(o, 0, 0.5);
|
|
|
|
elm_radio_state_value_set(o, NONE);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_radio_add(win);
|
|
|
|
elm_object_text_set(o, "No weight + grid fill");
|
|
|
|
eo_event_callback_add(o, ELM_RADIO_EVENT_CHANGED, weights_cb, grid);
|
|
|
|
evas_object_size_hint_align_set(o, 0, 0.5);
|
|
|
|
elm_radio_state_value_set(o, NONE_BUT_FILL);
|
|
|
|
elm_radio_group_add(o, chk);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_radio_add(win);
|
|
|
|
elm_object_text_set(o, "Equal weights");
|
|
|
|
eo_event_callback_add(o, ELM_RADIO_EVENT_CHANGED, weights_cb, grid);
|
|
|
|
evas_object_size_hint_align_set(o, 0, 0.5);
|
|
|
|
elm_radio_state_value_set(o, EQUAL);
|
|
|
|
elm_radio_group_add(o, chk);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_radio_add(win);
|
|
|
|
elm_object_text_set(o, "One weight only");
|
|
|
|
eo_event_callback_add(o, ELM_RADIO_EVENT_CHANGED, weights_cb, grid);
|
|
|
|
evas_object_size_hint_align_set(o, 0, 0.5);
|
|
|
|
elm_radio_state_value_set(o, ONE);
|
|
|
|
elm_radio_group_add(o, chk);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_radio_add(win);
|
|
|
|
elm_object_text_set(o, "Two weights");
|
|
|
|
eo_event_callback_add(o, ELM_RADIO_EVENT_CHANGED, weights_cb, grid);
|
|
|
|
evas_object_size_hint_align_set(o, 0, 0.5);
|
|
|
|
elm_radio_state_value_set(o, TWO);
|
|
|
|
elm_radio_group_add(o, chk);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
2016-04-18 04:17:24 -07:00
|
|
|
o = elm_radio_add(win);
|
|
|
|
elm_object_text_set(o, "Custom layout");
|
|
|
|
eo_event_callback_add(o, ELM_RADIO_EVENT_CHANGED, weights_cb, grid);
|
|
|
|
evas_object_size_hint_align_set(o, 0, 0.5);
|
|
|
|
elm_radio_state_value_set(o, CUSTOM);
|
|
|
|
elm_radio_group_add(o, chk);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
2016-04-13 19:12:44 -07:00
|
|
|
elm_radio_value_set(chk, EQUAL);
|
|
|
|
|
|
|
|
|
|
|
|
/* requested size setter */
|
|
|
|
bx = eo_add(EFL_UI_BOX_CLASS, win,
|
2016-06-02 23:55:29 -07:00
|
|
|
efl_orientation_set(eo_self, EFL_ORIENT_DOWN));
|
2016-04-13 19:12:44 -07:00
|
|
|
evas_object_size_hint_align_set(bx, 0.5, -1);
|
|
|
|
evas_object_size_hint_weight_set(bx, 0, 1);
|
|
|
|
efl_pack(hbox, bx);
|
|
|
|
efl_gfx_visible_set(bx, 1);
|
|
|
|
|
|
|
|
o = elm_label_add(win);
|
|
|
|
elm_object_text_set(o, "Requested size");
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_slider_add(win);
|
|
|
|
elm_slider_indicator_format_set(o, "%.0fpx");
|
|
|
|
elm_slider_indicator_show_set(o, 1);
|
|
|
|
elm_slider_horizontal_set(o, 0);
|
|
|
|
evas_object_size_hint_align_set(o, 0.5, -1);
|
|
|
|
evas_object_size_hint_weight_set(o, 1, 1);
|
|
|
|
eo_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, request_slider_cb, NULL);
|
|
|
|
elm_slider_min_max_set(o, 0, 250);
|
|
|
|
elm_slider_inverted_set(o, 1);
|
|
|
|
elm_slider_value_set(o, 0);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
|
|
|
|
/* inner box padding */
|
|
|
|
bx = eo_add(EFL_UI_BOX_CLASS, win,
|
2016-06-02 23:55:29 -07:00
|
|
|
efl_orientation_set(eo_self, EFL_ORIENT_DOWN));
|
2016-04-13 19:12:44 -07:00
|
|
|
evas_object_size_hint_align_set(bx, 0, -1);
|
|
|
|
evas_object_size_hint_weight_set(bx, 0, 1);
|
|
|
|
efl_pack(hbox, bx);
|
|
|
|
efl_gfx_visible_set(bx, 1);
|
|
|
|
|
|
|
|
o = elm_label_add(win);
|
|
|
|
elm_object_text_set(o, "Padding");
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_slider_add(win);
|
|
|
|
elm_slider_indicator_format_set(o, "%.0fpx");
|
|
|
|
elm_slider_indicator_show_set(o, 1);
|
|
|
|
elm_slider_horizontal_set(o, 0);
|
|
|
|
evas_object_size_hint_align_set(o, 0.5, -1);
|
|
|
|
evas_object_size_hint_weight_set(o, 1, 1);
|
|
|
|
eo_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, padding_slider_cb, grid);
|
|
|
|
elm_slider_min_max_set(o, 0, 40);
|
|
|
|
elm_slider_inverted_set(o, 1);
|
|
|
|
elm_slider_value_set(o, 10);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
|
|
|
|
/* outer margin */
|
|
|
|
bx = eo_add(EFL_UI_BOX_CLASS, win,
|
2016-06-02 23:55:29 -07:00
|
|
|
efl_orientation_set(eo_self, EFL_ORIENT_DOWN));
|
2016-04-13 19:12:44 -07:00
|
|
|
evas_object_size_hint_align_set(bx, 0, -1);
|
|
|
|
evas_object_size_hint_weight_set(bx, 0, 1);
|
|
|
|
efl_pack(hbox, bx);
|
|
|
|
efl_gfx_visible_set(bx, 1);
|
|
|
|
|
|
|
|
o = elm_label_add(win);
|
|
|
|
elm_object_text_set(o, "Margin");
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_slider_add(win);
|
|
|
|
elm_slider_indicator_format_set(o, "%.0fpx");
|
|
|
|
elm_slider_indicator_show_set(o, 1);
|
|
|
|
elm_slider_horizontal_set(o, 0);
|
|
|
|
evas_object_size_hint_align_set(o, 0.5, -1);
|
|
|
|
evas_object_size_hint_weight_set(o, 1, 1);
|
|
|
|
eo_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, margin_slider_cb, grid);
|
|
|
|
elm_slider_min_max_set(o, 0, 40);
|
|
|
|
elm_slider_inverted_set(o, 1);
|
|
|
|
elm_slider_value_set(o, 10);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
|
|
|
|
/* button margins */
|
|
|
|
bx = eo_add(EFL_UI_BOX_CLASS, win,
|
2016-06-02 23:55:29 -07:00
|
|
|
efl_orientation_set(eo_self, EFL_ORIENT_DOWN));
|
2016-04-13 19:12:44 -07:00
|
|
|
evas_object_size_hint_align_set(bx, 0, -1);
|
|
|
|
evas_object_size_hint_weight_set(bx, 1, 1);
|
|
|
|
efl_pack(hbox, bx);
|
|
|
|
efl_gfx_visible_set(bx, 1);
|
|
|
|
|
|
|
|
o = elm_label_add(win);
|
|
|
|
elm_object_text_set(o, "Buttons margins");
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_slider_add(win);
|
|
|
|
elm_slider_indicator_format_set(o, "%.0fpx");
|
|
|
|
elm_slider_indicator_show_set(o, 1);
|
|
|
|
elm_slider_horizontal_set(o, 0);
|
|
|
|
evas_object_size_hint_align_set(o, 0.5, -1);
|
|
|
|
evas_object_size_hint_weight_set(o, 1, 1);
|
|
|
|
eo_event_callback_add(o, ELM_SLIDER_EVENT_CHANGED, btnmargins_slider_cb, grid);
|
|
|
|
elm_slider_min_max_set(o, 0, 40);
|
|
|
|
elm_slider_inverted_set(o, 1);
|
|
|
|
elm_slider_value_set(o, 10);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
/* ro info */
|
|
|
|
bx = eo_add(EFL_UI_BOX_CLASS, win,
|
2016-06-02 23:55:29 -07:00
|
|
|
efl_orientation_set(eo_self, EFL_ORIENT_DOWN));
|
2016-04-14 00:41:57 -07:00
|
|
|
evas_object_size_hint_align_set(bx, 0, -1);
|
|
|
|
evas_object_size_hint_weight_set(bx, 1, 1);
|
|
|
|
efl_pack(hbox, bx);
|
|
|
|
efl_gfx_visible_set(bx, 1);
|
|
|
|
|
|
|
|
o = elm_label_add(win);
|
|
|
|
elm_object_text_set(o, "<b>Properties</>");
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_label_add(win);
|
|
|
|
eo_event_callback_add(grid, EFL_PACK_EVENT_LAYOUT_UPDATED, layout_updated_cb, o);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_label_add(win);
|
2016-04-19 22:55:26 -07:00
|
|
|
eo_event_callback_add(grid, EFL_CONTAINER_EVENT_CONTENT_ADDED, child_evt_cb, o);
|
|
|
|
eo_event_callback_add(grid, EFL_CONTAINER_EVENT_CONTENT_REMOVED, child_evt_cb, o);
|
2016-04-14 00:41:57 -07:00
|
|
|
evas_object_size_hint_align_set(o, 0.5, 0);
|
|
|
|
evas_object_size_hint_weight_set(o, 1, 1);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
|
2016-04-13 19:12:44 -07:00
|
|
|
/* contents */
|
|
|
|
f = elm_frame_add(win);
|
|
|
|
elm_object_text_set(f, "Contents");
|
|
|
|
evas_object_size_hint_align_set(f, -1, -1);
|
|
|
|
evas_object_size_hint_weight_set(f, 1, 1);
|
|
|
|
efl_pack(vbox, f);
|
|
|
|
efl_gfx_visible_set(f, 1);
|
|
|
|
|
|
|
|
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_object_content_set(f, grid);
|
|
|
|
evas_object_show(grid);
|
|
|
|
|
|
|
|
objects[i++] = o = evas_object_rectangle_add(win);
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_min_set(o, 10, 10);
|
|
|
|
evas_object_color_set(o, 64, 96, 128, 255);
|
|
|
|
efl_pack_grid(grid, o, 0, 0, 3, 1);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
objects[i++] = o = elm_button_add(win);
|
|
|
|
elm_object_text_set(o, "Button 1");
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
efl_pack_grid(grid, o, 0, 0, 1, 1);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
objects[i++] = o = elm_button_add(win);
|
|
|
|
elm_object_text_set(o, "Button 2");
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
efl_pack_grid(grid, o, 1, 0, 1, 1);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
objects[i++] = o = elm_button_add(win);
|
|
|
|
elm_object_text_set(o, "Button 3");
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
efl_pack_grid(grid, o, 2, 0, 1, 1);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
objects[i++] = o = elm_button_add(win);
|
|
|
|
elm_object_text_set(o, "Button 4");
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
efl_pack_grid(grid, o, 0, 1, 2, 1);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
objects[i++] = o = elm_button_add(win);
|
|
|
|
elm_object_text_set(o, "Button 5");
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
efl_pack_grid(grid, o, 2, 1, 1, 2);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
objects[i++] = o = elm_button_add(win);
|
|
|
|
elm_object_text_set(o, "Button 6");
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
efl_pack_grid(grid, o, 0, 2, 2, 1);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
evas_object_show(win);
|
|
|
|
}
|
2016-04-13 22:12:16 -07:00
|
|
|
|
|
|
|
static const char *
|
|
|
|
btn_text(const char *str)
|
|
|
|
{
|
|
|
|
static char buf[64];
|
|
|
|
static int id = 0;
|
|
|
|
sprintf(buf, "%s %d", str ?: "item", ++id);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
remove_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2016-04-14 00:41:57 -07:00
|
|
|
//efl_pack_unpack(data, obj);
|
Revert "Eo: Remove eo_del() and make eo_unref() the replacement."
This reverts commit 546ff7bbba788ec834c5608361c0834853f2d5d7.
It seems that eo_del() is useful and removing it was creating bugs.
The issue is that the way we defined parents in eo, both the parent and
the programmer share a reference to the object. When we eo_unref() that
reference as the programmer, eo has no way to know it's this specific
reference we are freeing, and not a general one, so in some
circumstances, for example:
eo_ref(child);
eo_unref(child); // trying to delete here
eo_unref(container); // container is deleted here
eo_unref(child); // child already has 0 refs before this point.
We would have an issue with references and objects being freed too soon
and in general, issue with the references.
Having eo_del() solves that, because this one explicitly unparents if
there is a parent, meaning the reference ownership is explicitly taken
by the programmer.
eo_del() is essentially a convenience function around "check if has
parent, and if so unparent, otherwise, unref". Which should be used when
you want to delete an object although it has a parent, and is equivalent
to eo_unref() when it doesn't have one.
2016-06-01 05:14:30 -07:00
|
|
|
eo_del(obj);
|
2016-04-13 22:12:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
append_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Eo *grid = data;
|
|
|
|
Eo *o = elm_button_add(grid);
|
|
|
|
elm_object_text_set(o, btn_text("appended"));
|
|
|
|
evas_object_smart_callback_add(o, "clicked", remove_cb, grid);
|
|
|
|
elm_object_tooltip_text_set(o, "Click to unpack");
|
|
|
|
efl_pack_end(grid, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clear_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Eo *grid = data;
|
|
|
|
efl_pack_clear(grid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
test_ui_grid_linear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
2016-04-14 00:41:57 -07:00
|
|
|
Evas_Object *win, *o, *vbox, *f, *hbox, *grid, *ico, *bx;
|
2016-04-13 22:12:16 -07:00
|
|
|
|
|
|
|
win = elm_win_util_standard_add("ui-grid-linear", "Efl.Ui.Grid Linear APIs");
|
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
|
|
|
efl_gfx_size_set(win, 600, 400);
|
|
|
|
|
|
|
|
vbox = eo_add(EFL_UI_BOX_CLASS, win);
|
|
|
|
efl_pack_padding_set(vbox, 10, 10, EINA_TRUE);
|
2016-06-02 23:55:29 -07:00
|
|
|
efl_orientation_set(vbox, EFL_ORIENT_DOWN);
|
2016-04-13 22:12:16 -07:00
|
|
|
evas_object_size_hint_weight_set(vbox, 1, 1);
|
|
|
|
evas_object_size_hint_padding_set(vbox, 5, 5, 5, 5);
|
|
|
|
elm_win_resize_object_add(win, vbox);
|
|
|
|
efl_gfx_visible_set(vbox, 1);
|
|
|
|
|
|
|
|
|
|
|
|
// create here to pass in cb
|
|
|
|
grid = eo_add(EFL_UI_GRID_CLASS, win);
|
|
|
|
|
|
|
|
|
|
|
|
/* controls */
|
|
|
|
f = elm_frame_add(win);
|
|
|
|
elm_object_text_set(f, "Controls");
|
|
|
|
evas_object_size_hint_align_set(f, -1, -1);
|
|
|
|
evas_object_size_hint_weight_set(f, 1, 0);
|
|
|
|
efl_pack(vbox, f);
|
|
|
|
efl_gfx_visible_set(f, 1);
|
|
|
|
|
|
|
|
hbox = eo_add(EFL_UI_BOX_CLASS, win);
|
|
|
|
elm_object_content_set(f, hbox);
|
|
|
|
efl_pack_padding_set(hbox, 5, 0, EINA_TRUE);
|
|
|
|
efl_gfx_visible_set(hbox, 1);
|
|
|
|
|
|
|
|
ico = elm_icon_add(win);
|
|
|
|
elm_icon_standard_set(ico, "list-add");
|
|
|
|
o = elm_button_add(win);
|
|
|
|
elm_object_content_set(o, ico);
|
|
|
|
elm_object_text_set(o, "Append");
|
|
|
|
evas_object_smart_callback_add(o, "clicked", append_cb, grid);
|
|
|
|
efl_pack(hbox, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
ico = elm_icon_add(win);
|
|
|
|
elm_icon_standard_set(ico, "edit-clear-all");
|
|
|
|
o = elm_button_add(win);
|
|
|
|
elm_object_content_set(o, ico);
|
|
|
|
elm_object_text_set(o, "Clear");
|
|
|
|
evas_object_smart_callback_add(o, "clicked", clear_cb, grid);
|
|
|
|
efl_pack(hbox, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
/* ro info */
|
|
|
|
bx = eo_add(EFL_UI_BOX_CLASS, win,
|
2016-06-02 23:55:29 -07:00
|
|
|
efl_orientation_set(eo_self, EFL_ORIENT_DOWN));
|
2016-04-14 00:41:57 -07:00
|
|
|
evas_object_size_hint_align_set(bx, 0, -1);
|
|
|
|
evas_object_size_hint_weight_set(bx, 1, 1);
|
|
|
|
efl_pack(hbox, bx);
|
|
|
|
efl_gfx_visible_set(bx, 1);
|
|
|
|
|
|
|
|
o = elm_label_add(win);
|
|
|
|
elm_object_text_set(o, "<b>Properties</>");
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_label_add(win);
|
|
|
|
eo_event_callback_add(grid, EFL_PACK_EVENT_LAYOUT_UPDATED, layout_updated_cb, o);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_label_add(win);
|
2016-04-19 22:55:26 -07:00
|
|
|
eo_event_callback_add(grid, EFL_CONTAINER_EVENT_CONTENT_ADDED, child_evt_cb, o);
|
|
|
|
eo_event_callback_add(grid, EFL_CONTAINER_EVENT_CONTENT_REMOVED, child_evt_cb, o);
|
2016-04-14 00:41:57 -07:00
|
|
|
evas_object_size_hint_align_set(o, 0.5, 0);
|
|
|
|
evas_object_size_hint_weight_set(o, 1, 1);
|
|
|
|
efl_pack(bx, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
|
2016-04-13 22:12:16 -07:00
|
|
|
/* contents */
|
|
|
|
f = elm_frame_add(win);
|
|
|
|
elm_object_text_set(f, "Contents");
|
|
|
|
evas_object_size_hint_align_set(f, -1, -1);
|
|
|
|
evas_object_size_hint_weight_set(f, 1, 1);
|
|
|
|
efl_pack(vbox, f);
|
|
|
|
efl_gfx_visible_set(f, 1);
|
|
|
|
|
2016-04-19 01:43:28 -07:00
|
|
|
efl_pack_grid_columns_set(grid, 4);
|
2016-06-02 23:55:29 -07:00
|
|
|
efl_pack_grid_orientation_set(grid, EFL_ORIENT_RIGHT, EFL_ORIENT_DOWN);
|
2016-04-13 22:12:16 -07:00
|
|
|
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_object_content_set(f, grid);
|
|
|
|
evas_object_show(grid);
|
|
|
|
|
|
|
|
o = elm_button_add(win);
|
|
|
|
elm_object_text_set(o, btn_text(NULL));
|
|
|
|
evas_object_smart_callback_add(o, "clicked", remove_cb, grid);
|
|
|
|
efl_pack(grid, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_button_add(win);
|
|
|
|
elm_object_text_set(o, btn_text(NULL));
|
|
|
|
evas_object_smart_callback_add(o, "clicked", remove_cb, grid);
|
|
|
|
efl_pack(grid, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
o = elm_button_add(win);
|
|
|
|
elm_object_text_set(o, btn_text(NULL));
|
|
|
|
evas_object_smart_callback_add(o, "clicked", remove_cb, grid);
|
|
|
|
efl_pack(grid, o);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
|
|
|
|
evas_object_show(win);
|
|
|
|
}
|