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

more work on "Cancel" functionality for iemguis-- selectively set undo point

parent 74942878
......@@ -372,12 +372,13 @@ function update_attr(elem) {
//Clean up strings to send as symbol arguments to Pd
function pd_symbol_carwash(s) {
s = (s === "" || !s) ? "empty" : s;
s = !s ? "empty" : s;
if (s.charAt(0) === "$") {
s = "#" + s.slice(1);
}
s = substitute_space(s);
s = strip_problem_chars(s);
return s;
}
function send_params(attrs, create_undo_point) {
......@@ -391,13 +392,12 @@ function send_params(attrs, create_undo_point) {
iemgui_clip_fontsize $id
*/
pdgui.post("label is " + attrs["label"]);
var send_symbol = attrs["send-symbol"],
receive_symbol = attrs["receive-symbol"],
label = attrs["label"];
pd_symbol_carwash(send_symbol);
pd_symbol_carwash(receive_symbol);
pd_symbol_carwash(label);
send_symbol = pd_symbol_carwash(send_symbol);
receive_symbol = pd_symbol_carwash(receive_symbol);
label = pd_symbol_carwash(label);
var label_x_offset = attrs["x-offset"];
var label_y_offset = attrs["y-offset"];
......@@ -439,7 +439,7 @@ pdgui.post("label is " + attrs["label"]);
if (!slot3) { // toggle
slot3 = attrs["nonzero-value"];
if (slot3 === "") {
if (!slot3) {
slot3 = 0;
}
slot4 = 0;
......@@ -474,7 +474,9 @@ pdgui.post("label is " + attrs["label"]);
var font_size = attrs["font-size"];
if (!font_size) { font_size = 0; }
var foreground_color = attrs["foreground-color"];
// [vu] doesn't have a foreground color
var foreground_color = attrs["foreground-color"] ?
attrs["foreground-color"] : 0;
var background_color = attrs["background-color"];
var label_color = attrs["label-color"];
......@@ -500,7 +502,9 @@ pdgui.post("label is " + attrs["label"]);
background_color, foreground_color,
label_color,
slot18, // steady on click
0);
0, // not sure what this is doing here
create_undo_point ? 1 : 0 // whether we set an undo point
);
}
function cancel(revert_changes) {
......@@ -528,6 +532,8 @@ function ok() {
// Steal focus from any active input to make sure it triggers an
// onchange event
document.querySelector("button").focus();
// send the old attrs first so we can set an undo point on them
send_params(old_attrs, false);
send_params(new_attrs, true);
cancel(false);
}
......
......@@ -346,7 +346,8 @@ static void bng_bang2(t_bng *x)/*wird immer gesendet, wenn moeglich*/
static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv)
{
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
if (atom_getintarg(19, argc, argv))
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
x->x_gui.x_h = x->x_gui.x_w = atom_getintarg(0, argc, argv);
int fthold = atom_getintarg(2, argc, argv);
int ftbreak = atom_getintarg(3, argc, argv);
......
......@@ -224,7 +224,8 @@ static void my_canvas_get_pos(t_my_canvas *x)
static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv)
{
//printf("cnv_dialog: selected=%d\n",x->x_gui.x_selected);
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
if (atom_getintarg(19, argc, argv))
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
//printf("cnv_dialog: selected=%d\n",x->x_gui.x_selected);
x->x_gui.x_h =
x->x_gui.x_w = maxi(atom_getintarg(0, argc, argv),1);
......
......@@ -500,7 +500,8 @@ static void my_numbox_bang(t_my_numbox *x)
static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc,
t_atom *argv)
{
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
if (atom_getintarg(19, argc, argv))
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
x->x_gui.x_w = maxi(atom_getintarg(0, argc, argv),1);
x->x_gui.x_h = maxi(atom_getintarg(1, argc, argv),8);
double min = atom_getfloatarg(2, argc, argv);
......
......@@ -273,7 +273,8 @@ static void radio_properties(t_gobj *z, t_glist *owner)
static void radio_dialog(t_radio *x, t_symbol *s, int argc, t_atom *argv)
{
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
if (atom_getintarg(19, argc, argv))
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
x->x_gui.x_h =
x->x_gui.x_w = iemgui_clip_size(atom_getintarg(0, argc, argv));
x->x_change = !!atom_getintarg(4, argc, argv);
......
......@@ -319,7 +319,8 @@ static void slider_bang(t_slider *x)
static void slider_dialog(t_slider *x, t_symbol *s, int argc, t_atom *argv)
{
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
if (atom_getintarg(19, argc, argv))
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
int w = atom_getintarg(0, argc, argv);
int h = atom_getintarg(1, argc, argv);
double min = atom_getfloatarg(2, argc, argv);
......
......@@ -263,7 +263,8 @@ static void toggle_bang(t_toggle *x)
static void toggle_dialog(t_toggle *x, t_symbol *s, int argc, t_atom *argv)
{
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
if (atom_getintarg(19, argc, argv))
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
x->x_gui.x_h =
x->x_gui.x_w = iemgui_clip_size(atom_getintarg(0, argc, argv));
t_float nonzero = atom_getfloatarg(2, argc, argv);
......
......@@ -529,7 +529,8 @@ static void vu_properties(t_gobj *z, t_glist *owner)
static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv)
{
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
if (atom_getintarg(19, argc, argv))
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
int w = atom_getintarg(0, argc, argv);
int h = atom_getintarg(1, argc, argv);
......
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