From 0b6f60c53c727132ea21e01cf74c86ef636bc151 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Sun, 17 Jan 2016 19:23:07 -0500 Subject: [PATCH] add cord inspector menu item, port remaining sys_vgui calls in g_editor.c --- pd/nw/pd_canvas.js | 8 ++++++++ pd/nw/pd_menus.js | 1 + pd/nw/pdgui.js | 13 +++++++++++++ pd/src/g_editor.c | 21 ++++++++++++++++----- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js index 409ec79bd..2437392cf 100644 --- a/pd/nw/pd_canvas.js +++ b/pd/nw/pd_canvas.js @@ -794,6 +794,10 @@ function register_window_id(cid, attr_array) { canvas_events.normal(); pdgui.canvas_map(cid); // side-effect: triggers gui_canvas_getscroll from Pd set_editmode_checkbox(attr_array.editmode !== 0 ? true : false); + // 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 + //set_cord_inspector_checkbox(); } function create_popup_menu(name) { @@ -875,6 +879,10 @@ function set_editmode_checkbox(state) { canvas_menu.edit.editmode.checked = state; } +function set_cord_inspector_checkbox(state) { + canvas_menu.edit.cordinspector.checked = state; +} + // stop-gap function menu_generic () { alert("Please implement this"); diff --git a/pd/nw/pd_menus.js b/pd/nw/pd_menus.js index a5495c3f4..74ad60951 100644 --- a/pd/nw/pd_menus.js +++ b/pd/nw/pd_menus.js @@ -186,6 +186,7 @@ function create_menu(gui, type) { tooltip: l("menu.font_tt") })); editMenu.append(m.edit.cordinspector = new gui.MenuItem({ + type: "checkbox", label: l("menu.cordinspector"), key: "r", modifiers: cmd_or_ctrl, diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index 96f3db450..8d8fc162b 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -340,6 +340,15 @@ function pd_geo_string(w, h, x, y) { return [w,"x",h,"+",x,"+",y].join(""); } +// quick hack so that we can paste pd code from clipboard and +// have it affect an empty canvas' geometry +function gui_change_patch_window_geometry(cid, w, h, x, y) { + patchwin[cid].width = w; + patchwin[cid].height = h + 23; // 23 is a kludge to account for menubar + patchwin[cid].x = x; + patchwin[cid].y = y; +} + // In tcl/tk, this function had some checks to apparently // keep from sending a "relocate" message to Pd, but I'm // not exactly clear on how it works. If this ends up being @@ -583,6 +592,10 @@ function gui_set_editmode(cid, state) { patchwin[cid].window.set_editmode_checkbox(state !== 0 ? true : false); } +function gui_set_cordinspector(cid, state) { + patchwin[cid].window.set_cord_inspector_checkbox(state !== 0 ? true : false); +} + exports.menu_send = menu_send; function gui_set_toplevel_window_list(dummy, attr_array) { diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 656c9c6a7..499c1a60f 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -6455,10 +6455,16 @@ static void canvas_dopaste(t_canvas *x, t_binbuf *b) x->gl_screeny2 = screeny1 + screeny2; //canvas_setbounds(x, screenx1, screeny1, // screenx1+screenx2, screeny1+screeny2); - sys_vgui("wm geometry .x%lx =%dx%d+%d+%d\n", x, + //sys_vgui("wm geometry .x%lx =%dx%d+%d+%d\n", x, + // (int)(x->gl_screenx2 - x->gl_screenx1), + // (int)(x->gl_screeny2 - x->gl_screeny1), + // (int)(x->gl_screenx1), (int)(x->gl_screeny1)); + gui_vmess("gui_change_patch_window_geometry", "xiiii", + x, (int)(x->gl_screenx2 - x->gl_screenx1), (int)(x->gl_screeny2 - x->gl_screeny1), - (int)(x->gl_screenx1), (int)(x->gl_screeny1)); + (int)(x->gl_screenx1), + (int)(x->gl_screeny1)); // hardwired stretchval and whichstretch // until we figure out proper resizing canvas_dofont(x, copiedfont, 1, 1); @@ -7581,7 +7587,9 @@ void canvas_editmode(t_canvas *x, t_floatarg fyesplease) if (glist_isvisible(x) && glist_istoplevel(x)) { canvas_setcursor(x, CURSOR_RUNMODE_NOTHING); - sys_vgui(".x%lx.c delete commentbar\n", glist_getcanvas(x)); + /* Don't need this anymore, as we can control comment appearance + with CSS. */ + //sys_vgui(".x%lx.c delete commentbar\n", glist_getcanvas(x)); // jsarlo if (x->gl_editor->canvas_cnct_inlet_tag[0] != 0) { @@ -7643,8 +7651,11 @@ void canvas_magicglass(t_canvas *x, t_floatarg fyesplease) magicGlass_setOn(x->gl_editor->gl_magic_glass, 0); magicGlass_hide(x->gl_editor->gl_magic_glass); } - sys_vgui("pdtk_canvas_magicglassval .x%x %d\n", - glist_getcanvas(x), magicGlass_isOn(x->gl_editor->gl_magic_glass)); + //sys_vgui("pdtk_canvas_magicglassval .x%x %d\n", + // glist_getcanvas(x), magicGlass_isOn(x->gl_editor->gl_magic_glass)); + gui_vmess("gui_set_cordinspector", "xi", + glist_getcanvas(x), + magicGlass_isOn(x->gl_editor->gl_magic_glass)); } // end jsarlo -- GitLab