more gadcon work... oooh getting close.

SVN revision: 20383
This commit is contained in:
Carsten Haitzler 2006-02-10 12:21:22 +00:00
parent e23367f722
commit daccad473b
5 changed files with 166 additions and 20 deletions

View File

@ -43,6 +43,7 @@ static void e_gadcon_layout_pack_size_set(Evas_Object *obj, int size);
static void e_gadcon_layout_pack_request_set(Evas_Object *obj, int pos, int size);
static void e_gadcon_layout_pack_options_set(Evas_Object *obj, int pos, int size, int res);
static void e_gadcon_layout_pack_min_size_set(Evas_Object *obj, int w, int h);
static void e_gadcon_layout_pack_aspect_set(Evas_Object *obj, int w, int h);
static void e_gadcon_layout_unpack(Evas_Object *obj);
static Evas_Hash *providers = NULL;
@ -161,8 +162,8 @@ e_gadcon_populate(E_Gadcon *gc)
E_Config_Gadcon *cf_gc;
E_Config_Gadcon_Client *cf_gcc;
E_OBJECT_CHECK_RETURN(gc, NULL);
E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, NULL);
E_OBJECT_CHECK(gc);
E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
ok = 0;
e_gadcon_layout_freeze(gc->o_container);
printf("e_config->gadcons = %p\n", e_config->gadcons);
@ -184,7 +185,6 @@ e_gadcon_populate(E_Gadcon *gc)
E_Gadcon_Client_Class *cc;
cf_gcc = l->data;
printf("cf_gcc->name = %s\n", cf_gcc->name);
cc = evas_hash_find(providers, cf_gcc->name);
if (cc)
{
@ -295,6 +295,40 @@ e_gadcon_all_edit_end(void)
}
}
EAPI void
e_gadcon_zone_set(E_Gadcon *gc, E_Zone *zone)
{
E_OBJECT_CHECK(gc);
E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
gc->zone = zone;
}
EAPI E_Zone *
e_gadcon_zone_get(E_Gadcon *gc)
{
E_OBJECT_CHECK_RETURN(gc, NULL);
E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, NULL);
return gc->zone;
}
EAPI void
e_gadcon_ecore_evas_set(E_Gadcon *gc, Ecore_Evas *ee)
{
E_OBJECT_CHECK(gc);
E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
gc->ecore_evas = ee;
}
EAPI int
e_gadcon_canvas_zone_geometry_get(E_Gadcon *gc, int *x, int *y, int *w, int *h)
{
E_OBJECT_CHECK_RETURN(gc, 0);
E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, 0);
if (!gc->ecore_evas) return 0;
ecore_evas_geometry_get(gc->ecore_evas, x, y, w, h);
return 1;
}
EAPI E_Gadcon_Client *
e_gadcon_client_new(E_Gadcon *gc, char *name, char *id, Evas_Object *base_obj)
{
@ -432,6 +466,14 @@ e_gadcon_client_min_size_set(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h)
e_gadcon_layout_pack_min_size_set(gcc->o_base, w, h);
}
EAPI void
e_gadcon_client_aspect_set(E_Gadcon_Client *gcc, int w, int h)
{
E_OBJECT_CHECK(gcc);
E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
e_gadcon_layout_pack_aspect_set(gcc->o_base, w, h);
}
/* local subsystem functions */
static void
_e_gadcon_free(E_Gadcon *gc)
@ -759,8 +801,8 @@ struct _E_Gadcon_Layout_Item
} ask;
int hookp;
struct {
Evas_Coord w, h;
} min, max;
int w, h;
} min, aspect;
Evas_Coord x, y, w, h;
Evas_Object *obj;
unsigned char can_move : 1;
@ -1007,6 +1049,18 @@ e_gadcon_layout_pack_min_size_set(Evas_Object *obj, int w, int h)
_e_gadcon_layout_smart_reconfigure(bi->sd);
}
static void
e_gadcon_layout_pack_aspect_set(Evas_Object *obj, int w, int h)
{
E_Gadcon_Layout_Item *bi;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) return;
bi->aspect.w = w;
bi->aspect.h = h;
_e_gadcon_layout_smart_reconfigure(bi->sd);
}
static void
e_gadcon_layout_unpack(Evas_Object *obj)
{
@ -1137,6 +1191,17 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
else
min += bi->min.h;
bi->ask.size2 = bi->ask.size;
if ((bi->aspect.w > 0) && (bi->aspect.h > 0))
{
if (sd->horizontal)
{
bi->ask.size2 = (h * bi->aspect.w) / bi->aspect.h;
}
else
{
bi->ask.size2 = (w * bi->aspect.h) / bi->aspect.w;
}
}
}
if (sd->horizontal)
{

View File

@ -45,6 +45,8 @@ struct _E_Gadcon
Evas_Object *o_parent;
char *swallow_name;
} edje;
Ecore_Evas *ecore_evas;
E_Zone *zone;
E_Gadcon_Orient orient;
@ -96,10 +98,15 @@ EAPI void e_gadcon_edit_begin(E_Gadcon *gc);
EAPI void e_gadcon_edit_end(E_Gadcon *gc);
EAPI void e_gadcon_all_edit_begin(void);
EAPI void e_gadcon_all_edit_end(void);
EAPI void e_gadcon_zone_set(E_Gadcon *gc, E_Zone *zone);
EAPI E_Zone *e_gadcon_zone_get(E_Gadcon *gc);
EAPI void e_gadcon_ecore_evas_set(E_Gadcon *gc, Ecore_Evas *ee);
EAPI int e_gadcon_canvas_zone_geometry_get(E_Gadcon *gc, int *x, int *y, int *w, int *h);
EAPI E_Gadcon_Client *e_gadcon_client_new(E_Gadcon *gc, char *name, char *id, Evas_Object *base_obj);
EAPI void e_gadcon_client_size_request(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h);
EAPI void e_gadcon_client_min_size_set(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h);
EAPI void e_gadcon_client_aspect_set(E_Gadcon_Client *gcc, int w, int h);
EAPI void e_gadcon_client_edit_begin(E_Gadcon_Client *gcc);
EAPI void e_gadcon_client_edit_end(E_Gadcon_Client *gcc);

