diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js index 9e074b5447676c96e17b8ddb2f06144f5d34fe12..60278d79f958af3e413dea8b8bc2e5f525c029e6 100644 --- a/pd/nw/pd_canvas.js +++ b/pd/nw/pd_canvas.js @@ -1323,7 +1323,7 @@ function register_window_id(cid, attr_array) { // Initialize the zoom level to the value retrieved from the patch, if any. nw.Window.get().zoomLevel = attr_array.zoom; pdgui.canvas_map(cid); // side-effect: triggers gui_canvas_get_scroll - pdgui.canvas_set_editmode(cid, attr_array.editmode); + pdgui.canvas_query_editmode(cid); // For now, there is no way for the cord inspector to be turned on by // default. But if this changes we need to set its menu item checkbox // accordingly here diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index ffcc1f52684b948813611fd20fc5fe0b02d15dc9..90289fd216704268bb9fafdef211f0dea3ee7f19 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -1302,6 +1302,13 @@ function gui_canvas_set_editmode(cid, state) { canvas_set_editmode(cid, state); } +// ask the engine about the current edit mode +function canvas_query_editmode(cid) { + pdsend(cid, "query-editmode"); +} + +exports.canvas_query_editmode = canvas_query_editmode; + function update_grid(grid) { // Update the grid background of all canvas windows when the corresponding // option in the gui prefs changes. diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 86f355928c3815fca652859c5689e7231038d776..ffe807aaba2d8b1224a292dd0b3157f59635da04 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -497,6 +497,7 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv) } x->gl_willvis = vis; x->gl_edit = !strncmp(x->gl_name->s_name, "Untitled", 8); + x->gl_edit_save = 0; x->gl_font = sys_nearestfontsize(font); x->gl_zoom = zoom; pd_pushsym(&x->gl_pd); @@ -2717,6 +2718,8 @@ void g_canvas_setup(void) gensym("vis"), A_FLOAT, A_NULL); class_addmethod(canvas_class, (t_method)glist_menu_open, gensym("menu-open"), A_NULL); + class_addmethod(canvas_class, (t_method)canvas_query_editmode, + gensym("query-editmode"), A_NULL); class_addmethod(canvas_class, (t_method)canvas_map, gensym("map"), A_FLOAT, A_NULL); class_addmethod(canvas_class, (t_method)canvas_dirty, diff --git a/pd/src/g_canvas.h b/pd/src/g_canvas.h index ab053d08d70939c718798395a9b58e4a1e414f1e..a5d7ed1166c0a9cb192c3c809af20e649e8e49aa 100644 --- a/pd/src/g_canvas.h +++ b/pd/src/g_canvas.h @@ -210,6 +210,7 @@ struct _glist unsigned int gl_loading:1; /* am now loading from file */ unsigned int gl_willvis:1; /* make me visible after loading */ unsigned int gl_edit:1; /* edit mode */ + unsigned int gl_edit_save:1; /* set in temporary run mode */ unsigned int gl_isdeleting:1; /* we're inside glist_delete -- hack! */ unsigned int gl_unloading:1; /* we're inside canvas_free */ unsigned int gl_goprect:1; /* draw rectangle for graph-on-parent */ @@ -564,6 +565,7 @@ EXTERN void canvas_resortoutlets(t_canvas *x); EXTERN void canvas_free(t_canvas *x); EXTERN void canvas_updatewindowlist( void); EXTERN void canvas_editmode(t_canvas *x, t_floatarg yesplease); +EXTERN void canvas_query_editmode(t_canvas *x); EXTERN int canvas_isabstraction(t_canvas *x); EXTERN int canvas_istable(t_canvas *x); EXTERN int canvas_showtext(t_canvas *x); diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index b41086d47cdd1da592724244e2728b3fa9192de0..78b76cb5962aa6c0f2aac9b85a813b3066a33b1e 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -3520,6 +3520,8 @@ static double canvas_upclicktime; static int canvas_upx, canvas_upy; #define DCLICKINTERVAL 0.25 +static int ctrl_runmode_warned; + /* mouse click */ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, int mod, int doit) @@ -3532,7 +3534,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, //post("canvas_doclick %d", doit); t_gobj *y; - int shiftmod, runmode, altmod, doublemod = 0, rightclick, + int shiftmod, runmode, ctrlmod, altmod, doublemod = 0, rightclick, in_text_resizing_hotspot, default_type; int x1=0, y1=0, x2=0, y2=0, clickreturned = 0; t_gobj *yclick = NULL; @@ -3551,8 +3553,9 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, // read key and mouse button states shiftmod = (mod & SHIFTMOD); - runmode = ((mod & CTRLMOD) || (!x->gl_edit)); + ctrlmod = (mod & CTRLMOD); altmod = (mod & ALTMOD); + runmode = (altmod || (!x->gl_edit)); rightclick = (mod & RIGHTCLICK); // set global left mouse click variable @@ -3644,7 +3647,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, if (yclick) { clickreturned = gobj_click(yclick, x, xpos, ypos, - shiftmod, ((mod & CTRLMOD) && (!x->gl_edit)) || altmod, + shiftmod, (altmod && (!x->gl_edit)) || ctrlmod, 0, doit); //fprintf(stderr, " MAIN clicking\n"); } @@ -3690,6 +3693,14 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, if (y) { + /* check for ctrlmod click and give a warning once in the console that + the hotkey for temporary runmode has changed */ + if (!ctrl_runmode_warned && ctrlmod && !rightclick && doit) { + post("\nwarning: The hotkey for temporary run mode has changed. " + "Please press Alt instead of Ctrl to enable it.\n"); + ctrl_runmode_warned = 1; + } + // if we are right-clicking if (rightclick) canvas_rightclick(x, xpos, ypos, y); @@ -4063,7 +4074,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, return; } /* having failed to find a box, we try lines now. */ - if (!runmode && !altmod && !shiftmod) + if (!runmode && !ctrlmod && !shiftmod) { t_linetraverser t; t_outconnect *oc; @@ -5578,31 +5589,34 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av) } if (x && keynum == 0 && x->gl_edit && - !strncmp(gotkeysym->s_name, "Alt", 3)) + !strncmp(gotkeysym->s_name, "Control", 7)) { - glob_alt = down; + glob_ctrl = down; } - /* if control key goes up or down, and if we're in edit mode, change + /* if alt key goes up or down, and if we're in edit mode, change cursor to indicate how the click action changes NEW: do so only if not doing anything else in edit mode */ if (x && keynum == 0 && - !strncmp(gotkeysym->s_name, "Control", 7)) + !strncmp(gotkeysym->s_name, "Alt", 3)) { //fprintf(stderr,"ctrl\n"); - glob_ctrl = down; - //post("glob_ctrl=%d", down); + glob_alt = down; + //post("glob_alt=%d", down); /* ico@vt.edu: commenting MA_NONE part as that prevents the patch from assuming editmode after it has had an object added via a ctrl+(1-5) shortcut while not in edit mode */ - if (x->gl_edit /*&& x->gl_editor->e_onmotion == MA_NONE*/) + if (x->gl_edit /*&& x->gl_editor->e_onmotion == MA_NONE*/ || + x->gl_edit_save) { canvas_setcursor(x, down ? CURSOR_RUNMODE_NOTHING : CURSOR_EDITMODE_NOTHING); + x->gl_edit = down ? 0 : 1; + x->gl_edit_save = !x->gl_edit; gui_vmess("gui_canvas_set_editmode", "xi", x, - down ? 0 : 1); + x->gl_edit); if(x->gl_editor && x->gl_editor->gl_magic_glass) { if (down) @@ -7993,6 +8007,8 @@ void canvas_editmode(t_canvas *x, t_floatarg fyesplease) return; } x->gl_edit = !x->gl_edit; + // make sure to exit temporary run mode here + x->gl_edit_save = 0; if (x->gl_edit && glist_isvisible(x) && glist_istoplevel(x)){ //dpsaha@vt.edu add the resize blobs on GOP t_gobj *g; @@ -8042,13 +8058,21 @@ void canvas_editmode(t_canvas *x, t_floatarg fyesplease) } if (glist_isvisible(x)) { - int edit = !glob_ctrl && x->gl_edit; + int edit = /*!glob_ctrl && */x->gl_edit; gui_vmess("gui_canvas_set_editmode", "xi", glist_getcanvas(x), edit); } } +void canvas_query_editmode(t_canvas *x) +{ + int edit = /*!glob_ctrl && */x->gl_edit; + gui_vmess("gui_canvas_set_editmode", "xi", + glist_getcanvas(x), + edit); +} + // jsarlo void canvas_magicglass(t_canvas *x, t_floatarg fyesplease) {