Commit 45587416 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

add garray labels to graphs

fix feature for putting array in existing graph
add a delete checkbox for graphs with multiple arrays
parent 062158e8
......@@ -241,11 +241,24 @@
data-i18n="[title]canvas.prop.array_in_existing_graph_tt">
<input onchange="flag2_change(this);"
type="checkbox"
id="array_in_existing_graph"
name="array_in_existing_graph"
value="on">
<span data-i18n="canvas.prop.array_in_existing_graph"></span>
</label>
</div>
<div class="array_delete">
<label class="array-delete"
data-i18n="[title]canvas.prop.array_delete_tt">
<input onchange="array_delete_change(this);"
type="checkbox"
id="array_delete"
name="array_delete"
value="on">
<span data-i18n="canvas.prop.array_delete"></span>
</label>
</div>
</fieldset>
<div class="submit_buttons">
......@@ -345,6 +358,12 @@ function flag2_change(elem) {
pdgui.gui_post("array is " + array_attr);
}
function array_delete_change(elem) {
var arrays_select = document.getElementById('arrays_select'),
array_attr = pd_garray_attrs[arrays_select.value];
array_attr.array_delete = elem.checked;
}
function attr_change(elem) {
var array_index, array_attr, arrays_select, name;
arrays_select = document.getElementById('arrays_select');
......@@ -482,8 +501,28 @@ function get_array_value(name, attrs) {
return attrs[name];
}
// for a new array, slot 4 is:
// "0" to create the array in a new graph
// "1" to create the array in existing graph
// for a graph with more than one array in it, slot 4 is:
// "0" to do nothing
// "1" to delete the array when the dialog is finished
// The deletion interface is bad, but it is also an obscure
// feature probably not worth improving.
function get_array_slot_4(attrs) {
if (new_array_dialog) {
return document.getElementById('array_in_existing_graph').checked ?
"1" : "0";
} else if (pd_garray_attrs.length > 1) {
return attrs.array_delete ? "1" : "0";
} else {
return "0";
}
}
function apply() {
var i, attrs, gop, hide_name;
var i, attrs, gop, hide_name, slot_4;
// If this is a dialog to create a new array, we
// skip the canvas dialog callback
if (!new_array_dialog) {
......@@ -520,8 +559,7 @@ function apply() {
name,
get_array_value('array_size', attrs),
get_array_value('array_flags', attrs),
0, // create an array in a new graph -- we don't
// need this in a prexisting graph
get_array_slot_4(attrs),
0, // xdraw-- not sure if this is still used
0, // ydraw-- not sure if this is still used
get_array_value('array_fill', attrs),
......@@ -544,12 +582,12 @@ function cancel() {
}
function populate_array_form(objects) {
var arrays_select, a_field = document.getElementById('arrays');
var i, opt;
var arrays_select = document.getElementById('arrays_select'),
a_field = document.getElementById('arrays'),
opt, i;
a_field.classList.remove('hidden');
arrays_select = document.getElementById('arrays_select');
if (i > 0) {
// unhide select element if there's more than one array
if (objects.length > 1) {
// show the select element if there's more than one array
arrays_select.classList.remove('hidden');
}
for (i = 0; i < objects.length; i++) {
......@@ -563,6 +601,11 @@ function populate_array_form(objects) {
document.getElementsByClassName('array_in_existing_graph')[0]
.classList.add('hidden');
}
// Hide the "delete this array" button if we don't have
// more than one array
if (new_array_dialog || objects.length < 2) {
document.getElementsByClassName('array_delete')[0].classList.add('hidden');
}
array_choose(0);
}
......
......@@ -289,7 +289,9 @@
"array_fill": "fill color",
"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."
"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.",
"array_delete": "delete this array",
"array_delete_tt": "delete this array (i.e., remove it from the graph) when you click Ok"
}
},
"prefs": {
......
......@@ -2543,8 +2543,10 @@ function gui_graph_deleteborder(cid, tag) {
b.parentNode.removeChild(b);
}
function gui_graph_label(cid, tag, y, array_name, font, font_size,
font_weight, is_selected) {
function gui_graph_label(cid, tag, label_number, font_height, array_name,
font, font_size, font_weight, is_selected) {
var y = font_height * label_number * -1;
gui_text_new(cid, tag, "graph_label", 0, 0, y, array_name, font_size);
}
function gui_graph_vtick(cid, tag, x, up_y, down_y, tick_pix, basex, basey) {
......
......@@ -646,10 +646,11 @@ void garray_arraydialog(t_garray *x, t_symbol *s, int argc, t_atom *argv)
//glist_select(x->x_glist, &x->x_gobj);
//canvas_undo_add(x->x_glist, 3, "delete", canvas_undo_set_cut(x->x_glist, 2)); // 2 = UCUT_CLEAR (from g_editor.c)
//currently cannot be undo'd until we do a new kind of undo
t_canvas *c = x->x_glist;
int dspwas = canvas_suspend_dsp();
glist_delete(x->x_glist, &x->x_gobj);
canvas_resume_dsp(dspwas);
canvas_redraw(glist_getcanvas(x->x_glist));
canvas_redraw(glist_getcanvas(c));
}
else
{
......
......@@ -980,7 +980,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
"none",
0, x1, y1, x2, y2);
/* write garrays' names along the top */
for (i = (y1 < y2 ? y1 : y2)-1, g = x->gl_list; g; g = g->g_next)
for (i = 0, g = x->gl_list; g; g = g->g_next, i++)
{
//fprintf(stderr,".\n");
//if (g->g_pd == garray_class)
......@@ -996,17 +996,16 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
// tag,
// (glist_isselected(x, gr) ?
// "$pd_colors(selection)" : "$pd_colors(graph_border)"));
gui_vmess("gui_graph_label", "xsissisi",
gui_vmess("gui_graph_label", "xsiissisi",
glist_getcanvas(x),
tag,
i,
sys_fontheight(glist_getfont(x)),
arrayname->s_name,
sys_font,
sys_hostfontsize(glist_getfont(x)),
sys_fontweight,
glist_isselected(x, gr));
i += sys_fontheight(glist_getfont(x));
}
}
/* draw ticks on horizontal borders. If lperb field is
......
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