From ab44363d3120d6f8bfe7c7266d88b0b9aa42282c Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 17 Jan 2011 21:05:23 +0000 Subject: first stab at a simple plugin for creating a object-by-category menu by a simple text file svn path=/trunk/scripts/guiplugins/category_menu-plugin/; revision=14749 --- LICENSE.txt | 30 ++++++++++++++++++++++++++++++ README.txt | 7 +++++++ category_menu-plugin.tcl | 40 ++++++++++++++++++++++++++++++++++++++++ menutree.tcl | 13 +++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 LICENSE.txt create mode 100644 README.txt create mode 100644 category_menu-plugin.tcl create mode 100644 menutree.tcl diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..a56a51e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,30 @@ +This software is copyrighted by Miller Puckette and others. The following +terms (the "Standard Improved BSD License") apply to all files associated with +the software unless explicitly disclaimed in individual files: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. +3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..8aaf041 --- /dev/null +++ b/README.txt @@ -0,0 +1,7 @@ +This plugin builds a object-by-category menu on the popup menu so you can create objects by browsing via category. + +This project was started at Eyebeam as part of an X-lab Residency and grew out of the NYC Patching Circle. + +Hans-Christoph Steiner +Joshua Clayton +Sofy Yuditskaya diff --git a/category_menu-plugin.tcl b/category_menu-plugin.tcl new file mode 100644 index 0000000..a5821e1 --- /dev/null +++ b/category_menu-plugin.tcl @@ -0,0 +1,40 @@ + +package require pd_menus + +namespace eval category_menu { +} + +proc category_menu::load_menutree {} { + # load object -> tags mapping from file in Pd's path + set testfile [file join $::current_plugin_loadpath menutree.tcl] + set f [open $testfile] + set menutree [read $f] + close $f + unset f + return $menutree +} + +proc category_menu::create {mymenu} { + pdtk_post "category menu plugin\n" + set menutree [load_menutree] + + $mymenu add separator + foreach categorylist $menutree { + set category [lindex $categorylist 0] + menu $mymenu.$category + $mymenu add cascade -label $category -menu $mymenu.$category + foreach subcategorylist [lrange $categorylist 1 end] { + set subcategory [lindex $subcategorylist 0] + menu $mymenu.$category.$subcategory + $mymenu.$category add cascade -label $subcategory -menu $mymenu.$category.$subcategory + pdtk_post "subcategorylist: $subcategorylist\n" + foreach item [lindex $subcategorylist 1] { + pdtk_post "item: $item\n" + $mymenu.$category.$subcategory add command -label $item \ + -command "pdsend \"\$::focused_window obj \$::popup_xcanvas \$::popup_ycanvas $item\"" + } + } + } +} + +category_menu::create .popup diff --git a/menutree.tcl b/menutree.tcl new file mode 100644 index 0000000..f23c5d7 --- /dev/null +++ b/menutree.tcl @@ -0,0 +1,13 @@ +{category1 + {subcategory1 + {1a b2 c3 d4}} + {subcategory2 + {1a 2b 3c 4d}}} +{category2 + {subcategoryA + {a1 b2 c3 d4}} + {subcategoryB + {1a 2b 3c 4d}}} +{audio + {math + {+~ /~ *~ pow}}} -- cgit v1.2.1