@@ -75,6 +75,7 @@ typedef struct _fwf{
7575 char x_waveformcolor [6 ];
7676 int x_linewidth ;
7777 char x_featurescolor [6 ];
78+ char x_mousedown ;
7879 t_symbol * x_fullname ;
7980 t_symbol * x_receive ;
8081 t_symbol * x_rcv_raw ;
@@ -164,7 +165,11 @@ static void fwf_motion(t_fwf *x, t_floatarg dx, t_floatarg dy){
164165 t_atom at [2 ];
165166 SETFLOAT (at , x -> x_x );
166167 SETFLOAT (at + 1 , x -> x_y );
167- outlet_anything (x -> x_obj .ob_outlet , & s_list , 2 , at );
168+ if (x -> x_mousedown ) {
169+ outlet_anything (x -> x_obj .ob_outlet , & s_list , 2 , at );
170+ if (x -> x_send != & s_ && x -> x_send -> s_thing )
171+ pd_list (x -> x_send -> s_thing , & s_list , 2 , at );
172+ }
168173}
169174
170175static int fwf_click (t_fwf * x , struct _glist * glist , int xpix , int ypix , int shift , int alt , int dbl , int doit ){
@@ -174,15 +179,16 @@ static int fwf_click(t_fwf *x, struct _glist *glist, int xpix, int ypix, int shi
174179 x -> x_x = CLIP ((xpix - xpos ) / x -> x_zoom ,0 ,x -> x_width );
175180 x -> x_y = CLIP (x -> x_height - (ypix - ypos ) / x -> x_zoom ,0 ,x -> x_height );
176181 if (doit ){//if mousedown
177- // SETFLOAT(at, (float)doit); // to send a click message if we want to eventually
178- // outlet_anything(x->x_obj.ob_outlet, gensym("click"), 1, at);
182+ x -> x_mousedown = 1 ;
179183 SETFLOAT (at , (float )x -> x_x );
180184 SETFLOAT (at + 1 , (float )x -> x_y );
181185 outlet_anything (x -> x_obj .ob_outlet , & s_list , 2 , at );
186+ if (x -> x_send != & s_ && x -> x_send -> s_thing )
187+ pd_list (x -> x_send -> s_thing , & s_list , 2 , at );
182188 // start streaming the coordinates
183189 glist_grab (x -> x_glist , & x -> x_obj .te_g , (t_glistmotionfn )fwf_motion , 0 , xpix , ypix );
184190 }
185- // else{// to send the coordinates on mouse up if we want to eventually
191+ // else{// to send the coordinates on hover if we want to eventually
186192 // SETFLOAT(at, (float)x->x_x);
187193 // SETFLOAT(at+1, (float)x->x_y);
188194 // outlet_anything(x->x_obj.ob_outlet, &s_list, 2, at);
@@ -191,12 +197,13 @@ static int fwf_click(t_fwf *x, struct _glist *glist, int xpix, int ypix, int shi
191197}
192198
193199static void fwf_mouserelease (t_fwf * x ){
194- // could do something here if needs be
195- // if(x->x_latch){
196- // outlet_float(x->x_outlet, -1);
197- // if(x->x_send != &s_ && x->x_send->s_thing)
198- // pd_float(x->x_send->s_thing, -1);
199- // }
200+ x -> x_mousedown = 0 ;
201+ if (x -> x_latch ) {
202+ t_symbol * mouseup = gensym ("mouseup" );
203+ outlet_symbol (x -> x_obj .ob_outlet , mouseup );
204+ if (x -> x_send != & s_ && x -> x_send -> s_thing )
205+ pd_symbol (x -> x_send -> s_thing , mouseup );
206+ };
200207}
201208
202209static void fwf_getrect (t_gobj * z , t_glist * glist , int * xp1 , int * yp1 , int * xp2 , int * yp2 ){
@@ -249,16 +256,16 @@ static void fwf_draw(t_fwf* x, struct _glist *glist, int vis){
249256 int xpos = text_xpix (& x -> x_obj , x -> x_glist ), ypos = text_ypix (& x -> x_obj , x -> x_glist );
250257 int visible = (glist_isvisible (x -> x_glist ) && gobj_shouldvis ((t_gobj * )x , x -> x_glist ));
251258 if (x -> x_def_img && (visible || (_Bool )vis )){ // DEFAULT LOAD STATE AS FRAME
252- sys_vgui (".x%lx.c create rectangle %d %d %d %d -tags %lx_outline -outline black -width %d\n" ,
253- cv , xpos , ypos , xpos + x -> x_width * x -> x_zoom , ypos + x -> x_height * x -> x_zoom , x , x -> x_zoom );
259+ sys_vgui (".x%lx.c create rectangle %d %d %d %d -tags %lx_outline -outline black -width %d -fill white -tags %lx_picture \n" ,
260+ cv , xpos , ypos , xpos + x -> x_width * x -> x_zoom , ypos + x -> x_height * x -> x_zoom , x , x -> x_zoom , x );
254261 }
255262 else {
256263 if (visible || (_Bool )vis ){
257264 if (x -> x_edit || x -> x_outline )
258265 sys_vgui (".x%lx.c create rectangle %d %d %d %d -tags %lx_outline -outline black -width %d\n" ,
259266 cv , xpos , ypos , xpos + x -> x_width * x -> x_zoom , ypos + x -> x_height * x -> x_zoom , x , x -> x_zoom );
260- sys_vgui ("if { [info exists %lx_picname] == 1 } { .x%lx.c create image %d %d -anchor nw -image %lx_picname -tags %lx_picture\n} \n" ,
261- x -> x_fullname , cv , xpos , ypos , x -> x_fullname , x );
267+ sys_vgui ("if { [info exists %lx_picname] == 1 } { .x%lx.c create image %d %d -anchor nw -image %lx_picname -tags %lx_picture\n} else { .x%lx.c create rectangle %d %d %d %d -width %d -outline %s -fill white -tags %lx_picture\n} \n" ,
268+ x -> x_fullname , cv , xpos , ypos , x -> x_fullname , x , cv , xpos , ypos , xpos + x -> x_width * x -> x_zoom , ypos + x -> x_height * x -> x_zoom , x -> x_zoom , x -> x_outline ? "black" : "white" , x );
262269 sys_vgui ("if { [info exists %lx_audiopeaks] == 1 } { for { set index 0 } { $index < [llength $%lx_audiopeaks] } { incr index 4 } { .x%lx.c create line [expr [lindex $%lx_audiopeaks $index] + %d] [expr [lindex $%lx_audiopeaks [expr $index + 1]] + %d] [expr [lindex $%lx_audiopeaks [expr $index + 2]] + %d] [expr [lindex $%lx_audiopeaks [expr $index + 3]] + %d] -tags %lx_waveform -fill #%s\n}\n}\n" ,
263270 x -> x_fullname , x -> x_fullname , cv , x -> x_fullname , xpos , x -> x_fullname , ypos , x -> x_fullname , xpos , x -> x_fullname , ypos , x , x -> x_waveformcolor );
264271 sys_vgui ("if { [info exists %lx_featurespeaks] == 1 } { set scaledfeatures {} \n foreach {i j} $%lx_featurespeaks {lappend scaledfeatures [expr $i + %d] \n lappend scaledfeatures [expr $j + %d] \n} \n for {set chans 0} {$chans < $%lx_featurescount} {incr chans} { .x%lx.c create line [lrange $scaledfeatures [expr $chans * $%lx_featureslen] [expr (($chans + 1) * $%lx_featureslen) - 1]] -tags %lx_features -width %d -fill #%s\n} \n unset scaledfeatures \n}\n" ,
@@ -1172,7 +1179,7 @@ void setup_fluid0x2ewaveform(void){
11721179 sys_vgui (" pack $id.tics -side top\n" );
11731180 sys_vgui (" label $id.tics.loutline -text \"Outline:\"\n" );
11741181 sys_vgui (" checkbutton $id.tics.outline -variable $var_outline \n" );
1175- sys_vgui (" label $id.tics.llatch -text \" Latch Mode :\"\n" );//dirty pad
1182+ sys_vgui (" label $id.tics.llatch -text \" Mouse Up :\"\n" );//dirty pad
11761183 sys_vgui (" checkbutton $id.tics.latch -variable $var_latch \n" );
11771184 sys_vgui (" pack $id.tics.loutline $id.tics.outline $id.tics.llatch $id.tics.latch -side left\n" );
11781185 sys_vgui ("\n" );
0 commit comments