more gadman work... on the way there...

SVN revision: 13027
This commit is contained in:
Carsten Haitzler 2005-01-20 13:42:51 +00:00
parent 08ef1688d6
commit 45ef78688c
8 changed files with 308 additions and 39 deletions

View File

@ -1797,10 +1797,10 @@ _e_border_cb_mouse_move(void *data, int type, void *event)
new_x = x;
new_y = y;
skiplist = evas_list_append(skiplist, bd);
e_resist_container_position(bd->container, skiplist,
bd->x, bd->y, bd->w, bd->h,
x, y, bd->w, bd->h,
&new_x, &new_y);
e_resist_container_border_position(bd->container, skiplist,
bd->x, bd->y, bd->w, bd->h,
x, y, bd->w, bd->h,
&new_x, &new_y);
evas_list_free(skiplist);
e_border_move(bd, new_x, new_y);

View File

@ -5,13 +5,10 @@
/* FIXME: corner case if module is sized to full screen... cant stop edit or */
/* re-enter edit mode (cant access root menu) */
/* FIXME: resist can still jump on top of other gads... */
/* FIXME: evas_clip to the zone - make a zone clip for gadman obj's */
/* FIXME: actully call callbacks */
/* FIXME: handle save */
/* FIXME: handle load */
/* FIXME: if u set align, or minmax size or edge then figure out new-coords */
/* FIXME: handle move resist */
/* FIXME: handle resize resist */
/* local subsystem functions */
@ -24,6 +21,7 @@ static int _e_gadman_client_is_being_modified(E_Gadman_Client *gmc);
static void _e_gadman_client_geometry_to_align(E_Gadman_Client *gmc);
static void _e_gadman_client_aspect_enforce(E_Gadman_Client *gmc, double cx, double cy, int use_horiz);
static void _e_gadman_client_geometry_apply(E_Gadman_Client *gmc);
static void _e_gadman_client_callback_call(E_Gadman_Client *gmc, E_Gadman_Change change);
static void _e_gadman_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static void _e_gadman_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
@ -408,6 +406,8 @@ _e_gadman_client_edit_begin(E_Gadman_Client *gmc)
else
edje_object_signal_emit(gmc->control_object, "move", "off");
evas_object_clip_set(gmc->event_object, gmc->zone->bg_clip_object);
evas_object_clip_set(gmc->control_object, gmc->zone->bg_clip_object);
evas_object_show(gmc->event_object);
evas_object_show(gmc->control_object);
}
@ -501,6 +501,12 @@ _e_gadman_client_geometry_apply(E_Gadman_Client *gmc)
evas_object_resize(gmc->control_object, gmc->w, gmc->h);
}
static void
_e_gadman_client_callback_call(E_Gadman_Client *gmc, E_Gadman_Change change)
{
if (gmc->func) gmc->func(gmc->data, gmc, change);
}
static void
_e_gadman_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
{
@ -573,7 +579,7 @@ _e_gadman_cb_signal_move_start(void *data, Evas_Object *obj, const char *emissio
gmc->moving = 1;
evas_object_raise(gmc->control_object);
evas_object_raise(gmc->event_object);
/* FIXME: call callback to raise */
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_RAISE);
}
static void
@ -593,11 +599,23 @@ _e_gadman_cb_signal_move_go(void *data, Evas_Object *obj, const char *emission,
E_Gadman_Client *gmc;
Evas_Coord x, y;
int new_edge = 0;
int nx, ny, nxx, nyy;
int new_zone = 0;
Evas_List *skiplist = NULL;
gmc = data;
if (!gmc->moving) return;
evas_pointer_canvas_xy_get(gmc->gadman->container->bg_evas, &x, &y);
nxx = nx = gmc->down_store_x + (x - gmc->down_x);
nyy = ny = gmc->down_store_y + (y - gmc->down_y);
skiplist = evas_list_append(skiplist, gmc);
e_resist_container_gadman_position(gmc->zone->container, skiplist,
gmc->x, gmc->y, gmc->w, gmc->h,
nx, ny, gmc->w, gmc->h,
&nxx, &nyy);
evas_list_free(skiplist);
x += (nxx - nx);
y += (nyy - ny);
if ((gmc->policy & 0xff) == E_GADMAN_POLICY_EDGES)
{
double xr, yr;
@ -614,6 +632,8 @@ _e_gadman_cb_signal_move_go(void *data, Evas_Object *obj, const char *emission,
{
gmc->zone = nz;
new_zone = 1;
evas_object_clip_set(gmc->event_object, gmc->zone->bg_clip_object);
evas_object_clip_set(gmc->control_object, gmc->zone->bg_clip_object);
}
}
@ -640,6 +660,7 @@ _e_gadman_cb_signal_move_go(void *data, Evas_Object *obj, const char *emission,
{
gmc->x = gmc->zone->x;
gmc->y = gmc->down_store_y + (y - gmc->down_y);
if (gmc->h > gmc->zone->h) gmc->h = gmc->zone->h;
if (gmc->y < gmc->zone->y)
gmc->y = gmc->zone->y;
else if ((gmc->y + gmc->h) > (gmc->zone->y + gmc->zone->h))
@ -649,6 +670,7 @@ _e_gadman_cb_signal_move_go(void *data, Evas_Object *obj, const char *emission,
{
gmc->x = gmc->zone->x + gmc->zone->w - gmc->w;
gmc->y = gmc->down_store_y + (y - gmc->down_y);
if (gmc->h > gmc->zone->h) gmc->h = gmc->zone->h;
if (gmc->y < gmc->zone->y)
gmc->y = gmc->zone->y;
else if ((gmc->y + gmc->h) > (gmc->zone->y + gmc->zone->h))
@ -658,6 +680,7 @@ _e_gadman_cb_signal_move_go(void *data, Evas_Object *obj, const char *emission,
{
gmc->x = gmc->down_store_x + (x - gmc->down_x);
gmc->y = gmc->zone->y;
if (gmc->w > gmc->zone->w) gmc->w = gmc->zone->w;
if (gmc->x < gmc->zone->x)
gmc->x = gmc->zone->x;
else if ((gmc->x + gmc->w) > (gmc->zone->x + gmc->zone->w))
@ -667,6 +690,7 @@ _e_gadman_cb_signal_move_go(void *data, Evas_Object *obj, const char *emission,
{
gmc->x = gmc->down_store_x + (x - gmc->down_x);
gmc->y = gmc->zone->y + gmc->zone->h - gmc->h;
if (gmc->w > gmc->zone->w) gmc->w = gmc->zone->w;
if (gmc->x < gmc->zone->x)
gmc->x = gmc->zone->x;
else if ((gmc->x + gmc->w) > (gmc->zone->x + gmc->zone->w))
@ -696,6 +720,8 @@ _e_gadman_cb_signal_move_go(void *data, Evas_Object *obj, const char *emission,
new_zone = 1;
}
}
if (gmc->h > gmc->zone->h) gmc->h = gmc->zone->h;
if (gmc->w > gmc->zone->w) gmc->w = gmc->zone->w;
if (gmc->x < gmc->zone->x)
gmc->x = gmc->zone->x;
else if ((gmc->x + gmc->w) > (gmc->zone->x + gmc->zone->w))
@ -706,15 +732,21 @@ _e_gadman_cb_signal_move_go(void *data, Evas_Object *obj, const char *emission,
gmc->y = gmc->zone->y + gmc->zone->h - gmc->h;
}
_e_gadman_client_geometry_to_align(gmc);
if (new_zone)
{
/* FIXME: callback for zone change */
}
if (new_edge)
{
/* FIXME: callback for edge change */
}
_e_gadman_client_geometry_apply(gmc);
e_object_ref(E_OBJECT(gmc));
if (!e_object_del_get(E_OBJECT(gmc)))
{
if (new_zone)
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_ZONE);
}
if (!e_object_del_get(E_OBJECT(gmc)))
{
if (new_edge)
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_EDGE);
}
if (!e_object_del_get(E_OBJECT(gmc)))
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
e_object_unref(E_OBJECT(gmc));
}
static void
@ -783,6 +815,7 @@ _e_gadman_cb_signal_resize_left_go(void *data, Evas_Object *obj, const char *emi
_e_gadman_client_aspect_enforce(gmc, 1.0, 0.5, 1);
_e_gadman_client_geometry_to_align(gmc);
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
static void
@ -847,6 +880,7 @@ _e_gadman_cb_signal_resize_right_go(void *data, Evas_Object *obj, const char *em
_e_gadman_client_aspect_enforce(gmc, 0.0, 0.5, 1);
_e_gadman_client_geometry_to_align(gmc);
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
static void
@ -915,6 +949,7 @@ _e_gadman_cb_signal_resize_up_go(void *data, Evas_Object *obj, const char *emiss
_e_gadman_client_aspect_enforce(gmc, 0.5, 1.0, 0);
_e_gadman_client_geometry_to_align(gmc);
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
static void
@ -979,6 +1014,7 @@ _e_gadman_cb_signal_resize_down_go(void *data, Evas_Object *obj, const char *emi
_e_gadman_client_aspect_enforce(gmc, 0.5, 0.0, 0);
_e_gadman_client_geometry_to_align(gmc);
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
static void
@ -1008,6 +1044,7 @@ _e_gadman_cb_half_width(void *data, E_Menu *m, E_Menu_Item *mi)
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_geometry_to_align(gmc);
e_gadman_client_save(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
static void
@ -1028,6 +1065,7 @@ _e_gadman_cb_full_width(void *data, E_Menu *m, E_Menu_Item *mi)
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_geometry_to_align(gmc);
e_gadman_client_save(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
static void
@ -1050,6 +1088,7 @@ _e_gadman_cb_auto_width(void *data, E_Menu *m, E_Menu_Item *mi)
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_geometry_to_align(gmc);
e_gadman_client_save(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
static void
@ -1062,6 +1101,7 @@ _e_gadman_cb_center_horiz(void *data, E_Menu *m, E_Menu_Item *mi)
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_geometry_to_align(gmc);
e_gadman_client_save(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
static void
@ -1081,6 +1121,7 @@ _e_gadman_cb_half_height(void *data, E_Menu *m, E_Menu_Item *mi)
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_geometry_to_align(gmc);
e_gadman_client_save(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
static void
@ -1101,6 +1142,7 @@ _e_gadman_cb_full_height(void *data, E_Menu *m, E_Menu_Item *mi)
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_geometry_to_align(gmc);
e_gadman_client_save(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
static void
@ -1123,6 +1165,7 @@ _e_gadman_cb_auto_height(void *data, E_Menu *m, E_Menu_Item *mi)
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_geometry_to_align(gmc);
e_gadman_client_save(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}
@ -1136,5 +1179,6 @@ _e_gadman_cb_center_vert(void *data, E_Menu *m, E_Menu_Item *mi)
_e_gadman_client_geometry_apply(gmc);
_e_gadman_client_geometry_to_align(gmc);
e_gadman_client_save(gmc);
_e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_MOVE_RESIZE);
}

View File

@ -15,10 +15,10 @@ typedef enum _E_Gadman_Policy
typedef enum _E_Gadman_Change
{
E_GADMAN_CHANGE_MOVE,
E_GADMAN_CHANGE_RESIZE,
E_GADMAN_CHANGE_MOVE_RESIZE,
E_GADMAN_CHANGE_EDGE,
E_GADMAN_CHANGE_ZONE
E_GADMAN_CHANGE_ZONE,
E_GADMAN_CHANGE_RAISE
} E_Gadman_Change;
typedef enum _E_Gadman_Edge

View File

@ -542,7 +542,41 @@ _e_main_screens_init(void)
gmc->x = 0;
gmc->y = 300;
gmc->w = 100;
gmc->h = 200;
gmc->h = 100;
e_gadman_client_policy_set(gmc,
// E_GADMAN_POLICY_EDGES |
E_GADMAN_POLICY_ANYWHERE |
E_GADMAN_POLICY_HMOVE |
E_GADMAN_POLICY_VMOVE |
E_GADMAN_POLICY_HSIZE |
E_GADMAN_POLICY_VSIZE);
e_gadman_client_min_size_set(gmc, 20, 20);
e_gadman_client_auto_size_set(gmc, 50, 200);
e_gadman_client_align_set(gmc, 0.0, 0.5);
e_client_gadman_edge_set(gmc, E_GADMAN_EDGE_LEFT);
gmc = e_gadman_client_new(con->gadman);
gmc->x = 0;
gmc->y = 400;
gmc->w = 100;
gmc->h = 100;
e_gadman_client_policy_set(gmc,
// E_GADMAN_POLICY_EDGES |
E_GADMAN_POLICY_ANYWHERE |
E_GADMAN_POLICY_HMOVE |
E_GADMAN_POLICY_VMOVE |
E_GADMAN_POLICY_HSIZE |
E_GADMAN_POLICY_VSIZE);
e_gadman_client_min_size_set(gmc, 20, 20);
e_gadman_client_auto_size_set(gmc, 50, 200);
e_gadman_client_align_set(gmc, 0.0, 0.5);
e_client_gadman_edge_set(gmc, E_GADMAN_EDGE_LEFT);
gmc = e_gadman_client_new(con->gadman);
gmc->x = 0;
gmc->y = 500;
gmc->w = 100;
gmc->h = 100;
e_gadman_client_policy_set(gmc,
// E_GADMAN_POLICY_EDGES |
E_GADMAN_POLICY_ANYWHERE |

View File

@ -10,10 +10,10 @@ struct _E_Resist_Rect
};
int
e_resist_container_position(E_Container *con, Evas_List *skiplist,
int px, int py, int pw, int ph,
int x, int y, int w, int h,
int *rx, int *ry)
e_resist_container_border_position(E_Container *con, Evas_List *skiplist,
int px, int py, int pw, int ph,
int x, int y, int w, int h,
int *rx, int *ry)
{
int resist = 1;
int desk_resist = 32;
@ -34,9 +34,6 @@ e_resist_container_position(E_Container *con, Evas_List *skiplist,
dx = x - px;
dy = y - py;
/* FIXME: need to make resist obscales where it resists being moved OUT */
/* of the box */
/* edges of screen */
#define OBSTACLE(_x, _y, _w, _h, _resist) \
{ \
@ -52,16 +49,7 @@ e_resist_container_position(E_Container *con, Evas_List *skiplist,
r->resist_out = 1; \
rects = evas_list_append(rects, r); \
}
#if 0 /* dont need this anymore */
OBSTACLE(-1000000, -1000000, 2000000 + con->w, 1000000,
desk_resist);
OBSTACLE(-1000000, -1000000, 1000000, 2000000 + con->h,
desk_resist);
OBSTACLE(-1000000, con->h, 2000000 + con->w, 1000000,
desk_resist);
OBSTACLE(con->w, -1000000, 1000000, 2000000 + con->h,
desk_resist);
#endif
for (l = con->zones; l; l = l->next)
{
E_Zone *zone;
@ -237,3 +225,188 @@ e_resist_container_position(E_Container *con, Evas_List *skiplist,
*ry = y;
return 1;
}
int
e_resist_container_gadman_position(E_Container *con, Evas_List *skiplist,
int px, int py, int pw, int ph,
int x, int y, int w, int h,
int *rx, int *ry)
{
int resist = 1;
int gad_resist = 4800;
int dx, dy, d, pd;
int resist_x = 0, resist_y = 0;
Evas_List *l, *ll, *rects = NULL;
E_Resist_Rect *r;
/* FIXME: get resist values from config */
if (!resist)
{
*rx = x;
*ry = y;
return 0;
}
dx = x - px;
dy = y - py;
for (l = con->gadman->clients; l; l = l->next)
{
E_Gadman_Client *gmc;
int ok;
gmc = l->data;
ok = 1;
for (ll = skiplist; ll; ll = ll->next)
{
if (ll->data == gmc)
{
ok = 0;
break;
}
}
if (ok)
{
r = E_NEW(E_Resist_Rect, 1);
r->x = gmc->x;
r->y = gmc->y;
r->w = gmc->w;
r->h = gmc->h;
r->v1 = gad_resist;
rects = evas_list_append(rects, r);
}
}
for (l = rects; l; l = l->next)
{
r = l->data;
if (E_SPANS_COMMON(r->y, r->h, y, h))
{
if (dx > 0)
{
/* moving right */
if (r->resist_out)
{
/* check right edge of windows against left */
d = x + w - (r->x + r->w);
pd = px + pw - (r->x + r->w);
if ((d > 0) && (pd <= 0) && (d <= r->v1))
{
if (-resist_x < d)
resist_x = -d;
}
}
else
{
/* check left edge of windows against right */
d = r->x - (x + w);
pd = r->x - (px + pw);
if ((d < 0) && (pd >= 0) && (d >= -r->v1))
{
if (resist_x > d)
resist_x = d;
}
}
}
else if (dx < 0)
{
/* moving left */
if (r->resist_out)
{
/* check left edge of windows against right */
d = r->x - x;
pd = r->x - px;
if ((d > 0) && (pd <= 0) && (d <= r->v1))
{
if (resist_x < d)
resist_x = d;
}
}
else
{
/* check right edge of windows against left */
d = x - (r->x + r->w);
pd = px - (r->x + r->w);
if ((d < 0) && (pd >= 0) && (d >= -r->v1))
{
if (-resist_x > d)
resist_x = -d;
}
}
}
}
if (E_SPANS_COMMON(r->x, r->w, x, w))
{
if (dy > 0)
{
/* moving down */
if (r->resist_out)
{
/* check bottom edge of windows against top */
d = y + h - (r->y + r->h);
pd = py + ph - (r->y + r->h);
if ((d > 0) && (pd <= 0) && (d <= r->v1))
{
if (-resist_y < d)
resist_y = -d;
}
}
else
{
/* check top edge of windows against bottom */
d = r->y - (y + h);
pd = r->y - (py + ph);
if ((d < 0) && (pd >= 0) && (d >= -r->v1))
{
if (resist_y > d)
resist_y = d;
}
}
}
else if (dy < 0)
{
/* moving up */
if (r->resist_out)
{
/* check top edge of windows against bottom */
d = r->y - y;
pd = r->y - py;
if ((d > 0) && (pd <= 0) && (d <= r->v1))
{
if (resist_y < d)
resist_y = d;
}
}
else
{
/* moving up - check bottom edge of windows against top */
d = y - (r->y + r->h);
pd = py - (r->y + r->h);
if ((d < 0) && (pd >= 0) && (d >= -r->v1))
{
if (-resist_y > d)
resist_y = -d;
}
}
}
}
}
if (rects)
{
for (l = rects; l; l = l->next)
{
E_FREE(l->data);
}
evas_list_free(rects);
}
if (dx != 0)
*rx = x + resist_x;
else
*rx = x;
if (dy != 0)
*ry = y + resist_y;
else
*ry = y;
return 1;
}

View File

@ -3,7 +3,8 @@
#ifndef E_RESIST_H
#define E_RESIST_H
EAPI int e_resist_container_position(E_Container *con, Evas_List *skiplist, int px, int py, int pw, int ph, int x, int y, int w, int h, int *rx, int *ry);
EAPI int e_resist_container_border_position(E_Container *con, Evas_List *skiplist, int px, int py, int pw, int ph, int x, int y, int w, int h, int *rx, int *ry);
EAPI int e_resist_container_gadman_position(E_Container *con, Evas_List *skiplist, int px, int py, int pw, int ph, int x, int y, int w, int h, int *rx, int *ry);
#endif
#endif

View File

@ -58,6 +58,13 @@ e_zone_new(E_Container *con, int x, int y, int w, int h)
char name[40];
Evas_Object *o;
o = evas_object_rectangle_add(con->bg_evas);
zone->bg_clip_object = o;
evas_object_move(o, x, y);
evas_object_resize(o, w, h);
evas_object_color_set(o, 255, 255, 255, 255);
evas_object_show(o);
o = edje_object_add(con->bg_evas);
zone->bg_object = o;
evas_object_layer_set(o, -1);
@ -69,10 +76,12 @@ e_zone_new(E_Container *con, int x, int y, int w, int h)
edje_object_file_set(o,
e_config->desktop_default_background,
"desktop/background");
evas_object_clip_set(o, zone->bg_clip_object);
evas_object_show(o);
o = evas_object_rectangle_add(con->bg_evas);
zone->bg_event_object = o;
evas_object_clip_set(o, zone->bg_clip_object);
evas_object_move(o, x, y);
evas_object_resize(o, w, h);
evas_object_color_set(o, 255, 255, 255, 0);
@ -111,6 +120,7 @@ e_zone_move(E_Zone *zone, int x, int y)
zone->y = y;
evas_object_move(zone->bg_object, x, y);
evas_object_move(zone->bg_event_object, x, y);
evas_object_move(zone->bg_clip_object, x, y);
}
void
@ -123,6 +133,7 @@ e_zone_resize(E_Zone *zone, int w, int h)
zone->h = h;
evas_object_resize(zone->bg_object, w, h);
evas_object_resize(zone->bg_event_object, w, h);
evas_object_resize(zone->bg_clip_object, w, h);
}
void
@ -140,8 +151,10 @@ e_zone_move_resize(E_Zone *zone, int x, int y, int w, int h)
evas_object_move(zone->bg_object, x, y);
evas_object_move(zone->bg_event_object, x, y);
evas_object_move(zone->bg_clip_object, x, y);
evas_object_resize(zone->bg_object, w, h);
evas_object_resize(zone->bg_event_object, w, h);
evas_object_resize(zone->bg_clip_object, w, h);
}
E_Zone *
@ -207,6 +220,9 @@ _e_zone_free(E_Zone *zone)
con = zone->container;
if (zone->name) free(zone->name);
con->zones = evas_list_remove(con->zones, zone);
evas_object_del(zone->bg_event_object);
evas_object_del(zone->bg_clip_object);
evas_object_del(zone->bg_object);
free(zone);
}

View File

@ -19,6 +19,7 @@ struct _E_Zone
Evas_Object *bg_object;
Evas_Object *bg_event_object;
Evas_Object *bg_clip_object;
int desk_x_count, desk_y_count;
int desk_x_current, desk_y_current;