View File

@ -182,7 +182,9 @@ e_menu_activate_key(E_Menu *m, E_Zone *zone, int x, int y, int w, int h, int dir
case E_MENU_POP_DIRECTION_LEFT:
_e_menu_realize(m);
m->cur.x = x - m->cur.w;
m->cur.y = y ;
m->cur.y = y;
if ((m->cur.y + m->cur.h) > (m->zone->y + m->zone->h))
m->cur.y = y + h - m->cur.h;
_e_menu_activate_first();
break;
case E_MENU_POP_DIRECTION_RIGHT:
@ -192,14 +194,20 @@ e_menu_activate_key(E_Menu *m, E_Zone *zone, int x, int y, int w, int h, int dir
break;
case E_MENU_POP_DIRECTION_UP:
_e_menu_realize(m);
m->cur.x = x + w;
m->cur.x = x;
if ((m->cur.x + m->cur.w) > (m->zone->x + m->zone->w))
m->cur.x = x + w - m->cur.w;
m->cur.y = y - m->cur.h;
_e_menu_activate_last();
break;
case E_MENU_POP_DIRECTION_DOWN:
_e_menu_realize(m);
m->cur.x = x + w;
m->cur.x = x;
if ((m->cur.x + m->cur.w) > (m->zone->x + m->zone->w))
m->cur.x = x + w - m->cur.w;
m->cur.y = y + h;
if ((m->cur.y + m->cur.h) > (m->zone->y + m->zone->h))
m->cur.y = y + h - m->cur.h;
_e_menu_activate_first();
break;
case E_MENU_POP_DIRECTION_AUTO:
@ -238,20 +246,33 @@ e_menu_activate_mouse(E_Menu *m, E_Zone *zone, int x, int y, int w, int h, int d
case E_MENU_POP_DIRECTION_LEFT:
_e_menu_realize(m);
m->cur.x = x - m->cur.w;
m->cur.y = y ;
m->cur.y = y;
if ((m->cur.y + m->cur.h) > (m->zone->y + m->zone->h))
m->cur.y = y + h - m->cur.h;
_e_menu_activate_first();
break;
case E_MENU_POP_DIRECTION_RIGHT:
m->cur.x = x + w;
m->cur.y = y ;
_e_menu_activate_first();
break;
case E_MENU_POP_DIRECTION_UP:
_e_menu_realize(m);
m->cur.x = x + w;
m->cur.x = x;
if ((m->cur.x + m->cur.w) > (m->zone->x + m->zone->w))
m->cur.x = x + w - m->cur.w;
m->cur.y = y - m->cur.h;
_e_menu_activate_last();
break;
case E_MENU_POP_DIRECTION_DOWN:
m->cur.x = x + w;
_e_menu_realize(m);
m->cur.x = x;
if ((m->cur.x + m->cur.w) > (m->zone->x + m->zone->w))
m->cur.x = x + w - m->cur.w;
m->cur.y = y + h;
if ((m->cur.y + m->cur.h) > (m->zone->y + m->zone->h))
m->cur.y = y + h - m->cur.h;
_e_menu_activate_first();
break;
case E_MENU_POP_DIRECTION_AUTO:
_e_menu_auto_place(m, x, y, w, h);
@ -282,20 +303,33 @@ e_menu_activate(E_Menu *m, E_Zone *zone, int x, int y, int w, int h, int dir)
case E_MENU_POP_DIRECTION_LEFT:
_e_menu_realize(m);
m->cur.x = x - m->cur.w;
m->cur.y = y ;
m->cur.y = y;
if ((m->cur.y + m->cur.h) > (m->zone->y + m->zone->h))
m->cur.y = y + h - m->cur.h;
_e_menu_activate_first();
break;
case E_MENU_POP_DIRECTION_RIGHT:
m->cur.x = x + w;
m->cur.y = y ;
_e_menu_activate_first();
break;
case E_MENU_POP_DIRECTION_UP:
_e_menu_realize(m);
m->cur.x = x + w;
m->cur.x = x;
if ((m->cur.x + m->cur.w) > (m->zone->x + m->zone->w))
m->cur.x = x + w - m->cur.w;
m->cur.y = y - m->cur.h;
_e_menu_activate_last();
break;
case E_MENU_POP_DIRECTION_DOWN:
m->cur.x = x + w;
_e_menu_realize(m);
m->cur.x = x;
if ((m->cur.x + m->cur.w) > (m->zone->x + m->zone->w))
m->cur.x = x + w - m->cur.w;
m->cur.y = y + h;
if ((m->cur.y + m->cur.h) > (m->zone->y + m->zone->h))
m->cur.y = y + h - m->cur.h;
_e_menu_activate_first();
break;
case E_MENU_POP_DIRECTION_AUTO:
_e_menu_auto_place(m, x, y, w, h);

View File

@ -51,10 +51,11 @@ e_shelf_zone_new(E_Zone *zone, char *name)
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);
e_gadcon_orient(es->gadcon, E_GADCON_ORIENT_TOP);
e_gadcon_zone_set(es->gadcon, zone);
e_gadcon_ecore_evas_set(es->gadcon, es->ee);
shelves = evas_list_append(shelves, es);
return es;
}

View File

@ -65,6 +65,7 @@ _gc_init(E_Gadcon *gc, char *name, char *id)
* another to be the same */
e_gadcon_client_size_request(gcc, 32, 32);
e_gadcon_client_min_size_set(gcc, 16, 16);
e_gadcon_client_aspect_set(gcc, 1, 1);
return gcc;
}
@ -101,21 +102,59 @@ _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
if (ev->button == 1)
{
Evas_Coord x, y, w, h;
/* FIXME: need a way of getting screen-relative coords */
int cx, cy, cw, ch;
E_Zone *zone;
evas_object_geometry_get(inst->o_button, &x, &y, &w, &h);
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &cx, &cy, &cw, &ch);
x += cx;
y += cy;
zone = e_gadcon_zone_get(inst->gcc->gadcon);
if (!zone)
zone = e_util_zone_current_get(e_manager_current_get());
x -= zone->x;
y -= zone->y;
if (!inst->main_menu)
inst->main_menu = e_int_menus_main_new();
if (inst->main_menu)
{
int dir;
e_menu_post_deactivate_callback_set(inst->main_menu,
_menu_cb_post,
inst);
/* FIXME: need a way of getting gadcon zone */
dir = E_MENU_POP_DIRECTION_AUTO;
switch (inst->gcc->gadcon->orient)
{
case E_GADCON_ORIENT_TOP:
dir = E_MENU_POP_DIRECTION_DOWN;
// these make the menu pop off the panels' edge, not the module's object - not
// a very generic thing though.
// y = cy;
// h = ch;
break;
case E_GADCON_ORIENT_BOTTOM:
dir = E_MENU_POP_DIRECTION_UP;
// y = cy;
// h = ch;
break;
case E_GADCON_ORIENT_LEFT:
dir = E_MENU_POP_DIRECTION_RIGHT;
// x = cx;
// w = cw;
break;
case E_GADCON_ORIENT_RIGHT:
dir = E_MENU_POP_DIRECTION_LEFT;
// x = cx;
// w = cw;
break;
default:
break;
}
e_menu_activate_mouse(inst->main_menu,
e_util_zone_current_get(e_manager_current_get()),
x, y, w, h,
E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
dir, ev->timestamp);
edje_object_signal_emit(inst->o_button, "active", "");
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button, EVAS_BUTTON_NONE, ev->timestamp, NULL);
}