Commit 558876b3 authored by Ivica Bukvic's avatar Ivica Bukvic Committed by Hans-Christoph Steiner
Browse files

Pd-0.42.5-extended-l2ork-dev-20110403.tar.bz2

parent 98bc8bd8
......@@ -124,6 +124,9 @@
#define SCALEHANDLE_WIDTH 5
#define SCALEHANDLE_HEIGHT 5
#define LABELHANDLE_WIDTH 5
#define LABELHANDLE_HEIGHT 5
typedef struct _iem_fstyle_flags
{
unsigned int x_font_style:6;
......@@ -166,6 +169,7 @@ typedef struct _scalehandle
t_pd h_pd;
t_gobj *h_master;
t_symbol *h_bindsym;
int h_scale;
char h_pathname[64];
char h_outlinetag[64];
int h_dragon;
......@@ -204,6 +208,10 @@ typedef struct _iemgui
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_iemgui;
typedef struct _iemguidummy
......
......@@ -53,6 +53,9 @@ void bng_draw_new(t_bng *x, t_glist *glist)
t_scalehandle *sh = (t_scalehandle *)x->x_gui.x_handle;
sprintf(sh->h_pathname, ".x%x.h%x", (int)canvas, (int)sh);
t_scalehandle *lh = (t_scalehandle *)x->x_gui.x_lhandle;
sprintf(lh->h_pathname, ".x%x.h%x", (int)canvas, (int)lh);
//if (glist_isvisible(canvas)) {
t_gobj *y = (t_gobj *)x;
......@@ -152,6 +155,8 @@ void bng_draw_erase(t_bng* x, t_glist* glist)
if (x->x_gui.x_fsf.x_selected) {
t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle);
sys_vgui("destroy %s\n", sh->h_pathname);
t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle);
sys_vgui("destroy %s\n", lh->h_pathname);
}
/*
sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x);
......@@ -224,6 +229,7 @@ void bng_draw_select(t_bng* x, t_glist* glist)
{
t_canvas *canvas=glist_getcanvas(glist);
t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle);
t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle);
if (glist_isvisible(canvas)) {
......@@ -239,8 +245,8 @@ void bng_draw_select(t_bng* x, t_glist* glist)
sys_vgui("canvas %s -width %d -height %d -bg $select_color -bd 0 -cursor bottom_right_corner\n",
sh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT);
sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxSCALE %lxBNG}\n",
canvas, x->x_gui.x_obj.te_xpix + x->x_gui.x_w - SCALEHANDLE_WIDTH,
x->x_gui.x_obj.te_ypix + x->x_gui.x_h - SCALEHANDLE_HEIGHT,
canvas, x->x_gui.x_obj.te_xpix + x->x_gui.x_w - SCALEHANDLE_WIDTH - 1,
x->x_gui.x_obj.te_ypix + x->x_gui.x_h - SCALEHANDLE_HEIGHT - 1,
SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT,
sh->h_pathname, x, x);
sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n",
......@@ -251,6 +257,27 @@ void bng_draw_select(t_bng* x, t_glist* glist)
sh->h_pathname, sh->h_bindsym->s_name);
x->x_gui.scale_vis = 1;
if (strcmp(x->x_gui.x_lab->s_name, "empty") != 0)
{
if (x->x_gui.label_vis)
sys_vgui("destroy %s\n", lh->h_pathname);
sys_vgui("canvas %s -width %d -height %d -bg $select_color -bd 0 -cursor crosshair\n",
lh->h_pathname, LABELHANDLE_WIDTH, LABELHANDLE_HEIGHT);
sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxLABEL %lxBNG}\n",
canvas, x->x_gui.x_obj.te_xpix+ x->x_gui.x_ldx - LABELHANDLE_WIDTH,
x->x_gui.x_obj.te_ypix + x->x_gui.x_ldy - LABELHANDLE_HEIGHT,
LABELHANDLE_WIDTH, LABELHANDLE_HEIGHT,
lh->h_pathname, x, x);
sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n",
lh->h_pathname, lh->h_bindsym->s_name);
sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n",
lh->h_pathname, lh->h_bindsym->s_name);
sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n",
lh->h_pathname, lh->h_bindsym->s_name);
x->x_gui.label_vis = 1;
}
sys_vgui(".x%lx.c addtag selected withtag %lxBNG\n", canvas, x);
}
else
......@@ -261,6 +288,8 @@ void bng_draw_select(t_bng* x, t_glist* glist)
sys_vgui(".x%lx.c dtag %lxBNG selected\n", canvas, x);
sys_vgui("destroy %s\n", sh->h_pathname);
x->x_gui.scale_vis = 0;
sys_vgui("destroy %s\n", lh->h_pathname);
x->x_gui.label_vis = 0;
}
}
}
......@@ -270,11 +299,17 @@ static void bng__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_fl
t_bng *x = (t_bng *)(sh->h_master);
if (xxx) x->x_gui.scale_offset_x = xxx;
if (yyy) x->x_gui.scale_offset_y = yyy;
if (xxx) {
x->x_gui.scale_offset_x = xxx;
x->x_gui.label_offset_x = xxx;
}
if (yyy) {
x->x_gui.scale_offset_y = yyy;
x->x_gui.label_offset_y = yyy;
}
int newstate = (int)f;
if (sh->h_dragon && newstate == 0)
if (sh->h_dragon && newstate == 0 && sh->h_scale)
{
/* done dragging */
......@@ -316,7 +351,7 @@ static void bng__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_fl
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x->x_gui.x_glist);
}
}
else if (!sh->h_dragon && newstate)
else if (!sh->h_dragon && newstate && sh->h_scale)
{
/* dragging */
if (glist_isvisible(x->x_gui.x_glist))
......@@ -332,13 +367,59 @@ static void bng__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_fl
sh->h_dragx = 0;
sh->h_dragy = 0;
}
else if (sh->h_dragon && newstate == 0 && !sh->h_scale)
{
/* done dragging */
/* first set up the undo apply */
canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x);
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_ldy = x->x_gui.x_ldy + sh->h_dragy - x->x_gui.label_offset_y;
canvas_dirty(x->x_gui.x_glist, 1);
}
int properties = gfxstub_haveproperties((void *)x);
if (properties) {
sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties);
sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", properties, x->x_gui.x_w);
//sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties);
//sys_vgui(".gfxstub%lx.dim.h_ent insert 0 %d\n", properties, x->x_gui.x_h);
}
if (glist_isvisible(x->x_gui.x_glist))
{
sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag);
bng_draw_move(x, x->x_gui.x_glist);
sys_vgui("destroy %s\n", sh->h_pathname);
iemgui_select((t_gobj *)x, x->x_gui.x_glist, 1);
canvas_fixlinesfor(x->x_gui.x_glist, (t_text *)x);
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x->x_gui.x_glist);
}
}
else if (!sh->h_dragon && newstate && !sh->h_scale)
{
/* dragging */
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;
sys_vgui("lower .x%x.h%x\n", (int)glist_getcanvas(x->x_gui.x_glist), (int)othersh);
}
sh->h_dragx = 0;
sh->h_dragy = 0;
}
sh->h_dragon = newstate;
}
static void bng__motionhook(t_scalehandle *sh,
t_floatarg f1, t_floatarg f2)
{
if (sh->h_dragon)
if (sh->h_dragon && sh->h_scale)
{
t_bng *x = (t_bng *)(sh->h_master);
int dx = (int)f1, dy = (int)f2;
......@@ -380,6 +461,38 @@ static void bng__motionhook(t_scalehandle *sh,
//sys_vgui(".gfxstub%lx.dim.h_ent insert 0 %d\n", properties, new_h);
}
}
if (sh->h_dragon && !sh->h_scale)
{
t_bng *x = (t_bng *)(sh->h_master);
int dx = (int)f1, dy = (int)f2;
int newx, newy;
newx = x->x_gui.x_obj.te_xpix + x->x_gui.x_w - x->x_gui.scale_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_dragx = dx;
sh->h_dragy = dy;
int properties = gfxstub_haveproperties((void *)x);
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;
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);
sys_vgui(".gfxstub%lx.label.xy.y_entry delete 0 end\n", properties);
sys_vgui(".gfxstub%lx.label.xy.y_entry insert 0 %d\n", properties, new_y);
}
if (glist_isvisible(x->x_gui.x_glist)) {
int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
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);
}
}
}
void bng_draw(t_bng *x, t_glist *glist, int mode)
......@@ -742,10 +855,26 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv)
pd_bind(x->x_gui.x_handle, sh->h_bindsym = gensym(buf));
sprintf(sh->h_outlinetag, "h%x", (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%x", (int)lh);
pd_bind(x->x_gui.x_lhandle, lh->h_bindsym = gensym(lhbuf));
sprintf(lh->h_outlinetag, "h%x", (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;
return (x);
}
......@@ -764,6 +893,13 @@ static void bng_ff(t_bng *x)
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);
}
}
void g_bang_setup(void)
......
......@@ -367,11 +367,39 @@ void glist_init(t_glist *x)
}
/* make a new glist. It will either be a "root" canvas or else
it appears as a "text" object in another window (canvas_getcurrnet()
it appears as a "text" object in another window (canvas_getcurrent()
tells us which.) */
t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
{
/* first alloc one byte or redundant memory to prevent creation of objects with the same "name"
which leads to double-action invoked from every single action and eventually possible crashes
we keep a list of these redundant allocations and destroy them when pd quits */
//if (x->gl_owner && x->gl_env) {
t_redundant_mem *new_rm = (t_redundant_mem *)t_getbytes(sizeof(*new_rm));
new_rm->rm_what = (int)getbytes(1);
if (rm_start == NULL) {
//fprintf(stderr,"first allocation\n");
rm_start = new_rm;
rm_end = new_rm;
}
else if (rm_start == rm_end) {
//fprintf(stderr,"second allocation\n");
rm_end = new_rm;
rm_start->rm_next = rm_end;
}
else {
//fprintf(stderr,"allocation\n");
rm_end->rm_next = new_rm;
rm_end = new_rm;
}
//}
t_canvas *x = (t_canvas *)pd_new(canvas_class);
/* now that we've created a new canvas, add canvas info to the new_rm */
new_rm->rm_canvas = x;
t_canvas *owner = canvas_getcurrent();
t_symbol *s = &s_;
int vis = 0, width = GLIST_DEFCANVASWIDTH, height = GLIST_DEFCANVASHEIGHT;
......@@ -463,6 +491,7 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
x->gl_edit = !strncmp(x->gl_name->s_name, "Untitled", 8);
x->gl_font = sys_nearestfontsize(font);
pd_pushsym(&x->gl_pd);
return(x);
}
......
......@@ -40,6 +40,20 @@ in future releases. The public (stable) API is in m_pd.h. */
extern "C" {
#endif
/* redundant struct queue for maintaining a list of redundantly
allocated memory chunks to avoid double-entry bug. these are
instantiated inside canvas_new since the bug only affects new
canvases/abstractions rather than individual objects. the queue
is destructed in m_glob.c quit call (when pd exits) */
typedef struct _redundant_mem
{
int rm_what;
t_canvas *rm_canvas;
struct _redundant_mem *rm_next;
} t_redundant_mem;
t_redundant_mem *rm_start;
t_redundant_mem *rm_end;
/* --------------------- geometry ---------------------------- */
#define IOWIDTH 7 /* width of an inlet/outlet in pixels */
......
......@@ -2313,23 +2313,24 @@ static void canvas_doregion(t_canvas *x, int xpos, int ypos, int doit)
x->gl_editor->e_ywas, xpos, ypos);
}
/*
static void canvas_mouseup_gop(t_canvas *x, t_gobj *g) {
/* simulate clearing and recreating object */
//simulate clearing and recreating object
gobj_activate(g, x, 1);
t_object *ob = pd_checkobject(&g->g_pd);
t_rtext *yyyy = glist_findrtext(x, (t_text *)&ob->ob_g);
/* copy current text */
//copy current text
char *buf;
int bufsize;
rtext_gettext(yyyy, &buf, &bufsize);
//fprintf(stderr, ">%s<\n", buf);
rtext_key(yyyy, 127, NULL);
/* recreate object with no args */
//recreate object with no args
glist_deselect(x, g);
/* object was recreated, so now it is latest in the queue */
//object was recreated, so now it is latest in the queue
t_gobj *z = x->gl_list;
while (z->g_next) {
......@@ -2341,7 +2342,7 @@ static void canvas_mouseup_gop(t_canvas *x, t_gobj *g) {
ob = pd_checkobject(&g->g_pd);
yyyy = glist_findrtext(x, (t_text *)&ob->ob_g);
/* redo the old text */
//redo the old text
int i;
for (i = 0; i < bufsize; i++) {
rtext_key(yyyy, (int)buf[i], NULL);
......@@ -2349,6 +2350,7 @@ static void canvas_mouseup_gop(t_canvas *x, t_gobj *g) {
gobj_activate(z, x, 1);
x->gl_editor->e_textdirty = 1;
}
*/
void canvas_mouseup(t_canvas *x,
t_floatarg fxpos, t_floatarg fypos, t_floatarg fwhich)
......@@ -2397,21 +2399,23 @@ void canvas_mouseup(t_canvas *x,
}
/* OK, activate it */
/* but before we do, check if this is GOP and adjust accordingly */
/*
// but before we do, check if this is GOP and adjust accordingly
//fprintf(stderr,"activate...");
if (pd_class(&g->g_pd) == canvas_class &&
((t_glist *)g)->gl_isgraph &&
canvas_isabstraction((t_glist *)g))
{
//fprintf(stderr,"gop...");
/* if mouse has not moved AND this object does not have its text hidden (otherwise we only translate the selection) */
// if mouse has not moved AND this object does not have its text hidden (otherwise we only translate the selection)
if (!(((t_glist *)g)->gl_hidetext) && !x->gl_editor->e_lastmoved) {
//fprintf(stderr,"yes\n");
canvas_mouseup_gop(x, x->gl_editor->e_selection->sel_what);
}
//else fprintf(stderr,"no\n");
}
/* else if it is a regular object */
// else if it is a regular object
*/
else {
//fprintf(stderr,"reg_obj\n");
gobj_activate(x->gl_editor->e_selection->sel_what, x, 1);
......@@ -3029,11 +3033,11 @@ static t_binbuf *canvas_docopy(t_canvas *x)
t_linetraverser t;
t_outconnect *oc;
t_binbuf *b = binbuf_new();
int c = 0;
//int c = 0;
for (y = x->gl_list; y; y = y->g_next)
{
if (glist_isselected(x, y)) {
c++;
//c++;
//fprintf(stderr, "saving object num %d\n", c);
//fprintf(stderr, "saving object >.x%lx<\n", (t_int)y);
/* introduce redundant comment to avoid recreation of old abstractions
......@@ -3042,28 +3046,28 @@ static t_binbuf *canvas_docopy(t_canvas *x)
is yet another bug in tcl/tk which means that canvas tries to do some
kind of caching behind the curtains resulting in objects not always
having unique ids, contrary to tcl/tk's canvas man page */
if (c==1) {
/*if (c==1) {
binbuf_addv(b, "ssiis;", gensym("#X"), gensym("text"),
(int)((t_text *)y)->te_xpix-30, (int)((t_text *)y)->te_ypix-30, gensym("tcltksucks"));
}
}*/
gobj_save(y, b);
}
}
//fprintf(stderr,"done saving objects\n");
linetraverser_start(&t, x);
c = 0;
//c = 0;
while (oc = linetraverser_next(&t))
{
if (glist_isselected(x, &t.tr_ob->ob_g)
&& glist_isselected(x, &t.tr_ob2->ob_g))
{
//fprintf(stderr, "lines need to be copied\n");
c = 1;
//c = 1;
binbuf_addv(b, "ssiiii;", gensym("#X"), gensym("connect"),
// glist_selectionindex(x, &t.tr_ob->ob_g, 1), t.tr_outno,
// glist_selectionindex(x, &t.tr_ob2->ob_g, 1), t.tr_inno);
glist_selectionindex(x, &t.tr_ob->ob_g, 1)+1, t.tr_outno,
glist_selectionindex(x, &t.tr_ob2->ob_g, 1)+1, t.tr_inno);
glist_selectionindex(x, &t.tr_ob->ob_g, 1), t.tr_outno,
glist_selectionindex(x, &t.tr_ob2->ob_g, 1), t.tr_inno);
// glist_selectionindex(x, &t.tr_ob->ob_g, 1)+1, t.tr_outno,
// glist_selectionindex(x, &t.tr_ob2->ob_g, 1)+1, t.tr_inno);
}
}
//if (!c) fprintf(stderr, "no lines copied\n");
......@@ -3188,7 +3192,8 @@ static void canvas_doclear(t_canvas *x)
}
restore:
canvas_dirty(x, 1);
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x);
canvas_redraw(x);
//sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x);
canvas_resume_dsp(dspstate);
}
......@@ -3294,11 +3299,11 @@ static void canvas_dopaste(t_canvas *x, t_binbuf *b)
/* select newly created objects */
for (g2 = x->gl_list, count = 0; g2; g2 = g2->g_next, count++)
if (count == nbox) {
/* delete bogus object we created in canvas_docopy in order to circumvent tcl/tk's failure
to provide "unique" id to every new instance of an object */
/*if (count == nbox) {
// delete bogus object we created in canvas_docopy in order to circumvent tcl/tk's failure
// to provide "unique" id to every new instance of an object
glist_delete(x, g2);
} else if (count > nbox) {
} else*/ if (count >= nbox) {
glist_select(x, g2);
//fprintf(stderr,"object=.x%lx glist_getcanvas(x)=.x%lx\n", (t_int)g2, (t_int)glist_getcanvas((t_glist*)g2) );
}
......
......@@ -118,10 +118,6 @@ void glist_delete(t_glist *x, t_gobj *y)
if (drawcommand)
canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(
glist_getcanvas(x)->gl_name)), 2);
//if(glist_isvisible(canvas)) {
// gobj_select(y, x, 0);
//}
gobj_delete(y, x);
if (glist_isvisible(canvas))
gobj_vis(y, x, 0);
if (x->gl_editor && (ob = pd_checkobject(&y->g_pd)))
......@@ -133,6 +129,7 @@ void glist_delete(t_glist *x, t_gobj *y)
g->g_next = y->g_next;
break;
}
gobj_delete(y, x);
pd_free(&y->g_pd);
if (chkdsp) canvas_update_dsp();
if (drawcommand)
......@@ -140,7 +137,6 @@ void glist_delete(t_glist *x, t_gobj *y)
glist_getcanvas(x)->gl_name)), 1);
canvas_setdeleting(canvas, wasdeleting);
x->gl_valid = ++glist_valid;
//canvas_redraw(x);
}
/* remove every object from a glist. Experimental. */
......
......@@ -66,7 +66,8 @@ void hradio_draw_new(t_hradio *x, t_glist *glist)
t_scalehandle *sh = (t_scalehandle *)x->x_gui.x_handle;
sprintf(sh->h_pathname, ".x%x.h%x", (int)canvas, (int)sh);
t_scalehandle *lh = (t_scalehandle *)x->x_gui.x_lhandle;
sprintf(lh->h_pathname, ".x%x.h%x", (int)canvas, (int)lh);
//if (glist_isvisible(canvas)) {
......@@ -173,6 +174,8 @@ void hradio_draw_erase(t_hradio* x, t_glist* glist)
if (x->x_gui.x_fsf.x_selected) {
t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle);
sys_vgui("destroy %s\n", sh->h_pathname);
t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle);
sys_vgui("destroy %s\n", lh->h_pathname);
}
/*
for(i=0; i<n; i++)
......@@ -256,6 +259,7 @@ void hradio_draw_select(t_hradio* x, t_glist* glist)
{
t_canvas *canvas=glist_getcanvas(glist);
t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle);
t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle);
int n=x->x_number, i;
if (glist_isvisible(canvas)) {
......@@ -274,8 +278,8 @@ void hradio_draw_select(t_hradio* x, t_glist* glist)
sys_vgui("canvas %s -width %d -height %d -bg $select_color -bd 0 -cursor bottom_right_corner\n",
sh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT);
sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxSCALE %lxHRDO}\n",
canvas, x->x_gui.x_obj.te_xpix + x->x_gui.x_w * x->x_number - SCALEHANDLE_WIDTH,
x->x_gui.x_obj.te_ypix + x->x_gui.x_h - SCALEHANDLE_HEIGHT,
canvas, x->x_gui.x_obj.te_xpix + x->x_gui.x_w * x->x_number - SCALEHANDLE_WIDTH - 1,
x->x_gui.x_obj.te_ypix + x->x_gui.x_h - SCALEHANDLE_HEIGHT - 1,
SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT,
sh->h_pathname, x, x);
sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n",
......@@ -285,6 +289,26 @@ void hradio_draw_select(t_hradio* x, t_glist* glist)
sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n",
sh->h_pathname, sh->h_bindsym->s_name);
x->x_gui.scale_vis = 1;
if (strcmp(x->x_gui.x_lab->s_name, "empty") != 0)
{
if (x->x_gui.label_vis)
sys_vgui("destroy %s\n", lh->h_pathname);
sys_vgui("canvas %s -width %d -height %d -bg $select_color -bd 0 -cursor crosshair\n",
lh->h_pathname, LABELHANDLE_WIDTH, LABELHANDLE_HEIGHT);
sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxLABEL %lxHRDO}\n",
canvas, x->x_gui.x_obj.te_xpix+ x->x_gui.x_ldx - LABELHANDLE_WIDTH,
x->x_gui.x_obj.te_ypix + x->x_gui.x_ldy - LABELHANDLE_HEIGHT,
LABELHANDLE_WIDTH, LABELHANDLE_HEIGHT,
lh->h_pathname, x, x);
sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n",
lh->h_pathname, lh->h_bindsym->s_name);
sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n",
lh->h_pathname, lh->h_bindsym->s_name);
sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n",
lh->h_pathname, lh->h_bindsym->s_name);
x->x_gui.label_vis = 1;
}
sys_vgui(".x%lx.c addtag selected withtag %lxHRDO\n", canvas, x);
}
......@@ -300,6 +324,8 @@ void hradio_draw_select(t_hradio* x, t_glist* glist)
x->x_gui.x_lcol);
sys_vgui("destroy %s\n", sh->h_pathname);
x->x_gui.scale_vis = 0;
sys_vgui("destroy %s\n", lh->h_pathname);
x->x_gui.label_vis = 0;
}
}
}
......@@ -309,11 +335,17 @@ static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t
t_hradio *x = (t_hradio *)(sh->h_master);
if (xxx) x->x_gui.scale_offset_x = xxx;
if (yyy) x->x_gui.scale_offset_y = yyy;
if (xxx) {
x->x_gui.scale_offset_x = xxx;
x->x_gui.label_offset_x = xxx;
}
if (yyy) {
x->x_gui.scale_offset_y = yyy;
x->x_gui.label_offset_y = yyy;
}
int newstate = (int)f;
if (sh->h_dragon && newstate == 0)
if (sh->h_dragon && newstate == 0 && sh->h_scale)
{
/* done dragging */
......@@ -353,7 +385,7 @@ static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x->x_gui.x_glist);
}
}
else if (!sh->h_dragon && newstate)
else if (!sh->h_dragon && newstate && sh->h_scale)
{
/* dragging */
if (glist_isvisible(x->x_gui.x_glist))
......@@ -369,13 +401,60 @@ static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t
sh->h_dragx = 0;
sh->h_dragy = 0;
}
else if (sh->h_dragon && newstate == 0 && !sh->h_scale)
{