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