From 063d78e4f74400a2b9410ccc4b214bf09665fba6 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Fri, 14 Mar 2014 19:30:24 -0400 Subject: [PATCH] refactored files --- pd/src/g_magicglass.c | 235 ++++---- pd/src/g_mycanvas.c | 847 +++++++++++++++------------- pd/src/g_numbox.c | 1213 ++++++++++++++++++++++------------------- 3 files changed, 1257 insertions(+), 1038 deletions(-) diff --git a/pd/src/g_magicglass.c b/pd/src/g_magicglass.c index dc139f4f8..bdde53081 100644 --- a/pd/src/g_magicglass.c +++ b/pd/src/g_magicglass.c @@ -18,7 +18,7 @@ void magicGlass_clearText(t_magicGlass *x); void magicGlass_bind(t_magicGlass *x, t_object *obj, int outno) { - //fprintf(stderr,"magicglass_bind %lx\n", (t_int)x); + //fprintf(stderr,"magicglass_bind %lx\n", (t_int)x); if (x->x_connectedObj != obj) { if (x->x_connectedObj) @@ -30,15 +30,15 @@ void magicGlass_bind(t_magicGlass *x, t_object *obj, int outno) } x->x_connectedObj = obj; x->x_connectedOutno = outno; - x->x_maxSize = 1; - magicGlass_clearText(x); + x->x_maxSize = 1; + magicGlass_clearText(x); obj_connect(obj, outno, &x->x_obj, 0); } } void magicGlass_unbind(t_magicGlass *x) { - //fprintf(stderr,"magicglass_unbind %lx\n", (t_int)x); + //fprintf(stderr,"magicglass_unbind %lx\n", (t_int)x); if (x->x_connectedObj) { obj_disconnect(x->x_connectedObj, @@ -51,43 +51,53 @@ void magicGlass_unbind(t_magicGlass *x) x->x_sampleCount = 0; x->x_connectedObj = NULL; x->x_connectedOutno = 0; - x->x_maxSize = 1; + x->x_maxSize = 1; } void magicGlass_updateText(t_magicGlass *x, int moved) { - //fprintf(stderr,"magicglass_updateText\n"); + //fprintf(stderr,"magicglass_updateText\n"); int bgSize; - x->x_display_font = sys_hostfontsize(glist_getfont(x->x_c)); + x->x_display_font = sys_hostfontsize(glist_getfont(x->x_c)); if (x->x_visible) { - if (!moved) { - char *color; - if (x->x_issignal || strcmp(x->x_old_string, x->x_string)) { - color = "$pd_colors(magic_glass_text)"; - } - else { - color = "$pd_colors(magic_glass_flash)"; - clock_delay(x->x_flashClock, MG_CLOCK_FLASH_DELAY); - } - sys_vgui(".x%x.c itemconfigure magicGlassText -text {%s} -fill %s -font {{%s} -%d %s}\n", - x->x_c, - x->x_string, - color, - sys_font, x->x_display_font, sys_fontweight); - } else { - sys_vgui(".x%x.c itemconfigure magicGlassText -text {%s}\n", - x->x_c, - x->x_string); - } + if (!moved) + { + char *color; + if (x->x_issignal || strcmp(x->x_old_string, x->x_string)) + { + color = "$pd_colors(magic_glass_text)"; + } + else + { + color = "$pd_colors(magic_glass_flash)"; + clock_delay(x->x_flashClock, MG_CLOCK_FLASH_DELAY); + } + sys_vgui(".x%x.c itemconfigure magicGlassText -text {%s} " + "-fill %s -font {{%s} -%d %s}\n", + x->x_c, + x->x_string, + color, + sys_font, x->x_display_font, sys_fontweight); + } + else + { + sys_vgui(".x%x.c itemconfigure magicGlassText -text {%s}\n", + x->x_c, + x->x_string); + } if (strlen(x->x_string) > 0) { - if (strlen(x->x_string) > x->x_maxSize) x->x_maxSize = strlen(x->x_string); + if (strlen(x->x_string) > x->x_maxSize) + x->x_maxSize = strlen(x->x_string); } - bgSize = x->x_x + (sys_fontwidth(x->x_display_font) * x->x_maxSize) + 26; - //fprintf(stderr,"%d %d %d : %d %d\n", sys_fontheight(x->x_display_font), sys_fontwidth(x->x_display_font), x->x_maxSize, x->x_x, bgSize); + bgSize = x->x_x + + (sys_fontwidth(x->x_display_font) * x->x_maxSize) + 26; + //fprintf(stderr,"%d %d %d : %d %d\n", + // sys_fontheight(x->x_display_font), + // sys_fontwidth(x->x_display_font), x->x_maxSize, x->x_x, bgSize); sys_vgui(".x%x.c coords magicGlassText %d %d\n", x->x_c, x->x_x + 20, @@ -111,24 +121,29 @@ void magicGlass_updateText(t_magicGlass *x, int moved) void magicGlass_drawNew(t_magicGlass *x) { - //fprintf(stderr,"magicglass_drawNew\n"); - sys_vgui(".x%x.c create prect 0 0 0 0 -stroke $pd_colors(magic_glass_bg) -fill $pd_colors(magic_glass_bg) -tags magicGlassBg\n", + //fprintf(stderr,"magicglass_drawNew\n"); + sys_vgui(".x%x.c create prect 0 0 0 0 -stroke $pd_colors(magic_glass_bg) " + "-fill $pd_colors(magic_glass_bg) -tags magicGlassBg\n", x->x_c); - sys_vgui(".x%x.c create ppolygon 0 0 0 0 0 0 -fill $pd_colors(magic_glass_bd) -strokewidth 1 -tags magicGlassLine\n", + sys_vgui(".x%x.c create ppolygon 0 0 0 0 0 0 " + "-fill $pd_colors(magic_glass_bd) -strokewidth 1 " + "-tags magicGlassLine\n", x->x_c); - sys_vgui(".x%x.c create text 0 0 -text {} -anchor w -fill $pd_colors(magic_glass_flash) -font {{%s} -%d %s} -tags magicGlassText\n", + sys_vgui(".x%x.c create text 0 0 -text {} -anchor w " + "-fill $pd_colors(magic_glass_flash) " + "-font {{%s} -%d %s} -tags magicGlassText\n", x->x_c, sys_font, x->x_display_font, sys_fontweight); sys_vgui(".x%x.c raise magicGlassBg\n", x->x_c); sys_vgui(".x%x.c raise magicGlassText\n", x->x_c); magicGlass_updateText(x, 0); - clock_delay(x->x_flashClock, MG_CLOCK_FLASH_DELAY); + clock_delay(x->x_flashClock, MG_CLOCK_FLASH_DELAY); } void magicGlass_undraw(t_magicGlass *x) { - //fprintf(stderr,"magicglass_undraw\n"); + //fprintf(stderr,"magicglass_undraw\n"); sys_vgui(".x%x.c delete magicGlassBg\n", x->x_c); sys_vgui(".x%x.c delete magicGlassLine\n", x->x_c); sys_vgui(".x%x.c delete magicGlassText\n", x->x_c); @@ -136,23 +151,24 @@ void magicGlass_undraw(t_magicGlass *x) void magicGlass_flashText(t_magicGlass *x) { - //fprintf(stderr,"magicglass_flashText\n"); - sys_vgui(".x%x.c itemconfigure magicGlassText -fill $pd_colors(magic_glass_text)\n", + //fprintf(stderr,"magicglass_flashText\n"); + sys_vgui(".x%x.c itemconfigure magicGlassText " + "-fill $pd_colors(magic_glass_text)\n", x->x_c); } void magicGlass_clearText(t_magicGlass *x) { - //fprintf(stderr,"magicglass_clearText\n"); - strcpy(x->x_old_string, x->x_string); + //fprintf(stderr,"magicglass_clearText\n"); + strcpy(x->x_old_string, x->x_string); x->x_string[0] = 0; magicGlass_updateText(x, 0); } void magicGlass_bang(t_magicGlass *x) { - x->x_issignal = 0; - strcpy(x->x_old_string, x->x_string); + x->x_issignal = 0; + strcpy(x->x_old_string, x->x_string); strcpy(x->x_string, "bang"); magicGlass_updateText(x, 0); clock_delay(x->x_clearClock, MG_CLOCK_CLEAR_DELAY); @@ -160,8 +176,8 @@ void magicGlass_bang(t_magicGlass *x) void magicGlass_float(t_magicGlass *x, t_float f) { - x->x_issignal = 0; - strcpy(x->x_old_string, x->x_string); + x->x_issignal = 0; + strcpy(x->x_old_string, x->x_string); sprintf(x->x_string, "%g", f); magicGlass_updateText(x, 0); clock_delay(x->x_clearClock, MG_CLOCK_CLEAR_DELAY); @@ -169,8 +185,8 @@ void magicGlass_float(t_magicGlass *x, t_float f) void magicGlass_symbol(t_magicGlass *x, t_symbol *sym) { - x->x_issignal = 0; - strcpy(x->x_old_string, x->x_string); + x->x_issignal = 0; + strcpy(x->x_old_string, x->x_string); sprintf(x->x_string, "symbol %s", sym->s_name); magicGlass_updateText(x, 0); clock_delay(x->x_clearClock, MG_CLOCK_CLEAR_DELAY); @@ -182,9 +198,9 @@ void magicGlass_anything(t_magicGlass *x, t_symbol *sym, int argc, t_atom *argv) char valueString[4096]; int i; - x->x_issignal = 0; + x->x_issignal = 0; - strcpy(x->x_old_string, x->x_string); + strcpy(x->x_old_string, x->x_string); strcpy(aString, sym->s_name); valueString[0] = 0; for (i = 0; i < argc; i++) @@ -211,13 +227,13 @@ void magicGlass_list(t_magicGlass *x, t_symbol *sym, int argc, t_atom *argv) char valueString[4096]; int i; - x->x_issignal = 0; + x->x_issignal = 0; aString[0] = 0; valueString[0] = 0; - strcpy(x->x_old_string, x->x_string); - strcpy(aString, sym->s_name); + strcpy(x->x_old_string, x->x_string); + strcpy(aString, sym->s_name); for (i = 0; i < argc; i++) { if (argv[i].a_type == A_SYMBOL) @@ -243,12 +259,13 @@ void magicGlass_setCanvas(t_magicGlass *x, t_glist *c) void magicGlass_show(t_magicGlass *x) { - //fprintf(stderr,"magicglass_show\n"); - if (!x->x_visible) { - x->x_sampleCount = 0; - x->x_minSample = 999999; - x->x_maxSample = -999999; - x->x_string[0] = 0; + //fprintf(stderr,"magicglass_show\n"); + if (!x->x_visible) + { + x->x_sampleCount = 0; + x->x_minSample = 999999; + x->x_maxSample = -999999; + x->x_string[0] = 0; x->x_visible = 1; magicGlass_drawNew(x); } @@ -256,20 +273,21 @@ void magicGlass_show(t_magicGlass *x) void magicGlass_hide(t_magicGlass *x) { - //fprintf(stderr,"magicglass_hide\n"); - if (x->x_visible) { + //fprintf(stderr,"magicglass_hide\n"); + if (x->x_visible) + { magicGlass_undraw(x); - x->x_sampleCount = 0; - x->x_minSample = 999999; - x->x_maxSample = -999999; - x->x_string[0] = 0; - x->x_visible = 0; - } + x->x_sampleCount = 0; + x->x_minSample = 999999; + x->x_maxSample = -999999; + x->x_string[0] = 0; + x->x_visible = 0; + } } void magicGlass_moveText(t_magicGlass *x, int pX, int pY) { - //fprintf(stderr,"magicglass_moveText\n"); + //fprintf(stderr,"magicglass_moveText\n"); int bgSize; x->x_x = pX; @@ -279,7 +297,7 @@ void magicGlass_moveText(t_magicGlass *x, int pX, int pY) int magicGlass_bound(t_magicGlass *x) { - //fprintf(stderr,"magicglass_bound\n"); + //fprintf(stderr,"magicglass_bound\n"); if (x->x_connectedObj != NULL) return 1; else @@ -288,7 +306,7 @@ int magicGlass_bound(t_magicGlass *x) int magicGlass_isOn(t_magicGlass *x) { - //fprintf(stderr,"magicglass_isOn\n"); + //fprintf(stderr,"magicglass_isOn\n"); if (x->x_viewOn) return 1; else @@ -297,7 +315,7 @@ int magicGlass_isOn(t_magicGlass *x) void magicGlass_setOn(t_magicGlass *x, int i) { - //fprintf(stderr,"magicglass_setOn\n"); + //fprintf(stderr,"magicglass_setOn\n"); if (i) { x->x_viewOn = 1; @@ -310,20 +328,21 @@ void magicGlass_setOn(t_magicGlass *x, int i) void magicGlass_setDsp(t_magicGlass *x, int i) { - //fprintf(stderr,"magicglass_setDsp\n"); - if (i != x->x_dspOn) { - if (i) - { - x->x_dspOn = 1; - x->x_sampleCount = 0; - x->x_minSample = 999999; - x->x_maxSample = -999999; - } - else - { - x->x_dspOn = 0; - } - } + //fprintf(stderr,"magicglass_setDsp\n"); + if (i != x->x_dspOn) + { + if (i) + { + x->x_dspOn = 1; + x->x_sampleCount = 0; + x->x_minSample = 999999; + x->x_maxSample = -999999; + } + else + { + x->x_dspOn = 0; + } + } } t_int *magicGlass_perform(t_int *w) @@ -331,29 +350,31 @@ t_int *magicGlass_perform(t_int *w) t_magicGlass *x = (t_magicGlass *)(w[1]); if (x->x_dspOn && x->x_connectedObj) { - //fprintf(stderr,"magicglass_perform\n"); - float *in = (float *)(w[2]); - int N = (int)(w[3]); - int i; + //fprintf(stderr,"magicglass_perform\n"); + float *in = (float *)(w[2]); + int N = (int)(w[3]); + int i; for (i = 0; i < N; i++) { if (in[i] > x->x_maxSample) x->x_maxSample = in[i]; if (in[i] < x->x_minSample) - x->x_minSample = in[i]; + x->x_minSample = in[i]; x->x_sampleCount++; if (x->x_sampleCount >= MG_SAMPLE_COUNT) { - char l[64], m[64], h[64]; - sprintf(l, "%s%#g", (x->x_minSample < 0.0f ? "" : " "), x->x_minSample); - l[6] = '\0'; - sprintf(m, "%s%#g", (in[i] < 0.0f ? "" : " "), in[i]); - m[6] = '\0'; - sprintf(h, "%s%#g", (x->x_maxSample < 0.0f ? "" : " "), x->x_maxSample); - h[6] = '\0'; + char l[64], m[64], h[64]; + sprintf(l, "%s%#g", (x->x_minSample < 0.0f ? "" : " "), + x->x_minSample); + l[6] = '\0'; + sprintf(m, "%s%#g", (in[i] < 0.0f ? "" : " "), in[i]); + m[6] = '\0'; + sprintf(h, "%s%#g", (x->x_maxSample < 0.0f ? "" : " "), + x->x_maxSample); + h[6] = '\0'; sprintf(x->x_string, "~ %s %s %s", l, m, h); magicGlass_updateText(x, 0); - //x->x_minSample = 999999; + //x->x_minSample = 999999; //x->x_maxSample = -999999; x->x_sampleCount = 0; } @@ -364,14 +385,14 @@ t_int *magicGlass_perform(t_int *w) void magicGlass_dsp(t_magicGlass *x, t_signal **sp) { - //fprintf(stderr,"magicglass_dsp\n"); + //fprintf(stderr,"magicglass_dsp\n"); dsp_add(magicGlass_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); - x->x_issignal = 1; + x->x_issignal = 1; } void *magicGlass_new(t_glist *c) { - //fprintf(stderr,"magicglass_new\n"); + //fprintf(stderr,"magicglass_new\n"); t_magicGlass *x = (t_magicGlass *)pd_new(magicGlass_class); x->x_connectedObj = NULL; x->x_connectedOutno = 0; @@ -384,19 +405,19 @@ void *magicGlass_new(t_glist *c) x->x_sampleCount = 0; x->x_clearClock = clock_new(x, (t_method)magicGlass_clearText); x->x_flashClock = clock_new(x, (t_method)magicGlass_flashText); - x->x_maxSize = 1; - x->x_issignal = 0; - x->x_display_font = 9; + x->x_maxSize = 1; + x->x_issignal = 0; + x->x_display_font = 9; return x; } void magicGlass_free(t_magicGlass *x) { - //fprintf(stderr,"magicglass_free %lx\n", (t_int)x); - magicGlass_unbind(x); + //fprintf(stderr,"magicglass_free %lx\n", (t_int)x); + magicGlass_unbind(x); x->x_dspOn = 0; clock_free(x->x_clearClock); - clock_free(x->x_flashClock); + clock_free(x->x_flashClock); } void magicGlass_setup(void) @@ -410,9 +431,9 @@ void magicGlass_setup(void) 0); CLASS_MAINSIGNALIN(magicGlass_class, t_magicGlass, x_sigF); class_addmethod(magicGlass_class, - (t_method)magicGlass_dsp, - gensym("dsp"), - 0); + (t_method)magicGlass_dsp, + gensym("dsp"), + 0); class_addbang(magicGlass_class, (t_method)magicGlass_bang); class_addfloat(magicGlass_class, (t_method)magicGlass_float); class_addsymbol(magicGlass_class, (t_method)magicGlass_symbol); diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c index f6b4d43dd..8fe240308 100644 --- a/pd/src/g_mycanvas.c +++ b/pd/src/g_mycanvas.c @@ -41,30 +41,33 @@ void my_canvas_draw_new(t_my_canvas *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); - - //if (glist_isvisible(glist)) { - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x -stroke #%6.6x -tags {%lxRECT %lxMYCNV %s text iemgui}\n", - canvas, xpos, ypos, - xpos + x->x_vis_w, ypos + x->x_vis_h, - x->x_gui.x_bcol, x->x_gui.x_bcol, x, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke #%6.6x -tags {%lxBASE %lxMYCNV %s text iemgui}\n", - canvas, xpos, ypos, - xpos + x->x_gui.x_w, ypos + x->x_gui.x_h, - x->x_gui.x_bcol, x, x, nlet_tag); - sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ - -font {{%s} -%d %s} -fill #%6.6x -tags {%lxLABEL %lxMYCNV %s text iemgui}\n", - canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, - strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", - x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x, x, nlet_tag); - //} + 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); + + //if (glist_isvisible(glist) { + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x -stroke #%6.6x " + "-tags {%lxRECT %lxMYCNV %s text iemgui}\n", + canvas, xpos, ypos, + xpos + x->x_vis_w, ypos + x->x_vis_h, + x->x_gui.x_bcol, x->x_gui.x_bcol, x, x, nlet_tag); + sys_vgui(".x%lx.c create prect %d %d %d %d -stroke #%6.6x " + "-tags {%lxBASE %lxMYCNV %s text iemgui}\n", + canvas, xpos, ypos, + xpos + x->x_gui.x_w, ypos + x->x_gui.x_h, + x->x_gui.x_bcol, x, x, nlet_tag); + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " + "-font {{%s} -%d %s} -fill #%6.6x " + "-tags {%lxLABEL %lxMYCNV %s text iemgui}\n", + canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", + x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_lcol, x, x, nlet_tag); + //} } void my_canvas_draw_move(t_my_canvas *x, t_glist *glist) @@ -73,38 +76,41 @@ void my_canvas_draw_move(t_my_canvas *x, t_glist *glist) int ypos=text_ypix(&x->x_gui.x_obj, glist); t_canvas *canvas=glist_getcanvas(glist); - if (glist_isvisible(canvas)) { - - sys_vgui(".x%lx.c coords %lxRECT %d %d %d %d\n", - canvas, x, xpos, ypos, xpos + x->x_vis_w, - ypos + x->x_vis_h); - sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", - canvas, x, xpos, ypos, - xpos + x->x_gui.x_w, ypos + x->x_gui.x_h); - sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", - canvas, x, xpos+x->x_gui.x_ldx, - ypos+x->x_gui.x_ldy); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) { - my_canvas_draw_select(x, x->x_gui.x_glist); - } - } + if (glist_isvisible(canvas)) + { + + sys_vgui(".x%lx.c coords %lxRECT %d %d %d %d\n", + canvas, x, xpos, ypos, xpos + x->x_vis_w, + ypos + x->x_vis_h); + sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", + canvas, x, xpos, ypos, + xpos + x->x_gui.x_w, ypos + x->x_gui.x_h); + sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", + canvas, x, xpos+x->x_gui.x_ldx, + ypos+x->x_gui.x_ldy); + /* redraw scale handle rectangle if selected */ + if (x->x_gui.x_fsf.x_selected) + { + my_canvas_draw_select(x, x->x_gui.x_glist); + } + } } void my_canvas_draw_erase(t_my_canvas* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - sys_vgui(".x%lx.c delete %lxMYCNV\n", canvas, x); - sys_vgui(".x%lx.c dtag all %lxMYCNV\n", canvas, x); - 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); - sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); - t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); - sys_vgui("destroy %s\n", lh->h_pathname); - sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); - } + sys_vgui(".x%lx.c delete %lxMYCNV\n", canvas, x); + sys_vgui(".x%lx.c dtag all %lxMYCNV\n", canvas, x); + 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); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); + sys_vgui("destroy %s\n", lh->h_pathname); + sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); + } //sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x); //sys_vgui(".x%lx.c delete %lxRECT\n", canvas, x); //sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x); @@ -114,307 +120,356 @@ void my_canvas_draw_config(t_my_canvas* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - /* - char color[64]; - if (x->x_gui.x_fsf.x_selected) - sprintf(color, "$pd_colors(selection)"); - else - sprintf(color, "#%6.6x", x->x_gui.x_bcol); - */ - - sys_vgui(".x%lx.c itemconfigure %lxRECT -fill #%6.6x -stroke #%6.6x\n", canvas, x, - x->x_gui.x_bcol, x->x_gui.x_bcol); - if (x->x_gui.x_fsf.x_selected && x->x_gui.x_glist == canvas) - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke $pd_colors(selection)\n", canvas, x); - else - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke #%6.6x\n", canvas, x, + /* + char color[64]; + if (x->x_gui.x_fsf.x_selected) + sprintf(color, "$pd_colors(selection)"); + else + sprintf(color, "#%6.6x", x->x_gui.x_bcol); + */ + + sys_vgui(".x%lx.c itemconfigure %lxRECT -fill #%6.6x -stroke #%6.6x\n", + canvas, x, x->x_gui.x_bcol, x->x_gui.x_bcol); + if (x->x_gui.x_fsf.x_selected && x->x_gui.x_glist == canvas) + sys_vgui(".x%lx.c itemconfigure %lxBASE " + "-stroke $pd_colors(selection)\n", + canvas, x); + else + sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke #%6.6x\n", canvas, x, x->x_gui.x_bcol); - sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n", + sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} " + "-fill #%6.6x -text {%s} \n", canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, + x->x_gui.x_lcol, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); } void my_canvas_draw_select(t_my_canvas* 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)) { - - if(x->x_gui.x_fsf.x_selected) - { - // check if we are drawing inside a gop abstraction visible on parent canvas - // if so, disable highlighting - if (x->x_gui.x_glist == glist_getcanvas(glist)) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke $pd_colors(selection)\n", canvas, x); - - if (x->x_gui.scale_vis) { - sys_vgui("destroy %s\n", sh->h_pathname); - sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); - } - - 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); - sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxSCALE %lxMYCNV %s}\n", - canvas, x->x_gui.x_obj.te_xpix + x->x_vis_w - SCALEHANDLE_WIDTH - 1, - x->x_gui.x_obj.te_ypix + x->x_vis_h - SCALEHANDLE_HEIGHT - 1, - SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT, - sh->h_pathname, x, x, nlet_tag); - sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n", - sh->h_pathname, sh->h_bindsym->s_name); - sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n", - sh->h_pathname, sh->h_bindsym->s_name); - 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(".x%lx.c delete %lxLABELH\n", canvas, x); - } - - sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -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 %lxLABELH %lxMYCNV %s}\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, x, nlet_tag); - 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 %lxMYCNV\n", canvas, x); - } - else - { - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke #%6.6x\n", canvas, x, x->x_gui.x_bcol); - sys_vgui(".x%lx.c dtag %lxMYCNV selected\n", canvas, x); - sys_vgui("destroy %s\n", sh->h_pathname); - sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); - x->x_gui.scale_vis = 0; - sys_vgui("destroy %s\n", lh->h_pathname); - sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); - x->x_gui.label_vis = 0; - } - //} + t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle); + t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); + + //if (glist_isvisible(canvas)) { + + if(x->x_gui.x_fsf.x_selected) + { + // check if we are drawing inside a gop abstraction + // visible on parent canvas + // if so, disable highlighting + if (x->x_gui.x_glist == glist_getcanvas(glist)) + { + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + sys_vgui(".x%lx.c itemconfigure %lxBASE " + "-stroke $pd_colors(selection)\n", canvas, x); + + if (x->x_gui.scale_vis) + { + sys_vgui("destroy %s\n", sh->h_pathname); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + } + + 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); + sys_vgui(".x%x.c create window %d %d -anchor nw " + "-width %d -height %d -window %s " + "-tags {%lxSCALE %lxMYCNV %s}\n", + canvas, + x->x_gui.x_obj.te_xpix + x->x_vis_w - + SCALEHANDLE_WIDTH - 1, + x->x_gui.x_obj.te_ypix + x->x_vis_h - + SCALEHANDLE_HEIGHT - 1, + SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT, + sh->h_pathname, x, x, nlet_tag); + sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n", + sh->h_pathname, sh->h_bindsym->s_name); + sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n", + sh->h_pathname, sh->h_bindsym->s_name); + 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(".x%lx.c delete %lxLABELH\n", canvas, x); + } + + sys_vgui("canvas %s -width %d -height %d " + "-bg $pd_colors(selection) " + "-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 %lxLABELH %lxMYCNV %s}\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, x, nlet_tag); + 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 %lxMYCNV\n", canvas, x); + } + else + { + sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke #%6.6x\n", + canvas, x, x->x_gui.x_bcol); + sys_vgui(".x%lx.c dtag %lxMYCNV selected\n", canvas, x); + sys_vgui("destroy %s\n", sh->h_pathname); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + x->x_gui.scale_vis = 0; + sys_vgui("destroy %s\n", lh->h_pathname); + sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); + x->x_gui.label_vis = 0; + } + //} } -static void my_canvas__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_floatarg yyy) +static void my_canvas__clickhook(t_scalehandle *sh, t_floatarg f, + 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); - 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; - } + 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 && 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_vis_w = x->x_vis_w + sh->h_dragx - x->x_gui.scale_offset_x; - if (x->x_vis_w < SCALE_CNV_MINWIDTH) - x->x_vis_w = SCALE_CNV_MINWIDTH; - x->x_vis_h = x->x_vis_h + sh->h_dragy - x->x_gui.scale_offset_y; - if (x->x_vis_h < SCALE_CNV_MINHEIGHT) - x->x_vis_h = SCALE_CNV_MINHEIGHT; - - if (x->x_gui.x_w > x->x_vis_w || x->x_gui.x_h > x->x_vis_h) { - x->x_gui.x_w = (x->x_vis_w > x->x_vis_h ? x->x_vis_h : x->x_vis_w); - x->x_gui.x_h = x->x_gui.x_w; - } - canvas_dirty(x->x_gui.x_glist, 1); - } - - int properties = gfxstub_haveproperties((void *)x); - - if (properties) { - sys_vgui(".gfxstub%lx.rng.min_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.rng.min_ent insert 0 %d\n", properties, x->x_vis_w); - sys_vgui(".gfxstub%lx.rng.max_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.rng.max_ent insert 0 %d\n", properties, x->x_vis_h); - 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); - } - - if (glist_isvisible(x->x_gui.x_glist)) - { - sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); - my_canvas_draw_move(x, x->x_gui.x_glist); - 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); - } + /* 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_vis_w = x->x_vis_w + sh->h_dragx - x->x_gui.scale_offset_x; + if (x->x_vis_w < SCALE_CNV_MINWIDTH) + x->x_vis_w = SCALE_CNV_MINWIDTH; + x->x_vis_h = x->x_vis_h + sh->h_dragy - x->x_gui.scale_offset_y; + if (x->x_vis_h < SCALE_CNV_MINHEIGHT) + x->x_vis_h = SCALE_CNV_MINHEIGHT; + + if (x->x_gui.x_w > x->x_vis_w || x->x_gui.x_h > x->x_vis_h) + { + x->x_gui.x_w = (x->x_vis_w > x->x_vis_h ? x->x_vis_h : x->x_vis_w); + x->x_gui.x_h = x->x_gui.x_w; + } + canvas_dirty(x->x_gui.x_glist, 1); + } + + int properties = gfxstub_haveproperties((void *)x); + + if (properties) + { + sys_vgui(".gfxstub%lx.rng.min_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.rng.min_ent insert 0 %d\n", properties, x->x_vis_w); + sys_vgui(".gfxstub%lx.rng.max_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.rng.max_ent insert 0 %d\n", properties, x->x_vis_h); + 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); + } + + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); + my_canvas_draw_move(x, x->x_gui.x_glist); + 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); - sys_vgui(".x%x.c create prect %d %d %d %d\ - -stroke $pd_colors(selection) -strokewidth 1 -tags %s\n", - x->x_gui.x_glist, x->x_gui.x_obj.te_xpix, x->x_gui.x_obj.te_ypix, - x->x_gui.x_obj.te_xpix + x->x_vis_w, - x->x_gui.x_obj.te_ypix + x->x_vis_h, sh->h_outlinetag); - } - - sh->h_dragx = 0; - sh->h_dragy = 0; + /* dragging */ + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui("lower %s\n", sh->h_pathname); + sys_vgui(".x%x.c create prect %d %d %d %d " + "-stroke $pd_colors(selection) -strokewidth 1 -tags %s\n", + x->x_gui.x_glist, x->x_gui.x_obj.te_xpix, + x->x_gui.x_obj.te_ypix, + x->x_gui.x_obj.te_xpix + x->x_vis_w, + x->x_gui.x_obj.te_ypix + x->x_vis_h, sh->h_outlinetag); + } + + 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.label.xy.x_entry delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.label.xy.x_entry insert 0 %d\n", properties, x->x_gui.x_ldx); - 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, x->x_gui.x_ldy); - } - - if (glist_isvisible(x->x_gui.x_glist)) - { - my_canvas_draw_move(x, x->x_gui.x_glist); - 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); - } + /* 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.label.xy.x_entry delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.label.xy.x_entry insert 0 %d\n", properties, + x->x_gui.x_ldx); + 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, + x->x_gui.x_ldy); + } + + if (glist_isvisible(x->x_gui.x_glist)) + { + my_canvas_draw_move(x, x->x_gui.x_glist); + 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%lx.h%lx\n", (t_int)glist_getcanvas(x->x_gui.x_glist), (t_int)othersh); - } - - sh->h_dragx = 0; - sh->h_dragy = 0; + /* 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%lx.h%lx\n", + (t_int)glist_getcanvas(x->x_gui.x_glist), (t_int)othersh); + } + + sh->h_dragx = 0; + sh->h_dragy = 0; } sh->h_dragon = newstate; } static void my_canvas__motionhook(t_scalehandle *sh, - t_floatarg f1, t_floatarg f2) + t_floatarg f1, t_floatarg f2) { if (sh->h_dragon && sh->h_scale) { - t_my_canvas *x = (t_my_canvas *)(sh->h_master); - int dx = (int)f1, dy = (int)f2; - int newx, newy; - newx = x->x_gui.x_obj.te_xpix + x->x_vis_w - x->x_gui.scale_offset_x + dx; - newy = x->x_gui.x_obj.te_ypix + x->x_vis_h - x->x_gui.scale_offset_y + dy; - - if (newx < x->x_gui.x_obj.te_xpix + SCALE_CNV_MINWIDTH) - newx = x->x_gui.x_obj.te_xpix + SCALE_CNV_MINWIDTH; - if (newy < x->x_gui.x_obj.te_ypix + SCALE_CNV_MINHEIGHT) - newy = x->x_gui.x_obj.te_ypix + SCALE_CNV_MINHEIGHT; - - if (glist_isvisible(x->x_gui.x_glist)) { - sys_vgui(".x%x.c coords %s %d %d %d %d\n", - x->x_gui.x_glist, sh->h_outlinetag, x->x_gui.x_obj.te_xpix, - x->x_gui.x_obj.te_ypix, newx, newy); - } - sh->h_dragx = dx; - sh->h_dragy = dy; - - int properties = gfxstub_haveproperties((void *)x); - - if (properties) { - int new_w = x->x_vis_w - x->x_gui.scale_offset_x + sh->h_dragx; - int new_h = x->x_vis_h - x->x_gui.scale_offset_y + sh->h_dragy; - sys_vgui(".gfxstub%lx.rng.min_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.rng.min_ent insert 0 %d\n", properties, new_w); - sys_vgui(".gfxstub%lx.rng.max_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.rng.max_ent insert 0 %d\n", properties, new_h); - int min = (new_w < new_h ? new_w : new_h); - if (min <= x->x_gui.x_w) { - sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", properties, min); - } - } + t_my_canvas *x = (t_my_canvas *)(sh->h_master); + int dx = (int)f1, dy = (int)f2; + int newx, newy; + newx = x->x_gui.x_obj.te_xpix + x->x_vis_w - + x->x_gui.scale_offset_x + dx; + newy = x->x_gui.x_obj.te_ypix + x->x_vis_h - + x->x_gui.scale_offset_y + dy; + + if (newx < x->x_gui.x_obj.te_xpix + SCALE_CNV_MINWIDTH) + newx = x->x_gui.x_obj.te_xpix + SCALE_CNV_MINWIDTH; + if (newy < x->x_gui.x_obj.te_ypix + SCALE_CNV_MINHEIGHT) + newy = x->x_gui.x_obj.te_ypix + SCALE_CNV_MINHEIGHT; + + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui(".x%x.c coords %s %d %d %d %d\n", + x->x_gui.x_glist, sh->h_outlinetag, x->x_gui.x_obj.te_xpix, + x->x_gui.x_obj.te_ypix, newx, newy); + } + sh->h_dragx = dx; + sh->h_dragy = dy; + + int properties = gfxstub_haveproperties((void *)x); + + if (properties) + { + int new_w = x->x_vis_w - x->x_gui.scale_offset_x + sh->h_dragx; + int new_h = x->x_vis_h - x->x_gui.scale_offset_y + sh->h_dragy; + sys_vgui(".gfxstub%lx.rng.min_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.rng.min_ent insert 0 %d\n", properties, new_w); + sys_vgui(".gfxstub%lx.rng.max_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.rng.max_ent insert 0 %d\n", properties, new_h); + int min = (new_w < new_h ? new_w : new_h); + if (min <= x->x_gui.x_w) + { + sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", properties, min); + } + } + } + else if (sh->h_dragon && !sh->h_scale) + { + t_my_canvas *x = (t_my_canvas *)(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_ldx - + x->x_gui.label_offset_x + dx; + newy = x->x_gui.x_obj.te_ypix + x->x_gui.x_ldy - + x->x_gui.label_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); + } } - else if (sh->h_dragon && !sh->h_scale) - { - t_my_canvas *x = (t_my_canvas *)(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_ldx - x->x_gui.label_offset_x + dx; - newy = x->x_gui.x_obj.te_ypix + x->x_gui.x_ldy - x->x_gui.label_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 my_canvas_draw(t_my_canvas *x, t_glist *glist, int mode) { if(mode == IEM_GUI_DRAW_MODE_MOVE) my_canvas_draw_move(x, glist); - else if(mode == IEM_GUI_DRAW_MODE_NEW) { + else if(mode == IEM_GUI_DRAW_MODE_NEW) + { my_canvas_draw_new(x, glist); - sys_vgui(".x%lx.c raise all_cords\n", glist_getcanvas(glist)); - } + sys_vgui(".x%lx.c raise all_cords\n", glist_getcanvas(glist)); + } else if(mode == IEM_GUI_DRAW_MODE_SELECT) my_canvas_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) @@ -425,24 +480,25 @@ void my_canvas_draw(t_my_canvas *x, t_glist *glist, int mode) /* ------------------------ cnv widgetbehaviour----------------------------- */ -static void my_canvas_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) +static void my_canvas_getrect(t_gobj *z, t_glist *glist, + int *xp1, int *yp1, int *xp2, int *yp2) { t_my_canvas *x = (t_my_canvas *)z; *xp1 = text_xpix(&x->x_gui.x_obj, glist); *yp1 = text_ypix(&x->x_gui.x_obj, glist); - if (!glist_istoplevel(glist)) - { - //if we are trying to calculate visibility of a widget inside a GOP - *xp2 = *xp1 + x->x_vis_w; - *yp2 = *yp1 + x->x_vis_h; - } - else - { - *xp2 = *xp1 + x->x_gui.x_w; - *yp2 = *yp1 + x->x_gui.x_h; - } - iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); + if (!glist_istoplevel(glist)) + { + //if we are trying to calculate visibility of a widget inside a GOP + *xp2 = *xp1 + x->x_vis_w; + *yp2 = *yp1 + x->x_vis_h; + } + else + { + *xp2 = *xp1 + x->x_gui.x_w; + *yp2 = *yp1 + x->x_gui.x_h; + } + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void my_canvas_save(t_gobj *z, t_binbuf *b) @@ -498,7 +554,7 @@ static void my_canvas_get_pos(t_my_canvas *x) static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv) { - canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); + canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); t_symbol *srl[3]; int a = (int)atom_getintarg(0, argc, argv); @@ -519,16 +575,18 @@ static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv x->x_vis_h = h; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); - /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) { - my_canvas_draw_select(x, x->x_gui.x_glist); - } + /* forcing redraw of the scale handle */ + if (x->x_gui.x_fsf.x_selected) + { + my_canvas_draw_select(x, x->x_gui.x_glist); + } - //ico@bukvic.net 100518 update scrollbars when object potentially exceeds window size + //ico@bukvic.net 100518 update scrollbars when object + //potentially exceeds window size t_canvas *canvas=(t_canvas *)glist_getcanvas(x->x_gui.x_glist); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)canvas); + sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)canvas); } static void my_canvas_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) @@ -604,7 +662,8 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) w = (int)atom_getintarg(1, argc, argv); h = (int)atom_getintarg(2, argc, argv); } - if((argc >= 12)&&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))&&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))) + if((argc >= 12) && (IS_A_SYMBOL(argv,3) || IS_A_FLOAT(argv,3)) && + (IS_A_SYMBOL(argv,4) || IS_A_FLOAT(argv,4))) { i = 2; iemgui_new_getnames(&x->x_gui, 3, argv); @@ -656,10 +715,15 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) if(h < 1) h = 1; x->x_vis_h = h; - if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica"); - else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); - else { x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); } + if(x->x_gui.x_fsf.x_font_style == 1) + strcpy(x->x_gui.x_font, "helvetica"); + else if(x->x_gui.x_fsf.x_font_style == 2) + strcpy(x->x_gui.x_font, "times"); + else + { + x->x_gui.x_fsf.x_font_style = 0; + strcpy(x->x_gui.x_font, sys_font); + } if (x->x_gui.x_fsf.x_rcv_able) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; @@ -672,7 +736,7 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) x->x_at[1].a_type = A_FLOAT; iemgui_verify_snd_ne_rcv(&x->x_gui); - /* scale handle init */ + /* scale handle init */ t_scalehandle *sh; char buf[64]; x->x_gui.x_handle = pd_new(scalehandle_class); @@ -682,27 +746,27 @@ static void *my_canvas_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%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_obj.te_iemgui = 1; + 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_obj.te_iemgui = 1; return (x); } @@ -713,45 +777,60 @@ static void my_canvas_ff(t_my_canvas *x) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); - /* scale handle deconstructor */ + /* 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); + 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); - } + /* 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_mycanvas_setup(void) { my_canvas_class = class_new(gensym("cnv"), (t_newmethod)my_canvas_new, - (t_method)my_canvas_ff, sizeof(t_my_canvas), CLASS_NOINLET, A_GIMME, 0); - class_addcreator((t_newmethod)my_canvas_new, gensym("my_canvas"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_dialog, gensym("dialog"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_size, gensym("size"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_delta, gensym("delta"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_pos, gensym("pos"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_vis_size, gensym("vis_size"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_color, gensym("color"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_send, gensym("send"), A_DEFSYM, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_receive, gensym("receive"), A_DEFSYM, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_label, gensym("label"), A_DEFSYM, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_label_pos, gensym("label_pos"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_label_font, gensym("label_font"), A_GIMME, 0); - class_addmethod(my_canvas_class, (t_method)my_canvas_get_pos, gensym("get_pos"), 0); + (t_method)my_canvas_ff, sizeof(t_my_canvas), CLASS_NOINLET, A_GIMME, 0); + class_addcreator((t_newmethod)my_canvas_new, + gensym("my_canvas"), A_GIMME, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_dialog, + gensym("dialog"), A_GIMME, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_size, + gensym("size"), A_GIMME, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_delta, + gensym("delta"), A_GIMME, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_pos, + gensym("pos"), A_GIMME, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_vis_size, + gensym("vis_size"), A_GIMME, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_color, + gensym("color"), A_GIMME, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_send, + gensym("send"), A_DEFSYM, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_receive, + gensym("receive"), A_DEFSYM, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_label, + gensym("label"), A_DEFSYM, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_label_pos, + gensym("label_pos"), A_GIMME, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_label_font, + gensym("label_font"), A_GIMME, 0); + class_addmethod(my_canvas_class, (t_method)my_canvas_get_pos, + gensym("get_pos"), 0); scalehandle_class = class_new(gensym("_scalehandle"), 0, 0, - sizeof(t_scalehandle), CLASS_PD, 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); + 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); + gensym("_motion"), A_FLOAT, A_FLOAT, 0); my_canvas_widgetbehavior.w_getrectfn = my_canvas_getrect; my_canvas_widgetbehavior.w_displacefn = iemgui_displace; @@ -760,7 +839,7 @@ void g_mycanvas_setup(void) my_canvas_widgetbehavior.w_deletefn = iemgui_delete; my_canvas_widgetbehavior.w_visfn = iemgui_vis; my_canvas_widgetbehavior.w_clickfn = NULL; - my_canvas_widgetbehavior.w_displacefnwtag = iemgui_displace_withtag; + my_canvas_widgetbehavior.w_displacefnwtag = iemgui_displace_withtag; class_setwidget(my_canvas_class, &my_canvas_widgetbehavior); class_sethelpsymbol(my_canvas_class, gensym("my_canvas")); class_setsavefn(my_canvas_class, my_canvas_save); diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c index d0aa6e67e..e915e1e5b 100644 --- a/pd/src/g_numbox.c +++ b/pd/src/g_numbox.c @@ -76,7 +76,7 @@ int my_numbox_calc_fontwidth(t_my_numbox *x) w = x->x_gui.x_fontsize * f * x->x_gui.x_w; w /= 36; w = w + (x->x_gui.x_h / 2) + 4; - return w; + return w; } void my_numbox_ftoa(t_my_numbox *x) @@ -139,8 +139,9 @@ void my_numbox_ftoa(t_my_numbox *x) static void my_numbox_draw_update(t_gobj *client, t_glist *glist) { t_my_numbox *x = (t_my_numbox *)client; - if (x->x_gui.x_changed == 0) { - return; + if (x->x_gui.x_changed == 0) + { + return; } if (glist_isvisible(glist)) { @@ -156,7 +157,7 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist) if(sl >= x->x_gui.x_w) cp += sl - x->x_gui.x_w + 1; sys_vgui( - ".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x -text {%s} \n", + ".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x -text {%s}\n", glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, cp); x->x_buf[sl] = 0; } @@ -164,18 +165,18 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist) { my_numbox_ftoa(x); sys_vgui( - ".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x -text {%s} \n", + ".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x -text {%s}\n", glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, x->x_buf); x->x_buf[0] = 0; } } else { - char color[64]; - if (x->x_gui.x_fsf.x_selected) - sprintf(color, "$pd_colors(selection)"); - else - sprintf(color, "#%6.6x", x->x_gui.x_fcol); + char color[64]; + if (x->x_gui.x_fsf.x_selected) + sprintf(color, "$pd_colors(selection)"); + else + sprintf(color, "#%6.6x", x->x_gui.x_fcol); my_numbox_ftoa(x); sys_vgui( @@ -196,69 +197,79 @@ static void my_numbox_draw_new(t_my_numbox *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); - - //if (glist_isvisible(canvas)) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - if (x->x_hide_frame <= 1) { - sys_vgui( - ".x%lx.c create ppolygon %d %d %d %d %d %d %d %d %d %d -stroke %s \ - -fill #%6.6x -tags {%lxBASE1 %lxNUM %s text iemgui border}\n", - canvas, xpos, ypos, - xpos + x->x_numwidth-4, ypos, - xpos + x->x_numwidth, ypos+4, - xpos + x->x_numwidth, ypos + x->x_gui.x_h, - xpos, ypos + x->x_gui.x_h, - IEM_GUI_COLOR_NORMAL, x->x_gui.x_bcol, x, x, nlet_tag); - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxNUM%so%d %so%d %lxNUM %s outlet iemgui}\n", - canvas, - xpos, ypos + x->x_gui.x_h-1, - xpos+IOWIDTH, ypos + x->x_gui.x_h, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxNUM%si%d %si%d %lxNUM %s inlet iemgui}\n", - canvas, - xpos, ypos, - xpos+IOWIDTH, ypos+1, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - } else { - sys_vgui( - ".x%lx.c create ppolygon %d %d %d %d %d %d %d %d %d %d -stroke #%6.6x \ - -fill #%6.6x -tags {%lxBASE1 %lxNUM %s text iemgui}\n", - canvas, xpos, ypos, - xpos + x->x_numwidth-4, ypos, - xpos + x->x_numwidth, ypos+4, - xpos + x->x_numwidth, ypos + x->x_gui.x_h, - xpos, ypos + x->x_gui.x_h, - x->x_gui.x_bcol, x->x_gui.x_bcol, x, x, nlet_tag); - } - if (!x->x_hide_frame || x->x_hide_frame == 2) - sys_vgui( - ".x%lx.c create polyline %d %d %d %d %d %d -stroke #%6.6x -tags {%lxBASE2 %lxNUM %s text iemgui}\n", - canvas, xpos, ypos, - xpos + half, ypos + half, - xpos, ypos + x->x_gui.x_h, - x->x_gui.x_fcol, x, x, nlet_tag); - sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ - -font {{%s} -%d %s} -fill #%6.6x -tags {%lxLABEL %lxNUM %s text iemgui}\n", - canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, - strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", - x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x, x, nlet_tag); - my_numbox_ftoa(x); - sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ - -font {{%s} -%d %s} -fill #%6.6x -tags {%lxNUMBER %lxNUM %s noscroll text iemgui}\n", - canvas, xpos+half+2, ypos+half+d, - x->x_buf, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_fcol, x, x, nlet_tag); - //} + 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); + + //if (glist_isvisible(canvas)) { + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + if (x->x_hide_frame <= 1) + { + sys_vgui( + ".x%lx.c create ppolygon %d %d %d %d %d %d %d %d %d %d " + "-stroke %s -fill #%6.6x " + "-tags {%lxBASE1 %lxNUM %s text iemgui border}\n", + canvas, xpos, ypos, + xpos + x->x_numwidth-4, ypos, + xpos + x->x_numwidth, ypos+4, + xpos + x->x_numwidth, ypos + x->x_gui.x_h, + xpos, ypos + x->x_gui.x_h, + IEM_GUI_COLOR_NORMAL, x->x_gui.x_bcol, x, x, nlet_tag); + if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxNUM%so%d %so%d %lxNUM %s outlet iemgui}\n", + canvas, + xpos, ypos + x->x_gui.x_h-1, + xpos+IOWIDTH, ypos + x->x_gui.x_h, + x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxNUM%si%d %si%d %lxNUM %s inlet iemgui}\n", + canvas, + xpos, ypos, + xpos+IOWIDTH, ypos+1, + x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + } + else + { + sys_vgui(".x%lx.c create ppolygon %d %d %d %d %d %d %d %d %d %d " + "-stroke #%6.6x -fill #%6.6x " + "-tags {%lxBASE1 %lxNUM %s text iemgui}\n", + canvas, xpos, ypos, + xpos + x->x_numwidth-4, ypos, + xpos + x->x_numwidth, ypos+4, + xpos + x->x_numwidth, ypos + x->x_gui.x_h, + xpos, ypos + x->x_gui.x_h, + x->x_gui.x_bcol, x->x_gui.x_bcol, x, x, nlet_tag); + } + if (!x->x_hide_frame || x->x_hide_frame == 2) + sys_vgui(".x%lx.c create polyline %d %d %d %d %d %d -stroke #%6.6x " + "-tags {%lxBASE2 %lxNUM %s text iemgui}\n", + canvas, xpos, ypos, + xpos + half, ypos + half, + xpos, ypos + x->x_gui.x_h, + x->x_gui.x_fcol, x, x, nlet_tag); + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " + "-font {{%s} -%d %s} -fill #%6.6x " + "-tags {%lxLABEL %lxNUM %s text iemgui}\n", + canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", + x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_lcol, x, x, nlet_tag); + my_numbox_ftoa(x); + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " + "-font {{%s} -%d %s} -fill #%6.6x " + "-tags {%lxNUMBER %lxNUM %s noscroll text iemgui}\n", + canvas, xpos+half+2, ypos+half+d, + x->x_buf, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_fcol, x, x, nlet_tag); + //} } static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist) @@ -268,450 +279,543 @@ static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist) int ypos=text_ypix(&x->x_gui.x_obj, glist); t_canvas *canvas=glist_getcanvas(glist); - if (glist_isvisible(canvas)) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - sys_vgui(".x%lx.c coords %lxBASE1 %d %d %d %d %d %d %d %d %d %d\n", - canvas, x, xpos, ypos, - xpos + x->x_numwidth-4, ypos, - xpos + x->x_numwidth, ypos+4, - xpos + x->x_numwidth, ypos + x->x_gui.x_h, - xpos, ypos + x->x_gui.x_h); - if (x->x_hide_frame <= 1) { - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxNUM%so%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, - xpos, ypos + x->x_gui.x_h-1, - xpos+IOWIDTH, ypos + x->x_gui.x_h); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxNUM%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, - xpos, ypos, - xpos+IOWIDTH, ypos+1); - } - if (!x->x_hide_frame || x->x_hide_frame == 2) - sys_vgui(".x%lx.c coords %lxBASE2 %d %d %d %d %d %d\n", - canvas, x, xpos, ypos, - xpos + half, ypos + half, - xpos, ypos + x->x_gui.x_h); - sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", - canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy); - sys_vgui(".x%lx.c coords %lxNUMBER %d %d\n", - canvas, x, xpos+half+2, ypos+half+d); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) - my_numbox_draw_select(x, x->x_gui.x_glist); - } + if (glist_isvisible(canvas)) + { + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + sys_vgui(".x%lx.c coords %lxBASE1 %d %d %d %d %d %d %d %d %d %d\n", + canvas, x, xpos, ypos, + xpos + x->x_numwidth-4, ypos, + xpos + x->x_numwidth, ypos+4, + xpos + x->x_numwidth, ypos + x->x_gui.x_h, + xpos, ypos + x->x_gui.x_h); + if (x->x_hide_frame <= 1) + { + if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + sys_vgui(".x%lx.c coords %lxNUM%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, + xpos, ypos + x->x_gui.x_h-1, + xpos+IOWIDTH, ypos + x->x_gui.x_h); + if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + sys_vgui(".x%lx.c coords %lxNUM%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, + xpos, ypos, + xpos+IOWIDTH, ypos+1); + } + if (!x->x_hide_frame || x->x_hide_frame == 2) + sys_vgui(".x%lx.c coords %lxBASE2 %d %d %d %d %d %d\n", + canvas, x, xpos, ypos, + xpos + half, ypos + half, + xpos, ypos + x->x_gui.x_h); + sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", + canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy); + sys_vgui(".x%lx.c coords %lxNUMBER %d %d\n", + canvas, x, xpos+half+2, ypos+half+d); + /* redraw scale handle rectangle if selected */ + if (x->x_gui.x_fsf.x_selected) + my_numbox_draw_select(x, x->x_gui.x_glist); + } } static void my_numbox_draw_erase(t_my_numbox* x,t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - sys_vgui(".x%lx.c delete %lxNUM\n", canvas, x); - sys_vgui(".x%lx.c dtag all %lxNUM\n", canvas, x); - 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); - sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); - t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); - sys_vgui("destroy %s\n", lh->h_pathname); - sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); - } + sys_vgui(".x%lx.c delete %lxNUM\n", canvas, x); + sys_vgui(".x%lx.c dtag all %lxNUM\n", canvas, x); + 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); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); + sys_vgui("destroy %s\n", lh->h_pathname); + sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); + } } static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - /* - char color[64]; - char lcolor[64]; - if (x->x_gui.x_fsf.x_selected) { - sprintf(color, "$pd_colors(selection)"); - sprintf(lcolor, "$pd_colors(selection)"); - } - else { - sprintf(color, "#%6.6x", x->x_gui.x_fcol); - sprintf(lcolor, "#%6.6x", x->x_gui.x_lcol); - } - */ - - if (x->x_gui.x_fsf.x_selected && x->x_gui.x_glist == canvas) { - sys_vgui(" .x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill $pd_colors(selection) -text {%s} \n .x%lx.c itemconfigure %lxNUMBER -font {{%s} -%d %s} -fill $pd_colors(selection) \n .x%lx.c itemconfigure %lxBASE2 -stroke $pd_colors(selection)\n", - canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", - canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - canvas,x); - /* - sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font {{%s} %d %s} -fill $pd_colors(selection) \n", - canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight); - sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill $pd_colors(selection)\n", canvas, - x); - */ - } - else { - sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n .x%lx.c itemconfigure %lxNUMBER -font {{%s} -%d %s} -fill #%6.6x \n .x%lx.c itemconfigure %lxBASE2 -stroke #%6.6x\n", - canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", - canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_fcol, canvas, x, x->x_gui.x_fcol); - /*sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font {{%s} %d %s} -fill #%6.6x \n", - canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_fcol); - sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill #%6.6x\n", canvas, - x, x->x_gui.x_fcol);*/ - } + /* + char color[64]; + char lcolor[64]; + if (x->x_gui.x_fsf.x_selected) + { + sprintf(color, "$pd_colors(selection)"); + sprintf(lcolor, "$pd_colors(selection)"); + } + else + { + sprintf(color, "#%6.6x", x->x_gui.x_fcol); + sprintf(lcolor, "#%6.6x", x->x_gui.x_lcol); + } + */ + + if (x->x_gui.x_fsf.x_selected && x->x_gui.x_glist == canvas) + { + sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} " + "-fill $pd_colors(selection) -text {%s} \n " + ".x%lx.c itemconfigure %lxNUMBER -font {{%s} -%d %s} " + "-fill $pd_colors(selection) \n " + ".x%lx.c itemconfigure %lxBASE2 " + "-stroke $pd_colors(selection)\n", + canvas, x, x->x_gui.x_font, + x->x_gui.x_fontsize, sys_fontweight, + strcmp( + x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", + canvas, x, x->x_gui.x_font, + x->x_gui.x_fontsize, sys_fontweight, + canvas,x); + /* + sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font {{%s} %d %s} " + "-fill $pd_colors(selection) \n", + canvas, x, x->x_gui.x_font, + x->x_gui.x_fontsize, sys_fontweight); + sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill $pd_colors(selection)\n", + canvas, x); + */ + } + else + { + sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} " + "-fill #%6.6x -text {%s} \n " + ".x%lx.c itemconfigure %lxNUMBER -font {{%s} -%d %s} " + "-fill #%6.6x \n .x%lx.c itemconfigure %lxBASE2 " + "-stroke #%6.6x\n", + canvas, x, x->x_gui.x_font, + x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_lcol, + strcmp( + x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", + canvas, x, x->x_gui.x_font, + x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_fcol, canvas, x, x->x_gui.x_fcol); + + /*sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font {{%s} %d %s} " + "-fill #%6.6x \n", + canvas, x, x->x_gui.x_font, + x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_fcol); + sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill #%6.6x\n", + canvas, + x, x->x_gui.x_fcol);*/ + + } sys_vgui(".x%lx.c itemconfigure %lxBASE1 -fill #%6.6x;\n", canvas, x, x->x_gui.x_bcol); } -static void my_numbox_draw_io(t_my_numbox* x,t_glist* glist, int old_snd_rcv_flags) +static void my_numbox_draw_io(t_my_numbox* x,t_glist* glist, + int old_snd_rcv_flags) { int xpos=text_xpix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist); t_canvas *canvas=glist_getcanvas(glist); - if (glist_isvisible(canvas) && canvas == x->x_gui.x_glist) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxNUM%so%d %so%d %lxNUM %s outlet iemgui}\n", - canvas, - xpos, ypos + x->x_gui.x_h-1, - xpos+IOWIDTH, ypos + x->x_gui.x_h, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c delete %lxNUM%so%d\n", canvas, x, nlet_tag, 0); - if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxNUM%si%d %si%d %lxNUM %s inlet iemgui}\n", - canvas, - xpos, ypos, - xpos+IOWIDTH, ypos+1, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c delete %lxNUM%si%d\n", canvas, x, nlet_tag, 0); - - } + if (glist_isvisible(canvas) && canvas == x->x_gui.x_glist) + { + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && + !x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxNUM%so%d %so%d %lxNUM %s outlet iemgui}\n", + canvas, + xpos, ypos + x->x_gui.x_h-1, + xpos+IOWIDTH, ypos + x->x_gui.x_h, + x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) + && x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c delete %lxNUM%so%d\n", canvas, x, nlet_tag, 0); + if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && + !x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxNUM%si%d %si%d %lxNUM %s inlet iemgui}\n", + canvas, + xpos, ypos, + xpos+IOWIDTH, ypos+1, + x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && + x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c delete %lxNUM%si%d\n", canvas, x, nlet_tag, 0); + } } static void my_numbox_draw_select(t_my_numbox *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)) { - - if(x->x_gui.x_fsf.x_selected) - { - if(x->x_gui.x_fsf.x_change) - { - x->x_gui.x_fsf.x_change = 0; - clock_unset(x->x_clock_reset); - x->x_buf[0] = 0; - sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); - } - - // check if we are drawing inside a gop abstraction visible on parent canvas - // if so, disable highlighting - if (x->x_gui.x_glist == glist_getcanvas(glist)) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - sys_vgui(".x%lx.c itemconfigure %lxBASE1 -stroke $pd_colors(selection)\n", - canvas, x); - sys_vgui(".x%lx.c itemconfigure %lxBASE2 -stroke $pd_colors(selection)\n", - canvas, x); - sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill $pd_colors(selection)\n", - canvas, x); - sys_vgui(".x%lx.c itemconfigure %lxNUMBER -fill $pd_colors(selection)\n", - canvas, x); - - if (x->x_gui.scale_vis) { - sys_vgui("destroy %s\n", sh->h_pathname); - sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); - } - - 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); - sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxSCALE %lxNUM %s}\n", - canvas, x->x_gui.x_obj.te_xpix + x->x_numwidth - 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, nlet_tag); - sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n", - sh->h_pathname, sh->h_bindsym->s_name); - sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n", - sh->h_pathname, sh->h_bindsym->s_name); - 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(".x%lx.c delete %lxLABELH\n", canvas, x); - } - - sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -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 %lxLABELH %lxNUM %s}\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, x, nlet_tag); - 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 %lxNUM\n", canvas, x); - } - else - { - sys_vgui(".x%lx.c dtag %lxNUM selected\n", canvas, x); - - if (x->x_hide_frame <= 1) - sys_vgui(".x%lx.c itemconfigure %lxBASE1 -stroke %s\n", - canvas, x, IEM_GUI_COLOR_NORMAL); - else sys_vgui(".x%lx.c itemconfigure %lxBASE1 -stroke #%6.6x\n", - canvas, x, x->x_gui.x_bcol); - - sys_vgui(".x%lx.c itemconfigure %lxBASE2 -stroke #%6.6x\n", - canvas, x, x->x_gui.x_fcol); - sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", - canvas, x, x->x_gui.x_lcol); - sys_vgui(".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x\n", - canvas, x, x->x_gui.x_fcol); - sys_vgui("destroy %s\n", sh->h_pathname); - sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); - x->x_gui.scale_vis = 0; - sys_vgui("destroy %s\n", lh->h_pathname); - sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); - x->x_gui.label_vis = 0; - } - //} + t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle); + t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); + + //if (glist_isvisible(canvas)) { + + if(x->x_gui.x_fsf.x_selected) + { + if(x->x_gui.x_fsf.x_change) + { + x->x_gui.x_fsf.x_change = 0; + clock_unset(x->x_clock_reset); + x->x_buf[0] = 0; + sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); + } + + // check if we are drawing inside a gop abstraction + // visible on parent canvas + // if so, disable highlighting + if (x->x_gui.x_glist == glist_getcanvas(glist)) + { + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + sys_vgui(".x%lx.c itemconfigure %lxBASE1 " + "-stroke $pd_colors(selection)\n", + canvas, x); + sys_vgui(".x%lx.c itemconfigure %lxBASE2 " + "-stroke $pd_colors(selection)\n", + canvas, x); + sys_vgui(".x%lx.c itemconfigure %lxLABEL " + "-fill $pd_colors(selection)\n", + canvas, x); + sys_vgui(".x%lx.c itemconfigure %lxNUMBER " + "-fill $pd_colors(selection)\n", + canvas, x); + + if (x->x_gui.scale_vis) + { + sys_vgui("destroy %s\n", sh->h_pathname); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + } + + 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); + sys_vgui(".x%x.c create window %d %d -anchor nw " + "-width %d -height %d -window %s " + "-tags {%lxSCALE %lxNUM %s}\n", + canvas, x->x_gui.x_obj.te_xpix + x->x_numwidth - + 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, nlet_tag); + sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n", + sh->h_pathname, sh->h_bindsym->s_name); + sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n", + sh->h_pathname, sh->h_bindsym->s_name); + 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(".x%lx.c delete %lxLABELH\n", canvas, x); + } + + sys_vgui("canvas %s -width %d -height %d " + "-bg $pd_colors(selection) " + "-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 %lxLABELH %lxNUM %s}\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, x, nlet_tag); + 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 %lxNUM\n", canvas, x); + } + else + { + sys_vgui(".x%lx.c dtag %lxNUM selected\n", canvas, x); + + if (x->x_hide_frame <= 1) + sys_vgui(".x%lx.c itemconfigure %lxBASE1 -stroke %s\n", + canvas, x, IEM_GUI_COLOR_NORMAL); + else sys_vgui(".x%lx.c itemconfigure %lxBASE1 -stroke #%6.6x\n", + canvas, x, x->x_gui.x_bcol); + + sys_vgui(".x%lx.c itemconfigure %lxBASE2 -stroke #%6.6x\n", + canvas, x, x->x_gui.x_fcol); + sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", + canvas, x, x->x_gui.x_lcol); + sys_vgui(".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x\n", + canvas, x, x->x_gui.x_fcol); + sys_vgui("destroy %s\n", sh->h_pathname); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + x->x_gui.scale_vis = 0; + sys_vgui("destroy %s\n", lh->h_pathname); + sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); + x->x_gui.label_vis = 0; + } + //} } -static void my_numbox__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_floatarg yyy) +static void my_numbox__clickhook(t_scalehandle *sh, t_floatarg f, + 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); - 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; - } + 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 && 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_fontsize = x->x_tmpfontsize; - x->x_gui.x_w = x->x_scalewidth; - x->x_gui.x_h = x->x_scaleheight; - - x->x_numwidth = my_numbox_calc_fontwidth(x); - - 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); - sys_vgui(".gfxstub%lx.label.fontsize_entry delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.label.fontsize_entry insert 0 %d\n", properties, x->x_gui.x_fontsize); - } - - if (glist_isvisible(x->x_gui.x_glist)) - { - sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); - my_numbox_draw_move(x, x->x_gui.x_glist); - my_numbox_draw_config(x, x->x_gui.x_glist); - my_numbox_draw_update((t_gobj*)x, x->x_gui.x_glist); - 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); - } + /* 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_fontsize = x->x_tmpfontsize; + x->x_gui.x_w = x->x_scalewidth; + x->x_gui.x_h = x->x_scaleheight; + + x->x_numwidth = my_numbox_calc_fontwidth(x); + + 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); + sys_vgui(".gfxstub%lx.label.fontsize_entry delete 0 end\n", + properties); + sys_vgui(".gfxstub%lx.label.fontsize_entry insert 0 %d\n", + properties, x->x_gui.x_fontsize); + } + + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); + my_numbox_draw_move(x, x->x_gui.x_glist); + my_numbox_draw_config(x, x->x_gui.x_glist); + my_numbox_draw_update((t_gobj*)x, x->x_gui.x_glist); + 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); - sys_vgui(".x%x.c create prect %d %d %d %d\ - -stroke $pd_colors(selection) -strokewidth 1 -tags %s\n", - x->x_gui.x_glist, x->x_gui.x_obj.te_xpix, x->x_gui.x_obj.te_ypix, - x->x_gui.x_obj.te_xpix + x->x_numwidth, - x->x_gui.x_obj.te_ypix + x->x_gui.x_h, sh->h_outlinetag); - } - - x->x_scalewidth = x->x_gui.x_w; - x->x_scaleheight = x->x_gui.x_h; - x->x_tmpfontsize = x->x_gui.x_fontsize; - sh->h_dragx = 0; - sh->h_dragy = 0; + /* dragging */ + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui("lower %s\n", sh->h_pathname); + sys_vgui(".x%x.c create prect %d %d %d %d " + "-stroke $pd_colors(selection) -strokewidth 1 -tags %s\n", + x->x_gui.x_glist, x->x_gui.x_obj.te_xpix, + x->x_gui.x_obj.te_ypix, + x->x_gui.x_obj.te_xpix + x->x_numwidth, + x->x_gui.x_obj.te_ypix + x->x_gui.x_h, sh->h_outlinetag); + } + + x->x_scalewidth = x->x_gui.x_w; + x->x_scaleheight = x->x_gui.x_h; + x->x_tmpfontsize = x->x_gui.x_fontsize; + sh->h_dragx = 0; + sh->h_dragy = 0; } - else if (sh->h_dragon && newstate == 0 && !sh->h_scale) + else if (sh->h_dragon && newstate == 0 && !sh->h_scale) { - /* done dragging */ + /* done dragging */ - /* first set up the undo apply */ - canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); + /* first set up the undo apply */ + canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); - if (sh->h_dragx || sh->h_dragy) { + 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; + 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); - } + canvas_dirty(x->x_gui.x_glist, 1); + } - int properties = gfxstub_haveproperties((void *)x); + 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 (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); - my_numbox_draw_move(x, x->x_gui.x_glist); - 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); - } + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); + my_numbox_draw_move(x, x->x_gui.x_glist); + 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%lx.h%lx\n", (t_int)glist_getcanvas(x->x_gui.x_glist), (t_int)othersh); - } - - sh->h_dragx = 0; - sh->h_dragy = 0; + /* 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%lx.h%lx\n", + (t_int)glist_getcanvas(x->x_gui.x_glist), (t_int)othersh); + } + + sh->h_dragx = 0; + sh->h_dragy = 0; } sh->h_dragon = newstate; } static void my_numbox__motionhook(t_scalehandle *sh, - t_floatarg f1, t_floatarg f2) + t_floatarg f1, t_floatarg f2) { if (sh->h_dragon && sh->h_scale) { - t_my_numbox *x = (t_my_numbox *)(sh->h_master); - int dx = (int)f1, dy = (int)f2; - int newx, newy; - - /* first calculate y */ - newy = x->x_gui.x_obj.te_ypix + x->x_gui.x_h + (dy - x->x_gui.scale_offset_y); - if (newy < x->x_gui.x_obj.te_ypix + SCALE_NUM_MINHEIGHT) - newy = x->x_gui.x_obj.te_ypix + SCALE_NUM_MINHEIGHT; - - /* then readjust fontsize */ - x->x_tmpfontsize = (newy - x->x_gui.x_obj.te_ypix) * 0.8; - if (x->x_tmpfontsize < IEM_FONT_MINSIZE) - x->x_tmpfontsize = IEM_FONT_MINSIZE; - - int f = 31; - if(x->x_gui.x_fsf.x_font_style == 1) - f = 27; - else if(x->x_gui.x_fsf.x_font_style == 2) - f = 25; - int char_w = x->x_tmpfontsize * f; - char_w /= 36; - - /* get the new total width */ - int new_total_width = x->x_numwidth + (dx - x->x_gui.scale_offset_x); - - /* now figure out what does this translate into in terms of character length */ - int new_char_len = (new_total_width - ((newy - x->x_gui.x_obj.te_ypix) / 2) - 4) / char_w; - if (new_char_len < SCALE_NUM_MINWIDTH) - new_char_len = SCALE_NUM_MINWIDTH; - - newx = x->x_gui.x_obj.te_xpix + - new_char_len * char_w + - ((newy - x->x_gui.x_obj.te_ypix) / 2) + 4; - - if (glist_isvisible(x->x_gui.x_glist)) { - sys_vgui(".x%x.c coords %s %d %d %d %d\n", - x->x_gui.x_glist, sh->h_outlinetag, x->x_gui.x_obj.te_xpix, - x->x_gui.x_obj.te_ypix, newx, newy); - } - sh->h_dragx = dx; - sh->h_dragy = dy; - x->x_scalewidth = new_char_len; - x->x_scaleheight = newy - x->x_gui.x_obj.te_ypix; - - 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_scalewidth); - 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_scaleheight); - sys_vgui(".gfxstub%lx.label.fontsize_entry delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.label.fontsize_entry insert 0 %d\n", properties, x->x_tmpfontsize); - } + t_my_numbox *x = (t_my_numbox *)(sh->h_master); + int dx = (int)f1, dy = (int)f2; + int newx, newy; + + /* first calculate y */ + newy = x->x_gui.x_obj.te_ypix + x->x_gui.x_h + + (dy - x->x_gui.scale_offset_y); + if (newy < x->x_gui.x_obj.te_ypix + SCALE_NUM_MINHEIGHT) + newy = x->x_gui.x_obj.te_ypix + SCALE_NUM_MINHEIGHT; + + /* then readjust fontsize */ + x->x_tmpfontsize = (newy - x->x_gui.x_obj.te_ypix) * 0.8; + if (x->x_tmpfontsize < IEM_FONT_MINSIZE) + x->x_tmpfontsize = IEM_FONT_MINSIZE; + + int f = 31; + if(x->x_gui.x_fsf.x_font_style == 1) + f = 27; + else if(x->x_gui.x_fsf.x_font_style == 2) + f = 25; + int char_w = x->x_tmpfontsize * f; + char_w /= 36; + + /* get the new total width */ + int new_total_width = x->x_numwidth + (dx - x->x_gui.scale_offset_x); + + /* now figure out what does this translate into in terms of + character length */ + int new_char_len = (new_total_width - + ((newy - x->x_gui.x_obj.te_ypix) / 2) - 4) / char_w; + if (new_char_len < SCALE_NUM_MINWIDTH) + new_char_len = SCALE_NUM_MINWIDTH; + + newx = x->x_gui.x_obj.te_xpix + + new_char_len * char_w + + ((newy - x->x_gui.x_obj.te_ypix) / 2) + 4; + + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui(".x%x.c coords %s %d %d %d %d\n", + x->x_gui.x_glist, sh->h_outlinetag, x->x_gui.x_obj.te_xpix, + x->x_gui.x_obj.te_ypix, newx, newy); + } + sh->h_dragx = dx; + sh->h_dragy = dy; + x->x_scalewidth = new_char_len; + x->x_scaleheight = newy - x->x_gui.x_obj.te_ypix; + + 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_scalewidth); + 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_scaleheight); + sys_vgui(".gfxstub%lx.label.fontsize_entry delete 0 end\n", + properties); + sys_vgui(".gfxstub%lx.label.fontsize_entry insert 0 %d\n", + properties, x->x_tmpfontsize); + } } - if (sh->h_dragon && !sh->h_scale) + 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); - } + 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); + } } } @@ -721,10 +825,11 @@ void my_numbox_draw(t_my_numbox *x, t_glist *glist, int mode) sys_queuegui(x, glist, my_numbox_draw_update); else if(mode == IEM_GUI_DRAW_MODE_MOVE) my_numbox_draw_move(x, glist); - else if(mode == IEM_GUI_DRAW_MODE_NEW) { + else if(mode == IEM_GUI_DRAW_MODE_NEW) + { my_numbox_draw_new(x, glist); - sys_vgui(".x%lx.c raise all_cords\n", glist_getcanvas(glist)); - } + sys_vgui(".x%lx.c raise all_cords\n", glist_getcanvas(glist)); + } else if(mode == IEM_GUI_DRAW_MODE_SELECT) my_numbox_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) @@ -748,7 +853,7 @@ static void my_numbox_getrect(t_gobj *z, t_glist *glist, *xp2 = *xp1 + x->x_numwidth; *yp2 = *yp1 + x->x_gui.x_h; - iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void my_numbox_save(t_gobj *z, t_binbuf *b) @@ -840,7 +945,8 @@ static void my_numbox_properties(t_gobj *z, t_glist *owner) %d %d \ %d %d %d\n", x->x_gui.x_w, 1, x->x_gui.x_h, 8, - x->x_min, x->x_max, x->x_hide_frame,/*EXCEPTION: x_hide_frame instead of schedule*/ + x->x_min, x->x_max, + x->x_hide_frame, /*EXCEPTION: x_hide_frame instead of schedule*/ x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, -1, x->x_log_height, /*no multi, but iem-characteristic*/ srl[0]->s_name, srl[1]->s_name, @@ -861,7 +967,7 @@ static void my_numbox_bang(t_my_numbox *x) static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc, t_atom *argv) { - canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); + canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); t_symbol *srl[3]; int w = (int)atom_getintarg(0, argc, argv); @@ -870,9 +976,10 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc, double max = (double)atom_getfloatarg(3, argc, argv); int lilo = (int)atom_getintarg(4, argc, argv); int log_height = (int)atom_getintarg(6, argc, argv); - if (argc > 17) { - x->x_hide_frame = (int)atom_getintarg(18, argc, argv); - } + if (argc > 17) + { + x->x_hide_frame = (int)atom_getintarg(18, argc, argv); + } int sr_flags; if(lilo != 0) lilo = 1; @@ -891,36 +998,39 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc, /*if(my_numbox_check_minmax(x, min, max)) my_numbox_bang(x);*/ my_numbox_check_minmax(x, min, max); - //if (need_to_redraw) { + //if (need_to_redraw) { (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE); //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_NEW); - /*} else { - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); - //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); - //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); - }*/ - + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_NEW); + /*} else { + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); + }*/ + canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - /* forcing redraw of the scale handle */ - if (x->x_gui.x_fsf.x_selected) { - my_numbox_draw_select(x, x->x_gui.x_glist); - } + /* forcing redraw of the scale handle */ + if (x->x_gui.x_fsf.x_selected) + { + my_numbox_draw_select(x, x->x_gui.x_glist); + } - canvas_restore_original_position(x->x_gui.x_glist, (t_gobj *)x, iem_get_tag(x->x_gui.x_glist, (t_iemgui *)x), -1); + canvas_restore_original_position(x->x_gui.x_glist, (t_gobj *)x, + iem_get_tag(x->x_gui.x_glist, (t_iemgui *)x), -1); - //ico@bukvic.net 100518 update scrollbars when object potentially exceeds window size + //ico@bukvic.net 100518 update scrollbars + //when object potentially exceeds window size t_canvas *canvas=(t_canvas *)glist_getcanvas(x->x_gui.x_glist); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)canvas); + sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)canvas); } static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy) { double k2=1.0; - int old = x->x_val; + int old = x->x_val; if(x->x_gui.x_fsf.x_finemoved) k2 = 0.01; @@ -929,12 +1039,13 @@ static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy) else x->x_val -= k2*dy; my_numbox_clip(x); - if (old != x->x_val) { - x->x_gui.x_changed = 1; - sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); - my_numbox_bang(x); - } - clock_unset(x->x_clock_reset); + if (old != x->x_val) + { + x->x_gui.x_changed = 1; + sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); + my_numbox_bang(x); + } + clock_unset(x->x_clock_reset); } static void my_numbox_click(t_my_numbox *x, t_floatarg xpos, t_floatarg ypos, @@ -979,11 +1090,12 @@ static int my_numbox_newclick(t_gobj *z, struct _glist *glist, static void my_numbox_set(t_my_numbox *x, t_floatarg f) { - if (x->x_val != f) { - x->x_val = f; - my_numbox_clip(x); - x->x_gui.x_changed = 1; - sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); + if (x->x_val != f) + { + x->x_val = f; + my_numbox_clip(x); + x->x_gui.x_changed = 1; + sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); } } @@ -1003,11 +1115,11 @@ static void my_numbox_hide_frame(t_my_numbox *x, t_floatarg lh) { if(lh < 0.0) lh = 0.0; - if (lh > 3.0) - lh = 3.0; + if (lh > 3.0) + lh = 3.0; x->x_hide_frame = (int)lh; - my_numbox_draw(x, x->x_gui.x_glist, 4); - my_numbox_draw(x, x->x_gui.x_glist, 2); + my_numbox_draw(x, x->x_gui.x_glist, 4); + my_numbox_draw(x, x->x_gui.x_glist, 2); } static void my_numbox_float(t_my_numbox *x, t_floatarg f) @@ -1047,7 +1159,7 @@ static void my_numbox_range(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) if(my_numbox_check_minmax(x, (double)atom_getfloatarg(0, ac, av), (double)atom_getfloatarg(1, ac, av))) { - x->x_gui.x_changed = 1; + x->x_gui.x_changed = 1; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); /*my_numbox_bang(x);*/ } @@ -1089,7 +1201,7 @@ static void my_numbox_log(t_my_numbox *x) x->x_lin0_log1 = 1; if(my_numbox_check_minmax(x, x->x_min, x->x_max)) { - x->x_gui.x_changed = 1; + x->x_gui.x_changed = 1; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); /*my_numbox_bang(x);*/ } @@ -1215,10 +1327,10 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) { log_height = (int)atom_getintarg(17, argc, argv); } - x->x_hide_frame = 0; // default behavior + x->x_hide_frame = 0; // default behavior if((argc == 19)&&IS_A_FLOAT(argv,18)) { - //fprintf(stderr,"blah %d\n", (int)atom_getintarg(18, argc, argv)); + //fprintf(stderr,"blah %d\n", (int)atom_getintarg(18, argc, argv)); x->x_hide_frame = (int)atom_getintarg(18, argc, argv); } x->x_gui.x_draw = (t_iemfunptr)my_numbox_draw; @@ -1238,10 +1350,15 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.x_fsf.x_snd_able = 0; if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) x->x_gui.x_fsf.x_rcv_able = 0; - if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica"); - else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); - else { x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); } + if (x->x_gui.x_fsf.x_font_style == 1) + strcpy(x->x_gui.x_font, "helvetica"); + else if(x->x_gui.x_fsf.x_font_style == 2) + strcpy(x->x_gui.x_font, "times"); + else + { + x->x_gui.x_fsf.x_font_style = 0; + strcpy(x->x_gui.x_font, sys_font); + } if (x->x_gui.x_fsf.x_rcv_able) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; @@ -1265,7 +1382,7 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.x_fsf.x_change = 0; outlet_new(&x->x_gui.x_obj, &s_float); - /* scale handle init */ + /* scale handle init */ t_scalehandle *sh; char buf[64]; x->x_gui.x_handle = pd_new(scalehandle_class); @@ -1275,32 +1392,32 @@ static void *my_numbox_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%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_scalewidth = 0; - x->x_scaleheight = 0; - x->x_tmpfontsize = 0; - - x->x_gui.x_obj.te_iemgui = 1; - x->x_gui.x_changed = 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_scalewidth = 0; + x->x_scaleheight = 0; + x->x_tmpfontsize = 0; + + x->x_gui.x_obj.te_iemgui = 1; + x->x_gui.x_changed = 0; return (x); } @@ -1313,19 +1430,21 @@ static void my_numbox_free(t_my_numbox *x) clock_free(x->x_clock_wait); gfxstub_deleteforkey(x); - /* scale handle deconstructor */ + /* 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); + 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); - } + /* 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_numbox_setup(void) @@ -1384,14 +1503,14 @@ void g_numbox_setup(void) my_numbox_widgetbehavior.w_deletefn = iemgui_delete; my_numbox_widgetbehavior.w_visfn = iemgui_vis; my_numbox_widgetbehavior.w_clickfn = my_numbox_newclick; - my_numbox_widgetbehavior.w_displacefnwtag = iemgui_displace_withtag; + my_numbox_widgetbehavior.w_displacefnwtag = iemgui_displace_withtag; scalehandle_class = class_new(gensym("_scalehandle"), 0, 0, - sizeof(t_scalehandle), CLASS_PD, 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); + 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); + gensym("_motion"), A_FLOAT, A_FLOAT, 0); class_setwidget(my_numbox_class, &my_numbox_widgetbehavior); class_sethelpsymbol(my_numbox_class, gensym("numbox2")); -- GitLab