aboutsummaryrefslogtreecommitdiff
path: root/buttonbar-plugin.tcl
blob: f2975c35bdb49476ea1e887ba748e0f0f1f069cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# this plugin creates a buttonbar on a patch window when that patch
# window is in Edit Mode

# this GUI plugin removes the menubars from any patch window that is
# not in Edit Mode.  Also, if a patch is switched to Run Mode, the
# menubar will be removed.

lappend ::auto_path $::current_plugin_loadpath

package require base64
package require tooltip 1.4.2

proc make_pd_button {mytoplevel name description} {
    button $mytoplevel.buttonbar.$name -image buttonimage$name \
        -relief flat -borderwidth 0 -highlightthickness 0 \
        -highlightcolor grey -highlightbackground grey -padx 0 -pady 0 \
        -command "menu_send_float \$::focused_window $name 0"
    pack $mytoplevel.buttonbar.$name -side left -padx 0 -pady 0
    ::tooltip::tooltip $mytoplevel.buttonbar.$name $description
}

proc make_iemgui_button {mytoplevel name description} {
    button $mytoplevel.buttonbar.$name -image buttonimage$name \
        -relief sunken -borderwidth 0 -highlightthickness 0 \
        -highlightcolor grey -highlightbackground grey -padx 0 -pady 0 \
        -command "menu_send \$::focused_window $name"
    pack $mytoplevel.buttonbar.$name -side left -padx 0 -pady 0
    ::tooltip::tooltip $mytoplevel.buttonbar.$name $description
}

proc showhide_buttonbar {mytoplevel} {
    if { ! [winfo exists $mytoplevel.buttonbar]} {
        frame $mytoplevel.buttonbar -cursor arrow -background grey \
            -pady 0
        make_pd_button $mytoplevel obj {Object (obj)}
        make_pd_button $mytoplevel msg {Message (msg)}
        make_pd_button $mytoplevel floatatom {Number (floatatom)}
        make_pd_button $mytoplevel symbolatom {Symbol (symbolatom)}
        make_pd_button $mytoplevel text {Comment}
        make_iemgui_button $mytoplevel bng {Bang Button \[bng]}
        make_iemgui_button $mytoplevel toggle {Toggle \[tgl]}
        make_iemgui_button $mytoplevel numbox {Number2 \[my_numbox]}
        make_iemgui_button $mytoplevel hslider {Horizontal Slider \[hslider]}
        make_iemgui_button $mytoplevel vslider {Verical Slider \[vslider]}
        make_iemgui_button $mytoplevel hradio {Horizontal Radio Button \[hradio]}
        make_iemgui_button $mytoplevel vradio {Vertical Radio Button \[vradio]}
        make_iemgui_button $mytoplevel vumeter {VU Meter \[vumeter]}
        make_iemgui_button $mytoplevel mycnv {Canvas \[mycnv]}
        make_iemgui_button $mytoplevel menuarray {Array (menuarray)}
    }
    if {$::editmode($mytoplevel)} {
        set tkcanvas [tkcanvas_name $mytoplevel]
        pack forget $tkcanvas
        pack $mytoplevel.buttonbar -side top -fill x
        pack $tkcanvas -side top -expand 1 -fill both
    } else {
        pack forget $mytoplevel.buttonbar
    }
}

bind PatchWindow <FocusIn> {+showhide_buttonbar %W}
bind PatchWindow <<EditMode>> {+showhide_buttonbar %W}

image create photo buttonimageobj -file $::current_plugin_loadpath/obj.gif
image create photo buttonimagemsg -file $::current_plugin_loadpath/msg.gif
image create photo buttonimagefloatatom -file $::current_plugin_loadpath/floatatom.gif
image create photo buttonimagesymbolatom -file $::current_plugin_loadpath/symbolatom.gif
image create photo buttonimagetext -file $::current_plugin_loadpath/text.gif

image create photo buttonimagebng -file $::current_plugin_loadpath/bng.gif
image create photo buttonimagetoggle -file $::current_plugin_loadpath/toggle.gif
image create photo buttonimagenumbox -file $::current_plugin_loadpath/numbox.gif
image create photo buttonimagehslider -file $::current_plugin_loadpath/hslider.gif
image create photo buttonimagevslider -file $::current_plugin_loadpath/vslider.gif
image create photo buttonimagehradio -file $::current_plugin_loadpath/hradio.gif
image create photo buttonimagevradio -file $::current_plugin_loadpath/vradio.gif
image create photo buttonimagevumeter -file $::current_plugin_loadpath/vumeter.gif
image create photo buttonimagemycnv -file $::current_plugin_loadpath/mycnv.gif

image create photo buttonimagemenuarray -file $::current_plugin_loadpath/menuarray.gif