From ed07bdc43793cc84357ce1092722e57716683750 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jancsika@yahoo.com>
Date: Sun, 19 Apr 2015 12:28:13 -0400
Subject: [PATCH] fixed garray redrawing so arrays get displaced with the
 parent graph.

---
 pd/nw/todo.txt   |  2 ++
 pd/src/g_array.c | 13 +++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/pd/nw/todo.txt b/pd/nw/todo.txt
index 37f4834c6..9b84187e0 100644
--- a/pd/nw/todo.txt
+++ b/pd/nw/todo.txt
@@ -137,6 +137,8 @@ add a canvas message to set a transform on the patchsvg.  Good for:
 change 'array_element_fill' to 'element_fill', array_outline to 'array_element_outline' 
 either nw_create_window should take fewer parameters or it should take an
     object with name: value pairs
+getting the sense that glist_isselected should _always_ have
+    glist_getcanvas(x) as its first parameter
 Crashers
 --------
 
diff --git a/pd/src/g_array.c b/pd/src/g_array.c
index 6c8e8de18..39bd420c9 100644
--- a/pd/src/g_array.c
+++ b/pd/src/g_array.c
@@ -1533,7 +1533,7 @@ static void garray_doredraw(t_gobj *client, t_glist *glist)
     t_garray *x = (t_garray *)client;
     if (glist_isvisible(x->x_glist))
     {
-        garray_vis(&x->x_gobj, x->x_glist, 0); 
+        garray_vis(&x->x_gobj, x->x_glist, 0);
         garray_vis(&x->x_gobj, x->x_glist, 1);
 
         /* we do this to reposition objects back where they belong */
@@ -1545,7 +1545,8 @@ static void garray_doredraw(t_gobj *client, t_glist *glist)
         //fprintf(stderr,"check if we need to reselect %lx %lx %lx\n",
         //    glist_getcanvas(glist), (t_gobj *)glist, glist->gl_owner);
         int selected = 0;
-        t_glist *sel = glist->gl_owner;
+//        t_glist *sel = glist->gl_owner;
+        t_glist *sel = glist;
         while (sel && sel != glist_getcanvas(glist))
         {
             if (glist_isselected(glist_getcanvas(glist), (t_gobj *)sel))
@@ -1560,6 +1561,14 @@ static void garray_doredraw(t_gobj *client, t_glist *glist)
             //fprintf(stderr,"garray_doredraw isselected\n");
             sys_vgui("pdtk_select_all_gop_widgets .x%lx %lx %d\n",
                 glist_getcanvas(glist), glist, 1);
+            // a giant kludge-- we really just need gop items
+            // to be children of their gop <group>
+            t_scalar *sc = x->x_scalar;
+            char tagbuf[MAXPDSTRING];
+            post("did we make it here?");
+            sprintf(tagbuf, "scalar%lx", (long unsigned int)sc->sc_vec);
+            gui_vmess("gui_text_select", "ss",
+                canvas_tag(glist_getcanvas(glist)), tagbuf);
         }
     }
 }
-- 
GitLab