Ok, the attached patch "should fix" the poly obj moving issue,
please do test and let me know if it works as desired (it may not!) --
we're assuming everyone agrees that moving a poly obj should move the
polygon. Again, this still leaves the resizing issue undealt with til
we can agree on a good semantics for that.
jose.
Index: e17/libs/evas/src/lib/canvas/evas_object_polygon.c
===================================================================
RCS file: /var/cvs/e/e17/libs/evas/src/lib/canvas/evas_object_polygon.c,v
retrieving revision 1.20
diff -u -r1.20 evas_object_polygon.c
--- e17/libs/evas/src/lib/canvas/evas_object_polygon.c 28 Mar 2007 23:58:49 -0000 1.20
+++ e17/libs/evas/src/lib/canvas/evas_object_polygon.c 29 Mar 2007 09:23:39 -0000
@@ -12,6 +12,7 @@
{
DATA32 magic;
Evas_List *points;
+ int px, py;
char changed : 1;
void *engine_data;
@@ -117,29 +118,31 @@
p->x = x;
p->y = y;
+ min_x = o->px;
+ min_y = o->py;
if (!o->points)
{
- obj->cur.geometry.x = p->x;
- obj->cur.geometry.y = p->y;
- obj->cur.geometry.w = 2.0;
- obj->cur.geometry.h = 2.0;
+ min_x = p->x;
+ min_y = p->y;
+ max_x = min_x;
+ max_y = min_y;
}
else
{
- if (x < obj->cur.geometry.x) min_x = x;
- else min_x = obj->cur.geometry.x;
- if (x > (obj->cur.geometry.x + obj->cur.geometry.w - 2.0)) max_x = x;
- else max_x = obj->cur.geometry.x + obj->cur.geometry.w - 2.0;
- if (y < obj->cur.geometry.y) min_y = y;
- else min_y = obj->cur.geometry.y;
- if (y > (obj->cur.geometry.y + obj->cur.geometry.h - 2.0)) max_y = y;
- else max_y = obj->cur.geometry.y + obj->cur.geometry.h - 2.0;
- obj->cur.geometry.x = min_x;
- obj->cur.geometry.y = min_y;
- obj->cur.geometry.w = max_x - min_x + 2.0;
- obj->cur.geometry.h = max_y - min_y + 2.0;
+ if (x < min_x) min_x = x;
+ if (x > (o->px + obj->cur.geometry.w - 1.0)) max_x = x;
+ else max_x = o->px + obj->cur.geometry.w - 1.0;
+ if (y < min_y) min_y = y;
+ if (y > (o->py + obj->cur.geometry.h - 1.0)) max_y = y;
+ else max_y = o->py + obj->cur.geometry.h - 1.0;
}
o->points = evas_list_append(o->points, p);
+ obj->cur.geometry.x = min_x;
+ obj->cur.geometry.y = min_y;
+ obj->cur.geometry.w = max_x - min_x + 1.0;
+ obj->cur.geometry.h = max_y - min_y + 1.0;
+ o->px = min_x;
+ o->py = min_y;
//// obj->cur.cache.geometry.validity = 0;
o->changed = 1;
@@ -193,6 +196,7 @@
obj->cur.geometry.w = 0;
obj->cur.geometry.h = 0;
//// obj->cur.cache.geometry.validity = 0;
+ o->px = o->py = 0;
o->changed = 1;
evas_object_change(obj);
evas_object_coords_recalc(obj);
@@ -243,7 +247,9 @@
/* alloc obj private data */
o = calloc(1, sizeof(Evas_Object_Polygon));
+ if (!o) return NULL;
o->magic = MAGIC_OBJ_POLYGON;
+ o->changed = 1;
return o;
}
@@ -268,6 +274,7 @@
o->engine_data);
o->magic = 0;
free(o);
+ obj->object_data = NULL;
}
static void
@@ -275,6 +282,7 @@
{
Evas_Object_Polygon *o;
Evas_List *l;
+ int dx, dy;
/* render object to surface with context, and offxet by x,y */
o = (Evas_Object_Polygon *)(obj->object_data);
@@ -291,19 +299,23 @@
o->engine_data = obj->layer->evas->engine.func->polygon_points_clear(obj->layer->evas->engine.data.output,
obj->layer->evas->engine.data.context,
o->engine_data);
+ dx = obj->cur.geometry.x - o->px;
+ dy = obj->cur.geometry.y - o->py;
for (l = o->points; l; l = l->next)
{
Evas_Polygon_Point *p;
- //int px, py;
+ int px, py;
p = l->data;
//px = evas_coord_world_x_to_screen(obj->layer->evas, p->x);
//py = evas_coord_world_y_to_screen(obj->layer->evas, p->y);
+ px = p->x + dx;
+ py = p->y + dy;
o->engine_data = obj->layer->evas->engine.func->polygon_point_add(obj->layer->evas->engine.data.output,
obj->layer->evas->engine.data.context,
o->engine_data,
- p->x + x, p->y + y);
+ px + x, py + y);
}
if (o->engine_data)
obj->layer->evas->engine.func->polygon_draw(output,
@@ -389,6 +401,8 @@
evas_object_polygon_render_post(Evas_Object *obj)
{
Evas_Object_Polygon *o;
+ Evas_List *l;
+ int dx, dy;
/* this moves the current data to the previous state parts of the object */
/* in whatever way is safest for the object. also if we don't need object */
@@ -403,6 +417,18 @@
obj->clip.changes = evas_list_remove(obj->clip.changes, r);
free(r);
}
+ /* reset polygon points with 'origin' at obj origin */
+ dx = obj->cur.geometry.x - o->px;
+ dy = obj->cur.geometry.y - o->py;
+ for (l = o->points; l; l = l->next)
+ {
+ Evas_Object_Polygon_Point *p = l->data;
+
+ p->x += dx;
+ p->y += dy;
+ }
+ o->px = obj->cur.geometry.x;
+ o->py = obj->cur.geometry.y;
/* move cur to prev safely for object data */
obj->prev = obj->cur;
o->changed = 0;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel