2006-02-02 01:42:19 -08:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
|
|
|
#include "e.h"
|
|
|
|
|
|
|
|
static void _e_gadcon_free(E_Gadcon *gc);
|
|
|
|
static void _e_gadcon_client_free(E_Gadcon_Client *gcc);
|
|
|
|
|
2006-02-05 00:17:40 -08:00
|
|
|
static Evas_Object *e_gadcon_layout_add(Evas *evas);
|
|
|
|
static void e_gadcon_layout_orientation_set(Evas_Object *obj, int horizontal);
|
|
|
|
static int e_gadcon_layout_pack(Evas_Object *obj, Evas_Object *child);
|
|
|
|
static void e_gadcon_layout_pack_size_set(Evas_Object *obj, int size);
|
|
|
|
static void e_gadcon_layout_pack_initial_set(Evas_Object *obj, double pos, int size);
|
|
|
|
static void e_gadcon_layout_pack_options_set(Evas_Object *obj, int pos, int size);
|
|
|
|
static void e_gadcon_layout_unpack(Evas_Object *obj);
|
|
|
|
|
|
|
|
static Evas_List *providers = NULL;
|
|
|
|
|
|
|
|
static E_Gadcon_Client *
|
|
|
|
__test(E_Gadcon *gc, char *name)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
E_Gadcon_Client *gcc;
|
|
|
|
double p;
|
|
|
|
|
|
|
|
printf("create gadcon client \"%s\" for \"%s\" \"%s\"\n",
|
|
|
|
name, gc->name, gc->id);
|
|
|
|
o = evas_object_rectangle_add(gc->evas);
|
|
|
|
evas_object_color_set(o, rand() & 0xff, rand() & 0xff, rand() & 0xff, 150);
|
|
|
|
gcc = e_gadcon_client_new(gc, name, o);
|
|
|
|
p = (double)(rand() % 5) / 4.0;
|
|
|
|
e_gadcon_layout_pack_initial_set(o, p, 32 + (rand() & 0x2f));
|
|
|
|
gcc->data = NULL;
|
|
|
|
return gcc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
__test2(E_Gadcon_Client *gcc)
|
|
|
|
{
|
|
|
|
evas_object_del(gcc->o_base);
|
|
|
|
}
|
|
|
|
|
2006-02-02 01:42:19 -08:00
|
|
|
/* externally accessible functions */
|
|
|
|
EAPI int
|
|
|
|
e_gadcon_init(void)
|
|
|
|
{
|
2006-02-05 00:17:40 -08:00
|
|
|
{
|
|
|
|
static E_Gadcon_Client_Class cc =
|
|
|
|
{
|
|
|
|
GADCON_CLIENT_CLASS_VERSION,
|
|
|
|
"test0",
|
|
|
|
{
|
|
|
|
__test, __test2, NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
e_gadcon_provider_register(&cc);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
static E_Gadcon_Client_Class cc =
|
|
|
|
{
|
|
|
|
GADCON_CLIENT_CLASS_VERSION,
|
|
|
|
"test2",
|
|
|
|
{
|
|
|
|
__test, __test2, NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
e_gadcon_provider_register(&cc);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
static E_Gadcon_Client_Class cc =
|
|
|
|
{
|
|
|
|
GADCON_CLIENT_CLASS_VERSION,
|
|
|
|
"test3",
|
|
|
|
{
|
|
|
|
__test, __test2, NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
e_gadcon_provider_register(&cc);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
static E_Gadcon_Client_Class cc =
|
|
|
|
{
|
|
|
|
GADCON_CLIENT_CLASS_VERSION,
|
|
|
|
"test3",
|
|
|
|
{
|
|
|
|
__test, __test2, NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
e_gadcon_provider_register(&cc);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
static E_Gadcon_Client_Class cc =
|
|
|
|
{
|
|
|
|
GADCON_CLIENT_CLASS_VERSION,
|
|
|
|
"test4",
|
|
|
|
{
|
|
|
|
__test, __test2, NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
e_gadcon_provider_register(&cc);
|
|
|
|
}
|
|
|
|
|
2006-02-02 01:42:19 -08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
e_gadcon_shutdown(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-02-05 00:17:40 -08:00
|
|
|
EAPI void
|
|
|
|
e_gadcon_provider_register(E_Gadcon_Client_Class *cc)
|
|
|
|
{
|
|
|
|
providers = evas_list_append(providers, cc);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_gadcon_provider_unregister(E_Gadcon_Client_Class *cc)
|
|
|
|
{
|
|
|
|
providers = evas_list_remove(providers, cc);
|
|
|
|
}
|
|
|
|
|
2006-02-02 01:42:19 -08:00
|
|
|
EAPI E_Gadcon *
|
2006-02-05 00:17:40 -08:00
|
|
|
e_gadcon_swallowed_new(char *name, char *id, Evas_Object *obj, char *swallow_name)
|
2006-02-02 01:42:19 -08:00
|
|
|
{
|
|
|
|
E_Gadcon *gc;
|
|
|
|
|
|
|
|
gc = E_OBJECT_ALLOC(E_Gadcon, E_GADCON_TYPE, _e_gadcon_free);
|
|
|
|
if (!gc) return NULL;
|
|
|
|
|
2006-02-05 00:17:40 -08:00
|
|
|
gc->name = strdup(name);
|
|
|
|
gc->id = strdup(id);
|
2006-02-02 01:42:19 -08:00
|
|
|
gc->edje.o_parent = obj;
|
|
|
|
gc->edje.swallow_name = strdup(swallow_name);
|
|
|
|
|
2006-02-05 00:17:40 -08:00
|
|
|
gc->orient = E_GADCON_ORIENT_HORIZ;
|
|
|
|
gc->evas = evas_object_evas_get(obj);
|
|
|
|
gc->o_container = e_gadcon_layout_add(gc->evas);
|
|
|
|
evas_object_show(gc->o_container);
|
|
|
|
edje_object_part_swallow(gc->edje.o_parent, gc->edje.swallow_name, gc->o_container);
|
2006-02-02 01:42:19 -08:00
|
|
|
return gc;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2006-02-05 00:17:40 -08:00
|
|
|
e_gadcon_populate(E_Gadcon *gc)
|
2006-02-02 01:42:19 -08:00
|
|
|
{
|
2006-02-05 00:17:40 -08:00
|
|
|
Evas_List *l;
|
|
|
|
int i;
|
|
|
|
|
2006-02-02 01:42:19 -08:00
|
|
|
E_OBJECT_CHECK_RETURN(gc, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, NULL);
|
2006-02-05 00:17:40 -08:00
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
/* hardcoded 4 sample clients
|
|
|
|
* "test0" "test1" "test2" "test3"
|
|
|
|
*/
|
|
|
|
snprintf(buf, sizeof(buf), "test%i", i);
|
|
|
|
for (l = providers; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Gadcon_Client_Class *cc;
|
|
|
|
|
|
|
|
cc = l->data;
|
|
|
|
if ((cc->name) && (!strcmp(cc->name, buf)))
|
|
|
|
{
|
|
|
|
E_Gadcon_Client *gcc;
|
|
|
|
|
|
|
|
gcc = cc->func.init(gc, cc->name);
|
|
|
|
if (gcc)
|
|
|
|
{
|
|
|
|
gcc->client_class = *cc;
|
|
|
|
if (gcc->client_class.func.orient)
|
|
|
|
gcc->client_class.func.orient(gcc);
|
|
|
|
/* FIXME: apply saved config */
|
|
|
|
// e_gadcon_layout_pack_options_set(gcc->o_base, pos, size, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-02 01:42:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2006-02-05 00:17:40 -08:00
|
|
|
e_gadcon_orient(E_Gadcon *gc, E_Gadcon_Orient orient)
|
2006-02-02 01:42:19 -08:00
|
|
|
{
|
2006-02-05 00:17:40 -08:00
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (gc->orient == orient) return;
|
|
|
|
gc->orient = orient;
|
|
|
|
for (l = gc->clients; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Gadcon_Client *gcc;
|
|
|
|
|
|
|
|
gcc = l->data;
|
|
|
|
if (gcc->client_class.func.orient)
|
|
|
|
gcc->client_class.func.orient(gcc);
|
|
|
|
}
|
2006-02-02 01:42:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI E_Gadcon_Client *
|
2006-02-05 00:17:40 -08:00
|
|
|
e_gadcon_client_new(E_Gadcon *gc, char *name, Evas_Object *base_obj)
|
2006-02-02 01:42:19 -08:00
|
|
|
{
|
|
|
|
E_Gadcon_Client *gcc;
|
|
|
|
|
|
|
|
E_OBJECT_CHECK_RETURN(gc, NULL);
|
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, NULL);
|
|
|
|
|
|
|
|
gcc = E_OBJECT_ALLOC(E_Gadcon_Client, E_GADCON_CLIENT_TYPE, _e_gadcon_client_free);
|
|
|
|
if (!gcc) return NULL;
|
|
|
|
gcc->gadcon = gc;
|
2006-02-05 00:17:40 -08:00
|
|
|
gcc->o_base = base_obj;
|
|
|
|
gcc->name = strdup(name);
|
2006-02-02 01:42:19 -08:00
|
|
|
gc->clients = evas_list_append(gc->clients, gcc);
|
2006-02-05 00:17:40 -08:00
|
|
|
e_gadcon_layout_pack(gc->o_container, gcc->o_base);
|
|
|
|
evas_object_show(gcc->o_base);
|
2006-02-02 01:42:19 -08:00
|
|
|
return gcc;
|
|
|
|
}
|
|
|
|
|
2006-02-05 00:17:40 -08:00
|
|
|
EAPI void
|
|
|
|
e_gadcon_client_size_request(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-02-02 01:42:19 -08:00
|
|
|
/* local subsystem functions */
|
|
|
|
static void
|
|
|
|
_e_gadcon_free(E_Gadcon *gc)
|
|
|
|
{
|
|
|
|
if (gc->o_container) evas_object_del(gc->o_container);
|
2006-02-05 00:17:40 -08:00
|
|
|
E_FREE(gc->name);
|
|
|
|
E_FREE(gc->id);
|
2006-02-02 01:42:19 -08:00
|
|
|
E_FREE(gc->edje.swallow_name);
|
|
|
|
free(gc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_client_free(E_Gadcon_Client *gcc)
|
|
|
|
{
|
|
|
|
gcc->gadcon->clients = evas_list_remove(gcc->gadcon->clients, gcc);
|
2006-02-05 00:17:40 -08:00
|
|
|
E_FREE(gcc->name);
|
2006-02-02 01:42:19 -08:00
|
|
|
free(gcc);
|
|
|
|
}
|
2006-02-05 00:17:40 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _E_Smart_Data E_Smart_Data;
|
|
|
|
typedef struct _E_Gadcon_Layout_Item E_Gadcon_Layout_Item;
|
|
|
|
|
|
|
|
struct _E_Smart_Data
|
|
|
|
{
|
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas_Object *clip;
|
|
|
|
unsigned char horizontal : 1;
|
|
|
|
Evas_List *items;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _E_Gadcon_Layout_Item
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
struct {
|
|
|
|
int pos, size, res;
|
|
|
|
} ask;
|
|
|
|
int hookp;
|
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
Evas_Object *obj;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* local subsystem functions */
|
|
|
|
static E_Gadcon_Layout_Item *_e_gadcon_layout_smart_adopt(E_Smart_Data *sd, Evas_Object *obj);
|
|
|
|
static void _e_gadcon_layout_smart_disown(Evas_Object *obj);
|
|
|
|
static void _e_gadcon_layout_smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
static void _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd);
|
|
|
|
|
|
|
|
static void _e_gadcon_layout_smart_init(void);
|
|
|
|
static void _e_gadcon_layout_smart_add(Evas_Object *obj);
|
|
|
|
static void _e_gadcon_layout_smart_del(Evas_Object *obj);
|
|
|
|
static void _e_gadcon_layout_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
|
|
|
static void _e_gadcon_layout_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
|
|
|
|
static void _e_gadcon_layout_smart_show(Evas_Object *obj);
|
|
|
|
static void _e_gadcon_layout_smart_hide(Evas_Object *obj);
|
|
|
|
static void _e_gadcon_layout_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
|
|
|
|
static void _e_gadcon_layout_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
|
|
|
|
static void _e_gadcon_layout_smart_clip_unset(Evas_Object *obj);
|
|
|
|
|
|
|
|
/* local subsystem globals */
|
|
|
|
static Evas_Smart *_e_smart = NULL;
|
|
|
|
|
|
|
|
/* externally accessible functions */
|
|
|
|
static Evas_Object *
|
|
|
|
e_gadcon_layout_add(Evas *evas)
|
|
|
|
{
|
|
|
|
_e_gadcon_layout_smart_init();
|
|
|
|
return evas_object_smart_add(evas, _e_smart);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
e_gadcon_layout_orientation_set(Evas_Object *obj, int horizontal)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
if (((sd->horizontal) && (horizontal)) ||
|
|
|
|
((!sd->horizontal) && (!horizontal))) return;
|
|
|
|
sd->horizontal = horizontal;
|
|
|
|
_e_gadcon_layout_smart_reconfigure(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
e_gadcon_layout_pack(Evas_Object *obj, Evas_Object *child)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return 0;
|
|
|
|
_e_gadcon_layout_smart_adopt(sd, child);
|
|
|
|
sd->items = evas_list_prepend(sd->items, child);
|
|
|
|
_e_gadcon_layout_smart_reconfigure(sd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
e_gadcon_layout_pack_size_set(Evas_Object *obj, int size)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
|
|
|
|
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
if (!bi) return;
|
|
|
|
bi->ask.size = size;
|
|
|
|
_e_gadcon_layout_smart_reconfigure(bi->sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
e_gadcon_layout_pack_initial_set(Evas_Object *obj, double pos, int size)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
|
|
|
|
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
if (!bi) return;
|
|
|
|
if (bi->sd->horizontal)
|
|
|
|
bi->ask.res = bi->sd->w;
|
|
|
|
else
|
|
|
|
bi->ask.res = bi->sd->h;
|
|
|
|
bi->ask.size = size;
|
|
|
|
bi->ask.pos = pos * (bi->ask.res - bi->ask.size);
|
|
|
|
_e_gadcon_layout_smart_reconfigure(bi->sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
e_gadcon_layout_pack_options_set(Evas_Object *obj, int pos, int size)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
|
|
|
|
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
if (!bi) return;
|
|
|
|
if (bi->sd->horizontal)
|
|
|
|
bi->ask.res = bi->sd->w;
|
|
|
|
else
|
|
|
|
bi->ask.res = bi->sd->h;
|
|
|
|
bi->ask.size = size;
|
|
|
|
bi->ask.pos = pos;
|
|
|
|
_e_gadcon_layout_smart_reconfigure(bi->sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
e_gadcon_layout_unpack(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
if (!bi) return;
|
|
|
|
sd = bi->sd;
|
|
|
|
if (!sd) return;
|
|
|
|
sd->items = evas_list_remove(sd->items, obj);
|
|
|
|
_e_gadcon_layout_smart_disown(obj);
|
|
|
|
_e_gadcon_layout_smart_reconfigure(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* local subsystem functions */
|
|
|
|
static E_Gadcon_Layout_Item *
|
|
|
|
_e_gadcon_layout_smart_adopt(E_Smart_Data *sd, Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
|
|
|
|
bi = calloc(1, sizeof(E_Gadcon_Layout_Item));
|
|
|
|
if (!bi) return NULL;
|
|
|
|
bi->sd = sd;
|
|
|
|
bi->obj = obj;
|
|
|
|
/* defaults */
|
|
|
|
evas_object_clip_set(obj, sd->clip);
|
|
|
|
evas_object_smart_member_add(obj, bi->sd->obj);
|
|
|
|
evas_object_data_set(obj, "e_gadcon_layout_data", bi);
|
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_FREE,
|
|
|
|
_e_gadcon_layout_smart_item_del_hook, NULL);
|
|
|
|
if ((!evas_object_visible_get(sd->clip)) &&
|
|
|
|
(evas_object_visible_get(sd->obj)))
|
|
|
|
evas_object_show(sd->clip);
|
|
|
|
return bi;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_disown(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
|
|
|
|
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
if (!bi) return;
|
|
|
|
if (!bi->sd->items)
|
|
|
|
{
|
|
|
|
if (evas_object_visible_get(bi->sd->clip))
|
|
|
|
evas_object_hide(bi->sd->clip);
|
|
|
|
}
|
|
|
|
evas_object_event_callback_del(obj,
|
|
|
|
EVAS_CALLBACK_FREE,
|
|
|
|
_e_gadcon_layout_smart_item_del_hook);
|
|
|
|
evas_object_smart_member_del(obj);
|
|
|
|
evas_object_clip_unset(obj);
|
|
|
|
evas_object_data_del(obj, "e_gadcon_layout_data");
|
|
|
|
free(bi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
e_gadcon_layout_unpack(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
_e_gadcon_sort_cb(void *d1, void *d2)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi1, *bi2;
|
|
|
|
int v1, v2;
|
|
|
|
|
|
|
|
bi1 = evas_object_data_get(d1, "e_gadcon_layout_data");
|
|
|
|
bi2 = evas_object_data_get(d2, "e_gadcon_layout_data");
|
|
|
|
v1 = (bi1->ask.pos + (bi1->ask.size / 2)) - bi1->hookp;
|
|
|
|
if (v1 < 0) v1 = -v1;
|
|
|
|
v2 = (bi2->ask.pos + (bi2->ask.size / 2)) - bi2->hookp;
|
|
|
|
if (v2 < 0) v2 = -v2;
|
|
|
|
return v1 - v2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
|
|
|
|
{
|
|
|
|
Evas_Coord x, y, w, h, xx, yy;
|
|
|
|
Evas_List *l, *l2;
|
|
|
|
int minw, minh, wdif, hdif;
|
|
|
|
int count, expand;
|
|
|
|
Evas_List *list_s = NULL, *list_m = NULL, *list_e = NULL;
|
|
|
|
|
|
|
|
x = sd->x;
|
|
|
|
y = sd->y;
|
|
|
|
w = sd->w;
|
|
|
|
h = sd->h;
|
|
|
|
|
|
|
|
for (l = sd->items; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
obj = l->data;
|
|
|
|
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
if (sd->horizontal)
|
|
|
|
{
|
|
|
|
xx = bi->ask.pos + (bi->ask.size / 2);
|
|
|
|
if (xx < (bi->ask.res / 3))
|
|
|
|
{ /* hooked to start */
|
|
|
|
bi->x = bi->ask.pos;
|
|
|
|
bi->w = bi->ask.size;
|
|
|
|
list_s = evas_list_append(list_s, obj);
|
|
|
|
bi->hookp = 0;
|
|
|
|
}
|
|
|
|
else if (xx > ((2 * bi->ask.res) / 3))
|
|
|
|
{ /* hooked to end */
|
|
|
|
bi->x = (bi->ask.pos - bi->ask.res) + w;
|
|
|
|
bi->w = bi->ask.size;
|
|
|
|
list_e = evas_list_append(list_e, obj);
|
|
|
|
bi->hookp = bi->ask.res;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* hooked to middle */
|
|
|
|
if ((bi->ask.pos <= (bi->ask.res / 2)) &&
|
|
|
|
((bi->ask.pos + bi->ask.size) > (bi->ask.res / 2)))
|
|
|
|
{ /* straddles middle */
|
|
|
|
if (bi->ask.res > 2)
|
|
|
|
bi->x = (w / 2) +
|
|
|
|
(((bi->ask.pos + (bi->ask.size / 2) -
|
|
|
|
(bi->ask.res / 2)) *
|
|
|
|
(bi->ask.res / 2)) /
|
|
|
|
(bi->ask.res / 2)) - (bi->ask.size / 2);
|
|
|
|
else
|
|
|
|
bi->x = w / 2;
|
|
|
|
bi->w = bi->ask.size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* either side of middle */
|
|
|
|
bi->x = (bi->ask.pos - (bi->ask.res / 2)) + (w / 2);
|
|
|
|
bi->w = bi->ask.size;
|
|
|
|
}
|
|
|
|
list_m = evas_list_append(list_m, obj);
|
|
|
|
bi->hookp = bi->ask.res / 2;
|
|
|
|
}
|
|
|
|
if (bi->x < 0) bi->x = 0;
|
|
|
|
else if ((bi->x + bi->w) > w) bi->x = w - bi->w;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yy = bi->ask.pos + (bi->ask.size / 2);
|
|
|
|
if (yy < (bi->ask.res / 3))
|
|
|
|
{ /* hooked to start */
|
|
|
|
bi->y = bi->ask.pos;
|
|
|
|
bi->h = bi->ask.size;
|
|
|
|
list_s = evas_list_append(list_s, obj);
|
|
|
|
bi->hookp = 0;
|
|
|
|
}
|
|
|
|
else if (yy > ((2 * bi->ask.res) / 3))
|
|
|
|
{ /* hooked to end */
|
|
|
|
bi->y = (bi->ask.pos - bi->ask.res) + h;
|
|
|
|
bi->h = bi->ask.size;
|
|
|
|
list_e = evas_list_append(list_e, obj);
|
|
|
|
bi->hookp = bi->ask.res;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* hooked to middle */
|
|
|
|
if ((bi->ask.pos <= (bi->ask.res / 2)) &&
|
|
|
|
((bi->ask.pos + bi->ask.size) > (bi->ask.res / 2)))
|
|
|
|
{ /* straddles middle */
|
|
|
|
if (bi->ask.res > 2)
|
|
|
|
bi->y = (h / 2) +
|
|
|
|
(((bi->ask.pos + (bi->ask.size / 2) -
|
|
|
|
(bi->ask.res / 2)) *
|
|
|
|
(bi->ask.res / 2)) /
|
|
|
|
(bi->ask.res / 2)) - (bi->ask.size / 2);
|
|
|
|
else
|
|
|
|
bi->y = h / 2;
|
|
|
|
bi->h = bi->ask.size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* either side of middle */
|
|
|
|
bi->y = (bi->ask.pos - (bi->ask.res / 2)) + (h / 2);
|
|
|
|
bi->h = bi->ask.size;
|
|
|
|
}
|
|
|
|
list_s = evas_list_append(list_s, obj);
|
|
|
|
bi->hookp = bi->ask.res / 2;
|
|
|
|
}
|
|
|
|
if (bi->y < 0) bi->y = 0;
|
|
|
|
else if ((bi->y + bi->h) > h) bi->y = h - bi->y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list_s = evas_list_sort(list_s, evas_list_count(list_s), _e_gadcon_sort_cb);
|
|
|
|
list_m = evas_list_sort(list_m, evas_list_count(list_m), _e_gadcon_sort_cb);
|
|
|
|
list_e = evas_list_sort(list_e, evas_list_count(list_e), _e_gadcon_sort_cb);
|
|
|
|
for (l = list_s; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
obj = l->data;
|
|
|
|
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
for (l2 = l->prev; l2; l2 = l2->prev)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi2;
|
|
|
|
|
|
|
|
obj = l2->data;
|
|
|
|
bi2 = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
if (E_SPANS_COMMON(bi->x, bi->w, bi2->x, bi2->w))
|
|
|
|
bi->x = bi2->x + bi2->w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (l = list_m; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
obj = l->data;
|
|
|
|
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
for (l2 = l->prev; l2; l2 = l2->prev)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi2;
|
|
|
|
|
|
|
|
obj = l2->data;
|
|
|
|
bi2 = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
if (E_SPANS_COMMON(bi->x, bi->w, bi2->x, bi2->w))
|
|
|
|
{
|
|
|
|
if ((bi2->x + (bi2->w / 2)) < (w / 2))
|
|
|
|
bi->x = bi2->x - bi->w;
|
|
|
|
else
|
|
|
|
bi->x = bi2->x + bi2->w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (l = list_e; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
obj = l->data;
|
|
|
|
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
for (l2 = l->prev; l2; l2 = l2->prev)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi2;
|
|
|
|
|
|
|
|
obj = l2->data;
|
|
|
|
bi2 = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
if (E_SPANS_COMMON(bi->x, bi->w, bi2->x, bi2->w))
|
|
|
|
bi->x = bi2->x - bi->w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* FIXME: now walk all 3 lists - if any memebrs of any list overlay another
|
|
|
|
* then calculate how much "give" there is with items that can resize
|
|
|
|
* down and then resize them down and reposition */
|
|
|
|
/* FIXME: if not enough "give" is there - forcibly resize everything down
|
|
|
|
* so it all fits */
|
|
|
|
|
|
|
|
evas_list_free(list_s);
|
|
|
|
evas_list_free(list_m);
|
|
|
|
evas_list_free(list_e);
|
|
|
|
/* sort items in 3 lists (based on hook point) */
|
|
|
|
for (l = sd->items; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Gadcon_Layout_Item *bi;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
obj = l->data;
|
|
|
|
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
|
|
|
|
if (sd->horizontal)
|
|
|
|
{
|
|
|
|
bi->h = h;
|
|
|
|
xx = x + bi->x;
|
|
|
|
yy = y + ((h - bi->h) / 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bi->w = w;
|
|
|
|
xx = x + ((w - bi->w) / 2);
|
|
|
|
yy = y + bi->y;
|
|
|
|
}
|
|
|
|
evas_object_move(obj, xx, yy);
|
|
|
|
evas_object_resize(obj, bi->w, bi->h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_init(void)
|
|
|
|
{
|
|
|
|
if (_e_smart) return;
|
|
|
|
_e_smart = evas_smart_new("e_gadcon_layout",
|
|
|
|
_e_gadcon_layout_smart_add,
|
|
|
|
_e_gadcon_layout_smart_del,
|
|
|
|
NULL, NULL, NULL, NULL, NULL,
|
|
|
|
_e_gadcon_layout_smart_move,
|
|
|
|
_e_gadcon_layout_smart_resize,
|
|
|
|
_e_gadcon_layout_smart_show,
|
|
|
|
_e_gadcon_layout_smart_hide,
|
|
|
|
_e_gadcon_layout_smart_color_set,
|
|
|
|
_e_gadcon_layout_smart_clip_set,
|
|
|
|
_e_gadcon_layout_smart_clip_unset,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_add(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = calloc(1, sizeof(E_Smart_Data));
|
|
|
|
if (!sd) return;
|
|
|
|
sd->obj = obj;
|
|
|
|
sd->x = 0;
|
|
|
|
sd->y = 0;
|
|
|
|
sd->w = 0;
|
|
|
|
sd->h = 0;
|
|
|
|
sd->clip = evas_object_rectangle_add(evas_object_evas_get(obj));
|
|
|
|
sd->horizontal = 1;
|
|
|
|
evas_object_smart_member_add(sd->clip, obj);
|
|
|
|
evas_object_move(sd->clip, -100005, -100005);
|
|
|
|
evas_object_resize(sd->clip, 200010, 200010);
|
|
|
|
evas_object_color_set(sd->clip, 255, 255, 255, 255);
|
|
|
|
evas_object_smart_data_set(obj, sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
while (sd->items)
|
|
|
|
{
|
|
|
|
Evas_Object *child;
|
|
|
|
|
|
|
|
child = sd->items->data;
|
|
|
|
e_gadcon_layout_unpack(child);
|
|
|
|
}
|
|
|
|
evas_object_del(sd->clip);
|
|
|
|
free(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
if ((x == sd->x) && (y == sd->y)) return;
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
Evas_Coord dx, dy;
|
|
|
|
|
|
|
|
dx = x - sd->x;
|
|
|
|
dy = y - sd->y;
|
|
|
|
for (l = sd->items; l; l = l->next)
|
|
|
|
{
|
|
|
|
Evas_Coord ox, oy;
|
|
|
|
|
|
|
|
evas_object_geometry_get(l->data, &ox, &oy, NULL, NULL);
|
|
|
|
evas_object_move(l->data, ox + dx, oy + dy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sd->x = x;
|
|
|
|
sd->y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
if ((w == sd->w) && (h == sd->h)) return;
|
|
|
|
sd->w = w;
|
|
|
|
sd->h = h;
|
|
|
|
_e_gadcon_layout_smart_reconfigure(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_show(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
if (sd->items) evas_object_show(sd->clip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_hide(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_hide(sd->clip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_color_set(sd->clip, r, g, b, a);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_clip_set(sd->clip, clip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_gadcon_layout_smart_clip_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Smart_Data *sd;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (!sd) return;
|
|
|
|
evas_object_clip_unset(sd->clip);
|
|
|
|
}
|