Skip to content

Commit

Permalink
handle iolets on the GUI-side
Browse files Browse the repository at this point in the history
  • Loading branch information
umlaeute committed Sep 21, 2022
1 parent aa47bf6 commit 4902b12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 38 deletions.
41 changes: 3 additions & 38 deletions src/g_all_guis.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,44 +872,9 @@ static void iemgui_draw_update(t_iemgui*x, t_glist*glist) {;}
static void iemgui_draw_select(t_iemgui*x, t_glist*glist) {;}
static void iemgui_draw_iolets(t_iemgui*x, t_glist*glist, int old_snd_rcv_flags)
{
const int zoom = x->x_glist->gl_zoom;
int xpos = text_xpix(&x->x_obj, glist);
int ypos = text_ypix(&x->x_obj, glist);
int iow = IOWIDTH * zoom, ioh = IEM_GUI_IOHEIGHT * zoom;
t_canvas *canvas = glist_getcanvas(glist);
char tag_object[128], tag_label[128], tag[128];
char *tags[] = {tag_object, tag};

(void)old_snd_rcv_flags;

sprintf(tag_object, "%lxOBJ", x);
sprintf(tag_label, "%lxLABEL", x);

/* re-create outlet */
sprintf(tag, "%lxOUT%d", x, 0);
pdgui_vmess(0, "crs", canvas, "delete", tag);
if(!x->x_fsf.x_snd_able) {
pdgui_vmess(0, "crr iiii rs rS",
canvas, "create", "rectangle",
xpos, ypos + x->x_h + zoom - ioh, xpos + iow, ypos + x->x_h,
"-fill", "black",
"-tags", 2, tags);
/* keep label above outlet */
pdgui_vmess(0, "crss", canvas, "lower", tag, tag_label);
}

/* re-create inlet */
sprintf(tag, "%lxIN%d", x, 0);
pdgui_vmess(0, "crs", canvas, "delete", tag);
if(!x->x_fsf.x_rcv_able) {
pdgui_vmess(0, "crr iiii rs rS",
canvas, "create", "rectangle",
xpos, ypos, xpos + iow, ypos - zoom + ioh,
"-fill", "black",
"-tags", 2, tags);
/* keep label above inlet */
pdgui_vmess(0, "crss", canvas, "lower", tag, tag_label);
}
pdgui_vmess("::pd::widget::show_iolets", "o ii"
, x
, !x->x_fsf.x_rcv_able, !x->x_fsf.x_snd_able);
}

static void iemgui_draw_erase(t_iemgui* x, t_glist* glist)
Expand Down
9 changes: 9 additions & 0 deletions tcl/pdwidget_bang.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ proc ::pd::widget::bang::create {obj cnv} {
$cnv create rectangle 0 0 0 0 -tags [list ${tag}] -outline {} -fill {} -width 0
$cnv create rectangle 0 0 0 0 -tags [list ${tag} ${tag}BASE]
$cnv create oval 0 0 0 0 -tags [list ${tag} ${tag}BUT]
$cnv create rectangle 0 0 0 0 -tags [list ${tag} ${tag}INLET] -outline {} -fill {}
$cnv create rectangle 0 0 0 0 -tags [list ${tag} ${tag}OUTLET] -outline {} -fill {}
$cnv create text 0 0 -anchor w -tags [list ${tag} ${tag}LABEL label text]

dict set ::pd::widget::bang::_state $obj canvas $cnv
Expand Down Expand Up @@ -68,6 +70,13 @@ foreach cnv [::pd::widget::get_canvases $obj] {
$cnv coords "${tag}BUT" \
[expr ($xpos + 1) * $zoom] [expr ($ypos + 1) * $zoom] \
[expr ($xpos + $xnew - 1.5) * $zoom] [expr ($ypos + $ynew - 1.5) * $zoom]

$cnv coords "${tag}INLET" \
[expr $xpos * $zoom] [expr ($ypos ) * $zoom] \
[expr ($xpos + $iow) * $zoom] [expr ($ypos + $ih) * $zoom]
$cnv coords "${tag}OUTLET" \
[expr $xpos * $zoom] [expr ($ypos + $ynew - $oh) * $zoom] \
[expr ($xpos + $iow) * $zoom] [expr ($ypos + $ynew ) * $zoom]
} "-colors" {
set color [lindex $v 0]
$cnv itemconfigure "${tag}BUT" -fill $color
Expand Down

0 comments on commit 4902b12

Please sign in to comment.