From 302a88b41bed4e9942f293485aee838f06503b40 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Wed, 10 Sep 2014 20:50:45 -0400 Subject: [PATCH] *made startmotion more user-friendly by hiding iemgui's handles after initial creation until motion is complete. LATER get rid of this because it is likely to be seen as an interim hack due to determinacy issues between the gui and core engine. --- pd/src/g_all_guis.c | 15 ++++++++++++++- pd/src/g_editor.c | 23 +++++++++++++++++++++++ pd/src/g_text.c | 10 +++++----- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index 417a1444b..0cf62ce20 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -506,7 +506,20 @@ void iemgui_select(t_gobj *z, t_glist *glist, int selected) sys_vgui(".x%lx.c itemconfigure {x%lx&&border} -stroke %s\n", canvas, x, x->x_selected && x->x_glist == canvas ? selection_color : fcol); x->x_draw((void *)z, glist, IEM_GUI_DRAW_MODE_SELECT); - scalehandle_draw(x); + if (selected < 2) + { + scalehandle_draw(x); + } + else + { + // exception where we get rid of handles when moving tiny objects + // because tkpath's slowness sometimes makes mouse pointer go over + // a handle and messes things up. we only do this when using + // startmotion (see g_editor.c). + // LATER: get rid of this because we will deal with this better using + // the new toolkit. + scalehandle_draw_erase2(x); + } iemgui_label_draw_select(x); iemgui_tag_selected(x); } diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index a896c623b..8dccf5fea 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -3073,6 +3073,18 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, if (x->gl_editor->e_onmotion == MA_MOVE) { //fprintf(stderr,"letting go of objects\n"); + t_selection *sel; + for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next) + { + if (sel && ((t_text *)sel->sel_what)->te_iemgui) + { + // iemgui exception to hide all handles that may interfere + // with the mouse cursor and its ability to move/deselect + // object(s) in question. Here we reinstate them once we've + // let go of the object(s) + gobj_select(sel->sel_what, x, 1); + } + } canvas_raise_all_cords(x); scrollbar_update(x); } @@ -5128,6 +5140,17 @@ void canvas_startmotion(t_canvas *x) x->gl_editor->e_onmotion = MA_MOVE; x->gl_editor->e_xwas = xval; x->gl_editor->e_ywas = yval; + t_selection *sel; + for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next) + { + if (sel && ((t_text *)sel->sel_what)->te_iemgui) + { + // iemgui exception to hide all handles that may interfere + // with the mouse cursor and its ability to move/deselect + // object(s) in question + gobj_select(sel->sel_what, x, 2); + } + } } /* ----------------------------- window stuff ----------------------- */ diff --git a/pd/src/g_text.c b/pd/src/g_text.c index d01da0d3a..06fdf4937 100644 --- a/pd/src/g_text.c +++ b/pd/src/g_text.c @@ -102,7 +102,7 @@ void glist_text(t_glist *gl, t_symbol *s, int argc, t_atom *argv) (void *)canvas_undo_set_create(glist_getcanvas(gl))); if (connectme == 0) { - canvas_displaceselection(glist_getcanvas(gl), 5, -7); + canvas_displaceselection(glist_getcanvas(gl), -8, -8); canvas_startmotion(glist_getcanvas(gl)); } } @@ -352,7 +352,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), 5, -7); + canvas_displaceselection(glist_getcanvas(gl), -8, -8); canvas_startmotion(glist_getcanvas(gl)); } //canvas_setundo(glist_getcanvas(gl), @@ -452,7 +452,7 @@ void canvas_iemguis(t_glist *gl, t_symbol *guiobjname) //canvas_objtext(gl, xpix, ypix, 1, b); else if (connectme == 0) { - canvas_displaceselection(glist_getcanvas(gl), 5, -7); + canvas_displaceselection(glist_getcanvas(gl), -8, -8); canvas_startmotion(glist_getcanvas(gl)); } //canvas_setundo(glist_getcanvas(gl), @@ -775,7 +775,7 @@ void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv) canvas_connect(gl, indx, 0, nobj, 0); else if (connectme == 0) { - canvas_displaceselection(glist_getcanvas(gl), 5, -7); + canvas_displaceselection(glist_getcanvas(gl), -8, -8); canvas_startmotion(glist_getcanvas(gl)); } //canvas_setundo(glist_getcanvas(gl), @@ -1274,7 +1274,7 @@ void canvas_atom(t_glist *gl, t_atomtype type, canvas_connect(gl, indx, 0, nobj, 0); else if (connectme == 0) { - canvas_displaceselection(glist_getcanvas(gl), 5, -7); + canvas_displaceselection(glist_getcanvas(gl), -8, -8); canvas_startmotion(glist_getcanvas(gl)); } //canvas_setundo(glist_getcanvas(gl), -- GitLab