From 5aef03b3a165b309622f6d051bd4d53c42b4532d Mon Sep 17 00:00:00 2001 From: Guenter Geiger Date: Mon, 25 Nov 2002 10:47:53 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r232, which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=233 --- pd/src/configure | 487 ++++++++- pd/src/configure.in | 30 +- pd/src/core.5452 | Bin 0 -> 266240 bytes pd/src/core.5470 | Bin 0 -> 266240 bytes pd/src/core.5487 | Bin 0 -> 266240 bytes pd/src/d_array.c | 6 +- pd/src/d_ctl.c | 6 +- pd/src/d_delay.c | 3 +- pd/src/d_filter.c | 16 +- pd/src/d_global.c | 9 +- pd/src/g_all_guis.c | 52 - pd/src/g_all_guis.h | 4 +- pd/src/g_bang.c | 18 +- pd/src/g_canvas.c | 48 +- pd/src/g_canvas.h | 27 +- pd/src/g_editor.c | 779 ++++++++++++-- pd/src/g_graph.c | 7 +- pd/src/g_hdial.c | 377 ++++--- pd/src/g_hslider.c | 23 - pd/src/g_mycanvas.c | 22 - pd/src/g_numbox.c | 330 +++--- pd/src/g_readwrite.c | 22 +- pd/src/g_template.c | 13 +- pd/src/g_text.c | 272 ++++- pd/src/g_toggle.c | 23 - pd/src/g_vdial.c | 362 ++++--- pd/src/g_vslider.c | 27 +- pd/src/g_vumeter.c | 26 - pd/src/m_binbuf.c | 11 +- pd/src/m_conf.c | 8 +- pd/src/m_obj.c | 6 + pd/src/m_pd.h | 14 +- pd/src/makefile.in | 29 +- pd/src/makefile.nt.bad | 92 ++ pd/src/notes.txt | 44 +- pd/src/s_linux.c | 2 +- pd/src/s_mac.c | 23 +- pd/src/s_main.c | 2 +- pd/src/s_unix.c | 11 +- pd/src/t_tkcmd.c | 2 +- pd/src/u_main.tk | 359 ++++--- pd/src/u_main.tk.test | 2686 ++++++++++++++++++++++++++++++++++++++++++++++++ pd/src/z.pd | 72 +- pd/src/z2.pd | 37 +- pd/src/z3.pd | 17 +- 45 files changed, 5295 insertions(+), 1109 deletions(-) create mode 100644 pd/src/core.5452 create mode 100644 pd/src/core.5470 create mode 100644 pd/src/core.5487 create mode 100644 pd/src/makefile.nt.bad create mode 100644 pd/src/u_main.tk.test (limited to 'pd/src') diff --git a/pd/src/configure b/pd/src/configure index 88e26a18..9205ddb3 100755 --- a/pd/src/configure +++ b/pd/src/configure @@ -2194,19 +2194,20 @@ echo "no X11 found" || exit 1 fi + ac_safe=`echo "tcl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for tcl.h""... $ac_c" 1>&6 -echo "configure:2200: checking for tcl.h" >&5 +echo "configure:2201: checking for tcl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2210: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2211: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2227,17 +2228,17 @@ else echo "$ac_t""no" 1>&6 ac_safe=`echo "tcl8.1/tcl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for tcl8.1/tcl.h""... $ac_c" 1>&6 -echo "configure:2231: checking for tcl8.1/tcl.h" >&5 +echo "configure:2232: checking for tcl8.1/tcl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2241: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2242: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2258,17 +2259,17 @@ else echo "$ac_t""no" 1>&6 ac_safe=`echo "tcl8.2/tcl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for tcl8.2/tcl.h""... $ac_c" 1>&6 -echo "configure:2262: checking for tcl8.2/tcl.h" >&5 +echo "configure:2263: checking for tcl8.2/tcl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2273: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2289,17 +2290,17 @@ else echo "$ac_t""no" 1>&6 ac_safe=`echo "tcl8.3/tcl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for tcl8.3/tcl.h""... $ac_c" 1>&6 -echo "configure:2293: checking for tcl8.3/tcl.h" >&5 +echo "configure:2294: checking for tcl8.3/tcl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2303: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2304: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2320,17 +2321,17 @@ else echo "$ac_t""no" 1>&6 ac_safe=`echo "tcl8.4/tcl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for tcl8.4/tcl.h""... $ac_c" 1>&6 -echo "configure:2324: checking for tcl8.4/tcl.h" >&5 +echo "configure:2325: checking for tcl8.4/tcl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2334: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2335: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2351,17 +2352,79 @@ else echo "$ac_t""no" 1>&6 ac_safe=`echo "tcl8.5/tcl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for tcl8.5/tcl.h""... $ac_c" 1>&6 -echo "configure:2355: checking for tcl8.5/tcl.h" >&5 +echo "configure:2356: checking for tcl8.5/tcl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2365: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2366: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + GUIFLAGS="$GUIFLAGS -I /usr/include/tcl8.5" +else + echo "$ac_t""no" 1>&6 +ac_safe=`echo "tcl8.6/tcl.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for tcl8.6/tcl.h""... $ac_c" 1>&6 +echo "configure:2387: checking for tcl8.6/tcl.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2397: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + GUIFLAGS="$GUIFLAGS -I /usr/include/tcl8.5" +else + echo "$ac_t""no" 1>&6 +ac_safe=`echo "tcl8.7/tcl.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for tcl8.7/tcl.h""... $ac_c" 1>&6 +echo "configure:2418: checking for tcl8.7/tcl.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2428: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2393,9 +2456,177 @@ fi fi +fi + +fi + + +echo $ac_n "checking for main in -ltcl8.7""... $ac_c" 1>&6 +echo "configure:2466: checking for main in -ltcl8.7" >&5 +ac_lib_var=`echo tcl8.7'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltcl8.7 $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo tcl8.7 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +echo $ac_n "checking for main in -ltcl8.6""... $ac_c" 1>&6 +echo "configure:2507: checking for main in -ltcl8.6" >&5 +ac_lib_var=`echo tcl8.6'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltcl8.6 $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo tcl8.6 | sed -e 's/^a-zA-Z0-9_/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +echo $ac_n "checking for main in -ltcl8.5""... $ac_c" 1>&6 +echo "configure:2548: checking for main in -ltcl8.5" >&5 +ac_lib_var=`echo tcl8.5'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltcl8.5 $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo tcl8.5 | sed -e 's/^a-zA-Z0-9_/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +echo $ac_n "checking for main in -ltcl8.4""... $ac_c" 1>&6 +echo "configure:2589: checking for main in -ltcl8.4" >&5 +ac_lib_var=`echo tcl8.4'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltcl8.4 $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo tcl8.4 | sed -e 's/^a-zA-Z0-9_/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 echo $ac_n "checking for main in -ltcl8.3""... $ac_c" 1>&6 -echo "configure:2399: checking for main in -ltcl8.3" >&5 +echo "configure:2630: checking for main in -ltcl8.3" >&5 ac_lib_var=`echo tcl8.3'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2403,14 +2634,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ltcl8.3 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2425,7 +2656,7 @@ LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo tcl8.3 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + ac_tr_lib=HAVE_LIB`echo tcl8.3 | sed -e 's/^a-zA-Z0-9_/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 echo $ac_n "checking for main in -ltcl8.2""... $ac_c" 1>&6 -echo "configure:2440: checking for main in -ltcl8.2" >&5 +echo "configure:2671: checking for main in -ltcl8.2" >&5 ac_lib_var=`echo tcl8.2'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2444,14 +2675,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ltcl8.2 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2477,7 +2708,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -ltcl8.0""... $ac_c" 1>&6 -echo "configure:2481: checking for main in -ltcl8.0" >&5 +echo "configure:2712: checking for main in -ltcl8.0" >&5 ac_lib_var=`echo tcl8.0'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2485,14 +2716,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ltcl8.0 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2523,9 +2754,181 @@ fi fi +fi + +fi + +fi + +fi + + +echo $ac_n "checking for main in -ltk8.7""... $ac_c" 1>&6 +echo "configure:2768: checking for main in -ltk8.7" >&5 +ac_lib_var=`echo tk8.7'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltk8.7 $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo tk8.7 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +echo $ac_n "checking for main in -ltk8.6""... $ac_c" 1>&6 +echo "configure:2809: checking for main in -ltk8.6" >&5 +ac_lib_var=`echo tk8.6'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltk8.6 $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo tk8.6 | sed -e 's/^a-zA-Z0-9_/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +echo $ac_n "checking for main in -ltk8.5""... $ac_c" 1>&6 +echo "configure:2850: checking for main in -ltk8.5" >&5 +ac_lib_var=`echo tk8.5'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltk8.5 $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo tk8.5 | sed -e 's/^a-zA-Z0-9_/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +echo $ac_n "checking for main in -ltk8.4""... $ac_c" 1>&6 +echo "configure:2891: checking for main in -ltk8.4" >&5 +ac_lib_var=`echo tk8.4'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltk8.4 $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo tk8.4 | sed -e 's/^a-zA-Z0-9_/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 echo $ac_n "checking for main in -ltk8.3""... $ac_c" 1>&6 -echo "configure:2529: checking for main in -ltk8.3" >&5 +echo "configure:2932: checking for main in -ltk8.3" >&5 ac_lib_var=`echo tk8.3'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2533,14 +2936,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ltk8.3 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2947: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2555,7 +2958,7 @@ LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo tk8.3 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + ac_tr_lib=HAVE_LIB`echo tk8.3 | sed -e 's/^a-zA-Z0-9_/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 echo $ac_n "checking for main in -ltk8.2""... $ac_c" 1>&6 -echo "configure:2570: checking for main in -ltk8.2" >&5 +echo "configure:2973: checking for main in -ltk8.2" >&5 ac_lib_var=`echo tk8.2'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2574,14 +2977,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ltk8.2 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2607,7 +3010,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -ltk8.0""... $ac_c" 1>&6 -echo "configure:2611: checking for main in -ltk8.0" >&5 +echo "configure:3014: checking for main in -ltk8.0" >&5 ac_lib_var=`echo tk8.0'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2615,14 +3018,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ltk8.0 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3029: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2653,6 +3056,14 @@ fi fi +fi + +fi + +fi + +fi + diff --git a/pd/src/configure.in b/pd/src/configure.in index ad1eba66..edc2250c 100644 --- a/pd/src/configure.in +++ b/pd/src/configure.in @@ -82,21 +82,33 @@ dnl Checking for `XCreateWindow' function in -lX11: AC_CHECK_LIB(X11, XCreateWindow, LIBS="$LIBS -lX11 -L$x_libraries", echo "no X11 found" || exit 1, -L$x_libraries) +dnl look for tcl 8.x... do I really have to go through all this!? + AC_CHECK_HEADER(tcl.h,, AC_CHECK_HEADER(tcl8.1/tcl.h,GUIFLAGS="$GUIFLAGS -I /usr/include/tcl8.1", AC_CHECK_HEADER(tcl8.2/tcl.h,GUIFLAGS="$GUIFLAGS -I /usr/include/tcl8.2", AC_CHECK_HEADER(tcl8.3/tcl.h,GUIFLAGS="$GUIFLAGS -I /usr/include/tcl8.3", AC_CHECK_HEADER(tcl8.4/tcl.h,GUIFLAGS="$GUIFLAGS -I /usr/include/tcl8.4", AC_CHECK_HEADER(tcl8.5/tcl.h,GUIFLAGS="$GUIFLAGS -I /usr/include/tcl8.5", - echo "no tcl/tk header found" || exit 1)))))) - -AC_CHECK_LIB(tcl8.3, main,, - AC_CHECK_LIB(tcl8.2, main,, - AC_CHECK_LIB(tcl8.0, main))) - -AC_CHECK_LIB(tk8.3, main,, - AC_CHECK_LIB(tk8.2, main,, - AC_CHECK_LIB(tk8.0, main))) + AC_CHECK_HEADER(tcl8.6/tcl.h,GUIFLAGS="$GUIFLAGS -I /usr/include/tcl8.5", + AC_CHECK_HEADER(tcl8.7/tcl.h,GUIFLAGS="$GUIFLAGS -I /usr/include/tcl8.5", + echo "no tcl/tk header found" || exit 1)))))))) + +AC_CHECK_LIB(tcl8.7, main,, + AC_CHECK_LIB(tcl8.6, main,, + AC_CHECK_LIB(tcl8.5, main,, + AC_CHECK_LIB(tcl8.4, main,, + AC_CHECK_LIB(tcl8.3, main,, + AC_CHECK_LIB(tcl8.2, main,, + AC_CHECK_LIB(tcl8.0, main))))))) + +AC_CHECK_LIB(tk8.7, main,, + AC_CHECK_LIB(tk8.6, main,, + AC_CHECK_LIB(tk8.5, main,, + AC_CHECK_LIB(tk8.4, main,, + AC_CHECK_LIB(tk8.3, main,, + AC_CHECK_LIB(tk8.2, main,, + AC_CHECK_LIB(tk8.0, main))))))) dnl Checking for tk.h or tkstep.h - not used at the moment dnl AC_CHECK_HEADER(tk.h,DEFINES="$DEFINES -DTKINC=\\\"tk.h\\\"") diff --git a/pd/src/core.5452 b/pd/src/core.5452 new file mode 100644 index 00000000..56382f9f Binary files /dev/null and b/pd/src/core.5452 differ diff --git a/pd/src/core.5470 b/pd/src/core.5470 new file mode 100644 index 00000000..d07e2d4a Binary files /dev/null and b/pd/src/core.5470 differ diff --git a/pd/src/core.5487 b/pd/src/core.5487 new file mode 100644 index 00000000..3b2acc4a Binary files /dev/null and b/pd/src/core.5487 differ diff --git a/pd/src/d_array.c b/pd/src/d_array.c index 3491ad35..e870b522 100644 --- a/pd/src/d_array.c +++ b/pd/src/d_array.c @@ -52,8 +52,7 @@ static t_int *tabwrite_tilde_perform(t_int *w) while (nxfer--) { float f = *in++; - /* bash NANs and underflow/overflow hazards to zero */ - if (!((f > 1.0e-20f && f < 1.0e20f) || (f < -1e-20f && f > -1e20))) + if (PD_BADFLOAT(f)) f = 0; *fp++ = f; } @@ -735,8 +734,7 @@ static t_int *tabsend_perform(t_int *w) while (n--) { float f = *in++; - /* bash NANs and underflow/overflow hazards to zero */ - if (!((f > 1.0e-20f && f < 1.0e20f) || (f < -1e-20f && f > -1e20))) + if (PD_BADFLOAT(f)) f = 0; *dest++ = f; } diff --git a/pd/src/d_ctl.c b/pd/src/d_ctl.c index e143a067..461703d2 100644 --- a/pd/src/d_ctl.c +++ b/pd/src/d_ctl.c @@ -105,9 +105,9 @@ static t_int *line_perform(t_int *w) t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); float f = x->x_value; - /* bash NANs and underflow/overflow hazards to zero */ - if (!((f > 1.0e-20f && f < 1.0e20f) || (f < -1e-20f && f > -1e20))) - x->x_value = f = 0; + + if (PD_BADFLOAT(f)) + x->x_value = f = 0; if (x->x_retarget) { int nticks = x->x_inletwas * x->x_msectodsptick; diff --git a/pd/src/d_delay.c b/pd/src/d_delay.c index f14bb112..edcf1235 100644 --- a/pd/src/d_delay.c +++ b/pd/src/d_delay.c @@ -78,8 +78,7 @@ static t_int *sigdelwrite_perform(t_int *w) while (n--) { float f = *in++; - /* bash NANs and underflow/overflow hazards to zero */ - if (!((f > 1.0e-20f && f < 1.0e20f) || (f < -1e-20f && f > -1e20))) + if (PD_BADFLOAT(f)) f = 0; *bp++ = f; if (bp == ep) diff --git a/pd/src/d_filter.c b/pd/src/d_filter.c index 1693cd85..88318900 100644 --- a/pd/src/d_filter.c +++ b/pd/src/d_filter.c @@ -4,7 +4,6 @@ /* "filters", both linear and nonlinear. */ - #include "m_pd.h" #include @@ -65,9 +64,8 @@ static t_int *sighip_perform(t_int *w) *out++ = new - last; last = new; } - /* NAN protect */ - if (!((last <= 0) || (last >= 0))) - last = 0; + if (PD_BADFLOAT(last)) + last = 0; c->c_x = last; return (w+5); } @@ -158,8 +156,7 @@ static t_int *siglop_perform(t_int *w) float feedback = 1 - coef; for (i = 0; i < n; i++) last = *out++ = coef * *in++ + feedback * last; - /* NAN protect */ - if (!((last <= 0) || (last >= 0))) + if (PD_BADFLOAT(last)) last = 0; c->c_x = last; return (w+5); @@ -290,10 +287,9 @@ static t_int *sigbp_perform(t_int *w) prev = last; last = output; } - /* NAN protect */ - if (!((last <= 0) || (last >= 0))) + if (PD_BADFLOAT(last)) last = 0; - if (!((prev <= 0) || (prev >= 0))) + if (PD_BADFLOAT(prev)) prev = 0; c->c_x1 = last; c->c_x2 = prev; @@ -376,6 +372,8 @@ static t_int *sigbiquad_perform(t_int *w) for (i = 0; i < n; i++) { float output = *in++ + fb1 * last + fb2 * prev; + if (PD_BADFLOAT(output)) + output = 0; *out++ = ff1 * output + ff2 * last + ff3 * prev; prev = last; last = output; diff --git a/pd/src/d_global.c b/pd/src/d_global.c index 633eba1c..a84a1ae0 100644 --- a/pd/src/d_global.c +++ b/pd/src/d_global.c @@ -41,9 +41,9 @@ static t_int *sigsend_perform(t_int *w) while (n--) { float f = *in++; - /* bash NANs and underflow/overflow hazards to zero */ - if (!((f > 1.0e-20f && f < 1.0e20f) || (f < -1e-20f && f > -1e20))) + if (PD_BADFLOAT(f)) f = 0; + *out++ = f; } return (w+4); @@ -245,9 +245,8 @@ static t_int *sigthrow_perform(t_int *w) while (n--) { float f = *in++; - /* bash NANs and underflow/overflow hazards to zero */ - if (!((f > 1.0e-20f && f < 1.0e20f) || (f < -1e-20f && f > -1e20))) - f = 0; + if (PD_BADFLOAT(f)) + f = 0; *out++ += f; } } diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index 5bbf2f4a..db562404 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -26,8 +26,6 @@ /*------------------ global varaibles -------------------------*/ -t_symbol *iemgui_key_sym=0; - int iemgui_color_hex[]= { 16579836, 10526880, 4210752, 16572640, 16572608, @@ -741,56 +739,6 @@ void iemgui_color(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_CONFIG); } -int iemgui_list(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) -{ - if(iemgui->x_fsf.x_selected) - { - if((ac == 2)&&IS_A_FLOAT(av,0)&&IS_A_SYMBOL(av,1)) - { - t_symbol *key = atom_getsymbolarg(1, ac, av); - int keydown = atom_getintarg(0, ac, av); - - if(keydown) - { - int refresh = 1,i,d=1; - static char buf[20]; - - buf[0] = 0; - if(!strcmp(key->s_name, "Shift_L")||!strcmp(key->s_name, "Shift_R")) - iemgui->x_fsf.x_shiftdown = 1; - else - { - if(iemgui->x_fsf.x_shiftdown) - d = 10; - if(!strcmp(key->s_name, "Up")) - iemgui->x_obj.te_ypix -= d; - else if(!strcmp(key->s_name, "Down")) - iemgui->x_obj.te_ypix += d; - else if(!strcmp(key->s_name, "Left")) - iemgui->x_obj.te_xpix -= d; - else if(!strcmp(key->s_name, "Right")) - iemgui->x_obj.te_xpix += d; - else - refresh = 0; - if(refresh) - return(1); - } - return(0); - } - else - { - if(!strcmp(key->s_name, "Shift_L")||!strcmp(key->s_name, "Shift_R")) - iemgui->x_fsf.x_shiftdown = 0; - return(0); - } - } - else - return(-1); - } - else - return(-1); -} - void iemgui_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_iemguidummy *x = (t_iemguidummy *)z; diff --git a/pd/src/g_all_guis.h b/pd/src/g_all_guis.h index 54f9cef4..ec9d4e69 100644 --- a/pd/src/g_all_guis.h +++ b/pd/src/g_all_guis.h @@ -265,8 +265,10 @@ typedef struct _vdial t_atom x_at[2]; } t_vdial; +#define t_vradio t_vdial +#define t_hradio t_hdial + extern int sys_noloadbang; -extern t_symbol *iemgui_key_sym; extern int iemgui_color_hex[]; extern int iemgui_vu_db2i[]; extern int iemgui_vu_col[]; diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c index cb92c685..399f45f4 100644 --- a/pd/src/g_bang.c +++ b/pd/src/g_bang.c @@ -151,14 +151,12 @@ void bng_draw_select(t_bng* x, t_glist* glist) if(x->x_gui.x_fsf.x_selected) { - pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); sys_vgui(".x%x.c itemconfigure %xBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); } else { - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); sys_vgui(".x%x.c itemconfigure %xBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); @@ -359,17 +357,7 @@ static void bng_pointer(t_bng *x, t_gpointer *gp) static void bng_list(t_bng *x, t_symbol *s, int ac, t_atom *av) { - int l=iemgui_list((void *)x, &x->x_gui, s, ac, av); - - if(l < 0) - { - bng_bang2(x); - } - else if(l > 0) - { - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - } + bng_bang2(x); } static void bng_anything(t_bng *x, t_symbol *s, int argc, t_atom *argv) @@ -548,8 +536,6 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv) static void bng_ff(t_bng *x) { - if(x->x_gui.x_fsf.x_selected) - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); if(x->x_gui.x_fsf.x_rcv_able) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); clock_free(x->x_clock_lck); @@ -584,8 +570,6 @@ void g_bang_setup(void) class_addmethod(bng_class, (t_method)bng_label_pos, gensym("label_pos"), A_GIMME, 0); class_addmethod(bng_class, (t_method)bng_label_font, gensym("label_font"), A_GIMME, 0); class_addmethod(bng_class, (t_method)bng_init, gensym("init"), A_FLOAT, 0); - if(!iemgui_key_sym) - iemgui_key_sym = gensym("#keyname"); bng_widgetbehavior.w_getrectfn = bng_getrect; bng_widgetbehavior.w_displacefn = iemgui_displace; bng_widgetbehavior.w_selectfn = iemgui_select; diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index c63b2c0b..8bad09a9 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -254,6 +254,15 @@ void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir) /* --------------- traversing the set of lines in a canvas ----------- */ +int canvas_getindex(t_canvas *x, t_gobj *y) +{ + t_gobj *y2; + int indexno; + for (indexno = 0, y2 = x->gl_list; y2 && y2 != y; y2 = y2->g_next) + indexno++; + return (indexno); +} + void linetraverser_start(t_linetraverser *t, t_canvas *x) { t->tr_ob = 0; @@ -516,10 +525,13 @@ int glist_isgraph(t_glist *x) moved or resized. */ static void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2) { + int heightwas = y2 - y1; + int heightchange = y2 - y1 - (x->gl_screeny2 - x->gl_screeny1); x->gl_screenx1 = x1; x->gl_screeny1 = y1; x->gl_screenx2 = x2; x->gl_screeny2 = y2; + /* post("set bounds %d %d %d %d", x1, y1, x2, y2); */ if (!glist_isgraph(x) && (x->gl_y2 < x->gl_y1)) { /* if it's flipped so that y grows upward, @@ -527,8 +539,14 @@ static void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2) only appropriate if we're a regular "text" object on the parent. */ float diff = x->gl_y1 - x->gl_y2; - x->gl_y1 = x->gl_screeny2 * diff; + t_gobj *y; + x->gl_y1 = heightwas * diff; x->gl_y2 = x->gl_y1 - diff; + /* and move text objects accordingly; they should stick + to the bottom, not the top. */ + for (y = x->gl_list; y; y = y->g_next) + if (pd_checkobject(&y->g_pd)) + gobj_displace(y, x, 0, heightchange); canvas_redraw(x); } } @@ -607,6 +625,9 @@ void canvas_map(t_canvas *x, t_floatarg f) canvas_selectme = 0; } canvas_drawlines(x); + /* simulate a mouse up so u_main will calculate scrollbars... + ugly! */ + sys_vgui("pdtk_canvas_mouseup .x%x.c 0 0 0\n", x); } } else @@ -700,15 +721,12 @@ void canvas_vis(t_canvas *x, t_floatarg f) else { canvas_create_editor(x, 1); - sys_vgui("pdtk_canvas_new .x%x %d %d +%d+%d\n", x, + sys_vgui("pdtk_canvas_new .x%x %d %d +%d+%d %d\n", x, (int)(x->gl_screenx2 - x->gl_screenx1), (int)(x->gl_screeny2 - x->gl_screeny1), - (int)(x->gl_screenx1), (int)(x->gl_screeny1) - ); + (int)(x->gl_screenx1), (int)(x->gl_screeny1), + x->gl_edit); canvas_reflecttitle(x); - /* simulate a mouse up so u_main will calculate scrollbars... - ugly! */ - sys_vgui("pdtk_canvas_mouseup .x%x.c 0 0 0\n", x); x->gl_havewindow = 1; canvas_updatewindowlist(); } @@ -799,6 +817,7 @@ void canvas_free(t_canvas *x) t_gobj *y; int dspstate = canvas_suspend_dsp(); + canvas_noundo(x); if (canvas_editing == x) canvas_editing = 0; if (canvas_whichfind == x) @@ -831,9 +850,11 @@ static void canvas_drawlines(t_canvas *x) { linetraverser_start(&t, x); while (oc = linetraverser_next(&t)) - sys_vgui(".x%x.c create line %d %d %d %d -tags l%x\n", + sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n", glist_getcanvas(x), - t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2, oc); + t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2, + (outlet_getsymbol(t.tr_outlet) == &s_signal ? 2:1), + oc); } } @@ -1376,7 +1397,12 @@ extern void canvas_toggle(t_glist *gl, t_symbol *s, int argc, t_atom *argv); extern void canvas_vslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv); extern void canvas_hslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv); extern void canvas_vdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv); + /* old version... */ extern void canvas_hdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv); +extern void canvas_hdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv); + /* new version: */ +extern void canvas_hradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv); +extern void canvas_vradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv); extern void canvas_vumeter(t_glist *gl, t_symbol *s, int argc, t_atom *argv); extern void canvas_mycnv(t_glist *gl, t_symbol *s, int argc, t_atom *argv); extern void canvas_numbox(t_glist *gl, t_symbol *s, int argc, t_atom *argv); @@ -1434,6 +1460,10 @@ void g_canvas_setup(void) A_GIMME, A_NULL); class_addmethod(canvas_class, (t_method)canvas_vdial, gensym("vdial"), A_GIMME, A_NULL); + class_addmethod(canvas_class, (t_method)canvas_hradio, gensym("hradio"), + A_GIMME, A_NULL); + class_addmethod(canvas_class, (t_method)canvas_vradio, gensym("vradio"), + A_GIMME, A_NULL); class_addmethod(canvas_class, (t_method)canvas_vumeter, gensym("vumeter"), A_GIMME, A_NULL); class_addmethod(canvas_class, (t_method)canvas_mycnv, gensym("mycnv"), diff --git a/pd/src/g_canvas.h b/pd/src/g_canvas.h index fb567ea5..5348f25f 100644 --- a/pd/src/g_canvas.h +++ b/pd/src/g_canvas.h @@ -66,9 +66,6 @@ EXTERN_STRUCT _tscalar; EXTERN_STRUCT _canvasenvironment; #define t_canvasenvironment struct _canvasenvironment -EXTERN_STRUCT _linetraverser; -#define t_linetraverser struct _linetraverser - typedef struct _selection { t_gobj *sel_what; @@ -92,9 +89,15 @@ typedef struct _editor struct _glist *e_glist; /* glist which owns this */ int e_xwas; /* xpos on last mousedown or motion event */ int e_ywas; /* ypos, similarly */ + int e_selectline_index1; /* indices for the selected line if any */ + int e_selectline_outno; /* (only valid if e_selectedline is set) */ + int e_selectline_index2; + int e_selectline_inno; + t_outconnect *e_selectline_tag; unsigned int e_onmotion: 3; /* action to take on motion */ unsigned int e_lastmoved: 1; /* one if mouse has moved since click */ unsigned int e_textdirty: 1; /* one if e_textedfor has changed */ + unsigned int e_selectedline: 1; /* one if a line is selected */ } t_editor; #define MA_NONE 0 /* e_onmotion: do nothing on mouse motion */ @@ -166,7 +169,6 @@ struct _glist unsigned int gl_edit:1; /* edit mode */ unsigned int gl_imatemplate:1; /* someone needs me as template */ unsigned int gl_isdeleting:1; /* we're inside glist_delete -- hack! */ - unsigned int gl_protect:1; /* don't delete connections on click */ unsigned int gl_stretch:1; /* stretch contents on resize */ unsigned int gl_isgraph:1; /* show as graph on parent */ }; @@ -209,7 +211,7 @@ struct _array }; /* structure for traversing all the connections in a glist */ -struct _linetraverser +typedef struct _linetraverser { t_canvas *tr_x; t_object *tr_ob; @@ -225,7 +227,7 @@ struct _linetraverser int tr_lx1, tr_ly1, tr_lx2, tr_ly2; t_outconnect *tr_nextoc; int tr_nextoutno; -}; +} t_linetraverser; /* function types used to define graphical behavior for gobjs, a bit like X widgets. We don't use Pd methods because Pd's typechecking can't specify the @@ -388,6 +390,9 @@ EXTERN void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime, char *tag, int x1, int y1, int x2, int y2); EXTERN void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag); EXTERN void canvas_create_editor(t_glist *x, int createit); +void canvas_deletelinesforio(t_canvas *x, t_text *text, + t_inlet *inp, t_outlet *outp); + /* -------------------- functions on texts ------------------------- */ EXTERN void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize); @@ -470,6 +475,16 @@ EXTERN int canvas_hitbox(t_canvas *x, t_gobj *y, int xpos, int ypos, int *x1p, int *y1p, int *x2p, int *y2p); EXTERN int canvas_setdeleting(t_canvas *x, int flag); +typedef void (*t_undofn)(t_canvas *canvas, void *buf, + int action); /* a function that does UNDO/REDO */ +#define UNDO_FREE 0 /* free current undo/redo buffer */ +#define UNDO_UNDO 1 /* undo */ +#define UNDO_REDO 2 /* redo */ +EXTERN void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf, + const char *name); +EXTERN void canvas_noundo(t_canvas *x); +EXTERN int canvas_getindex(t_canvas *x, t_gobj *y); + /* ---- functions on canvasses as objects --------------------- */ EXTERN void canvas_fattenforscalars(t_canvas *x, diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 4e6783ff..101c655a 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -11,10 +11,15 @@ void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, int selectem); -/* ------------------ forward function declarations --------------- */ +/* ------------------ forward declarations --------------- */ static void canvas_doclear(t_canvas *x); static void glist_setlastxy(t_glist *gl, int xval, int yval); static void glist_donewloadbangs(t_glist *x); +static t_binbuf *canvas_docopy(t_canvas *x); +static void canvas_dopaste(t_canvas *x, t_binbuf *b); +static void canvas_paste(t_canvas *x); +static void canvas_clearline(t_canvas *x); +static t_binbuf *copy_binbuf; /* ---------------- generic widget behavior ------------------------- */ @@ -78,6 +83,33 @@ void gobj_properties(t_gobj *x, struct _glist *glist) /* ------------------------ managing the selection ----------------- */ +void glist_selectline(t_glist *x, t_outconnect *oc, int index1, + int outno, int index2, int inno) +{ + if (x->gl_editor) + { + glist_noselect(x); + x->gl_editor->e_selectedline = 1; + x->gl_editor->e_selectline_index1 = index1; + x->gl_editor->e_selectline_outno = outno; + x->gl_editor->e_selectline_index2 = index2; + x->gl_editor->e_selectline_inno = inno; + x->gl_editor->e_selectline_tag = oc; + sys_vgui(".x%x.c itemconfigure l%x -fill blue\n", + x, x->gl_editor->e_selectline_tag); + } +} + +void glist_deselectline(t_glist *x) +{ + if (x->gl_editor) + { + x->gl_editor->e_selectedline = 0; + sys_vgui(".x%x.c itemconfigure l%x -fill black\n", + x, x->gl_editor->e_selectline_tag); + } +} + int glist_isselected(t_glist *x, t_gobj *y) { if (x->gl_editor) @@ -95,6 +127,8 @@ void glist_select(t_glist *x, t_gobj *y) if (x->gl_editor) { t_selection *sel = (t_selection *)getbytes(sizeof(*sel)); + if (x->gl_editor->e_selectedline) + glist_deselectline(x); /* LATER #ifdef out the following check */ if (glist_isselected(x, y)) bug("glist_select"); sel->sel_next = x->gl_editor->e_selection; @@ -169,8 +203,13 @@ void glist_deselect(t_glist *x, t_gobj *y) void glist_noselect(t_glist *x) { - if (x->gl_editor) while (x->gl_editor->e_selection) - glist_deselect(x, x->gl_editor->e_selection->sel_what); + if (x->gl_editor) + { + while (x->gl_editor->e_selection) + glist_deselect(x, x->gl_editor->e_selection->sel_what); + if (x->gl_editor->e_selectedline) + glist_deselectline(x); + } } void glist_selectall(t_glist *x) @@ -198,6 +237,428 @@ void glist_selectall(t_glist *x) } } + /* get the index of a gobj in a glist. If y is zero, return the + total number of objects. */ +int glist_getindex(t_glist *x, t_gobj *y) +{ + t_gobj *y2; + int indx; + + for (y2 = x->gl_list, indx = 0; y2 && y2 != y; y2 = y2->g_next) + indx++; + return (indx); +} + + /* get the index of the object, among selected items, if "selected" + is set; otherwise, among unselected ones. If y is zero, just + counts the selected or unselected objects. */ +int glist_selectionindex(t_glist *x, t_gobj *y, int selected) +{ + t_gobj *y2; + int indx; + + for (y2 = x->gl_list, indx = 0; y2 && y2 != y; y2 = y2->g_next) + if (selected == glist_isselected(x, y2)) + indx++; + return (indx); +} + +static t_gobj *glist_nth(t_glist *x, int n) +{ + t_gobj *y; + int indx; + for (y = x->gl_list, indx = 0; y; y = y->g_next, indx++) + if (indx == n) + return (y); + return (0); +} + +/* ------------------- support for undo/redo -------------------------- */ + +static t_undofn canvas_undo_fn; /* current undo function if any */ +static int canvas_undo_whatnext; /* whether we can now UNDO or REDO */ +static void *canvas_undo_buf; /* data private to the undo function */ +static t_canvas *canvas_undo_canvas; /* which canvas we can undo on */ +static const char *canvas_undo_name; + +void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf, + const char *name) +{ + int hadone = 0; + /* blow away the old undo information. In one special case the + old undo info is re-used; if so we shouldn't free it here. */ + if (canvas_undo_fn && canvas_undo_buf && (buf != canvas_undo_buf)) + { + (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_FREE); + hadone = 1; + } + canvas_undo_canvas = x; + canvas_undo_fn = undofn; + canvas_undo_buf = buf; + canvas_undo_whatnext = UNDO_UNDO; + canvas_undo_name = name; + if (x) + /* enable undo in menu */ + sys_vgui("pdtk_undomenu .x%x %s no\n", x, name); + else if (hadone) sys_vgui("pdtk_undomenu .x%x no no\n", x, name); +} + + /* clear undo if it happens to be for the canvas x. + (but if x is 0, clear it regardless of who owns it.) */ +void canvas_noundo(t_canvas *x) +{ + if (!x || (x == canvas_undo_canvas)) + canvas_setundo(0, 0, 0, "foo"); +} + +static void canvas_undo(t_canvas *x) +{ + if (x != canvas_undo_canvas) + bug("canvas_undo 1"); + else if (canvas_undo_whatnext != UNDO_UNDO) + bug("canvas_undo 2"); + else + { + /* post("undo"); */ + (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_UNDO); + /* enable redo in menu */ + sys_vgui("pdtk_undomenu .x%x no %s\n", x, canvas_undo_name); + canvas_undo_whatnext = UNDO_REDO; + } +} + +static void canvas_redo(t_canvas *x) +{ + if (x != canvas_undo_canvas) + bug("canvas_undo 1"); + else if (canvas_undo_whatnext != UNDO_REDO) + bug("canvas_undo 2"); + else + { + /* post("redo"); */ + (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_REDO); + /* enable undo in menu */ + sys_vgui("pdtk_undomenu .x%x %s no\n", x, canvas_undo_name); + canvas_undo_whatnext = UNDO_UNDO; + } +} + +/* ------- specific undo methods: 1. connect and disconnect -------- */ + +typedef struct _undo_connect +{ + int u_index1; + int u_outletno; + int u_index2; + int u_inletno; +} t_undo_connect; + +static void *canvas_undo_set_disconnect(t_canvas *x, + int index1, int outno, int index2, int inno) +{ + t_undo_connect *buf = (t_undo_connect *)getbytes(sizeof(*buf)); + buf->u_index1 = index1; + buf->u_outletno = outno; + buf->u_index2 = index2; + buf->u_inletno = inno; + return (buf); +} + +static void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno, + t_floatarg fwhoin, t_floatarg finno); + +static void canvas_disconnect(t_canvas *x, + int index1, int outno, int index2, int inno) +{ + t_linetraverser t; + t_outconnect *oc; + linetraverser_start(&t, x); + while (oc = linetraverser_next(&t)) + { + int srcno = canvas_getindex(x, &t.tr_ob->ob_g); + int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g); + if (srcno == index1 && t.tr_outno == outno && + sinkno == index2 && t.tr_inno == inno) + { + sys_vgui(".x%x.c delete l%x\n", x, oc); + obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno); + break; + } + } +} + +static void canvas_undo_disconnect(t_canvas *x, void *z, int action) +{ + t_undo_connect *buf = z; + if (action == UNDO_UNDO) + { + canvas_connect(x, buf->u_index1, buf->u_outletno, + buf->u_index2, buf->u_inletno); + } + else if (action == UNDO_REDO) + { + canvas_disconnect(x, buf->u_index1, buf->u_outletno, + buf->u_index2, buf->u_inletno); + } + else if (action == UNDO_FREE) + t_freebytes(buf, sizeof(*buf)); +} + + /* connect just calls disconnect actions backward... */ +static void *canvas_undo_set_connect(t_canvas *x, + int index1, int outno, int index2, int inno) +{ + return (canvas_undo_set_disconnect(x, index1, outno, index2, inno)); +} + +static void canvas_undo_connect(t_canvas *x, void *z, int action) +{ + int myaction; + if (action == UNDO_UNDO) + myaction = UNDO_REDO; + else if (action == UNDO_REDO) + myaction = UNDO_UNDO; + else myaction = action; + canvas_undo_disconnect(x, z, myaction); +} + +/* ---------- ... 2. cut, clear, and typing into objects: -------- */ + +#define UCUT_CUT 1 /* operation was a cut */ +#define UCUT_CLEAR 2 /* .. a clear */ +#define UCUT_TEXT 3 /* text typed into a box */ + +typedef struct _undo_cut +{ + t_binbuf *u_objectbuf; /* the object cleared or typed into */ + t_binbuf *u_reconnectbuf; /* connections into and out of object */ + t_binbuf *u_redotextbuf; /* buffer to paste back for redo if TEXT */ + int u_mode; /* from flags above */ +} t_undo_cut; + +static void *canvas_undo_set_cut(t_canvas *x, int mode) +{ + t_undo_cut *buf; + t_gobj *y; + t_linetraverser t; + t_outconnect *oc; + int nnotsel= glist_selectionindex(x, 0, 0); + buf = (t_undo_cut *)getbytes(sizeof(*buf)); + buf->u_mode = mode; + buf->u_redotextbuf = 0; + + /* store connections into/out of the selection */ + buf->u_reconnectbuf = binbuf_new(); + linetraverser_start(&t, x); + while (oc = linetraverser_next(&t)) + { + int issel1 = glist_isselected(x, &t.tr_ob->ob_g); + int issel2 = glist_isselected(x, &t.tr_ob2->ob_g); + if (issel1 != issel2) + { + binbuf_addv(buf->u_reconnectbuf, "ssiiii;", + gensym("#X"), gensym("connect"), + (issel1 ? nnotsel : 0) + + glist_selectionindex(x, &t.tr_ob->ob_g, issel1), + t.tr_outno, + (issel2 ? nnotsel : 0) + + glist_selectionindex(x, &t.tr_ob2->ob_g, issel2), + t.tr_inno); + } + } + if (mode == UCUT_TEXT) + { + buf->u_objectbuf = canvas_docopy(x); + } + else if (mode == UCUT_CUT) + { + buf->u_objectbuf = 0; + } + else if (mode == UCUT_CLEAR) + { + buf->u_objectbuf = canvas_docopy(x); + } + return (buf); +} + +static void canvas_undo_cut(t_canvas *x, void *z, int action) +{ + t_undo_cut *buf = z; + int mode = buf->u_mode; + if (action == UNDO_UNDO) + { + if (mode == UCUT_CUT) + canvas_dopaste(x, copy_binbuf); + else if (mode == UCUT_CLEAR) + canvas_dopaste(x, buf->u_objectbuf); + else if (mode == UCUT_TEXT) + { + t_gobj *y1, *y2; + for (y1 = x->gl_list; y2 = y1->g_next; y1 = y2) + ; + if (y1) + { + if (!buf->u_redotextbuf) + { + glist_noselect(x); + glist_select(x, y1); + buf->u_redotextbuf = canvas_docopy(x); + glist_noselect(x); + } + glist_delete(x, y1); + } + canvas_dopaste(x, buf->u_objectbuf); + } + pd_bind(&x->gl_pd, gensym("#X")); + binbuf_eval(buf->u_reconnectbuf, 0, 0, 0); + pd_unbind(&x->gl_pd, gensym("#X")); + } + else if (action == UNDO_REDO) + { + if (mode == UCUT_CUT || mode == UCUT_CLEAR) + canvas_doclear(x); + else if (mode == UCUT_TEXT) + { + t_gobj *y1, *y2; + for (y1 = x->gl_list; y2 = y1->g_next; y1 = y2) + ; + if (y1) + glist_delete(x, y1); + canvas_dopaste(x, buf->u_redotextbuf); + pd_bind(&x->gl_pd, gensym("#X")); + binbuf_eval(buf->u_reconnectbuf, 0, 0, 0); + pd_unbind(&x->gl_pd, gensym("#X")); + } + } + else if (action == UNDO_FREE) + { + if (buf->u_objectbuf) + binbuf_free(buf->u_objectbuf); + if (buf->u_reconnectbuf) + binbuf_free(buf->u_reconnectbuf); + if (buf->u_redotextbuf) + binbuf_free(buf->u_redotextbuf); + t_freebytes(buf, sizeof(*buf)); + } +} + +/* --------- 3. motion, including "tidy up" and stretching ----------- */ + +typedef struct _undo_move_elem +{ + int e_index; + int e_xpix; + int e_ypix; +} t_undo_move_elem; + +typedef struct _undo_move +{ + t_undo_move_elem *u_vec; + int u_n; +} t_undo_move; + +static int canvas_undo_already_set_move; + +static void *canvas_undo_set_move(t_canvas *x, int selected) +{ + int x1, y1, x2, y2, i, indx; + t_gobj *y; + t_undo_move *buf = (t_undo_move *)getbytes(sizeof(*buf)); + buf->u_n = selected ? glist_selectionindex(x, 0, 1) : glist_getindex(x, 0); + buf->u_vec = (t_undo_move_elem *)getbytes(sizeof(*buf->u_vec) * + (selected ? glist_selectionindex(x, 0, 1) : glist_getindex(x, 0))); + if (selected) + { + for (y = x->gl_list, i = indx = 0; y; y = y->g_next, indx++) + if (glist_isselected(x, y)) + { + gobj_getrect(y, x, &x1, &y1, &x2, &y2); + buf->u_vec[i].e_index = indx; + buf->u_vec[i].e_xpix = x1; + buf->u_vec[i].e_ypix = y1; + i++; + } + } + else + { + for (y = x->gl_list, indx = 0; y; y = y->g_next, indx++) + { + gobj_getrect(y, x, &x1, &y1, &x2, &y2); + buf->u_vec[indx].e_index = indx; + buf->u_vec[indx].e_xpix = x1; + buf->u_vec[indx].e_ypix = y1; + } + } + canvas_undo_already_set_move = 1; + return (buf); +} + +static void canvas_undo_move(t_canvas *x, void *z, int action) +{ + t_undo_move *buf = z; + if (action == UNDO_UNDO || action == UNDO_REDO) + { + int i; + for (i = 0; i < buf->u_n; i++) + { + int x1, y1, x2, y2, newx, newy; + t_gobj *y; + newx = buf->u_vec[i].e_xpix; + newy = buf->u_vec[i].e_ypix; + y = glist_nth(x, buf->u_vec[i].e_index); + if (y) + { + gobj_getrect(y, x, &x1, &y1, &x2, &y2); + gobj_displace(y, x, newx-x1, newy - y1); + buf->u_vec[i].e_xpix = x1; + buf->u_vec[i].e_ypix = y1; + } + } + } + else if (action == UNDO_FREE) + { + t_freebytes(buf->u_vec, buf->u_n * sizeof(*buf->u_vec)); + t_freebytes(buf, sizeof(*buf)); + } +} + +/* --------- 4. paste (also duplicate) ----------- */ + +typedef struct _undo_paste +{ + int u_index; /* index of first object pasted */ +} t_undo_paste; + +static void *canvas_undo_set_paste(t_canvas *x) +{ + t_undo_paste *buf = (t_undo_paste *)getbytes(sizeof(*buf)); + buf->u_index = glist_getindex(x, 0); + return (buf); +} + +static void canvas_undo_paste(t_canvas *x, void *z, int action) +{ + t_undo_paste *buf = z; + if (action == UNDO_UNDO) + { + t_gobj *y; + glist_noselect(x); + for (y = glist_nth(x, buf->u_index); y; y = y->g_next) + glist_select(x, y); + canvas_doclear(x); + } + else if (action == UNDO_REDO) + { + t_selection *sel; + canvas_dopaste(x, copy_binbuf); + /* if it was "duplicate" have to re-enact the displacement. */ + if (canvas_undo_name && canvas_undo_name[0] == 'd') + for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next) + gobj_displace(sel->sel_what, x, 10, 10); + } +else if (action == UNDO_FREE) + t_freebytes(buf, sizeof(*buf)); +} /* ------------------------ event handling ------------------------ */ @@ -443,12 +904,21 @@ static int canvas_upx, canvas_upy; #define DCLICKINTERVAL 0.25 #endif + /* figure out of the outlet is a "signal" outlet. "nout" is the + index of the outlet, counting from zero. */ +int obj_sigoutletindex(t_object *x, int m); +static int canvas_issigoutlet(t_object *ob, int nout) +{ + int ret = obj_sigoutletindex(ob, nout); + return (obj_sigoutletindex(ob, nout) >= 0); +} + /* mouse click */ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, int mod, int doit) { t_gobj *y; - int shiftmod, runmode, altmod, rightclick, protectmod; + int shiftmod, runmode, altmod, rightclick; int x1, y1, x2, y2, clickreturned = 0; if (!x->gl_editor) @@ -461,7 +931,15 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, runmode = ((mod & CTRLMOD) || (!x->gl_edit)); altmod = (mod & ALTMOD); rightclick = (mod & RIGHTCLICK); - protectmod = x->gl_protect; + + canvas_undo_already_set_move = 0; + + /* if keyboard was grabbed, notify grabber and cancel the grab */ + if (doit && x->gl_editor->e_grab && x->gl_editor->e_keyfn) + { + (* x->gl_editor->e_keyfn) (x->gl_editor->e_grab, 0); + glist_grab(x, 0, 0, 0, 0, 0); + } #ifdef SIMULATERIGHTCLICK if (doit && !runmode && xpos == canvas_upx && ypos == canvas_upy && @@ -546,12 +1024,14 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, { if (doit) { + int issignal = canvas_issigoutlet(ob, closest); x->gl_editor->e_onmotion = MA_CONNECT; x->gl_editor->e_xwas = xpos; x->gl_editor->e_ywas = ypos; sys_vgui( - ".x%x.c create line %d %d %d %d -tags x\n", - x, xpos, ypos, xpos, ypos); + ".x%x.c create line %d %d %d %d -width %d -tags x\n", + x, xpos, ypos, xpos, ypos, + (issignal ? 2 : 1)); } else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT); } @@ -600,12 +1080,13 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, return; } /* having failed to find a box, we try lines now. */ - if (!runmode && !altmod && !shiftmod && !protectmod) + if (!runmode && !altmod && !shiftmod) { t_linetraverser t; t_outconnect *oc; float fx = xpos, fy = ypos; - linetraverser_start(&t, glist_getcanvas(x)); + t_glist *glist2 = glist_getcanvas(x); + linetraverser_start(&t, glist2); while (oc = linetraverser_next(&t)) { float lx1 = t.tr_lx1, ly1 = t.tr_ly1, @@ -618,11 +1099,11 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, if ((lx2-lx1) * (lx2-fx) + (ly2-ly1) * (ly2-fy) < 0) continue; if (doit) { - sys_vgui(".x%x.c delete l%x\n", - glist_getcanvas(x), oc); - obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno); + glist_selectline(glist2, oc, + canvas_getindex(glist2, &t.tr_ob->ob_g), t.tr_outno, + canvas_getindex(glist2, &t.tr_ob2->ob_g), t.tr_inno); } - else canvas_setcursor(x, CURSOR_EDITMODE_DISCONNECT); + canvas_setcursor(x, CURSOR_EDITMODE_DISCONNECT); return; } } @@ -720,10 +1201,16 @@ void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit) ((x22-x21-IOWIDTH) * closest2)/(ninlet2-1) : 0) + IOMIDDLE; ly2 = y21; - sys_vgui(".x%x.c create line %d %d %d %d -tags l%x\n", + sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n", glist_getcanvas(x), - lx1, ly1, lx2, ly2, oc); - } + lx1, ly1, lx2, ly2, + (canvas_issigoutlet(ob1, closest1) ? 2 : 1), oc); + canvas_setundo(x, canvas_undo_connect, + canvas_undo_set_connect(x, + canvas_getindex(x, &ob1->ob_g), closest1, + canvas_getindex(x, &ob2->ob_g), closest2), + "connect"); + } else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT); return; } @@ -792,6 +1279,29 @@ void canvas_mouseup(t_canvas *x, x->gl_editor->e_onmotion = MA_NONE; } + /* displace the selection by (dx, dy) pixels */ +static void canvas_displaceselection(t_canvas *x, int dx, int dy) +{ + t_selection *y; + int resortin = 0, resortout = 0; + if (!canvas_undo_already_set_move) + { + canvas_setundo(x, canvas_undo_move, canvas_undo_set_move(x, 1), + "motion"); + canvas_undo_already_set_move = 1; + } + for (y = x->gl_editor->e_selection; y; y = y->sel_next) + { + t_class *cl = pd_class(&y->sel_what->g_pd); + gobj_displace(y->sel_what, x, dx, dy); + if (cl == vinlet_class) resortin = 1; + else if (cl == voutlet_class) resortout = 1; + } + if (resortin) canvas_resortinlets(x); + if (resortout) canvas_resortoutlets(x); + canvas_dirty(x, 1); +} + /* this routine is called whenever a key is pressed or released. "x" may be zero if there's no current canvas. The first argument is true or fals for down/up; the second one is either a symbolic key name (e.g., @@ -800,8 +1310,30 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av) { static t_symbol *keynumsym, *keyupsym, *keynamesym; float keynum, fflag; - if (ac < 2) + t_symbol *gotkeysym; + + int down, shift; + + if (ac < 3) + return; + if (!x->gl_editor) + { + bug("editor"); return; + } + canvas_undo_already_set_move = 0; + + down = (atom_getfloat(av) != 0); /* nonzero if it's a key down */ + shift = (atom_getfloat(av+2) != 0); /* nonzero if shift-ed */ + if (av[1].a_type == A_SYMBOL) + gotkeysym = av[1].a_w.w_symbol; + else if (av[1].a_type == A_FLOAT) + { + char buf[3]; + sprintf(buf, "%c", (int)(av[1].a_w.w_float)); + gotkeysym = gensym(buf); + } + else gotkeysym = gensym("?"); fflag = (av[0].a_type == A_FLOAT ? av[0].a_w.w_float : 0); keynum = (av[1].a_type == A_FLOAT ? av[1].a_w.w_float : 0); if (keynum == '\\' || keynum == '{' || keynum == '}') @@ -820,48 +1352,60 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av) keyupsym = gensym("#keyup"); keynamesym = gensym("#keyname"); } - if (keynumsym->s_thing && (fflag != 0)) + if (keynumsym->s_thing && down) pd_float(keynumsym->s_thing, keynum); - if (keyupsym->s_thing && (fflag == 0)) + if (keyupsym->s_thing && down) pd_float(keyupsym->s_thing, keynum); if (keynamesym->s_thing) { t_atom at[2]; at[0] = av[0]; - if (av[1].a_type == A_SYMBOL) - at[1] = av[1]; - else - { - char buf[3]; - sprintf(buf, "%c", (int)(av[1].a_w.w_float)); - SETSYMBOL(at+1, gensym(buf)); - } + SETFLOAT(at, down); + SETSYMBOL(at+1, gotkeysym); pd_list(keynamesym->s_thing, 0, 2, at); } - if (x && (fflag != 0)) + if (x && down) { - if (!x->gl_editor) - { - bug("editor"); - return; - } /* if an object has "grabbed" keys just send them on */ - if (x->gl_editor->e_grab && (keynum != 0) - && x->gl_editor->e_keyfn) + if (x->gl_editor->e_grab + && x->gl_editor->e_keyfn && keynum) (* x->gl_editor->e_keyfn) (x->gl_editor->e_grab, keynum); /* if a text editor is open send it on */ else if (x->gl_editor->e_textedfor) { + if (!x->gl_editor->e_textdirty) + { + canvas_setundo(x, canvas_undo_cut, + canvas_undo_set_cut(x, UCUT_TEXT), "typing"); + } rtext_key(x->gl_editor->e_textedfor, (int)keynum, (av[1].a_type == A_SYMBOL ? av[1].a_w.w_symbol : &s_)); if (x->gl_editor->e_textdirty) canvas_dirty(x, 1); } - /* otherwise check for backspace or clear and do so */ + /* check for backspace or clear */ else if (keynum == 8 || keynum == 127) - canvas_doclear(x); + { + if (x->gl_editor->e_selectedline) + canvas_clearline(x); + else if (x->gl_editor->e_selection) + { + canvas_setundo(x, canvas_undo_cut, + canvas_undo_set_cut(x, UCUT_CLEAR), "clear"); + canvas_doclear(x); + } + } + /* check for arrow keys */ + else if (!strcmp(gotkeysym->s_name, "Up")) + canvas_displaceselection(x, 0, shift ? -10 : -1); + else if (!strcmp(gotkeysym->s_name, "Down")) + canvas_displaceselection(x, 0, shift ? 10 : 1); + else if (!strcmp(gotkeysym->s_name, "Left")) + canvas_displaceselection(x, shift ? -10 : -1, 0); + else if (!strcmp(gotkeysym->s_name, "Right")) + canvas_displaceselection(x, shift ? 10 : 1, 0); } } @@ -878,22 +1422,10 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, glist_setlastxy(x, xpos, ypos); if (x->gl_editor->e_onmotion == MA_MOVE) { - t_selection *y; - int resortin = 0, resortout = 0; - for (y = x->gl_editor->e_selection; y; y = y->sel_next) - { - t_class *cl = pd_class(&y->sel_what->g_pd); - gobj_displace(y->sel_what, x, - xpos - x->gl_editor->e_xwas, - ypos - x->gl_editor->e_ywas); - if (cl == vinlet_class) resortin = 1; - else if (cl == voutlet_class) resortout = 1; - } + canvas_displaceselection(x, + xpos - x->gl_editor->e_xwas, ypos - x->gl_editor->e_ywas); x->gl_editor->e_xwas = xpos; - x->gl_editor->e_ywas = ypos; - if (resortin) canvas_resortinlets(x); - if (resortout) canvas_resortoutlets(x); - canvas_dirty(x, 1); + x->gl_editor->e_ywas = ypos; } else if (x->gl_editor->e_onmotion == MA_REGION) canvas_doregion(x, xpos, ypos, 0); @@ -901,6 +1433,8 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, canvas_doconnect(x, xpos, ypos, 0, 0); else if (x->gl_editor->e_onmotion == MA_PASSOUT) { + if (!x->gl_editor->e_motionfn) + bug("e_motionfn"); (*x->gl_editor->e_motionfn)(&x->gl_editor->e_grab->g_pd, xpos - x->gl_editor->e_xwas, ypos - x->gl_editor->e_ywas); @@ -1031,9 +1565,19 @@ static int canvas_dofind(t_canvas *x, int *myindex1p) glist_noselect(x); if (glist_isvisible(x)) { +#ifdef NT + /* For windows canvas_vis() does something + special so here we explicitly invis + the window and proceed as in the "invis" + case below. */ + canvas_vis(x, 0); + canvas_selectme = y; + canvas_vis(x, 1); +#else canvas_vis(x, 1); canvas_editmode(x, 1.); glist_select(x, y); +#endif } else { @@ -1194,19 +1738,13 @@ void canvas_stowconnections(t_canvas *x) linetraverser_start(&t, x); while (oc = linetraverser_next(&t)) { - int srcno = 0, sinkno = 0; int s1 = glist_isselected(x, &t.tr_ob->ob_g); int s2 = glist_isselected(x, &t.tr_ob2->ob_g); if (s1 != s2) - { - for (y = x->gl_list; y && y != &t.tr_ob->ob_g; y = y->g_next) - srcno++; - for (y = x->gl_list; y && y != &t.tr_ob2->ob_g; y = y->g_next) - sinkno++; binbuf_addv(x->gl_editor->e_connectbuf, "ssiiii;", gensym("#X"), gensym("connect"), - srcno, t.tr_outno, sinkno, t.tr_inno); - } + glist_getindex(x, &t.tr_ob->ob_g), t.tr_outno, + glist_getindex(x, &t.tr_ob2->ob_g), t.tr_inno); } } @@ -1217,37 +1755,55 @@ void canvas_restoreconnections(t_canvas *x) pd_unbind(&x->gl_pd, gensym("#X")); } - -static t_binbuf *copy_binbuf; - -static void canvas_copy(t_canvas *x) +static t_binbuf *canvas_docopy(t_canvas *x) { t_gobj *y; t_linetraverser t; t_outconnect *oc; - if (!x->gl_editor || !x->gl_editor->e_selection) - return; - binbuf_clear(copy_binbuf); + t_binbuf *b = binbuf_new(); for (y = x->gl_list; y; y = y->g_next) { if (glist_isselected(x, y)) - gobj_save(y, copy_binbuf); + gobj_save(y, b); } linetraverser_start(&t, x); while (oc = linetraverser_next(&t)) { - int srcno = 0, sinkno = 0; if (glist_isselected(x, &t.tr_ob->ob_g) && glist_isselected(x, &t.tr_ob2->ob_g)) { - for (y = x->gl_list; y && y != &t.tr_ob->ob_g; y = y->g_next) - if (glist_isselected(x, y)) srcno++; - for (y = x->gl_list; y && y != &t.tr_ob2->ob_g; y = y->g_next) - if (glist_isselected(x, y)) sinkno++; - binbuf_addv(copy_binbuf, "ssiiii;", gensym("#X"), - gensym("connect"), srcno, t.tr_outno, sinkno, t.tr_inno); + binbuf_addv(b, "ssiiii;", gensym("#X"), gensym("connect"), + glist_selectionindex(x, &t.tr_ob->ob_g, 1), t.tr_outno, + glist_selectionindex(x, &t.tr_ob2->ob_g, 1), t.tr_inno); } } + return (b); +} + +static void canvas_copy(t_canvas *x) +{ + if (!x->gl_editor || !x->gl_editor->e_selection) + return; + binbuf_free(copy_binbuf); + copy_binbuf = canvas_docopy(x); +} + +static void canvas_clearline(t_canvas *x) +{ + if (x->gl_editor->e_selectedline) + { + canvas_disconnect(x, x->gl_editor->e_selectline_index1, + x->gl_editor->e_selectline_outno, + x->gl_editor->e_selectline_index2, + x->gl_editor->e_selectline_inno); + canvas_setundo(x, canvas_undo_disconnect, + canvas_undo_set_disconnect(x, + x->gl_editor->e_selectline_index1, + x->gl_editor->e_selectline_outno, + x->gl_editor->e_selectline_index2, + x->gl_editor->e_selectline_inno), + "disconnect"); + } } extern t_pd *newest; @@ -1257,6 +1813,20 @@ static void canvas_doclear(t_canvas *x) int dspstate; dspstate = canvas_suspend_dsp(); + if (x->gl_editor->e_selectedline) + { + canvas_disconnect(x, x->gl_editor->e_selectline_index1, + x->gl_editor->e_selectline_outno, + x->gl_editor->e_selectline_index2, + x->gl_editor->e_selectline_inno); + canvas_setundo(x, canvas_undo_disconnect, + canvas_undo_set_disconnect(x, + x->gl_editor->e_selectline_index1, + x->gl_editor->e_selectline_outno, + x->gl_editor->e_selectline_index2, + x->gl_editor->e_selectline_inno), + "disconnect"); + } /* if text is selected, deselecting it might remake the object. So we deselect it and hunt for a "new" object on the glist to reselect. */ @@ -1295,8 +1865,15 @@ restore: static void canvas_cut(t_canvas *x) { - canvas_copy(x); - canvas_doclear(x); + if (x->gl_editor && x->gl_editor->e_selectedline) + canvas_clearline(x); + else if (x->gl_editor && x->gl_editor->e_selection) + { + canvas_setundo(x, canvas_undo_cut, + canvas_undo_set_cut(x, UCUT_CUT), "cut"); + canvas_copy(x); + canvas_doclear(x); + } } static int paste_onset; @@ -1313,7 +1890,7 @@ static void glist_donewloadbangs(t_glist *x) } } -static void canvas_paste(t_canvas *x) +static void canvas_dopaste(t_canvas *x, t_binbuf *b) { t_gobj *newgobj, *last, *g2; int dspstate = canvas_suspend_dsp(), nbox, count; @@ -1326,7 +1903,7 @@ static void canvas_paste(t_canvas *x) paste_canvas = x; pd_bind(&x->gl_pd, gensym("#X")); - binbuf_eval(copy_binbuf, 0, 0, 0); + binbuf_eval(b, 0, 0, 0); pd_unbind(&x->gl_pd, gensym("#X")); for (g2 = x->gl_list, count = 0; g2; g2 = g2->g_next, count++) if (count >= nbox) @@ -1337,13 +1914,21 @@ static void canvas_paste(t_canvas *x) glist_donewloadbangs(x); } +static void canvas_paste(t_canvas *x) +{ + canvas_setundo(x, canvas_undo_paste, canvas_undo_set_paste(x), "paste"); + canvas_dopaste(x, copy_binbuf); +} + static void canvas_duplicate(t_canvas *x) { if (x->gl_editor->e_onmotion == MA_NONE) { t_selection *y; canvas_copy(x); - canvas_paste(x); + canvas_setundo(x, canvas_undo_paste, canvas_undo_set_paste(x), + "duplicate"); + canvas_dopaste(x, copy_binbuf); for (y = x->gl_editor->e_selection; y; y = y->sel_next) gobj_displace(y->sel_what, x, 10, 10); @@ -1405,12 +1990,21 @@ static void canvas_tidy(t_canvas *x) t_gobj *y, *y2, *y3; int ax1, ay1, ax2, ay2, bx1, by1, bx2, by2; int histogram[NHIST], *ip, i, besthist, bestdist; + /* if nobody is selected, this means do it to all boxes; + othewise just the selection */ + int all = (x->gl_editor ? (x->gl_editor->e_selection == 0) : 1); + + canvas_setundo(x, canvas_undo_move, canvas_undo_set_move(x, !all), + "motion"); + /* tidy horizontally */ for (y = x->gl_list; y; y = y->g_next) + if (all || glist_isselected(x, y)) { gobj_getrect(y, x, &ax1, &ay1, &ax2, &ay2); for (y2 = x->gl_list; y2; y2 = y2->g_next) + if (all || glist_isselected(x, y2)) { gobj_getrect(y2, x, &bx1, &by1, &bx2, &by2); if (by1 <= ay1 + YTOLERANCE && by1 >= ay1 - YTOLERANCE && @@ -1419,6 +2013,7 @@ static void canvas_tidy(t_canvas *x) } for (y2 = x->gl_list; y2; y2 = y2->g_next) + if (all || glist_isselected(x, y2)) { gobj_getrect(y2, x, &bx1, &by1, &bx2, &by2); if (by1 <= ay1 + YTOLERANCE && by1 >= ay1 - YTOLERANCE @@ -1430,9 +2025,11 @@ static void canvas_tidy(t_canvas *x) /* tidy vertically. First guess the user's favorite vertical spacing */ for (i = NHIST, ip = histogram; i--; ip++) *ip = 0; for (y = x->gl_list; y; y = y->g_next) + if (all || glist_isselected(x, y)) { gobj_getrect(y, x, &ax1, &ay1, &ax2, &ay2); for (y2 = x->gl_list; y2; y2 = y2->g_next) + if (all || glist_isselected(x, y2)) { gobj_getrect(y2, x, &bx1, &by1, &bx2, &by2); if (bx1 <= ax1 + XTOLERANCE && bx1 >= ax1 - XTOLERANCE) @@ -1455,10 +2052,12 @@ static void canvas_tidy(t_canvas *x) } post("best vertical distance %d", bestdist); for (y = x->gl_list; y; y = y->g_next) + if (all || glist_isselected(x, y)) { int keep = 1; gobj_getrect(y, x, &ax1, &ay1, &ax2, &ay2); for (y2 = x->gl_list; y2; y2 = y2->g_next) + if (all || glist_isselected(x, y2)) { gobj_getrect(y2, x, &bx1, &by1, &bx2, &by2); if (bx1 <= ax1 + XTOLERANCE && bx1 >= ax1 - XTOLERANCE && @@ -1469,6 +2068,7 @@ static void canvas_tidy(t_canvas *x) { keep = 0; for (y2 = x->gl_list; y2; y2 = y2->g_next) + if (all || glist_isselected(x, y2)) { gobj_getrect(y2, x, &bx1, &by1, &bx2, &by2); if (bx1 <= ax1 + XTOLERANCE && bx1 >= ax1 - XTOLERANCE && @@ -1524,17 +2124,6 @@ void canvas_editmode(t_canvas *x, t_floatarg fyesplease) if (yesplease) canvas_dirty(x, 1); } -static void canvas_protectmode(t_canvas *x, t_floatarg fyesplease) -{ - int yesplease = fyesplease; - - if (yesplease && x->gl_protect) - return; - x->gl_protect = !x->gl_protect; - sys_vgui("pdtk_canvas_protectval .x%x %d\n", - glist_getcanvas(x), x->gl_protect); -} - /* called by canvas_font below */ static void canvas_dofont(t_canvas *x, t_floatarg font, t_floatarg xresize, t_floatarg yresize) @@ -1543,6 +2132,8 @@ static void canvas_dofont(t_canvas *x, t_floatarg font, t_floatarg xresize, x->gl_font = font; if (xresize != 1 || yresize != 1) { + canvas_setundo(x, canvas_undo_move, canvas_undo_set_move(x, 0), + "motion"); for (y = x->gl_list; y; y = y->g_next) { int x1, x2, y1, y2, nx1, ny1; @@ -1622,14 +2213,16 @@ void g_editor_setup(void) gensym("duplicate"), A_NULL); class_addmethod(canvas_class, (t_method)canvas_selectall, gensym("selectall"), A_NULL); + class_addmethod(canvas_class, (t_method)canvas_undo, + gensym("undo"), A_NULL); + class_addmethod(canvas_class, (t_method)canvas_redo, + gensym("redo"), A_NULL); class_addmethod(canvas_class, (t_method)canvas_tidy, gensym("tidy"), A_NULL); class_addmethod(canvas_class, (t_method)canvas_texteditor, gensym("texteditor"), A_NULL); class_addmethod(canvas_class, (t_method)canvas_editmode, gensym("editmode"), A_DEFFLOAT, A_NULL); - class_addmethod(canvas_class, (t_method)canvas_protectmode, - gensym("protectmode"), A_DEFFLOAT, A_NULL); class_addmethod(canvas_class, (t_method)canvas_print, gensym("print"), A_SYMBOL, A_NULL); class_addmethod(canvas_class, (t_method)canvas_menufont, diff --git a/pd/src/g_graph.c b/pd/src/g_graph.c index 65a5d056..b893d42d 100644 --- a/pd/src/g_graph.c +++ b/pd/src/g_graph.c @@ -129,7 +129,9 @@ void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn, t_glistkeyfn keyfn, int xpos, int ypos) { t_glist *x2 = glist_getcanvas(x); - x2->gl_editor->e_onmotion = MA_PASSOUT; + if (motionfn) + x2->gl_editor->e_onmotion = MA_PASSOUT; + else x2->gl_editor->e_onmotion = 0; x2->gl_editor->e_grab = y; x2->gl_editor->e_motionfn = motionfn; x2->gl_editor->e_keyfn = keyfn; @@ -263,9 +265,6 @@ t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *s) return (ip); } -void canvas_deletelinesforio(t_canvas *x, t_text *text, - t_inlet *inp, t_outlet *outp); - void canvas_rminlet(t_canvas *x, t_inlet *ip) { t_canvas *owner = x->gl_owner; diff --git a/pd/src/g_hdial.c b/pd/src/g_hdial.c index 6e9f08a7..caca3a22 100644 --- a/pd/src/g_hdial.c +++ b/pd/src/g_hdial.c @@ -5,6 +5,8 @@ /* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ +/* name change to hradio by MSP and changed to +put out a "float" as in sliders, toggles, etc. */ #include #include @@ -24,12 +26,12 @@ /* ------------- hdl gui-horicontal dial ---------------------- */ -t_widgetbehavior hdial_widgetbehavior; -static t_class *hdial_class; +t_widgetbehavior hradio_widgetbehavior; +static t_class *hradio_class, *hradio_old_class; /* widget helper functions */ -void hdial_draw_update(t_hdial *x, t_glist *glist) +void hradio_draw_update(t_hradio *x, t_glist *glist) { if(glist_isvisible(glist)) { @@ -44,7 +46,7 @@ void hdial_draw_update(t_hdial *x, t_glist *glist) } } -void hdial_draw_new(t_hdial *x, t_glist *glist) +void hradio_draw_new(t_hradio *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4; @@ -82,7 +84,7 @@ void hdial_draw_new(t_hdial *x, t_glist *glist) } -void hdial_draw_move(t_hdial *x, t_glist *glist) +void hradio_draw_move(t_hradio *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4; @@ -114,7 +116,7 @@ void hdial_draw_move(t_hdial *x, t_glist *glist) canvas, x, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1); } -void hdial_draw_erase(t_hdial* x, t_glist* glist) +void hradio_draw_erase(t_hradio* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i; @@ -131,7 +133,7 @@ void hdial_draw_erase(t_hdial* x, t_glist* glist) sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); } -void hdial_draw_config(t_hdial* x, t_glist* glist) +void hradio_draw_config(t_hradio* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i; @@ -150,7 +152,7 @@ void hdial_draw_config(t_hdial* x, t_glist* glist) } } -void hdial_draw_io(t_hdial* x, t_glist* glist, int old_snd_rcv_flags) +void hradio_draw_io(t_hradio* x, t_glist* glist, int old_snd_rcv_flags) { t_canvas *canvas=glist_getcanvas(glist); int xpos=text_xpix(&x->x_gui.x_obj, glist); @@ -173,14 +175,13 @@ void hdial_draw_io(t_hdial* x, t_glist* glist, int old_snd_rcv_flags) sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); } -void hdial_draw_select(t_hdial* x, t_glist* glist) +void hradio_draw_select(t_hradio* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i; if(x->x_gui.x_fsf.x_selected) { - pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); for(i=0; ix_gui.x_obj.ob_pd, iemgui_key_sym); for(i=0; i= IEM_GUI_DRAW_MODE_IO) - hdial_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO); + hradio_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO); } /* ------------------------ hdl widgetbehaviour----------------------------- */ -static void hdial_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) +static void hradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) { - t_hdial *x = (t_hdial *)z; + t_hradio *x = (t_hradio *)z; *xp1 = text_xpix(&x->x_gui.x_obj, glist); *yp1 = text_ypix(&x->x_gui.x_obj, glist); @@ -231,9 +231,9 @@ static void hdial_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp *yp2 = *yp1 + x->x_gui.x_h; } -static void hdial_save(t_gobj *z, t_binbuf *b) +static void hradio_save(t_gobj *z, t_binbuf *b) { - t_hdial *x = (t_hdial *)z; + t_hradio *x = (t_hradio *)z; int bflcol[3], *ip1, *ip2; t_symbol *srl[3]; @@ -241,8 +241,11 @@ static void hdial_save(t_gobj *z, t_binbuf *b) ip1 = (int *)(&x->x_gui.x_isa); ip2 = (int *)(&x->x_gui.x_fsf); binbuf_addv(b, "ssiisiiiisssiiiiiiii", gensym("#X"),gensym("obj"), - (t_int)text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist), (t_int)text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist), - gensym("hdl"), x->x_gui.x_w, + (t_int)text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist), + (t_int)text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist), + (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class ? + gensym("vdl") : gensym("vradio")), + x->x_gui.x_w, x->x_change, (*ip1)&IEM_INIT_ARGS_ALL, x->x_number, srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, @@ -251,14 +254,14 @@ static void hdial_save(t_gobj *z, t_binbuf *b) binbuf_addv(b, ";"); } -static void hdial_properties(t_gobj *z, t_glist *owner) +static void hradio_properties(t_gobj *z, t_glist *owner) { - t_hdial *x = (t_hdial *)z; + t_hradio *x = (t_hradio *)z; char buf[800]; t_symbol *srl[3]; iemgui_properties(&x->x_gui, srl); - sprintf(buf, "pdtk_iemgui_dialog %%s HDIAL \ + sprintf(buf, "pdtk_iemgui_dialog %%s hradio \ ----------dimensions(pix):----------- %d %d size: 0 0 empty \ empty 0.0 empty 0.0 empty %d \ %d new-only new&old %d %d number: %d \ @@ -276,7 +279,7 @@ static void hdial_properties(t_gobj *z, t_glist *owner) gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); } -static void hdial_dialog(t_hdial *x, t_symbol *s, int argc, t_atom *argv) +static void hradio_dialog(t_hradio *x, t_symbol *s, int argc, t_atom *argv) { t_symbol *srl[3]; int a = (int)atom_getintarg(0, argc, argv); @@ -310,7 +313,7 @@ static void hdial_dialog(t_hdial *x, t_symbol *s, int argc, t_atom *argv) } -static void hdial_set(t_hdial *x, t_floatarg f) +static void hradio_set(t_hradio *x, t_floatarg f) { int i=(int)f; int old=x->x_on_old; @@ -334,25 +337,30 @@ static void hdial_set(t_hdial *x, t_floatarg f) } } -static void hdial_bang(t_hdial *x) +static void hradio_bang(t_hradio *x) { - if((x->x_change)&&(x->x_on != x->x_on_old)) + /* compatibility with earlier "hdial" behavior */ + if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class) { - SETFLOAT(x->x_at, (float)x->x_on_old); - SETFLOAT(x->x_at+1, 0.0); + if((x->x_change)&&(x->x_on != x->x_on_old)) + { + SETFLOAT(x->x_at, (float)x->x_on_old); + SETFLOAT(x->x_at+1, 0.0); + outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + } + x->x_on_old = x->x_on; + SETFLOAT(x->x_at, (float)x->x_on); + SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } - x->x_on_old = x->x_on; - SETFLOAT(x->x_at, (float)x->x_on); - SETFLOAT(x->x_at+1, 1.0); - outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) - pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + else outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); } -static void hdial_fout(t_hdial *x, t_floatarg f) +static void hradio_fout(t_hradio *x, t_floatarg f) { int i=(int)f; @@ -361,27 +369,36 @@ static void hdial_fout(t_hdial *x, t_floatarg f) if(i >= x->x_number) i = x->x_number-1; - if((x->x_change)&&(i != x->x_on_old)) + if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class) { - SETFLOAT(x->x_at, (float)x->x_on_old); - SETFLOAT(x->x_at+1, 0.0); + if((x->x_change)&&(i != x->x_on_old)) + { + SETFLOAT(x->x_at, (float)x->x_on_old); + SETFLOAT(x->x_at+1, 0.0); + outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + } + if(x->x_on != x->x_on_old) + x->x_on_old = x->x_on; + x->x_on = i; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + x->x_on_old = x->x_on; + SETFLOAT(x->x_at, (float)x->x_on); + SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } - if(x->x_on != x->x_on_old) + else + { + outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on = i); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); x->x_on_old = x->x_on; - x->x_on = i; - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); - x->x_on_old = x->x_on; - SETFLOAT(x->x_at, (float)x->x_on); - SETFLOAT(x->x_at+1, 1.0); - outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) - pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + } } -static void hdial_float(t_hdial *x, t_floatarg f) +static void hradio_float(t_hradio *x, t_floatarg f) { int i=(int)f; @@ -390,53 +407,69 @@ static void hdial_float(t_hdial *x, t_floatarg f) if(i >= x->x_number) i = x->x_number-1; - if((x->x_change)&&(i != x->x_on_old)) + if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class) { + /* compatibility with earlier "vdial" behavior */ + if((x->x_change)&&(i != x->x_on_old)) + { + if(x->x_gui.x_fsf.x_put_in2out) + { + SETFLOAT(x->x_at, (float)x->x_on_old); + SETFLOAT(x->x_at+1, 0.0); + outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + } + } + if(x->x_on != x->x_on_old) + x->x_on_old = x->x_on; + x->x_on = i; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + x->x_on_old = x->x_on; if(x->x_gui.x_fsf.x_put_in2out) { - SETFLOAT(x->x_at, (float)x->x_on_old); - SETFLOAT(x->x_at+1, 0.0); + SETFLOAT(x->x_at, (float)x->x_on); + SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } } - if(x->x_on != x->x_on_old) - x->x_on_old = x->x_on; - x->x_on = i; - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); - x->x_on_old = x->x_on; - if(x->x_gui.x_fsf.x_put_in2out) + else { - SETFLOAT(x->x_at, (float)x->x_on); - SETFLOAT(x->x_at+1, 1.0); - outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) - pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + x->x_on = i; + if (x->x_gui.x_fsf.x_put_in2out) + { + outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_float(x->x_gui.x_snd->s_thing, x->x_on); + } + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + x->x_on_old = x->x_on; } } -static void hdial_click(t_hdial *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) +static void hradio_click(t_hradio *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) { int xx = (int)xpos - (int)text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist); - hdial_fout(x, (float)(xx / x->x_gui.x_w)); + hradio_fout(x, (float)(xx / x->x_gui.x_w)); } -static int hdial_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) +static int hradio_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) { if(doit) - hdial_click((t_hdial *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); + hradio_click((t_hradio *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); return (1); } -static void hdial_loadbang(t_hdial *x) +static void hradio_loadbang(t_hradio *x) { if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) - hdial_bang(x); + hradio_bang(x); } -static void hdial_number(t_hdial *x, t_floatarg num) +static void hradio_number(t_hradio *x, t_floatarg num) { int n=(int)num; @@ -455,67 +488,51 @@ static void hdial_number(t_hdial *x, t_floatarg num) } } -static void hdial_size(t_hdial *x, t_symbol *s, int ac, t_atom *av) +static void hradio_size(t_hradio *x, t_symbol *s, int ac, t_atom *av) { x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_h = x->x_gui.x_w; iemgui_size((void *)x, &x->x_gui); } -static void hdial_delta(t_hdial *x, t_symbol *s, int ac, t_atom *av) +static void hradio_delta(t_hradio *x, t_symbol *s, int ac, t_atom *av) {iemgui_delta((void *)x, &x->x_gui, s, ac, av);} -static void hdial_pos(t_hdial *x, t_symbol *s, int ac, t_atom *av) +static void hradio_pos(t_hradio *x, t_symbol *s, int ac, t_atom *av) {iemgui_pos((void *)x, &x->x_gui, s, ac, av);} -static void hdial_color(t_hdial *x, t_symbol *s, int ac, t_atom *av) +static void hradio_color(t_hradio *x, t_symbol *s, int ac, t_atom *av) {iemgui_color((void *)x, &x->x_gui, s, ac, av);} -static void hdial_send(t_hdial *x, t_symbol *s) +static void hradio_send(t_hradio *x, t_symbol *s) {iemgui_send(x, &x->x_gui, s);} -static void hdial_receive(t_hdial *x, t_symbol *s) +static void hradio_receive(t_hradio *x, t_symbol *s) {iemgui_receive(x, &x->x_gui, s);} -static void hdial_label(t_hdial *x, t_symbol *s) +static void hradio_label(t_hradio *x, t_symbol *s) {iemgui_label((void *)x, &x->x_gui, s);} -static void hdial_label_pos(t_hdial *x, t_symbol *s, int ac, t_atom *av) +static void hradio_label_pos(t_hradio *x, t_symbol *s, int ac, t_atom *av) {iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} -static void hdial_label_font(t_hdial *x, t_symbol *s, int ac, t_atom *av) +static void hradio_label_font(t_hradio *x, t_symbol *s, int ac, t_atom *av) {iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} -static void hdial_init(t_hdial *x, t_floatarg f) +static void hradio_init(t_hradio *x, t_floatarg f) { x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; } -static void hdial_double_change(t_hdial *x) +static void hradio_double_change(t_hradio *x) {x->x_change = 1;} -static void hdial_single_change(t_hdial *x) +static void hradio_single_change(t_hradio *x) {x->x_change = 0;} -static void hdial_list(t_hdial *x, t_symbol *s, int ac, t_atom *av) +static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old) { - int l=iemgui_list((void *)x, &x->x_gui, s, ac, av); - - if(l < 0) - { - if(IS_A_FLOAT(av,0)) - hdial_float(x, atom_getfloatarg(0, ac, av)); - } - else if(l > 0) - { - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - } -} - -static void *hdial_new(t_symbol *s, int argc, t_atom *argv) -{ - t_hdial *x = (t_hdial *)pd_new(hdial_class); + t_hradio *x = (t_hradio *)pd_new(old? hradio_old_class : hradio_class); int bflcol[]={-262144, -1, -1}; t_symbol *srl[3]; int a=IEM_GUI_DEFAULTSIZE, on=0, f=0; @@ -573,7 +590,7 @@ static void *hdial_new(t_symbol *s, int argc, t_atom *argv) bflcol[2] = (int)atom_getintarg(13, argc, argv); on = (int)atom_getintarg(14, argc, argv); } - x->x_gui.x_draw = (t_iemfunptr)hdial_draw; + x->x_gui.x_draw = (t_iemfunptr)hradio_draw; iinit &= IEM_INIT_ARGS_ALL; ifstyle &= IEM_FSTYLE_FLAGS_ALL; fstyle->x_snd_able = 1; @@ -621,55 +638,119 @@ static void *hdial_new(t_symbol *s, int argc, t_atom *argv) return (x); } -static void hdial_ff(t_hdial *x) +static void *hradio_new(t_symbol *s, int argc, t_atom *argv) +{ + return (hradio_donew(s, argc, argv, 0)); +} + +static void *hdial_new(t_symbol *s, int argc, t_atom *argv) +{ + return (hradio_donew(s, argc, argv, 1)); +} + +static void hradio_ff(t_hradio *x) { - if(x->x_gui.x_fsf.x_selected) - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); if(x->x_gui.x_fsf.x_rcv_able) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); } -void g_hdial_setup(void) +void g_hradio_setup(void) { - hdial_class = class_new(gensym("hdl"), (t_newmethod)hdial_new, - (t_method)hdial_ff, sizeof(t_hdial), 0, A_GIMME, 0); - class_addcreator((t_newmethod)hdial_new, gensym("rdb"), A_GIMME, 0); - class_addcreator((t_newmethod)hdial_new, gensym("radiobut"), A_GIMME, 0); - class_addcreator((t_newmethod)hdial_new, gensym("radiobutton"), A_GIMME, 0); - class_addbang(hdial_class, hdial_bang); - class_addfloat(hdial_class, hdial_float); - class_addlist(hdial_class, hdial_list); - class_addmethod(hdial_class, (t_method)hdial_click, gensym("click"), + hradio_class = class_new(gensym("hdl"), (t_newmethod)hradio_new, + (t_method)hradio_ff, sizeof(t_hradio), 0, A_GIMME, 0); + class_addbang(hradio_class, hradio_bang); + class_addfloat(hradio_class, hradio_float); + class_addmethod(hradio_class, (t_method)hradio_click, gensym("click"), + A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + class_addmethod(hradio_class, (t_method)hradio_dialog, gensym("dialog"), + A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_loadbang, + gensym("loadbang"), 0); + class_addmethod(hradio_class, (t_method)hradio_set, + gensym("set"), A_FLOAT, 0); + class_addmethod(hradio_class, (t_method)hradio_size, + gensym("size"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_delta, + gensym("delta"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_pos, + gensym("pos"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_color, + gensym("color"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_send, + gensym("send"), A_DEFSYM, 0); + class_addmethod(hradio_class, (t_method)hradio_receive, + gensym("receive"), A_DEFSYM, 0); + class_addmethod(hradio_class, (t_method)hradio_label, + gensym("label"), A_DEFSYM, 0); + class_addmethod(hradio_class, (t_method)hradio_label_pos, + gensym("label_pos"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_label_font, + gensym("label_font"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_init, + gensym("init"), A_FLOAT, 0); + class_addmethod(hradio_class, (t_method)hradio_number, + gensym("number"), A_FLOAT, 0); + class_addmethod(hradio_class, (t_method)hradio_single_change, + gensym("single_change"), 0); + class_addmethod(hradio_class, (t_method)hradio_double_change, + gensym("double_change"), 0); + hradio_widgetbehavior.w_getrectfn = hradio_getrect; + hradio_widgetbehavior.w_displacefn = iemgui_displace; + hradio_widgetbehavior.w_selectfn = iemgui_select; + hradio_widgetbehavior.w_activatefn = NULL; + hradio_widgetbehavior.w_deletefn = iemgui_delete; + hradio_widgetbehavior.w_visfn = iemgui_vis; + hradio_widgetbehavior.w_clickfn = hradio_newclick; + hradio_widgetbehavior.w_propertiesfn = hradio_properties; + hradio_widgetbehavior.w_savefn = hradio_save; + class_setwidget(hradio_class, &hradio_widgetbehavior); + class_sethelpsymbol(hradio_class, gensym("hradio")); + + /*obsolete version (0.34-0.35) */ + hradio_old_class = class_new(gensym("hdl"), (t_newmethod)hdial_new, + (t_method)hradio_ff, sizeof(t_hradio), 0, A_GIMME, 0); + class_addcreator((t_newmethod)hradio_new, gensym("rdb"), A_GIMME, 0); + class_addcreator((t_newmethod)hradio_new, gensym("radiobut"), A_GIMME, 0); + class_addcreator((t_newmethod)hradio_new, gensym("radiobutton"), + A_GIMME, 0); + class_addbang(hradio_class, hradio_bang); + class_addfloat(hradio_class, hradio_float); + class_addmethod(hradio_class, (t_method)hradio_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); - class_addmethod(hdial_class, (t_method)hdial_dialog, gensym("dialog"), + class_addmethod(hradio_class, (t_method)hradio_dialog, gensym("dialog"), A_GIMME, 0); - class_addmethod(hdial_class, (t_method)hdial_loadbang, gensym("loadbang"), 0); - class_addmethod(hdial_class, (t_method)hdial_set, gensym("set"), A_FLOAT, 0); - class_addmethod(hdial_class, (t_method)hdial_size, gensym("size"), A_GIMME, 0); - class_addmethod(hdial_class, (t_method)hdial_delta, gensym("delta"), A_GIMME, 0); - class_addmethod(hdial_class, (t_method)hdial_pos, gensym("pos"), A_GIMME, 0); - class_addmethod(hdial_class, (t_method)hdial_color, gensym("color"), A_GIMME, 0); - class_addmethod(hdial_class, (t_method)hdial_send, gensym("send"), A_DEFSYM, 0); - class_addmethod(hdial_class, (t_method)hdial_receive, gensym("receive"), A_DEFSYM, 0); - class_addmethod(hdial_class, (t_method)hdial_label, gensym("label"), A_DEFSYM, 0); - class_addmethod(hdial_class, (t_method)hdial_label_pos, gensym("label_pos"), A_GIMME, 0); - class_addmethod(hdial_class, (t_method)hdial_label_font, gensym("label_font"), A_GIMME, 0); - class_addmethod(hdial_class, (t_method)hdial_init, gensym("init"), A_FLOAT, 0); - class_addmethod(hdial_class, (t_method)hdial_number, gensym("number"), A_FLOAT, 0); - class_addmethod(hdial_class, (t_method)hdial_single_change, gensym("single_change"), 0); - class_addmethod(hdial_class, (t_method)hdial_double_change, gensym("double_change"), 0); - if(!iemgui_key_sym) - iemgui_key_sym = gensym("#keyname"); - hdial_widgetbehavior.w_getrectfn = hdial_getrect; - hdial_widgetbehavior.w_displacefn = iemgui_displace; - hdial_widgetbehavior.w_selectfn = iemgui_select; - hdial_widgetbehavior.w_activatefn = NULL; - hdial_widgetbehavior.w_deletefn = iemgui_delete; - hdial_widgetbehavior.w_visfn = iemgui_vis; - hdial_widgetbehavior.w_clickfn = hdial_newclick; - hdial_widgetbehavior.w_propertiesfn = hdial_properties; - hdial_widgetbehavior.w_savefn = hdial_save; - class_setwidget(hdial_class, &hdial_widgetbehavior); - class_sethelpsymbol(hdial_class, gensym("hdial")); + class_addmethod(hradio_class, (t_method)hradio_loadbang, + gensym("loadbang"), 0); + class_addmethod(hradio_class, (t_method)hradio_set, + gensym("set"), A_FLOAT, 0); + class_addmethod(hradio_class, (t_method)hradio_size, + gensym("size"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_delta, + gensym("delta"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_pos, + gensym("pos"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_color, + gensym("color"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_send, + gensym("send"), A_DEFSYM, 0); + class_addmethod(hradio_class, (t_method)hradio_receive, + gensym("receive"), A_DEFSYM, 0); + class_addmethod(hradio_class, (t_method)hradio_label, + gensym("label"), A_DEFSYM, 0); + class_addmethod(hradio_class, (t_method)hradio_label_pos, + gensym("label_pos"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_label_font, + gensym("label_font"), A_GIMME, 0); + class_addmethod(hradio_class, (t_method)hradio_init, + gensym("init"), A_FLOAT, 0); + class_addmethod(hradio_class, (t_method)hradio_number, + gensym("number"), A_FLOAT, 0); + class_addmethod(hradio_class, (t_method)hradio_single_change, + gensym("single_change"), 0); + class_addmethod(hradio_class, (t_method)hradio_double_change, + gensym("double_change"), 0); + class_setwidget(hradio_class, &hradio_widgetbehavior); + class_sethelpsymbol(hradio_class, gensym("hradio")); + } diff --git a/pd/src/g_hslider.c b/pd/src/g_hslider.c index 0e5415a9..5b08a9bb 100644 --- a/pd/src/g_hslider.c +++ b/pd/src/g_hslider.c @@ -169,13 +169,11 @@ static void hslider_draw_select(t_hslider* x,t_glist* glist) if(x->x_gui.x_fsf.x_selected) { - pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); } else { - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); } @@ -524,22 +522,6 @@ static void hslider_loadbang(t_hslider *x) } } -static void hslider_list(t_hslider *x, t_symbol *s, int ac, t_atom *av) -{ - int l=iemgui_list((void *)x, &x->x_gui, s, ac, av); - - if(l < 0) - { - if(IS_A_FLOAT(av,0)) - hslider_float(x, atom_getfloatarg(0, ac, av)); - } - else if(l > 0) - { - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - } -} - static void *hslider_new(t_symbol *s, int argc, t_atom *argv) { t_hslider *x = (t_hslider *)pd_new(hslider_class); @@ -654,8 +636,6 @@ static void *hslider_new(t_symbol *s, int argc, t_atom *argv) static void hslider_free(t_hslider *x) { - if(x->x_gui.x_fsf.x_selected) - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); if(x->x_gui.x_fsf.x_rcv_able) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -670,7 +650,6 @@ void g_hslider_setup(void) #endif class_addbang(hslider_class,hslider_bang); class_addfloat(hslider_class,hslider_float); - class_addlist(hslider_class, hslider_list); class_addmethod(hslider_class, (t_method)hslider_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod(hslider_class, (t_method)hslider_motion, gensym("motion"), @@ -692,8 +671,6 @@ void g_hslider_setup(void) class_addmethod(hslider_class, (t_method)hslider_lin, gensym("lin"), 0); class_addmethod(hslider_class, (t_method)hslider_init, gensym("init"), A_FLOAT, 0); class_addmethod(hslider_class, (t_method)hslider_steady, gensym("steady"), A_FLOAT, 0); - if(!iemgui_key_sym) - iemgui_key_sym = gensym("#keyname"); hslider_widgetbehavior.w_getrectfn = hslider_getrect; hslider_widgetbehavior.w_displacefn = iemgui_displace; hslider_widgetbehavior.w_selectfn = iemgui_select; diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c index edddb568..726b6770 100644 --- a/pd/src/g_mycanvas.c +++ b/pd/src/g_mycanvas.c @@ -95,12 +95,10 @@ void my_canvas_draw_select(t_my_canvas* x, t_glist* glist) if(x->x_gui.x_fsf.x_selected) { - pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); } else { - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, x->x_gui.x_bcol); } } @@ -261,21 +259,6 @@ static void my_canvas_label_pos(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) static void my_canvas_label_font(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) {iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} -static void my_canvas_list(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) -{ - int l=iemgui_list((void *)x, &x->x_gui, s, ac, av); - - /*if(l < 0) - { - post("error: my_canvas: no method for 'list'"); - } - else */if(l > 0) - { - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - } -} - static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) { t_my_canvas *x = (t_my_canvas *)pd_new(my_canvas_class); @@ -397,8 +380,6 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) static void my_canvas_ff(t_my_canvas *x) { - if(x->x_gui.x_fsf.x_selected) - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); if(x->x_gui.x_fsf.x_rcv_able) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -409,7 +390,6 @@ void g_mycanvas_setup(void) my_canvas_class = class_new(gensym("cnv"), (t_newmethod)my_canvas_new, (t_method)my_canvas_ff, sizeof(t_my_canvas), CLASS_NOINLET, A_GIMME, 0); class_addcreator((t_newmethod)my_canvas_new, gensym("my_canvas"), A_GIMME, 0); - class_addlist(my_canvas_class, my_canvas_list); class_addmethod(my_canvas_class, (t_method)my_canvas_dialog, gensym("dialog"), A_GIMME, 0); class_addmethod(my_canvas_class, (t_method)my_canvas_size, gensym("size"), A_GIMME, 0); class_addmethod(my_canvas_class, (t_method)my_canvas_delta, gensym("delta"), A_GIMME, 0); @@ -423,8 +403,6 @@ void g_mycanvas_setup(void) class_addmethod(my_canvas_class, (t_method)my_canvas_label_font, gensym("label_font"), A_GIMME, 0); class_addmethod(my_canvas_class, (t_method)my_canvas_get_pos, gensym("get_pos"), 0); - if(!iemgui_key_sym) - iemgui_key_sym = gensym("#keyname"); my_canvas_widgetbehavior.w_getrectfn = my_canvas_getrect; my_canvas_widgetbehavior.w_displacefn = iemgui_displace; my_canvas_widgetbehavior.w_selectfn = iemgui_select; diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c index e0967b5b..092c2718 100644 --- a/pd/src/g_numbox.c +++ b/pd/src/g_numbox.c @@ -25,6 +25,7 @@ /*------------------ global functions -------------------------*/ +static void my_numbox_key(void *z, t_floatarg fkey); /* ------------ nmx gui-my number box ----------------------- */ @@ -38,7 +39,7 @@ static void my_numbox_tick_reset(t_my_numbox *x) if(x->x_gui.x_fsf.x_change) { x->x_gui.x_fsf.x_change = 0; - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); + glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); } } @@ -142,25 +143,29 @@ static void my_numbox_draw_update(t_my_numbox *x, t_glist *glist) x->x_buf[sl+1] = 0; if(sl >= x->x_gui.x_w) cp += sl - x->x_gui.x_w + 1; - sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x -text {%s} \n", + sys_vgui( + ".x%x.c itemconfigure %xNUMBER -fill #%6.6x -text {%s} \n", glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, cp); x->x_buf[sl] = 0; } else { my_numbox_ftoa(x); - sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x -text {%s} \n", - glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, x->x_buf); + sys_vgui( + ".x%x.c itemconfigure %xNUMBER -fill #%6.6x -text {%s} \n", + glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, x->x_buf); x->x_buf[0] = 0; } } else { my_numbox_ftoa(x); - sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x -text {%s} \n", - glist_getcanvas(glist), x, - x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol, - x->x_buf); + sys_vgui( + ".x%x.c itemconfigure %xNUMBER -fill #%6.6x -text {%s} \n", + glist_getcanvas(glist), x, + x->x_gui.x_fsf.x_selected? + IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol, + x->x_buf); x->x_buf[0] = 0; } } @@ -173,28 +178,31 @@ static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist) int ypos=text_ypix(&x->x_gui.x_obj, glist); t_canvas *canvas=glist_getcanvas(glist); - sys_vgui(".x%x.c create polygon %d %d %d %d %d %d %d %d %d %d -outline #%6.6x -fill #%6.6x -tags %xBASE1\n", + sys_vgui( +".x%x.c create polygon %d %d %d %d %d %d %d %d %d %d -outline #%6.6x \ +-fill #%6.6x -tags %xBASE1\n", canvas, xpos, ypos, xpos + x->x_numwidth-4, ypos, xpos + x->x_numwidth, ypos+4, xpos + x->x_numwidth, ypos + x->x_gui.x_h, xpos, ypos + x->x_gui.x_h, IEM_GUI_COLOR_NORMAL, x->x_gui.x_bcol, x); - sys_vgui(".x%x.c create line %d %d %d %d %d %d -fill #%6.6x -tags %xBASE2\n", - canvas, xpos, ypos, - xpos + half, ypos + half, - xpos, ypos + x->x_gui.x_h, - x->x_gui.x_fcol, x); + sys_vgui( + ".x%x.c create line %d %d %d %d %d %d -fill #%6.6x -tags %xBASE2\n", + canvas, xpos, ypos, + xpos + half, ypos + half, + xpos, ypos + x->x_gui.x_h, + x->x_gui.x_fcol, x); sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \ - -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n", - canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, - strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", - x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x); + -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n", + canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", + x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x); my_numbox_ftoa(x); sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \ - -font {%s %d bold} -fill #%6.6x -tags %xNUMBER\n", - canvas, xpos+half+2, ypos+half+d, - x->x_buf, x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_fcol, x); + -font {%s %d bold} -fill #%6.6x -tags %xNUMBER\n", + canvas, xpos+half+2, ypos+half+d, + x->x_buf, x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_fcol, x); if(!x->x_gui.x_fsf.x_snd_able) sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n", canvas, @@ -305,25 +313,33 @@ static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist) { if(x->x_gui.x_fsf.x_change) { - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); x->x_gui.x_fsf.x_change = 0; clock_unset(x->x_clock_reset); x->x_buf[0] = 0; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); } - pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); - sys_vgui(".x%x.c itemconfigure %xBASE1 -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); - sys_vgui(".x%x.c itemconfigure %xBASE2 -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); - sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); - sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); + glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.ob_g, + 0, my_numbox_key, 0, 0); + sys_vgui(".x%x.c itemconfigure %xBASE1 -outline #%6.6x\n", + canvas, x, IEM_GUI_COLOR_SELECTED); + sys_vgui(".x%x.c itemconfigure %xBASE2 -fill #%6.6x\n", + canvas, x, IEM_GUI_COLOR_SELECTED); + sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", + canvas, x, IEM_GUI_COLOR_SELECTED); + sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x\n", + canvas, x, IEM_GUI_COLOR_SELECTED); } else { - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); - sys_vgui(".x%x.c itemconfigure %xBASE1 -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); - sys_vgui(".x%x.c itemconfigure %xBASE2 -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol); - sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); - sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol); + glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0); + sys_vgui(".x%x.c itemconfigure %xBASE1 -outline #%6.6x\n", + canvas, x, IEM_GUI_COLOR_NORMAL); + sys_vgui(".x%x.c itemconfigure %xBASE2 -fill #%6.6x\n", + canvas, x, x->x_gui.x_fcol); + sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", + canvas, x, x->x_gui.x_lcol); + sys_vgui(".x%x.c itemconfigure %xNUMBER -fill #%6.6x\n", + canvas, x, x->x_gui.x_fcol); } } @@ -370,7 +386,7 @@ static void my_numbox_save(t_gobj *z, t_binbuf *b) { x->x_gui.x_fsf.x_change = 0; clock_unset(x->x_clock_reset); - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); + glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); } @@ -438,7 +454,7 @@ static void my_numbox_properties(t_gobj *z, t_glist *owner) { x->x_gui.x_fsf.x_change = 0; clock_unset(x->x_clock_reset); - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); + glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); } @@ -452,11 +468,13 @@ static void my_numbox_properties(t_gobj *z, t_glist *owner) %d %d %d\n", x->x_gui.x_w, 1, x->x_gui.x_h, 8, x->x_min, x->x_max, 0,/*no_schedule*/ - x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, -1, x->x_log_height,/*no multi, but iem-characteristic*/ + x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, -1, + x->x_log_height, /*no multi, but iem-characteristic*/ srl[0]->s_name, srl[1]->s_name, srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, - 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); + 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, + 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); } @@ -467,7 +485,8 @@ static void my_numbox_bang(t_my_numbox *x) pd_float(x->x_gui.x_snd->s_thing, x->x_val); } -static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc, t_atom *argv) +static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc, + t_atom *argv) { t_symbol *srl[3]; int w = (int)atom_getintarg(0, argc, argv); @@ -512,13 +531,6 @@ static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy) else x->x_val -= k2*dy; my_numbox_clip(x); - if(x->x_gui.x_fsf.x_change) - { - x->x_gui.x_fsf.x_change = 0; - clock_unset(x->x_clock_reset); - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); - - } (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); my_numbox_bang(x); } @@ -526,19 +538,19 @@ static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy) static void my_numbox_click(t_my_numbox *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) { - glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, (t_glistmotionfn)my_numbox_motion, - 0, xpos, ypos); + glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, + (t_glistmotionfn)my_numbox_motion, my_numbox_key, xpos, ypos); } static int my_numbox_newclick(t_gobj *z, struct _glist *glist, - int xpix, int ypix, int shift, int alt, int dbl, int doit) + int xpix, int ypix, int shift, int alt, int dbl, int doit) { t_my_numbox* x = (t_my_numbox *)z; if(doit) { - my_numbox_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, - 0, (t_floatarg)alt); + my_numbox_click( x, (t_floatarg)xpix, (t_floatarg)ypix, + (t_floatarg)shift, 0, (t_floatarg)alt); if(shift) x->x_gui.x_fsf.x_finemoved = 1; else @@ -548,14 +560,16 @@ static int my_numbox_newclick(t_gobj *z, struct _glist *glist, clock_delay(x->x_clock_wait, 50); x->x_gui.x_fsf.x_change = 1; clock_delay(x->x_clock_reset, 3000); - pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); + /* glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.ob_g, + 0, my_numbox_key, 0, 0); */ + x->x_buf[0] = 0; } else { x->x_gui.x_fsf.x_change = 0; clock_unset(x->x_clock_reset); - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); + glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0); x->x_buf[0] = 0; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); } @@ -639,7 +653,8 @@ static void my_numbox_label(t_my_numbox *x, t_symbol *s) static void my_numbox_label_pos(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) {iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} -static void my_numbox_label_font(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) +static void my_numbox_label_font(t_my_numbox *x, + t_symbol *s, int ac, t_atom *av) { int f = (int)atom_getintarg(1, ac, av); @@ -683,118 +698,58 @@ static void my_numbox_loadbang(t_my_numbox *x) } } -static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) +static void my_numbox_key(void *z, t_floatarg fkey) { - int l=-1; + t_my_numbox *x = z; + char c=fkey; + char buf[3]; + buf[1] = 0; - if(x->x_gui.x_fsf.x_selected) + if (c == 0) { - if((ac == 2)&&IS_A_FLOAT(av,0)&&IS_A_SYMBOL(av,1)) - { - t_symbol *key = atom_getsymbolarg(1, ac, av); - int keydown = atom_getintarg(0, ac, av); - - if(keydown) - { - int refresh = 1,i,d=1; - static char buf[20]; - - buf[0] = 0; - if(!strcmp(key->s_name, "Shift_L")||!strcmp(key->s_name, "Shift_R")) - x->x_gui.x_fsf.x_shiftdown = 1; - else - { - if(x->x_gui.x_fsf.x_shiftdown) - d = 10; - if(!strcmp(key->s_name, "Up")) - x->x_gui.x_obj.te_ypix -= d; - else if(!strcmp(key->s_name, "Down")) - x->x_gui.x_obj.te_ypix += d; - else if(!strcmp(key->s_name, "Left")) - x->x_gui.x_obj.te_xpix -= d; - else if(!strcmp(key->s_name, "Right")) - x->x_gui.x_obj.te_xpix += d; - else - refresh = 0; - if(refresh) - l = 1; - } - l = 0; - } - else - { - if(!strcmp(key->s_name, "Shift_L")||!strcmp(key->s_name, "Shift_R")) - x->x_gui.x_fsf.x_shiftdown = 0; - l = 0; - } - } + x->x_gui.x_fsf.x_change = 0; + clock_unset(x->x_clock_reset); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + return; } - else + if(((c>='0')&&(c<='9'))||(c=='.')||(c=='-')|| + (c=='e')||(c=='+')||(c=='E')) { - if(x->x_gui.x_fsf.x_change) + if(strlen(x->x_buf) < (IEMGUI_MAX_NUM_LEN-2)) { - if((ac == 2)&&IS_A_FLOAT(av,0)&&IS_A_SYMBOL(av,1)) - { - t_symbol *key = atom_getsymbolarg(1, ac, av); - int keydown = atom_getintarg(0, ac, av); - char buf[3]; - - buf[1] = 0; - if(keydown) - { - char *c=key->s_name; - - l = 0; - if(((*c>='0')&&(*c<='9'))||(*c=='.')||(*c=='-')||(*c=='e')||(*c=='+')||(*c=='E')) - { - if(strlen(x->x_buf) < (IEMGUI_MAX_NUM_LEN-2)) - { - buf[0] = *c; - strcat(x->x_buf, buf); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); - } - } - else if((*c=='\b')||(*c==127)) - { - int sl=strlen(x->x_buf)-1; - - if(sl < 0) - sl = 0; - x->x_buf[sl] = 0; - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); - } - else if((*c=='\n')||(*c==13)) - { - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); - x->x_val = atof(x->x_buf); - x->x_buf[0] = 0; - x->x_gui.x_fsf.x_change = 0; - clock_unset(x->x_clock_reset); - my_numbox_clip(x); - my_numbox_bang(x); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); - } - clock_delay(x->x_clock_reset, 3000); - } - else - { - l = 0; - } - } + buf[0] = c; + strcat(x->x_buf, buf); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); } } - if(l < 0) + else if((c=='\b')||(c==127)) { - if(IS_A_FLOAT(av,0)) - { - my_numbox_set(x, atom_getfloatarg(0, ac, av)); - my_numbox_bang(x); - } + int sl=strlen(x->x_buf)-1; + + if(sl < 0) + sl = 0; + x->x_buf[sl] = 0; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); } - else if(l > 0) + else if((c=='\n')||(c==13)) { - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + x->x_val = atof(x->x_buf); + x->x_buf[0] = 0; + x->x_gui.x_fsf.x_change = 0; + clock_unset(x->x_clock_reset); + my_numbox_clip(x); + my_numbox_bang(x); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + } + clock_delay(x->x_clock_reset, 3000); +} + +static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) +{ + if (IS_A_FLOAT(av,0)) + { + my_numbox_set(x, atom_getfloatarg(0, ac, av)); + my_numbox_bang(x); } } @@ -924,8 +879,6 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) static void my_numbox_free(t_my_numbox *x) { - if(x->x_gui.x_fsf.x_selected) - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); if(x->x_gui.x_fsf.x_rcv_able) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); clock_free(x->x_clock_reset); @@ -936,35 +889,50 @@ static void my_numbox_free(t_my_numbox *x) void g_numbox_setup(void) { my_numbox_class = class_new(gensym("nbx"), (t_newmethod)my_numbox_new, - (t_method)my_numbox_free, sizeof(t_my_numbox), 0, A_GIMME, 0); - class_addcreator((t_newmethod)my_numbox_new, gensym("my_numbox"), A_GIMME, 0); + (t_method)my_numbox_free, sizeof(t_my_numbox), 0, A_GIMME, 0); + class_addcreator((t_newmethod)my_numbox_new, gensym("my_numbox"), + A_GIMME, 0); class_addbang(my_numbox_class,my_numbox_bang); class_addfloat(my_numbox_class,my_numbox_float); class_addlist(my_numbox_class, my_numbox_list); - class_addmethod(my_numbox_class, (t_method)my_numbox_click, gensym("click"), - A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_motion, gensym("motion"), - A_FLOAT, A_FLOAT, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_dialog, gensym("dialog"), - A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_loadbang, gensym("loadbang"), 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_set, gensym("set"), A_FLOAT, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_size, gensym("size"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_delta, gensym("delta"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_pos, gensym("pos"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_range, gensym("range"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_color, gensym("color"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_send, gensym("send"), A_DEFSYM, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_receive, gensym("receive"), A_DEFSYM, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_label, gensym("label"), A_DEFSYM, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_label_pos, gensym("label_pos"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_label_font, gensym("label_font"), A_GIMME, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_log, gensym("log"), 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_lin, gensym("lin"), 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_init, gensym("init"), A_FLOAT, 0); - class_addmethod(my_numbox_class, (t_method)my_numbox_log_height, gensym("log_height"), A_FLOAT, 0); - if(!iemgui_key_sym) - iemgui_key_sym = gensym("#keyname"); + class_addmethod(my_numbox_class, (t_method)my_numbox_click, + gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_motion, + gensym("motion"), A_FLOAT, A_FLOAT, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_dialog, + gensym("dialog"), A_GIMME, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_loadbang, + gensym("loadbang"), 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_set, + gensym("set"), A_FLOAT, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_size, + gensym("size"), A_GIMME, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_delta, + gensym("delta"), A_GIMME, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_pos, + gensym("pos"), A_GIMME, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_range, + gensym("range"), A_GIMME, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_color, + gensym("color"), A_GIMME, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_send, + gensym("send"), A_DEFSYM, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_receive, + gensym("receive"), A_DEFSYM, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_label, + gensym("label"), A_DEFSYM, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_label_pos, + gensym("label_pos"), A_GIMME, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_label_font, + gensym("label_font"), A_GIMME, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_log, + gensym("log"), 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_lin, + gensym("lin"), 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_init, + gensym("init"), A_FLOAT, 0); + class_addmethod(my_numbox_class, (t_method)my_numbox_log_height, + gensym("log_height"), A_FLOAT, 0); my_numbox_widgetbehavior.w_getrectfn = my_numbox_getrect; my_numbox_widgetbehavior.w_displacefn = iemgui_displace; my_numbox_widgetbehavior.w_selectfn = iemgui_select; diff --git a/pd/src/g_readwrite.c b/pd/src/g_readwrite.c index ab380971..40755bb0 100644 --- a/pd/src/g_readwrite.c +++ b/pd/src/g_readwrite.c @@ -587,20 +587,20 @@ static void canvas_saveto(t_canvas *x, t_binbuf *b) linetraverser_start(&t, x); while (oc = linetraverser_next(&t)) { - int srcno, sinkno; - for (srcno = 0, y = x->gl_list; y && y != &t.tr_ob->ob_g; y = y->g_next) - srcno++; - for (sinkno = 0, y = x->gl_list; y && y != &t.tr_ob2->ob_g; y = y->g_next) - sinkno++; + int srcno = canvas_getindex(x, &t.tr_ob->ob_g); + int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g); binbuf_addv(b, "ssiiii;", gensym("#X"), gensym("connect"), srcno, t.tr_outno, sinkno, t.tr_inno); } - if (x->gl_isgraph) - binbuf_addv(b, "ssfffffff;", gensym("#X"), gensym("coords"), - x->gl_x1, x->gl_y1, - x->gl_x2, x->gl_y2, - (float)x->gl_pixwidth, (float)x->gl_pixheight, - (float)x->gl_isgraph); + /* unless everything is the default (as in ordinary subpatches) + print out a "coords" message to set up the coordinate systems */ + if (x->gl_isgraph || x->gl_x1 || x->gl_y1 || + x->gl_x2 != 1 || x->gl_y2 != 1 || x->gl_pixwidth || x->gl_pixheight) + binbuf_addv(b, "ssfffffff;", gensym("#X"), gensym("coords"), + x->gl_x1, x->gl_y1, + x->gl_x2, x->gl_y2, + (float)x->gl_pixwidth, (float)x->gl_pixheight, + (float)x->gl_isgraph); } /* call this recursively to collect all the template names for diff --git a/pd/src/g_template.c b/pd/src/g_template.c index 5e11cc5a..8dc897a3 100644 --- a/pd/src/g_template.c +++ b/pd/src/g_template.c @@ -279,7 +279,8 @@ static t_scalar *template_conformscalar(t_template *tfrom, t_template *tto, t_scalar *x; t_gpointer gp; int nto = tto->t_n, nfrom = tfrom->t_n, i; - post("conform scalar"); + t_template *scalartemplate; + /* post("conform scalar"); */ /* possibly replace the scalar */ if (scfrom->sc_template == tfrom->t_sym) { @@ -321,15 +322,17 @@ static t_scalar *template_conformscalar(t_template *tfrom, t_template *tto, pd_free(&scfrom->sc_gobj.g_pd); } else x = scfrom; + scalartemplate = template_findbyname(x->sc_template); /* convert all array elements and sublists */ - for (i = 0; i < nto; i++) + for (i = 0; i < scalartemplate->t_n; i++) { - if (tto->t_vec[i].ds_type == DT_LIST) + t_dataslot *ds = scalartemplate->t_vec + i; + if (ds->ds_type == DT_LIST) { t_glist *gl2 = x->sc_vec[i].w_list; template_conformglist(tfrom, tto, gl2, conformaction); } - else if (tto->t_vec[i].ds_type == DT_ARRAY) + else if (ds->ds_type == DT_ARRAY) { template_conformarray(tfrom, tto, conformaction, x->sc_vec[i].w_array); @@ -373,7 +376,7 @@ static void template_conformglist(t_template *tfrom, t_template *tto, t_glist *glist, int *conformaction) { t_gobj *g; - post("conform glist %s", glist->gl_name->s_name); + /* post("conform glist %s", glist->gl_name->s_name); */ for (g = glist->gl_list; g; g = g->g_next) { if (pd_class(&g->g_pd) == scalar_class) diff --git a/pd/src/g_text.c b/pd/src/g_text.c index 226ddc7a..d59afb3a 100644 --- a/pd/src/g_text.c +++ b/pd/src/g_text.c @@ -17,12 +17,17 @@ static t_class *text_class; static t_class *message_class; static t_class *gatom_class; +static void text_vis(t_gobj *z, t_glist *glist, int vis); +static void text_displace(t_gobj *z, t_glist *glist, + int dx, int dy); +static void text_getrect(t_gobj *z, t_glist *glist, + int *xp1, int *yp1, int *xp2, int *yp2); + void canvas_startmotion(t_canvas *x); t_widgetbehavior text_widgetbehavior; /* ----------------- the "text" object. ------------------ */ - /* add a "text" object (comment) to a glist. While this one goes for any glist, the other 3 below are for canvases only. (why?) This is called without args if invoked from the GUI; otherwise at least x and y @@ -60,6 +65,7 @@ void glist_text(t_glist *gl, t_symbol *s, int argc, t_atom *argv) glist_add(gl, &x->te_g); glist_noselect(gl); glist_select(gl, &x->te_g); + gobj_activate(&x->te_g, gl, 1); canvas_startmotion(glist_getcanvas(gl)); } } @@ -193,6 +199,16 @@ void canvas_vdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv) canvas_iemguis(gl, gensym("vdl")); } +void canvas_hradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv) +{ + canvas_iemguis(gl, gensym("hradio")); +} + +void canvas_vradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv) +{ + canvas_iemguis(gl, gensym("vradio")); +} + void canvas_vumeter(t_glist *gl, t_symbol *s, int argc, t_atom *argv) { canvas_iemguis(gl, gensym("vu")); @@ -367,6 +383,7 @@ void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv) glist_add(gl, &x->m_text.te_g); glist_noselect(gl); glist_select(gl, &x->m_text.te_g); + gobj_activate(&x->m_text.te_g, gl, 1); canvas_startmotion(glist_getcanvas(gl)); } } @@ -374,19 +391,49 @@ void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv) /* ---------------------- the "atom" text item ------------------------ */ #define ATOMBUFSIZE 40 +#define ATOM_LABELLEFT 0 +#define ATOM_LABELRIGHT 1 +#define ATOM_LABELUP 2 +#define ATOM_LABELDOWN 3 typedef struct _gatom { t_text a_text; - t_atom a_atom; /* this holds the value and the type */ - t_glist *a_glist; /* owning glist */ - t_float a_toggle; /* value to toggle to */ - t_float a_draghi; /* high end of drag range */ - t_float a_draglo; /* low end of drag range */ - char a_buf[ATOMBUFSIZE]; - char a_shift; + t_atom a_atom; /* this holds the value and the type */ + t_glist *a_glist; /* owning glist */ + t_float a_toggle; /* value to toggle to */ + t_float a_draghi; /* high end of drag range */ + t_float a_draglo; /* low end of drag range */ + t_symbol *a_label; /* symbol to show as label next to box */ + t_symbol *a_symfrom; /* "receive" name -- bind ourselvs to this */ + t_symbol *a_symto; /* "send" name -- send to this on output */ + char a_buf[ATOMBUFSIZE];/* string buffer for typing */ + char a_shift; /* was shift key down when dragging started? */ + char a_wherelabel; /* 0-3 for left, right, above, below */ } t_gatom; +static t_symbol *gatom_escapit(t_symbol *s) +{ + if (!*s->s_name) + return (gensym("-")); + else if (*s->s_name == '-') + { + char shmo[100]; + shmo[0] = '-'; + strncpy(shmo+1, s->s_name, 99); + shmo[99] = 0; + return (gensym(shmo)); + } + else return (s); +} + +static t_symbol *gatom_unescapit(t_symbol *s) +{ + if (*s->s_name == '-') + return (gensym(s->s_name+1)); + else return (s); +} + static void gatom_set(t_gatom *x, t_symbol *s, int argc, t_atom *argv) { if (!argc) return; @@ -403,9 +450,31 @@ static void gatom_set(t_gatom *x, t_symbol *s, int argc, t_atom *argv) static void gatom_bang(t_gatom *x) { if (x->a_atom.a_type == A_FLOAT) - outlet_float(x->a_text.te_outlet, x->a_atom.a_w.w_float); + { + if (x->a_text.te_outlet) + outlet_float(x->a_text.te_outlet, x->a_atom.a_w.w_float); + if (*x->a_symto->s_name && x->a_symto->s_thing) + { + if (x->a_symto == x->a_symfrom) + pd_error(x, + "%s: atom with same send/receive name (infinite loop)", + x->a_symto->s_name); + else pd_float(x->a_symto->s_thing, x->a_atom.a_w.w_float); + } + } else if (x->a_atom.a_type == A_SYMBOL) - outlet_symbol(x->a_text.te_outlet, x->a_atom.a_w.w_symbol); + { + if (x->a_text.te_outlet) + outlet_symbol(x->a_text.te_outlet, x->a_atom.a_w.w_symbol); + if (*x->a_symto->s_name && x->a_symto->s_thing) + { + if (x->a_symto == x->a_symfrom) + pd_error(x, + "%s: atom with same send/receive name (infinite loop)", + x->a_symto->s_name); + else pd_symbol(x->a_symto->s_thing, x->a_atom.a_w.w_symbol); + } + } } static void gatom_float(t_gatom *x, t_float f) @@ -465,17 +534,26 @@ static void gatom_key(void *z, t_floatarg f) { t_gatom *x = (t_gatom *)z; int c = f; - int l = strlen(x->a_buf); + int len = strlen(x->a_buf); t_atom at; char sbuf[ATOMBUFSIZE + 4]; - if (c == ' ') return; - else if (c == '\b') + if (c == 0) { - if (l > 0) - { - x->a_buf[l-1] = 0; - goto redraw; + /* we're being notified that no more keys will come for this grab */ + if (x->a_buf[0]) + { + binbuf_clear(x->a_text.te_binbuf); + binbuf_add(x->a_text.te_binbuf, 1, &x->a_atom); + glist_retext(x->a_glist, &x->a_text); } + return; + } + else if (c == ' ') return; + else if (c == '\b') + { + if (len > 0) + x->a_buf[len-1] = 0; + goto redraw; } else if (c == '\n') { @@ -485,10 +563,10 @@ static void gatom_key(void *z, t_floatarg f) gatom_symbol(x, gensym(x->a_buf)); else bug("gatom_key"); } - else if (l < (ATOMBUFSIZE-1)) + else if (len < (ATOMBUFSIZE-1)) { - x->a_buf[l] = c; - x->a_buf[l+1] = 0; + x->a_buf[len] = c; + x->a_buf[len+1] = 0; goto redraw; } return; @@ -530,9 +608,34 @@ static void gatom_click(t_gatom *x, } } -static void gatom_param(t_gatom *x, t_floatarg width, t_floatarg draglo, - t_floatarg draghi) -{ + /* message back from dialog window */ +static void gatom_param(t_gatom *x, t_symbol *sel, int argc, t_atom *argv) +{ + t_float width = atom_getfloatarg(0, argc, argv); + t_float draglo = atom_getfloatarg(1, argc, argv); + t_float draghi = atom_getfloatarg(2, argc, argv); + t_symbol *label = gatom_unescapit(atom_getsymbolarg(3, argc, argv)); + t_float wherelabel = atom_getfloatarg(4, argc, argv); + t_symbol *symfrom = gatom_unescapit(atom_getsymbolarg(5, argc, argv)); + t_symbol *symto = gatom_unescapit(atom_getsymbolarg(6, argc, argv)); + + gobj_vis(&x->a_text.te_g, x->a_glist, 0); + if (!*symfrom->s_name && *x->a_symfrom->s_name) + inlet_new(&x->a_text, &x->a_text.te_pd, 0, 0); + else if (*symfrom->s_name && !*x->a_symfrom->s_name && x->a_text.te_inlet) + { + canvas_deletelinesforio(x->a_glist, &x->a_text, + x->a_text.te_inlet, 0); + inlet_free(x->a_text.te_inlet); + } + if (!*symto->s_name && *x->a_symto->s_name) + outlet_new(&x->a_text, 0); + else if (*symto->s_name && !*x->a_symto->s_name && x->a_text.te_outlet) + { + canvas_deletelinesforio(x->a_glist, &x->a_text, + 0, x->a_text.te_outlet); + outlet_free(x->a_text.te_outlet); + } if (draglo >= draghi) draglo = draghi = 0; x->a_draglo = draglo; @@ -542,7 +645,76 @@ static void gatom_param(t_gatom *x, t_floatarg width, t_floatarg draglo, else if (width > 80) width = 80; x->a_text.te_width = width; - glist_retext(x->a_glist, &x->a_text); + x->a_wherelabel = ((int)wherelabel & 3); + x->a_label = label; + if (*x->a_symfrom->s_name) + pd_unbind(&x->a_text.te_pd, x->a_symfrom); + x->a_symfrom = symfrom; + if (*x->a_symfrom->s_name) + pd_bind(&x->a_text.te_pd, x->a_symfrom); + x->a_symto = symto; + gobj_vis(&x->a_text.te_g, x->a_glist, 1); + + /* glist_retext(x->a_glist, &x->a_text); */ +} + + /* ---------------- gatom-specific widget functions --------------- */ +static void gatom_getwherelabel(t_gatom *x, t_glist *glist, int *xp, int *yp) +{ + int x1, y1, x2, y2, width, height; + text_getrect(&x->a_text.te_g, glist, &x1, &y1, &x2, &y2); + width = x2 - x1; + height = y2 - y1; + if (x->a_wherelabel == ATOM_LABELLEFT) + { + *xp = x1 - 3 - strlen(x->a_label->s_name) * + sys_fontwidth(glist_getfont(glist)); + *yp = y1 + 2; + } + else if (x->a_wherelabel == ATOM_LABELRIGHT) + { + *xp = x2 + 2; + *yp = y1 + 2; + } + else if (x->a_wherelabel == ATOM_LABELUP) + { + *xp = x1 - 1; + *yp = y1 - 1 - sys_fontheight(glist_getfont(glist));; + } + else + { + *xp = x1 - 1; + *yp = y2 + 3; + } +} + +static void gatom_displace(t_gobj *z, t_glist *glist, + int dx, int dy) +{ + t_gatom *x = (t_gatom*)z; + text_displace(z, glist, dx, dy); + sys_vgui(".x%x.c move %x.l %d %d\n", glist_getcanvas(glist), + x, dx, dy); +} + +static void gatom_vis(t_gobj *z, t_glist *glist, int vis) +{ + t_gatom *x = (t_gatom*)z; + text_vis(z, glist, vis); + if (*x->a_label->s_name) + { + if (vis) + { + int x1, y1; + gatom_getwherelabel(x, glist, &x1, &y1); + sys_vgui("pdtk_text_new .x%x.c %x.l %f %f {%s} %d %s\n", + glist_getcanvas(glist), x, + (double)x1, (double)y1, + x->a_label->s_name, sys_hostfontsize(glist_getfont(glist)), + "black"); + } + else sys_vgui(".x%x.c delete %x.l\n", glist_getcanvas(glist), x); + } } void canvas_atom(t_glist *gl, t_atomtype type, @@ -558,22 +730,26 @@ void canvas_atom(t_glist *gl, t_atomtype type, x->a_toggle = 1; x->a_draglo = 0; x->a_draghi = 0; + x->a_wherelabel = 0; + x->a_label = &s_; + x->a_symfrom = &s_; + x->a_symto = &s_; if (type == A_FLOAT) { x->a_atom.a_w.w_float = 0; x->a_text.te_width = 5; - outlet_new(&x->a_text, &s_float); SETFLOAT(&at, 0); } else { x->a_atom.a_w.w_symbol = &s_symbol; x->a_text.te_width = 10; - outlet_new(&x->a_text, &s_symbol); SETSYMBOL(&at, &s_symbol); } binbuf_add(x->a_text.te_binbuf, 1, &at); if (argc > 1) + /* create from file. x, y, width, low-range, high-range, flags, + label, receive-name, send-name */ { x->a_text.te_xpix = atom_getfloatarg(0, argc, argv); x->a_text.te_ypix = atom_getfloatarg(1, argc, argv); @@ -584,11 +760,26 @@ void canvas_atom(t_glist *gl, t_atomtype type, x->a_text.te_width = 4; x->a_draglo = atom_getfloatarg(3, argc, argv); x->a_draghi = atom_getfloatarg(4, argc, argv); + x->a_wherelabel = (((int)atom_getfloatarg(5, argc, argv)) & 3); + x->a_label = gatom_unescapit(atom_getsymbolarg(6, argc, argv)); + x->a_symfrom = gatom_unescapit(atom_getsymbolarg(7, argc, argv)); + if (*x->a_symfrom->s_name) + pd_bind(&x->a_text.te_pd, x->a_symfrom); + + x->a_symto = gatom_unescapit(atom_getsymbolarg(8, argc, argv)); + if (x->a_symto == &s_) + outlet_new(&x->a_text, + x->a_atom.a_type == A_FLOAT ? &s_float: &s_symbol); + if (x->a_symfrom == &s_) + inlet_new(&x->a_text, &x->a_text.te_pd, 0, 0); glist_add(gl, &x->a_text.te_g); } else { int xpix, ypix; + outlet_new(&x->a_text, + x->a_atom.a_type == A_FLOAT ? &s_float: &s_symbol); + inlet_new(&x->a_text, &x->a_text.te_pd, 0, 0); pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1); glist_noselect(gl); glist_getnextxy(gl, &xpix, &ypix); @@ -613,6 +804,8 @@ void canvas_symbolatom(t_glist *gl, t_symbol *s, int argc, t_atom *argv) static void gatom_free(t_gatom *x) { + if (*x->a_symfrom->s_name) + pd_bind(&x->a_text.te_pd, x->a_symfrom); gfxstub_deleteforkey(x); } @@ -620,8 +813,11 @@ static void gatom_properties(t_gobj *z, t_glist *owner) { t_gatom *x = (t_gatom *)z; char buf[200]; - sprintf(buf, "pdtk_gatom_dialog %%s %d %g %g\n", - x->a_text.te_width, x->a_draglo, x->a_draghi); + sprintf(buf, "pdtk_gatom_dialog %%s %d %g %g %d %s %s %s\n", + x->a_text.te_width, x->a_draglo, x->a_draghi, + x->a_wherelabel, gatom_escapit(x->a_label)->s_name, + gatom_escapit(x->a_symfrom)->s_name, + gatom_escapit(x->a_symto)->s_name); gfxstub_new(&x->a_text.te_pd, x, buf); } @@ -812,9 +1008,15 @@ static void text_save(t_gobj *z, t_binbuf *b) t_atomtype t = ((t_gatom *)x)->a_atom.a_type; t_symbol *sel = (t == A_SYMBOL ? gensym("symbolatom") : (t == A_FLOAT ? gensym("floatatom") : gensym("intatom"))); - binbuf_addv(b, "ssiiiff", gensym("#X"), sel, + t_symbol *label = gatom_escapit(((t_gatom *)x)->a_label); + t_symbol *symfrom = gatom_escapit(((t_gatom *)x)->a_symfrom); + t_symbol *symto = gatom_escapit(((t_gatom *)x)->a_symto); + binbuf_addv(b, "ssiiifffsss", gensym("#X"), sel, (t_int)x->te_xpix, (t_int)x->te_ypix, (t_int)x->te_width, - (double)((t_gatom *)x)->a_draglo, (double)((t_gatom *)x)->a_draghi); + (double)((t_gatom *)x)->a_draglo, + (double)((t_gatom *)x)->a_draghi, + (double)((t_gatom *)x)->a_wherelabel, + label, symfrom, symto); binbuf_addv(b, ";"); } else @@ -843,11 +1045,11 @@ t_widgetbehavior text_widgetbehavior = static t_widgetbehavior gatom_widgetbehavior = { text_getrect, - text_displace, + gatom_displace, text_select, text_activate, text_delete, - text_vis, + gatom_vis, text_click, text_save, gatom_properties, @@ -950,7 +1152,7 @@ void text_drawborder(t_text *x, t_glist *glist, sys_vgui(".x%x.c coords %sR\ %d %d %d %d %d %d %d %d %d %d %d %d\n", glist_getcanvas(glist), tag, - x1, y1, x2, y1, x2+4, y1+4, x2+4, y2, x1, y2, x1, y1); + x1, y1, x2-4, y1, x2, y1+4, x2, y2, x1, y2, x1, y1); } /* draw inlets/outlets */ @@ -1054,7 +1256,7 @@ void g_text_setup(void) class_addanything(messresponder_class, messresponder_anything); gatom_class = class_new(gensym("gatom"), 0, (t_method)gatom_free, - sizeof(t_gatom), CLASS_PATCHABLE, 0); + sizeof(t_gatom), CLASS_NOINLET | CLASS_PATCHABLE, 0); class_addbang(gatom_class, gatom_bang); class_addfloat(gatom_class, gatom_float); class_addsymbol(gatom_class, gatom_symbol); @@ -1063,7 +1265,7 @@ void g_text_setup(void) class_addmethod(gatom_class, (t_method)gatom_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod(gatom_class, (t_method)gatom_param, gensym("param"), - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + A_GIMME, 0); class_setwidget(gatom_class, &gatom_widgetbehavior); } diff --git a/pd/src/g_toggle.c b/pd/src/g_toggle.c index 6eba64d2..a119e242 100644 --- a/pd/src/g_toggle.c +++ b/pd/src/g_toggle.c @@ -159,13 +159,11 @@ void toggle_draw_select(t_toggle* x, t_glist* glist) if(x->x_gui.x_fsf.x_selected) { - pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); } else { - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); } @@ -362,22 +360,6 @@ static void toggle_nonzero(t_toggle *x, t_floatarg f) x->x_nonzero = f; } -static void toggle_list(t_toggle *x, t_symbol *s, int ac, t_atom *av) -{ - int l=iemgui_list((void *)x, &x->x_gui, s, ac, av); - - if(l < 0) - { - if(IS_A_FLOAT(av,0)) - toggle_float(x, atom_getfloatarg(0, ac, av)); - } - else if(l > 0) - { - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - } -} - static void *toggle_new(t_symbol *s, int argc, t_atom *argv) { t_toggle *x = (t_toggle *)pd_new(toggle_class); @@ -480,8 +462,6 @@ static void *toggle_new(t_symbol *s, int argc, t_atom *argv) static void toggle_ff(t_toggle *x) { - if(x->x_gui.x_fsf.x_selected) - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); if(x->x_gui.x_fsf.x_rcv_able) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -494,7 +474,6 @@ void g_toggle_setup(void) class_addcreator((t_newmethod)toggle_new, gensym("toggle"), A_GIMME, 0); class_addbang(toggle_class, toggle_bang); class_addfloat(toggle_class, toggle_float); - class_addlist(toggle_class, toggle_list); class_addmethod(toggle_class, (t_method)toggle_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod(toggle_class, (t_method)toggle_dialog, gensym("dialog"), @@ -512,8 +491,6 @@ void g_toggle_setup(void) class_addmethod(toggle_class, (t_method)toggle_label_font, gensym("label_font"), A_GIMME, 0); class_addmethod(toggle_class, (t_method)toggle_init, gensym("init"), A_FLOAT, 0); class_addmethod(toggle_class, (t_method)toggle_nonzero, gensym("nonzero"), A_FLOAT, 0); - if(!iemgui_key_sym) - iemgui_key_sym = gensym("#keyname"); toggle_widgetbehavior.w_getrectfn = toggle_getrect; toggle_widgetbehavior.w_displacefn = iemgui_displace; toggle_widgetbehavior.w_selectfn = iemgui_select; diff --git a/pd/src/g_vdial.c b/pd/src/g_vdial.c index 49c8d0d4..e1cd2a5d 100644 --- a/pd/src/g_vdial.c +++ b/pd/src/g_vdial.c @@ -2,7 +2,10 @@ * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ -/* vdial.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ +/* vradio.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ + +/* name change to vradio by MSP (it's a radio button really) and changed to +put out a "float" as in sliders, toggles, etc. */ #include #include @@ -14,7 +17,7 @@ #include "g_all_guis.h" #include -/*------------------ global varaibles -------------------------*/ +/*------------------ global variables -------------------------*/ /*------------------ global functions -------------------------*/ @@ -22,14 +25,14 @@ -/* ------------- vdl gui-vertical dial ---------------------- */ +/* ------------- vdl gui-vertical radio button ---------------------- */ -t_widgetbehavior vdial_widgetbehavior; -static t_class *vdial_class; +t_widgetbehavior vradio_widgetbehavior; +static t_class *vradio_class, *vradio_old_class; /* widget helper functions */ -void vdial_draw_update(t_vdial *x, t_glist *glist) +void vradio_draw_update(t_vradio *x, t_glist *glist) { if(glist_isvisible(glist)) { @@ -44,7 +47,7 @@ void vdial_draw_update(t_vdial *x, t_glist *glist) } } -void vdial_draw_new(t_vdial *x, t_glist *glist) +void vradio_draw_new(t_vradio *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4; @@ -82,7 +85,7 @@ void vdial_draw_new(t_vdial *x, t_glist *glist) canvas, xx11, yy11b, xx11 + IOWIDTH, yy11b+1, x, 0); } -void vdial_draw_move(t_vdial *x, t_glist *glist) +void vradio_draw_move(t_vradio *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4; @@ -113,7 +116,7 @@ void vdial_draw_move(t_vdial *x, t_glist *glist) canvas, x, 0, xx11, yy11b, xx11 + IOWIDTH, yy11b+1); } -void vdial_draw_erase(t_vdial* x, t_glist* glist) +void vradio_draw_erase(t_vradio* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i; @@ -130,7 +133,7 @@ void vdial_draw_erase(t_vdial* x, t_glist* glist) sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); } -void vdial_draw_config(t_vdial* x, t_glist* glist) +void vradio_draw_config(t_vradio* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i; @@ -149,7 +152,7 @@ void vdial_draw_config(t_vdial* x, t_glist* glist) } } -void vdial_draw_io(t_vdial* x, t_glist* glist, int old_snd_rcv_flags) +void vradio_draw_io(t_vradio* x, t_glist* glist, int old_snd_rcv_flags) { t_canvas *canvas=glist_getcanvas(glist); int xpos=text_xpix(&x->x_gui.x_obj, glist); @@ -172,14 +175,13 @@ void vdial_draw_io(t_vdial* x, t_glist* glist, int old_snd_rcv_flags) sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); } -void vdial_draw_select(t_vdial* x, t_glist* glist) +void vradio_draw_select(t_vradio* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i; if(x->x_gui.x_fsf.x_selected) { - pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); for(i=0; ix_gui.x_obj.ob_pd, iemgui_key_sym); for(i=0; i= IEM_GUI_DRAW_MODE_IO) - vdial_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO); + vradio_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO); } /* ------------------------ vdl widgetbehaviour----------------------------- */ -static void vdial_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) +static void vradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) { - t_vdial *x = (t_vdial *)z; + t_vradio *x = (t_vradio *)z; *xp1 = text_xpix(&x->x_gui.x_obj, glist); *yp1 = text_ypix(&x->x_gui.x_obj, glist); @@ -230,9 +231,9 @@ static void vdial_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp *yp2 = *yp1 + x->x_gui.x_h*x->x_number; } -static void vdial_save(t_gobj *z, t_binbuf *b) +static void vradio_save(t_gobj *z, t_binbuf *b) { - t_vdial *x = (t_vdial *)z; + t_vradio *x = (t_vradio *)z; int bflcol[3], *ip1, *ip2; t_symbol *srl[3]; @@ -242,7 +243,9 @@ static void vdial_save(t_gobj *z, t_binbuf *b) binbuf_addv(b, "ssiisiiiisssiiiiiiii", gensym("#X"),gensym("obj"), (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix, - gensym("vdl"), x->x_gui.x_w, + (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class ? + gensym("vdl") : gensym("vradio")), + x->x_gui.x_w, x->x_change, (*ip1)&IEM_INIT_ARGS_ALL, x->x_number, srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, @@ -251,14 +254,14 @@ static void vdial_save(t_gobj *z, t_binbuf *b) binbuf_addv(b, ";"); } -static void vdial_properties(t_gobj *z, t_glist *owner) +static void vradio_properties(t_gobj *z, t_glist *owner) { - t_vdial *x = (t_vdial *)z; + t_vradio *x = (t_vradio *)z; char buf[800]; t_symbol *srl[3]; iemgui_properties(&x->x_gui, srl); - sprintf(buf, "pdtk_iemgui_dialog %%s VDIAL \ + sprintf(buf, "pdtk_iemgui_dialog %%s vradio \ ----------dimensions(pix):----------- %d %d size: 0 0 empty \ empty 0.0 empty 0.0 empty %d \ %d new-only new&old %d %d number: %d \ @@ -276,7 +279,7 @@ static void vdial_properties(t_gobj *z, t_glist *owner) gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); } -static void vdial_dialog(t_vdial *x, t_symbol *s, int argc, t_atom *argv) +static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv) { t_symbol *srl[3]; int a = (int)atom_getintarg(0, argc, argv); @@ -309,7 +312,7 @@ static void vdial_dialog(t_vdial *x, t_symbol *s, int argc, t_atom *argv) } } -static void vdial_set(t_vdial *x, t_floatarg f) +static void vradio_set(t_vradio *x, t_floatarg f) { int i=(int)f; int old; @@ -333,25 +336,30 @@ static void vdial_set(t_vdial *x, t_floatarg f) } } -static void vdial_bang(t_vdial *x) +static void vradio_bang(t_vradio *x) { - if((x->x_change)&&(x->x_on != x->x_on_old)) + /* compatibility with earlier "vdial" behavior */ + if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class) { - SETFLOAT(x->x_at, (float)x->x_on_old); - SETFLOAT(x->x_at+1, 0.0); + if((x->x_change)&&(x->x_on != x->x_on_old)) + { + SETFLOAT(x->x_at, (float)x->x_on_old); + SETFLOAT(x->x_at+1, 0.0); + outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + } + x->x_on_old = x->x_on; + SETFLOAT(x->x_at, (float)x->x_on); + SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } - x->x_on_old = x->x_on; - SETFLOAT(x->x_at, (float)x->x_on); - SETFLOAT(x->x_at+1, 1.0); - outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) - pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + else outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); } -static void vdial_fout(t_vdial *x, t_floatarg f) +static void vradio_fout(t_vradio *x, t_floatarg f) { int i=(int)f; @@ -360,27 +368,37 @@ static void vdial_fout(t_vdial *x, t_floatarg f) if(i >= x->x_number) i = x->x_number-1; - if((x->x_change)&&(i != x->x_on_old)) + if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class) { - SETFLOAT(x->x_at, (float)x->x_on_old); - SETFLOAT(x->x_at+1, 0.0); + /* compatibility with earlier "vdial" behavior */ + if((x->x_change)&&(i != x->x_on_old)) + { + SETFLOAT(x->x_at, (float)x->x_on_old); + SETFLOAT(x->x_at+1, 0.0); + outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + } + if(x->x_on != x->x_on_old) + x->x_on_old = x->x_on; + x->x_on = i; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + x->x_on_old = x->x_on; + SETFLOAT(x->x_at, (float)x->x_on); + SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } - if(x->x_on != x->x_on_old) + else + { + outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on = i); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); x->x_on_old = x->x_on; - x->x_on = i; - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); - x->x_on_old = x->x_on; - SETFLOAT(x->x_at, (float)x->x_on); - SETFLOAT(x->x_at+1, 1.0); - outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) - pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + } } -static void vdial_float(t_vdial *x, t_floatarg f) +static void vradio_float(t_vradio *x, t_floatarg f) { int i=(int)f; @@ -389,54 +407,72 @@ static void vdial_float(t_vdial *x, t_floatarg f) if(i >= x->x_number) i = x->x_number-1; - if((x->x_change)&&(i != x->x_on_old)) + if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class) { + /* compatibility with earlier "vdial" behavior */ + if((x->x_change)&&(i != x->x_on_old)) + { + if(x->x_gui.x_fsf.x_put_in2out) + { + SETFLOAT(x->x_at, (float)x->x_on_old); + SETFLOAT(x->x_at+1, 0.0); + outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + } + } + if(x->x_on != x->x_on_old) + x->x_on_old = x->x_on; + x->x_on = i; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + x->x_on_old = x->x_on; if(x->x_gui.x_fsf.x_put_in2out) { - SETFLOAT(x->x_at, (float)x->x_on_old); - SETFLOAT(x->x_at+1, 0.0); + SETFLOAT(x->x_at, (float)x->x_on); + SETFLOAT(x->x_at+1, 1.0); outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); } } - if(x->x_on != x->x_on_old) - x->x_on_old = x->x_on; - x->x_on = i; - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); - x->x_on_old = x->x_on; - if(x->x_gui.x_fsf.x_put_in2out) + else { - SETFLOAT(x->x_at, (float)x->x_on); - SETFLOAT(x->x_at+1, 1.0); - outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) - pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at); + x->x_on = i; + if (x->x_gui.x_fsf.x_put_in2out) + { + outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_float(x->x_gui.x_snd->s_thing, x->x_on); + } + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + x->x_on_old = x->x_on; } } -static void vdial_click(t_vdial *x, t_floatarg xpos, t_floatarg ypos, +static void vradio_click(t_vradio *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) { int yy = (int)ypos - text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist); - vdial_fout(x, (float)(yy / x->x_gui.x_h)); + vradio_fout(x, (float)(yy / x->x_gui.x_h)); } -static int vdial_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) +static int vradio_newclick(t_gobj *z, struct _glist *glist, + int xpix, int ypix, int shift, int alt, int dbl, int doit) { if(doit) - vdial_click((t_vdial *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); + vradio_click((t_vradio *)z, (t_floatarg)xpix, (t_floatarg)ypix, + (t_floatarg)shift, 0, (t_floatarg)alt); return (1); } -static void vdial_loadbang(t_vdial *x) +static void vradio_loadbang(t_vradio *x) { if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) - vdial_bang(x); + vradio_bang(x); } -static void vdial_number(t_vdial *x, t_floatarg num) +static void vradio_number(t_vradio *x, t_floatarg num) { int n=(int)num; @@ -455,67 +491,51 @@ static void vdial_number(t_vdial *x, t_floatarg num) } } -static void vdial_size(t_vdial *x, t_symbol *s, int ac, t_atom *av) +static void vradio_size(t_vradio *x, t_symbol *s, int ac, t_atom *av) { x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); x->x_gui.x_h = x->x_gui.x_w; iemgui_size((void *)x, &x->x_gui); } -static void vdial_delta(t_vdial *x, t_symbol *s, int ac, t_atom *av) +static void vradio_delta(t_vradio *x, t_symbol *s, int ac, t_atom *av) {iemgui_delta((void *)x, &x->x_gui, s, ac, av);} -static void vdial_pos(t_vdial *x, t_symbol *s, int ac, t_atom *av) +static void vradio_pos(t_vradio *x, t_symbol *s, int ac, t_atom *av) {iemgui_pos((void *)x, &x->x_gui, s, ac, av);} -static void vdial_color(t_vdial *x, t_symbol *s, int ac, t_atom *av) +static void vradio_color(t_vradio *x, t_symbol *s, int ac, t_atom *av) {iemgui_color((void *)x, &x->x_gui, s, ac, av);} -static void vdial_send(t_vdial *x, t_symbol *s) +static void vradio_send(t_vradio *x, t_symbol *s) {iemgui_send(x, &x->x_gui, s);} -static void vdial_receive(t_vdial *x, t_symbol *s) +static void vradio_receive(t_vradio *x, t_symbol *s) {iemgui_receive(x, &x->x_gui, s);} -static void vdial_label(t_vdial *x, t_symbol *s) +static void vradio_label(t_vradio *x, t_symbol *s) {iemgui_label((void *)x, &x->x_gui, s);} -static void vdial_label_pos(t_vdial *x, t_symbol *s, int ac, t_atom *av) +static void vradio_label_pos(t_vradio *x, t_symbol *s, int ac, t_atom *av) {iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} -static void vdial_label_font(t_vdial *x, t_symbol *s, int ac, t_atom *av) +static void vradio_label_font(t_vradio *x, t_symbol *s, int ac, t_atom *av) {iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} -static void vdial_init(t_vdial *x, t_floatarg f) +static void vradio_init(t_vradio *x, t_floatarg f) { x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; } -static void vdial_double_change(t_vdial *x) +static void vradio_double_change(t_vradio *x) {x->x_change = 1;} -static void vdial_single_change(t_vdial *x) +static void vradio_single_change(t_vradio *x) {x->x_change = 0;} -static void vdial_list(t_vdial *x, t_symbol *s, int ac, t_atom *av) +static void *vradio_donew(t_symbol *s, int argc, t_atom *argv, int old) { - int l=iemgui_list((void *)x, &x->x_gui, s, ac, av); - - if(l < 0) - { - if(IS_A_FLOAT(av,0)) - vdial_float(x, atom_getfloatarg(0, ac, av)); - } - else if(l > 0) - { - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - } -} - -static void *vdial_new(t_symbol *s, int argc, t_atom *argv) -{ - t_vdial *x = (t_vdial *)pd_new(vdial_class); + t_vradio *x = (t_vradio *)pd_new(old? vradio_old_class : vradio_class); int bflcol[]={-262144, -1, -1}; t_symbol *srl[3]; int a=IEM_GUI_DEFAULTSIZE, on=0, f=0; @@ -526,6 +546,7 @@ static void *vdial_new(t_symbol *s, int argc, t_atom *argv) t_iem_fstyle_flags *fstyle=(t_iem_fstyle_flags *)(&ifstyle); char str[144]; + /* post("new %s %d", s->s_name, old); */ srl[0] = gensym("empty"); srl[1] = gensym("empty"); srl[2] = gensym("empty"); @@ -573,7 +594,7 @@ static void *vdial_new(t_symbol *s, int argc, t_atom *argv) bflcol[2] = (int)atom_getintarg(13, argc, argv); on = (int)atom_getintarg(14, argc, argv); } - x->x_gui.x_draw = (t_iemfunptr)vdial_draw; + x->x_gui.x_draw = (t_iemfunptr)vradio_draw; iinit &= IEM_INIT_ARGS_ALL; ifstyle &= IEM_FSTYLE_FLAGS_ALL; fstyle->x_snd_able = 1; @@ -621,52 +642,99 @@ static void *vdial_new(t_symbol *s, int argc, t_atom *argv) return (x); } -static void vdial_ff(t_vdial *x) +static void *vradio_new(t_symbol *s, int argc, t_atom *argv) +{ + return (vradio_donew(s, argc, argv, 0)); +} + +static void *vdial_new(t_symbol *s, int argc, t_atom *argv) +{ + return (vradio_donew(s, argc, argv, 1)); +} + +static void vradio_ff(t_vradio *x) { - if(x->x_gui.x_fsf.x_selected) - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); if(x->x_gui.x_fsf.x_rcv_able) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); } -void g_vdial_setup(void) +void g_vradio_setup(void) { - vdial_class = class_new(gensym("vdl"), (t_newmethod)vdial_new, - (t_method)vdial_ff, sizeof(t_vdial), 0, A_GIMME, 0); - class_addbang(vdial_class, vdial_bang); - class_addfloat(vdial_class, vdial_float); - class_addlist(vdial_class, vdial_list); - class_addmethod(vdial_class, (t_method)vdial_click, gensym("click"), + vradio_class = class_new(gensym("vradio"), (t_newmethod)vradio_new, + (t_method)vradio_ff, sizeof(t_vradio), 0, A_GIMME, 0); + class_addbang(vradio_class, vradio_bang); + class_addfloat(vradio_class, vradio_float); + class_addmethod(vradio_class, (t_method)vradio_click, gensym("click"), + A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + class_addmethod(vradio_class, (t_method)vradio_dialog, gensym("dialog"), + A_GIMME, 0); + class_addmethod(vradio_class, (t_method)vradio_loadbang, + gensym("loadbang"), 0); + class_addmethod(vradio_class, (t_method)vradio_set, + gensym("set"), A_FLOAT, 0); + class_addmethod(vradio_class, (t_method)vradio_size, + gensym("size"), A_GIMME, 0); + class_addmethod(vradio_class, (t_method)vradio_delta, + gensym("delta"), A_GIMME, 0); + class_addmethod(vradio_class, (t_method)vradio_pos, + gensym("pos"), A_GIMME, 0); + class_addmethod(vradio_class, (t_method)vradio_color, + gensym("color"), A_GIMME, 0); + class_addmethod(vradio_class, (t_method)vradio_send, + gensym("send"), A_DEFSYM, 0); + class_addmethod(vradio_class, (t_method)vradio_receive, + gensym("receive"), A_DEFSYM, 0); + class_addmethod(vradio_class, (t_method)vradio_label, + gensym("label"), A_DEFSYM, 0); + class_addmethod(vradio_class, (t_method)vradio_label_pos, + gensym("label_pos"), A_GIMME, 0); + class_addmethod(vradio_class, (t_method)vradio_label_font, + gensym("label_font"), A_GIMME, 0); + class_addmethod(vradio_class, (t_method)vradio_init, + gensym("init"), A_FLOAT, 0); + class_addmethod(vradio_class, (t_method)vradio_number, + gensym("number"), A_FLOAT, 0); + class_addmethod(vradio_class, (t_method)vradio_single_change, + gensym("single_change"), 0); + class_addmethod(vradio_class, (t_method)vradio_double_change, + gensym("double_change"), 0); + vradio_widgetbehavior.w_getrectfn = vradio_getrect; + vradio_widgetbehavior.w_displacefn = iemgui_displace; + vradio_widgetbehavior.w_selectfn = iemgui_select; + vradio_widgetbehavior.w_activatefn = NULL; + vradio_widgetbehavior.w_deletefn = iemgui_delete; + vradio_widgetbehavior.w_visfn = iemgui_vis; + vradio_widgetbehavior.w_clickfn = vradio_newclick; + vradio_widgetbehavior.w_propertiesfn = vradio_properties; + vradio_widgetbehavior.w_savefn = vradio_save; + class_setwidget(vradio_class, &vradio_widgetbehavior); + class_sethelpsymbol(vradio_class, gensym("vradio")); + + /* obsolete version (0.34-0.35) */ + vradio_old_class = class_new(gensym("vdl"), (t_newmethod)vdial_new, + (t_method)vradio_ff, sizeof(t_vradio), 0, A_GIMME, 0); + class_addbang(vradio_old_class, vradio_bang); + class_addfloat(vradio_old_class, vradio_float); + class_addmethod(vradio_old_class, (t_method)vradio_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); - class_addmethod(vdial_class, (t_method)vdial_dialog, gensym("dialog"), + class_addmethod(vradio_old_class, (t_method)vradio_dialog, gensym("dialog"), A_GIMME, 0); - class_addmethod(vdial_class, (t_method)vdial_loadbang, gensym("loadbang"), 0); - class_addmethod(vdial_class, (t_method)vdial_set, gensym("set"), A_FLOAT, 0); - class_addmethod(vdial_class, (t_method)vdial_size, gensym("size"), A_GIMME, 0); - class_addmethod(vdial_class, (t_method)vdial_delta, gensym("delta"), A_GIMME, 0); - class_addmethod(vdial_class, (t_method)vdial_pos, gensym("pos"), A_GIMME, 0); - class_addmethod(vdial_class, (t_method)vdial_color, gensym("color"), A_GIMME, 0); - class_addmethod(vdial_class, (t_method)vdial_send, gensym("send"), A_DEFSYM, 0); - class_addmethod(vdial_class, (t_method)vdial_receive, gensym("receive"), A_DEFSYM, 0); - class_addmethod(vdial_class, (t_method)vdial_label, gensym("label"), A_DEFSYM, 0); - class_addmethod(vdial_class, (t_method)vdial_label_pos, gensym("label_pos"), A_GIMME, 0); - class_addmethod(vdial_class, (t_method)vdial_label_font, gensym("label_font"), A_GIMME, 0); - class_addmethod(vdial_class, (t_method)vdial_init, gensym("init"), A_FLOAT, 0); - class_addmethod(vdial_class, (t_method)vdial_number, gensym("number"), A_FLOAT, 0); - class_addmethod(vdial_class, (t_method)vdial_single_change, gensym("single_change"), 0); - class_addmethod(vdial_class, (t_method)vdial_double_change, gensym("double_change"), 0); - if(!iemgui_key_sym) - iemgui_key_sym = gensym("#keyname"); - vdial_widgetbehavior.w_getrectfn = vdial_getrect; - vdial_widgetbehavior.w_displacefn = iemgui_displace; - vdial_widgetbehavior.w_selectfn = iemgui_select; - vdial_widgetbehavior.w_activatefn = NULL; - vdial_widgetbehavior.w_deletefn = iemgui_delete; - vdial_widgetbehavior.w_visfn = iemgui_vis; - vdial_widgetbehavior.w_clickfn = vdial_newclick; - vdial_widgetbehavior.w_propertiesfn = vdial_properties; - vdial_widgetbehavior.w_savefn = vdial_save; - class_setwidget(vdial_class, &vdial_widgetbehavior); - class_sethelpsymbol(vdial_class, gensym("vdial")); + class_addmethod(vradio_old_class, (t_method)vradio_loadbang, gensym("loadbang"), 0); + class_addmethod(vradio_old_class, (t_method)vradio_set, gensym("set"), A_FLOAT, 0); + class_addmethod(vradio_old_class, (t_method)vradio_size, gensym("size"), A_GIMME, 0); + class_addmethod(vradio_old_class, (t_method)vradio_delta, gensym("delta"), A_GIMME, 0); + class_addmethod(vradio_old_class, (t_method)vradio_pos, gensym("pos"), A_GIMME, 0); + class_addmethod(vradio_old_class, (t_method)vradio_color, gensym("color"), A_GIMME, 0); + class_addmethod(vradio_old_class, (t_method)vradio_send, gensym("send"), A_DEFSYM, 0); + class_addmethod(vradio_old_class, (t_method)vradio_receive, gensym("receive"), A_DEFSYM, 0); + class_addmethod(vradio_old_class, (t_method)vradio_label, gensym("label"), A_DEFSYM, 0); + class_addmethod(vradio_old_class, (t_method)vradio_label_pos, gensym("label_pos"), A_GIMME, 0); + class_addmethod(vradio_old_class, (t_method)vradio_label_font, gensym("label_font"), A_GIMME, 0); + class_addmethod(vradio_old_class, (t_method)vradio_init, gensym("init"), A_FLOAT, 0); + class_addmethod(vradio_old_class, (t_method)vradio_number, gensym("number"), A_FLOAT, 0); + class_addmethod(vradio_old_class, (t_method)vradio_single_change, gensym("single_change"), 0); + class_addmethod(vradio_old_class, (t_method)vradio_double_change, gensym("double_change"), 0); + class_setwidget(vradio_old_class, &vradio_widgetbehavior); + class_sethelpsymbol(vradio_old_class, gensym("vradio")); } diff --git a/pd/src/g_vslider.c b/pd/src/g_vslider.c index 12cc4213..81960d48 100644 --- a/pd/src/g_vslider.c +++ b/pd/src/g_vslider.c @@ -161,13 +161,11 @@ static void vslider_draw_select(t_vslider *x, t_glist *glist) if(x->x_gui.x_fsf.x_selected) { - pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); } else { - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); } @@ -381,8 +379,8 @@ static void vslider_click(t_vslider *x, t_floatarg xpos, t_floatarg ypos, x->x_pos = x->x_val; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); vslider_bang(x); - glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, (t_glistmotionfn)vslider_motion, - 0, xpos, ypos); + glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, + (t_glistmotionfn)vslider_motion, 0, xpos, ypos); } static int vslider_newclick(t_gobj *z, struct _glist *glist, @@ -505,22 +503,6 @@ static void vslider_loadbang(t_vslider *x) } } -static void vslider_list(t_vslider *x, t_symbol *s, int ac, t_atom *av) -{ - int l=iemgui_list((void *)x, &x->x_gui, s, ac, av); - - if(l < 0) - { - if(IS_A_FLOAT(av,0)) - vslider_float(x, atom_getfloatarg(0, ac, av)); - } - else if(l > 0) - { - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - } -} - static void *vslider_new(t_symbol *s, int argc, t_atom *argv) { t_vslider *x = (t_vslider *)pd_new(vslider_class); @@ -635,8 +617,6 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv) static void vslider_free(t_vslider *x) { - if(x->x_gui.x_fsf.x_selected) - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); if(x->x_gui.x_fsf.x_rcv_able) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -649,7 +629,6 @@ void g_vslider_setup(void) class_addcreator((t_newmethod)vslider_new, gensym("vslider"), A_GIMME, 0); class_addbang(vslider_class,vslider_bang); class_addfloat(vslider_class,vslider_float); - class_addlist(vslider_class, vslider_list); class_addmethod(vslider_class, (t_method)vslider_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod(vslider_class, (t_method)vslider_motion, gensym("motion"), @@ -672,8 +651,6 @@ void g_vslider_setup(void) class_addmethod(vslider_class, (t_method)vslider_lin, gensym("lin"), 0); class_addmethod(vslider_class, (t_method)vslider_init, gensym("init"), A_FLOAT, 0); class_addmethod(vslider_class, (t_method)vslider_steady, gensym("steady"), A_FLOAT, 0); - if(!iemgui_key_sym) - iemgui_key_sym = gensym("#keyname"); vslider_widgetbehavior.w_getrectfn = vslider_getrect; vslider_widgetbehavior.w_displacefn = iemgui_displace; vslider_widgetbehavior.w_selectfn = iemgui_select; diff --git a/pd/src/g_vumeter.c b/pd/src/g_vumeter.c index b257c588..95b976dd 100644 --- a/pd/src/g_vumeter.c +++ b/pd/src/g_vumeter.c @@ -330,7 +330,6 @@ static void vu_draw_select(t_vu* x,t_glist* glist) if(x->x_gui.x_fsf.x_selected) { - pd_bind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); for(i=1; i<=IEM_VU_STEPS; i++) { @@ -348,7 +347,6 @@ static void vu_draw_select(t_vu* x,t_glist* glist) } else { - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); for(i=1; i<=IEM_VU_STEPS; i++) { @@ -598,25 +596,6 @@ static void vu_ft1(t_vu *x, t_floatarg peak) vu_update_peak(x, x->x_gui.x_glist); } -static void vu_list(t_vu *x, t_symbol *s, int ac, t_atom *av) -{ - int l=iemgui_list((void *)x, &x->x_gui, s, ac, av); - - if(l < 0) - { - if((IS_A_FLOAT(av,0))&&(IS_A_FLOAT(av,1))) - { - vu_ft1(x, atom_getfloatarg(1, ac, av)); - vu_float(x, atom_getfloatarg(0, ac, av)); - } - } - else if(l > 0) - { - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - } -} - static void vu_bang(t_vu *x) { outlet_float(x->x_out_peak, x->x_fp); @@ -720,8 +699,6 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv) static void vu_free(t_vu *x) { - if(x->x_gui.x_fsf.x_selected) - pd_unbind(&x->x_gui.x_obj.ob_pd, iemgui_key_sym); if(x->x_gui.x_fsf.x_rcv_able) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); @@ -734,7 +711,6 @@ void g_vumeter_setup(void) class_addbang(vu_class,vu_bang); class_addfloat(vu_class,vu_float); class_addmethod(vu_class, (t_method)vu_ft1, gensym("ft1"), A_FLOAT, 0); - class_addlist(vu_class, vu_list); class_addmethod(vu_class, (t_method)vu_dialog, gensym("dialog"), A_GIMME, 0); class_addmethod(vu_class, (t_method)vu_size, gensym("size"), A_GIMME, 0); @@ -746,8 +722,6 @@ void g_vumeter_setup(void) class_addmethod(vu_class, (t_method)vu_label, gensym("label"), A_DEFSYM, 0); class_addmethod(vu_class, (t_method)vu_label_pos, gensym("label_pos"), A_GIMME, 0); class_addmethod(vu_class, (t_method)vu_label_font, gensym("label_font"), A_GIMME, 0); - if(!iemgui_key_sym) - iemgui_key_sym = gensym("#keyname"); vu_widgetbehavior.w_getrectfn = vu_getrect; vu_widgetbehavior.w_displacefn = iemgui_displace; vu_widgetbehavior.w_selectfn = iemgui_select; diff --git a/pd/src/m_binbuf.c b/pd/src/m_binbuf.c index 6ff79e93..1398ad84 100644 --- a/pd/src/m_binbuf.c +++ b/pd/src/m_binbuf.c @@ -43,6 +43,15 @@ void binbuf_free(t_binbuf *x) t_freebytes(x, sizeof(*x)); } +t_binbuf *binbuf_duplicate(t_binbuf *y) +{ + t_binbuf *x = (t_binbuf *)t_getbytes(sizeof(*x)); + x->b_n = y->b_n; + x->b_vec = t_getbytes(x->b_n * sizeof(*x->b_vec)); + memcpy(x->b_vec, y->b_vec, x->b_n * sizeof(*x->b_vec)); + return (x); +} + void binbuf_clear(t_binbuf *x) { x->b_vec = t_resizebytes(x->b_vec, x->b_n * sizeof(*x->b_vec), 0); @@ -729,7 +738,7 @@ int binbuf_write(t_binbuf *x, char *filename, char *dir, int crflag) bp += length; ncolumn += length; } - if (ap->a_type == A_SEMI || ncolumn > 65) + if (ap->a_type == A_SEMI || (!crflag && ncolumn > 65)) { *bp++ = '\n'; ncolumn = 0; diff --git a/pd/src/m_conf.c b/pd/src/m_conf.c index 04cddeda..e2ba1689 100644 --- a/pd/src/m_conf.c +++ b/pd/src/m_conf.c @@ -12,12 +12,12 @@ void g_canvas_setup(void); void g_guiconnect_setup(void); /* iemlib */ void g_bang_setup(void); -void g_hdial_setup(void); +void g_hradio_setup(void); void g_hslider_setup(void); void g_mycanvas_setup(void); void g_numbox_setup(void); void g_toggle_setup(void); -void g_vdial_setup(void); +void g_vradio_setup(void); void g_vslider_setup(void); void g_vumeter_setup(void); /* iemlib */ @@ -58,12 +58,12 @@ void conf_init(void) g_guiconnect_setup(); /* iemlib */ g_bang_setup(); - g_hdial_setup(); + g_hradio_setup(); g_hslider_setup(); g_mycanvas_setup(); g_numbox_setup(); g_toggle_setup(); - g_vdial_setup(); + g_vradio_setup(); g_vslider_setup(); g_vumeter_setup(); /* iemlib */ diff --git a/pd/src/m_obj.c b/pd/src/m_obj.c index 6b9ea932..6e3e1c19 100644 --- a/pd/src/m_obj.c +++ b/pd/src/m_obj.c @@ -384,6 +384,12 @@ void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom *argv) typedmess(oc->oc_to, s, argc, argv); } + /* get the outlet's declared symbol */ +t_symbol *outlet_getsymbol(t_outlet *x) +{ + return (x->o_sym); +} + void outlet_free(t_outlet *x) { t_object *y = x->o_owner; diff --git a/pd/src/m_pd.h b/pd/src/m_pd.h index 172bf49d..c6ddb0c9 100644 --- a/pd/src/m_pd.h +++ b/pd/src/m_pd.h @@ -26,7 +26,7 @@ extern "C" { /* and depending on the compiler, hidden data structures are declared differently: */ -#ifdef __GNUC__ +#if defined( __GNUC__) || defined( __BORLANDC__ ) #define EXTERN_STRUCT struct #else #define EXTERN_STRUCT extern struct @@ -262,6 +262,7 @@ EXTERN void atom_string(t_atom *a, char *buf, unsigned int bufsize); EXTERN t_binbuf *binbuf_new(void); EXTERN void binbuf_free(t_binbuf *x); +EXTERN t_binbuf *binbuf_duplicate(t_binbuf *y); EXTERN void binbuf_text(t_binbuf *x, char *text, size_t size); EXTERN void binbuf_gettext(t_binbuf *x, char **bufp, int *lengthp); @@ -339,6 +340,7 @@ EXTERN void outlet_float(t_outlet *x, t_float f); EXTERN void outlet_symbol(t_outlet *x, t_symbol *s); EXTERN void outlet_list(t_outlet *x, t_symbol *s, int argc, t_atom *argv); EXTERN void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom *argv); +EXTERN t_symbol *outlet_getsymbol(t_outlet *x); EXTERN void outlet_free(t_outlet *x); EXTERN t_object *pd_checkobject(t_pd *x); @@ -580,15 +582,17 @@ EXTERN void c_addmess(t_method fn, t_symbol *sel, t_atomtype arg1, ...); #define typedmess pd_typedmess #define vmess pd_vmess -#ifdef MACOSX -#define cabs() smerdyakov(void) -#endif - /* A definition to help gui objects straddle 0.34-0.35 changes. If this is defined, there is a "te_xpix" field in objects, not a "te_xpos" as before: */ #define PD_USE_TE_XPIX +/* a test for NANs and denormals. Shouldn't be necessary on Mac but can't +test this just now. */ + +#define PD_BADFLOAT(f) ((((*(unsigned int*)&(f))&0x7f800000)==0) || \ + (((*(unsigned int*)&(f))&0x7f800000)==0x7f800000)) + #if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) } #endif diff --git a/pd/src/makefile.in b/pd/src/makefile.in index b7eb1104..f9204e78 100644 --- a/pd/src/makefile.in +++ b/pd/src/makefile.in @@ -12,6 +12,10 @@ GUINAME= @GUINAME@ INSTALL_PREFIX = @prefix@ GFLAGS = -DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\" +# there should be a better way to do this... +prefix = @prefix@ +MANDIR = @mandir@ + # ALSA compilation SOUND_ALSA = @alsa@ @@ -105,7 +109,7 @@ GOBJ = $(GSRC:.c=.o) # ------------------ targets ------------------------------------ # -.PHONY: pd gui externs +.PHONY: pd gui externs all all: $(PDEXEC) $(BIN_DIR)/pd-watchdog $(BIN_DIR)/$(GUINAME) $(BIN_DIR)/pdsend \ $(BIN_DIR)/pdreceive $(BIN_DIR)/pd.tk externs @@ -164,7 +168,9 @@ externs: cd ../extra/pique;make @EXTERNTARGET@ INSTDIR = $(DESTDIR)/$(INSTALL_PREFIX) -install: +MANINSTDIR = $(DESTDIR)/$(MANDIR) + +install: all install -d $(INSTDIR)/lib/pd/bin install $(BIN_DIR)/$(GUINAME) $(INSTDIR)/lib/pd/bin/$(GUINAME) install $(BIN_DIR)/pd-watchdog $(INSTDIR)/lib/pd/bin/pd-watchdog @@ -179,12 +185,13 @@ install: cp -r ../doc $(INSTDIR)/lib/pd/ install -d $(INSTDIR)/include install -m644 m_pd.h $(INSTDIR)/include/m_pd.h - gzip < ../man/pd.1 > $(INSTDIR)/man/man1/pd.1.gz - chmod 644 $(INSTDIR)/man/man1/pd.1.gz - gzip < ../man/pdsend.1 > $(INSTDIR)/man/man1/pdsend.1.gz - chmod 644 $(INSTDIR)/man/man1/pdsend.1.gz - gzip < ../man/pdreceive.1 > $(INSTDIR)/man/man1/pdreceive.1.gz - chmod 644 $(INSTDIR)/man/man1/pdreceive.1.gz + install -d $(MANINSTDIR)/man1 + gzip < ../man/pd.1 > $(MANINSTDIR)/man1/pd.1.gz + chmod 644 $(MANINSTDIR)/man1/pd.1.gz + gzip < ../man/pdsend.1 > $(MANINSTDIR)/man1/pdsend.1.gz + chmod 644 $(MANINSTDIR)/man1/pdsend.1.gz + gzip < ../man/pdreceive.1 > $(MANINSTDIR)/man1/pdreceive.1.gz + chmod 644 $(MANINSTDIR)/man1/pdreceive.1.gz local-clean: -rm -f ../obj/* $(BIN_DIR)/pd $(BIN_DIR)/$(GUINAME) $(BIN_DIR)/pdsend \ @@ -219,9 +226,9 @@ uninstall: -rm $(INSTDIR)/bin/pdsend -rm $(INSTDIR)/bin/pdreceive -rm $(INSTDIR)/include/m_pd.h - -rm $(INSTDIR)/man/man1/pd.1.gz - -rm $(INSTDIR)/man/man1/pdsend.1.gz - -rm $(INSTDIR)/man/man1/pdreceive.1.gz + -rm $(MANINSTDIR)/man/man1/pd.1.gz + -rm $(MANINSTDIR)/man/man1/pdsend.1.gz + -rm $(MANINSTDIR)/man/man1/pdreceive.1.gz include makefile.dependencies diff --git a/pd/src/makefile.nt.bad b/pd/src/makefile.nt.bad new file mode 100644 index 00000000..d45b72e0 --- /dev/null +++ b/pd/src/makefile.nt.bad @@ -0,0 +1,92 @@ +# Makefile for portaudio ASIO driver version of PD + +all: pd gui ..\bin\pd.tk + +VC = "C:\Program Files\Microsoft Visual Studio\VC98" +#VC="\Program Files\DevStudio\Vc" +INCLUDE = -I.\ -I..\Tcl\include -I$(VC)\include + +LDIR = $(VC)\lib + +LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel \ + /NODEFAULTLIB:uuid \ + $(LDIR)\libc.lib $(LDIR)\oldnames.lib $(LDIR)\kernel32.lib \ + $(LDIR)\wsock32.lib $(LDIR)\winmm.lib ..\bin\pthreadVC.lib + +GLIB = $(LIB) ..\lib\tcl83.lib ..\lib\tk83.lib +CFLAGS = /nologo /W3 /DNT /DPD /DPD_INTERNAL /DWIN32 /DWINDOWS /Ox +LFLAGS = /nologo + +SYSSRC = s_nt.c s_portaudio.c + +SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \ + g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \ + g_all_guis.c g_bang.c g_hdial.c g_hslider.c g_mycanvas.c g_numbox.c \ + g_toggle.c g_vdial.c g_vslider.c g_vumeter.c \ + m_pd.c m_class.c m_obj.c m_atom.c m_memory.c m_binbuf.c \ + m_conf.c m_glob.c m_sched.c \ + s_main.c s_inter.c s_unix.c s_file.c s_print.c \ + s_loader.c s_path.c s_entry.c \ + d_ugen.c d_ctl.c d_arithmetic.c d_osc.c d_filter.c d_dac.c d_misc.c \ + d_math.c d_fft.c d_mayer_fft.c d_fftroutine.c d_array.c d_global.c \ + d_delay.c d_resample.c \ + x_arithmetic.c x_connective.c x_interface.c x_midi.c x_misc.c \ + x_time.c x_acoustics.c x_net.c x_qlist.c x_gui.c d_soundfile.c \ + $(SYSSRC) + +SRCPA = pa_lib.c pa_trace.c pablio_pd.c ringbuffer_pd.c +SRCASIO = pa_asio.cpp + +ASIOLIB = $(LDIR)\user32.lib $(LDIR)\gdi32.lib $(LDIR)\winspool.lib $(LDIR)\comdlg32.lib \ +$(LDIR)\advapi32.lib $(LDIR)\shell32.lib $(LDIR)\ole32.lib $(LDIR)\oleaut32.lib $(LDIR)\uuid.lib \ +$(LDIR)\odbc32.lib $(LDIR)\odbccp32.lib ..\lib\asio\asiolib.lib + + +PAOBJ = pa_lib.obj pa_trace.obj pablio_pd.obj ringbuffer_pd.obj pa_asio.obj +OBJC = $(SRC:.c=.obj) $(PAOBJ) + +GSRC = t_main.c t_tkcmd.c + +GOBJ = $(GSRC:.c=.obj) +.PHONY: pd gui + +ALLCF = $(CFLAGS) $(INCLUDE) $(INCASIO) $(INCPA) /D_WINDOWS + +.c.obj: + cl /c $(ALLCF) /Tc$*.c + +pd: ..\bin\pd.exe + +gui: ..\bin\pdtcl.dll + +..\bin\pd.exe: s_entry.obj ..\bin\pd.lib + link $(LFLAGS) /out:..\bin\pd.exe /INCREMENTAL:NO s_entry.obj \ + ..\bin\pd.lib $(LIB) $(ASIOLIB) + +..\bin\pd.dll ..\bin\pd.lib: $(OBJC) $(OBJASIO) + link $(LFLAGS) /dll /export:sys_main /out:..\bin\pd.dll $(OBJC) \ + $(OBJASIO) $(LIB) $(ASIOLIB) + +..\bin\pdtcl.dll: t_tkcmd.obj + link $(LFLAGS) /dll /export:Pdtcl_Init /out:..\bin\pdtcl.dll \ + t_tkcmd.obj $(GLIB) + +..\bin\pd.tk: u_main.tk; copy u_main.tk ..\bin\pd.tk + +# explicit rules to compile portaudio sources: +pa_lib.obj: pa_lib.c + cl /c $(ALLCF) pa_lib.c +pa_trace.obj: pa_trace.c + cl /c $(ALLCF) pa_trace.c +pablio_pd.obj: pablio_pd.c + cl /c $(ALLCF) pablio_pd.c +ringbuffer_pd.obj: ringbuffer_pd.c + cl /c $(ALLCF) ringbuffer_pd.c +pa_asio.obj: pa_asio.cpp + cl /c $(ALLCF) pa_asio.cpp + +# the following should also clean up "bin" but it doesn't because "bin" holds +# precious stuff from elsewhere. +clean: + del *.obj + diff --git a/pd/src/notes.txt b/pd/src/notes.txt index 6a01dd0b..03a8728f 100644 --- a/pd/src/notes.txt +++ b/pd/src/notes.txt @@ -1,18 +1,34 @@ ----------------- dolist -------------------- -++portno wierdness in gcc 3 worked around (Burton) -non-power-of-2 channel counts in ASIO (Olaf Matthes) -Bug, David McCallum, Jul. 13 -- find last error crashes +done for 0.35: +bug fix: flipping canvases +bug fix: canvas coordinates saved correctly +signal lines fatter than control ones +number box labels, send&receive +rework [vh]dial +'make install' depending on Pd, etc +undo +fix symbol binding GUI problem +new expr object +test on p4s +undo paste and duplicate +fix flipped window resizing to move comments +---------------- dolist -------------------- +pddp doc -last-minute bug fixes: -add flag to select MIDI open to use select()? -check top-of-window problem in OSX -denormal protection +scheduler to do DSP computations even if no audio +hook to scheduler to let others get called for DSP I/O +figure out how to avoid "dac freeze" if nosound -doc: -fix readme file and recopy to web page (add to README in dist instructions) +try again to fix the font scene +look at zeros to IIR filters +compile pdsend, pdreceive for windows and document somehow +addcomma message to message +pasting should look at current mouse location problems: +number boxes should ignore non-numeric characters +messages & comments don't come up with text activated? +arrays of non-existent templates crash don't draw in/outlets on gui objects in graphs Alsa degradation after several hours running on soundblaster font size should depend on subpatch/abstraction @@ -22,9 +38,6 @@ missed Thomas's multi-dialog trick??? fix iemguis not to bash symbol names check what happens when going back and forth between graph-on-parent deal with spaces in iemgui labels and send/receive names -David McCallum, table crashes in 98? -font hack (pix@test.at, 30 Nov 2001 - perl -pi -e 's/-[*%a-z0-9-]*\*[*%a-z0-9-]*/fixed/' u_main.tk get rid of messages causing renaming; try to prevent patches closing themselves. Krzysztof's qlist_next reentrancy bug dac~/ adc~/ block~ incompatibility @@ -35,6 +48,7 @@ rfft~ loses nyquist bin -- see "to hell with it" comment in d_fft.c soundfile writing gets wrong sample rate; see /* lie */ in d_soundfile.c data: +doesn't redraw when changing draw commands? vget, vset traversal objects cursor to show (x, y) location better hit detection (getrect is too greedy) @@ -48,6 +62,7 @@ scalar hook to catch the mouse protect against "plots" going away while you drag on them features: +signal inlets with initialized values... Pd to open html help on windows/mac flag to hide array names ??? have a way to disambiguate externs from different libs??? @@ -56,7 +71,6 @@ if there's just one array, don't do stringent hit check. netsend separate thread netreceive (and netsend?) message to set port number delete-in-rectangle message to Pds -pasting should look at current mouse location "regular" numbers/symbols to do send/receive thing ala IEMGUI make selecting text grab keyboard focus think about x and y scale preservation when changing between graph and object @@ -112,6 +126,8 @@ pique~ and fiddle~ unification (notice pique filtering is different!) new message box look figure out what to do when "pd sym" conflicts with window title as in Pluton? +MAX compatibilty: +trigger 1 (on Pd, outputs 0; on Max?) LATER Hammerfall adapt to ALSA diff --git a/pd/src/s_linux.c b/pd/src/s_linux.c index 5c394674..54cdb978 100644 --- a/pd/src/s_linux.c +++ b/pd/src/s_linux.c @@ -2685,7 +2685,7 @@ void alsa_resync( void) } memset(alsa_buf, 0, sizeof(char) * alsa_samplewidth * DACBLKSIZE * linux_outchannels); - for (i = 0; i < 100; i++) + for (i = 0; i < 1000000; i++) { result = snd_pcm_writei(alsa_device.outhandle, alsa_buf, DACBLKSIZE); diff --git a/pd/src/s_mac.c b/pd/src/s_mac.c index a36f192a..9d3c1543 100644 --- a/pd/src/s_mac.c +++ b/pd/src/s_mac.c @@ -303,16 +303,37 @@ void sys_poll_midi(void) } } +#if defined(_POSIX_PRIORITY_SCHEDULING) || defined(_POSIX_MEMLOCK) +#include +#endif + void sys_set_priority(int higher) { +#ifdef _POSIX_PRIORITY_SCHEDULING + struct sched_param par; + int p1 ,p2, p3; + p1 = sched_get_priority_min(SCHED_FIFO); + p2 = sched_get_priority_max(SCHED_FIFO); + p3 = (higher ? p2 - 1 : p2 - 3); + par.sched_priority = p3; + if (sched_setscheduler(0,SCHED_FIFO,&par) != -1) + fprintf(stderr, "priority %d scheduling enabled.\n", p3); +#else /* no priority scheduling, so renice and wish for something better */ int retval; errno = 0; retval = setpriority(PRIO_PROCESS, 0, (higher? -20 : -19)); if (retval == -1 & errno != 0) { perror("setpriority"); - fprintf(stderr, "priority bost faled.\n"); + fprintf(stderr, "priority boost faled.\n"); } +#endif + +#ifdef _POSIX_MEMLOCK + if (mlockall(MCL_FUTURE) != -1) + fprintf(stderr, "memory locking enabled.\n"); +#endif + } void sys_listdevs(void ) diff --git a/pd/src/s_main.c b/pd/src/s_main.c index 3c0f4164..cb08960a 100644 --- a/pd/src/s_main.c +++ b/pd/src/s_main.c @@ -7,7 +7,7 @@ * 1311:forum::für::umläute:2001 */ -char pd_version[] = "Pd version 0.35\n"; +char pd_version[] = "Pd version 0.36 PRELIMINARY TEST 5\n"; char pd_compiletime[] = __TIME__; char pd_compiledate[] = __DATE__; diff --git a/pd/src/s_unix.c b/pd/src/s_unix.c index ee0ce160..85282f3b 100644 --- a/pd/src/s_unix.c +++ b/pd/src/s_unix.c @@ -412,15 +412,24 @@ void sys_pollmidiinqueue( void) comes in, as a result of our calling sys_poll_midi. We stick it on a timetag queue and dispatch it at the appropriate logical time. */ + void sys_midibytein(int portno, int byte) { + static int warned = 0; t_midiqelem *midiqelem; int newhead = midi_inhead +1; if (newhead == MIDIQSIZE) newhead = 0; /* if FIFO is full flush an element to make room */ if (newhead == midi_intail) - post("flush"), sys_dispatchnextmidiin(); + { + if (!warned) + { + post("warning: MIDI timing FIFO overflowed"); + warned = 1; + } + sys_dispatchnextmidiin(); + } midi_inqueue[midi_inhead].q_portno = portno; midi_inqueue[midi_inhead].q_onebyte = 1; midi_inqueue[midi_inhead].q_byte1 = byte; diff --git a/pd/src/t_tkcmd.c b/pd/src/t_tkcmd.c index c2abd846..3415691b 100644 --- a/pd/src/t_tkcmd.c +++ b/pd/src/t_tkcmd.c @@ -349,7 +349,7 @@ void pdgui_setname(char *s) int Pdtcl_Init(Tcl_Interp *interp) { - char *myvalue = Tcl_GetVar(interp, "argv", 0); + const char *myvalue = Tcl_GetVar(interp, "argv", 0); int myportno; if (myvalue && (myportno = atoi(myvalue)) > 1) pdgui_setsock(myportno); diff --git a/pd/src/u_main.tk b/pd/src/u_main.tk index a19b0951..da17b720 100644 --- a/pd/src/u_main.tk +++ b/pd/src/u_main.tk @@ -12,10 +12,6 @@ set pd_nt 0 # a new dialogbox was inserted, named: # "pdtk_iemgui_dialog -- dialog window for iem guis" # -# there are 2 new features: 1.) line-delete-protection in edit-menue -# -# 2.) there are all iem-guis in a seperated put-gui-menue -# # all this changes are labeled with #######iemlib########## if {$pd_nt == 1} { @@ -108,10 +104,9 @@ set untitled_number 1 set untitled_directory [pwd] set saveas_client doggy set pd_opendir $untitled_directory -############iemlib################## -# need it to know, if new or open file -set iem_new_open_flag "open" -############iemlib################## +set pd_undoaction no +set pd_redoaction no +set pd_undocanvas no ################ utility functions ######################### @@ -152,11 +147,6 @@ proc pdtk_fixwindowmenu {} { proc menu_new {} { global untitled_number global untitled_directory -############iemlib################## - global iem_new_open_flag - - set iem_new_open_flag "new" -############iemlib################## pd [concat pd filename Untitled-$untitled_number $untitled_directory \;] pd { #N canvas; @@ -170,11 +160,6 @@ proc menu_new {} { proc menu_open {} { global pd_opendir global pd_nt -############iemlib################## - global iem_new_open_flag - - set iem_new_open_flag "open" -############iemlib################## # workaround -- initialdir doesn't work on MACOSX yet --- if {$pd_nt == 2} { @@ -258,11 +243,6 @@ set help_directory $pd_guidir/doc proc menu_documentation {} { global help_directory global pd_nt -############iemlib################## - global iem_new_open_flag - - set iem_new_open_flag "open" -############iemlib################## if {$pd_nt == 2} { cd $help_directory @@ -301,11 +281,6 @@ proc menu_documentation {} { proc menu_doc_open {subdir basename} { global pd_guidir -############iemlib################## - global iem_new_open_flag - - set iem_new_open_flag "open" -############iemlib################## set dirname $pd_guidir/$subdir @@ -367,6 +342,24 @@ proc menu_close {name} { pd [concat $name menuclose \;] } +proc menu_undo {name} { + global pd_undoaction + global pd_redoaction + global pd_undocanvas + if {$name == $pd_undocanvas && $pd_undoaction != "no"} { + pd [concat $name undo \;] + } +} + +proc menu_redo {name} { + global pd_undoaction + global pd_redoaction + global pd_undocanvas + if {$name == $pd_undocanvas && $pd_redoaction != "no"} { + pd [concat $name redo \;] + } +} + proc menu_cut {name} { pd [concat $name cut \;] } @@ -452,12 +445,12 @@ proc menu_hslider {name accel} { pd [concat $name hslider $accel \;] } -proc menu_hdial {name accel} { - pd [concat $name hdial $accel \;] +proc menu_hradio {name accel} { + pd [concat $name hradio $accel \;] } -proc menu_vdial {name accel} { - pd [concat $name vdial $accel \;] +proc menu_vradio {name accel} { + pd [concat $name vradio $accel \;] } proc menu_vumeter {name accel} { @@ -468,11 +461,38 @@ proc menu_mycnv {name accel} { pd [concat $name mycnv $accel \;] } -proc menu_protectmode {name} { - pd [concat $name protectmode 0 \;] +############iemlib################## + +# correct edit menu, enabling or disabling undo/redo +# LATER also cut/copy/paste +proc menu_fixeditmenu {name} { + global pd_undoaction + global pd_redoaction + global pd_undocanvas +# puts stderr [concat menu_fixeditmenu $name $pd_undocanvas $pd_undoaction] + if {$name == $pd_undocanvas && $pd_undoaction != "no"} { + $name.m.edit.m entryconfigure "Undo*" -state normal \ + -label [concat "Undo " $pd_undoaction] + } else { + $name.m.edit.m entryconfigure "Undo*" -state disabled -label "Undo" + } + if {$name == $pd_undocanvas && $pd_redoaction != "no"} { + $name.m.edit.m entryconfigure "Redo" -state normal + } else { + $name.m.edit.m entryconfigure "Redo" -state disabled + } } -############iemlib################## +# message from Pd to update the currently available undo/redo action +proc pdtk_undomenu {name undoaction redoaction} { + global pd_undoaction + global pd_redoaction + global pd_undocanvas +# puts stderr [concat pdtk_undomenu $name $undoaction $redoaction] + set pd_undocanvas $name + set pd_undoaction $undoaction + set pd_redoaction $redoaction +} proc menu_windowparent {name} { pd [concat $name findparent \;] @@ -557,9 +577,8 @@ proc menu_findobject {canvas} { ############# pdtk_canvas_new -- create a new canvas ############### -proc pdtk_canvas_new {name width height geometry} { +proc pdtk_canvas_new {name width height geometry editable} { global pd_opendir - global iem_new_open_flag toplevel $name frame $name.m -relief raised -bd 2 @@ -580,7 +599,6 @@ proc pdtk_canvas_new {name width height geometry} { pack $name.c -side left -expand 1 -fill both wm minsize $name 1 1 wm geometry $name $geometry - # the file menu menubutton $name.m.file -text File -menu $name.m.file.m @@ -619,8 +637,15 @@ proc pdtk_canvas_new {name width height geometry} { # the edit menu menubutton $name.m.edit -text Edit -menu $name.m.edit.m pack $name.m.edit -side left - menu $name.m.edit.m + menu $name.m.edit.m -postcommand [concat menu_fixeditmenu $name] + $name.m.edit.m add command -label Undo -command [concat menu_undo $name] \ + -accelerator "Ctrl+z" + + $name.m.edit.m add command -label Redo -command [concat menu_redo $name] \ + -accelerator "Ctrl+Z" + + $name.m.edit.m add separator $name.m.edit.m add command -label Cut -command [concat menu_cut $name] \ -accelerator "Ctrl+x" @@ -661,16 +686,8 @@ proc pdtk_canvas_new {name width height geometry} { -command [concat menu_editmode $name] \ -accelerator "Ctrl+e" - - - $name.m.edit.m add checkbutton -label "Protect" \ - -indicatoron true -selectcolor grey85 \ - -command [concat menu_protectmode $name] \ - -accelerator "Ctrl+r" - - if { $iem_new_open_flag == "open" } { + if { $editable == 0 } { $name.m.edit.m entryconfigure "Edit mode" -indicatoron false } - $name.m.edit.m entryconfigure "Protect" -indicatoron false ############iemlib################## @@ -721,12 +738,12 @@ proc pdtk_canvas_new {name width height geometry} { -command [concat menu_hslider $name 0] \ -accelerator "Alt+h" - $name.m.put.m add command -label Vdial \ - -command [concat menu_vdial $name 0] \ + $name.m.put.m add command -label Vradio \ + -command [concat menu_vradio $name 0] \ -accelerator "Alt+d" - $name.m.put.m add command -label Hdial \ - -command [concat menu_hdial $name 0] \ + $name.m.put.m add command -label Hradio \ + -command [concat menu_hradio $name 0] \ -accelerator "Alt+i" $name.m.put.m add command -label VU \ @@ -824,7 +841,8 @@ proc pdtk_canvas_new {name width height geometry} { bind $name.c {pdtk_canvas_ctrlkey %W %K 1} bind $name.c {pdtk_canvas_altkey %W %K %A} # bind $name.c {puts stderr [concat mod1 %W %K %A]} - bind $name.c {pdtk_canvas_key %W %K %A} + bind $name.c {pdtk_canvas_key %W %K %A 0} + bind $name.c {pdtk_canvas_key %W %K %A 1} bind $name.c {pdtk_canvas_keyup %W %K %A} bind $name.c {pdtk_canvas_motion %W %x %y 0} bind $name.c {pdtk_canvas_motion %W %x %y 4} @@ -937,7 +955,7 @@ proc pdtk_canvas_mouseup {name x y b} { pdtk_canvas_checkgeometry [canvastosym $name] } -proc pdtk_canvas_key {name key iso} { +proc pdtk_canvas_key {name key iso shift} { # puts stderr [concat down key= $key iso= $iso] # .controls.switches.meterbutton configure -text $key # HACK for MAC OSX -- backspace seems different; I don't understand why. @@ -955,9 +973,9 @@ proc pdtk_canvas_key {name key iso} { } if {$iso != ""} { scan $iso %c keynum - pd [canvastosym $name] key 1 $keynum \; + pd [canvastosym $name] key 1 $keynum $shift\; } else { - pd [canvastosym $name] key 1 $key \; + pd [canvastosym $name] key 1 $key $shift\; } } @@ -980,8 +998,8 @@ proc pdtk_canvas_altkey {name key iso} { if {$key == "n" || $key == "N"} {menu_numbox $topname 1} if {$key == "v" || $key == "V"} {menu_vslider $topname 1} if {$key == "h" || $key == "H"} {menu_hslider $topname 1} - if {$key == "i" || $key == "I"} {menu_hdial $topname 1} - if {$key == "d" || $key == "D"} {menu_vdial $topname 1} + if {$key == "i" || $key == "I"} {menu_hradio $topname 1} + if {$key == "d" || $key == "D"} {menu_vradio $topname 1} if {$key == "u" || $key == "U"} {menu_vumeter $topname 1} if {$key == "c" || $key == "C"} {menu_mycnv $topname 1} ############iemlib################## @@ -1001,6 +1019,9 @@ proc pdtk_canvas_ctrlkey {name key shift} { if {$key == "s" || $key == "S"} { if {$shift == 1} {menu_saveas $topname} else {menu_save $topname} } + if {$key == "z" || $key == "Z"} { + if {$shift == 1} {menu_redo $topname} else {menu_undo $topname} + } if {$key == "w" || $key == "W"} {menu_close $topname} if {$key == "p" || $key == "P"} {menu_print $topname} if {$key == "x" || $key == "X"} {menu_cut $topname} @@ -1019,9 +1040,6 @@ proc pdtk_canvas_ctrlkey {name key shift} { if {$key == "slash"} {menu_audio 1} if {$key == "period"} {menu_audio 0} if {$key == "e" || $key == "E"} {menu_editmode $topname} -############iemlib################## - if {$key == "r" || $key == "R"} {menu_protectmode $topname} -############iemlib################## } proc pdtk_canvas_motion {name x y mods} { @@ -1155,13 +1173,65 @@ proc pdtk_canvas_dofont {name initsize} { ############ pdtk_gatom_dialog -- run a gatom dialog ######### -set gatomwidth 0 -set gatomlo 0 -set gatomhi 0 +# see graph_apply, etc., for comments about handling variable names here... + +proc gatom_escape {sym} { + if {[string length $sym] == 0} { + set ret "-" +# puts stderr [concat escape1 $sym $ret] + } else { + if {[string equal -length 1 $sym "-"]} { + set ret [string replace $sym 0 0 "--"] +# puts stderr [concat escape $sym $ret] + } else { + set ret $sym +# puts stderr [concat escape $sym "no change"] + } + } + concat $ret +} + +proc gatom_unescape {sym} { + if {[string equal -length 1 $sym "-"]} { + set ret [string replace $sym 0 0 ""] +# puts stderr [concat unescape $sym $ret] + } else { + set ret $sym +# puts stderr [concat unescape $sym "no change"] + } + concat $ret +} + +proc dogatom_apply {id} { + set vid [string trimleft $id .] + + set var_gatomwidth [concat gatomwidth_$vid] + global $var_gatomwidth + set var_gatomlo [concat gatomlo_$vid] + global $var_gatomlo + set var_gatomhi [concat gatomhi_$vid] + global $var_gatomhi + set var_gatomwherelabel [concat gatomwherelabel_$vid] + global $var_gatomwherelabel + set var_gatomlabel [concat gatomlabel_$vid] + global $var_gatomlabel + set var_gatomsymfrom [concat gatomsymfrom_$vid] + global $var_gatomsymfrom + set var_gatomsymto [concat gatomsymto_$vid] + global $var_gatomsymto + +# set cmd [concat $id param $gatomwidth $gatomlo $gatomhi \;] + + set cmd [concat $id param \ + [eval concat $$var_gatomwidth] \ + [eval concat $$var_gatomlo] \ + [eval concat $$var_gatomhi] \ + [eval gatom_escape $$var_gatomlabel] \ + [eval concat $$var_gatomwherelabel] \ + [eval gatom_escape $$var_gatomsymfrom] \ + [eval gatom_escape $$var_gatomsymto] \ + \;] -proc dogatom_apply {name} { - global gatomwidth gatomlo gatomhi - set cmd [concat $name param $gatomwidth $gatomlo $gatomhi \;] # puts stderr $cmd pd $cmd } @@ -1177,50 +1247,117 @@ proc dogatom_ok {name} { dogatom_cancel $name } -proc pdtk_gatom_dialog {name initwidth initlo inithi} { - - global gatomwidth gatomlo gatomhi - set gatomwidth $initwidth - set gatomlo $initlo - set gatomhi $inithi - - toplevel $name - wm title $name {Atom} - wm protocol $name WM_DELETE_WINDOW [concat dogatom_cancel $name] +proc pdtk_gatom_dialog {id initwidth initlo inithi \ + wherelabel label symfrom symto} { - frame $name.buttonframe - pack $name.buttonframe -side bottom -fill x -pady 2m - button $name.buttonframe.cancel -text {Cancel}\ - -command "dogatom_cancel $name" - button $name.buttonframe.ok -text {Apply}\ - -command "dogatom_apply $name" - pack $name.buttonframe.cancel -side left -expand 1 - pack $name.buttonframe.ok -side left -expand 1 - - frame $name.paramhi - pack $name.paramhi -side bottom - label $name.paramhi.entryname -text "upper limit" - entry $name.paramhi.entry -textvariable gatomhi -width 8 - pack $name.paramhi.entryname $name.paramhi.entry -side left + set vid [string trimleft $id .] + + set var_gatomwidth [concat gatomwidth_$vid] + global $var_gatomwidth + set var_gatomlo [concat gatomlo_$vid] + global $var_gatomlo + set var_gatomhi [concat gatomhi_$vid] + global $var_gatomhi + set var_gatomwherelabel [concat gatomwherelabel_$vid] + global $var_gatomwherelabel + set var_gatomlabel [concat gatomlabel_$vid] + global $var_gatomlabel + set var_gatomsymfrom [concat gatomsymfrom_$vid] + global $var_gatomsymfrom + set var_gatomsymto [concat gatomsymto_$vid] + global $var_gatomsymto + + set $var_gatomwidth $initwidth + set $var_gatomlo $initlo + set $var_gatomhi $inithi + set $var_gatomwherelabel $wherelabel + set $var_gatomlabel [gatom_unescape $label] + set $var_gatomsymfrom [gatom_unescape $symfrom] + set $var_gatomsymto [gatom_unescape $symto] + + toplevel $id + wm title $id {Atom} + wm protocol $id WM_DELETE_WINDOW [concat dogatom_cancel $id] + + frame $id.buttonframe + pack $id.buttonframe -side bottom -fill x -pady 2m + button $id.buttonframe.cancel -text {Cancel}\ + -command "dogatom_cancel $id" + button $id.buttonframe.apply -text {Apply}\ + -command "dogatom_apply $id" + button $id.buttonframe.ok -text {OK}\ + -command "dogatom_ok $id" + pack $id.buttonframe.cancel -side left -expand 1 + pack $id.buttonframe.apply -side left -expand 1 + pack $id.buttonframe.ok -side left -expand 1 + + frame $id.paramsymto + pack $id.paramsymto -side bottom + label $id.paramsymto.entryname -text {send symbol} + entry $id.paramsymto.entry -textvariable $var_gatomsymto -width 20 + pack $id.paramsymto.entryname $id.paramsymto.entry -side left + + frame $id.paramsymfrom + pack $id.paramsymfrom -side bottom + label $id.paramsymfrom.entryname -text {receive symbol} + entry $id.paramsymfrom.entry -textvariable $var_gatomsymfrom -width 20 + pack $id.paramsymfrom.entryname $id.paramsymfrom.entry -side left + + frame $id.radio + pack $id.radio -side bottom + label $id.radio.label -text {show label on:} + frame $id.radio.l + frame $id.radio.r + pack $id.radio.label -side top + pack $id.radio.l $id.radio.r -side left + radiobutton $id.radio.l.radio0 -value 0 \ + -variable $var_gatomwherelabel \ + -text "left" + radiobutton $id.radio.l.radio1 -value 1 \ + -variable $var_gatomwherelabel \ + -text "right" + radiobutton $id.radio.r.radio2 -value 2 \ + -variable $var_gatomwherelabel \ + -text "top" + radiobutton $id.radio.r.radio3 -value 3 \ + -variable $var_gatomwherelabel \ + -text "bottom" + pack $id.radio.l.radio0 $id.radio.l.radio1 -side top -anchor w + pack $id.radio.r.radio2 $id.radio.r.radio3 -side top -anchor w + + + frame $id.paramlabel + pack $id.paramlabel -side bottom + label $id.paramlabel.entryname -text label + entry $id.paramlabel.entry -textvariable $var_gatomlabel -width 20 + pack $id.paramlabel.entryname $id.paramlabel.entry -side left + + frame $id.paramhi + pack $id.paramhi -side bottom + label $id.paramhi.entryname -text "upper limit" + entry $id.paramhi.entry -textvariable $var_gatomhi -width 8 + pack $id.paramhi.entryname $id.paramhi.entry -side left + + frame $id.paramlo + pack $id.paramlo -side bottom + label $id.paramlo.entryname -text "lower limit" + entry $id.paramlo.entry -textvariable $var_gatomlo -width 8 + pack $id.paramlo.entryname $id.paramlo.entry -side left + + frame $id.params + pack $id.params -side bottom + label $id.params.entryname -text width + entry $id.params.entry -textvariable $var_gatomwidth -width 4 + pack $id.params.entryname $id.params.entry -side left - frame $name.paramlo - pack $name.paramlo -side bottom - label $name.paramlo.entryname -text "lower limit" - entry $name.paramlo.entry -textvariable gatomlo -width 8 - pack $name.paramlo.entryname $name.paramlo.entry -side left - frame $name.params - pack $name.params -side bottom - label $name.params.entryname -text width - entry $name.params.entry -textvariable gatomwidth -width 4 - pack $name.params.entryname $name.params.entry -side left - bind $name.paramhi.entry [concat dogatom_ok $name] - bind $name.paramlo.entry [concat dogatom_ok $name] - bind $name.params.entry [concat dogatom_ok $name] - $name.params.entry select from 0 - $name.params.entry select adjust end - focus $name.params.entry + bind $id.paramhi.entry [concat dogatom_ok $id] + bind $id.paramlo.entry [concat dogatom_ok $id] + bind $id.params.entry [concat dogatom_ok $id] + $id.params.entry select from 0 + $id.params.entry select adjust end + focus $id.params.entry } ############ pdtk_canvas_popup -- popup menu for canvas ######### @@ -2340,14 +2477,6 @@ proc pdtk_canvas_editval {name value} { $name.m.edit.m entryconfigure "Edit mode" -indicatoron false } } - -proc pdtk_canvas_protectval {name value} { - if { $value } { - $name.m.edit.m entryconfigure "Protect" -indicatoron true - } else { - $name.m.edit.m entryconfigure "Protect" -indicatoron false - } -} #####################iemlib####################### ############ pdtk_text_new -- create a new text object #2########### diff --git a/pd/src/u_main.tk.test b/pd/src/u_main.tk.test new file mode 100644 index 00000000..fc32a321 --- /dev/null +++ b/pd/src/u_main.tk.test @@ -0,0 +1,2686 @@ +set pd_nt 0 +# (The above is 0 for unix, 1 for microsoft, and 2 for Mac OSX. The first +# line is automatically munged by the relevant makefiles.) + +# Copyright (c) 1997-1999 Miller Puckette. +# For information on usage and redistribution, and for a DISCLAIMER OF ALL +# WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +# changed by Thomas Musil 09.2001 +# between "pdtk_graph_dialog -- dialog window for graphs" +# and "pdtk_array_dialog -- dialog window for arrays" +# a new dialogbox was inserted, named: +# "pdtk_iemgui_dialog -- dialog window for iem guis" +# +# there are 2 new features: 1.) line-delete-protection in edit-menue +# +# 2.) there are all iem-guis in a seperated put-gui-menue +# +# all this changes are labeled with #######iemlib########## + +if {$pd_nt == 1} { + global pd_guidir + set pd_gui2 [string range $argv0 0 [expr [string last \\ $argv0 ] - 1]] + regsub -all \\\\ $pd_gui2 / pd_gui3 + set pd_guidir $pd_gui3/.. + load $pd_guidir/bin/pdtcl +} + +if {$pd_nt == 2} { + global pd_guidir + set pd_gui2 [string range $argv0 0 [expr [string last / $argv0 ] - 1]] + set pd_guidir $pd_gui2/.. + load $pd_guidir/bin/pdtcl +} + +# it's unfortunate but we seem to have to turn off global bindings +# for Text objects to get control-s and control-t to do what we want for +# "text" dialogs below. Also we have to get rid of tab's changing the focus. + +bind all "" +bind all "" +bind Text {} +bind Text {} +# puts stderr [bind all] + +################## set up main window ######################### +frame .mbar -relief raised -bd 2 +canvas .dummy -height 1c -width 1c +frame .controls +pack .mbar .controls .dummy -side top -fill x +menubutton .mbar.file -text File -menu .mbar.file.menu +menubutton .mbar.find -text Find -menu .mbar.find.menu +menubutton .mbar.windows -text Windows -menu .mbar.windows.menu +menubutton .mbar.audio -text Audio -menu .mbar.audio.menu +menubutton .mbar.help -text Help -menu .mbar.help.menu +pack .mbar.file .mbar.find .mbar.windows .mbar.audio -side left +pack .mbar.help -side right +menu .mbar.file.menu +menu .mbar.find.menu +menu .mbar.windows.menu -postcommand [concat pdtk_fixwindowmenu] +menu .mbar.audio.menu +menu .mbar.help.menu + +set ctrls_audio_on 0 +set ctrls_meter_on 0 +set ctrls_inlevel 0 +set ctrls_outlevel 0 + +frame .controls.switches +checkbutton .controls.switches.audiobutton -text {compute audio} \ + -variable ctrls_audio_on \ + -anchor w \ + -command {pd [concat pd dsp $ctrls_audio_on \;]} + +checkbutton .controls.switches.meterbutton -text {peak meters} \ + -variable ctrls_meter_on \ + -anchor w \ + -command {pd [concat pd meters $ctrls_meter_on \;]} + +pack .controls.switches.meterbutton .controls.switches.audiobutton -side left + +frame .controls.in +label .controls.in.label -text IN +entry .controls.in.level -textvariable ctrls_inlevel -width 3 +button .controls.in.clip -text {CLIP} -state disabled +pack .controls.in.label .controls.in.level .controls.in.clip -side top + +frame .controls.out +label .controls.out.label -text OUT +entry .controls.out.level -textvariable ctrls_outlevel -width 3 +button .controls.out.clip -text {CLIP} -state disabled +pack .controls.out.label .controls.out.level .controls.out.clip -side top + +button .controls.dio -text "DIO\nerrors" \ + -command {pd [concat pd audiostatus \;]} + +pack .controls.switches -side bottom +pack .controls.in .controls.out -side left +pack .controls.dio -side right + +bind . {pdtk_pd_ctrlkey %W %K 0} +bind . {pdtk_pd_ctrlkey %W %K 1} + + +############### set up global variables ################################ + +set untitled_number 1 +set untitled_directory [pwd] +set saveas_client doggy +set pd_opendir $untitled_directory +############iemlib################## +# need it to know, if new or open file +set iem_new_open_flag "open" +############iemlib################## + +################ utility functions ######################### + +proc pdtk_enquote {x} { + set foo [string map {"," "" ";" "" \" ""} $x] + set foo2 [string map {" " "\\ "} $foo] + concat $foo2 +} + +proc pdtk_debug {x} { + tk_messageBox -message $x -type ok +} + +proc pdtk_watchdog {} { + pd [concat pd ping \;] + after 2000 {pdtk_watchdog} +} + +proc pdtk_check {x message} { + set answer [tk_messageBox \-message $x \-type yesno \-icon question] + switch $answer { + yes {pd $message} } +# no {tk_messageBox \-message "cancelled" \-type ok} +} + +set menu_windowlist {} + +proc pdtk_fixwindowmenu {} { + global menu_windowlist + .mbar.windows.menu delete 0 end + foreach i $menu_windowlist { + .mbar.windows.menu add command -label [lindex $i 0] \ + -command [concat menu_domenuwindow [lindex $i 1]] + } +} + +############### the "New" menu command ######################## +proc menu_new {} { + global untitled_number + global untitled_directory +############iemlib################## + global iem_new_open_flag + + set iem_new_open_flag "new" +############iemlib################## + pd [concat pd filename Untitled-$untitled_number $untitled_directory \;] + pd { + #N canvas; + #X pop 1; + } + set untitled_number [expr $untitled_number + 1] +} + +################## the "Open" menu command ######################### + +proc menu_open {} { + global pd_opendir + global pd_nt +############iemlib################## + global iem_new_open_flag + + set iem_new_open_flag "open" +############iemlib################## + +# workaround -- initialdir doesn't work on MACOSX yet --- + if {$pd_nt == 2} { + cd $pd_opendir + set filename [tk_getOpenFile -defaultextension .pd \ + -filetypes { {{pd files} {.pd}} {{max files} {.pat}}} ] + } else { + set filename [tk_getOpenFile -defaultextension .pd \ + -filetypes { {{pd files} {.pd}} {{max files} {.pat}}} \ + -initialdir $pd_opendir] + } +# puts stderr $filename + if {$filename != ""} { + set directory [string range $filename 0 \ + [expr [string last / $filename ] - 1]] + set pd_opendir $directory + set basename [string range $filename \ + [expr [string last / $filename ] + 1] end] + +# pd_debug [concat file $filename base $basename dir $directory] + + pd [concat pd open [pdtk_enquote $basename] \ + [pdtk_enquote $directory]\;] + } +} + +################## the "Message" menu command ######################### +proc menu_send {} { + toplevel .sendpanel + entry .sendpanel.entry -textvariable send_textvariable + pack .sendpanel.entry -side bottom -fill both -ipadx 100 + .sendpanel.entry select from 0 + .sendpanel.entry select adjust end + bind .sendpanel.entry { + pd [concat $send_textvariable \;] + after 50 {destroy .sendpanel} + } + focus .sendpanel.entry +} + +################## the "Quit" menu command ######################### +proc menu_really_quit {} {pd {pd quit;}} + +proc menu_quit {} {pdtk_check {Really quit?} {pd quit;}} + +######### the "Pd" menu command, which puts the Pd window on top ######## +proc menu_pop_pd {} {raise .} + +######### the "audio" menu command ############### +proc menu_audio {flag} {pd [concat pd dsp $flag \;]} + +######### the "documentation" menu command ############### + +set doc_number 1 + +proc menu_opentext {filename} { + global doc_number + global pd_guidir + global pd_myversion + set name [format ".help%d" $doc_number] + toplevel $name + text $name.text -relief raised -bd 2 -font fixed \ + -yscrollcommand "$name.scroll set" -background white + scrollbar $name.scroll -command "$name.text yview" + pack $name.scroll -side right -fill y + pack $name.text -side left -fill both -expand 1 + + set f [open $filename] + while {![eof $f]} { + set bigstring [read $f 1000] + regsub -all PD_BASEDIR $bigstring $pd_guidir bigstring2 + regsub -all PD_VERSION $bigstring2 $pd_myversion bigstring3 + $name.text insert end $bigstring3 + } + close $f + set doc_number [expr $doc_number + 1] +} + +set help_directory $pd_guidir/doc + +proc menu_documentation {} { + global help_directory + global pd_nt +############iemlib################## + global iem_new_open_flag + + set iem_new_open_flag "open" +############iemlib################## + + if {$pd_nt == 2} { + cd $help_directory + set filename [tk_getOpenFile -defaultextension .pd \ + -filetypes { {{documentation} {.pd .txt .htm}} } ] + } else { + set filename [tk_getOpenFile -defaultextension .pd \ + -filetypes { {{documentation} {.pd .txt .htm}} } \ + -initialdir $help_directory] + } + + if {$filename != ""} { + if {[string first .txt $filename] >= 0} { + menu_opentext $filename + } elseif {[string first .htm $filename] >= 0} { + if {$pd_nt == 0} { +#I wish I could get this to run in the background; the "&" doesn't do it: + exec sh -c \ + [format "mozilla file:%s || netscape file:%s &\n" \ + $filename $filename] + } else { + tk_messageBox -message \ + {sorry -- can't open htm files yet; open this manually} \ + -type ok + } + } else { + set help_directory [string range $filename 0 \ + [expr [string last / $filename ] - 1]] + set basename [string range $filename \ + [expr [string last / $filename ] + 1] end] + pd [concat pd open [pdtk_enquote $basename] \ + [pdtk_enquote $help_directory] \;] + } + } +} + +proc menu_doc_open {subdir basename} { + global pd_guidir +############iemlib################## + global iem_new_open_flag + + set iem_new_open_flag "open" +############iemlib################## + + set dirname $pd_guidir/$subdir + + if {[string first .txt $basename] >= 0} { + menu_opentext $dirname/$basename + } else { + pd [concat pd open [pdtk_enquote $basename] \ + [pdtk_enquote $dirname] \;] + } +} + +#################### the "File" menu for the Pd window ############## +.mbar.file.menu add command -label New -command {menu_new} \ + -accelerator "Ctrl+n" +.mbar.file.menu add command -label Open -command {menu_open} \ + -accelerator "Ctrl+o" +.mbar.file.menu add command -label Message -command {menu_send} \ + -accelerator "Ctrl+m" +.mbar.file.menu add separator +.mbar.file.menu add command -label Quit -command {menu_quit} \ + -accelerator "Ctrl+q" + +#################### the "Find" menu for the Pd window ############## +.mbar.find.menu add command -label {last error?} -command {menu_finderror} + +#################### the "Audio" menu for the Pd window ############## +.mbar.audio.menu add command -label On -accelerator "Ctrl+/" \ + -command {menu_audio 1} +.mbar.audio.menu add command -label Off -accelerator "Ctrl+." \ + -command {menu_audio 0} + +#################### the "Help" menu for the Pd window ############## +.mbar.help.menu add command -label {About Pd} \ + -command {menu_doc_open doc/1.manual 1.introduction.txt} +.mbar.help.menu add command -label {Test Audio and MIDI} \ + -command {menu_doc_open doc/7.stuff/tools testtone.pd} +.mbar.help.menu add command -label {Load Meter} \ + -command {menu_doc_open doc/7.stuff/tools load-meter.pd} +.mbar.help.menu add command -label {Pure Documentation...} \ + -command {menu_documentation} + +########### functions for menu functions on document windows ######## + +proc menu_save {name} { + pdtk_canvas_checkgeometry $name + pd [concat $name menusave \;] +} + +proc menu_saveas {name} { + pdtk_canvas_checkgeometry $name + pd [concat $name menusaveas \;] +} + +proc menu_print {name} { + $name.c postscript -file x.ps +} + +proc menu_close {name} { + pd [concat $name menuclose \;] +} + +proc menu_cut {name} { + pd [concat $name cut \;] +} + +proc menu_copy {name} { + pd [concat $name copy \;] +} + +proc menu_paste {name} { + pd [concat $name paste \;] +} + +proc menu_duplicate {name} { + pd [concat $name duplicate \;] +} + +proc menu_selectall {name} { + pd [concat $name selectall \;] +} + +proc menu_texteditor {name} { + pd [concat $name texteditor \;] +} + +proc menu_font {name} { + pd [concat $name menufont \;] +} + +proc menu_tidyup {name} { + pd [concat $name tidy \;] +} + +proc menu_editmode {name} { + pd [concat $name editmode 0 \;] +} + +proc menu_object {name accel} { + pd [concat $name obj $accel \;] +} + +proc menu_message {name accel} { + pd [concat $name msg $accel \;] +} + +proc menu_floatatom {name accel} { + pd [concat $name floatatom $accel \;] +} + +proc menu_symbolatom {name accel} { + pd [concat $name symbolatom $accel \;] +} + +proc menu_comment {name accel} { + pd [concat $name text $accel \;] +} + +proc menu_graph {name} { + pd [concat $name graph \;] +} + +proc menu_array {name} { + pd [concat $name menuarray \;] +} + +############iemlib################## +proc menu_bng {name accel} { + pd [concat $name bng $accel \;] +} + +proc menu_toggle {name accel} { + pd [concat $name toggle $accel \;] +} + +proc menu_numbox {name accel} { + pd [concat $name numbox $accel \;] +} + +proc menu_vslider {name accel} { + pd [concat $name vslider $accel \;] +} + +proc menu_hslider {name accel} { + pd [concat $name hslider $accel \;] +} + +proc menu_hdial {name accel} { + pd [concat $name hdial $accel \;] +} + +proc menu_vdial {name accel} { + pd [concat $name vdial $accel \;] +} + +proc menu_vumeter {name accel} { + pd [concat $name vumeter $accel \;] +} + +proc menu_mycnv {name accel} { + pd [concat $name mycnv $accel \;] +} + +proc menu_protectmode {name} { + pd [concat $name protectmode 0 \;] +} + +############iemlib################## + +proc menu_windowparent {name} { + pd [concat $name findparent \;] +} + +proc menu_findagain {name} { + pd [concat $name findagain \;] +} + +proc menu_finderror {} { + pd [concat pd finderror \;] +} + +proc menu_domenuwindow {i} { + raise $i +} + +proc menu_fixwindowmenu {name} { + global menu_windowlist + $name.m.windows.m add command + $name.m.windows.m delete 4 end + foreach i $menu_windowlist { + $name.m.windows.m add command -label [lindex $i 0] \ + -command [concat menu_domenuwindow [lindex $i 1]] + } +} + +################## the "find" menu item ################### + +set find_canvas nobody +set find_string "" +set find_count 1 + +proc find_apply {name} { + global find_string + global find_canvas + regsub -all \; $find_string " _semi_ " find_string2 + regsub -all \, $find_string2 " _comma_ " find_string3 +# puts stderr [concat $find_canvas find $find_string3 \ +# \;] + pd [concat $find_canvas find $find_string3 \ + \;] + after 50 destroy $name +} + +proc find_cancel {name} { + after 50 destroy $name +} + +proc menu_findobject {canvas} { + global find_string + global find_canvas + global find_count + + set name [format ".find%d" $find_count] + set find_count [expr $find_count + 1] + + set find_canvas $canvas + + toplevel $name + + label $name.label -text {find...} + pack $name.label -side top + + entry $name.entry -textvariable find_string + pack $name.entry -side top + + frame $name.buttonframe + pack $name.buttonframe -side bottom -fill x -pady 2m + button $name.buttonframe.cancel -text {Cancel}\ + -command "find_cancel $name" + button $name.buttonframe.ok -text {OK}\ + -command "find_apply $name" + pack $name.buttonframe.cancel -side left -expand 1 + pack $name.buttonframe.ok -side left -expand 1 + + $name.entry select from 0 + $name.entry select adjust end + bind $name.entry [ concat find_apply $name] + focus $name.entry +} + + +############# pdtk_canvas_new -- create a new canvas ############### +proc pdtk_canvas_new {name width height geometry} { + global pd_opendir + global iem_new_open_flag + + toplevel $name + frame $name.m -relief raised -bd 2 +# puts stderr [concat geometry: $geometry] + wm geometry $name $geometry + canvas $name.c -width $width -height $height -background white \ + -yscrollcommand "$name.scrollvert set" \ + -xscrollcommand "$name.scrollhort set" \ + -scrollregion [concat 0 0 $width $height] + + scrollbar $name.scrollvert -command "$name.c yview" + scrollbar $name.scrollhort -command "$name.c xview" \ + -orient horizontal + + pack $name.m -side top -fill x + pack $name.scrollhort -side bottom -fill x + pack $name.scrollvert -side right -fill y + pack $name.c -side left -expand 1 -fill both + wm minsize $name 1 1 + wm geometry $name $geometry + +# the file menu + + menubutton $name.m.file -text File -menu $name.m.file.m + pack $name.m.file -side left + menu $name.m.file.m + + $name.m.file.m add command -label New -command {menu_new} \ + -accelerator "Ctrl+n" + + $name.m.file.m add command -label Open -command {menu_open} \ + -accelerator "Ctrl+o" + + $name.m.file.m add command -label Message -command {menu_send} \ + -accelerator "Ctrl+m" + + $name.m.file.m add separator + $name.m.file.m add command -label Save -command [concat menu_save $name] \ + -accelerator "Ctrl+s" + + $name.m.file.m add command -label Close \ + -command [concat menu_close $name] \ + -accelerator "Ctrl+w" + + $name.m.file.m add command -label "Save as..." \ + -command [concat menu_saveas $name] \ + -accelerator "Ctrl+S" + + $name.m.file.m add command -label Print -command [concat menu_print $name] \ + -accelerator "Ctrl+p" + + $name.m.file.m add separator + + $name.m.file.m add command -label Quit -command {menu_quit} \ + -accelerator "Ctrl+q" + +# the edit menu + menubutton $name.m.edit -text Edit -menu $name.m.edit.m + pack $name.m.edit -side left + menu $name.m.edit.m + + + $name.m.edit.m add command -label Cut -command [concat menu_cut $name] \ + -accelerator "Ctrl+x" + + $name.m.edit.m add command -label Copy -command [concat menu_copy $name] \ + -accelerator "Ctrl+c" + + $name.m.edit.m add command -label Paste \ + -command [concat menu_paste $name] \ + -accelerator "Ctrl+v" + + $name.m.edit.m add command -label Duplicate \ + -command [concat menu_duplicate $name] \ + -accelerator "Ctrl+d" + + $name.m.edit.m add command -label {Select all} \ + -command [concat menu_selectall $name] \ + -accelerator "Ctrl+a" + + $name.m.edit.m add command -label {Text Editor} \ + -command [concat menu_texteditor $name] \ + -accelerator "Ctrl+t" + + $name.m.edit.m add command -label Font \ + -command [concat menu_font $name] + + $name.m.edit.m add command -label {Tidy Up} \ + -command [concat menu_tidyup $name] + + $name.m.edit.m add separator + +############iemlib################## +# instead of "red = #BC3C60" we take "grey85", so there is no difference, +# if widget is selected or not. + + $name.m.edit.m add checkbutton -label "Edit mode" \ + -indicatoron true -selectcolor grey85 \ + -command [concat menu_editmode $name] \ + -accelerator "Ctrl+e" + + + + $name.m.edit.m add checkbutton -label "Protect" \ + -indicatoron true -selectcolor grey85 \ + -command [concat menu_protectmode $name] \ + -accelerator "Ctrl+r" + + if { $iem_new_open_flag == "open" } { + $name.m.edit.m entryconfigure "Edit mode" -indicatoron false } + $name.m.edit.m entryconfigure "Protect" -indicatoron false + +############iemlib################## + +# the put menu + menubutton $name.m.put -text Put -menu $name.m.put.m + pack $name.m.put -side left + menu $name.m.put.m + + $name.m.put.m add command -label Object \ + -command [concat menu_object $name 0] \ + -accelerator "Ctrl+1" + + $name.m.put.m add command -label Message \ + -command [concat menu_message $name 0] \ + -accelerator "Ctrl+2" + + $name.m.put.m add command -label Number \ + -command [concat menu_floatatom $name 0] \ + -accelerator "Ctrl+3" + + $name.m.put.m add command -label Symbol \ + -command [concat menu_symbolatom $name 0] \ + -accelerator "Ctrl+4" + + $name.m.put.m add command -label Comment \ + -command [concat menu_comment $name 0] \ + -accelerator "Ctrl+5" + +############iemlib################## + + $name.m.put.m add command -label Bang \ + -command [concat menu_bng $name 0] \ + -accelerator "Alt+b" + + $name.m.put.m add command -label Toggle \ + -command [concat menu_toggle $name 0] \ + -accelerator "Alt+t" + + $name.m.put.m add command -label Number2 \ + -command [concat menu_numbox $name 0] \ + -accelerator "Alt+n" + + $name.m.put.m add command -label Vslider \ + -command [concat menu_vslider $name 0] \ + -accelerator "Alt+v" + + $name.m.put.m add command -label Hslider \ + -command [concat menu_hslider $name 0] \ + -accelerator "Alt+h" + + $name.m.put.m add command -label Vdial \ + -command [concat menu_vdial $name 0] \ + -accelerator "Alt+d" + + $name.m.put.m add command -label Hdial \ + -command [concat menu_hdial $name 0] \ + -accelerator "Alt+i" + + $name.m.put.m add command -label VU \ + -command [concat menu_vumeter $name 0] \ + -accelerator "Alt+u" + + $name.m.put.m add command -label Canvas \ + -command [concat menu_mycnv $name 0] \ + -accelerator "Alt+c" + +############iemlib################## + + $name.m.put.m add command -label Graph \ + -command [concat menu_graph $name] + + $name.m.put.m add command -label Array \ + -command [concat menu_array $name] + + + +# the find menu + menubutton $name.m.find -text Find -menu $name.m.find.m + pack $name.m.find -side left + menu $name.m.find.m + $name.m.find.m add command -label {Find...} -accelerator "Ctrl+f" \ + -command [concat menu_findobject $name] + $name.m.find.m add command -label {Find Again} -accelerator "Ctrl+g" \ + -command [concat menu_findagain $name] + $name.m.find.m add command -label {Find last error} \ + -command [concat menu_finderror] + +# the window menu + menubutton $name.m.windows -text Windows -menu $name.m.windows.m + pack $name.m.windows -side left + menu $name.m.windows.m -postcommand [concat menu_fixwindowmenu $name] + $name.m.windows.m add command -label {parent window}\ + -command [concat menu_windowparent $name] + $name.m.windows.m add command -label {Pd window} -command menu_pop_pd + $name.m.windows.m add separator + +# the audio menu + menubutton $name.m.audio -text Audio -menu $name.m.audio.m + pack $name.m.audio -side left + menu $name.m.audio.m + $name.m.audio.m add command -label On -accelerator "Ctrl+/" \ + -command {menu_audio 1} + $name.m.audio.m add command -label Off -accelerator "Ctrl+." \ + -command {menu_audio 0} + +# the help menu + menubutton $name.m.help -text Help -menu $name.m.help.m + pack $name.m.help -side right + menu $name.m.help.m + $name.m.help.m add command -label {Getting Started} \ + -command {menu_doc_open doc/1.manual 1.introduction.txt} + $name.m.help.m add command -label {Test Audio and MIDI} \ + -command {menu_doc_open doc/7.stuff/tools testtone.pd} + $name.m.help.m add command -label {Load Meter} \ + -command {menu_doc_open doc/7.stuff/tools load-meter.pd} + $name.m.help.m add command -label {Pure Documentation} \ + -command {menu_documentation} + +# the popup menu + menu $name.popup -tearoff false + $name.popup add command -label {Properties} \ + -command [concat popup_action $name 0] + $name.popup add command -label {Open} \ + -command [concat popup_action $name 1] + $name.popup add command -label {Help} \ + -command [concat popup_action $name 2] + +# WM protocol + wm protocol $name WM_DELETE_WINDOW [concat menu_close $name] + +# bindings. +# this is idiotic -- how do you just sense what mod keys are down and +# pass them on? I can't find it anywhere. +# Here we encode shift as 1, control 2, alt 4, in agreement +# with definitions in g_canvas.c. The third button gets "8" but we don't +# bother with modifiers there. +# We don't handle multiple clicks yet. + + bind $name.c