2017-12-18 21:13:58 -08:00
|
|
|
#include "efl_ui_table_private.h"
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2019-03-05 08:15:40 -08:00
|
|
|
#include "../evas/canvas/evas_table_eo.h"
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2017-12-18 21:13:58 -08:00
|
|
|
#define MY_CLASS EFL_UI_TABLE_CLASS
|
|
|
|
#define MY_CLASS_NAME "Efl.Ui.Table"
|
2016-07-12 02:03:54 -07:00
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_grid"
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2016-04-18 04:17:24 -07:00
|
|
|
typedef struct _Custom_Table_Data Custom_Table_Data;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2016-08-30 05:34:10 -07:00
|
|
|
static void _subobj_del_cb(void *data, const Efl_Event *event);
|
2018-04-05 01:47:26 -07:00
|
|
|
static void _item_remove(Efl_Ui_Table *obj, Efl_Ui_Table_Data *pd, Efl_Gfx_Entity *subobj);
|
2016-04-14 00:41:57 -07:00
|
|
|
|
2016-04-18 04:17:24 -07:00
|
|
|
struct _Custom_Table_Data
|
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
Efl_Ui_Table *parent;
|
|
|
|
Efl_Ui_Table_Data *gd;
|
2016-04-18 04:17:24 -07:00
|
|
|
};
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
EFL_CALLBACKS_ARRAY_DEFINE(subobj_callbacks,
|
2016-08-10 07:23:04 -07:00
|
|
|
{ EFL_EVENT_DEL, _subobj_del_cb });
|
2016-04-14 00:41:57 -07:00
|
|
|
|
2016-04-11 22:10:47 -07:00
|
|
|
static void
|
|
|
|
_mirrored_set(Evas_Object *obj, Eina_Bool rtl)
|
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
|
|
|
evas_object_table_mirrored_set(wd->resize_obj, rtl);
|
|
|
|
}
|
|
|
|
|
2019-03-04 10:37:07 -08:00
|
|
|
EOLIAN static Eina_Error
|
2018-01-07 20:55:35 -08:00
|
|
|
_efl_ui_table_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2019-03-04 10:37:07 -08:00
|
|
|
Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
|
2017-10-23 22:03:46 -07:00
|
|
|
int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
|
2019-03-04 10:36:41 -08:00
|
|
|
if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2017-06-13 03:41:15 -07:00
|
|
|
_mirrored_set(obj, efl_ui_mirrored_get(obj));
|
2016-04-11 22:10:47 -07:00
|
|
|
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
return int_ret;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_layout_updated_emit(Efl_Ui_Table *obj)
|
2016-04-14 00:41:57 -07:00
|
|
|
{
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(obj, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL);
|
2016-04-14 00:41:57 -07:00
|
|
|
}
|
|
|
|
|
2016-04-11 22:10:47 -07:00
|
|
|
static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_sizing_eval(Evas_Object *obj, Efl_Ui_Table_Data *pd EINA_UNUSED)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
Evas_Coord minw = 0, minh = 0, maxw = -1, maxh = -1;
|
|
|
|
Evas_Coord w, h;
|
|
|
|
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2018-08-01 07:41:45 -07:00
|
|
|
if (!efl_alive_get(obj)) return;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2017-09-18 00:22:01 -07:00
|
|
|
evas_object_size_hint_combined_min_get(wd->resize_obj, &minw, &minh);
|
2017-04-16 21:41:29 -07:00
|
|
|
evas_object_size_hint_max_get(wd->resize_obj, &maxw, &maxh);
|
2016-04-11 22:10:47 -07:00
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
|
|
|
if (w < minw) w = minw;
|
|
|
|
if (h < minh) h = minh;
|
|
|
|
if ((maxw >= 0) && (w > maxw)) w = maxw;
|
|
|
|
if ((maxh >= 0) && (h > maxh)) h = maxh;
|
|
|
|
evas_object_resize(obj, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-14 00:41:57 -07:00
|
|
|
_table_size_hints_changed(void *data, Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *table EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
Efl_Ui_Table_Data *pd = efl_data_scope_get(data, MY_CLASS);
|
2016-04-11 22:10:47 -07:00
|
|
|
|
efl_ui_table: refactor layout_update
Summary:
There are three reasons to refactor layout_update of Efl.Ui.Table.
=== 1. Inconsistency of hint behavior. ===
Some hint property is often not respected. for example, hint_min is ignored in
Table when it is used with hint_max even if hint_weight is 0. hint_aspect is
always ignored in Table.
The ambiguous behavior make it hard to layout widgets in container. of course,
we documented 'it's just a hint that should be used whenever appropriate.' but i
don't think it means that 'hint API is sometimes respected and we also don't
know when that API is respected.'. at least there is rule for consistent
behavior and we should be able to explain why a widget is located here and
why some hint property is ignored.
So, i'll suggest priority of hint property. this refactoring support following
priority.
1) HintMin
2) HintMin + HintAspect
3) HintMargin
4) HintMax
5) HintAspect
6) HintWeight, HintFill
7) HintAlign
ref T5487
Please check with unit test D7840
=== 2. To Enhance usability. ===
Efl.Ui.Table is using homogeneous mode of evas_table which have same columns,
rows size. but i think a table can generally change columns, rows size and
we can provide homogeneous mode option.(D7892)
In this patch
- table columns(rows) min size is decided by maximum size among its cells
width(height) min size.
- table columns(rows) weight is decided by maximum weight among its cells
horizontal(vertical) weight.
Also, pack_align is implemented. it is used if no item has a weight.
=== 3. To remove internal evas_table. ===
This is low priority work. however, i guess is is necessary for lightweight
container widget. there are two size_hint callback to adjust table size and
efl_canvas_group_calculate is called twice when it is resized.
This patch is first step to remove internal evas_table.
Test Plan:
make check
elementary_test -to 'efl.ui.table'
Reviewers: jpeg, Jaehyun_Cho, zmike
Reviewed By: zmike
Subscribers: zmike, cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T5487
Differential Revision: https://phab.enlightenment.org/D7841
2019-02-27 11:45:27 -08:00
|
|
|
if (table == data)
|
|
|
|
efl_pack_layout_request(data);
|
|
|
|
else
|
|
|
|
_sizing_eval(data, pd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_table_size_hints_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
|
|
|
|
{
|
|
|
|
efl_pack_layout_request(ev->object);
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2016-04-18 04:17:24 -07:00
|
|
|
/* Custom table class: overrides smart_calculate. */
|
|
|
|
static void _custom_table_calc(Eo *obj, Custom_Table_Data *pd);
|
|
|
|
|
2016-09-01 06:34:55 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_custom_table_initializer(Efl_Class *klass)
|
|
|
|
{
|
2019-02-10 07:57:00 -08:00
|
|
|
EFL_OPS_DEFINE(ops,
|
2016-09-09 02:53:58 -07:00
|
|
|
EFL_OBJECT_OP_FUNC(efl_canvas_group_calculate, _custom_table_calc)
|
2016-09-01 06:34:55 -07:00
|
|
|
);
|
|
|
|
|
2019-02-10 07:57:00 -08:00
|
|
|
return efl_class_functions_set(klass, &ops, NULL);
|
2016-04-18 04:17:24 -07:00
|
|
|
};
|
|
|
|
|
2016-08-10 07:23:04 -07:00
|
|
|
static const Efl_Class_Description custom_table_class_desc = {
|
2017-12-18 21:13:58 -08:00
|
|
|
EO_VERSION, "Efl.Ui.Table.Internal", EFL_CLASS_TYPE_REGULAR,
|
2016-09-05 04:31:55 -07:00
|
|
|
sizeof(Custom_Table_Data), _custom_table_initializer, NULL, NULL
|
2016-04-18 04:17:24 -07:00
|
|
|
};
|
|
|
|
|
2017-12-18 21:13:58 -08:00
|
|
|
EFL_DEFINE_CLASS(_efl_ui_table_custom_table_class_get, &custom_table_class_desc,
|
2016-04-18 04:17:24 -07:00
|
|
|
EVAS_TABLE_CLASS, NULL)
|
|
|
|
|
2017-12-18 21:13:58 -08:00
|
|
|
#define CUSTOM_TABLE_CLASS _efl_ui_table_custom_table_class_get()
|
2016-04-18 04:17:24 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_custom_table_calc(Eo *obj, Custom_Table_Data *pd)
|
|
|
|
{
|
|
|
|
int cols, rows;
|
|
|
|
|
|
|
|
evas_object_table_col_row_size_get(obj, &cols, &rows);
|
|
|
|
if ((cols < 1) || (rows < 1)) return;
|
|
|
|
|
|
|
|
efl_pack_layout_update(pd->parent);
|
|
|
|
_layout_updated_emit(pd->parent);
|
|
|
|
}
|
|
|
|
/* End of custom table class */
|
|
|
|
|
2019-02-27 11:45:32 -08:00
|
|
|
EOLIAN static void
|
2019-03-08 05:22:12 -08:00
|
|
|
_efl_ui_table_homogeneous_set(Eo *obj, Efl_Ui_Table_Data *pd, Eina_Bool homogeneoush, Eina_Bool homogeneousv)
|
2019-02-27 11:45:32 -08:00
|
|
|
{
|
2019-03-08 05:22:12 -08:00
|
|
|
if ((pd->homogeneoush == !!homogeneoush) &&
|
|
|
|
(pd->homogeneousv == !!homogeneousv))
|
|
|
|
return;
|
|
|
|
|
2019-02-27 11:45:32 -08:00
|
|
|
pd->homogeneoush = !!homogeneoush;
|
|
|
|
pd->homogeneousv = !!homogeneousv;
|
2019-03-08 05:22:12 -08:00
|
|
|
efl_pack_layout_request(obj);
|
2019-02-27 11:45:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_table_homogeneous_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd, Eina_Bool *homogeneoush, Eina_Bool *homogeneousv)
|
|
|
|
{
|
|
|
|
if (homogeneoush) *homogeneoush = pd->homogeneoush;
|
|
|
|
if (homogeneousv) *homogeneousv = pd->homogeneousv;
|
|
|
|
}
|
|
|
|
|
2016-04-18 04:17:24 -07:00
|
|
|
EOLIAN static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_layout_layout_update(Eo *obj, Efl_Ui_Table_Data *pd)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
efl_ui_table: refactor layout_update
Summary:
There are three reasons to refactor layout_update of Efl.Ui.Table.
=== 1. Inconsistency of hint behavior. ===
Some hint property is often not respected. for example, hint_min is ignored in
Table when it is used with hint_max even if hint_weight is 0. hint_aspect is
always ignored in Table.
The ambiguous behavior make it hard to layout widgets in container. of course,
we documented 'it's just a hint that should be used whenever appropriate.' but i
don't think it means that 'hint API is sometimes respected and we also don't
know when that API is respected.'. at least there is rule for consistent
behavior and we should be able to explain why a widget is located here and
why some hint property is ignored.
So, i'll suggest priority of hint property. this refactoring support following
priority.
1) HintMin
2) HintMin + HintAspect
3) HintMargin
4) HintMax
5) HintAspect
6) HintWeight, HintFill
7) HintAlign
ref T5487
Please check with unit test D7840
=== 2. To Enhance usability. ===
Efl.Ui.Table is using homogeneous mode of evas_table which have same columns,
rows size. but i think a table can generally change columns, rows size and
we can provide homogeneous mode option.(D7892)
In this patch
- table columns(rows) min size is decided by maximum size among its cells
width(height) min size.
- table columns(rows) weight is decided by maximum weight among its cells
horizontal(vertical) weight.
Also, pack_align is implemented. it is used if no item has a weight.
=== 3. To remove internal evas_table. ===
This is low priority work. however, i guess is is necessary for lightweight
container widget. there are two size_hint callback to adjust table size and
efl_canvas_group_calculate is called twice when it is resized.
This patch is first step to remove internal evas_table.
Test Plan:
make check
elementary_test -to 'efl.ui.table'
Reviewers: jpeg, Jaehyun_Cho, zmike
Reviewed By: zmike
Subscribers: zmike, cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T5487
Differential Revision: https://phab.enlightenment.org/D7841
2019-02-27 11:45:27 -08:00
|
|
|
_efl_ui_table_custom_layout(obj, pd);
|
2016-04-18 04:17:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED)
|
2016-04-18 04:17:24 -07:00
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
|
|
|
efl_pack_layout_update(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Table_Data *pd)
|
2016-04-18 04:17:24 -07:00
|
|
|
{
|
|
|
|
Custom_Table_Data *custom;
|
2016-04-11 22:10:47 -07:00
|
|
|
Evas_Object *table;
|
|
|
|
|
|
|
|
elm_widget_sub_object_parent_add(obj);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
table = efl_add(CUSTOM_TABLE_CLASS, obj);
|
|
|
|
custom = efl_data_scope_get(table, CUSTOM_TABLE_CLASS);
|
2016-04-18 04:17:24 -07:00
|
|
|
custom->gd = pd;
|
|
|
|
custom->parent = obj;
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
evas_object_table_homogeneous_set(table, EVAS_OBJECT_TABLE_HOMOGENEOUS_TABLE);
|
2017-08-08 05:06:43 -07:00
|
|
|
elm_widget_resize_object_set(obj, table);
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
evas_object_event_callback_add
|
2016-04-19 01:43:28 -07:00
|
|
|
(table, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _table_size_hints_changed, obj);
|
efl_ui_table: refactor layout_update
Summary:
There are three reasons to refactor layout_update of Efl.Ui.Table.
=== 1. Inconsistency of hint behavior. ===
Some hint property is often not respected. for example, hint_min is ignored in
Table when it is used with hint_max even if hint_weight is 0. hint_aspect is
always ignored in Table.
The ambiguous behavior make it hard to layout widgets in container. of course,
we documented 'it's just a hint that should be used whenever appropriate.' but i
don't think it means that 'hint API is sometimes respected and we also don't
know when that API is respected.'. at least there is rule for consistent
behavior and we should be able to explain why a widget is located here and
why some hint property is ignored.
So, i'll suggest priority of hint property. this refactoring support following
priority.
1) HintMin
2) HintMin + HintAspect
3) HintMargin
4) HintMax
5) HintAspect
6) HintWeight, HintFill
7) HintAlign
ref T5487
Please check with unit test D7840
=== 2. To Enhance usability. ===
Efl.Ui.Table is using homogeneous mode of evas_table which have same columns,
rows size. but i think a table can generally change columns, rows size and
we can provide homogeneous mode option.(D7892)
In this patch
- table columns(rows) min size is decided by maximum size among its cells
width(height) min size.
- table columns(rows) weight is decided by maximum weight among its cells
horizontal(vertical) weight.
Also, pack_align is implemented. it is used if no item has a weight.
=== 3. To remove internal evas_table. ===
This is low priority work. however, i guess is is necessary for lightweight
container widget. there are two size_hint callback to adjust table size and
efl_canvas_group_calculate is called twice when it is resized.
This patch is first step to remove internal evas_table.
Test Plan:
make check
elementary_test -to 'efl.ui.table'
Reviewers: jpeg, Jaehyun_Cho, zmike
Reviewed By: zmike
Subscribers: zmike, cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T5487
Differential Revision: https://phab.enlightenment.org/D7841
2019-02-27 11:45:27 -08:00
|
|
|
efl_event_callback_add(obj, EFL_GFX_ENTITY_EVENT_HINTS_CHANGED,
|
|
|
|
_efl_ui_table_size_hints_changed_cb, NULL);
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
|
|
|
elm_widget_highlight_ignore_set(obj, EINA_FALSE);
|
|
|
|
|
2017-10-23 22:03:46 -07:00
|
|
|
efl_ui_widget_theme_apply(obj);
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evas_Object *child;
|
|
|
|
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
|
|
|
evas_object_event_callback_del_full
|
2016-04-19 01:43:28 -07:00
|
|
|
(wd->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_table_size_hints_changed, obj);
|
efl_ui_table: refactor layout_update
Summary:
There are three reasons to refactor layout_update of Efl.Ui.Table.
=== 1. Inconsistency of hint behavior. ===
Some hint property is often not respected. for example, hint_min is ignored in
Table when it is used with hint_max even if hint_weight is 0. hint_aspect is
always ignored in Table.
The ambiguous behavior make it hard to layout widgets in container. of course,
we documented 'it's just a hint that should be used whenever appropriate.' but i
don't think it means that 'hint API is sometimes respected and we also don't
know when that API is respected.'. at least there is rule for consistent
behavior and we should be able to explain why a widget is located here and
why some hint property is ignored.
So, i'll suggest priority of hint property. this refactoring support following
priority.
1) HintMin
2) HintMin + HintAspect
3) HintMargin
4) HintMax
5) HintAspect
6) HintWeight, HintFill
7) HintAlign
ref T5487
Please check with unit test D7840
=== 2. To Enhance usability. ===
Efl.Ui.Table is using homogeneous mode of evas_table which have same columns,
rows size. but i think a table can generally change columns, rows size and
we can provide homogeneous mode option.(D7892)
In this patch
- table columns(rows) min size is decided by maximum size among its cells
width(height) min size.
- table columns(rows) weight is decided by maximum weight among its cells
horizontal(vertical) weight.
Also, pack_align is implemented. it is used if no item has a weight.
=== 3. To remove internal evas_table. ===
This is low priority work. however, i guess is is necessary for lightweight
container widget. there are two size_hint callback to adjust table size and
efl_canvas_group_calculate is called twice when it is resized.
This patch is first step to remove internal evas_table.
Test Plan:
make check
elementary_test -to 'efl.ui.table'
Reviewers: jpeg, Jaehyun_Cho, zmike
Reviewed By: zmike
Subscribers: zmike, cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T5487
Differential Revision: https://phab.enlightenment.org/D7841
2019-02-27 11:45:27 -08:00
|
|
|
efl_event_callback_del(obj, EFL_GFX_ENTITY_EVENT_HINTS_CHANGED,
|
|
|
|
_efl_ui_table_size_hints_changed_cb, NULL);
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
/* let's make our table object the *last* to be processed, since it
|
|
|
|
* may (smart) parent other sub objects here */
|
|
|
|
EINA_LIST_FOREACH(wd->subobjs, l, child)
|
|
|
|
{
|
|
|
|
if (child == wd->resize_obj)
|
|
|
|
{
|
|
|
|
wd->subobjs =
|
2016-04-19 01:43:28 -07:00
|
|
|
eina_list_demote_list(wd->subobjs, l);
|
2016-04-11 22:10:47 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_del(efl_super(obj, MY_CLASS));
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eo *
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_object_constructor(Eo *obj, Efl_Ui_Table_Data *pd)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
2016-06-20 21:26:15 -07:00
|
|
|
efl_canvas_object_type_set(obj, MY_CLASS_NAME);
|
2018-04-03 04:27:30 -07:00
|
|
|
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_FILLER);
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2017-08-09 07:36:02 -07:00
|
|
|
pd->dir1 = EFL_UI_DIR_RIGHT;
|
|
|
|
pd->dir2 = EFL_UI_DIR_DOWN;
|
2016-04-14 00:41:57 -07:00
|
|
|
pd->last_col = -1;
|
|
|
|
pd->last_row = -1;
|
|
|
|
pd->req_cols = 0;
|
|
|
|
pd->req_rows = 0;
|
efl_ui_table: refactor layout_update
Summary:
There are three reasons to refactor layout_update of Efl.Ui.Table.
=== 1. Inconsistency of hint behavior. ===
Some hint property is often not respected. for example, hint_min is ignored in
Table when it is used with hint_max even if hint_weight is 0. hint_aspect is
always ignored in Table.
The ambiguous behavior make it hard to layout widgets in container. of course,
we documented 'it's just a hint that should be used whenever appropriate.' but i
don't think it means that 'hint API is sometimes respected and we also don't
know when that API is respected.'. at least there is rule for consistent
behavior and we should be able to explain why a widget is located here and
why some hint property is ignored.
So, i'll suggest priority of hint property. this refactoring support following
priority.
1) HintMin
2) HintMin + HintAspect
3) HintMargin
4) HintMax
5) HintAspect
6) HintWeight, HintFill
7) HintAlign
ref T5487
Please check with unit test D7840
=== 2. To Enhance usability. ===
Efl.Ui.Table is using homogeneous mode of evas_table which have same columns,
rows size. but i think a table can generally change columns, rows size and
we can provide homogeneous mode option.(D7892)
In this patch
- table columns(rows) min size is decided by maximum size among its cells
width(height) min size.
- table columns(rows) weight is decided by maximum weight among its cells
horizontal(vertical) weight.
Also, pack_align is implemented. it is used if no item has a weight.
=== 3. To remove internal evas_table. ===
This is low priority work. however, i guess is is necessary for lightweight
container widget. there are two size_hint callback to adjust table size and
efl_canvas_group_calculate is called twice when it is resized.
This patch is first step to remove internal evas_table.
Test Plan:
make check
elementary_test -to 'efl.ui.table'
Reviewers: jpeg, Jaehyun_Cho, zmike
Reviewed By: zmike
Subscribers: zmike, cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T5487
Differential Revision: https://phab.enlightenment.org/D7841
2019-02-27 11:45:27 -08:00
|
|
|
pd->align.h = 0.5;
|
|
|
|
pd->align.v = 0.5;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2016-04-18 04:17:24 -07:00
|
|
|
|
|
|
|
|
2016-04-11 22:10:47 -07:00
|
|
|
EOLIAN static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_pack_padding_set(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED, double h, double v, Eina_Bool scalable)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
|
|
|
if (h < 0) h = 0;
|
|
|
|
if (v < 0) v = 0;
|
|
|
|
pd->pad.h = h;
|
|
|
|
pd->pad.v = v;
|
|
|
|
pd->pad.scalable = !!scalable;
|
|
|
|
if (pd->pad.scalable)
|
|
|
|
{
|
|
|
|
double scale = elm_object_scale_get(obj);
|
|
|
|
evas_object_table_padding_set(wd->resize_obj, h * scale, v * scale);
|
|
|
|
}
|
|
|
|
else
|
2016-04-19 01:43:28 -07:00
|
|
|
evas_object_table_padding_set(wd->resize_obj, h, v);
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_table_efl_pack_pack_padding_get(const Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED, double *h, double *v, Eina_Bool *scalable)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
|
|
|
if (scalable) *scalable = pd->pad.scalable;
|
|
|
|
if (h) *h = pd->pad.h;
|
|
|
|
if (v) *v = pd->pad.v;
|
|
|
|
}
|
|
|
|
|
efl_ui_table: refactor layout_update
Summary:
There are three reasons to refactor layout_update of Efl.Ui.Table.
=== 1. Inconsistency of hint behavior. ===
Some hint property is often not respected. for example, hint_min is ignored in
Table when it is used with hint_max even if hint_weight is 0. hint_aspect is
always ignored in Table.
The ambiguous behavior make it hard to layout widgets in container. of course,
we documented 'it's just a hint that should be used whenever appropriate.' but i
don't think it means that 'hint API is sometimes respected and we also don't
know when that API is respected.'. at least there is rule for consistent
behavior and we should be able to explain why a widget is located here and
why some hint property is ignored.
So, i'll suggest priority of hint property. this refactoring support following
priority.
1) HintMin
2) HintMin + HintAspect
3) HintMargin
4) HintMax
5) HintAspect
6) HintWeight, HintFill
7) HintAlign
ref T5487
Please check with unit test D7840
=== 2. To Enhance usability. ===
Efl.Ui.Table is using homogeneous mode of evas_table which have same columns,
rows size. but i think a table can generally change columns, rows size and
we can provide homogeneous mode option.(D7892)
In this patch
- table columns(rows) min size is decided by maximum size among its cells
width(height) min size.
- table columns(rows) weight is decided by maximum weight among its cells
horizontal(vertical) weight.
Also, pack_align is implemented. it is used if no item has a weight.
=== 3. To remove internal evas_table. ===
This is low priority work. however, i guess is is necessary for lightweight
container widget. there are two size_hint callback to adjust table size and
efl_canvas_group_calculate is called twice when it is resized.
This patch is first step to remove internal evas_table.
Test Plan:
make check
elementary_test -to 'efl.ui.table'
Reviewers: jpeg, Jaehyun_Cho, zmike
Reviewed By: zmike
Subscribers: zmike, cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T5487
Differential Revision: https://phab.enlightenment.org/D7841
2019-02-27 11:45:27 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_table_efl_pack_pack_align_set(Eo *obj, Efl_Ui_Table_Data *pd, double h, double v)
|
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
|
|
|
if (h < 0) h = -1;
|
|
|
|
if (v < 0) v = -1;
|
|
|
|
if (h > 1) h = 1;
|
|
|
|
if (v > 1) v = 1;
|
|
|
|
pd->align.h = h;
|
|
|
|
pd->align.v = v;
|
|
|
|
|
|
|
|
efl_pack_layout_request(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_table_efl_pack_pack_align_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd, double *h, double *v)
|
|
|
|
{
|
|
|
|
if (h) *h = pd->align.h;
|
|
|
|
if (v) *v = pd->align.v;
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_subobj_del_cb(void *data, const Efl_Event *event)
|
2016-04-14 00:41:57 -07:00
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
Efl_Ui_Table *obj = data;
|
|
|
|
Efl_Ui_Table_Data *pd = efl_data_scope_get(obj, EFL_UI_TABLE_CLASS);
|
2016-04-14 00:41:57 -07:00
|
|
|
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_array_del(event->object, subobj_callbacks(), data);
|
2016-05-18 08:17:36 -07:00
|
|
|
_item_remove(obj, pd, event->object);
|
2016-04-14 00:41:57 -07:00
|
|
|
|
2016-05-18 08:17:36 -07:00
|
|
|
if (!elm_widget_sub_object_del(obj, event->object))
|
2016-04-14 00:41:57 -07:00
|
|
|
WRN("failed to remove child from its parent");
|
|
|
|
}
|
|
|
|
|
2016-04-25 23:21:21 -07:00
|
|
|
static Eina_Bool
|
2018-04-05 01:47:26 -07:00
|
|
|
_pack_at(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Gfx_Entity *subobj,
|
2016-04-14 00:41:57 -07:00
|
|
|
int col, int row, int colspan, int rowspan, Eina_Bool linear)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
Table_Item *gi = NULL;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2016-04-25 23:21:21 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
|
|
|
|
2016-04-11 22:10:47 -07:00
|
|
|
if (col < 0) col = 0;
|
|
|
|
if (row < 0) row = 0;
|
2016-04-14 00:41:57 -07:00
|
|
|
|
|
|
|
// note: we could have colspan = -1 mean "full width" if req_cols is set?
|
2016-04-11 22:10:47 -07:00
|
|
|
if (colspan < 1) colspan = 1;
|
|
|
|
if (rowspan < 1) rowspan = 1;
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
if (((int64_t) col + (int64_t) colspan) > (int64_t) INT_MAX)
|
|
|
|
colspan = INT_MAX - col;
|
|
|
|
|
|
|
|
if (((int64_t) row + (int64_t) rowspan) > (int64_t) INT_MAX)
|
|
|
|
rowspan = INT_MAX - row;
|
|
|
|
|
|
|
|
if ((pd->req_cols && ((col + colspan) > pd->req_cols)) ||
|
|
|
|
(pd->req_rows && ((row + rowspan) > pd->req_rows)))
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
ERR("table requested size exceeded! packing in extra cell at "
|
|
|
|
"%d,%d %dx%d (table: %dx%d)",
|
2016-04-14 00:41:57 -07:00
|
|
|
col, row, colspan, rowspan, pd->req_cols, pd->req_rows);
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
2016-04-14 00:41:57 -07:00
|
|
|
|
|
|
|
if (obj == elm_widget_parent_widget_get(subobj))
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
gi = efl_key_data_get(subobj, TABLE_ITEM_KEY);
|
2016-04-14 00:41:57 -07:00
|
|
|
if (gi)
|
|
|
|
{
|
|
|
|
gi->col = col;
|
|
|
|
gi->row = row;
|
|
|
|
gi->col_span = colspan;
|
|
|
|
gi->row_span = rowspan;
|
|
|
|
gi->linear = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else ERR("object is a child but internal data was not found!");
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
if (!gi)
|
2016-04-13 22:12:16 -07:00
|
|
|
{
|
2016-04-14 00:41:57 -07:00
|
|
|
gi = calloc(1, sizeof(*gi));
|
2019-01-29 06:23:44 -08:00
|
|
|
if (!gi) return EINA_FALSE;
|
2016-04-14 00:41:57 -07:00
|
|
|
gi->col = col;
|
|
|
|
gi->row = row;
|
|
|
|
gi->col_span = colspan;
|
|
|
|
gi->row_span = rowspan;
|
|
|
|
gi->linear = !!linear;
|
|
|
|
gi->object = subobj; // xref(, obj);
|
|
|
|
pd->count++;
|
2017-12-18 21:13:58 -08:00
|
|
|
pd->items = (Table_Item *)
|
2016-04-14 00:41:57 -07:00
|
|
|
eina_inlist_append(EINA_INLIST_GET(pd->items), EINA_INLIST_GET(gi));
|
|
|
|
|
2017-12-18 21:13:58 -08:00
|
|
|
efl_key_data_set(subobj, TABLE_ITEM_KEY, gi);
|
2016-04-14 00:41:57 -07:00
|
|
|
elm_widget_sub_object_add(obj, subobj);
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(obj, EFL_CONTAINER_EVENT_CONTENT_ADDED, subobj);
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_array_add(subobj, subobj_callbacks(), obj);
|
2016-04-13 22:12:16 -07:00
|
|
|
}
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2016-04-25 23:21:21 -07:00
|
|
|
return evas_object_table_pack(wd->resize_obj, subobj, col, row, colspan, rowspan);
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2016-04-25 23:21:21 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_table_pack_table(Eo *obj, Efl_Ui_Table_Data *pd,
|
2018-04-05 01:47:26 -07:00
|
|
|
Efl_Gfx_Entity *subobj,
|
2016-04-14 00:41:57 -07:00
|
|
|
int col, int row, int colspan, int rowspan)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-25 23:21:21 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(subobj, EINA_FALSE);
|
2016-04-14 00:41:57 -07:00
|
|
|
|
2016-04-25 23:21:21 -07:00
|
|
|
return _pack_at(obj, pd, subobj, col, row, colspan, rowspan, EINA_FALSE);
|
2016-04-14 00:41:57 -07:00
|
|
|
}
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2016-04-18 04:17:24 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_table_efl_pack_table_table_position_get(const Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED, Evas_Object *subobj, int *col, int *row, int *colspan, int *rowspan)
|
2016-04-14 00:41:57 -07:00
|
|
|
{
|
|
|
|
int c = -1, r = -1, cs = 0, rs = 0;
|
2017-12-18 21:13:58 -08:00
|
|
|
Table_Item *gi;
|
2016-04-18 04:17:24 -07:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2016-04-14 00:41:57 -07:00
|
|
|
|
|
|
|
if (obj != elm_widget_parent_widget_get(subobj))
|
|
|
|
{
|
2018-04-06 11:31:03 -07:00
|
|
|
if (efl_invalidated_get(subobj)) goto end;
|
2016-04-14 00:41:57 -07:00
|
|
|
ERR("%p is not a child of %p", subobj, obj);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2017-12-18 21:13:58 -08:00
|
|
|
gi = efl_key_data_get(subobj, TABLE_ITEM_KEY);
|
2016-04-14 00:41:57 -07:00
|
|
|
if (gi)
|
|
|
|
{
|
|
|
|
c = gi->col;
|
|
|
|
r = gi->row;
|
|
|
|
cs = gi->col_span;
|
|
|
|
rs = gi->row_span;
|
|
|
|
}
|
|
|
|
|
2016-04-18 04:17:24 -07:00
|
|
|
ret = EINA_TRUE;
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
end:
|
|
|
|
if (col) *col = c;
|
|
|
|
if (row) *row = r;
|
|
|
|
if (colspan) *colspan = cs;
|
|
|
|
if (rowspan) *rowspan = rs;
|
2016-04-18 04:17:24 -07:00
|
|
|
return ret;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
EOLIAN static Efl_Gfx_Entity *
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_table_table_content_get(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED, int col, int row)
|
2016-04-13 22:12:16 -07:00
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
|
|
|
|
|
|
|
|
return evas_object_table_child_get(wd->resize_obj, col, row);
|
|
|
|
}
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
static void
|
2018-04-05 01:47:26 -07:00
|
|
|
_item_remove(Efl_Ui_Table *obj, Efl_Ui_Table_Data *pd, Efl_Gfx_Entity *subobj)
|
2016-04-14 00:41:57 -07:00
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
Table_Item *gi = efl_key_data_get(subobj, TABLE_ITEM_KEY);
|
|
|
|
Table_Item *gi2, *last = NULL;
|
2016-04-14 00:41:57 -07:00
|
|
|
|
|
|
|
if (!gi)
|
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
WRN("item %p has no table internal data", subobj);
|
2016-04-14 00:41:57 -07:00
|
|
|
EINA_INLIST_FOREACH(EINA_INLIST_GET(pd->items), gi)
|
|
|
|
if (gi->object == subobj)
|
|
|
|
break;
|
|
|
|
if (!gi)
|
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
ERR("item %p was not found in this table", subobj);
|
2016-04-14 00:41:57 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gi->linear)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(pd->items), gi2)
|
|
|
|
{
|
|
|
|
if (gi2 == gi) continue;
|
|
|
|
if (!gi2->linear) continue;
|
|
|
|
last = gi2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (last)
|
|
|
|
{
|
2017-08-09 07:36:02 -07:00
|
|
|
if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE))
|
2016-04-14 00:41:57 -07:00
|
|
|
{
|
|
|
|
pd->last_col = last->col + last->col_span - 1;
|
|
|
|
pd->last_row = last->row;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pd->last_row = last->row + last->row_span - 1;
|
|
|
|
pd->last_col = last->col;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pd->last_col = -1;
|
|
|
|
pd->last_row = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(obj, EFL_CONTAINER_EVENT_CONTENT_REMOVED, subobj);
|
2017-12-18 21:13:58 -08:00
|
|
|
pd->items = (Table_Item *)
|
2016-04-14 00:41:57 -07:00
|
|
|
eina_inlist_remove(EINA_INLIST_GET(pd->items), EINA_INLIST_GET(gi));
|
|
|
|
pd->count--;
|
2017-12-18 21:13:58 -08:00
|
|
|
efl_key_data_set(subobj, TABLE_ITEM_KEY, NULL);
|
2016-04-14 00:41:57 -07:00
|
|
|
free(gi);
|
|
|
|
}
|
|
|
|
|
2016-04-11 22:10:47 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-05 01:47:26 -07:00
|
|
|
_efl_ui_table_efl_pack_unpack(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Gfx_Entity *subobj)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
_item_remove(obj, pd, subobj);
|
2016-04-13 22:12:16 -07:00
|
|
|
if (evas_object_table_unpack(wd->resize_obj, subobj))
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-13 22:12:16 -07:00
|
|
|
if (elm_widget_sub_object_del(obj, subobj))
|
|
|
|
return EINA_TRUE;
|
2016-04-14 00:41:57 -07:00
|
|
|
return EINA_FALSE; // oops - unlikely
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-04-25 23:21:21 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_pack_clear(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-25 23:21:21 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
evas_object_table_clear(wd->resize_obj, EINA_TRUE);
|
2016-04-25 23:21:21 -07:00
|
|
|
return EINA_TRUE;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2016-04-25 23:21:21 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_unpack_all(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-25 23:21:21 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
evas_object_table_clear(wd->resize_obj, EINA_FALSE);
|
2016-04-25 23:21:21 -07:00
|
|
|
return EINA_TRUE;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2016-04-19 01:43:28 -07:00
|
|
|
EOLIAN static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_layout_layout_request(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
evas_object_smart_need_recalculate_set(obj, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2017-12-18 21:13:58 -08:00
|
|
|
_table_item_iterator_next(Table_Item_Iterator *it, void **data)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2018-04-05 01:47:26 -07:00
|
|
|
Efl_Gfx_Entity *sub;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
if (!eina_iterator_next(it->real_iterator, (void **) &sub))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
if (data) *data = sub;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2017-08-07 19:48:31 -07:00
|
|
|
static Eo *
|
2017-12-18 21:13:58 -08:00
|
|
|
_table_item_iterator_get_container(Table_Item_Iterator *it)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
return it->object;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_table_item_iterator_free(Table_Item_Iterator *it)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
eina_iterator_free(it->real_iterator);
|
|
|
|
eina_list_free(it->list);
|
|
|
|
free(it);
|
|
|
|
}
|
|
|
|
|
2016-04-19 01:43:28 -07:00
|
|
|
static inline Eina_Iterator *
|
2017-12-18 21:13:58 -08:00
|
|
|
_table_item_iterator_create(Eo *obj, Eina_List *list)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
Table_Item_Iterator *it;
|
2016-04-19 01:43:28 -07:00
|
|
|
if (!list) return NULL;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
it = calloc(1, sizeof(*it));
|
|
|
|
if (!it) return NULL;
|
|
|
|
|
|
|
|
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
|
|
|
|
|
2016-04-19 01:43:28 -07:00
|
|
|
it->list = list;
|
2016-04-11 22:10:47 -07:00
|
|
|
it->real_iterator = eina_list_iterator_new(it->list);
|
|
|
|
it->iterator.version = EINA_ITERATOR_VERSION;
|
2017-12-18 21:13:58 -08:00
|
|
|
it->iterator.next = FUNC_ITERATOR_NEXT(_table_item_iterator_next);
|
|
|
|
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_table_item_iterator_get_container);
|
|
|
|
it->iterator.free = FUNC_ITERATOR_FREE(_table_item_iterator_free);
|
2016-04-11 22:10:47 -07:00
|
|
|
it->object = obj;
|
|
|
|
|
|
|
|
return &it->iterator;
|
|
|
|
}
|
|
|
|
|
2016-04-19 01:43:28 -07:00
|
|
|
EOLIAN static Eina_Iterator *
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_container_content_iterate(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED)
|
2016-04-19 01:43:28 -07:00
|
|
|
{
|
|
|
|
Eina_List *list;
|
|
|
|
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
|
|
|
|
|
|
|
|
list = evas_object_table_children_get(wd->resize_obj);
|
2017-12-18 21:13:58 -08:00
|
|
|
return _table_item_iterator_create(obj, list);
|
2016-04-19 01:43:28 -07:00
|
|
|
}
|
|
|
|
|
2016-04-11 22:10:47 -07:00
|
|
|
EOLIAN static int
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_container_content_count(Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-14 00:41:57 -07:00
|
|
|
return pd->count;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2016-04-19 01:43:28 -07:00
|
|
|
EOLIAN static Eina_Iterator *
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_table_table_contents_get(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED,
|
2016-04-19 22:55:26 -07:00
|
|
|
int col, int row, Eina_Bool below)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-19 01:43:28 -07:00
|
|
|
Eina_List *list, *atlist = NULL;
|
|
|
|
Evas_Object *sobj;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
|
|
|
|
|
2016-04-19 01:43:28 -07:00
|
|
|
list = evas_object_table_children_get(wd->resize_obj);
|
|
|
|
EINA_LIST_FREE(list, sobj)
|
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
Table_Item *gi = efl_key_data_get(sobj, TABLE_ITEM_KEY);
|
2016-04-19 01:43:28 -07:00
|
|
|
if (!gi) continue;
|
|
|
|
|
|
|
|
if ((gi->col == col) && (gi->row == row))
|
|
|
|
atlist = eina_list_append(atlist, sobj);
|
|
|
|
else if (below)
|
|
|
|
{
|
|
|
|
if ((gi->col <= col) && (gi->col + gi->col_span >= col) &&
|
|
|
|
(gi->row <= row) && (gi->row + gi->row_span >= row))
|
|
|
|
atlist = eina_list_append(atlist, sobj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-18 21:13:58 -08:00
|
|
|
return _table_item_iterator_create(obj, atlist);
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Ui_Dir dir)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2017-08-09 07:36:02 -07:00
|
|
|
pd->dir1 = dir;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2017-08-09 07:36:02 -07:00
|
|
|
/* if both directions are either horizontal or vertical, need to adjust
|
|
|
|
* secondary direction (dir2) */
|
|
|
|
if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE) ==
|
|
|
|
efl_ui_dir_is_horizontal(pd->dir2, EINA_FALSE))
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2017-08-09 07:36:02 -07:00
|
|
|
if (!efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE))
|
|
|
|
pd->dir2 = EFL_UI_DIR_RIGHT;
|
2016-04-11 22:10:47 -07:00
|
|
|
else
|
2017-08-09 07:36:02 -07:00
|
|
|
pd->dir2 = EFL_UI_DIR_DOWN;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
efl_pack_layout_request(obj);
|
|
|
|
}
|
|
|
|
|
2017-08-09 07:36:02 -07:00
|
|
|
EOLIAN static Efl_Ui_Dir
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_table_efl_ui_direction_direction_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
return pd->dir1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_table_table_direction_set(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Ui_Dir primary, Efl_Ui_Dir secondary)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
pd->dir1 = primary;
|
|
|
|
pd->dir2 = secondary;
|
|
|
|
|
2017-08-09 07:36:02 -07:00
|
|
|
if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE) ==
|
|
|
|
efl_ui_dir_is_horizontal(pd->dir2, EINA_FALSE))
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2017-08-09 07:36:02 -07:00
|
|
|
ERR("specified two directions in the same axis, secondary directions "
|
2016-04-11 22:10:47 -07:00
|
|
|
" is reset to a valid default");
|
2017-08-09 07:36:02 -07:00
|
|
|
if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE))
|
|
|
|
pd->dir2 = EFL_UI_DIR_DOWN;
|
|
|
|
else
|
|
|
|
pd->dir2 = EFL_UI_DIR_RIGHT;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
efl_pack_layout_request(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_table_efl_pack_table_table_direction_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd, Efl_Ui_Dir *primary, Efl_Ui_Dir *secondary)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
if (primary) *primary = pd->dir1;
|
|
|
|
if (secondary) *secondary = pd->dir2;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_table_table_size_set(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED, int cols, int rows)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
if (cols < 0) cols = 0;
|
|
|
|
if (rows < 0) rows = 0;
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
pd->req_cols = cols;
|
|
|
|
pd->req_rows = rows;
|
|
|
|
|
|
|
|
efl_pack_layout_request(obj);
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_table_efl_pack_table_table_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd EINA_UNUSED, int *cols, int *rows)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2017-12-18 21:13:58 -08:00
|
|
|
if (cols) *cols = efl_pack_table_columns_get(obj);
|
|
|
|
if (rows) *rows = efl_pack_table_rows_get(obj);
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_table_table_columns_set(Eo *obj, Efl_Ui_Table_Data *pd, int columns)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-14 00:41:57 -07:00
|
|
|
pd->req_cols = columns;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
efl_pack_layout_request(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_table_efl_pack_table_table_columns_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-14 00:41:57 -07:00
|
|
|
if (!pd->req_cols)
|
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, 0);
|
|
|
|
int cols;
|
|
|
|
evas_object_table_col_row_size_get(wd->resize_obj, &cols, NULL);
|
|
|
|
return cols;
|
|
|
|
}
|
|
|
|
return pd->req_cols;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-12-18 21:13:58 -08:00
|
|
|
_efl_ui_table_efl_pack_table_table_rows_set(Eo *obj, Efl_Ui_Table_Data *pd, int rows)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-14 00:41:57 -07:00
|
|
|
pd->req_rows = rows;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
|
|
|
efl_pack_layout_request(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_table_efl_pack_table_table_rows_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-14 00:41:57 -07:00
|
|
|
if (!pd->req_rows)
|
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, 0);
|
|
|
|
int rows;
|
efl_ui_table: fix correct parameters of table_rows_get
Test Plan:
efl_pack_table_size_set(ui_table, 3, 4);
efl_pack_table_size_get(ui_table, &cols, &rows);
Check (cols, rows) are (3, 4)
Reviewers: Jaehyun_Cho, zmike, jpeg, bu5hm4n
Reviewed By: Jaehyun_Cho, bu5hm4n
Subscribers: bu5hm4n, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D7838
2019-02-22 03:05:39 -08:00
|
|
|
evas_object_table_col_row_size_get(wd->resize_obj, NULL, &rows);
|
2016-04-14 00:41:57 -07:00
|
|
|
return rows;
|
|
|
|
}
|
|
|
|
return pd->req_rows;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2016-04-25 23:21:21 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-05 01:47:26 -07:00
|
|
|
_efl_ui_table_efl_pack_pack(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED, Efl_Gfx_Entity *subobj)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
/* this is just an alias */
|
2016-04-25 23:21:21 -07:00
|
|
|
return efl_pack_end(obj, subobj);
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2016-04-25 23:21:21 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-05 01:47:26 -07:00
|
|
|
_efl_ui_table_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Gfx_Entity *subobj)
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
2016-04-25 23:21:21 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(subobj, EINA_FALSE);
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
int col = pd->last_col;
|
|
|
|
int row = pd->last_row;
|
2016-04-11 22:10:47 -07:00
|
|
|
|
2017-08-09 07:36:02 -07:00
|
|
|
if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE))
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
col++;
|
2016-04-14 00:41:57 -07:00
|
|
|
if (pd->req_cols && (col >= pd->req_cols))
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
col = 0;
|
|
|
|
row++;
|
|
|
|
}
|
2016-04-13 22:12:16 -07:00
|
|
|
if (row < 0) row = 0;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
row++;
|
2016-04-14 00:41:57 -07:00
|
|
|
if (pd->req_rows && (row >= pd->req_rows))
|
2016-04-11 22:10:47 -07:00
|
|
|
{
|
|
|
|
row = 0;
|
|
|
|
col++;
|
|
|
|
}
|
2016-04-13 22:12:16 -07:00
|
|
|
if (col < 0) col = 0;
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2016-04-14 00:41:57 -07:00
|
|
|
pd->last_col = col;
|
|
|
|
pd->last_row = row;
|
|
|
|
|
2016-04-11 22:10:47 -07:00
|
|
|
DBG("packing new obj at %d,%d", col, row);
|
2016-04-25 23:21:21 -07:00
|
|
|
return _pack_at(obj, pd, subobj, col, row, 1, 1, EINA_TRUE);
|
2016-04-11 22:10:47 -07:00
|
|
|
}
|
|
|
|
|
2017-05-18 01:52:17 -07:00
|
|
|
/* Internal EO APIs and hidden overrides */
|
|
|
|
|
2017-12-18 21:13:58 -08:00
|
|
|
#define EFL_UI_TABLE_EXTRA_OPS \
|
|
|
|
EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_table)
|
2017-05-18 01:52:17 -07:00
|
|
|
|
2017-12-18 21:13:58 -08:00
|
|
|
#include "efl_ui_table.eo.c"
|