Commit c1366bde authored by pokergaming's avatar pokergaming
Browse files

hooked up dsp shortcut keys, more work on garrays

parent 74bef34d
......@@ -7,7 +7,7 @@
<div class="container noselect">
<form>
<fieldset>
<fieldset class="canvas">
<legend data-i18n="canvas.prop.heading.gop"></legend>
<table class="pairs">
......@@ -77,7 +77,7 @@
</fieldset>
<fieldset>
<fieldset class="canvas">
<legend data-i18n="canvas.prop.heading.data_scaling"></legend>
<div class="x-scale prop hidden">
......@@ -133,76 +133,93 @@
</label>
<div class="array-name prop">
<label class="array-name" data-i18n="[title]canvas.prop.array_name_tt">
<label class="array-name"
data-i18n="[title]canvas.prop.array_name_tt">
<span data-i18n="canvas.prop.array_name"></span>
<input onchange="attr_change(this);" class="array-name" type="text" name="array_name">
<input onchange="attr_change(this);"
class="array-name"
type="text"
name="array_name">
</label>
<label class="array-size" data-i18n="[title]canvas.prop.array_size_tt">
<label class="array-size"
data-i18n="[title]canvas.prop.array_size_tt">
<span data-i18n="canvas.prop.array_size"></span>
<input onchange="attr_change(this);" class="array-size" type="text" name="array_size">
<input onchange="attr_change(this);"
class="array-size"
type="text"
name="array_size">
</label>
<label class="array-save" data-i18n="[title]canvas.prop.array_save_tt">
<br/>
<label class="array-save"
data-i18n="[title]canvas.prop.array_save_tt">
<input onchange="flag_change(this);"
type="checkbox"
name="array_save"
value="on">
<span data-i18n="canvas.prop.array_save"></span>
<input onchange="flag_change(this);" type="checkbox" name="array_save" value="on">
</label>
<label class="array-jump" data-i18n="[title]canvas.prop.array_jump_tt">
<br/>
<label class="array-jump"
data-i18n="[title]canvas.prop.array_jump_tt">
<input onchange="flag_change(this);"
type="checkbox" name="array_jump" value="on">
<span data-i18n="canvas.prop.array_jump"></span>
<input onchange="flag_change(this);" type="checkbox" name="array_jump" value="on">
</label>
<br/>
<span data-i18n="canvas.prop.array_style"></span>
<label class="polygon" data-i18n="[title]canvas.prop.array_polygon_tt">
<span data-i18n="canvas.prop.array_polygon"></span>
<span data-i18n="canvas.prop.array_style"></span>
<br/>
<label class="polygon"
data-i18n="[title]canvas.prop.array_polygon_tt">
<input class="array-style"
type="radio"
id="polygon"
value="0"
name="array_style"
onchange="flag_change(this);">
<span data-i18n="canvas.prop.array_polygon"></span>
</label>
<label class="points" data-i18n="[title]canvas.prop.array_points_tt">
<span data-i18n="canvas.prop.array_points"></span>
<br/>
<label class="points"
data-i18n="[title]canvas.prop.array_points_tt">
<input class="array-style"
type="radio"
id="points"
value="1"
name="array_style"
onchange="flag_change(this);">
<span data-i18n="canvas.prop.array_points"></span>
</label>
<label class="bezier-curve" data-i18n="[title]canvas.prop.array_bezier_tt">
<span data-i18n="canvas.prop.array_bezier"></span>
<br/>
<label class="bezier-curve"
data-i18n="[title]canvas.prop.array_bezier_tt">
<input class="array-style"
type="radio"
id="bezier"
value="2"
name="array_style"
onchange="flag_change(this);">
<span data-i18n="canvas.prop.array_bezier"></span>
</label>
<label class="bar-graph" data-i18n="[title]canvas.prop.array_bars_tt">
<span data-i18n="canvas.prop.array_bars"></span>
<br/>
<label class="bar-graph"
data-i18n="[title]canvas.prop.array_bars_tt">
<input class="array-style"
type="radio"
id="bar-graph"
value="3"
name="array_style"
onchange="flag_change(this);">
<span data-i18n="canvas.prop.array_bars"></span>
</label>
<br/>
</div>
<div class="array-fill">
<label data-i18n="[title]canvas.prop.array_fill_tt">
<input onchange="attr_change(this);" type="color" name="array_fill">
<input onchange="attr_change(this);"
type="color"
name="array_fill">
<span data-i18n="canvas.prop.array_fill"></span>
</label>
<br>
......@@ -210,48 +227,26 @@
<div class="array-outline">
<label data-i18n="[title]canvas.prop.array_outline_tt">
<input onchange="attr_change(this);" type="color" name="array_outline">
<input onchange="attr_change(this);"
type="color"
name="array_outline">
<span data-i18n="canvas.prop.array_outline"></span>
</label>
<br>
</div>
<div class="gop-range">
<div class="y1 prop hidden">
<label class="gop_opt" data-i18n="[title]canvas.prop.y1_tt">
<span data-i18n="canvas.prop.y1"></span>
<br>
<input class="gop_opt" type="text" name="y1">
</label>
<br>
</div>
<div class="x1 prop hidden">
<label class="gop_opt" data-i18n="[title]canvas.prop.x1_tt">
<span data-i18n="canvas.prop.x1"></span>
<input class="gop_opt" type="text" name="x1">
</label>
<label class="gop_opt" data-i18n="[title]canvas.prop.x2_tt">
<input class="gop_opt" type="text" name="x2">
<span data-i18n="canvas.prop.x2"></span>
</label>
<br>
</div>
<div class="y2">
<label class="gop_opt" data-i18n="[title]canvas.prop.y2_tt">
<input class="gop_opt" type="text" name="y2">
<br>
<span data-i18n="canvas.prop.y2"></span>
</label>
</div>
</div>
<div class="array_in_existing_graph">
<label class="array-in-existing-graph"
data-i18n="[title]canvas.prop.array_in_existing_graph_tt">
<input onchange="flag2_change(this);"
type="checkbox"
name="array_in_existing_graph"
value="on">
<span data-i18n="canvas.prop.array_in_existing_graph"></span>
</label>
</div>
</fieldset>
<div class="submit_buttons">
<button type="button" onClick="ok()" data-i18n="[title]iem.prop.ok_tt">
<span data-i18n="iem.prop.ok"></span>
......@@ -328,6 +323,20 @@
pdgui.gui_post("array is " + attr);
}
function flag2_change(elem) {
var attr, arrays_select, name, value, flag;
arrays_select = document.getElementById('arrays_select');
attr = pd_garray_attrs[arrays_select.value];
name = elem.name;
// pdgui.gui_post("name is " + name);
// get value from radio group, checked from checkboxes
// '+' for casting boolean to number
value = +elem.checked;
// pdgui.gui_post("value is " + value);
attr[attr.indexOf(name) + 1] = value;
pdgui.gui_post("array is " + attr);
}
function attr_change(elem) {
var array_index, attr, arrays_select, name;
arrays_select = document.getElementById('arrays_select');
......@@ -456,26 +465,31 @@
function apply() {
var i, attrs;
var i, attrs, gop, hide_name;
pdgui.gui_post("we're applying shits!");
// Note: the "+" casts Boolean to Number
var gop = +document.getElementsByName('gop')[0].checked;
var hide_name = +document.getElementsByName('hide-name')[0].checked;
pdgui.pdsend([pd_object_callback, 'donecanvasdialog',
get_input('x-scale'),
get_input('y-scale'),
(gop + 2 * hide_name),
get_input('x1'),
get_input('y1'),
get_input('x2'),
get_input('y2'),
get_input('x-pix'),
get_input('y-pix'),
get_input('x-margin'),
get_input('y-margin'),
].join(' '));
// If this is a dialog to create a new array, we
// skip the canvas dialog callback
if (pd_garray_attrs.length < 1 || pd_garray_attrs[0][0] !== 'array_gfxstub')
{
// Note: the "+" casts Boolean to Number
gop = +document.getElementsByName('gop')[0].checked;
hide_name = +document.getElementsByName('hide-name')[0].checked;
pdgui.pdsend([pd_object_callback, 'donecanvasdialog',
get_input('x-scale'),
get_input('y-scale'),
(gop + 2 * hide_name),
get_input('x1'),
get_input('y1'),
get_input('x2'),
get_input('y2'),
get_input('x-pix'),
get_input('y-pix'),
get_input('x-margin'),
get_input('y-margin'),
].join(' '));
}
// Now send the array properties, in a separate
// message for each array
......@@ -564,7 +578,7 @@ pdgui.gui_post("guistub is " + gfxstub);
// we can create the menu and register event callbacks
function register_canvas_id(gfxstub, attr_arrays) {
pd_object_callback = gfxstub;
var canvas_fieldsets, i;
// attr_arrays[0]: canvas properties
// attr_arrays[1...n-1]: array properties
for (var i = 0; i < attr_arrays.length; i+=2) {
......@@ -574,8 +588,17 @@ pdgui.gui_post("guistub is " + gfxstub);
// not sure that we need this for properties windows
// pdgui.canvas_map(gfxstub);
translate_form();
populate_form(attr_arrays[0]);
init_arrays(attr_arrays.slice(1));
if (attr_arrays[0] === 'array_gfxstub') {
canvas_fieldsets = document.getElementsByClassName('canvas');
for (i = 0; i < canvas_fieldsets.length; i++) {
canvas_fieldsets[i].classList.add('hidden');
}
init_arrays([attr_arrays]);
} else {
populate_form(attr_arrays[0]);
init_arrays(attr_arrays.slice(1));
}
// We don't turn on rendering of the "container" div until
// We've finished displaying all the spans and populating the
// labels and form elements. That makes it more efficient and
......
......@@ -377,7 +377,7 @@ function nw_create_pd_window_menus () {
click: function() {
pdgui.pdsend("pd dsp 1");
},
key: 'c',
key: '/',
modifiers: "ctrl",
tooltip: l('menu.audio_on_tt')
}));
......@@ -387,7 +387,7 @@ function nw_create_pd_window_menus () {
click: function() {
pdgui.pdsend("pd dsp 0");
},
key: 'a',
key: '.',
modifiers: "ctrl",
tooltip: l('menu.audio_off_tt')
}));
......
......@@ -267,7 +267,9 @@
"array_outline": "outline color",
"array_outline_tt": "color for outline around the bars",
"array_fill": "fill color",
"array_fill_tt": "inner color of the bars"
"array_fill_tt": "inner color of the bars",
"array_in_existing_graph": "put in last graph",
"array_in_existing_graph_tt": "draw the array inside the last graph that was created. This is a way to have multiple arrays drawn in the same graph."
}
}
}
......@@ -931,7 +931,9 @@ proc menu_array {name} {
// Media sub-entries
mediaMenu.append(new nw.MenuItem({
label: l('menu.audio_on'),
click: menu_generic,
click: function() {
pdgui.pdsend("pd dsp 1");
},
key: '/',
modifiers: "ctrl",
tooltip: l('menu.audio_on_tt'),
......@@ -939,8 +941,10 @@ proc menu_array {name} {
mediaMenu.append(new nw.MenuItem({
label: l('menu.audio_off'),
click: menu_generic,
key: 'a',
click: function() {
pdgui.pdsend("pd dsp 0");
},
key: '.',
modifiers: "ctrl",
tooltip: l('menu.audio_off_tt'),
}));
......
......@@ -1859,6 +1859,7 @@ function gui_configure_item(cid, tag, attributes) {
// Most of these map either to pd.tk procs, or in some cases Tk canvas subcommands
function gui_text_create_gobj(cid, tag, type, xpos, ypos, is_toplevel) {
gui_post("creating a gobj");
var svg = get_item(cid, "patchsvg"); // "patchsvg" is id for the svg in the DOM
// Put objects on half-pixels to make them crisp (look in to the difference between
// this and the object-rendering 'crispEdges' attribute)
......@@ -2729,6 +2730,7 @@ function gui_create_scalar(cid, tag, isselected, t1, t2, t3, t4, t5, t6,
is_toplevel) {
gui_post("creating a scalar...");
gui_post("is_toplevel is " + is_toplevel);
gui_post("isselected is " + isselected);
// we should probably use create_gobj here, but we're doing some initial
// scaling that normal gobjs don't need...
var svg = get_item(cid, "patchsvg"); // "patchsvg" is id for the svg in the DOM
......@@ -3210,8 +3212,19 @@ function gui_iemgui_dialog(did, attr_array) {
}
function gui_create_array(did, gfxstub, count) {
function gui_create_array(did, count) {
gui_post("trying to create an array...");
var attr_array = [
"array_gfxstub", did,
"array_name", 'array' + count,
"array_size", 100,
"array_flags", 3,
"array_fill", 'black',
"array_outline", 'black',
"array_in_existing_graph", 0
];
dialogwin[did] = nw_create_window(did, 'canvas', 265, 540, 20, 20, 0,
0, 1, 'white', 'Properties', '', 0, null, attr_array);
}
function gui_canvas_dialog(did, attr_arrays) {
......@@ -3237,3 +3250,11 @@ gui_post("did is " + did + " and dialogwin[did] is " + dialogwin[did]);
dialogwin[did] = null;
}
}
// Global settings
function gui_pd_dsp(state) {
if (pd_window !== undefined) {
pd_window.document.getElementById('dsp_control').checked = !!state;
}
}
......@@ -130,7 +130,13 @@ Everything else:
the tag for this XLET is .x98be5e8.t99c0de0o0
remove gui_text_select_color (css takes care of this)
add a canvas message to set a transform on the patchsvg. Good for:
* obscure display needs (zooming past the browser limits)
* rotating for a display
* transforming or scaling all scalars on a patch at once
change 'array_element_fill' to 'element_fill', array_outline to 'array_element_outline'
either nw_create_window should take fewer parameters or it should take an
object with name: value pairs
Crashers
--------
......
......@@ -521,8 +521,8 @@ void canvas_menuarray(t_glist *canvas)
pd_vmess(&x->gl_pd, gensym("editmode"), "i", 1);
//char cmdbuf[200];
gcount++;
gui_vmess("gui_create_array", "ssi",
canvas_tag(x), gfxstub_new2(&x->gl_pd, x),
gui_vmess("gui_create_array", "si",
gfxstub_new2(&x->gl_pd, x),
gcount);
//sprintf(cmdbuf, "pdtk_array_dialog %%s array%d 100 3 1 .x%lx black black\n",
// ++gcount, (long unsigned int)canvas);
......
......@@ -1605,8 +1605,11 @@ static void canvas_dsp(t_canvas *x, t_signal **sp)
static void canvas_start_dsp(void)
{
t_canvas *x;
if (canvas_dspstate) ugen_stop();
else sys_gui("pdtk_pd_dsp ON\n");
if (canvas_dspstate)
ugen_stop();
else
//sys_gui("pdtk_pd_dsp ON\n");
gui_vmess("gui_pd_dsp", "i", 1);
ugen_start();
for (x = canvas_list; x; x = x->gl_next)
......@@ -1620,7 +1623,8 @@ static void canvas_stop_dsp(void)
if (canvas_dspstate)
{
ugen_stop();
sys_gui("pdtk_pd_dsp OFF\n");
//sys_gui("pdtk_pd_dsp OFF\n");
gui_vmess("gui_pd_dsp", "i", 0);
canvas_dspstate = 0;
}
}
......
......@@ -761,7 +761,6 @@ static void scalar_groupvis(t_scalar *x, t_glist *owner, t_template *template,
svg_grouptogui(gl, template, x->sc_vec);
gui_end_vmess();
//sys_gui("\n");
}
for (y = gl->gl_list; y; y = y->g_next)
{
......@@ -922,6 +921,7 @@ static void scalar_vis(t_gobj *z, t_glist *owner, int vis)
// we removed this because it caused infinite recursion
// in the scalar-help.pd example
//scalar_select(z, owner, 1);
post("here we are in scalar vis, selected...");
scalar_drawselectrect(x, owner, 0);
scalar_drawselectrect(x, owner, 1);
}
......
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