Created
February 19, 2016 21:42
-
-
Save marcelhollerbach/4d6202a21be5834fc135 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void | |
_compute_node(Focus_Node *node, Eina_List *objects) | |
{ | |
int x = 0,y = 0,w = 0,h = 0; | |
Focus_Node *nodes[4], *r; | |
Eina_List *n; | |
int distances[4] = {-1, -1, -1, -1}; | |
evas_object_geometry_get(node->widget, &x, &y, &w, &h); | |
EINA_LIST_FOREACH(objects, n, r) | |
{ | |
int rx = 0,ry = 0,rw = 0,rh = 0; | |
int rel_x = 0, rel_y = 0; //relativ coords from new widget to old | |
int d; | |
if (r == node) continue; | |
evas_object_geometry_get(r->widget, &rx, &ry, &rw, &rh); | |
rel_x = rx+rw/2 - x+w/2; | |
rel_y = ry+rh/2 - y+h/2; | |
d = sqrt(powerof2(rel_x)+powerof2(rel_y)); | |
if (rel_x > 0) | |
_compare(d, r, distances, nodes, LEFT); | |
if (rel_x <= 0) | |
_compare(d, r, distances, nodes, RIGHT); | |
if (rel_y > 0) | |
_compare(d, r, distances, nodes, TOP); | |
if (rel_y <= 0) | |
_compare(d, r, distances, nodes, BOTTOM); | |
} | |
focus_node_connect(node, nodes[LEFT], LEFT); | |
focus_node_connect(node, nodes[RIGHT], RIGHT); | |
focus_node_connect(node, nodes[TOP], TOP); | |
focus_node_connect(node, nodes[BOTTOM], BOTTOM); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment