From 497e5c0c1410eb097eb0b560b75a180405bab834 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Fri, 29 Apr 2016 15:38:02 -0400
Subject: [PATCH] fix typo, add custom fg/bg colors for Scope.c

---
 externals/miXed/cyclone/sickle/Scope.c | 26 +++++++++++++++++++++-----
 pd/nw/pdgui.js                         | 20 ++++++++++++++++++++
 2 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/externals/miXed/cyclone/sickle/Scope.c b/externals/miXed/cyclone/sickle/Scope.c
index 338a34181..e949082a0 100644
--- a/externals/miXed/cyclone/sickle/Scope.c
+++ b/externals/miXed/cyclone/sickle/Scope.c
@@ -505,8 +505,15 @@ static void scope_frgb(t_scope *x, t_symbol *s, int ac, t_atom *av)
     x->x_fggreen = (int)fggreen;
     x->x_fgblue = (int)fgblue;
     if (cv = scope_isvisible(x))
-	sys_vgui(".x%x.c itemconfigure %s -fill #%2.2x%2.2x%2.2x\n",
-		 cv, x->x_fgtag, x->x_fgred, x->x_fggreen, x->x_fgblue);
+    {
+        char color[20];
+        sprintf(color, "#%2.2x%2.2x%2.2x",
+            x->x_fgred, x->x_fggreen, x->x_fgblue);
+	//sys_vgui(".x%x.c itemconfigure %s -fill #%2.2x%2.2x%2.2x\n",
+	//	 cv, x->x_fgtag, x->x_fgred, x->x_fggreen, x->x_fgblue);
+        gui_vmess("gui_scope_configure_fg_color", "xxs",
+            cv, x, color);
+    }
 }
 
 static void scope_brgb(t_scope *x, t_symbol *s, int ac, t_atom *av)
@@ -528,8 +535,15 @@ static void scope_brgb(t_scope *x, t_symbol *s, int ac, t_atom *av)
     x->x_bggreen = (int)bggreen;
     x->x_bgblue = (int)bgblue;
     if (cv = scope_isvisible(x))
-	sys_vgui(".x%x.c itemconfigure %s -fill #%2.2x%2.2x%2.2x\n",
-		 cv, x->x_bgtag, x->x_bgred, x->x_bggreen, x->x_bgblue);
+    {
+        char color[20];
+        sprintf(color, "#%2.2x%2.2x%2.2x",
+            x->x_bgred, x->x_bggreen, x->x_bgblue);
+	//sys_vgui(".x%x.c itemconfigure %s -fill #%2.2x%2.2x%2.2x\n",
+	//	 cv, x->x_bgtag, x->x_bgred, x->x_bggreen, x->x_bgblue);
+        gui_vmess("gui_scope_configure_bg_color", "xxs",
+            cv, x, color);
+    }
 }
 
 static void scope_getrect(t_gobj *z, t_glist *glist,
@@ -837,7 +851,8 @@ static void scope_redrawxy(t_scope *x, t_canvas *cv)
 
 static void scope_revis(t_scope *x, t_canvas *cv)
 {
-    sys_vgui(".x%x.c delete %s\n", cv, x->x_tag);
+//    sys_vgui(".x%x.c delete %s\n", cv, x->x_tag);
+    gui_vmess("gui_scope_clear_fg", "xx", cv, x);
     if (x->x_xymode)
 	scope_drawxy(x, cv);
     else
@@ -927,6 +942,7 @@ static void scope_setxymode(t_scope *x, int xymode)
 	if (cv = scope_isvisible(x))
 	{
 	    sys_vgui(".x%x.c delete %s\n", cv, x->x_fgtag);
+            gui_vmess("gui_scope_clear_fg", "xx", cv, x);
 	    if (!xymode)
 	    {
 		int x1, y1, x2, y2;
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index a2b86e4fc..242ae28d6 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -3048,6 +3048,7 @@ function gui_scope_draw_bg(cid, tag, fg_color, bg_color, w, h, grid_width, dx, d
             width: w,
             height: h,
             fill: bg_color,
+            class: "bg",
             stroke: "black",
             "stroke-width": grid_width
         }),
@@ -3109,6 +3110,25 @@ function gui_scope_configure_fg_mono(cid, tag, data_array) {
     scope_configure_fg(cid, tag, ".fgmono", data_array);
 }
 
+function gui_scope_configure_bg_color(cid, tag, color) {
+    var g = get_gobj(cid, tag),
+        elem = g.querySelector(".bg");
+    configure_item(elem, { fill: color });
+}
+
+function gui_scope_configure_fg_color(cid, tag, color) {
+     var g = get_gobj(cid, tag),
+        xy = g.querySelector(".fgxy"),
+        mono = g.querySelector(".fgmono");
+    configure_item(xy, { stroke: color });
+    configure_item(mono, { stroke: color });
+}
+
+function gui_scope_clear_fg(cid, tag) {
+    scope_configure_fg(cid, tag, ".fgxy", []);
+    scope_configure_fg(cid, tag, ".fgmono", []);
+}
+
 function add_popup(cid, popup) {
     popup_menu[cid] = popup;
 }
-- 
GitLab