From 9d232d8e6976d60b46fc0f3d45cea1826405fda9 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 25 Oct 2011 04:02:25 +0000 Subject: worked around tk_colorPanel hang by adding 100ms delay before popping up the color panel svn path=/trunk/externals/hcs/; revision=15650 --- colorpanel.c | 14 ++++++++------ colorpanel.tcl | 8 ++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 colorpanel.tcl diff --git a/colorpanel.c b/colorpanel.c index a7ef291..7f46351 100644 --- a/colorpanel.c +++ b/colorpanel.c @@ -2,8 +2,7 @@ #include #include #include - -#define DEBUG(x) +#include 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" +} -- cgit v1.2.1