Commit 7e67d4b9 authored by Ivica Ico Bukvic's avatar Ivica Ico Bukvic
Browse files

added intelligent scrolling when trying to make connections between objects...

added intelligent scrolling when trying to make connections between objects that do not fit on the current size of the canvas.
parent 297ad413
......@@ -3004,9 +3004,13 @@ void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit)
int xwas = x->gl_editor->e_xwas,
ywas = x->gl_editor->e_ywas;
if (doit) sys_vgui(".x%lx.c delete x\n", x);
else sys_vgui(".x%lx.c coords x %d %d %d %d\n",
else {
sys_vgui(".x%lx.c coords x %d %d %d %d\n",
x, x->gl_editor->e_xwas,
x->gl_editor->e_ywas, xpos, ypos);
sys_vgui("pdtk_check_scroll_on_motion .x%lx.c 0\n", x);
}
if ((y1 = canvas_findhitbox(x, xwas, ywas, &x11, &y11, &x12, &y12))
&& (y2 = canvas_findhitbox(x, xpos, ypos, &x21, &y21, &x22, &y22)))
......@@ -3100,7 +3104,7 @@ void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit)
// now check if explicit user-made connection into preset_node if kind other than message
// messages may be used to change node's operation
if (pd_class(&y2->g_pd) == preset_node_class && pd_class(&y1->g_pd) != message_class) {
error("preset node only accepts messages as input to set its destination preset_hub...\n");
error("preset node only accepts messages as input to adjust its settings...\n");
return;
}
......@@ -3630,7 +3634,9 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
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;
x->gl_editor->e_ywas = ypos;
//sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x);
//sys_vgui("pdtk_check_scroll_on_motion .x%lx.c 20\n", x);
}
else if (x->gl_editor->e_onmotion == MA_REGION)
canvas_doregion(x, xpos, ypos, 0);
......
......@@ -3815,6 +3815,34 @@ proc pdtk_canvas_scroll {canvas xy distance} {
}
}
proc pdtk_check_scroll_on_motion {w threshold} {
set x1 [$w canvasx 0]
set x2 [expr [$w canvasx 0] + [winfo width $w]]
set y1 [$w canvasy 0]
set y2 [expr [$w canvasy 0] + [winfo height $w]]
set xpointer [expr [$w canvasx 0] + [winfo pointerx $w]-[winfo rootx $w]]
set ypointer [expr [$w canvasy 0] + [winfo pointery $w]-[winfo rooty $w]]
#puts stderr "pdtk_boo x1=$x1 x2=$x2 y1=$y1 y2=$y2 xp=$xpointer yp=$ypointer"
if { $::xscrollable([winfo parent $w]) == 1 } {
if { $xpointer > [expr $x2 + $threshold] } {
pdtk_canvas_scroll $w x 1
}
if { $xpointer < [expr $x1 - $threshold] } {
pdtk_canvas_scroll $w x -1
}
}
if { $::yscrollable([winfo parent $w]) == 1 } {
if { $ypointer > [expr $y2 + $threshold] } {
pdtk_canvas_scroll $w y 1
}
if { $ypointer < [expr $y1 - $threshold] } {
pdtk_canvas_scroll $w y -1
}
}
}
proc pdtk_canvas_motion {name x y mods} {
global pointer_x_local pointer_y_local pointer_x_global pointer_y_global tooltip_visible
set pointer_x_local $x
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment