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);
/* 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 */
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);
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);
}
}
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)
{
Evas_Event_Mouse_Down *ev;
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
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;
{
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);
}
}
{
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))
{
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))
{
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))
{
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))
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))
gmc->y = gmc->zone->y + gmc->zone->h - gmc->h;
}
_e_gadman_client_geometry_to_align(gmc);
- if (new_zone)
+ _e_gadman_client_geometry_apply(gmc);
+ e_object_ref(E_OBJECT(gmc));
+ if (!e_object_del_get(E_OBJECT(gmc)))
{
- /* FIXME: callback for zone change */
+ if (new_zone)
+ _e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_ZONE);
}
- if (new_edge)
+ if (!e_object_del_get(E_OBJECT(gmc)))
{
- /* FIXME: callback for edge change */
+ if (new_edge)
+ _e_gadman_client_callback_call(gmc, E_GADMAN_CHANGE_EDGE);
}
- _e_gadman_client_geometry_apply(gmc);
+ 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
_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
_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
_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
_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
_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
_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
_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
_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
_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
_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
_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);
}
_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);
}
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
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 |
};
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;
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) \
{ \
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;
*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;
+}
#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
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);
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);
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
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
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 *
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);
}
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;