From e62a795038d144477bfbc0b530edb3d9711d1bb3 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Wed, 23 Dec 2015 22:20:03 -0500
Subject: [PATCH] port from Pd-l2ork: b0a8c407b3014459406a742268326f3636ae3406
 further refined legacy mode to match both iemgui and graph-on-parent objects.

---
 pd/src/g_bang.c     |  2 +-
 pd/src/g_canvas.c   |  2 +-
 pd/src/g_graph.c    | 15 +++++++++++++++
 pd/src/g_mycanvas.c |  2 +-
 pd/src/g_numbox.c   |  2 +-
 pd/src/g_radio.c    |  2 +-
 pd/src/g_slider.c   |  4 ++--
 pd/src/g_toggle.c   |  2 +-
 pd/src/g_vumeter.c  |  2 +-
 9 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c
index 7210556ae..5d5437f68 100644
--- a/pd/src/g_bang.c
+++ b/pd/src/g_bang.c
@@ -528,7 +528,7 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv)
     x->x_gui.x_changed = -1;
 
     x->x_gui.legacy_x = 0;
-    x->x_gui.legacy_y = 0;
+    x->x_gui.legacy_y = 1;
 
     //x->x_gui.click_x = 1;
     //x->x_gui.click_y = 2;
diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c
index 9ff38c28f..a25fb16f7 100644
--- a/pd/src/g_canvas.c
+++ b/pd/src/g_canvas.c
@@ -802,7 +802,7 @@ void canvas_drawredrect(t_canvas *x, int doit)
 {
     if (doit)
     {
-        int x1=x->gl_xmargin, y1=x->gl_ymargin;
+        int x1=x->gl_xmargin, y1=x->gl_ymargin + sys_legacy;
         int x2=x1+x->gl_pixwidth, y2=y1+x->gl_pixheight;
         //sys_vgui(".x%lx.c create line "
         //    "%d %d %d %d %d %d %d %d %d %d -fill #ff8080 -tags GOP\n",
diff --git a/pd/src/g_graph.c b/pd/src/g_graph.c
index 6e203692b..6b0809511 100644
--- a/pd/src/g_graph.c
+++ b/pd/src/g_graph.c
@@ -919,6 +919,12 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
     // conditional
     graph_getrect(gr, parent_glist, &x1, &y1, &x2, &y2);
     //fprintf(stderr,"%d %d %d %d\n", x1, y1, x2, y2);
+    if (sys_legacy == 1)
+    {
+        //fprintf(stderr,"legacy  gop\n");
+        y1 += 1;
+        y2 += 1;
+    }
 
     if (!vis)
         rtext_erase(glist_findrtext(parent_glist, &x->gl_obj));
@@ -1375,6 +1381,15 @@ static void graph_getrect(t_gobj *z, t_glist *glist,
         }*/
     }
     else text_widgetbehavior.w_getrectfn(z, glist, &x1, &y1, &x2, &y2);
+
+    if (sys_legacy == 1)
+    {
+        //fprintf(stderr,"legacy  gop\n");
+        y1 += 1;
+        y2 += 1;
+    }
+    //fprintf(stderr,"    post %d %d %d %d\n", x1, y1, x2, y2); 
+
     *xp1 = x1;
     *yp1 = y1;
     *xp2 = x2;
diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c
index a550c15b2..967680932 100644
--- a/pd/src/g_mycanvas.c
+++ b/pd/src/g_mycanvas.c
@@ -374,7 +374,7 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv)
     x->x_gui.x_obj.te_iemgui = 1;
 
     x->x_gui.legacy_x = 0;
-    x->x_gui.legacy_y = 0;
+    x->x_gui.legacy_y = 1;
 
     return (x);
 }
diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c
index e0728a583..b33381dbb 100644
--- a/pd/src/g_numbox.c
+++ b/pd/src/g_numbox.c
@@ -847,7 +847,7 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv)
     x->x_gui.x_changed = 0;
 
     x->x_gui.legacy_x = 0;
-    x->x_gui.legacy_y = 0;
+    x->x_gui.legacy_y = 1;
 
     return (x);
 }
diff --git a/pd/src/g_radio.c b/pd/src/g_radio.c
index 0262ee1c3..899324683 100644
--- a/pd/src/g_radio.c
+++ b/pd/src/g_radio.c
@@ -531,7 +531,7 @@ static void *radio_new(t_symbol *s, int argc, t_atom *argv)
     x->x_gui.x_obj.te_iemgui = 1;
 
     x->x_gui.legacy_x = 0;
-    x->x_gui.legacy_y = 0;   
+    x->x_gui.legacy_y = 1;
 
     return (x);
 }
diff --git a/pd/src/g_slider.c b/pd/src/g_slider.c
index abe3a350e..a993ca7a5 100644
--- a/pd/src/g_slider.c
+++ b/pd/src/g_slider.c
@@ -599,10 +599,10 @@ static void *slider_new(t_symbol *s, int argc, t_atom *argv)
     if (x->x_orient)
     {
         x->x_gui.legacy_x = 0;
-        x->x_gui.legacy_y = -2;
+        x->x_gui.legacy_y = -1;
     } else {
         x->x_gui.legacy_x = -3;
-        x->x_gui.legacy_y = 0;        
+        x->x_gui.legacy_y = 1;
     }
 
 
diff --git a/pd/src/g_toggle.c b/pd/src/g_toggle.c
index 36a4aa97f..089115e53 100644
--- a/pd/src/g_toggle.c
+++ b/pd/src/g_toggle.c
@@ -422,7 +422,7 @@ static void *toggle_new(t_symbol *s, int argc, t_atom *argv)
     x->x_gui.x_changed = 1;
 
     x->x_gui.legacy_x = 0;
-    x->x_gui.legacy_y = 0;
+    x->x_gui.legacy_y = 1;
 
     //x->x_gui.click_x = 1;
     //x->x_gui.click_y = 2;
diff --git a/pd/src/g_vumeter.c b/pd/src/g_vumeter.c
index d09301570..7e09183f1 100644
--- a/pd/src/g_vumeter.c
+++ b/pd/src/g_vumeter.c
@@ -751,7 +751,7 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv)
     x->x_gui.x_obj.te_iemgui = 1;
 
     x->x_gui.legacy_x = -1;
-    x->x_gui.legacy_y = -2;
+    x->x_gui.legacy_y = -1;
 
     return (x);
 }
-- 
GitLab