Skip to content

Commit fad10c8

Browse files
committed
waveform and plotter: fix the mouseup reporting and adds a mouseup option
1 parent 58b3c10 commit fad10c8

File tree

5 files changed

+89
-21
lines changed

5 files changed

+89
-21
lines changed

local_docs/fluid.plotter.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,59 @@ <h3 class="outlet_name">1<span class="type"> [list]</span></h3>
9191
</section>
9292
<section class="argument_section">
9393
<h2>Arguments</h2>
94+
<h3 class="argument_name">width<span class="type"> [int]</span></h3>
95+
<span class="defaultval"> (default: 10)</span>
96+
<div class="description">The width of the object.</div>
97+
<h3 class="argument_name">heigth<span class="type"> [int]</span></h3>
98+
<span class="defaultval"> (default: 10)</span>
99+
<div class="description">The height of the object.</div>
100+
<h3 class="argument_name">outline<span class="type"> [int]</span></h3>
101+
<div class="optional">Optional</div>
102+
<span class="defaultval"> (default: 0)</span>
103+
<div class="description">A flag to draw the frame around the object.</div>
104+
<h3 class="argument_name">mouseup<span class="type"> [int]</span></h3>
105+
<div class="optional">Optional</div>
106+
<span class="defaultval"> (default: 0)</span>
107+
<div class="description">A flag to send a value on mouse up.</div>
108+
<h3 class="argument_name">send<span class="type"> [symbol]</span></h3>
109+
<div class="optional">Optional</div>
110+
<span class="defaultval"> (default: empty)</span>
111+
<div class="description">The name of the object for receiving messages.</div>
112+
<h3 class="argument_name">receive<span class="type"> [symbol]</span></h3>
113+
<div class="optional">Optional</div>
114+
<span class="defaultval"> (default: empty)</span>
115+
<div class="description">The name of the object on which it will send its mousing values.</div>
94116
</section>
95117
<section class="attribute_section">
96118
<h2>Attributes</h2>
119+
<div class="attribute_group">
120+
<h3 class="attribute_name">outline
121+
<span class="type"> [int]</span>
122+
<span class="defaultval"> (default: 0)</span>
123+
</h3>
124+
<div class="description">A flag to draw the frame around the object.</div>
125+
</div>
126+
<div class="attribute_group">
127+
<h3 class="attribute_name">send
128+
<span class="type"> [symbol]</span>
129+
<span class="defaultval"> (default: empty)</span>
130+
</h3>
131+
<div class="description">The name of the object for receiving messages.</div>
132+
</div>
133+
<div class="attribute_group">
134+
<h3 class="attribute_name">receive
135+
<span class="type"> [symbol]</span>
136+
<span class="defaultval"> (default: empty)</span>
137+
</h3>
138+
<div class="description">The name of the object on which it will send its mousing values.</div>
139+
</div>
140+
<div class="attribute_group">
141+
<h3 class="attribute_name">mouseup
142+
<span class="type"> [int]</span>
143+
<span class="defaultval"> (default: 0)</span>
144+
</h3>
145+
<div class="description">A flag to send a 'mouseup' symbol on mouse up.</div>
146+
</div>
97147
</section>
98148
<section class="method_section">
99149
<h2>Messages</h2>

local_docs/fluid.waveform.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ <h3 class="argument_name">receive<span class="type"> [symbol]</span></h3>
107107
<div class="optional">Optional</div>
108108
<span class="defaultval"> (default: empty)</span>
109109
<div class="description">The name of the object on which it will send its mousing values.</div>
110-
<h3 class="argument_name">latch<span class="type"> [int]</span></h3>
110+
<h3 class="argument_name">mouseup<span class="type"> [int]</span></h3>
111111
<div class="optional">Optional</div>
112112
<span class="defaultval"> (default: 0)</span>
113113
<div class="description">A flag to send a value on mouse up.</div>
@@ -136,11 +136,11 @@ <h3 class="attribute_name">receive
136136
<div class="description">The name of the object on which it will send its mousing values.</div>
137137
</div>
138138
<div class="attribute_group">
139-
<h3 class="attribute_name">latch
139+
<h3 class="attribute_name">mouseup
140140
<span class="type"> [int]</span>
141141
<span class="defaultval"> (default: 0)</span>
142142
</h3>
143-
<div class="description">A flag to send a value on mouse up.</div>
143+
<div class="description">A flag to send a 'mouseup' symbol on mouse up.</div>
144144
</div>
145145
</section>
146146
<section class="method_section">

scripts/pd-linker-flags.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
-Wl,-U,_outlet_new
2222
-Wl,-U,_outlet_list
2323
-Wl,-U,_outlet_bang
24+
-Wl,-U,_outlet_symbol
2425
-Wl,-U,_outlet_float
2526
-Wl,-U,_outlet_anything
2627
-Wl,-U,_signalinlet_new
@@ -64,6 +65,7 @@
6465
-Wl,-U,_pd_bang
6566
-Wl,-U,_pd_float
6667
-Wl,-U,_pd_list
68+
-Wl,-U,_pd_symbol
6769
-Wl,-U,_text_getbufbyname
6870
-Wl,-U,_binbuf_getvec
6971
-Wl,-U,_binbuf_getnatom

src/fluid.plotter/fluid.plotter.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ static void fplot_motion(t_fplot *x, t_floatarg dx, t_floatarg dy){
188188
pd_list(x->x_send->s_thing, &s_list, 2, at);
189189
} else if (x->x_clicktype == 1) {
190190
fplot_draw(x, x->x_glist, 1, 0);
191+
} else if (x->x_clicktype == -1) {
192+
x->x_clicktype == 0;
191193
}
192194
}
193195

@@ -257,9 +259,16 @@ static void fplot_mouserelease(t_fplot* x){
257259
x->x_y_range = fabsf(x->x_y_s_temp - scaledY) * -1.0;
258260
}
259261

260-
x->x_clicktype = 0;
262+
x->x_clicktype = -1;
261263
fplot_draw(x, x->x_glist, 1, 0);
262-
}
264+
} else x->x_clicktype = -1;
265+
266+
if (x->x_latch) {
267+
t_symbol *mouseup = gensym("mouseup");
268+
outlet_symbol(x->x_obj.ob_outlet, mouseup);
269+
if(x->x_send != &s_ && x->x_send->s_thing)
270+
pd_symbol(x->x_send->s_thing, mouseup);
271+
};
263272
}
264273

265274
static void fplot_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2){
@@ -868,7 +877,7 @@ void setup_fluid0x2eplotter(void){
868877
sys_vgui(" pack $id.tics -side top\n");
869878
sys_vgui(" label $id.tics.loutline -text \"Outline:\"\n");
870879
sys_vgui(" checkbutton $id.tics.outline -variable $var_outline \n");
871-
sys_vgui(" label $id.tics.llatch -text \" Latch Mode:\"\n");//dirty pad
880+
sys_vgui(" label $id.tics.llatch -text \" Mouse Up:\"\n");//dirty pad
872881
sys_vgui(" checkbutton $id.tics.latch -variable $var_latch \n");
873882
sys_vgui(" pack $id.tics.loutline $id.tics.outline $id.tics.llatch $id.tics.latch -side left\n");
874883
sys_vgui("\n");

src/fluid.waveform/fluid.waveform.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

170175
static 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

193199
static 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

202209
static 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

Comments
 (0)