working on gadcon - it has a special smart object layout of its own that is
designed to optimally help lay out gadgets in a 1 d list along an interval and do the right thing shoudl that interval change size etc. SVN revision: 20285
This commit is contained in:
parent
c22dbe41ee
commit
93cec27126
|
@ -6,10 +6,100 @@
|
|||
static void _e_gadcon_free(E_Gadcon *gc);
|
||||
static void _e_gadcon_client_free(E_Gadcon_Client *gcc);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* externally accessible functions */
|
||||
EAPI int
|
||||
e_gadcon_init(void)
|
||||
{
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -19,64 +109,98 @@ e_gadcon_shutdown(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
EAPI E_Gadcon *
|
||||
e_gadcon_swallowed_new(Evas_Object *obj, char *swallow_name)
|
||||
e_gadcon_swallowed_new(char *name, char *id, Evas_Object *obj, char *swallow_name)
|
||||
{
|
||||
E_Gadcon *gc;
|
||||
|
||||
gc = E_OBJECT_ALLOC(E_Gadcon, E_GADCON_TYPE, _e_gadcon_free);
|
||||
if (!gc) return NULL;
|
||||
|
||||
gc->type = E_GADCON_TYPE_ARRANGE;
|
||||
gc->name = strdup(name);
|
||||
gc->id = strdup(id);
|
||||
gc->edje.o_parent = obj;
|
||||
gc->edje.swallow_name = strdup(swallow_name);
|
||||
|
||||
|
||||
gc->orient = E_GADCON_ORIENT_HORIZ;
|
||||
gc->evas = evas_object_evas_get(obj);
|
||||
gc->o_container = NULL; // need to make a new smart obj for the layout
|
||||
return gc;
|
||||
}
|
||||
|
||||
EAPI E_Gadcon *
|
||||
e_gadcon_freefloat_new(Ecore_Evas *ee)
|
||||
{
|
||||
E_Gadcon *gc;
|
||||
|
||||
gc = E_OBJECT_ALLOC(E_Gadcon, E_GADCON_TYPE, _e_gadcon_free);
|
||||
if (!gc) return NULL;
|
||||
|
||||
gc->type = E_GADCON_TYPE_FREEFLOAT;
|
||||
gc->ecore_evas.ee = ee;
|
||||
|
||||
gc->evas = ecore_evas_get(ee);
|
||||
gc->o_container = NULL; // use layout smart
|
||||
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);
|
||||
return gc;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_gadcon_orient_set(E_Gadcon *gc, E_Gadcon_Orient orient)
|
||||
e_gadcon_populate(E_Gadcon *gc)
|
||||
{
|
||||
Evas_List *l;
|
||||
int i;
|
||||
|
||||
E_OBJECT_CHECK_RETURN(gc, NULL);
|
||||
E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, NULL);
|
||||
if (gc->type != E_GADCON_TYPE_ARRANGE) return;
|
||||
gc->edje.orient = orient;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* only needed if it's a freefloat type and when the canvas changes size */
|
||||
EAPI void
|
||||
e_gadcon_resize(E_Gadcon *gc, int w, int h)
|
||||
e_gadcon_orient(E_Gadcon *gc, E_Gadcon_Orient orient)
|
||||
{
|
||||
E_OBJECT_CHECK_RETURN(gc, NULL);
|
||||
E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, NULL);
|
||||
if (gc->type != E_GADCON_TYPE_FREEFLOAT) return;
|
||||
e_layout_virtual_size_set(gc->o_container, w, h);
|
||||
evas_object_resize(gc->o_container, w, h);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EAPI E_Gadcon_Client *
|
||||
e_gadcon_client_new(E_Gadcon *gc)
|
||||
e_gadcon_client_new(E_Gadcon *gc, char *name, Evas_Object *base_obj)
|
||||
{
|
||||
E_Gadcon_Client *gcc;
|
||||
|
||||
|
@ -86,15 +210,26 @@ e_gadcon_client_new(E_Gadcon *gc)
|
|||
gcc = E_OBJECT_ALLOC(E_Gadcon_Client, E_GADCON_CLIENT_TYPE, _e_gadcon_client_free);
|
||||
if (!gcc) return NULL;
|
||||
gcc->gadcon = gc;
|
||||
gcc->o_base = base_obj;
|
||||
gcc->name = strdup(name);
|
||||
gc->clients = evas_list_append(gc->clients, gcc);
|
||||
e_gadcon_layout_pack(gc->o_container, gcc->o_base);
|
||||
evas_object_show(gcc->o_base);
|
||||
return gcc;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_gadcon_client_size_request(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h)
|
||||
{
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_e_gadcon_free(E_Gadcon *gc)
|
||||
{
|
||||
if (gc->o_container) evas_object_del(gc->o_container);
|
||||
E_FREE(gc->name);
|
||||
E_FREE(gc->id);
|
||||
E_FREE(gc->edje.swallow_name);
|
||||
free(gc);
|
||||
}
|
||||
|
@ -103,5 +238,556 @@ static void
|
|||
_e_gadcon_client_free(E_Gadcon_Client *gcc)
|
||||
{
|
||||
gcc->gadcon->clients = evas_list_remove(gcc->gadcon->clients, gcc);
|
||||
E_FREE(gcc->name);
|
||||
free(gcc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -3,12 +3,6 @@
|
|||
*/
|
||||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef enum _E_Gadcon_Type
|
||||
{
|
||||
E_GADCON_TYPE_FREEFLOAT,
|
||||
E_GADCON_TYPE_ARRANGE,
|
||||
} E_Gadcon_Type;
|
||||
|
||||
typedef enum _E_Gadcon_Orient
|
||||
{
|
||||
/* generic orientations */
|
||||
|
@ -21,8 +15,9 @@ typedef enum _E_Gadcon_Orient
|
|||
E_GADCON_ORIENT_BOTTOM
|
||||
} E_Gadcon_Orient;
|
||||
|
||||
typedef struct _E_Gadcon E_Gadcon;
|
||||
typedef struct _E_Gadcon_Client E_Gadcon_Client;
|
||||
typedef struct _E_Gadcon E_Gadcon;
|
||||
typedef struct _E_Gadcon_Client E_Gadcon_Client;
|
||||
typedef struct _E_Gadcon_Client_Class E_Gadcon_Client_Class;
|
||||
|
||||
#else
|
||||
#ifndef E_GADCON_H
|
||||
|
@ -35,42 +30,54 @@ struct _E_Gadcon
|
|||
{
|
||||
E_Object e_obj_inherit;
|
||||
|
||||
E_Gadcon_Type type;
|
||||
char *name;
|
||||
char *id;
|
||||
|
||||
struct {
|
||||
Evas_Object *o_parent;
|
||||
char *swallow_name;
|
||||
E_Gadcon_Orient orient;
|
||||
} edje;
|
||||
struct {
|
||||
Ecore_Evas *ee;
|
||||
} ecore_evas;
|
||||
|
||||
E_Gadcon_Orient orient;
|
||||
|
||||
Evas *evas;
|
||||
Evas_Object *o_container;
|
||||
Evas_List *clients;
|
||||
};
|
||||
|
||||
#define GADCON_CLIENT_CLASS_VERSION 1
|
||||
struct _E_Gadcon_Client_Class
|
||||
{
|
||||
int version;
|
||||
char *name;
|
||||
struct {
|
||||
E_Gadcon_Client *(*init) (E_Gadcon *gc, char *name);
|
||||
void (*shutdown) (E_Gadcon_Client *gcc);
|
||||
void (*orient) (E_Gadcon_Client *gcc);
|
||||
} func;
|
||||
};
|
||||
|
||||
struct _E_Gadcon_Client
|
||||
{
|
||||
E_Object e_obj_inherit;
|
||||
E_Gadcon *gadcon;
|
||||
|
||||
Evas_Object *o_base;
|
||||
struct {
|
||||
Evas_Coord w, h;
|
||||
} min, max, asked, given;
|
||||
E_Object e_obj_inherit;
|
||||
E_Gadcon *gadcon;
|
||||
char *name;
|
||||
Evas_Object *o_base;
|
||||
E_Gadcon_Client_Class client_class;
|
||||
void *data;
|
||||
};
|
||||
|
||||
EAPI int e_gadcon_init(void);
|
||||
EAPI int e_gadcon_shutdown(void);
|
||||
EAPI E_Gadcon *e_gadcon_swallowed_new(Evas_Object *obj, char *swallow_name);
|
||||
EAPI E_Gadcon *e_gadcon_freefloat_new(Ecore_Evas *ee);
|
||||
EAPI void e_gadcon_resize(E_Gadcon *gc, int w, int h);
|
||||
EAPI void e_gadcon_orient_set(E_Gadcon *gc, E_Gadcon_Orient orient);
|
||||
|
||||
|
||||
|
||||
EAPI E_Gadcon_Client *e_gadcon_client_new(E_Gadcon *gc);
|
||||
|
||||
EAPI void e_gadcon_provider_register(E_Gadcon_Client_Class *cc);
|
||||
EAPI void e_gadcon_provider_unregister(E_Gadcon_Client_Class *cc);
|
||||
EAPI E_Gadcon *e_gadcon_swallowed_new(char *name, char *id, Evas_Object *obj, char *swallow_name);
|
||||
EAPI void e_gadcon_populate(E_Gadcon *gc);
|
||||
EAPI void e_gadcon_orient(E_Gadcon *gc, E_Gadcon_Orient orient);
|
||||
|
||||
EAPI E_Gadcon_Client *e_gadcon_client_new(E_Gadcon *gc, char *name, Evas_Object *base_obj);
|
||||
EAPI void e_gadcon_client_size_request(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ static void _e_main_desk_save(void);
|
|||
static void _e_main_desk_restore(E_Manager *man, E_Container *con);
|
||||
|
||||
/* local subsystem globals */
|
||||
#define MAX_LEVEL 32
|
||||
#define MAX_LEVEL 64
|
||||
static int (*_e_main_shutdown_func[MAX_LEVEL]) (void);
|
||||
static int _e_main_level = 0;
|
||||
static int _e_cacheburst = 0;
|
||||
|
@ -659,9 +659,7 @@ main(int argc, char **argv)
|
|||
if (0)
|
||||
{
|
||||
Evas_List *l, *l2, *l3, *managers;
|
||||
int snum;
|
||||
|
||||
snum = 0;
|
||||
for (l = e_manager_list(); l; l = l->next)
|
||||
{
|
||||
E_Manager *man;
|
||||
|
@ -676,12 +674,9 @@ main(int argc, char **argv)
|
|||
{
|
||||
E_Zone *zone;
|
||||
E_Shelf *es;
|
||||
char buf[256];
|
||||
|
||||
zone = l3->data;
|
||||
snprintf(buf, sizeof(buf), "shelf.%i", snum);
|
||||
snum++;
|
||||
es = e_shelf_zone_new(zone, buf);
|
||||
es = e_shelf_zone_new(zone, "shelf");
|
||||
e_shelf_populate(es);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
static void _e_shelf_free(E_Shelf *es);
|
||||
|
||||
static Evas_List *shelves = NULL;
|
||||
static int shelf_id = 0;
|
||||
|
||||
/* externally accessible functions */
|
||||
EAPI int
|
||||
|
@ -47,33 +48,22 @@ e_shelf_zone_new(E_Zone *zone, char *name)
|
|||
e_popup_edje_bg_object_set(es->popup, es->o_base);
|
||||
e_popup_show(es->popup);
|
||||
|
||||
es->gadcon = e_gadcon_swallowed_new(es->o_base, "items");
|
||||
snprintf(buf, sizeof(buf), "%i", shelf_id);
|
||||
shelf_id++;
|
||||
es->gadcon = e_gadcon_swallowed_new(es->name, buf, es->o_base, "items");
|
||||
e_gadcon_orient(es->gadcon, E_GADCON_ORIENT_HORIZ);
|
||||
|
||||
shelves = evas_list_append(shelves, es);
|
||||
|
||||
return es;
|
||||
}
|
||||
|
||||
EAPI E_Shelf *
|
||||
e_shelf_inline_new(Ecore_Evas *ee, char *name)
|
||||
{
|
||||
E_Shelf *es;
|
||||
|
||||
/* not done yet */
|
||||
return NULL;
|
||||
|
||||
es = E_OBJECT_ALLOC(E_Shelf, E_SHELF_TYPE, _e_shelf_free);
|
||||
if (!es) return NULL;
|
||||
|
||||
return es;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_shelf_populate(E_Shelf *es)
|
||||
{
|
||||
E_OBJECT_CHECK(es);
|
||||
E_OBJECT_TYPE_CHECK(es, E_GADMAN_SHELF_TYPE);
|
||||
/* actually tell all the moduels that livbed in this shelf to populate it */
|
||||
e_gadcon_populate(es->gadcon);
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
|
|
|
@ -29,7 +29,6 @@ struct _E_Shelf
|
|||
EAPI int e_shelf_init(void);
|
||||
EAPI int e_shelf_shutdown(void);
|
||||
EAPI E_Shelf *e_shelf_zone_new(E_Zone *zone, char *name);
|
||||
EAPI E_Shelf *e_shelf_inline_new(Ecore_Evas *ee, char *name);
|
||||
EAPI void e_shelf_populate(E_Shelf *es);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue