Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/etox

Dir     : e17/libs/etox/src


Modified Files:
        etox.c etox_line.c etox_obstacle.c 


Log Message:
Some progress towards working obstacle code. Still not working, but getting
better.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -3 -r1.54 -r1.55
--- etox.c      6 Aug 2003 02:45:35 -0000       1.54
+++ etox.c      15 Aug 2003 06:38:58 -0000      1.55
@@ -931,10 +931,12 @@
        obst = etox_obstacle_new(et, x, y, w, h);
 
        if (obst) {
-               evas_list_append(et->obstacles, obst);
+               et->obstacles = evas_list_append(et->obstacles, obst);
                etox_obstacle_place(obst);
        }
 
+       etox_layout(et);
+
        return obst;
 }
 
@@ -1146,21 +1148,36 @@
 
        CHECK_PARAM_POINTER("et", et);
 
+       if (!et->w)
+               et->w = et->tw;
+
        /*
         * What the hell, do you expect us to "just know" what text to
         * display, you've got to set some dumbass!
         */
-       if (!et->lines)
+       if (!et->lines || et->w <= 0 || et->h <= 0)
                return;
 
        y = et->y;
 
        /*
+        * Remove all the obstacles from their places in the etox.
+        */
+       l = et->obstacles;
+       while (l) {
+               Etox_Obstacle *obst = l->data;
+               etox_obstacle_unplace(obst);
+               l = l->next;
+       }
+
+       /*
         * Traverse the list displaying each line, moving down the screen after
         * each line.
         */
        l = et->lines;
        while (l) {
+               Evas_List *ll;
+
                line = l->data;
                line->x = et->x;
                line->y = y;
@@ -1173,6 +1190,16 @@
 
                        if (temp->flags & ETOX_LINE_WRAPPED)
                                etox_line_unwrap(et, line);
+               }
+
+               /*
+                * Re-place all the obstacles into their places in the etox.
+                */
+               ll = et->obstacles;
+               while (ll) {
+                       Etox_Obstacle *obst = ll->data;
+                       etox_obstacle_place(obst);
+                       ll = ll->next;
                }
 
                etox_line_layout(line);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_line.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- etox_line.c 6 Aug 2003 02:45:36 -0000       1.20
+++ etox_line.c 15 Aug 2003 06:38:58 -0000      1.21
@@ -213,9 +213,9 @@
         */
        for (l = line->bits; l; l = l->next) {
                bit = l->data;
+               evas_object_geometry_get(bit, &tx, &ty, &tw, &th);
                if (!estyle_fixed(bit)) {
 
-                       evas_object_geometry_get(bit, &tx, &ty, &tw, &th);
                        if (line->h < th)
                                line->h = th;
 
@@ -234,6 +234,8 @@
                         */
                        evas_object_move(bit, x, ty);
                }
+               else
+                       printf("Encountered an obstacle!!\n");
 
                /*
                 * Move horizontally to place the next bit.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_obstacle.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- etox_obstacle.c     6 Aug 2003 02:45:36 -0000       1.14
+++ etox_obstacle.c     15 Aug 2003 06:38:58 -0000      1.15
@@ -57,10 +57,9 @@
 void etox_obstacle_place(Etox_Obstacle * obst)
 {
        int i = 0;
-       int j = 0;
        double x, y, w, h;
        Etox_Line *line;
-       Evas_List *l_nodes, *l;
+       Evas_List *l;
 
        CHECK_PARAM_POINTER("obst", obst);
 
@@ -81,14 +80,8 @@
        if (y + h < obst->et->y)
                return;
 
-       /*
-        * We know the obstacle intersects this etox, so now determine
-        * starting and ending lines, as well as split lines appropriately.
-        */
-       for (l_nodes = obst->et->lines; l_nodes; l_nodes = l_nodes->next)
-               j++;
-       obst->start_line = j;
-       obst->end_line = -1;
+       obst->start_line = 0;
+       obst->end_line = 0;
 
        /*
         * Run through to determine the lines to determine which intersect the
@@ -96,25 +89,26 @@
         */
        for (l = obst->et->lines; l; l = l->next) {
                line = l->data;
-               if (line->y < y + h) {
-                       if (line->y > y) {
-                               /*
-                                * Check if the obstacle starts at this line
-                                */
-                               if (i < obst->start_line)
-                                       obst->start_line = i;
-                               _etox_obstacle_line_insert(line, obst);
-                       }
-               } else
+
+               if (line->y > y + h)
                        break;
 
+               if (line->y + line->h >= y) {
+                       /*
+                        * Check if the obstacle starts at this line
+                        */
+                       if (!obst->start_line)
+                               obst->start_line = i;
+                       _etox_obstacle_line_insert(line, obst);
+               }
+
                /*
                 * Check if the obstacle starts at this line
                 */
                i++;
        }
 
-       obst->end_line = i - 1;
+       obst->end_line = i;
 }
 
 /*
@@ -123,9 +117,8 @@
 void etox_obstacle_unplace(Etox_Obstacle * obst)
 {
        int i, j;
-       Evas_Object *bit;
        Etox_Line *line;
-       Evas_List *l, *ll;
+       Evas_List *l;
 
        CHECK_PARAM_POINTER("obst", obst);
 
@@ -138,22 +131,11 @@
         * On each line within the obstacle bounds, remove the obstacle from
         * the list of bits.
         */
-       for (j = 1, l = obst->et->lines; j <= obst->end_line && l;
+       for (j = 0, l = obst->et->lines; j <= obst->end_line && l;
             l = l->next, j++) {
-               if (j < i);
-               else {
+               if (j >= i) {
                        line = l->data;
-                       /*
-                        * Now find the obstacle on the list of bits and remove it.
-                        */
-                       for (ll = line->bits; ll; ll = ll->next) {
-                               bit = ll->data;
-                               if (bit != obst->bit);
-                               else {
-                                       ll = evas_list_remove(ll, bit);
-                                       break;
-                               }
-                       }
+                       etox_line_remove(line, obst->bit);
                }
        }
 }
@@ -164,33 +146,44 @@
 static void _etox_obstacle_line_insert(Etox_Line * line,
                                       Etox_Obstacle * obst)
 {
+       int i;
        Evas_Object *bit;
-       double x, y, w, h;
-       Evas_List *l;
+       double x;
 
        CHECK_PARAM_POINTER("line", line);
        CHECK_PARAM_POINTER("obst", obst);
 
-       evas_object_geometry_get(obst->bit, &x, &y, &w, &h);
+       evas_object_geometry_get(obst->bit, &x, NULL, NULL, NULL);
 
        /*
         * Find the position to place the obstacle within the line
         */
-       for (l = line->bits; l; l = l->next) {
-               double tx, ty, tw, th;
-               bit = l->data;
-
-               evas_object_geometry_get(bit, &tx, &ty, &tw, &th);
-               if (etox_rect_intersect(x, y, w, h, tx, ty, tw, th)) {
-                       if (!bit)
-                               return;
-                       /*
-                        * FIXME: We need to do some bit-splitting here, just
-                        * need to get around to it.
-                        */
-                       l = evas_list_prepend_relative(l, obst->bit, l->next);
-                       break;
+       bit = etox_line_coord_to_bit(line, x);
+       if (!bit)
+               return;
+
+       /*
+        * Find the index into the line of the obstacle.
+        */
+       i = estyle_text_at_position(bit, x, line->y + (line->h / 2), NULL, NULL,
+                       NULL, NULL);
+
+       /*
+        * Check if we can append it after this bit, possibly after splitting.
+        */
+       if (i > 0) {
+               if (i < estyle_length(bit)) {
+                       etox_split_bit(line, bit, i);
                }
+               line->bits = evas_list_append_relative(line->bits, obst->bit,
+                               bit);
+       }
+       else {
+               /*
+                * Otherwise, stick it in front of this bit.
+                */
+               line->bits = evas_list_prepend_relative(line->bits, obst->bit,
+                               bit);
        }
 }
 




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to