Commit 6a613a0a authored by Mathieu L Bouchard's avatar Mathieu L Bouchard
Browse files

2nd refactor of scalehandle (including some changes to structs t_scalehandle, t_iemgui, t_canvas)

parent b8e6a503
......@@ -923,11 +923,10 @@ const char *nlet_tag, const char *class_tag) {
//printf("scalehandle_draw_select(x%lx,x%lx,%d,%d,\"%s\",\"%s\")\n",h,canvas,px,py,nlet_tag,class_tag);
if (h->h_scale ? x->scale_vis : x->label_vis)
scalehandle_draw_erase(h,canvas);
if (h->h_vis) scalehandle_draw_erase(h,canvas);
// sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -bd 0 "
sys_vgui("canvas %s -width %d -height %d -bg #0080ff -bd 0 "
sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -bd 0 "
// sys_vgui("canvas %s -width %d -height %d -bg #0080ff -bd 0 "
"-cursor %s\n", h->h_pathname, sx, sy, cursor);
// there was a %lxBNG tag (or similar) in every scalehandle,
// but it didn't seem to be used —mathieu
......@@ -943,27 +942,42 @@ const char *nlet_tag, const char *class_tag) {
"-window %s -tags {%s}\n", canvas, x->x_obj.te_xpix+px-sx, x->x_obj.te_ypix+py-sy,
sx, sy, h->h_pathname, tags);
scalehandle_bind(h);
if (h->h_scale) x->scale_vis = 1;
else x->label_vis = 1;
h->h_vis = 1;
}
void scalehandle_draw_erase(t_scalehandle *h, t_glist *canvas) {
sys_vgui("destroy %s\n", h->h_pathname);
sys_vgui(".x%lx.c delete %lx%s\n", canvas, h->h_master, h->h_scale ? "SCALE" : "LABELH");
h->h_vis = 0;
}
void scalehandle_draw_erase2(t_iemgui *x, t_glist *canvas) {
/*if (x->x_fsf.x_selected)
{
scalehandle_draw_erase((t_scalehandle *)(x->x_handle),canvas);
scalehandle_draw_erase((t_scalehandle *)(x->x_lhandle),canvas);
}*/
if (x->scale_vis) {
scalehandle_draw_erase((t_scalehandle *)(x->x_handle),canvas);
x->scale_vis = 0;
}
if (x->label_vis) {
scalehandle_draw_erase((t_scalehandle *)(x->x_lhandle),canvas);
x->label_vis = 0;
}
t_scalehandle *sh = (t_scalehandle *)(x->x_handle);
t_scalehandle *lh = (t_scalehandle *)(x->x_lhandle);
if (sh->h_vis) scalehandle_draw_erase(sh,canvas);
if (lh->h_vis) scalehandle_draw_erase(lh,canvas);
}
void scalehandle_draw_new(t_scalehandle *h, t_glist *canvas) {
sprintf(h->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)h);
}
t_scalehandle *scalehandle_new(t_class *c, t_iemgui *x, int scale) {
t_scalehandle *h = (t_scalehandle *)pd_new(c);
char buf[64];
h->h_master = (t_gobj*)x;
sprintf(buf, "_h%lx", (t_int)h);
pd_bind((t_pd *)h, h->h_bindsym = gensym(buf));
sprintf(h->h_outlinetag, "h%lx", (t_int)h);
h->h_dragon = 0;
h->h_scale = scale;
h->h_offset_x = 0;
h->h_offset_y = 0;
h->h_vis = 0;
return h;
}
void scalehandle_free(t_scalehandle *h) {
pd_unbind((t_pd *)h, h->h_bindsym);
pd_free((t_pd *)h);
}
......@@ -177,6 +177,9 @@ typedef struct _scalehandle
int h_dragon;
int h_dragx;
int h_dragy;
int h_offset_x;
int h_offset_y;
int h_vis;
} t_scalehandle;
static t_class *scalehandle_class;
......@@ -198,22 +201,16 @@ typedef struct _iemgui
int x_fcol;
int x_bcol;
int x_lcol;
t_symbol *x_snd; /* send symbol */
t_symbol *x_rcv; /* receive */
t_symbol *x_lab; /* label */
t_symbol *x_snd_unexpanded; /* same 3, with '$' unexpanded */
t_symbol *x_rcv_unexpanded;
t_symbol *x_lab_unexpanded;
t_symbol *x_snd; /* send symbol */
t_symbol *x_rcv; /* receive */
t_symbol *x_lab; /* label */
t_symbol *x_snd_unexpanded; /* same 3, with '$' unexpanded */
t_symbol *x_rcv_unexpanded;
t_symbol *x_lab_unexpanded;
int x_binbufindex; /* where in binbuf to find these */
int x_labelbindex; /* where in binbuf to find label */
t_pd *x_handle;
int scale_offset_x;
int scale_offset_y;
int scale_vis;
t_pd *x_lhandle;
int label_offset_x;
int label_offset_y;
int label_vis;
t_scalehandle *x_handle;
t_scalehandle *x_lhandle;
int x_vis; /* is the object drawn? */
int x_changed; /* has the value changed so that we need to do graphic update */
} t_iemgui;
......@@ -410,3 +407,6 @@ EXTERN void scalehandle_bind(t_scalehandle *h);
EXTERN void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py, const char *nlet_tag, const char *class_tag);
EXTERN void scalehandle_draw_erase(t_scalehandle *h, t_glist *canvas);
EXTERN void scalehandle_draw_erase2(t_iemgui *x, t_glist *canvas);
EXTERN void scalehandle_draw_new(t_scalehandle *x, t_glist *canvas);
EXTERN t_scalehandle *scalehandle_new(t_class *c, t_iemgui *x, int scale);
EXTERN void scalehandle_free(t_scalehandle *h);
......@@ -57,11 +57,8 @@ void bng_draw_new(t_bng *x, t_glist *glist)
int ypos=text_ypix(&x->x_gui.x_obj, glist);
t_canvas *canvas=glist_getcanvas(glist);
t_scalehandle *sh = (t_scalehandle *)x->x_gui.x_handle;
sprintf(sh->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)sh);
t_scalehandle *lh = (t_scalehandle *)x->x_gui.x_lhandle;
sprintf(lh->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)lh);
scalehandle_draw_new(x->x_gui. x_handle,canvas);
scalehandle_draw_new(x->x_gui.x_lhandle,canvas);
//if (glist_isvisible(canvas)) {
......@@ -278,13 +275,11 @@ static void bng__clickhook(t_scalehandle *sh, t_floatarg f,
if (xxx)
{
x->x_gui.scale_offset_x = xxx;
x->x_gui.label_offset_x = xxx;
sh->h_offset_x = xxx;
}
if (yyy)
{
x->x_gui.scale_offset_y = yyy;
x->x_gui.label_offset_y = yyy;
sh->h_offset_y = yyy;
}
int newstate = (int)f;
......@@ -301,10 +296,10 @@ static void bng__clickhook(t_scalehandle *sh, t_floatarg f,
sh->h_dragx = sh->h_dragy;
else sh->h_dragy = sh->h_dragx;
x->x_gui.x_w = x->x_gui.x_w + sh->h_dragx - x->x_gui.scale_offset_x;
x->x_gui.x_w = x->x_gui.x_w + sh->h_dragx - sh->h_offset_x;
if (x->x_gui.x_w < SCALE_BNG_MINWIDTH)
x->x_gui.x_w = SCALE_BNG_MINWIDTH;
x->x_gui.x_h = x->x_gui.x_h + sh->h_dragy - x->x_gui.scale_offset_y;
x->x_gui.x_h = x->x_gui.x_h + sh->h_dragy - sh->h_offset_y;
if (x->x_gui.x_h < SCALE_BNG_MINHEIGHT)
x->x_gui.x_h = SCALE_BNG_MINHEIGHT;
......@@ -359,9 +354,9 @@ static void bng__clickhook(t_scalehandle *sh, t_floatarg f,
if (sh->h_dragx || sh->h_dragy)
{
x->x_gui.x_ldx = x->x_gui.x_ldx + sh->h_dragx -
x->x_gui.label_offset_x;
sh->h_offset_x;
x->x_gui.x_ldy = x->x_gui.x_ldy + sh->h_dragy -
x->x_gui.label_offset_y;
sh->h_offset_y;
canvas_dirty(x->x_gui.x_glist, 1);
}
......@@ -392,7 +387,7 @@ static void bng__clickhook(t_scalehandle *sh, t_floatarg f,
if (glist_isvisible(x->x_gui.x_glist))
{
sys_vgui("lower %s\n", sh->h_pathname);
t_scalehandle *othersh = (t_scalehandle *)x->x_gui.x_handle;
t_scalehandle *othersh = x->x_gui.x_handle;
sys_vgui("lower .x%lx.h%lx\n",
(t_int)glist_getcanvas(x->x_gui.x_glist), (t_int)othersh);
}
......@@ -415,18 +410,18 @@ static void bng__motionhook(t_scalehandle *sh,
if (dx > dy)
{
dx = dy;
x->x_gui.scale_offset_x = x->x_gui.scale_offset_y;
sh->h_offset_x = sh->h_offset_y;
}
else
{
dy = dx;
x->x_gui.scale_offset_y = x->x_gui.scale_offset_x;
sh->h_offset_y = sh->h_offset_x;
}
newx = x->x_gui.x_obj.te_xpix + x->x_gui.x_w -
x->x_gui.scale_offset_x + dx;
sh->h_offset_x + dx;
newy = x->x_gui.x_obj.te_ypix + x->x_gui.x_h -
x->x_gui.scale_offset_y + dy;
sh->h_offset_y + dy;
if (newx < x->x_gui.x_obj.te_xpix + SCALE_BNG_MINWIDTH)
newx = x->x_gui.x_obj.te_xpix + SCALE_BNG_MINWIDTH;
......@@ -446,8 +441,8 @@ static void bng__motionhook(t_scalehandle *sh,
if (properties)
{
int new_w = x->x_gui.x_w - x->x_gui.scale_offset_x + sh->h_dragx;
//int new_h = x->x_gui.x_h - x->x_gui.scale_offset_y + sh->h_dragy;
int new_w = x->x_gui.x_w - sh->h_offset_x + sh->h_dragx;
//int new_h = x->x_gui.x_h - sh->h_offset_y + sh->h_dragy;
sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties);
sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", properties, new_w);
//sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties);
......@@ -466,8 +461,8 @@ static void bng__motionhook(t_scalehandle *sh,
if (properties)
{
int new_x = x->x_gui.x_ldx - x->x_gui.label_offset_x + sh->h_dragx;
int new_y = x->x_gui.x_ldy - x->x_gui.label_offset_y + sh->h_dragy;
int new_x = x->x_gui.x_ldx - sh->h_offset_x + sh->h_dragx;
int new_y = x->x_gui.x_ldy - sh->h_offset_y + sh->h_dragy;
sys_vgui(".gfxstub%lx.label.xy.x_entry delete 0 end\n", properties);
sys_vgui(".gfxstub%lx.label.xy.x_entry insert 0 %d\n", properties,
new_x);
......@@ -483,8 +478,8 @@ static void bng__motionhook(t_scalehandle *sh,
t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
canvas, x,
xpos+x->x_gui.x_ldx + sh->h_dragx - x->x_gui.label_offset_x,
ypos+x->x_gui.x_ldy + sh->h_dragy - x->x_gui.label_offset_y);
xpos+x->x_gui.x_ldx + sh->h_dragx - sh->h_offset_x,
ypos+x->x_gui.x_ldy + sh->h_dragy - sh->h_offset_y);
}
}
}
......@@ -857,36 +852,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);
outlet_new(&x->x_gui.x_obj, &s_bang);
/* scale handle init */
t_scalehandle *sh;
char buf[64];
x->x_gui.x_handle = pd_new(scalehandle_class);
sh = (t_scalehandle *)x->x_gui.x_handle;
sh->h_master = (t_gobj*)x;
sprintf(buf, "_h%lx", (t_int)sh);
pd_bind(x->x_gui.x_handle, sh->h_bindsym = gensym(buf));
sprintf(sh->h_outlinetag, "h%lx", (t_int)sh);
sh->h_dragon = 0;
sh->h_scale = 1;
x->x_gui.scale_offset_x = 0;
x->x_gui.scale_offset_y = 0;
x->x_gui.scale_vis = 0;
/* label handle init */
t_scalehandle *lh;
char lhbuf[64];
x->x_gui.x_lhandle = pd_new(scalehandle_class);
lh = (t_scalehandle *)x->x_gui.x_lhandle;
lh->h_master = (t_gobj*)x;
sprintf(lhbuf, "_h%lx", (t_int)lh);
pd_bind(x->x_gui.x_lhandle, lh->h_bindsym = gensym(lhbuf));
sprintf(lh->h_outlinetag, "h%lx", (t_int)lh);
lh->h_dragon = 0;
lh->h_scale = 0;
x->x_gui.label_offset_x = 0;
x->x_gui.label_offset_y = 0;
x->x_gui.label_vis = 0;
x->x_gui. x_handle = scalehandle_new(scalehandle_class,(t_iemgui *)x,1);
x->x_gui.x_lhandle = scalehandle_new(scalehandle_class,(t_iemgui *)x,0);
x->x_gui.x_obj.te_iemgui = 1;
x->x_gui.x_changed = 0;
......@@ -902,21 +869,8 @@ static void bng_ff(t_bng *x)
clock_free(x->x_clock_hld);
gfxstub_deleteforkey(x);
/* scale handle deconstructor */
if (x->x_gui.x_handle)
{
pd_unbind(x->x_gui.x_handle,
((t_scalehandle *)x->x_gui.x_handle)->h_bindsym);
pd_free(x->x_gui.x_handle);
}
/* label handle deconstructor */
if (x->x_gui.x_lhandle)
{
pd_unbind(x->x_gui.x_lhandle,
((t_scalehandle *)x->x_gui.x_lhandle)->h_bindsym);
pd_free(x->x_gui.x_lhandle);
}
if (x->x_gui. x_handle) scalehandle_free(x->x_gui. x_handle);
if (x->x_gui.x_lhandle) scalehandle_free(x->x_gui.x_lhandle);
}
void g_bang_setup(void)
......
......@@ -438,40 +438,11 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
x->gl_font = sys_nearestfontsize(font);
pd_pushsym(&x->gl_pd);
//dpsaha@vt.edu gop resize
//resize blob
t_scalehandle *sh;
char buf[64];
x->x_handle = pd_new(scalehandle_class);
sh = (t_scalehandle *)x->x_handle;
sh->h_master = (t_gobj*)x;
sprintf(buf, "_h%lx", (t_int)sh);
pd_bind(x->x_handle, sh->h_bindsym = gensym(buf));
sprintf(sh->h_outlinetag, "h%lx", (t_int)sh);
sh->h_dragon = 0;
sh->h_scale = 1;
x->scale_offset_x = 0;
x->scale_offset_y = 0;
x->scale_vis = 0;
//move blob
t_scalehandle *mh;
char mbuf[64];
x->x_mhandle = pd_new(scalehandle_class);
mh = (t_scalehandle *)x->x_mhandle;
mh->h_master = (t_gobj*)x;
sprintf(mbuf, "_h%lx", (t_int)mh);
pd_bind(x->x_mhandle, mh->h_bindsym = gensym(mbuf));
sprintf(mh->h_outlinetag, "h%lx", (t_int)mh);
mh->h_dragon = 0;
mh->h_scale = 0;
x->move_offset_x = 0;
x->move_offset_y = 0;
x->move_vis = 0;
//dpsaha@vt.edu gop resize (refactored by mathieu)
x-> x_handle = scalehandle_new(scalehandle_class,(t_iemgui *)x,1);
x->x_mhandle = scalehandle_new(scalehandle_class,(t_iemgui *)x,0);
x->u_queue = canvas_undo_init(x);
return(x);
}
......@@ -737,7 +708,9 @@ void canvas_draw_gop_resize_hooks(t_canvas* x)
sprintf(sh->h_pathname, ".x%lx.h%lx", (t_int)x, (t_int)sh);
sys_vgui("destroy %s\n", sh->h_pathname);
sys_vgui(".x%lx.c delete GOP_resblob\n", x);
// instead should call scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py, const char *nlet_tag, const char *class_tag);
// but the tags are different
sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) "
"-bd 0 -cursor bottom_right_corner\n",
sh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT);
......@@ -764,6 +737,7 @@ void canvas_draw_gop_resize_hooks(t_canvas* x)
SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT,
mh->h_pathname, x, x);
scalehandle_bind(mh);
// end of part to be replaced by scalehandle_draw_select
}
else
{
......@@ -1987,8 +1961,8 @@ void canvasgop__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_flo
t_canvas *x = (t_canvas *)(sh->h_master);
if (xxx) x->scale_offset_x = xxx;
if (yyy) x->scale_offset_y = yyy;
if (xxx) sh->h_offset_x = xxx;
if (yyy) sh->h_offset_y = yyy;
int newstate = (int)f;
if (sh->h_dragon && newstate == 0)
......@@ -2003,11 +1977,11 @@ void canvasgop__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_flo
if (sh->h_dragx || sh->h_dragy)
{
x->gl_pixwidth = x->gl_pixwidth + sh->h_dragx -
x->scale_offset_x;
sh->h_offset_x;
if (x->gl_pixwidth < SCALE_GOP_MINWIDTH)
x->gl_pixwidth = SCALE_GOP_MINWIDTH;
x->gl_pixheight = x->gl_pixheight + sh->h_dragy -
x->scale_offset_y;
sh->h_offset_y;
if (x->gl_pixheight < SCALE_GOP_MINHEIGHT)
x->gl_pixheight = SCALE_GOP_MINHEIGHT;
......@@ -2063,8 +2037,8 @@ void canvasgop__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_flo
if (sh->h_dragx || sh->h_dragy)
{
x->gl_xmargin = x->gl_xmargin + sh->h_dragx - x->scale_offset_x;
x->gl_ymargin = x->gl_ymargin + sh->h_dragy - x->scale_offset_y;
x->gl_xmargin = x->gl_xmargin + sh->h_dragx - sh->h_offset_x;
x->gl_ymargin = x->gl_ymargin + sh->h_dragy - sh->h_offset_y;
canvas_dirty(x, 1);
}
......@@ -2127,8 +2101,8 @@ void canvasgop__motionhook(t_scalehandle *sh,t_floatarg f1, t_floatarg f2)
{
if(sh->h_scale) //enter if resize_gop hook
{
newx = x->gl_xmargin + x->gl_pixwidth - x->scale_offset_x + dx;
newy = x->gl_ymargin + x->gl_pixheight - x->scale_offset_y + dy;
newx = x->gl_xmargin + x->gl_pixwidth - sh->h_offset_x + dx;
newy = x->gl_ymargin + x->gl_pixheight - sh->h_offset_y + dy;
if (newx < x->gl_xmargin + SCALE_GOP_MINWIDTH)
newx = x->gl_xmargin + SCALE_GOP_MINWIDTH;
......@@ -2145,8 +2119,8 @@ void canvasgop__motionhook(t_scalehandle *sh,t_floatarg f1, t_floatarg f2)
int properties = gfxstub_haveproperties((void *)x);
if (properties)
{
int new_w = x->gl_pixwidth - x->scale_offset_x + sh->h_dragx;
int new_h = x->gl_pixheight - x->scale_offset_y + sh->h_dragy;
int new_w = x->gl_pixwidth - sh->h_offset_x + sh->h_dragx;
int new_h = x->gl_pixheight - sh->h_offset_y + sh->h_dragy;
sys_vgui(".gfxstub%lx.xrange.entry3 delete 0 end\n",
properties);
sys_vgui(".gfxstub%lx.xrange.entry3 insert 0 %d\n",
......@@ -2159,8 +2133,8 @@ void canvasgop__motionhook(t_scalehandle *sh,t_floatarg f1, t_floatarg f2)
}
else //enter if move_gop hook
{
newx = x->gl_xmargin - x->scale_offset_x + dx;
newy = x->gl_ymargin - x->scale_offset_y + dy;
newx = x->gl_xmargin - sh->h_offset_x + dx;
newy = x->gl_ymargin - sh->h_offset_y + dy;
int properties = gfxstub_haveproperties((void *)x);
if (properties)
......
......@@ -215,16 +215,9 @@ struct _glist
//infinite undo goodies (have to stay here rather than the editor to prevent its obliteration when editor is deleted)
t_undo_action *u_queue;
t_undo_action *u_last;
//dpsaha@vt.edu for the gop dynamic resizing
t_pd *x_handle;
int scale_offset_x;
int scale_offset_y;
int scale_vis;
//dpsaha@vt.edu for the move handle
t_pd *x_mhandle;
int move_offset_x;
int move_offset_y;
int move_vis;
//dpsaha@vt.edu for the gop dynamic resizing & move handle (refactored by mathieu)
struct _scalehandle *x_handle;
struct _scalehandle *x_mhandle;
t_pd *gl_svg;
};
......
......@@ -64,10 +64,8 @@ void hradio_draw_new(t_hradio *x, t_glist *glist)
int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4;
int xx22=xx11b+dx-s4;
t_scalehandle *sh = (t_scalehandle *)x->x_gui.x_handle;
sprintf(sh->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)sh);
t_scalehandle *lh = (t_scalehandle *)x->x_gui.x_lhandle;
sprintf(lh->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)lh);
scalehandle_draw_new(x->x_gui. x_handle,canvas);
scalehandle_draw_new(x->x_gui.x_lhandle,canvas);
//if (glist_isvisible(canvas)) {
......@@ -299,13 +297,11 @@ static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx,
if (xxx)
{
x->x_gui.scale_offset_x = xxx;
x->x_gui.label_offset_x = xxx;
sh->h_offset_x = xxx;
}
if (yyy)
{
x->x_gui.scale_offset_y = yyy;
x->x_gui.label_offset_y = yyy;
sh->h_offset_y = yyy;
}
int newstate = (int)f;
......@@ -321,10 +317,10 @@ static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx,
sh->h_dragx = sh->h_dragy;
x->x_gui.x_w = x->x_gui.x_w + sh->h_dragx - x->x_gui.scale_offset_y;
x->x_gui.x_w = x->x_gui.x_w + sh->h_dragx - sh->h_offset_y;
if (x->x_gui.x_w < SCALE_HRDO_MINWIDTH)
x->x_gui.x_w = SCALE_HRDO_MINWIDTH;
x->x_gui.x_h = x->x_gui.x_h + sh->h_dragy - x->x_gui.scale_offset_y;
x->x_gui.x_h = x->x_gui.x_h + sh->h_dragy - sh->h_offset_y;
if (x->x_gui.x_h < SCALE_HRDO_MINHEIGHT)
x->x_gui.x_h = SCALE_HRDO_MINHEIGHT;
......@@ -378,9 +374,9 @@ static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx,
if (sh->h_dragx || sh->h_dragy)
{
x->x_gui.x_ldx =
x->x_gui.x_ldx + sh->h_dragx - x->x_gui.label_offset_x;
x->x_gui.x_ldx + sh->h_dragx - sh->h_offset_x;
x->x_gui.x_ldy =
x->x_gui.x_ldy + sh->h_dragy - x->x_gui.label_offset_y;
x->x_gui.x_ldy + sh->h_dragy - sh->h_offset_y;
canvas_dirty(x->x_gui.x_glist, 1);
}
......@@ -412,7 +408,7 @@ static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx,
if (glist_isvisible(x->x_gui.x_glist))
{
sys_vgui("lower %s\n", sh->h_pathname);
t_scalehandle *othersh = (t_scalehandle *)x->x_gui.x_handle;
t_scalehandle *othersh = x->x_gui.x_handle;
sys_vgui("lower .x%lx.h%lx\n",
(t_int)glist_getcanvas(x->x_gui.x_glist), (t_int)othersh);
}
......@@ -436,9 +432,9 @@ static void hradio__motionhook(t_scalehandle *sh,
dx = dy;
newx = x->x_gui.x_obj.te_xpix + x->x_gui.x_w*x->x_number +
(dx - x->x_gui.scale_offset_y) * x->x_number;
(dx - sh->h_offset_y) * x->x_number;
newy = x->x_gui.x_obj.te_ypix + x->x_gui.x_h +
(dy - x->x_gui.scale_offset_y);
(dy - sh->h_offset_y);
if (newx < x->x_gui.x_obj.te_xpix + SCALE_HRDO_MINWIDTH*x->x_number)
newx = x->x_gui.x_obj.te_xpix + SCALE_HRDO_MINWIDTH*x->x_number;
......@@ -458,8 +454,8 @@ static void hradio__motionhook(t_scalehandle *sh,
if (properties)
{
int new_w = x->x_gui.x_w - x->x_gui.scale_offset_x + sh->h_dragx;
//int new_h = x->x_gui.x_h - x->x_gui.scale_offset_y + sh->h_dragy;
int new_w = x->x_gui.x_w - sh->h_offset_x + sh->h_dragx;
//int new_h = x->x_gui.x_h - sh->h_offset_y + sh->h_dragy;
sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties);
sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", properties, new_w);
//sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties);
......@@ -478,8 +474,8 @@ static void hradio__motionhook(t_scalehandle *sh,
if (properties)
{
int new_x = x->x_gui.x_ldx - x->x_gui.label_offset_x + sh->h_dragx;
int new_y = x->x_gui.x_ldy - x->x_gui.label_offset_y + sh->h_dragy;
int new_x = x->x_gui.x_ldx - sh->h_offset_x + sh->h_dragx;
int new_y = x->x_gui.x_ldy - sh->h_offset_y + sh->h_dragy;
sys_vgui(".gfxstub%lx.label.xy.x_entry delete 0 end\n", properties);
sys_vgui(".gfxstub%lx.label.xy.x_entry insert 0 %d\n",
properties, new_x);
......@@ -495,8 +491,8 @@ static void hradio__motionhook(t_scalehandle *sh,
t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
canvas, x,
xpos+x->x_gui.x_ldx + sh->h_dragx - x->x_gui.label_offset_x,
ypos+x->x_gui.x_ldy + sh->h_dragy - x->x_gui.label_offset_y);
xpos+x->x_gui.x_ldx + sh->h_dragx - sh->h_offset_x,
ypos+x->x_gui.x_ldy + sh->h_dragy - sh->h_offset_y);
}
}
}
......@@ -947,36 +943,8 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old)
iemgui_all_colfromload(&x->x_gui, bflcol);
outlet_new(&x->x_gui.x_obj, &s_list);
/* scale handle init */
t_scalehandle *sh;
char buf[64];
x->x_gui.x_handle = pd_new(scalehandle_class);
sh = (t_scalehandle *)x->x_gui.x_handle;
sh->h_master = (t_gobj*)x;
sprintf(buf, "_h%lx", (t_int)sh);
pd_bind(x->x_gui.x_handle, sh->h_bindsym = gensym(buf));
sprintf(sh->h_outlinetag, "h%lx", (t_int)sh);
sh->h_dragon = 0;
sh->h_scale = 1;
x->x_gui.scale_offset_x = 0;
x->x_gui.scale_offset_y = 0;
x->x_gui.scale_vis = 0;
/* label handle init */
t_scalehandle *lh;
char lhbuf[64];
x->x_gui.x_lhandle = pd_new(scalehandle_class);
lh = (t_scalehandle *)x->x_gui.x_lhandle;
lh->h_master = (t_gobj*)x;
sprintf(lhbuf, "_h%lx", (t_int)lh);
pd_bind(x->x_gui.x_lhandle, lh->h_bindsym = gensym(lhbuf));
sprintf(lh->h_outlinetag, "h%lx", (t_int)lh);
lh->h_dragon = 0;
lh->h_scale = 0;
x->x_gui.label_offset_x = 0;
x->x_gui.label_offset_y = 0;
x->x_gui.label_vis = 0;
x->x_gui. x_handle = scalehandle_new(scalehandle_class,(t_iemgui *)x,1);