Commit ec6f964c authored by Mathieu L Bouchard's avatar Mathieu L Bouchard
Browse files

merged more scalehandle stuff together & put h_offset feature back in

parent 1e317c5a
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <math.h> #include <math.h>
t_symbol *s_empty; t_symbol *s_empty;
t_class *scalehandle_class;
int iemgui_color_hex[] = { int iemgui_color_hex[] = {
0xfcfcfc, 0xa0a0a0, 0x404040, 0xfce0e0, 0xfce0c0, 0xfcfcc8, 0xd8fcd8, 0xd8fcfc, 0xdce4fc, 0xf8d8fc, 0xfcfcfc, 0xa0a0a0, 0x404040, 0xfce0e0, 0xfce0c0, 0xfcfcc8, 0xd8fcd8, 0xd8fcfc, 0xdce4fc, 0xf8d8fc,
...@@ -742,8 +743,8 @@ void scalehandle_draw(t_iemgui *x) { ...@@ -742,8 +743,8 @@ void scalehandle_draw(t_iemgui *x) {
} }
} }
t_scalehandle *scalehandle_new(t_class *c, t_object *x, t_glist *glist, int scale) { t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale, t_clickhandlefn chf, t_motionhandlefn mhf) {
t_scalehandle *h = (t_scalehandle *)pd_new(c); t_scalehandle *h = (t_scalehandle *)pd_new(scalehandle_class);
char buf[19]; // 3 + max size of %lx char buf[19]; // 3 + max size of %lx
h->h_master = x; h->h_master = x;
h->h_glist = glist; h->h_glist = glist;
...@@ -756,6 +757,8 @@ t_scalehandle *scalehandle_new(t_class *c, t_object *x, t_glist *glist, int scal ...@@ -756,6 +757,8 @@ t_scalehandle *scalehandle_new(t_class *c, t_object *x, t_glist *glist, int scal
//h->h_offset_y = 0; // unused (maybe keep for later) //h->h_offset_y = 0; // unused (maybe keep for later)
h->h_vis = 0; h->h_vis = 0;
sprintf(h->h_pathname, ".x%lx.h%lx", (t_int)h->h_glist, (t_int)h); sprintf(h->h_pathname, ".x%lx.h%lx", (t_int)h->h_glist, (t_int)h);
h->h_clickfn = chf;
h->h_motionfn = mhf;
return h; return h;
} }
...@@ -873,6 +876,21 @@ void scalehandle_drag_scale(t_scalehandle *h) { ...@@ -873,6 +876,21 @@ void scalehandle_drag_scale(t_scalehandle *h) {
} }
} }
static void scalehandle_clickhook(t_scalehandle *h, t_floatarg f,
t_floatarg xxx, t_floatarg yyy)
{
h->h_offset_x=xxx;
h->h_offset_y=yyy;
h->h_clickfn(h,f);
}
static void scalehandle_motionhook(t_scalehandle *h,
t_floatarg f1, t_floatarg f2)
{
h->h_motionfn(h,f1-h->h_offset_x,f2-h->h_offset_y);
}
void iemgui__clickhook3(t_scalehandle *sh, int newstate) { void iemgui__clickhook3(t_scalehandle *sh, int newstate) {
if (!sh->h_dragon && newstate && sh->h_scale) if (!sh->h_dragon && newstate && sh->h_scale)
scalehandle_click_scale(sh); scalehandle_click_scale(sh);
...@@ -1127,6 +1145,12 @@ void iemgui_class_addmethods(t_class *c) { ...@@ -1127,6 +1145,12 @@ void iemgui_class_addmethods(t_class *c) {
void g_iemgui_setup (void) { void g_iemgui_setup (void) {
s_empty = gensym("empty"); s_empty = gensym("empty");
scalehandle_class = class_new(gensym("_scalehandle"), 0, 0,
sizeof(t_scalehandle), CLASS_PD, 0);
class_addmethod(scalehandle_class, (t_method)scalehandle_clickhook,
gensym("_click"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(scalehandle_class, (t_method)scalehandle_motionhook,
gensym("_motion"), A_FLOAT, A_FLOAT, 0);
} }
const char *selection_color = "$pd_colors(selection)"; const char *selection_color = "$pd_colors(selection)";
......
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
typedef void (*t_iemfunptr)(void *x, t_glist *glist, int mode); typedef void (*t_iemfunptr)(void *x, t_glist *glist, int mode);
struct _scalehandle;
typedef void (*t_clickhandlefn)(struct _scalehandle *sh, int newstate);
typedef void (*t_motionhandlefn)(struct _scalehandle *sh, t_floatarg f1, t_floatarg f2);
EXTERN t_class *scalehandle_class;
typedef struct _scalehandle typedef struct _scalehandle
{ {
t_pd h_pd; t_pd h_pd;
...@@ -46,9 +52,11 @@ typedef struct _scalehandle ...@@ -46,9 +52,11 @@ typedef struct _scalehandle
int h_dragon; // bool int h_dragon; // bool
int h_dragx; int h_dragx;
int h_dragy; int h_dragy;
int h_offset_x; // unused. bring back their use for extra precision. int h_offset_x;
int h_offset_y; // ditto. int h_offset_y;
int h_vis; // bool int h_vis; // bool
t_clickhandlefn h_clickfn;
t_motionhandlefn h_motionfn;
} t_scalehandle; } t_scalehandle;
typedef struct _iemgui typedef struct _iemgui
...@@ -224,7 +232,7 @@ EXTERN void scalehandle_draw_select2(t_iemgui *x); ...@@ -224,7 +232,7 @@ EXTERN void scalehandle_draw_select2(t_iemgui *x);
EXTERN void scalehandle_draw_erase(t_scalehandle *h); EXTERN void scalehandle_draw_erase(t_scalehandle *h);
EXTERN void scalehandle_draw_erase2(t_iemgui *x); EXTERN void scalehandle_draw_erase2(t_iemgui *x);
EXTERN void scalehandle_draw(t_iemgui *x); EXTERN void scalehandle_draw(t_iemgui *x);
EXTERN t_scalehandle *scalehandle_new(t_class *c, t_object *x, t_glist *glist, int scale); EXTERN t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale, t_clickhandlefn chf, t_motionhandlefn mhf);
EXTERN void scalehandle_free(t_scalehandle *h); EXTERN void scalehandle_free(t_scalehandle *h);
EXTERN void properties_set_field_int(long props, const char *gui_field, int value); EXTERN void properties_set_field_int(long props, const char *gui_field, int value);
EXTERN void scalehandle_dragon_label(t_scalehandle *h, float f1, float f2); EXTERN void scalehandle_dragon_label(t_scalehandle *h, float f1, float f2);
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#define IEM_BNG_MINHOLDFLASHTIME 50 #define IEM_BNG_MINHOLDFLASHTIME 50
#define IEM_BNG_MINBREAKFLASHTIME 10 #define IEM_BNG_MINBREAKFLASHTIME 10
static t_class *scalehandle_class;
extern int gfxstub_haveproperties(void *key); extern int gfxstub_haveproperties(void *key);
t_widgetbehavior bng_widgetbehavior; t_widgetbehavior bng_widgetbehavior;
static t_class *bng_class; static t_class *bng_class;
...@@ -76,11 +75,9 @@ void bng_draw_config(t_bng* x, t_glist* glist) ...@@ -76,11 +75,9 @@ void bng_draw_config(t_bng* x, t_glist* glist)
canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
} }
static void bng__clickhook(t_scalehandle *sh, t_floatarg f, static void bng__clickhook(t_scalehandle *sh, int newstate)
t_floatarg xxx, t_floatarg yyy)
{ {
t_bng *x = (t_bng *)(sh->h_master); t_bng *x = (t_bng *)(sh->h_master);
int newstate = (int)f;
if (sh->h_dragon && newstate == 0 && sh->h_scale) if (sh->h_dragon && newstate == 0 && sh->h_scale)
{ {
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
...@@ -368,8 +365,8 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv) ...@@ -368,8 +365,8 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv)
x->x_clock_lck = clock_new(x, (t_method)bng_tick_lck); x->x_clock_lck = clock_new(x, (t_method)bng_tick_lck);
outlet_new(&x->x_gui.x_obj, &s_bang); outlet_new(&x->x_gui.x_obj, &s_bang);
x->x_gui. x_handle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,1); x->x_gui. x_handle = scalehandle_new((t_object *)x,x->x_gui.x_glist,1,bng__clickhook,bng__motionhook);
x->x_gui.x_lhandle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,0); x->x_gui.x_lhandle = scalehandle_new((t_object *)x,x->x_gui.x_glist,0,bng__clickhook,bng__motionhook);
x->x_gui.x_obj.te_iemgui = 1; x->x_gui.x_obj.te_iemgui = 1;
x->x_gui.x_changed = 0; x->x_gui.x_changed = 0;
...@@ -410,13 +407,6 @@ void g_bang_setup(void) ...@@ -410,13 +407,6 @@ void g_bang_setup(void)
A_GIMME, 0); A_GIMME, 0);
class_addmethod(bng_class, (t_method)iemgui_init, gensym("init"), A_FLOAT, 0); class_addmethod(bng_class, (t_method)iemgui_init, gensym("init"), A_FLOAT, 0);
scalehandle_class = class_new(gensym("_scalehandle"), 0, 0,
sizeof(t_scalehandle), CLASS_PD, 0);
class_addmethod(scalehandle_class, (t_method)bng__clickhook,
gensym("_click"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(scalehandle_class, (t_method)bng__motionhook,
gensym("_motion"), A_FLOAT, A_FLOAT, 0);
wb_init(&bng_widgetbehavior,bng_getrect,bng_newclick); wb_init(&bng_widgetbehavior,bng_getrect,bng_newclick);
class_setwidget(bng_class, &bng_widgetbehavior); class_setwidget(bng_class, &bng_widgetbehavior);
class_sethelpsymbol(bng_class, gensym("bng")); class_sethelpsymbol(bng_class, gensym("bng"));
......
...@@ -15,7 +15,6 @@ to be different but are now unified except for some fossilized names.) */ ...@@ -15,7 +15,6 @@ to be different but are now unified except for some fossilized names.) */
#include "g_all_guis.h" #include "g_all_guis.h"
#include <string.h> #include <string.h>
static t_class *scalehandle_class;
extern int do_not_redraw; extern int do_not_redraw;
extern void canvas_drawconnection(t_canvas *x, int lx1, int ly1, int lx2, int ly2, t_int tag, int issignal); extern void canvas_drawconnection(t_canvas *x, int lx1, int ly1, int lx2, int ly2, t_int tag, int issignal);
extern void canvas_updateconnection(t_canvas *x, int lx1, int ly1, int lx2, int ly2, t_int tag); extern void canvas_updateconnection(t_canvas *x, int lx1, int ly1, int lx2, int ly2, t_int tag);
...@@ -350,6 +349,9 @@ void glist_init(t_glist *x) ...@@ -350,6 +349,9 @@ void glist_init(t_glist *x)
x->gl_ylabel = (t_symbol **)t_getbytes(0); x->gl_ylabel = (t_symbol **)t_getbytes(0);
} }
void canvasgop__clickhook(t_scalehandle *sh, int newstate);
void canvasgop__motionhook(t_scalehandle *sh,t_floatarg f1, t_floatarg f2);
/* make a new glist. It will either be a "root" canvas or else /* make a new glist. It will either be a "root" canvas or else
it appears as a "text" object in another window (canvas_getcurrent() it appears as a "text" object in another window (canvas_getcurrent()
tells us which.) */ tells us which.) */
...@@ -441,8 +443,8 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv) ...@@ -441,8 +443,8 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
pd_pushsym(&x->gl_pd); pd_pushsym(&x->gl_pd);
//dpsaha@vt.edu gop resize (refactored by mathieu) //dpsaha@vt.edu gop resize (refactored by mathieu)
x-> x_handle = scalehandle_new(scalehandle_class,(t_object *)x,x,1); x-> x_handle = scalehandle_new((t_object *)x,x,1,canvasgop__clickhook,canvasgop__motionhook);
x->x_mhandle = scalehandle_new(scalehandle_class,(t_object *)x,x,0); x->x_mhandle = scalehandle_new((t_object *)x,x,0,canvasgop__clickhook,canvasgop__motionhook);
x->u_queue = canvas_undo_init(x); x->u_queue = canvas_undo_init(x);
return(x); return(x);
...@@ -1924,11 +1926,9 @@ extern void canvas_canvas_setundo(t_canvas *x); ...@@ -1924,11 +1926,9 @@ extern void canvas_canvas_setundo(t_canvas *x);
extern void graph_checkgop_rect(t_gobj *z, t_glist *glist, extern void graph_checkgop_rect(t_gobj *z, t_glist *glist,
int *xp1, int *yp1, int *xp2, int *yp2); int *xp1, int *yp1, int *xp2, int *yp2);
void canvasgop__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_floatarg yyy) void canvasgop__clickhook(t_scalehandle *sh, int newstate)
{ {
t_canvas *x = (t_canvas *)(sh->h_master); t_canvas *x = (t_canvas *)(sh->h_master);
int newstate = (int)f;
if (sh->h_dragon && newstate == 0) if (sh->h_dragon && newstate == 0)
{ {
/* done dragging */ /* done dragging */
...@@ -2228,12 +2228,4 @@ void g_canvas_setup(void) ...@@ -2228,12 +2228,4 @@ void g_canvas_setup(void)
g_graph_setup(); g_graph_setup();
g_editor_setup(); g_editor_setup();
g_readwrite_setup(); g_readwrite_setup();
/* -------------- dpsaha@vt.edu gop resize move-----------------------*/
scalehandle_class = class_new(gensym("_scalehandle"), 0, 0,
sizeof(t_scalehandle), CLASS_PD, 0);
class_addmethod(scalehandle_class, (t_method)canvasgop__clickhook,
gensym("_click"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(scalehandle_class, (t_method)canvasgop__motionhook,
gensym("_motion"), A_FLOAT, A_FLOAT, 0);
} }
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "g_all_guis.h" #include "g_all_guis.h"
#include <math.h> #include <math.h>
static t_class *scalehandle_class;
extern int gfxstub_haveproperties(void *key); extern int gfxstub_haveproperties(void *key);
void my_canvas_draw_select(t_my_canvas* x, t_glist* glist); void my_canvas_draw_select(t_my_canvas* x, t_glist* glist);
...@@ -70,11 +69,9 @@ void my_canvas_draw_select(t_my_canvas* x, t_glist* glist) ...@@ -70,11 +69,9 @@ void my_canvas_draw_select(t_my_canvas* x, t_glist* glist)
"$pd_colors(selection)" : bcol); "$pd_colors(selection)" : bcol);
} }
static void my_canvas__clickhook(t_scalehandle *sh, t_floatarg f, static void my_canvas__clickhook(t_scalehandle *sh, int newstate)
t_floatarg xxx, t_floatarg yyy)
{ {
t_my_canvas *x = (t_my_canvas *)(sh->h_master); t_my_canvas *x = (t_my_canvas *)(sh->h_master);
int newstate = (int)f;
if (sh->h_dragon && newstate == 0 && sh->h_scale) if (sh->h_dragon && newstate == 0 && sh->h_scale)
{ {
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
...@@ -320,8 +317,8 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) ...@@ -320,8 +317,8 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv)
x->x_at[1].a_type = A_FLOAT; x->x_at[1].a_type = A_FLOAT;
iemgui_verify_snd_ne_rcv(&x->x_gui); iemgui_verify_snd_ne_rcv(&x->x_gui);
x->x_gui. x_handle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,1); x->x_gui. x_handle = scalehandle_new((t_object *)x,x->x_gui.x_glist,1,my_canvas__clickhook,my_canvas__motionhook);
x->x_gui.x_lhandle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,0); x->x_gui.x_lhandle = scalehandle_new((t_object *)x,x->x_gui.x_glist,0,my_canvas__clickhook,my_canvas__motionhook);
x->x_gui.x_obj.te_iemgui = 1; x->x_gui.x_obj.te_iemgui = 1;
return (x); return (x);
...@@ -353,13 +350,6 @@ void g_mycanvas_setup(void) ...@@ -353,13 +350,6 @@ void g_mycanvas_setup(void)
class_addmethod(my_canvas_class, (t_method)my_canvas_get_pos, class_addmethod(my_canvas_class, (t_method)my_canvas_get_pos,
gensym("get_pos"), 0); gensym("get_pos"), 0);
scalehandle_class = class_new(gensym("_scalehandle"), 0, 0,
sizeof(t_scalehandle), CLASS_PD, 0);
class_addmethod(scalehandle_class, (t_method)my_canvas__clickhook,
gensym("_click"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(scalehandle_class, (t_method)my_canvas__motionhook,
gensym("_motion"), A_FLOAT, A_FLOAT, 0);
wb_init(&my_canvas_widgetbehavior,my_canvas_getrect,0); wb_init(&my_canvas_widgetbehavior,my_canvas_getrect,0);
class_setwidget(my_canvas_class, &my_canvas_widgetbehavior); class_setwidget(my_canvas_class, &my_canvas_widgetbehavior);
class_sethelpsymbol(my_canvas_class, gensym("my_canvas")); class_sethelpsymbol(my_canvas_class, gensym("my_canvas"));
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <math.h> #include <math.h>
#define IEM_GUI_COLOR_EDITED 0xff0000 #define IEM_GUI_COLOR_EDITED 0xff0000
static t_class *scalehandle_class;
extern int gfxstub_haveproperties(void *key); extern int gfxstub_haveproperties(void *key);
static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist); static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist);
static void my_numbox_key(void *z, t_floatarg fkey); static void my_numbox_key(void *z, t_floatarg fkey);
...@@ -231,11 +230,9 @@ static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist) ...@@ -231,11 +230,9 @@ static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist)
scalehandle_draw_erase2(&x->x_gui); scalehandle_draw_erase2(&x->x_gui);
} }
static void my_numbox__clickhook(t_scalehandle *sh, t_floatarg f, static void my_numbox__clickhook(t_scalehandle *sh, int newstate)
t_floatarg xxx, t_floatarg yyy)
{ {
t_my_numbox *x = (t_my_numbox *)(sh->h_master); t_my_numbox *x = (t_my_numbox *)(sh->h_master);
int newstate = (int)f;
if (sh->h_dragon && newstate == 0 && sh->h_scale) if (sh->h_dragon && newstate == 0 && sh->h_scale)
{ {
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
...@@ -759,8 +756,8 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) ...@@ -759,8 +756,8 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv)
x->x_gui.x_change = 0; x->x_gui.x_change = 0;
outlet_new(&x->x_gui.x_obj, &s_float); outlet_new(&x->x_gui.x_obj, &s_float);
x->x_gui. x_handle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,1); x->x_gui. x_handle = scalehandle_new((t_object *)x,x->x_gui.x_glist,1,my_numbox__clickhook,my_numbox__motionhook);
x->x_gui.x_lhandle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,0); x->x_gui.x_lhandle = scalehandle_new((t_object *)x,x->x_gui.x_glist,0,my_numbox__clickhook,my_numbox__motionhook);
x->x_scalewidth = 0; x->x_scalewidth = 0;
x->x_scaleheight = 0; x->x_scaleheight = 0;
x->x_tmpfontsize = 0; x->x_tmpfontsize = 0;
...@@ -817,13 +814,6 @@ void g_numbox_setup(void) ...@@ -817,13 +814,6 @@ void g_numbox_setup(void)
class_addmethod(my_numbox_class, (t_method)my_numbox_hide_frame, class_addmethod(my_numbox_class, (t_method)my_numbox_hide_frame,
gensym("hide_frame"), A_FLOAT, 0); gensym("hide_frame"), A_FLOAT, 0);
scalehandle_class = class_new(gensym("_scalehandle"), 0, 0,
sizeof(t_scalehandle), CLASS_PD, 0);
class_addmethod(scalehandle_class, (t_method)my_numbox__clickhook,
gensym("_click"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(scalehandle_class, (t_method)my_numbox__motionhook,
gensym("_motion"), A_FLOAT, A_FLOAT, 0);
wb_init(&my_numbox_widgetbehavior,my_numbox_getrect,my_numbox_newclick); wb_init(&my_numbox_widgetbehavior,my_numbox_getrect,my_numbox_newclick);
class_setwidget(my_numbox_class, &my_numbox_widgetbehavior); class_setwidget(my_numbox_class, &my_numbox_widgetbehavior);
class_sethelpsymbol(my_numbox_class, gensym("numbox2")); class_sethelpsymbol(my_numbox_class, gensym("numbox2"));
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#define IEM_RADIO_MAX 128 #define IEM_RADIO_MAX 128
static t_class *scalehandle_class;
extern int gfxstub_haveproperties(void *key); extern int gfxstub_haveproperties(void *key);
t_widgetbehavior radio_widgetbehavior; t_widgetbehavior radio_widgetbehavior;
t_class *hradio_class, *hradio_old_class; t_class *hradio_class, *hradio_old_class;
...@@ -110,10 +109,8 @@ void radio_draw_config(t_radio *x, t_glist *glist) ...@@ -110,10 +109,8 @@ void radio_draw_config(t_radio *x, t_glist *glist)
} }
} }
static void radio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, static void radio__clickhook(t_scalehandle *sh, int newstate)
t_floatarg yyy)
{ {
int newstate = (int)f;
if (sh->h_dragon && newstate == 0 && sh->h_scale) if (sh->h_dragon && newstate == 0 && sh->h_scale)
{ {
t_radio *x = (t_radio *)(sh->h_master); t_radio *x = (t_radio *)(sh->h_master);
...@@ -460,8 +457,8 @@ static void *radio_new(t_symbol *s, int argc, t_atom *argv) ...@@ -460,8 +457,8 @@ static void *radio_new(t_symbol *s, int argc, t_atom *argv)
iemgui_all_colfromload(&x->x_gui, bflcol); iemgui_all_colfromload(&x->x_gui, bflcol);
outlet_new(&x->x_gui.x_obj, &s_list); outlet_new(&x->x_gui.x_obj, &s_list);
x->x_gui. x_handle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,1); x->x_gui. x_handle = scalehandle_new((t_object *)x,x->x_gui.x_glist,1,radio__clickhook,radio__motionhook);
x->x_gui.x_lhandle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,0); x->x_gui.x_lhandle = scalehandle_new((t_object *)x,x->x_gui.x_glist,0,radio__clickhook,radio__motionhook);
x->x_gui.x_obj.te_iemgui = 1; x->x_gui.x_obj.te_iemgui = 1;
return (x); return (x);
...@@ -528,12 +525,4 @@ void g_radio_setup(void) ...@@ -528,12 +525,4 @@ void g_radio_setup(void)
class_sethelpsymbol(hradio_old_class, gensym("hradio")); class_sethelpsymbol(hradio_old_class, gensym("hradio"));
class_sethelpsymbol(vradio_class, gensym("vradio")); class_sethelpsymbol(vradio_class, gensym("vradio"));
class_sethelpsymbol(vradio_old_class, gensym("vradio")); class_sethelpsymbol(vradio_old_class, gensym("vradio"));
scalehandle_class = class_new(gensym("_scalehandle"), 0, 0,
sizeof(t_scalehandle), CLASS_PD, 0);
class_addmethod(scalehandle_class, (t_method)radio__clickhook,
gensym("_click"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(scalehandle_class, (t_method)radio__motionhook,
gensym("_motion"), A_FLOAT, A_FLOAT, 0);
} }
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "g_all_guis.h" #include "g_all_guis.h"
#include <math.h> #include <math.h>
static t_class *scalehandle_class;
extern int gfxstub_haveproperties(void *key); extern int gfxstub_haveproperties(void *key);
t_widgetbehavior slider_widgetbehavior; t_widgetbehavior slider_widgetbehavior;
t_class *hslider_class; t_class *hslider_class;
...@@ -114,10 +113,8 @@ static void vslider__clickhook2(t_scalehandle *sh, t_slider *x) { ...@@ -114,10 +113,8 @@ static void vslider__clickhook2(t_scalehandle *sh, t_slider *x) {
slider_check_minmax(x, x->x_min, x->x_max); slider_check_minmax(x, x->x_min, x->x_max);
} }
static void slider__clickhook(t_scalehandle *sh, t_floatarg f, static void slider__clickhook(t_scalehandle *sh, int newstate)
t_floatarg xxx, t_floatarg yyy)
{ {
int newstate = (int)f;
if (sh->h_dragon && newstate == 0 && sh->h_scale) if (sh->h_dragon && newstate == 0 && sh->h_scale)
{ {
t_slider *x = (t_slider *)(sh->h_master); t_slider *x = (t_slider *)(sh->h_master);
...@@ -533,8 +530,8 @@ static void *slider_new(t_symbol *s, int argc, t_atom *argv) ...@@ -533,8 +530,8 @@ static void *slider_new(t_symbol *s, int argc, t_atom *argv)
iemgui_verify_snd_ne_rcv(&x->x_gui); iemgui_verify_snd_ne_rcv(&x->x_gui);
outlet_new(&x->x_gui.x_obj, &s_float); outlet_new(&x->x_gui.x_obj, &s_float);
x->x_gui. x_handle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,1); x->x_gui. x_handle = scalehandle_new((t_object *)x,x->x_gui.x_glist,1,slider__clickhook,slider__motionhook);
x->x_gui.x_lhandle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,0); x->x_gui.x_lhandle = scalehandle_new((t_object *)x,x->x_gui.x_glist,0,slider__clickhook,slider__motionhook);
x->x_gui.x_obj.te_iemgui = 1; x->x_gui.x_obj.te_iemgui = 1;
x->x_gui.x_changed = 0; x->x_gui.x_changed = 0;
...@@ -593,11 +590,4 @@ void g_slider_setup(void) ...@@ -593,11 +590,4 @@ void g_slider_setup(void)
class_sethelpsymbol(hslider_class, gensym("hslider")); class_sethelpsymbol(hslider_class, gensym("hslider"));
class_sethelpsymbol(vslider_class, gensym("vslider")); class_sethelpsymbol(vslider_class, gensym("vslider"));
scalehandle_class = class_new(gensym("_scalehandle"), 0, 0,
sizeof(t_scalehandle), CLASS_PD, 0);
class_addmethod(scalehandle_class, (t_method)slider__clickhook,
gensym("_click"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(scalehandle_class, (t_method)slider__motionhook,
gensym("_motion"), A_FLOAT, A_FLOAT, 0);
} }
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "g_all_guis.h" #include "g_all_guis.h"
#include <math.h> #include <math.h>
static t_class *scalehandle_class;
extern int gfxstub_haveproperties(void *key); extern int gfxstub_haveproperties(void *key);
t_widgetbehavior toggle_widgetbehavior; t_widgetbehavior toggle_widgetbehavior;
static t_class *toggle_class; static t_class *toggle_class;
...@@ -78,11 +77,9 @@ void toggle_draw_config(t_toggle* x, t_glist* glist) ...@@ -78,11 +77,9 @@ void toggle_draw_config(t_toggle* x, t_glist* glist)
canvas, x, x, x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); canvas, x, x, x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol);
} }
static void toggle__clickhook(t_scalehandle *sh, t_floatarg f, static void toggle__clickhook(t_scalehandle *sh, int newstate)
t_floatarg xxx, t_floatarg yyy)
{ {
t_toggle *x = (t_toggle *)(sh->h_master); t_toggle *x = (t_toggle *)(sh->h_master);
int newstate = (int)f;
if (sh->h_dragon && newstate == 0 && sh->h_scale) if (sh->h_dragon && newstate == 0 && sh->h_scale)
{ {
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
...@@ -318,8 +315,8 @@ static void *toggle_new(t_symbol *s, int argc, t_atom *argv) ...@@ -318,8 +315,8 @@ static void *toggle_new(t_symbol *s, int argc, t_atom *argv)
iemgui_verify_snd_ne_rcv(&x->x_gui); iemgui_verify_snd_ne_rcv(&x->x_gui);
outlet_new(&x->x_gui.x_obj, &s_float); outlet_new(&x->x_gui.x_obj, &s_float);
x->x_gui. x_handle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,1); x->x_gui. x_handle = scalehandle_new((t_object *)x,x->x_gui.x_glist,1,toggle__clickhook,toggle__motionhook);
x->x_gui.x_lhandle = scalehandle_new(scalehandle_class,(t_object *)x,x->x_gui.x_glist,0); x->x_gui.x_lhandle = scalehandle_new((t_object *)x,x->x_gui.x_glist,0,toggle__clickhook,toggle__motionhook);
x->x_gui.x_obj.te_iemgui = 1; x->x_gui.x_obj.te_iemgui = 1;
x->x_gui.x_changed = 1; x->x_gui.x_changed = 1;
...@@ -359,13 +356,6 @@ void g_toggle_setup(void) ...@@ -359,13 +356,6 @@ void g_toggle_setup(void)
class_addmethod(toggle_class, (t_method)toggle_nonzero, gensym("nonzero"), class_addmethod(toggle_class, (t_method)toggle_nonzero, gensym("nonzero"),
A_FLOAT, 0); A_FLOAT, 0);
scalehandle_class = class_new(gensym("_scalehandle"), 0, 0,
sizeof(t_scalehandle), CLASS_PD, 0);
class_addmethod(scalehandle_class, (t_method)toggle__clickhook,
gensym("_click"), A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(scalehandle_class, (t_method)toggle__motionhook,
gensym("_motion"), A_FLOAT, A_FLOAT, 0);
wb_init(&toggle_widgetbehavior,toggle_getrect,toggle_newclick); wb_init(&toggle_widgetbehavior,toggle_getrect,toggle_newclick);
class_setwidget(toggle_class, &toggle_widgetbehavior); class_setwidget(toggle_class, &toggle_widgetbehavior);
class_sethelpsymbol(toggle_class, gensym("toggle"));