From 35a664c6226e9cf100c78e47bd6a4eff4d5e158a Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Mon, 2 May 2016 19:48:24 -0400 Subject: [PATCH] fix svg_free_events to only free "drag" events (the others are automatically gc'd) --- .../pd-l2ork/ds-demos/curve-bbox.pd | 20 -------- pd/src/g_template.c | 51 ++++--------------- 2 files changed, 9 insertions(+), 62 deletions(-) delete mode 100644 pd/doc/4.data.structures/pd-l2ork/ds-demos/curve-bbox.pd diff --git a/pd/doc/4.data.structures/pd-l2ork/ds-demos/curve-bbox.pd b/pd/doc/4.data.structures/pd-l2ork/ds-demos/curve-bbox.pd deleted file mode 100644 index 70597c767..000000000 --- a/pd/doc/4.data.structures/pd-l2ork/ds-demos/curve-bbox.pd +++ /dev/null @@ -1,20 +0,0 @@ -#N struct curvebbox float x float y; -#N canvas 0 19 619 300 10; -#X obj 151 34 struct curvebbox float x float y; -#X scalar curvebbox 71 53 \;; -#X text 197 181 Short demo showing that Pd should find the correct -bounding box for a transformed scalar in edit-mode.; -#X text 197 221 Unfortunately it doesn't quite get it right for curves. -You can see with rotation at some angles it doesn't include part of -the curve.; -#N canvas 433 184 450 300 (subpatch) 0; -#X floatatom 163 116 5 0 0 0 - - -, f 5; -#X obj 163 160 draw path M 20 120 C 20 30 40 50 60 70; -#X msg 163 137 transform rotate \$1; -#X connect 0 0 2 0; -#X connect 2 0 1 0; -#X restore 417 94 group; -#X floatatom 408 21 5 0 0 0 - - -, f 5; -#X msg 408 42 transform translate \$1 0; -#X connect 5 0 6 0; -#X connect 6 0 4 0; diff --git a/pd/src/g_template.c b/pd/src/g_template.c index f02bc835c..578b3e725 100644 --- a/pd/src/g_template.c +++ b/pd/src/g_template.c @@ -4262,48 +4262,15 @@ t_parentwidgetbehavior draw_widgetbehavior = static void svg_free_events(t_svg *x) { - /* This is pretty simplistic-- if the flag is set then we set the - event to zero and send the update to the GUI. */ - if (x->x_events.e_focusin.a_flag == 1) - { - fielddesc_setfloat_const(&x->x_events.e_focusin.a_attr, 0); - svg_update(x, gensym("focusin")); - } - if (x->x_events.e_activate.a_flag == 1) - { - fielddesc_setfloat_const(&x->x_events.e_activate.a_attr, 0); - svg_update(x, gensym("focusout")); - } - if (x->x_events.e_click.a_flag == 1) - { - fielddesc_setfloat_const(&x->x_events.e_click.a_attr, 0); - svg_update(x, gensym("click")); - } - if (x->x_events.e_mousedown.a_flag == 1) - { - fielddesc_setfloat_const(&x->x_events.e_mousedown.a_attr, 0); - svg_update(x, gensym("mousedown")); - } - if (x->x_events.e_mouseup.a_flag == 1) - { - fielddesc_setfloat_const(&x->x_events.e_mouseup.a_attr, 0); - svg_update(x, gensym("mouseup")); - } - if (x->x_events.e_mouseover.a_flag == 1) - { - fielddesc_setfloat_const(&x->x_events.e_mouseover.a_attr, 0); - svg_update(x, gensym("mouseover")); - } - if (x->x_events.e_mousemove.a_flag == 1) - { - fielddesc_setfloat_const(&x->x_events.e_mousemove.a_attr, 0); - svg_update(x, gensym("mousemove")); - } - if (x->x_events.e_mouseout.a_flag == 1) - { - fielddesc_setfloat_const(&x->x_events.e_mouseout.a_attr, 0); - svg_update(x, gensym("mouseout")); - } + /* Right now all the events except for "drag" get automatically + garbage collected in the GUI. + The reason "drag" does not is that it's a kind of "meta-event"-- + we keep a reference to the "draggable" object and check for it + on clicking the canvas. The benefit is there's a single, centralized + set of canvas events instead of event listeners for each scalar. + Drawback is that we have to manage destroying the "drag" references + in the GUI. But eventually all scalar events should be handled this + way... */ if (x->x_events.e_drag.a_flag == 1) { fielddesc_setfloat_const(&x->x_events.e_drag.a_attr, 0); -- GitLab