Skip to content

Commit

Permalink
fix bezier cable pdtk calls
Browse files Browse the repository at this point in the history
  • Loading branch information
sebshader committed Jan 4, 2023
1 parent a0ca1ab commit 4c32fd9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 38 deletions.
15 changes: 7 additions & 8 deletions src/g_canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,17 +945,16 @@ static void canvas_drawlines(t_canvas *x)
char tag[128];
const char *tags[2] = {tag, "cord"};
int issignal;
t_canvas *c = glist_getcanvas(x);
linetraverser_start(&t, x);
while ((oc = linetraverser_next(&t)))
{
issignal = (outlet_getsymbol(t.tr_outlet) == &s_signal);
sprintf(tag, "l%p", oc);
pdgui_vmess("pdtk_canvas::set_option_types", "ci crr iiii ri rS rr",
c, 1, c, "create", "line",
pdgui_vmess("pdtk_canvas::pdtk_connect", "iiii i Sc r",
t.tr_lx1,t.tr_ly1, t.tr_lx2,t.tr_ly2,
"-width", (issignal ? 2 : 1) * x->gl_zoom,
"-tags", 2, tags, "-fill", (issignal ? "signal_cord" : "msg_cord"));
(issignal ? 2 : 1) * x->gl_zoom,
2, tags, glist_getcanvas(x),
(issignal ? "signal_cord" : "msg_cord"));
}
}
}
Expand All @@ -972,9 +971,9 @@ void canvas_fixlinesfor(t_canvas *x, t_text *text)
{
char tag[128];
sprintf(tag, "l%p", oc);
pdgui_vmess(0, "crs iiii",
glist_getcanvas(x), "coords", tag,
t.tr_lx1,t.tr_ly1, t.tr_lx2,t.tr_ly2);
pdgui_vmess("pdtk_canvas::pdtk_coords", "iiii sc",
t.tr_lx1,t.tr_ly1, t.tr_lx2,t.tr_ly2,
tag, glist_getcanvas(x));
}
}
}
Expand Down
34 changes: 14 additions & 20 deletions src/g_editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2407,12 +2407,11 @@ static void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
x->gl_editor->e_xwas = xpos;
x->gl_editor->e_ywas = ypos;
pdgui_vmess("::pdtk_canvas::cords_to_foreground", "ci", x, 0);
pdgui_vmess("pdtk_canvas::set_option_types",
"ci crr iiii ri rs rr",
x, 1, x, "create", "line",
pdgui_vmess("pdtk_canvas::pdtk_connect",
"iiii i rcr",
xpos,ypos, xpos,ypos,
"-width", (issignal ? 2 : 1) * x->gl_zoom,
"-tags", "x", "-fill", "selected");
(issignal ? 2 : 1) * x->gl_zoom,
"x", x, "selected");
}
else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT);
}
Expand Down Expand Up @@ -2611,7 +2610,6 @@ static int tryconnect(t_canvas*x, t_object*src, int nout, t_object*sink, int nin
int noutlets1, ninlets, lx1, ly1, lx2, ly2;
char tag[128];
char*tags[] = {tag, "cord"};
t_canvas *c = glist_getcanvas(x);
sprintf(tag, "l%p", oc);
gobj_getrect(&src->ob_g, x, &x11, &y11, &x12, &y12);
gobj_getrect(&sink->ob_g, x, &x21, &y21, &x22, &y22);
Expand All @@ -2627,11 +2625,10 @@ static int tryconnect(t_canvas*x, t_object*src, int nout, t_object*sink, int nin
((x22-x21-iow) * nin)/(ninlets-1) : 0)
+ iom;
ly2 = y21;
pdgui_vmess("pdtk_canvas::set_option_types", "ci crr iiii ri rS",
c, 1, c, "create", "line",
pdgui_vmess("pdtk_canvas::pdtk_connect", "iiii i Sc r",
lx1,ly1, lx2,ly2,
"-width", (obj_issignaloutlet(src, nout) ? 2 : 1) * x->gl_zoom,
"-tags", 2, tags, "-fill",
(obj_issignaloutlet(src, nout) ? 2 : 1) * x->gl_zoom,
2, tags, glist_getcanvas(x),
(issignal ? "signal_cord" : "msg_cord"));
canvas_undo_add(x, UNDO_CONNECT, "connect", canvas_undo_set_connect(x,
canvas_getindex(x, &src->ob_g), nout,
Expand Down Expand Up @@ -2659,9 +2656,9 @@ static void canvas_doconnect(t_canvas *x, int xpos, int ypos, int mod, int doit)
pdgui_vmess(0, "crs", x, "delete", "x");
}
else
pdgui_vmess(0, "crs iiii",
x, "coords", "x",
x->gl_editor->e_xwas,x->gl_editor->e_ywas, xpos,ypos);
pdgui_vmess("pdtk_canvas::pdtk_coords", "iiii rc",
x->gl_editor->e_xwas,x->gl_editor->e_ywas, xpos,ypos,
"x", x);

if ((y1 = canvas_findhitbox(x, xwas, ywas, &x11, &y11, &x12, &y12))
&& (y2 = canvas_findhitbox(x, xpos, ypos, &x21, &y21, &x22, &y22)))
Expand Down Expand Up @@ -4424,14 +4421,11 @@ void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno,
int issignal = obj_issignaloutlet(objsrc, outno);
char tag[128];
char*tags[] = {tag, "cord"};
t_canvas *c = glist_getcanvas (x);
sprintf(tag, "l%p", oc);
pdgui_vmess("pdtk_canvas::set_option_types",
"ci crr iiii ri rS rr",
c, 1, c, "create", "line",
0, 0, 0, 0,
"-width", (issignal ? 2 : 1) * x->gl_zoom,
"-tags", 2, tags, "-fill", issignal ? "signal_cord" : "msg_cord");
pdgui_vmess("pdtk_canvas::pdtk_connect",
"iiii i Scr",
0, 0, 0, 0, (issignal ? 2 : 1) * x->gl_zoom,
2, tags, glist_getcanvas(x), issignal ? "signal_cord" : "msg_cord");
canvas_fixlinesfor(x, objsrc);
}
return;
Expand Down
8 changes: 3 additions & 5 deletions src/g_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,9 @@ void glist_redraw(t_glist *x)
{
char tagbuf[128];
sprintf(tagbuf, "l%p", oc);
pdgui_vmess("pdtk_canvas::set_option_types", "crs iiii",
glist_getcanvas(x),
"coords",
tagbuf,
t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2);
pdgui_vmess("pdtk_canvas::pdtk_coords", "iiii sc",
t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2,
tagbuf, glist_getcanvas(x));
}
canvas_drawredrect(x, 0);
if (x->gl_goprect)
Expand Down
10 changes: 5 additions & 5 deletions tcl/pdtk_canvas.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ proc ::pdtk_canvas::cords_to_foreground {mytoplevel {state 1}} {
}
}

proc ::pdtk_canvas::pdtk_connect {x1 y1 x2 y2 width tags wind col} {
proc ::pdtk_canvas::pdtk_connect {x1 y1 x2 y2 width tags canv col} {
# from pd-l2ork
if {$::curve_cords} {
set ymax 0;
Expand All @@ -544,14 +544,14 @@ proc ::pdtk_canvas::pdtk_connect {x1 y1 x2 y2 width tags wind col} {
if {$yoff > $ymax} {
set yoff $ymax;
}
${wind}.c create line $x1 $y1 $x1 [expr {$y1 + $yoff}] \
$canv create line $x1 $y1 $x1 [expr {$y1 + $yoff}] \
[expr {$x1 + $halfx}] [expr {$y1 + $halfy}] $x2 \
[expr {$y2 - $yoff}] $x2 $y2 -smooth 1 \
-width $width -tags $tags -fill [get_color $col $wind]
-width $width -tags $tags -fill [get_color $col $canv]
} else {
# have to set smooth and splinesteps in case it changes
${wind}.c create line $x1 $y1 $x2 $y2 -width $width -tags $tags \
-smooth 1 -splinesteps 36 -fill [get_color $col $wind]
$canv create line $x1 $y1 $x2 $y2 -width $width -tags $tags \
-smooth 1 -splinesteps 36 -fill [get_color $col $canv]
}
}

Expand Down

0 comments on commit 4c32fd9

Please sign in to comment.