Commit 31b8c939 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*updated ggee/image to make it capable of ignoring clicks as it should, added...

*updated ggee/image to make it capable of ignoring clicks as it should, added new features, like gopspill_size and click, updated its help file to reflect this.
parent e28046aa
#N canvas 0 26 462 618 10;
#N canvas 429 34 607 627 10;
#X obj 74 489 ggee/image @pd_extra/ggee/logo100.gif 0;
#X text 26 12 Incorporate images. This is instantiated with;
#X text 26 25 [image logo100.gif];
#X text 38 14 Incorporate images. This is instantiated with;
#X text 38 34 [image logo100.gif];
#X msg 40 395 open \$1;
#X obj 40 351 bng 15 250 50 0 empty empty empty 0 -6 0 10 -4034 -1
-1;
......@@ -15,23 +15,35 @@ Wilkes for Pd version 0.42.;
#X text 12 85 OUTLET_0 bang;
#X text 12 105 AUTHOR Ivica Ico Bukvic \, based on Guenter Geiger's
image;
#X text 12 65 INLET_0 open gopspill;
#X restore 405 590 pd META;
#X obj 162 490 ggee/image @pd_extra/ggee/logo100.gif 1;
#X text 12 65 INLET_0 open gopspill gopspill_size click;
#X restore 550 603 pd META;
#X obj 162 489 ggee/image @pd_extra/ggee/logo100.gif 1;
#X obj 155 348 loadbang;
#X msg 155 371 1;
#X msg 155 395 gopspill \$1;
#X floatatom 184 371 5 0 0 0 - - -, f 5;
#X obj 257 448 ggee/image @pd_extra/ggee/empty_image.png 0;
#X msg 245 395 open \$1;
#X obj 245 351 bng 15 250 50 0 empty empty empty 0 -6 0 10 -4034 -1
#X obj 259 558 ggee/image @pd_extra/ggee/empty_image.png 0;
#X msg 247 505 open \$1;
#X obj 247 461 bng 15 250 50 0 empty empty empty 0 -6 0 10 -4034 -1
-1;
#X obj 245 372 openpanel;
#X text 26 48 [image] works with .gif \, .ppm \, .pgm and .png image
formats only.;
#X text 274 425 this is how an empty image looks like when created without
#X obj 247 482 openpanel;
#X text 38 50 [image] works with .gif \, .ppm \, .pgm and .png image
formats only., f 64;
#X text 276 535 this is how an empty image looks like when created without
any parameters;
#X text 27 83 Pd-L2Ork version of [image] also has a special feature
#X msg 352 483 click \$1;
#X obj 352 463 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 247 582 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X msg 101 291 click \$1;
#X obj 101 271 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 155 548 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X text 413 466 toggling click on enables object to capture clicks and
broadcast them as bangs via its only outlet;
#X text 39 85 Pd-L2Ork version of [image] also has a special feature
that allows its reported rectangle to be smaller \, so it can be used
as a decoration for a graph-on-parent abstraction that may potentially
spill beyond the grap-on-parent rectangle (as is the case with K12
......@@ -39,15 +51,32 @@ mode). To invoke this mode \, pass a "gopspill 0/1" message into the
object or create it by giving it an optional argument \, 0=off(default)
\, 1=on. Filename is always first optional argument and the float argument
second. In the absence of a symbol (string) filename \, the float value
will be treated as the gopspill argument. For instance: [image logo100.gif
1] [image logo100.gif 0] is synonymous to [image logo100.gif];
will be treated as the gopspill argument. For instance: [image logo100.gif
1] [image logo100.gif 0] is synonymous to [image logo100.gif], f
86;
#X text 162 272 notice how the click area (when toggled on) only exists
within the inner gop spill area of 15x15 (enter edit mode and select
the object to observe its selection area;
#X msg 239 395 gopspill_size \$1 \$1;
#X floatatom 239 363 5 0 0 0 - - -, f 5;
#X text 275 349 you can also set the gopspill size (default 15). Values
less than or equal to 3 will be silently ignored. Float values will
be rounded., f 49;
#X connect 3 0 0 0;
#X connect 4 0 5 0;
#X connect 5 0 3 0;
#X connect 7 0 23 0;
#X connect 8 0 9 0;
#X connect 9 0 10 0;
#X connect 10 0 7 0;
#X connect 11 0 10 0;
#X connect 12 0 20 0;
#X connect 13 0 12 0;
#X connect 14 0 15 0;
#X connect 15 0 13 0;
#X connect 18 0 12 0;
#X connect 19 0 18 0;
#X connect 21 0 7 0;
#X connect 22 0 21 0;
#X connect 27 0 7 0;
#X connect 28 0 27 0;
......@@ -22,6 +22,8 @@ typedef struct _image
int x_img_width;
int x_img_height;
int x_gop_spill;
int x_click;
//t_float x_clicked;
t_symbol* x_fname;
t_symbol* x_receive;
//int x_selected;
......@@ -110,6 +112,7 @@ static void image_getrect(t_gobj *z, t_glist *glist,
{
int width, height;
t_image* x = (t_image*)z;
//printf("image_getrect %d %d\n", *xp1, *yp1);
if (!x->x_gop_spill && (x->x_img_width + x->x_img_height) >= 2) {
width = x->x_img_width;
......@@ -122,6 +125,22 @@ static void image_getrect(t_gobj *z, t_glist *glist,
*yp1 = text_ypix(&x->x_obj, glist) - height/2;
*xp2 = text_xpix(&x->x_obj, glist) + width/2;
*yp2 = text_ypix(&x->x_obj, glist) + height/2;
// if we have click detection disabled and we are in runmode,
// return 0 size to allow for click relegation to hidden objects below
// CAREFUL: this code is not reusable for objects that have more than
// one inlet or outlet because it will cram them together
if ((glist_getcanvas(glist) != glist && !x->x_click) || (!glist->gl_edit && !x->x_click))
{
*xp2 = *xp1;
// only if we have an image loaded and we are placed within a GOP obliterate the height
//if (glist_getcanvas(glist) != glist && (x->x_img_width + x->x_img_height) >= 2)
//{
//printf("blah\n");
//*yp2 = *yp1;
//}
}
//fprintf(stderr,"image_getrect %d %d %d %d\n", *xp1, *yp1, *xp2, *yp2);
}
......@@ -269,18 +288,51 @@ t_widgetbehavior image_widgetbehavior;
}*/
/*static int image_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
static int image_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
{
//printf("doit=%d\n", doit);
t_image *x = (t_image *)z;
if (doit)
if (doit && x->x_click)
outlet_bang(x->x_obj.ob_outlet);
// LATER: figure out how to do click on and click off
// and provide a toggle button behavior insteadS
/*{
x->x_clicked = 1;
outlet_float(x->x_obj.ob_outlet, x->x_clicked);
}
else if (x->x_clicked)
{
x->x_clicked = 0;
outlet_float(x->x_obj.ob_outlet, x->x_clicked);
}*/
return(1);
}*/
}
static void image_click(t_image *x, t_float f)
{
if (f == 0)
x->x_click = 0;
else if (f == 1)
x->x_click = 1;
}
void image_gop_spill(t_image* x, t_floatarg f)
{
x->x_gop_spill = (f >= 0 ? f : 0);
image_displace((t_gobj*)x, x->x_glist, 0.0, 0.0);
x->x_gop_spill = (f >= 0 ? f : 0);
image_displace((t_gobj*)x, x->x_glist, 0.0, 0.0);
}
void image_gop_spill_size(t_image* x, t_floatarg f)
{
//printf("image_gop_spill_size=%d\n", (int)f);
// we need a size of at least 3 to have a meaningful
// selection frame around the selection box
if ((int)f >= 3)
{
x->x_width = (int)f;
x->x_height = x->x_width;
image_displace((t_gobj*)x, x->x_glist, 0.0, 0.0);
}
}
void image_open(t_image* x, t_symbol *s, t_int argc, t_atom *argv)
......@@ -308,10 +360,11 @@ static void image_imagesize_callback(t_image *x, t_float w, t_float h) {
image_erase(x, glist_getcanvas(x->x_glist));
} else {
//sys_vgui("catch {.x%x.c delete %xMT}\n", glist_getcanvas(x->x_glist), x);
//if (x->x_selected) {
//image_select((t_gobj *)x, glist_getcanvas(x->x_glist), 0);
//image_select((t_gobj *)x, glist_getcanvas(x->x_glist), 1);
//}
// reselect if we are on a toplevel canvas to adjust the selection rectangle, if necessary
if (glist_isselected(x->x_glist, (t_gobj *)x) && glist_getcanvas(x->x_glist) == x->x_glist) {
image_select((t_gobj *)x, glist_getcanvas(x->x_glist), 0);
image_select((t_gobj *)x, glist_getcanvas(x->x_glist), 1);
}
canvas_fixlinesfor(x->x_glist,(t_text*) x);
}
}
......@@ -324,7 +377,7 @@ static void image_setwidget(void)
image_widgetbehavior.w_activatefn = image_activate;
image_widgetbehavior.w_deletefn = image_delete;
image_widgetbehavior.w_visfn = image_vis;
//image_widgetbehavior.w_clickfn = image_newclick;
image_widgetbehavior.w_clickfn = image_newclick;
image_widgetbehavior.w_displacefnwtag = image_displace_wtag;
}
......@@ -349,6 +402,8 @@ static void *image_new(t_symbol *s, t_int argc, t_atom *argv)
x->x_img_width = 0;
x->x_img_height = 0;
x->x_gop_spill = 0;
x->x_click = 0;
//x->x_clicked = 0;
//x->x_selected = 0;
x->x_fname = get_filename(argc, argv);
......@@ -372,7 +427,9 @@ static void *image_new(t_symbol *s, t_int argc, t_atom *argv)
x->x_receive = gensym(buf);
pd_bind(&x->x_obj.ob_pd, x->x_receive);
//outlet_new(&x->x_obj, &s_bang);
outlet_new(&x->x_obj, &s_bang);
//outlet_new(&x->x_obj, &s_float);
return (x);
}
......@@ -387,10 +444,14 @@ void image_setup(void)
class_addmethod(image_class, (t_method)image_color, gensym("color"),
A_SYMBOL, 0);
*/
class_addmethod(image_class, (t_method)image_click, gensym("click"),
A_DEFFLOAT, 0);
class_addmethod(image_class, (t_method)image_open, gensym("open"),
A_GIMME, 0);
class_addmethod(image_class, (t_method)image_gop_spill, gensym("gopspill"),
A_DEFFLOAT, 0);
class_addmethod(image_class, (t_method)image_gop_spill_size, gensym("gopspill_size"),
A_DEFFLOAT, 0);
class_addmethod(image_class, (t_method)image_imagesize_callback,\
gensym("_imagesize"), A_DEFFLOAT, A_DEFFLOAT, 0);
......@@ -398,5 +459,3 @@ void image_setup(void)
class_setwidget(image_class,&image_widgetbehavior);
class_setsavefn(image_class,&image_save);
}
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