aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--colorpanel.c14
-rw-r--r--colorpanel.tcl8
2 files changed, 16 insertions, 6 deletions
diff --git a/colorpanel.c b/colorpanel.c
index a7ef291..7f46351 100644
--- a/colorpanel.c
+++ b/colorpanel.c
@@ -2,8 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <m_pd.h>
-
-#define DEBUG(x)
+#include <m_imp.h>
static t_class *colorpanel_class;
@@ -16,13 +15,12 @@ typedef struct _colorpanel
static void colorpanel_bang(t_colorpanel *x)
{
- sys_vgui("pd [concat %s callback [tk_chooseColor -initialcolor %s] \\;]\n",
+ sys_vgui("after idle [list after 100 ::hcs::colorpanel::open %s %s]\n",
x->x_s->s_name, x->current_color);
}
static void colorpanel_symbol(t_colorpanel *x, t_symbol *s)
{
- DEBUG(post("setting initial color: %s", s->s_name););
strncpy(x->current_color, s->s_name, MAXPDSTRING);
colorpanel_bang(x);
}
@@ -36,7 +34,8 @@ static void colorpanel_list(t_colorpanel *x, t_symbol *s, int argc, t_atom *argv
char color_string[MAXPDSTRING];
strncpy(color_string,"#",MAXPDSTRING);
- if(argc > 2) post("[colorpanel] warning more than three elements in list");
+ if(argc > 2)
+ logpost(x, 2, "[colorpanel] warning more than three elements in list");
for(i=0; i<3; i++)
{
tmp_symbol = atom_getsymbolarg(i, argc, argv);
@@ -52,7 +51,6 @@ static void colorpanel_list(t_colorpanel *x, t_symbol *s, int argc, t_atom *argv
}
}
memcpy(x->current_color, color_string, 7);
- DEBUG(post("setting initial color: %s", x->current_color););
colorpanel_bang(x);
}
@@ -99,4 +97,8 @@ void colorpanel_setup(void)
class_addlist(colorpanel_class, (t_method)colorpanel_list);
class_addmethod(colorpanel_class, (t_method)colorpanel_callback,
gensym("callback"), A_DEFSYMBOL, 0);
+
+ sys_vgui("eval [read [open {%s/%s.tcl}]]\n",
+ colorpanel_class->c_externdir->s_name,
+ colorpanel_class->c_name->s_name);
}
diff --git a/colorpanel.tcl b/colorpanel.tcl
new file mode 100644
index 0000000..23bc9e5
--- /dev/null
+++ b/colorpanel.tcl
@@ -0,0 +1,8 @@
+
+namespace eval ::hcs::colorpanel:: {
+}
+
+proc ::hcs::colorpanel::open {objectid initialcolor} {
+ set color [tk_chooseColor -initialcolor $initialcolor]
+ pdsend "$objectid callback $color"
+}