From 44cea8bb8c7cf4e9419da2932cfbe7453db22627 Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Sat, 23 Aug 2014 00:16:22 -0400
Subject: [PATCH] *further improvements on the garray selection and
 redraw--fixed garray contents not remaining selected after dialog properties
 have been applied *still need to explore problems with multiple arrays in a
 single GOP

---
 pd/src/g_array.c  | 11 +++++++----
 pd/src/g_canvas.c |  2 +-
 pd/src/g_editor.c |  2 +-
 pd/src/g_graph.c  |  5 +++--
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/pd/src/g_array.c b/pd/src/g_array.c
index 54941f0da..9d7dd7809 100644
--- a/pd/src/g_array.c
+++ b/pd/src/g_array.c
@@ -11,6 +11,8 @@
 
 extern int glob_lmclick;
 
+static void garray_select(t_gobj *z, t_glist *glist, int state);
+
 /* jsarlo { */
 #define ARRAYPAGESIZE 1000  /* this should match the page size in u_main.tk */
 /* } jsarlo */
@@ -92,7 +94,7 @@ void array_resize(t_array *x, int n)
 
 static void array_resize_and_redraw(t_array *array, t_glist *glist, int n)
 {
-    //fprintf(stderr,"array_resize_and_redraw\n");
+    fprintf(stderr,"array_resize_and_redraw\n");
     t_array *a2 = array;
     int vis = glist_isvisible(glist);
     while (a2->a_gp.gp_stub->gs_which == GP_ARRAY)
@@ -486,7 +488,7 @@ void glist_arraydialog(t_glist *parent, t_symbol *s, int argc, t_atom *argv)
     canvas_dirty(parent, 1);
     
     //canvas_redraw(glist_getcanvas(parent));
-    garray_fittograph(a, (int)size, 1);
+    garray_fittograph(a, (int)size, -1);
     sys_vgui("pdtk_canvas_getscroll .x%lx.c\n",
         (long unsigned int)glist_getcanvas(parent));
 }
@@ -604,6 +606,7 @@ void garray_arraydialog(t_garray *x, t_symbol *s, int argc, t_atom *argv)
         x->x_style = style;
         //fprintf(stderr,"GARRAY_REDRAW\n");
         garray_redraw(x);
+        garray_select((t_gobj *)x,glist_getcanvas(x->x_glist),1);
         canvas_dirty(x->x_glist, 1);
     }
 }
@@ -1408,8 +1411,8 @@ void garray_redraw(t_garray *x)
 {
     //fprintf(stderr,"garray_redraw\n");
     if (glist_isvisible(x->x_glist))
-        sys_queuegui(&x->x_gobj, x->x_glist, garray_doredraw);
-    //garray_doredraw(&x->x_gobj, x->x_glist);
+        //sys_queuegui(&x->x_gobj, x->x_glist, garray_doredraw);
+        garray_doredraw(&x->x_gobj, x->x_glist);
     /* jsarlo { */
     /* this happens in garray_vis() when array is visible for
        performance reasons */
diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c
index f8f8af4d7..5883009da 100644
--- a/pd/src/g_canvas.c
+++ b/pd/src/g_canvas.c
@@ -1181,7 +1181,7 @@ void canvas_closebang(t_canvas *x)
 
 /* needed for readjustment of garrays */
 extern t_array *garray_getarray(t_garray *x);
-extern void garray_fittograph(t_garray *x, int n, int redraw);
+extern void garray_fittograph(t_garray *x, int n, int flag);
 extern t_rtext *glist_findrtext(t_glist *gl, t_text *who);
 extern void rtext_gettext(t_rtext *x, char **buf, int *bufsize);
 
diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 1a32f9b6e..53621b866 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -2344,7 +2344,7 @@ void canvas_map(t_canvas *x, t_floatarg f);
     in front of all windows; or with "f" zero, when we want to get rid of
     the window. */
 //extern t_array *garray_getarray(t_garray *x);
-//extern void garray_fittograph(t_garray *x, int n, int redraw);
+//extern void garray_fittograph(t_garray *x, int n, int flag);
 //extern t_rtext *glist_findrtext(t_glist *gl, t_text *who);
 //extern void rtext_gettext(t_rtext *x, char **buf, int *bufsize);
 
diff --git a/pd/src/g_graph.c b/pd/src/g_graph.c
index 63a3fa075..ccbd5d353 100644
--- a/pd/src/g_graph.c
+++ b/pd/src/g_graph.c
@@ -607,8 +607,8 @@ static void graph_bounds(t_glist *x, t_floatarg x1, t_floatarg y1,
         x->gl_x2 = x2;
         x->gl_y1 = y1;
         x->gl_y2 = y2;
-        if (!do_not_redraw)
-            glist_redraw(x);
+        //if (!do_not_redraw)
+        glist_redraw(x);
     }
 }
 
@@ -1049,6 +1049,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
             tag, x1, y1, x2, y2);
         if (glist_isselected(parent_glist, gr))
             gobj_select(gr, parent_glist, 1);
+        //fprintf(stderr,"******************graph_vis SELECT\n");
     }
     else
     {
-- 
GitLab