Commit 6d53ed42 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*refined displacement and positioning of objects on new canvases

parent 185fd284
......@@ -351,6 +351,7 @@ void glist_init(t_glist *x)
void canvasgop__clickhook(t_scalehandle *sh, int newstate);
void canvasgop__motionhook(t_scalehandle *sh,t_floatarg f1, t_floatarg f2);
extern void glist_setlastxy(t_glist *gl, int xval, int yval);
/* make a new glist. It will either be a "root" canvas or else
it appears as a "text" object in another window (canvas_getcurrent()
......@@ -456,6 +457,7 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
x->x_mhandle = scalehandle_new((t_object *)x,x,0,canvasgop__clickhook,canvasgop__motionhook);
x->u_queue = canvas_undo_init(x);
glist_setlastxy(x, 20, 20);
return(x);
}
......
......@@ -72,7 +72,7 @@ int canvas_apply_restore_original_position(t_canvas *x, int orig_pos);
extern void canvas_draw_gop_resize_hooks(t_canvas *x);
static void canvas_font(t_canvas *x, t_floatarg font, t_floatarg oldfont,
t_floatarg resize, t_floatarg preview);
static void canvas_displaceselection(t_canvas *x, int dx, int dy);
void canvas_displaceselection(t_canvas *x, int dx, int dy);
void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
t_floatarg fmod);
/* for updating preset_node locations in case of operations that alter
......@@ -98,7 +98,7 @@ int glob_ctrl = 0;
int glob_alt = 0;
static t_glist *canvas_last_glist;
static int canvas_last_glist_x, canvas_last_glist_y, canvas_last_glist_mod;
static int canvas_last_glist_x=20, canvas_last_glist_y=20, canvas_last_glist_mod;
struct _outlet
{
......@@ -4653,7 +4653,7 @@ void canvas_mousedown_middle(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
}
/* displace the selection by (dx, dy) pixels */
static void canvas_displaceselection(t_canvas *x, int dx, int dy)
void canvas_displaceselection(t_canvas *x, int dx, int dy)
{
//fprintf(stderr,"canvas_displaceselection %d %d\n", dx, dy);
t_selection *y;
......@@ -5110,7 +5110,7 @@ void canvas_startmotion(t_canvas *x)
int xval, yval;
if (!x->gl_editor) return;
glist_getnextxy(x, &xval, &yval);
if (xval == 0 && yval == 0) return;
//if (xval == 0 && yval == 0) return;
x->gl_editor->e_onmotion = MA_MOVE;
x->gl_editor->e_xwas = xval;
x->gl_editor->e_ywas = yval;
......@@ -7239,7 +7239,7 @@ void glist_getnextxy(t_glist *gl, int *xpix, int *ypix)
{
if (canvas_last_glist == gl)
*xpix = canvas_last_glist_x, *ypix = canvas_last_glist_y;
else *xpix = *ypix = 40;
else *xpix = *ypix = 20;
}
void glist_setlastxy(t_glist *gl, int xval, int yval)
......
......@@ -35,6 +35,7 @@ t_widgetbehavior text_widgetbehavior;
static char *invalid_fill = "$::pd_colors(dash_fill)";
extern void canvas_displaceselection(t_canvas *x, int dx, int dy);
extern void canvas_apply_setundo(t_canvas *x, t_gobj *y);
extern void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf,
const char *name);
......@@ -99,7 +100,11 @@ void glist_text(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
if (!we_are_undoing)
canvas_undo_add(glist_getcanvas(gl), 9, "create",
(void *)canvas_undo_set_create(glist_getcanvas(gl)));
if (connectme == 0) canvas_startmotion(glist_getcanvas(gl));
if (connectme == 0)
{
canvas_displaceselection(glist_getcanvas(gl), -10, -10);
canvas_startmotion(glist_getcanvas(gl));
}
}
}
......@@ -341,6 +346,7 @@ void canvas_obj(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
else if (connectme == 0)
{
//fprintf(stderr,"canvas_obj calls canvas_startmotion\n");
canvas_displaceselection(glist_getcanvas(gl), -10, -10);
canvas_startmotion(glist_getcanvas(gl));
}
//canvas_setundo(glist_getcanvas(gl),
......@@ -411,6 +417,7 @@ void canvas_iemguis(t_glist *gl, t_symbol *guiobjname)
glist_noselect(gl);
int connectme, xpix, ypix, indx, nobj;
canvas_howputnew(gl, &connectme, &xpix, &ypix, &indx, &nobj);
/* NOT NECESSARY ANY MORE: compensate for the iemgui sliders' xyoffset
......@@ -437,7 +444,11 @@ void canvas_iemguis(t_glist *gl, t_symbol *guiobjname)
canvas_connect(gl, indx, 0, nobj, 0);
//glist_getnextxy(gl, &xpix, &ypix);
//canvas_objtext(gl, xpix, ypix, 1, b);
else if (connectme == 0 ) canvas_startmotion(glist_getcanvas(gl));
else if (connectme == 0)
{
canvas_displaceselection(glist_getcanvas(gl), -10, -10);
canvas_startmotion(glist_getcanvas(gl));
}
//canvas_setundo(glist_getcanvas(gl),
// canvas_undo_create, canvas_undo_set_create(gl), "create");
canvas_undo_add(glist_getcanvas(gl), 9, "create",
......@@ -751,7 +762,11 @@ void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
gobj_activate(&x->m_text.te_g, gl, 1);
if (connectme == 1)
canvas_connect(gl, indx, 0, nobj, 0);
else if (connectme == 0) canvas_startmotion(glist_getcanvas(gl));
else if (connectme == 0)
{
canvas_displaceselection(glist_getcanvas(gl), -10, -10);
canvas_startmotion(glist_getcanvas(gl));
}
//canvas_setundo(glist_getcanvas(gl),
// canvas_undo_create, canvas_undo_set_create(gl), "create");
canvas_undo_add(glist_getcanvas(gl), 9, "create",
......@@ -1246,7 +1261,11 @@ void canvas_atom(t_glist *gl, t_atomtype type,
glist_select(gl, &x->a_text.te_g);
if (connectme == 1)
canvas_connect(gl, indx, 0, nobj, 0);
else if (connectme == 0) canvas_startmotion(glist_getcanvas(gl));
else if (connectme == 0)
{
canvas_displaceselection(glist_getcanvas(gl), -10, -10);
canvas_startmotion(glist_getcanvas(gl));
}
//canvas_setundo(glist_getcanvas(gl),
// canvas_undo_create, canvas_undo_set_create(gl), "create");
canvas_undo_add(glist_getcanvas(gl), 9, "create",
......
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