From 83821cd4e5651486eea7ea113a20ad302d726243 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 1 Nov 2017 15:23:09 +0100 Subject: [PATCH] WIP --- src/lib/Clouseau_Debug.h | 1 + src/lib/extensions/focus_inspector/gui.c | 3 + src/lib/extensions/focus_inspector/gui.h | 12 +++ .../extensions/focus_inspector/tree_view.c | 84 +++++++++++++++++++ 4 files changed, 100 insertions(+) diff --git a/src/lib/Clouseau_Debug.h b/src/lib/Clouseau_Debug.h index 3f3b863..9a798d6 100644 --- a/src/lib/Clouseau_Debug.h +++ b/src/lib/Clouseau_Debug.h @@ -118,6 +118,7 @@ typedef struct { typedef struct { Efl_Ui_Focus_Relations relation; const char *class_name; + Evas_Object *vis; } Clouseau_Focus_Relation; diff --git a/src/lib/extensions/focus_inspector/gui.c b/src/lib/extensions/focus_inspector/gui.c index b5dd5e8..9801025 100644 --- a/src/lib/extensions/focus_inspector/gui.c +++ b/src/lib/extensions/focus_inspector/gui.c @@ -98,6 +98,8 @@ ui_manager_data_arrived(Instance *inst, Clouseau_Focus_Manager_Data *data) EINA_LIST_FREE(inst->realized.objects, o) evas_object_del(o); + inst->realized.focusable_to_cfr = eina_hash_pointer_new(NULL); + inst->realized.data = data; elm_hoversel_clear(history); @@ -106,6 +108,7 @@ ui_manager_data_arrived(Instance *inst, Clouseau_Focus_Manager_Data *data) { if (rel->relation.position_in_history != -1) sorted = eina_list_sorted_insert(sorted, _sort, rel); + eina_hash_add(inst->realized.focusable_to_cfr, &rel->relation.node, rel); } EINA_LIST_FOREACH(sorted, n, rel) diff --git a/src/lib/extensions/focus_inspector/gui.h b/src/lib/extensions/focus_inspector/gui.h index 683afe0..140754e 100644 --- a/src/lib/extensions/focus_inspector/gui.h +++ b/src/lib/extensions/focus_inspector/gui.h @@ -7,14 +7,26 @@ typedef struct { Clouseau_Extension *ext; struct { + Eina_Hash *focusable_to_cfr; Eina_List *objects; Clouseau_Focus_Manager_Data *data; } realized; } Instance; +typedef enum { + RELATION_TREE = 0, + RELATION_NEXT = 1, + RELATION_PREV = 2, +/* RELATION_RIGHT = 3, + RELATION_LEFT = 4, + RELATION_TOP = 5, + RELATION_DOWN = 6*/ +} Relations; + #define PUSH_CLEANUP(inst, o) inst->realized.objects = eina_list_append(inst->realized.objects, o) EAPI void tree_view_update(Instance *inst, Evas_Object *scroller); +EAPI void tree_view_relation_display(Instance *inst, Relations rel); EAPI void ui_managers_add(Instance *inst, Efl_Ui_Focus_Manager **manager, int size); EAPI void ui_manager_data_arrived(Instance *inst, Clouseau_Focus_Manager_Data *data); diff --git a/src/lib/extensions/focus_inspector/tree_view.c b/src/lib/extensions/focus_inspector/tree_view.c index 94b652a..a13d480 100644 --- a/src/lib/extensions/focus_inspector/tree_view.c +++ b/src/lib/extensions/focus_inspector/tree_view.c @@ -57,6 +57,8 @@ tree_level(void *data, Instance *inst, Clouseau_Focus_Relation *relation) evas_object_size_hint_max_set(vis, maxw, maxh); evas_object_size_hint_min_set(vis, minw, minh); + relation->vis = vis; + PUSH_CLEANUP(inst, vis); childbox = evas_object_box_add(evas_object_evas_get(data)); @@ -88,4 +90,86 @@ tree_view_update(Instance *inst, Evas_Object *scroller) find(inst, NULL, tree_level, box); elm_object_content_set(scroller, box); + + tree_view_relation_display(inst, RELATION_NEXT); +} + +static void +_geom_change(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Eina_Rectangle pos1, pos2; + Eina_Position2D calc_from, calc_to, from, to; + Evas_Object *line, *vis1, *vis2; + + line = data; + vis1 = evas_object_data_get(line, "__from"); + vis2 = evas_object_data_get(line, "__to"); + + evas_object_geometry_get(vis1, &pos1.x, &pos1.y, &pos1.w, &pos1.h); + evas_object_geometry_get(vis2, &pos2.x, &pos2.y, &pos2.w, &pos2.h); + + from.x = pos1.x + pos1.w / 2; + from.y = pos1.y + pos1.h / 2; + to.x = pos2.x + pos2.w / 2; + to.y = pos2.y + pos2.h / 2; + + evas_object_line_xy_set(line, from.x, from.y, to.x, to.y); +} + +static void +_relation_display(Instance *inst, Evas_Object *vis1, Evas_Object *vis2) +{ + Evas_Object *line; + + line = evas_object_line_add(evas_object_evas_get(vis1)); + evas_object_anti_alias_set(line, EINA_FALSE); + evas_object_geometry_set(line, 0, 0, 1000, 1000); + evas_object_pass_events_set(line, EINA_TRUE); + evas_object_data_set(line, "__from", vis1); + evas_object_data_set(line, "__to", vis2); + evas_object_show(line); + + PUSH_CLEANUP(inst, line); + + evas_object_event_callback_add(vis1, EVAS_CALLBACK_MOVE, _geom_change, line); + evas_object_event_callback_add(vis1, EVAS_CALLBACK_RESIZE, _geom_change, line); + evas_object_event_callback_add(vis2, EVAS_CALLBACK_MOVE, _geom_change, line); + evas_object_event_callback_add(vis2, EVAS_CALLBACK_RESIZE, _geom_change, line); +} + +EAPI void +tree_view_relation_display(Instance *inst, Relations rel_type) +{ + if (rel_type == RELATION_TREE || rel_type == RELATION_NEXT || rel_type == RELATION_PREV) + { + Clouseau_Focus_Relation *rel; + Eina_List *n; + + EINA_LIST_FOREACH(inst->realized.data->relations, n, rel) + { + Eo *relation_partner; + + if (rel_type == RELATION_TREE) + { + relation_partner = rel->relation.parent; + if (!rel->relation.parent) continue; + } + else if (rel_type == RELATION_NEXT) + { + relation_partner = rel->relation.next; + } + else if (rel_type == RELATION_PREV) + { + relation_partner = rel->relation.prev; + } + + Clouseau_Focus_Relation *c = eina_hash_find(inst->realized.focusable_to_cfr, &relation_partner); + + EINA_SAFETY_ON_NULL_GOTO(c, next); + + _relation_display(inst, c->vis, rel->vis); + next: + n = n; + } + } }