From 1435e5d46c510d184a25ce06fc4e097f733d5cca Mon Sep 17 00:00:00 2001 From: Mathieu L Bouchard <matju@artengine.ca> Date: Sun, 10 Aug 2014 13:06:03 -0400 Subject: [PATCH] =?UTF-8?q?big=20refactoring=20#7=C2=A0:=20iemgui=C2=A0:?= =?UTF-8?q?=20simplified=20draw=5Fnew,=20draw=5Fmove,=20draw=5Fupdate,=20.?= =?UTF-8?q?..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pd/src/g_all_guis.c | 128 +++++++++----- pd/src/g_all_guis.h | 39 +++-- pd/src/g_bang.c | 105 ++++-------- pd/src/g_canvas.c | 16 +- pd/src/g_editor.c | 62 ++++--- pd/src/g_hdial.c | 161 ++++++------------ pd/src/g_hslider.c | 140 +++++---------- pd/src/g_mycanvas.c | 53 ++---- pd/src/g_numbox.c | 311 ++++++++++------------------------ pd/src/g_toggle.c | 135 +++++---------- pd/src/g_vdial.c | 169 ++++++------------ pd/src/g_vslider.c | 136 +++++---------- pd/src/g_vumeter.c | 405 ++++++++++++-------------------------------- 13 files changed, 630 insertions(+), 1230 deletions(-) diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index 35a66d720..bd108e680 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -709,17 +709,13 @@ int iemgui_dialog(t_iemgui *iemgui, t_symbol **srl, int argc, t_atom *argv) void iem_inttosymargs(t_iemgui *x, int n) { x->x_loadinit = (n >> 0); - x->x_scale = (n >> 20); - x->x_flashed = 0; x->x_locked = 0; x->x_reverse = 0; } int iem_symargstoint(t_iemgui *x) { - return ( - (((x->x_loadinit & 1) << 0) | - ((x->x_scale & 1) << 20))); + return ((x->x_loadinit & 1) << 0); } void iem_inttofstyle(t_iemgui *x, int n) @@ -729,9 +725,6 @@ void iem_inttofstyle(t_iemgui *x, int n) x->x_finemoved = 0; x->x_put_in2out = 0; x->x_change = 0; - x->x_thick = 0; - x->x_lin0_log1 = 0; - x->x_steady = 0; } int iem_fstyletoint(t_iemgui *x) @@ -779,7 +772,7 @@ void scalehandle_bind(t_scalehandle *h) { // canvas has no label handle and has a motion handle // but in the case of canvas, the "iemgui" tag is added (it wasn't the case originally) void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py, -const char *nlet_tag, const char *class_tag) { +const char *nlet_tag) { char tags[128]; // BNG may need up to 100 chars in 64-bit mode, for example t_text *x = (t_text *)h->h_master; //if (!nlet_tag) nlet_tag = iem_get_tag(canvas, (t_iemgui *)x); @@ -788,7 +781,7 @@ const char *nlet_tag, const char *class_tag) { int sx = h->h_scale ? SCALEHANDLE_WIDTH : LABELHANDLE_WIDTH; int sy = h->h_scale ? SCALEHANDLE_HEIGHT : LABELHANDLE_HEIGHT; - //printf("scalehandle_draw_select(x%lx,x%lx,%d,%d,\"%s\",\"%s\")\n",h,canvas,px,py,nlet_tag,class_tag); + //printf("scalehandle_draw_select(x%lx,x%lx,%d,%d,\"%s\",\"%s\")\n",h,canvas,px,py,nlet_tag); if (h->h_vis) scalehandle_draw_erase(h,canvas); @@ -798,12 +791,12 @@ const char *nlet_tag, const char *class_tag) { // there was a %lxBNG tag (or similar) in every scalehandle, // but it didn't seem to be used —mathieu if (h->h_scale) { - sprintf(tags,"%lx%s %lxSCALE iemgui %s", - (long)x,class_tag,(long)x,nlet_tag); + sprintf(tags,"%lxOBJ %lxSCALE iemgui %s", + (long)x,(long)x,nlet_tag); } else { //sprintf(tags,"%lx%s %lxLABEL %lxLABELH iemgui %s", // causes unknown option "-fill" - sprintf(tags,"%lx%s %lx%s iemgui %s", (long)x,class_tag, - (long)x,strcmp(class_tag,"GOP")?"LABELH":"MOVE",nlet_tag); + sprintf(tags,"%lxOBJ %lx%s iemgui %s", (long)x, + (long)x,pd_class((t_pd *)x)==canvas_class?"MOVE":"LABELH",nlet_tag); } sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d " "-window %s -tags {%s}\n", canvas, x->te_xpix+px-sx, x->te_ypix+py-sy, @@ -812,12 +805,12 @@ const char *nlet_tag, const char *class_tag) { h->h_vis = 1; } -void scalehandle_draw_select2(t_iemgui *x, t_glist *canvas, const char *class_tag, int sx, int sy) { +void scalehandle_draw_select2(t_iemgui *x, t_glist *canvas, int sx, int sy) { char *nlet_tag = iem_get_tag(canvas, (t_iemgui *)x); - scalehandle_draw_select(x->x_handle,canvas,sx,sy,nlet_tag,class_tag); + scalehandle_draw_select(x->x_handle,canvas,sx,sy,nlet_tag); if (x->x_lab!=s_empty) { - scalehandle_draw_select(x->x_lhandle,canvas,x->x_ldx,x->x_ldy,nlet_tag,class_tag); + scalehandle_draw_select(x->x_lhandle,canvas,x->x_ldx,x->x_ldy,nlet_tag); } } @@ -967,21 +960,21 @@ void scalehandle_drag_scale(t_scalehandle *h) { //---------------------------------------------------------------- // IEMGUI refactor (by Mathieu) -void iemgui_tag_selected(t_iemgui *x, t_glist *canvas, const char *class_tag) { +void iemgui_tag_selected(t_iemgui *x, t_glist *canvas) { if(x->x_selected) - sys_vgui(".x%lx.c addtag selected withtag %lx%s\n", canvas, x, class_tag); + sys_vgui(".x%lx.c addtag selected withtag %lxOBJ\n", canvas, x); else - sys_vgui(".x%lx.c dtag %lx%s selected\n", canvas, x, class_tag); + sys_vgui(".x%lx.c dtag %lxOBJ selected\n", canvas, x); } -void iemgui_label_draw_new(t_iemgui *x, t_glist *canvas, int xpos, int ypos, const char *nlet_tag, const char *class_tag) { +void iemgui_label_draw_new(t_iemgui *x, t_glist *canvas, int xpos, int ypos, const char *nlet_tag) { sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " "-font {{%s} -%d %s} -fill #%6.6x " - "-tags {%lxLABEL %lx%s text iemgui %s}\n", + "-tags {%lxLABEL %lxOBJ text iemgui %s}\n", canvas, xpos+x->x_ldx, ypos+x->x_ldy, x->x_lab!=s_empty?x->x_lab->s_name:"", iemgui_font(x), x->x_fontsize, sys_fontweight, - x->x_lcol, x, x, class_tag, nlet_tag); + x->x_lcol, x, x, nlet_tag); } void iemgui_label_draw_move(t_iemgui *x, t_glist *canvas, int xpos, int ypos) { sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", @@ -1008,7 +1001,9 @@ void iemgui_label_draw_select(t_iemgui *x, t_glist *canvas) { canvas, x, x->x_lcol); } -void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags, const char *class_tag) { +extern t_class *vu_class; +void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags) { + if (x->x_glist != canvas) return; // is gop int a,b; t_class *c = pd_class((t_pd *)x); //printf("--- iemgui_io_draw %s flags=%d\n",c->c_name->s_name,old_sr_flags); @@ -1022,45 +1017,85 @@ void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags, const char * int x1,y1,x2,y2; c->c_wb->w_getrectfn((t_gobj *)x,canvas,&x1,&y1,&x2,&y2); + int i, n = c==vu_class ? 2 : 1, k=(x2-x1)-IOWIDTH; + a=old_sr_flags&IEM_GUI_OLD_SND_FLAG; - //b=iemgui_has_snd(x); // not inited at moment of new b=x->x_snd!=s_empty; //printf("a=%d b=%d snd=%s\n",a,b,x->x_snd->s_name); - if(a && !b) - //printf("%s create outlet\n",c->c_name->s_name), fflush(stdout), + if(a && !b) for (i=0; i<n; i++) sys_vgui(".x%lx.c create prect %d %d %d %d " "-stroke $pd_colors(iemgui_nlet) " - "-tags {%lx%s%so%d %so%d %lx%s outlet iemgui %s}\n", - canvas, x1, y2-1, x1 + IOWIDTH, y2, - x, class_tag, nlet_tag, 0, nlet_tag, 0, x, class_tag, nlet_tag); - if(!a && b) - //printf("%s delete outlet\n",c->c_name->s_name), fflush(stdout), - sys_vgui(".x%lx.c delete %lx%s%so%d\n", canvas, x, class_tag, nlet_tag, 0); + "-tags {%lxOBJ%so%d %so%d %lxOBJ outlet iemgui %s}\n", + canvas, x1+i*k, y2-1, x1+i*k + IOWIDTH, y2, + x, nlet_tag, i, nlet_tag, i, x, nlet_tag); + if(!a && b) for (i=0; i<n; i++) + sys_vgui(".x%lx.c delete %lxOBJ%so%d\n", canvas, x, nlet_tag, 0); a=old_sr_flags&IEM_GUI_OLD_RCV_FLAG; - //b=iemgui_has_rcv(x); // not inited at moment of new b=x->x_rcv!=s_empty; //printf("a=%d b=%d rcv=%s\n",a,b,x->x_rcv->s_name); - if(a && !b) - //printf("%s create inlet\n",c->c_name->s_name), fflush(stdout), + if(a && !b) for (i=0; i<n; i++) sys_vgui(".x%lx.c create prect %d %d %d %d " "-stroke $pd_colors(iemgui_nlet) " - "-tags {%lx%s%si%d %si%d %lx%s inlet iemgui %s}\n", - canvas, x1, y1, x1 + IOWIDTH, y1+1, - x, class_tag, nlet_tag, 0, nlet_tag, 0, x, class_tag, nlet_tag); - if(!a && b) - //printf("%s delete inlet\n",c->c_name->s_name), fflush(stdout), - sys_vgui(".x%lx.c delete %lx%s%si%d\n", canvas, x, class_tag, nlet_tag, 0); + "-tags {%lxOBJ%si%d %si%d %lxOBJ inlet iemgui %s}\n", + canvas, x1+i*k, y1, x1+i*k + IOWIDTH, y1+1, + x, nlet_tag, i, nlet_tag, i, x, nlet_tag); + if(!a && b) for (i=0; i<n; i++) + sys_vgui(".x%lx.c delete %lxOBJ%si%d\n", canvas, x, nlet_tag, 0); //printf("---/iemgui_io_draw\n"); } -void iemgui_draw_erase(t_iemgui *x, t_glist* glist, const char *class_tag) { +void iemgui_io_draw_move(t_iemgui *x, t_glist *canvas, const char *nlet_tag) { + t_class *c = pd_class((t_pd *)x); + int x1,y1,x2,y2; + c->c_wb->w_getrectfn((t_gobj *)x,canvas,&x1,&y1,&x2,&y2); + int i, n = c==vu_class ? 2 : 1, k=(x2-x1)-IOWIDTH; + if(!iemgui_has_snd(x) && canvas == x->x_glist) for (i=0; i<n; i++) + sys_vgui(".x%lx.c coords %lxOBJ%so%d %d %d %d %d\n", + canvas, x, nlet_tag, i, x1+i*k, y2-1, x1+i*k+IOWIDTH, y2); + if(!iemgui_has_rcv(x) && canvas == x->x_glist) for (i=0; i<n; i++) + sys_vgui(".x%lx.c coords %lxOBJ%si%d %d %d %d %d\n", + canvas, x, nlet_tag, i, x1+i*k, y1, x1+i*k+IOWIDTH, y1+1); +} + +void iemgui_base_draw_new(t_iemgui *x, t_glist *canvas, const char *nlet_tag) { + t_class *c = pd_class((t_pd *)x); + int x1,y1,x2,y2; + c->c_wb->w_getrectfn((t_gobj *)x,x->x_glist,&x1,&y1,&x2,&y2); + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_border) -fill #%6.6x " + "-tags {%lxBASE %lxOBJ text iemgui border %s}\n", + canvas, x1,y1,x2,y2, x->x_bcol, x, x, nlet_tag); +} + +void iemgui_base_draw_move(t_iemgui *x, t_glist *canvas, const char *nlet_tag) { + t_class *c = pd_class((t_pd *)x); + int x1,y1,x2,y2; + c->c_wb->w_getrectfn((t_gobj *)x,x->x_glist,&x1,&y1,&x2,&y2); + sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", canvas, x, x1, y1, x2, y2); +} + +void iemgui_base_draw_config(t_iemgui *x, t_glist *canvas) { + char fcol[8]; sprintf(fcol,"#%6.6x", x->x_fcol); + sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x, x->x_bcol); + sys_vgui(".x%lx.c itemconfigure {%lxBASE||%lxBASEL} -stroke %s\n", canvas, x, x, + x->x_selected && x->x_glist == canvas ? selection_color : fcol); +} + +void iemgui_draw_erase(t_iemgui *x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - sys_vgui(".x%lx.c delete %lx%s\n", canvas, x, class_tag); - sys_vgui(".x%lx.c dtag all %lx%s\n", canvas, x, class_tag); + sys_vgui(".x%lx.c delete %lxOBJ\n", canvas, x); + sys_vgui(".x%lx.c dtag all %lxOBJ\n", canvas, x); scalehandle_draw_erase2(x,glist); } +void scrollbar_update(t_glist *glist) { + //ico@bukvic.net 100518 update scrollbars when object potentially + //exceeds window size + t_canvas *canvas=(t_canvas *)glist_getcanvas(glist); + sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)canvas); +} + void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl) { wb->w_getrectfn = gr; wb->w_displacefn = iemgui_displace; @@ -1102,3 +1137,6 @@ void iemgui_class_addmethods(t_class *c) { void g_iemgui_setup (void) { s_empty = gensym("empty"); } + +const char *selection_color = "$pd_colors(selection)"; + diff --git a/pd/src/g_all_guis.h b/pd/src/g_all_guis.h index e9e2d8895..05e991973 100644 --- a/pd/src/g_all_guis.h +++ b/pd/src/g_all_guis.h @@ -153,18 +153,15 @@ typedef struct _iemgui // from t_iem_fstyle_flags unsigned int x_font_style:6; // 39 matches unsigned int x_selected:1; // 38 matches - unsigned int x_finemoved:1; // 11 matches + unsigned int x_finemoved:1; // 11 matches (sliders and [nbx] only) unsigned int x_put_in2out:1; // 17 matches - unsigned int x_change:1; // 37 matches - unsigned int x_thick:1; // 14 matches - unsigned int x_lin0_log1:1; // 38 matches - unsigned int x_steady:1; // 18 matches + unsigned int x_change:1; // 37 matches // what's this and why is there also a x_changed ? + unsigned int dummy2:3; // from t_iem_init_symargs unsigned int x_loadinit:1; // 33 matches - unsigned int x_scale:1; // 22 matches - unsigned int x_flashed:1; // 16 matches - unsigned int x_locked:1; // 8 matches - unsigned int x_reverse:1; /* bugfix */ // 8 matches + unsigned int dummy3:2; + unsigned int x_locked:1; // 8 matches ([bng] only) + unsigned int x_reverse:1; // 8 matches (sliders only) unsigned int dummy:14; } t_iemgui; @@ -184,7 +181,7 @@ typedef struct _hslider t_iemgui x_gui; int x_pos; int x_val; - int x_center; + int x_center; // is this necessary ? int x_thick; int x_lin0_log1; int x_steady; @@ -324,8 +321,8 @@ EXTERN void canvas_apply_setundo(t_canvas *x, t_gobj *y); // scalehandle code, as refactored by Mathieu EXTERN void scalehandle_bind(t_scalehandle *h); -EXTERN void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py, const char *nlet_tag, const char *class_tag); -EXTERN void scalehandle_draw_select2(t_iemgui *x, t_glist *canvas, const char *class_tag, int sx, int sy); +EXTERN void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py, const char *nlet_tag); +EXTERN void scalehandle_draw_select2(t_iemgui *x, t_glist *canvas, int sx, int sy); EXTERN void scalehandle_draw_erase(t_scalehandle *h, t_glist *canvas); EXTERN void scalehandle_draw_erase2(t_iemgui *x, t_glist *canvas); EXTERN void scalehandle_draw_new(t_scalehandle *x, t_glist *canvas); @@ -343,17 +340,22 @@ EXTERN int mini(int a, int b); EXTERN int maxi(int a, int b); // other refactor by Mathieu -EXTERN void iemgui_tag_selected( t_iemgui *x, t_glist *canvas, const char *class_tag); -EXTERN void iemgui_label_draw_new( t_iemgui *x, t_glist *canvas, int xpos, int ypos, const char *nlet_tag, const char *class_tag); +EXTERN void iemgui_tag_selected( t_iemgui *x, t_glist *canvas); +EXTERN void iemgui_label_draw_new( t_iemgui *x, t_glist *canvas, int xpos, int ypos, const char *nlet_tag); EXTERN void iemgui_label_draw_move( t_iemgui *x, t_glist *canvas, int xpos, int ypos); EXTERN void iemgui_label_draw_config(t_iemgui *x, t_glist *canvas); EXTERN void iemgui_label_draw_select(t_iemgui *x, t_glist *canvas); -EXTERN void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags, const char *class_tag); -EXTERN void iemgui_draw_erase(t_iemgui *x, t_glist* glist, const char *class_tag); +EXTERN void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags); +EXTERN void iemgui_io_draw_move(t_iemgui *x, t_glist *canvas, const char *nlet_tag); +EXTERN void iemgui_base_draw_new(t_iemgui *x, t_glist *canvas, const char *nlet_tag); +EXTERN void iemgui_base_draw_move(t_iemgui *x, t_glist *canvas, const char *nlet_tag); +EXTERN void iemgui_base_draw_config(t_iemgui *x, t_glist *canvas); -EXTERN void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl); +EXTERN void iemgui_draw_erase(t_iemgui *x, t_glist* glist); +EXTERN void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl); // rename this to iemgui_wb_init extern t_symbol *s_empty; +EXTERN const char *selection_color; //static inline int iemgui_has_snd (t_iemgui *x) {return x->x_snd_unexpanded!=s_empty;} //static inline int iemgui_has_rcv (t_iemgui *x) {return x->x_rcv_unexpanded!=s_empty;} @@ -362,4 +364,7 @@ static inline int iemgui_has_rcv (t_iemgui *x) {return x->x_rcv!=s_empty;} EXTERN const char *iemgui_font(t_iemgui *x); EXTERN void iemgui_class_addmethods(t_class *c); +EXTERN void scrollbar_update(t_glist *glist); + + diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c index 044a69f5a..7240ac1b2 100644 --- a/pd/src/g_bang.c +++ b/pd/src/g_bang.c @@ -38,21 +38,19 @@ static t_class *bng_class; void bng_draw_update(t_gobj *xgobj, t_glist *glist) { t_bng *x = (t_bng *)xgobj; - if (x->x_gui.x_changed != x->x_flashed) + + if (x->x_gui.x_changed != x->x_flashed && glist_isvisible(glist)) { - if(glist_isvisible(glist)) - { - sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", - glist_getcanvas(glist), x, - x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); - } - x->x_gui.x_changed = x->x_flashed; + sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", + glist_getcanvas(glist), x, + x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); } + x->x_gui.x_changed = x->x_flashed; } void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags) { t_canvas *canvas=glist_getcanvas(glist); - iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags,"BNG"); + iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags); } void bng_draw_new(t_bng *x, t_glist *glist) @@ -66,101 +64,72 @@ void bng_draw_new(t_bng *x, t_glist *glist) char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_border) -fill #%6.6x " - "-tags {%lxBASE %lxBNG text iemgui border %s}\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); + iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag); t_float cr = (x->x_gui.x_w-2)/2.0; t_float cx = xpos+cr+1.5; t_float cy = ypos+cr+1.5; sys_vgui(".x%lx.c create circle %f %f -r %f " "-stroke $pd_colors(iemgui_border) -fill #%6.6x " - "-tags {%lxBUT %lxBNG text iemgui border %s}\n", + "-tags {%lxBUT %lxOBJ text iemgui border %s}\n", canvas, cx, cy, cr, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, x, x, nlet_tag); - iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag,"BNG"); + iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag); bng_draw_io(x,glist,7); } void bng_draw_move(t_bng *x, t_glist *glist) { + t_canvas *canvas=glist_getcanvas(glist); + if (!glist_isvisible(canvas)) return; 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)) - { - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - 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); - t_float cr = (x->x_gui.x_w-2)/2.0; - t_float cx = xpos+cr+1.5; - t_float cy = ypos+cr+1.5; - - /*sys_vgui(".x%lx.c create circle %d %d -r %d " - "-stroke #%6.6x " - "-tags {%lxBUT %lxBNG %lx text iemgui}\n", - canvas, cx, cy, cr,*/ - - sys_vgui(".x%lx.c coords %lxBUT %f %f\n", - canvas, x, cx, cy); - sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x -r %f\n", - canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, cr); - iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); - if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxBNG%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(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxBNG%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xpos, ypos, - xpos + IOWIDTH, ypos+1); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_selected) - bng_draw_select(x, x->x_gui.x_glist); - } + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + iemgui_base_draw_move(&x->x_gui, canvas, nlet_tag); + t_float cr = (x->x_gui.x_w-2)/2.0; + t_float cx = xpos+cr+1.5; + t_float cy = ypos+cr+1.5; + sys_vgui(".x%lx.c coords %lxBUT %f %f\n", canvas, x, cx, cy); + sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x -r %f\n", + canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, cr); + iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); + iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag); + if (x->x_gui.x_selected) bng_draw_select(x, x->x_gui.x_glist); } void bng_draw_config(t_bng* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); iemgui_label_draw_config(&x->x_gui,canvas); - sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n " - ".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", - canvas, x, x->x_gui.x_bcol, canvas, x, - x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); - /*sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", canvas, x, - x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);*/ + iemgui_base_draw_config(&x->x_gui,canvas); + sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", + canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); } void bng_draw_select(t_bng* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); + iemgui_base_draw_config(&x->x_gui,canvas); if(x->x_gui.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)) { - sys_vgui(".x%lx.c itemconfigure {%lxBASE||%lxBUT} " - "-stroke $pd_colors(selection)\n", canvas, x, x); - scalehandle_draw_select2(&x->x_gui,glist,"BNG", + sys_vgui(".x%lx.c itemconfigure %lxBUT " + "-stroke $pd_colors(selection)\n", canvas, x); + scalehandle_draw_select2(&x->x_gui,glist, x->x_gui.x_w-1,x->x_gui.x_h-1); } } else { - sys_vgui(".x%lx.c itemconfigure {%lxBASE||%lxBUT} -stroke %s\n", - canvas, x, x, IEM_GUI_COLOR_NORMAL); + sys_vgui(".x%lx.c itemconfigure %lxBUT -stroke %s\n", + canvas, x, IEM_GUI_COLOR_NORMAL); scalehandle_draw_erase2(&x->x_gui,glist); } iemgui_label_draw_select(&x->x_gui,canvas); - iemgui_tag_selected(&x->x_gui,canvas,"BNG"); + iemgui_tag_selected(&x->x_gui,canvas); } static void bng__clickhook(t_scalehandle *sh, t_floatarg f, @@ -235,7 +204,7 @@ void bng_draw(t_bng *x, t_glist *glist, int mode) else if(mode == IEM_GUI_DRAW_MODE_SELECT) bng_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) - iemgui_draw_erase(&x->x_gui, glist, "BNG"); + iemgui_draw_erase(&x->x_gui, glist); else if(mode == IEM_GUI_DRAW_MODE_CONFIG) bng_draw_config(x, glist); else if(mode >= IEM_GUI_DRAW_MODE_IO) @@ -404,11 +373,7 @@ static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv) { bng_draw_select(x, x->x_gui.x_glist); } - - //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); + scrollbar_update(x->x_gui.x_glist); } static void bng_click(t_bng *x, t_floatarg xpos, t_floatarg ypos, diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 75578e82c..9be2ddffe 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -537,7 +537,7 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym, if (!menu) pd_pushsym(&x->gl_pd); glist_add(g, &x->gl_gobj); - if (!do_not_redraw) sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)glist_getcanvas(g)); + if (!do_not_redraw) scrollbar_update(glist_getcanvas(g)); //fprintf(stderr," ... %f %f\n", x->gl_x1, x->gl_x2); return (x); } @@ -711,11 +711,11 @@ void canvas_draw_gop_resize_hooks(t_canvas* x) scalehandle_draw_select(sh,x, -1-x->gl_obj.te_xpix+x->gl_xmargin + x->gl_pixwidth, -1-x->gl_obj.te_ypix+x->gl_ymargin + x->gl_pixheight, - "GOP_resblob","GOP"); + "GOP_resblob"); scalehandle_draw_select(mh,x, 2+SCALEHANDLE_WIDTH -x->gl_obj.te_xpix+x->gl_xmargin, 2+SCALEHANDLE_HEIGHT-x->gl_obj.te_ypix+x->gl_ymargin, - "GOP_movblob","GOP"); + "GOP_movblob"); } else { @@ -773,7 +773,7 @@ void canvas_map(t_canvas *x, t_floatarg f) canvas_drawlines(x); if (x->gl_isgraph && x->gl_goprect) canvas_drawredrect(x, 1); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); //} } else @@ -1907,9 +1907,9 @@ void canvasgop_draw_move(t_canvas *x, int doit) canvas=canvas->gl_owner; //canvas_redraw(canvas); } - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_int)x); + scrollbar_update(x); if (x->gl_owner && glist_isvisible(x->gl_owner)) - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_int)x->gl_owner); + scrollbar_update(x->gl_owner); } extern int gfxstub_haveproperties(void *key); @@ -1968,7 +1968,7 @@ void canvasgop__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_flo sys_vgui(".x%x.c delete %s\n", x, sh->h_outlinetag); canvasgop_draw_move(x,1); canvas_fixlinesfor(x, (t_text *)x); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } } else //enter if move_gop hook @@ -1984,7 +1984,7 @@ void canvasgop__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_flo { canvasgop_draw_move(x,1); canvas_fixlinesfor(x, (t_text *)x); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } } } diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index adbe5af47..f0a64e4c6 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -785,7 +785,7 @@ static void canvas_undo(t_canvas *x) if (glist_isvisible(x) && glist_istoplevel(x)) sys_vgui("pdtk_undomenu .x%lx no %s\n", x, canvas_undo_name); canvas_undo_whatnext = UNDO_REDO; - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } } @@ -804,7 +804,7 @@ static void canvas_redo(t_canvas *x) if (glist_isvisible(x) && glist_istoplevel(x)) sys_vgui("pdtk_undomenu .x%lx %s no\n", x, canvas_undo_name); canvas_undo_whatnext = UNDO_UNDO; - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } } @@ -1893,9 +1893,8 @@ void canvas_undo_canvas_apply(t_canvas *x, void *z, int action) properties, x->gl_ymargin); }*/ - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_int)x); - if (canvas != x) - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_int)canvas); + scrollbar_update(x); + if (canvas != x) scrollbar_update(canvas); } else if (action == UNDO_FREE) @@ -2425,7 +2424,7 @@ void canvas_vis(t_canvas *x, t_floatarg f) //if (g && (pd_class(&g->g_pd) == garray_class) // sys_vgui("pdtk_canvas_set_scrollless .x%lx\n", x); //else - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); /* //newly opened arrays created prior to pd-l2ork require fittograph @@ -2496,7 +2495,7 @@ void canvas_vis(t_canvas *x, t_floatarg f) canvas_destroy_editor(x); return; } - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); glist_noselect(x); if (glist_isvisible(x)) canvas_map(x, 0); @@ -2780,7 +2779,7 @@ static void canvas_donecanvasdialog(t_glist *x, t_canvas *canvas=(t_canvas *)glist_getcanvas(x); //if gop is being disabled go one level up (if u can) if (!graphme && canvas->gl_owner) canvas=canvas->gl_owner; - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_int)canvas); + scrollbar_update(x); } /* called by undo/redo arrange and done_canvas_popup. only done_canvas_popup @@ -3076,7 +3075,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, { //fprintf(stderr,"letting go of objects\n"); sys_vgui(".x%lx.c raise all_cords\n", x); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } if (x->gl_editor->e_onmotion != MA_SCROLL) { @@ -3302,7 +3301,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, { objtooltip = 1; sys_vgui("pdtk_canvas_enteritem " - ".x%x.c %d %d %s -1\n;", + ".x%x.c %d %d %s -1\n", x, xpos, ypos, x->gl_editor->canvas_cnct_outlet_tag); } @@ -3374,7 +3373,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, { objtooltip = 1; sys_vgui("pdtk_canvas_enteritem " - ".x%x.c %d %d %s -1\n;", + ".x%x.c %d %d %s -1\n", x, xpos, ypos, x->gl_editor->canvas_cnct_inlet_tag); } @@ -3432,7 +3431,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, //sys_vgui("pdtk_toggle_xy_tooltip .x%lx %d\n", x, 1); x->gl_editor->e_onmotion = MA_MOVE; if (tooltips) - sys_vgui("pdtk_tip .x%x.c 0 0\n;", x); + sys_vgui("pdtk_tip .x%x.c 0 0\n", x); } } else @@ -4095,6 +4094,7 @@ int canvas_trymulticonnect(t_canvas *x, int xpos, int ypos, int which, int doit) return_val = canvas_doconnect_doit( x, y1, y2, closest1 + i, closest2 + i, 1, 1); } + hotspot1=hotspot1; hotspot2=hotspot2; // silence warnings (unused vars) } return(return_val); /* end of FIRST OPTION */ @@ -4159,6 +4159,7 @@ int canvas_trymulticonnect(t_canvas *x, int xpos, int ypos, int which, int doit) } } } + hotspot1=hotspot1; hotspot2=hotspot2; // silence warnings (unused vars) } return(return_val); /* end of SECOND OPTION */ @@ -4225,7 +4226,8 @@ int canvas_trymulticonnect(t_canvas *x, int xpos, int ypos, int which, int doit) x, sel->sel_what, y2, closest1, closest2, 1, 1); } } - } + } + hotspot1=hotspot1; hotspot2=hotspot2; // silence warnings (unused vars) } return(return_val); /* end of THIRD OPTION */ @@ -4273,6 +4275,8 @@ int canvas_trymulticonnect(t_canvas *x, int xpos, int ypos, int which, int doit) } else closest2 = 0, hotspot2 = x21; + hotspot1=hotspot1; hotspot2=hotspot2; // silence warnings (unused vars) + if (closest1 >= noutlet1) closest1 = noutlet1 - 1; if (closest2 >= ninlet2) @@ -4508,6 +4512,8 @@ void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit) } else closest2 = 0, hotspot2 = x21; + hotspot1=hotspot1; hotspot2=hotspot2; // silence warnings (unused vars) + if (closest1 >= noutlet1) closest1 = noutlet1 - 1; if (closest2 >= ninlet2) @@ -4755,7 +4761,7 @@ void canvas_mouseup(t_canvas *x, gobj_activate(x->gl_editor->e_selection->sel_what, x, 1); //} } - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } else if (x->gl_editor->e_onmotion == MA_SCROLL) { @@ -4898,7 +4904,7 @@ static void canvas_displaceselection(t_canvas *x, int dx, int dy) sys_vgui("pdtk_canvas_displace_withtag .x%lx.c %d %d\n", x, dx, dy); if (resortin) canvas_resortinlets(x); if (resortout) canvas_resortoutlets(x); - //sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + //scrollbar_update(x); if (x->gl_editor->e_selection) canvas_dirty(x, 1); } @@ -4919,7 +4925,7 @@ static void canvas_displaceselection(t_canvas *x, int dx, int dy) void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av) { static t_symbol *keynumsym, *keyupsym, *keynamesym; - int keynum, fflag; + int keynum; t_symbol *gotkeysym; int down, shift; @@ -4986,7 +4992,7 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av) } } else gotkeysym = gensym("?"); - fflag = (av[0].a_type == A_FLOAT ? av[0].a_w.w_float : 0); + //fflag = (av[0].a_type == A_FLOAT ? av[0].a_w.w_float : 0); keynum = (av[1].a_type == A_FLOAT ? av[1].a_w.w_float : 0); if (keynum == '\\' || keynum == '{' || keynum == '}') { @@ -5098,24 +5104,24 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av) if (!strcmp(gotkeysym->s_name, "Up")) { canvas_displaceselection(x, 0, shift ? -10 : -1); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } else if (!strcmp(gotkeysym->s_name, "Down")) { canvas_displaceselection(x, 0, shift ? 10 : 1); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } else if (!strcmp(gotkeysym->s_name, "Left") || !strcmp(gotkeysym->s_name, "ShiftLeft")) { canvas_displaceselection(x, shift ? -10 : -1, 0); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } else if (!strcmp(gotkeysym->s_name, "Right") || !strcmp(gotkeysym->s_name, "ShiftRight")) { canvas_displaceselection(x, shift ? 10 : 1, 0); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } } } @@ -5182,7 +5188,7 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, x->gl_editor->e_ywas = ypos; x->gl_editor->e_xnew = xpos; x->gl_editor->e_ynew = ypos; - //sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + // scrollbar_update(x); //sys_vgui("pdtk_check_scroll_on_motion .x%lx.c 20\n", x); } else if (x->gl_editor->e_onmotion == MA_REGION) @@ -5982,7 +5988,7 @@ static void canvas_doclear(t_canvas *x) restore: canvas_dirty(x, 1); //canvas_redraw(x); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); canvas_resume_dsp(dspstate); } @@ -6014,7 +6020,7 @@ static void canvas_cut(t_canvas *x) canvas_doclear(x); glob_preset_node_list_check_loc_and_update(); paste_xyoffset = 0; - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } } @@ -6259,7 +6265,7 @@ static void canvas_dopaste(t_canvas *x, t_binbuf *b) // canvas_redraw(x); //} - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); if (!abort_when_pasting_from_external_buffer) { glist_donewloadbangs(x); @@ -7085,7 +7091,7 @@ static void canvas_tidy(t_canvas *x) } canvas_dirty(x, 1); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } @@ -7225,7 +7231,7 @@ void glob_pastetext(void *dummy, t_symbol *s, int ac, t_atom *av) if ((int)atom_getfloat(av) == 1) { //fprintf(stderr,"force getscroll\n"); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", canvas_editing); + scrollbar_update(canvas_editing); } } @@ -7412,7 +7418,7 @@ static void canvas_dofont(t_canvas *x, t_floatarg font, t_floatarg xresize, if (pd_class(&y->g_pd) == canvas_class && !canvas_isabstraction((t_canvas *)y)) canvas_dofont((t_canvas *)y, font, xresize, yresize); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x); + scrollbar_update(x); } /* canvas_menufont calls up a TK dialog which calls this back */ diff --git a/pd/src/g_hdial.c b/pd/src/g_hdial.c index 5eadf09ee..8b072ba2a 100644 --- a/pd/src/g_hdial.c +++ b/pd/src/g_hdial.c @@ -2,14 +2,12 @@ * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ -/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ +/* vdial.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ -/* name change to hradio by MSP and changed to +/* name change to vradio by MSP (it's a radio button really) and changed to put out a "float" as in sliders, toggles, etc. */ -#include "config.h" - #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -20,14 +18,6 @@ put out a "float" as in sliders, toggles, etc. */ #include "g_all_guis.h" #include <math.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#ifdef HAVE_IO_H -#include <io.h> -#endif - extern int gfxstub_haveproperties(void *key); void hradio_draw_select(t_hradio* x, t_glist* glist); @@ -41,98 +31,71 @@ static t_class *hradio_class, *hradio_old_class; void hradio_draw_update(t_gobj *client, t_glist *glist) { t_hradio *x = (t_hradio *)client; - if(glist_isvisible(glist)) - { - t_canvas *canvas=glist_getcanvas(glist); - - sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", - canvas, x, x->x_drawn, - x->x_gui.x_bcol, x->x_gui.x_bcol); - sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", - canvas, x, x->x_on, - x->x_gui.x_fcol, x->x_gui.x_fcol); - x->x_drawn = x->x_on; - } + if(!glist_isvisible(glist)) return; + t_canvas *canvas=glist_getcanvas(glist); + sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", + canvas, x, x->x_drawn, x->x_gui.x_bcol, x->x_gui.x_bcol); + sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", + canvas, x, x->x_on, x->x_gui.x_fcol, x->x_gui.x_fcol); + x->x_drawn = x->x_on; } void hradio_draw_io(t_hradio* x, t_glist* glist, int old_snd_rcv_flags) { t_canvas *canvas=glist_getcanvas(glist); - iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags,"HRDO"); + iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags); } void hradio_draw_new(t_hradio *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4; - int yy11=text_ypix(&x->x_gui.x_obj, glist), yy12=yy11+dx; - int yy21=yy11+s4, yy22=yy12-s4; - int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4; - int xx22=xx11b+dx-s4; + int n=x->x_number, i, d=x->x_gui.x_w, s=d/4; + int x1=text_xpix(&x->x_gui.x_obj, glist), xi=x1; + int y1=text_ypix(&x->x_gui.x_obj, glist); + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag); scalehandle_draw_new(x->x_gui. x_handle,canvas); scalehandle_draw_new(x->x_gui.x_lhandle,canvas); - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - for(i=0; i<n; i++) - { - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_border) -fill #%6.6x " - "-tags {%lxBASE%d %lxBASE %lxHRDO %s text iemgui border}\n", - canvas, xx11, yy11, xx11+dx, yy12, - x->x_gui.x_bcol, x, i, x, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x " - "-stroke #%6.6x -tags {%lxBUT%d %lxHRDO %s text iemgui}\n", - canvas, xx21, yy21, xx22, yy22, - (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, - (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, - x, i, x, nlet_tag); - xx11 += dx; - xx21 += dx; - xx22 += dx; - x->x_drawn = x->x_on; - } - iemgui_label_draw_new(&x->x_gui,canvas,xx11b,yy11,nlet_tag,"HRDO"); + for(i=0; i<n; i++) + { + if (i) sys_vgui(".x%lx.c create pline %d %d %d %d " + "-stroke $pd_colors(iemgui_border) " + "-tags {%lxBASE%d %lxBASEL %lxOBJ %s text iemgui border}\n", + canvas, xi, y1, xi, y1+d, x, i, x, x, nlet_tag); + sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x " + "-stroke #%6.6x -tags {%lxBUT%d %lxOBJ %s text iemgui}\n", + canvas, xi+s, y1+s, xi+d-s, y1+d-s, + (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, + (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, + x, i, x, nlet_tag); + xi += d; + x->x_drawn = x->x_on; + } + iemgui_label_draw_new(&x->x_gui,canvas,x1,y1,nlet_tag); hradio_draw_io(x,glist,7); } void hradio_draw_move(t_hradio *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4; - int yy11=text_ypix(&x->x_gui.x_obj, glist), yy12=yy11+dx; - int yy21=yy11+s4, yy22=yy12-s4; - int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4; - int xx22=xx11b+dx-s4; + if (!glist_isvisible(canvas)) return; + int n=x->x_number, i, d=x->x_gui.x_w, s=d/4; + int x1=text_xpix(&x->x_gui.x_obj, glist), xi=x1; + int y1=text_ypix(&x->x_gui.x_obj, glist); + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + iemgui_base_draw_move(&x->x_gui, canvas, nlet_tag); - if (glist_isvisible(canvas)) + for(i=0; i<n; i++) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - xx11 = xx11b; - xx21=xx11b+s4; - xx22=xx11b+dx-s4; - for(i=0; i<n; i++) - { - sys_vgui(".x%lx.c coords %lxBASE%d %d %d %d %d\n", - canvas, x, i, xx11, yy11, xx11+dx, yy12); - sys_vgui(".x%lx.c coords %lxBUT%d %d %d %d %d\n", - canvas, x, i, xx21, yy21, xx22, yy22); - xx11 += dx; - xx21 += dx; - xx22 += dx; - } - iemgui_label_draw_move(&x->x_gui,canvas,xx11b,yy11); - if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxHRDO%so%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xx11b, yy12-1, xx11b + IOWIDTH, yy12); - if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxHRDO%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_selected) - hradio_draw_select(x, x->x_gui.x_glist); + sys_vgui(".x%lx.c coords %lxBASE%d %d %d %d %d\n", + canvas, x, i, xi, y1, xi, y1+d); + sys_vgui(".x%lx.c coords %lxBUT%d %d %d %d %d\n", + canvas, x, i, xi+s,y1+s, xi+d-s, y1+d-s); + xi += d; } + iemgui_label_draw_move(&x->x_gui,canvas,x1,y1); + iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag); + if (x->x_gui.x_selected) hradio_draw_select(x, x->x_gui.x_glist); } void hradio_draw_config(t_hradio* x, t_glist* glist) @@ -140,44 +103,36 @@ void hradio_draw_config(t_hradio* x, t_glist* glist) t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i; iemgui_label_draw_config(&x->x_gui,canvas); + iemgui_base_draw_config(&x->x_gui,canvas); for(i=0; i<n; i++) { - sys_vgui(".x%lx.c itemconfigure %lxBASE%d " - "-fill #%6.6x\n " - ".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", - canvas, x, i, x->x_gui.x_bcol, canvas, x, i, - (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, - (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol); - /*sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x " - "-outline #%6.6x\n", canvas, x, i, - (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, - (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol);*/ + sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", + canvas, x, i, + (x->x_on==i) ? x->x_gui.x_fcol : x->x_gui.x_bcol, + (x->x_on==i) ? x->x_gui.x_fcol : x->x_gui.x_bcol); } } void hradio_draw_select(t_hradio* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); + iemgui_base_draw_config(&x->x_gui,canvas); if(x->x_gui.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)) { - sys_vgui(".x%lx.c itemconfigure %lxBASE " - "-stroke $pd_colors(selection)\n", canvas, x); - scalehandle_draw_select2(&x->x_gui,glist,"HRDO", + scalehandle_draw_select2(&x->x_gui,glist, x->x_gui.x_w*x->x_number-1,x->x_gui.x_h-1); } } else { - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", - canvas, x, IEM_GUI_COLOR_NORMAL); scalehandle_draw_erase2(&x->x_gui,glist); } iemgui_label_draw_select(&x->x_gui,canvas); - iemgui_tag_selected(&x->x_gui,canvas,"HRDO"); + iemgui_tag_selected(&x->x_gui,canvas); } static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, @@ -251,7 +206,7 @@ void hradio_draw(t_hradio *x, t_glist *glist, int mode) else if(mode == IEM_GUI_DRAW_MODE_SELECT) hradio_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) - iemgui_draw_erase(&x->x_gui, glist, "HRDO"); + iemgui_draw_erase(&x->x_gui, glist); else if(mode == IEM_GUI_DRAW_MODE_CONFIG) hradio_draw_config(x, glist); else if(mode >= IEM_GUI_DRAW_MODE_IO) @@ -362,11 +317,7 @@ static void hradio_dialog(t_hradio *x, t_symbol *s, int argc, t_atom *argv) { hradio_draw_select(x, x->x_gui.x_glist); } - - // 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); + scrollbar_update(x->x_gui.x_glist); } static void hradio_set(t_hradio *x, t_floatarg f) diff --git a/pd/src/g_hslider.c b/pd/src/g_hslider.c index ed12172e7..8bfddaf20 100644 --- a/pd/src/g_hslider.c +++ b/pd/src/g_hslider.c @@ -38,42 +38,25 @@ static t_class *hslider_class; static void hslider_draw_update(t_gobj *client, t_glist *glist) { t_hslider *x = (t_hslider *)client; - if (x->x_gui.x_changed == 0) return; - t_canvas *canvas=glist_getcanvas(glist); - int ypos=text_ypix(&x->x_gui.x_obj, glist); - - if (glist_isvisible(glist)) - { - int r = text_xpix(&x->x_gui.x_obj, glist) + 3 + (x->x_val + 50)/100; - sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", - canvas, x, r, ypos+2, - r, ypos + x->x_gui.x_h-2); - if(x->x_val == x->x_center) - { - if(!x->x_thick) - { - sys_vgui(".x%lx.c itemconfigure %lxKNOB -strokewidth 7\n", - canvas, x); - x->x_thick = 1; - } - } - else - { - if(x->x_thick) - { - sys_vgui(".x%lx.c itemconfigure %lxKNOB -strokewidth 3\n", - canvas, x); - x->x_thick = 0; - } - } - } + if (!x->x_gui.x_changed) return; x->x_gui.x_changed = 0; + if (!glist_isvisible(glist)) return; + t_canvas *canvas=glist_getcanvas(glist); + int y1=text_ypix(&x->x_gui.x_obj, glist); + int r = text_xpix(&x->x_gui.x_obj, glist) + 3 + (x->x_val + 50)/100; + sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", + canvas, x, r, y1+2, r, y1 + x->x_gui.x_h-2); + int t = x->x_thick; + x->x_thick = x->x_val == x->x_center; + if (t!=x->x_thick) + sys_vgui(".x%lx.c itemconfigure %lxKNOB -strokewidth %d\n", + canvas, x, 4*x->x_thick+3); } static void hslider_draw_io(t_hslider* x,t_glist* glist, int old_snd_rcv_flags) { t_canvas *canvas=glist_getcanvas(glist); - iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags,"HSLDR"); + iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags); } static void hslider_draw_new(t_hslider *x, t_glist *glist) { @@ -82,95 +65,72 @@ static void hslider_draw_new(t_hslider *x, t_glist *glist) int r = xpos + 3 + (x->x_val + 50)/100; t_canvas *canvas=glist_getcanvas(glist); + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag); + scalehandle_draw_new(x->x_gui. x_handle,canvas); scalehandle_draw_new(x->x_gui.x_lhandle,canvas); - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_border) -fill #%6.6x " - "-tags {%lxBASE %lxHSLDR %s text iemgui border}\n", - canvas, xpos, ypos, - xpos + x->x_gui.x_w+5, ypos + x->x_gui.x_h, - x->x_gui.x_bcol, x, x, nlet_tag); - sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth 3 " - "-stroke #%6.6x -tags {%lxKNOB %lxHSLDR %s text iemgui}\n", - canvas, r, ypos+2, r, - ypos + x->x_gui.x_h-2, x->x_gui.x_fcol, x, x, nlet_tag); - iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag,"HSLDR"); + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_border) -fill #%6.6x " + "-tags {%lxBASE %lxOBJ %s text iemgui border}\n", + canvas, xpos, ypos, + xpos + x->x_gui.x_w+5, ypos + x->x_gui.x_h, + x->x_gui.x_bcol, x, x, nlet_tag); + sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth 3 " + "-stroke #%6.6x -tags {%lxKNOB %lxOBJ %s text iemgui}\n", + canvas, r, ypos+2, r, + ypos + x->x_gui.x_h-2, x->x_gui.x_fcol, x, x, nlet_tag); + iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag); hslider_draw_io(x,glist,7); } static void hslider_draw_move(t_hslider *x, t_glist *glist) { + t_canvas *canvas=glist_getcanvas(glist); + if (!glist_isvisible(canvas)) return; int xpos=text_xpix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist); int r = xpos + 3 + (x->x_val + 50)/100; - 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 %lxBASE %d %d %d %d\n", - canvas, x, - xpos, ypos, - xpos + x->x_gui.x_w+5, ypos + x->x_gui.x_h); - sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", - canvas, x, r, ypos+2, - r, ypos + x->x_gui.x_h-2); - iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); - if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxHSLDR%so%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, - xpos, ypos + x->x_gui.x_h-1, - xpos+7, ypos + x->x_gui.x_h); - if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxHSLDR%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, - xpos, ypos, - xpos+7, ypos+1); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_selected) - { - hslider_draw_select(x, x->x_gui.x_glist); - } - } + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + iemgui_base_draw_move(&x->x_gui, canvas, nlet_tag); + sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", + canvas, x, r, ypos+2, r, ypos + x->x_gui.x_h-2); + iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); + iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag); + if (x->x_gui.x_selected) hslider_draw_select(x, x->x_gui.x_glist); } static void hslider_draw_config(t_hslider* x,t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); iemgui_label_draw_config(&x->x_gui,canvas); - sys_vgui(".x%lx.c itemconfigure %lxKNOB " - "-stroke #%6.6x\n .x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", - canvas, x, x->x_gui.x_fcol, canvas, x, x->x_gui.x_bcol); + iemgui_base_draw_config(&x->x_gui,canvas); + sys_vgui(".x%lx.c itemconfigure %lxKNOB -stroke #%6.6x\n", + canvas, x, x->x_gui.x_fcol); } static void hslider_draw_select(t_hslider* x,t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); + iemgui_base_draw_config(&x->x_gui,canvas); if(x->x_gui.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)) { - sys_vgui(".x%lx.c itemconfigure %lxBASE " - "-stroke $pd_colors(selection)\n", canvas, x); - scalehandle_draw_select2(&x->x_gui,glist,"HSLDR", + scalehandle_draw_select2(&x->x_gui,glist, x->x_gui.x_w+5-1,x->x_gui.x_h-1); } } else { - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", - canvas, x, IEM_GUI_COLOR_NORMAL); scalehandle_draw_erase2(&x->x_gui,glist); } iemgui_label_draw_select(&x->x_gui,canvas); - iemgui_tag_selected(&x->x_gui,canvas,"HSLDR"); + iemgui_tag_selected(&x->x_gui,canvas); } void hslider_check_minmax(t_hslider *x, double min, double max); @@ -254,7 +214,7 @@ void hslider_draw(t_hslider *x, t_glist *glist, int mode) else if(mode == IEM_GUI_DRAW_MODE_SELECT) hslider_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) - iemgui_draw_erase(&x->x_gui, glist, "HSLDR"); + iemgui_draw_erase(&x->x_gui, glist); else if(mode == IEM_GUI_DRAW_MODE_CONFIG) hslider_draw_config(x, glist); else if(mode >= IEM_GUI_DRAW_MODE_IO) @@ -453,16 +413,8 @@ static void hslider_dialog(t_hslider *x, t_symbol *s, int argc, t_atom *argv) //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); - /* forcing redraw of the scale handle */ - if (x->x_gui.x_selected) - { - hslider_draw_select(x, x->x_gui.x_glist); - } - - // 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); + if (x->x_gui.x_selected) hslider_draw_select(x, x->x_gui.x_glist); + scrollbar_update(x->x_gui.x_glist); } static void hslider_motion(t_hslider *x, t_floatarg dx, t_floatarg dy) @@ -700,9 +652,7 @@ void g_hslider_setup(void) { hslider_class = class_new(gensym("hsl"), (t_newmethod)hslider_new, (t_method)hslider_free, sizeof(t_hslider), 0, A_GIMME, 0); -#ifndef GGEE_HSLIDER_COMPATIBLE class_addcreator((t_newmethod)hslider_new, gensym("hslider"), A_GIMME, 0); -#endif class_addbang(hslider_class,hslider_bang); class_addfloat(hslider_class,hslider_float); class_addmethod(hslider_class, (t_method)hslider_click, gensym("click"), diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c index d86061251..69bfe5257 100644 --- a/pd/src/g_mycanvas.c +++ b/pd/src/g_mycanvas.c @@ -47,40 +47,31 @@ void my_canvas_draw_new(t_my_canvas *x, t_glist *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", + "-tags {%lxRECT %lxOBJ %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", + "-tags {%lxBASE %lxOBJ %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); - iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag,"MYCNV"); + iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag); } void my_canvas_draw_move(t_my_canvas *x, t_glist *glist) { + t_canvas *canvas=glist_getcanvas(glist); + if (!glist_isvisible(canvas)) return; 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)) - { - - 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); - iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_selected) - { - my_canvas_draw_select(x, x->x_gui.x_glist); - } - } + 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); + iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); + if (x->x_gui.x_selected) my_canvas_draw_select(x, x->x_gui.x_glist); } void my_canvas_draw_config(t_my_canvas* x, t_glist* glist) @@ -109,20 +100,20 @@ void my_canvas_draw_select(t_my_canvas* x, t_glist* glist) { sys_vgui(".x%lx.c itemconfigure %lxBASE " "-stroke $pd_colors(selection)\n", canvas, x); - scalehandle_draw_select2(&x->x_gui,glist,"MYCNV", + scalehandle_draw_select2(&x->x_gui,glist, x->x_vis_w,x->x_vis_h); } - sys_vgui(".x%lx.c addtag selected withtag %lxMYCNV\n", canvas, x); + sys_vgui(".x%lx.c addtag selected withtag %lxOBJ\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(".x%lx.c dtag %lxOBJ selected\n", canvas, x); scalehandle_draw_erase2(&x->x_gui,glist); } iemgui_label_draw_select(&x->x_gui,canvas); - iemgui_tag_selected(&x->x_gui,canvas,"MYCNV"); + iemgui_tag_selected(&x->x_gui,canvas); } static void my_canvas__clickhook(t_scalehandle *sh, t_floatarg f, @@ -202,7 +193,7 @@ void my_canvas_draw(t_my_canvas *x, t_glist *glist, int mode) else if(mode == IEM_GUI_DRAW_MODE_SELECT) my_canvas_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) - iemgui_draw_erase(&x->x_gui, glist, "MYCNV"); + iemgui_draw_erase(&x->x_gui, glist); else if(mode == IEM_GUI_DRAW_MODE_CONFIG) my_canvas_draw_config(x, glist); } @@ -306,16 +297,8 @@ static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); - /* forcing redraw of the scale handle */ - if (x->x_gui.x_selected) - { - my_canvas_draw_select(x, x->x_gui.x_glist); - } - - //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); + if (x->x_gui.x_selected) my_canvas_draw_select(x, x->x_gui.x_glist); + scrollbar_update(x->x_gui.x_glist); } static void my_canvas_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av) diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c index 53edd0be2..6c46a6845 100644 --- a/pd/src/g_numbox.c +++ b/pd/src/g_numbox.c @@ -27,9 +27,6 @@ extern int gfxstub_haveproperties(void *key); static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist); -/*------------------ global varaibles -------------------------*/ - - /*------------------ global functions -------------------------*/ static void my_numbox_key(void *z, t_floatarg fkey); @@ -138,206 +135,111 @@ 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) return; + x->x_gui.x_changed = 0; + if (!glist_isvisible(glist)) return; + if(x->x_gui.x_change && x->x_buf[0]) + { + char *cp=x->x_buf; + int sl = strlen(x->x_buf); + x->x_buf[sl] = '>'; + x->x_buf[sl+1] = 0; + 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", + glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, cp); + x->x_buf[sl] = 0; } - if (glist_isvisible(glist)) + else { - if(x->x_gui.x_change) - { - if(x->x_buf[0]) - { - char *cp=x->x_buf; - int sl = strlen(x->x_buf); - - x->x_buf[sl] = '>'; - x->x_buf[sl+1] = 0; - 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", - glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, cp); - x->x_buf[sl] = 0; - } - else - { - my_numbox_ftoa(x); - sys_vgui( - ".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_selected) - sprintf(color, "$pd_colors(selection)"); - else - sprintf(color, "#%6.6x", x->x_gui.x_fcol); - - my_numbox_ftoa(x); - sys_vgui( - ".x%lx.c itemconfigure %lxNUMBER -fill %s -text {%s} \n", - glist_getcanvas(glist), x, - color, - x->x_buf); - x->x_buf[0] = 0; - } + char fcol[8]; sprintf(fcol, "#%6.6x", + x->x_gui.x_change ? IEM_GUI_COLOR_EDITED : x->x_gui.x_fcol); + my_numbox_ftoa(x); + sys_vgui( + ".x%lx.c itemconfigure %lxNUMBER -fill %s -text {%s} \n", + glist_getcanvas(glist), x, + x->x_gui.x_selected && !x->x_gui.x_change ? selection_color : fcol, x->x_buf); + x->x_buf[0] = 0; } - x->x_gui.x_changed = 0; } static void my_numbox_draw_io(t_my_numbox* x,t_glist* glist, int old_snd_rcv_flags) { t_canvas *canvas=glist_getcanvas(glist); - iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags,"NUM"); + iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags); } static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist) { int half=x->x_gui.x_h/2, d=1+x->x_gui.x_h/34; - int xpos=text_xpix(&x->x_gui.x_obj, glist); - int ypos=text_ypix(&x->x_gui.x_obj, glist); + int x1=text_xpix(&x->x_gui.x_obj, glist), x2=x1+x->x_numwidth; + int y1=text_ypix(&x->x_gui.x_obj, glist), y2=y1+x->x_gui.x_h; t_canvas *canvas=glist_getcanvas(glist); + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); scalehandle_draw_new(x->x_gui. x_handle,canvas); scalehandle_draw_new(x->x_gui.x_lhandle,canvas); + char bcol[8]; sprintf(bcol, "#%6.6x", x->x_gui.x_bcol); - //if (glist_isvisible(canvas)) { + sys_vgui( + ".x%lx.c create ppolygon %d %d %d %d %d %d %d %d %d %d -stroke %s" + " -fill %s -tags {%lxBASE1 %lxOBJ %s text iemgui border}\n", + canvas, x1, y1, x2-4, y1, x2, y1+4, x2, y2, x1, y2, + x->x_hide_frame <= 1 ? IEM_GUI_COLOR_NORMAL : bcol, + bcol, x, x, nlet_tag); - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + if (x->x_hide_frame <= 1) my_numbox_draw_io(x,glist,7); - 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); - my_numbox_draw_io(x,glist,7); - } - 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, + "-tags {%lxBASE2 %lxOBJ %s text iemgui}\n", + canvas, x1, y1, x1 + half, y1 + half, x1, y2, x->x_gui.x_fcol, x, x, nlet_tag); - iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag,"NUM"); + iemgui_label_draw_new(&x->x_gui,canvas,x1,y1,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, + "-tags {%lxNUMBER %lxOBJ %s noscroll text iemgui}\n", + canvas, x1+half+2, y1+half+d, x->x_buf, iemgui_font(&x->x_gui), 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) { - int half = x->x_gui.x_h/2, d=1+x->x_gui.x_h/34; - 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)) - { - - 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(!iemgui_has_snd(&x->x_gui) && 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(!iemgui_has_rcv(&x->x_gui) && 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); - iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); - 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_selected) - my_numbox_draw_select(x, x->x_gui.x_glist); - } + if (!glist_isvisible(canvas)) return; + int half = x->x_gui.x_h/2, d=1+x->x_gui.x_h/34; + int x1=text_xpix(&x->x_gui.x_obj, glist), x2=x1+x->x_numwidth; + int y1=text_ypix(&x->x_gui.x_obj, glist), y2=y1+x->x_gui.x_h; + + 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, x1, y1, x2-4, y1, x2, y1+4, x2, y2, x1, y2); + if (x->x_hide_frame <= 1) + iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag); + 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, x1, y1, x1 + half, y1 + half, x1, y2); + iemgui_label_draw_move(&x->x_gui,canvas,x1,y1); + sys_vgui(".x%lx.c coords %lxNUMBER %d %d\n", + canvas, x, x1+half+2, y1+half+d); + if (x->x_gui.x_selected) my_numbox_draw_select(x, x->x_gui.x_glist); } static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - if (x->x_gui.x_selected && x->x_gui.x_glist == canvas) - { - sys_vgui(".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, iemgui_font(&x->x_gui), - 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, iemgui_font(&x->x_gui), - 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 %lxNUMBER -font {{%s} -%d %s} " - "-fill #%6.6x \n .x%lx.c itemconfigure %lxBASE2 " - "-stroke #%6.6x\n", - canvas, iemgui_font(&x->x_gui), - 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, iemgui_font(&x->x_gui), - 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 fcol[8]; sprintf(fcol, "%6.6x", x->x_gui.x_fcol); + int issel = x->x_gui.x_selected && x->x_gui.x_glist == canvas; + sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font {{%s} %d %s} " + "-fill %s\n", + canvas, x, iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, + issel ? selection_color : fcol); + sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill %s\n", + canvas, x, issel ? selection_color : fcol); - } iemgui_label_draw_config(&x->x_gui,canvas); sys_vgui(".x%lx.c itemconfigure %lxBASE1 -fill #%6.6x;\n", canvas, x, x->x_gui.x_bcol); @@ -346,44 +248,29 @@ static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist) static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.x_selected) + int issel = x->x_gui.x_selected && x->x_gui.x_glist == canvas; + if(x->x_gui.x_selected && x->x_gui.x_change) { - if(x->x_gui.x_change) - { - x->x_gui.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)) - { - sys_vgui(".x%lx.c itemconfigure {%lxBASE1||%lxBASE2} " - "-stroke $pd_colors(selection)\n", canvas, x, x); - sys_vgui(".x%lx.c itemconfigure %lxNUMBER " - "-fill $pd_colors(selection)\n", canvas, x); - scalehandle_draw_select2(&x->x_gui,glist,"NUM", - x->x_numwidth-1,x->x_gui.x_h-1); - } + x->x_gui.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); } + char fcol[8]; sprintf(fcol, "#%6.6x", x->x_gui.x_fcol); + char bcol[8]; sprintf(bcol, "#%6.6x", x->x_gui.x_bcol); + sys_vgui(".x%lx.c itemconfigure %lxBASE1 -stroke %s\n", canvas, x, + issel ? selection_color : x->x_hide_frame <= 1 ? IEM_GUI_COLOR_NORMAL : bcol); + sys_vgui(".x%lx.c itemconfigure %lxBASE2 -stroke %s\n", canvas, x, + issel ? selection_color : fcol); + sys_vgui(".x%lx.c itemconfigure %lxNUMBER -fill %s\n", canvas, x, + issel ? selection_color : fcol); + if(issel) + scalehandle_draw_select2(&x->x_gui,glist, + x->x_numwidth-1,x->x_gui.x_h-1); else - { - 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 %lxNUMBER -fill #%6.6x\n", - canvas, x, x->x_gui.x_fcol); scalehandle_draw_erase2(&x->x_gui,glist); - } iemgui_label_draw_select(&x->x_gui,canvas); - iemgui_tag_selected(&x->x_gui,canvas,"NUM"); + iemgui_tag_selected(&x->x_gui,canvas); } static void my_numbox__clickhook(t_scalehandle *sh, t_floatarg f, @@ -495,7 +382,7 @@ void my_numbox_draw(t_my_numbox *x, t_glist *glist, int mode) else if(mode == IEM_GUI_DRAW_MODE_SELECT) my_numbox_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) - iemgui_draw_erase(&x->x_gui, glist, "NUM"); + iemgui_draw_erase(&x->x_gui, glist); else if(mode == IEM_GUI_DRAW_MODE_CONFIG) my_numbox_draw_config(x, glist); else if(mode >= IEM_GUI_DRAW_MODE_IO) @@ -673,19 +560,11 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc, canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); - /* forcing redraw of the scale handle */ - if (x->x_gui.x_selected) - { - my_numbox_draw_select(x, x->x_gui.x_glist); - } + if (x->x_gui.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); - - //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); + scrollbar_update(x->x_gui.x_glist); } static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy) @@ -820,22 +699,6 @@ static void my_numbox_range(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) } } -static void my_numbox_label_font(t_my_numbox *x, - t_symbol *s, int ac, t_atom *av) -{ - int f = (int)atom_getintarg(1, ac, av); - - if(f < 4) - f = 4; - x->x_gui.x_fontsize = f; - f = (int)atom_getintarg(0, ac, av); - if((f < 0) || (f > 2)) - f = 0; - x->x_gui.x_font_style = f; - x->x_numwidth = my_numbox_calc_fontwidth(x); - iemgui_label_font(&x->x_gui, s, ac, av); -} - static void my_numbox_log(t_my_numbox *x) { x->x_lin0_log1 = 1; diff --git a/pd/src/g_toggle.c b/pd/src/g_toggle.c index 5e9683f99..e3f749087 100644 --- a/pd/src/g_toggle.c +++ b/pd/src/g_toggle.c @@ -57,128 +57,79 @@ void toggle_draw_update(t_gobj *xgobj, t_glist *glist) void toggle_draw_io(t_toggle* x, t_glist* glist, int old_snd_rcv_flags) { t_canvas *canvas=glist_getcanvas(glist); - iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags,"TGL"); + iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags); } void toggle_draw_new(t_toggle *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), - yy=text_ypix(&x->x_gui.x_obj, glist); - + int w=(x->x_gui.x_w+29)/30; + int x1=text_xpix(&x->x_gui.x_obj, glist); + int y1=text_ypix(&x->x_gui.x_obj, glist); + int x2=x1+x->x_gui.x_w, y2=y1+x->x_gui.x_h; + int col = (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol; scalehandle_draw_new(x->x_gui. x_handle,canvas); scalehandle_draw_new(x->x_gui.x_lhandle,canvas); - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - if(x->x_gui.x_w >= 30) - w = 2; - if(x->x_gui.x_w >= 60) - w = 3; - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_border) -fill #%6.6x " - "-tags {%lxBASE %lxTGL %s text iemgui border}\n", - canvas, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h, - x->x_gui.x_bcol, x, x, nlet_tag); - sys_vgui(".x%lx.c create polyline %d %d %d %d " - "-strokewidth %d -stroke #%6.6x " - "-tags {%lxX1 %lxTGL %s text iemgui}\n", - canvas, xx+w+1, yy+w+1, - xx + x->x_gui.x_w-w-1, yy + x->x_gui.x_h-w-1, w, - (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x, x, - nlet_tag); - sys_vgui(".x%lx.c create polyline %d %d %d %d " - "-strokewidth %d -stroke #%6.6x " - "-tags {%lxX2 %lxTGL %s text iemgui}\n", - canvas, xx+w+1, yy + x->x_gui.x_h-w-1, - xx + x->x_gui.x_w-w-1, yy+w+1, w, - (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x, x, nlet_tag); - iemgui_label_draw_new(&x->x_gui,canvas,xx,yy,nlet_tag,"TGL"); + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag); + sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth %d " + "-stroke #%6.6x -tags {%lxX1 %lxOBJ %s text iemgui}\n", + canvas, x1+w+1, y1+w+1, x2-w-1, y2-w-1, w, col, x, x, nlet_tag); + sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth %d " + "-stroke #%6.6x -tags {%lxX2 %lxOBJ %s text iemgui}\n", + canvas, x1+w+1, y2-w-1, x2-w-1, y1+w+1, w, col, x, x, nlet_tag); + iemgui_label_draw_new(&x->x_gui,canvas,x1,y1,nlet_tag); toggle_draw_io(x,glist,7); } void toggle_draw_move(t_toggle *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), - yy=text_ypix(&x->x_gui.x_obj, glist); - - if (glist_isvisible(canvas)) - { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - if(x->x_gui.x_w >= 30) - w = 2; - - if(x->x_gui.x_w >= 60) - w = 3; - sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", - canvas, x, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h); - sys_vgui(".x%lx.c itemconfigure %lxX1 -strokewidth %d\n", canvas, x, w); - sys_vgui(".x%lx.c coords %lxX1 %d %d %d %d\n", - canvas, x, xx+w+1, yy+w+1, - xx + x->x_gui.x_w-w-1, yy + x->x_gui.x_h-w-1); - sys_vgui(".x%lx.c itemconfigure %lxX2 -strokewidth %d\n", canvas, x, w); - sys_vgui(".x%lx.c coords %lxX2 %d %d %d %d\n", - canvas, x, xx+w+1, - yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w-1, yy+w+1); - iemgui_label_draw_move(&x->x_gui,canvas,xx,yy); - if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxTGL%so%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xx, - yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h); - if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxTGL%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xx, yy, xx + IOWIDTH, yy+1); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_selected) - toggle_draw_select(x, x->x_gui.x_glist); - } + if (!glist_isvisible(canvas)) return; + int w=(x->x_gui.x_w+29)/30, s=w+1; + int x1=text_xpix(&x->x_gui.x_obj, glist), x2=x1+x->x_gui.x_w; + int y1=text_ypix(&x->x_gui.x_obj, glist), y2=y1+x->x_gui.x_h; + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + iemgui_base_draw_move(&x->x_gui, canvas, nlet_tag); + sys_vgui(".x%lx.c itemconfigure {%lxX1||%lxX2} -strokewidth %d\n", canvas, x, x, w); + sys_vgui(".x%lx.c coords %lxX1 %d %d %d %d\n", + canvas, x, x1+s, y1+s, x2-s, y2-s); + sys_vgui(".x%lx.c coords %lxX2 %d %d %d %d\n", + canvas, x, x1+s, y2-s, x2-s, y1+s); + iemgui_label_draw_move(&x->x_gui,canvas,x1,y1); + iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag); + if (x->x_gui.x_selected) toggle_draw_select(x, x->x_gui.x_glist); } void toggle_draw_config(t_toggle* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); iemgui_label_draw_config(&x->x_gui,canvas); - sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n " - ".x%lx.c itemconfigure %lxX1 -stroke #%6.6x\n " - ".x%lx.c itemconfigure %lxX2 -stroke #%6.6x\n", - canvas, x, x->x_gui.x_bcol , canvas, x, - x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol, canvas, x, - x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); - /* - sys_vgui(".x%lx.c itemconfigure %lxX1 -fill #%6.6x\n", canvas, x, - x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); - sys_vgui(".x%lx.c itemconfigure %lxX2 -fill #%6.6x\n", canvas, x, - x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); - */ + iemgui_base_draw_config(&x->x_gui,canvas); + sys_vgui(".x%lx.c itemconfigure {%lxX1||%lX2} -fill #%6.6x\n", + canvas, x, x, x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); } void toggle_draw_select(t_toggle* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); + iemgui_base_draw_config(&x->x_gui,canvas); if(x->x_gui.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)) { - sys_vgui(".x%lx.c itemconfigure %lxBASE " - "-stroke $pd_colors(selection)\n", canvas, x); - scalehandle_draw_select2(&x->x_gui,glist,"TGL", + scalehandle_draw_select2(&x->x_gui,glist, x->x_gui.x_w-1,x->x_gui.x_h-1); } } else { - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", - canvas, x, IEM_GUI_COLOR_NORMAL); scalehandle_draw_erase2(&x->x_gui,glist); } iemgui_label_draw_select(&x->x_gui,canvas); - iemgui_tag_selected(&x->x_gui,canvas,"TGL"); + iemgui_tag_selected(&x->x_gui,canvas); } static void toggle__clickhook(t_scalehandle *sh, t_floatarg f, @@ -253,7 +204,7 @@ void toggle_draw(t_toggle *x, t_glist *glist, int mode) else if(mode == IEM_GUI_DRAW_MODE_SELECT) toggle_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) - iemgui_draw_erase(&x->x_gui, glist, "TGL"); + iemgui_draw_erase(&x->x_gui, glist); else if(mode == IEM_GUI_DRAW_MODE_CONFIG) toggle_draw_config(x, glist); else if(mode >= IEM_GUI_DRAW_MODE_IO) @@ -352,16 +303,8 @@ static void toggle_dialog(t_toggle *x, t_symbol *s, int argc, t_atom *argv) //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); - /* forcing redraw of the scale handle */ - if (x->x_gui.x_selected) - { - toggle_draw_select(x, x->x_gui.x_glist); - } - - //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); + if (x->x_gui.x_selected) toggle_draw_select(x, x->x_gui.x_glist); + scrollbar_update(x->x_gui.x_glist); } static void toggle_click(t_toggle *x, t_floatarg xpos, t_floatarg ypos, diff --git a/pd/src/g_vdial.c b/pd/src/g_vdial.c index e79a51c7c..076cd224e 100644 --- a/pd/src/g_vdial.c +++ b/pd/src/g_vdial.c @@ -3,6 +3,7 @@ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ /* vdial.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ +/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ /* name change to vradio by MSP (it's a radio button really) and changed to put out a "float" as in sliders, toggles, etc. */ @@ -20,14 +21,6 @@ put out a "float" as in sliders, toggles, etc. */ extern int gfxstub_haveproperties(void *key); void vradio_draw_select(t_vradio* x, t_glist* glist); -/*------------------ global variables -------------------------*/ - - -/*------------------ global functions -------------------------*/ - - - - /* ------------- vdl gui-vertical radio button ---------------------- */ t_widgetbehavior vradio_widgetbehavior; @@ -38,101 +31,72 @@ static t_class *vradio_class, *vradio_old_class; void vradio_draw_update(t_gobj *client, t_glist *glist) { t_hradio *x = (t_hradio *)client; - if(glist_isvisible(glist)) - { - t_canvas *canvas=glist_getcanvas(glist); - - sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", - canvas, x, x->x_drawn, - x->x_gui.x_bcol, x->x_gui.x_bcol); - sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", - canvas, x, x->x_on, - x->x_gui.x_fcol, x->x_gui.x_fcol); - x->x_drawn = x->x_on; - } + if(!glist_isvisible(glist)) return; + t_canvas *canvas=glist_getcanvas(glist); + sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", + canvas, x, x->x_drawn, x->x_gui.x_bcol, x->x_gui.x_bcol); + sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", + canvas, x, x->x_on, x->x_gui.x_fcol, x->x_gui.x_fcol); + x->x_drawn = x->x_on; } void vradio_draw_io(t_vradio* x, t_glist* glist, int old_snd_rcv_flags) { t_canvas *canvas=glist_getcanvas(glist); - iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags,"VRDO"); + iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags); } void vradio_draw_new(t_vradio *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4; - int yy11b=text_ypix(&x->x_gui.x_obj, glist); - int yy11=yy11b, yy12=yy11+dy; - int yy21=yy11+s4, yy22=yy12-s4; - int xx11=text_xpix(&x->x_gui.x_obj, glist), xx12=xx11+dy; - int xx21=xx11+s4, xx22=xx12-s4; + int n=x->x_number, i, d=x->x_gui.x_w, s=d/4; + int x1=text_xpix(&x->x_gui.x_obj, glist); + int y1=text_ypix(&x->x_gui.x_obj, glist), yi=y1; + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag); scalehandle_draw_new(x->x_gui. x_handle,canvas); scalehandle_draw_new(x->x_gui.x_lhandle,canvas); - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - for(i=0; i<n; i++) - { - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_border) -fill #%6.6x " - "-tags {%lxBASE%d %lxBASE %lxVRDO %s text iemgui border}\n", - canvas, xx11, yy11, xx12, yy12, - x->x_gui.x_bcol, x, i, x, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x " - "-stroke #%6.6x -tags {%lxBUT%d %lxVRDO %s text iemgui}\n", - canvas, xx21, yy21, xx22, yy22, - (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, - (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, - x, i, x, nlet_tag); - yy11 += dy; - yy12 += dy; - yy21 += dy; - yy22 += dy; - x->x_drawn = x->x_on; - } - iemgui_label_draw_new(&x->x_gui,canvas,xx11,yy11b,nlet_tag,"VRDO"); + for(i=0; i<n; i++) + { + if (i) sys_vgui(".x%lx.c create pline %d %d %d %d " + "-stroke $pd_colors(iemgui_border) " + "-tags {%lxBASE%d %lxBASEL %lxOBJ %s text iemgui border}\n", + canvas, x1, yi, x1+d, yi, x, i, x, x, nlet_tag); + sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x " + "-stroke #%6.6x -tags {%lxBUT%d %lxOBJ %s text iemgui}\n", + canvas, x1+s, yi+s, x1+d-s, yi+d-s, + (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, + (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, + x, i, x, nlet_tag); + yi += d; + x->x_drawn = x->x_on; + } + iemgui_label_draw_new(&x->x_gui,canvas,x1,y1,nlet_tag); vradio_draw_io(x,glist,7); } void vradio_draw_move(t_vradio *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4; - int yy11b=text_ypix(&x->x_gui.x_obj, glist); - int yy11=yy11b, yy12=yy11+dy; - int yy21=yy11+s4, yy22=yy12-s4; - int xx11=text_xpix(&x->x_gui.x_obj, glist), xx12=xx11+dy; - int xx21=xx11+s4, xx22=xx12-s4; - - if (glist_isvisible(canvas)) - { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + if (!glist_isvisible(canvas)) return; + int n=x->x_number, i, d=x->x_gui.x_w, s=d/4; + int x1=text_xpix(&x->x_gui.x_obj, glist); + int y1=text_ypix(&x->x_gui.x_obj, glist), yi=y1; - for(i=0; i<n; i++) - { - sys_vgui(".x%lx.c coords %lxBASE%d %d %d %d %d\n", - canvas, x, i, xx11, yy11, xx12, yy12); - sys_vgui(".x%lx.c coords %lxBUT%d %d %d %d %d\n", - canvas, x, i, xx21, yy21, xx22, yy22); - yy11 += dy; - yy12 += dy; - yy21 += dy; - yy22 += dy; - } - iemgui_label_draw_move(&x->x_gui,canvas,xx11,yy11b); - if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxVRDO%so%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xx11, yy11-1, xx11 + IOWIDTH, yy11); - if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxVRDO%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xx11, yy11b, xx11 + IOWIDTH, yy11b+1); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_selected) - vradio_draw_select(x, x->x_gui.x_glist); + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + for(i=0; i<n; i++) + { + sys_vgui(".x%lx.c coords %lxBASE%d %d %d %d %d\n", + canvas, x, i, x1, yi, x1+d, yi); + sys_vgui(".x%lx.c coords %lxBUT%d %d %d %d %d\n", + canvas, x, i, x1+s, yi+s, x1+d-s, yi+d-s); + yi += d; } + iemgui_label_draw_move(&x->x_gui,canvas,x1,y1); + iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag); + if (x->x_gui.x_selected) vradio_draw_select(x, x->x_gui.x_glist); } void vradio_draw_config(t_vradio* x, t_glist* glist) @@ -140,48 +104,36 @@ void vradio_draw_config(t_vradio* x, t_glist* glist) t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i; iemgui_label_draw_config(&x->x_gui,canvas); + iemgui_base_draw_config(&x->x_gui,canvas); for(i=0; i<n; i++) { - sys_vgui(".x%lx.c itemconfigure %lxBASE%d " - "-fill #%6.6x\n " - ".x%lx.c itemconfigure %lxBUT%d " - "-fill #%6.6x -stroke #%6.6x\n", - canvas, x, i, - x->x_gui.x_bcol, - canvas, x, i, - (x->x_on==i) ? x->x_gui.x_fcol : x->x_gui.x_bcol, - (x->x_on==i) ? x->x_gui.x_fcol : x->x_gui.x_bcol); - /*sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x " - "-outline #%6.6x\n", canvas, x, i, - (x->x_on==i) ? x->x_gui.x_fcol : x->x_gui.x_bcol, - (x->x_on==i) ? x->x_gui.x_fcol : x->x_gui.x_bcol); - */ + sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", + canvas, x, i, + (x->x_on==i) ? x->x_gui.x_fcol : x->x_gui.x_bcol, + (x->x_on==i) ? x->x_gui.x_fcol : x->x_gui.x_bcol); } } void vradio_draw_select(t_vradio* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); + iemgui_base_draw_config(&x->x_gui,canvas); if(x->x_gui.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)) { - sys_vgui(".x%lx.c itemconfigure %lxBASE " - "-stroke $pd_colors(selection)\n", canvas, x); - scalehandle_draw_select2(&x->x_gui,glist,"VRDO", + scalehandle_draw_select2(&x->x_gui,glist, x->x_gui.x_w-1,x->x_gui.x_h*x->x_number-1); } } else { - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", - canvas, x, IEM_GUI_COLOR_NORMAL); scalehandle_draw_erase2(&x->x_gui,glist); } iemgui_label_draw_select(&x->x_gui,canvas); - iemgui_tag_selected(&x->x_gui,canvas,"VRDO"); + iemgui_tag_selected(&x->x_gui,canvas); } static void vradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, @@ -255,7 +207,7 @@ void vradio_draw(t_vradio *x, t_glist *glist, int mode) else if(mode == IEM_GUI_DRAW_MODE_SELECT) vradio_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) - iemgui_draw_erase(&x->x_gui, glist, "VRDO"); + iemgui_draw_erase(&x->x_gui, glist); else if(mode == IEM_GUI_DRAW_MODE_CONFIG) vradio_draw_config(x, glist); else if(mode >= IEM_GUI_DRAW_MODE_IO) @@ -362,17 +314,8 @@ static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv) //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); } - - /* forcing redraw of the scale handle */ - if (x->x_gui.x_selected) - { - vradio_draw_select(x, x->x_gui.x_glist); - } - - /* 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); + if (x->x_gui.x_selected) vradio_draw_select(x, x->x_gui.x_glist); + scrollbar_update(x->x_gui.x_glist); } static void vradio_set(t_vradio *x, t_floatarg f) diff --git a/pd/src/g_vslider.c b/pd/src/g_vslider.c index ae35292a0..069726540 100644 --- a/pd/src/g_vslider.c +++ b/pd/src/g_vslider.c @@ -38,44 +38,25 @@ static t_class *vslider_class; static void vslider_draw_update(t_gobj *client, t_glist *glist) { t_vslider *x = (t_vslider *)client; - if (x->x_gui.x_changed == 0) return; - t_canvas *canvas=glist_getcanvas(glist); - if (glist_isvisible(glist)) - { - int r = text_ypix(&x->x_gui.x_obj, glist) + 2 + x->x_gui.x_h - (x->x_val + 50)/100; - int xpos=text_xpix(&x->x_gui.x_obj, glist); - - sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", - canvas, x, xpos+2, r, - xpos + x->x_gui.x_w-2, r); - if(x->x_val == x->x_center) - { - if(!x->x_thick) - { - sys_vgui(".x%lx.c itemconfigure %lxKNOB " - "-strokewidth 7\n", - canvas, x); - x->x_thick = 1; - } - } - else - { - if(x->x_thick) - { - sys_vgui(".x%lx.c itemconfigure %lxKNOB " - "-strokewidth 3\n", - canvas, x); - x->x_thick = 0; - } - } - } + if (!x->x_gui.x_changed) return; x->x_gui.x_changed = 0; + t_canvas *canvas=glist_getcanvas(glist); + if (!glist_isvisible(glist)) return; + int r = text_ypix(&x->x_gui.x_obj, glist) + 2 + x->x_gui.x_h - (x->x_val + 50)/100; + int x1=text_xpix(&x->x_gui.x_obj, glist), x2=x1+x->x_gui.x_w; + sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", + canvas, x, x1+2, r, x2-2, r); + int t = x->x_thick; + x->x_thick = x->x_val == x->x_center; + if (t!=x->x_thick) + sys_vgui(".x%lx.c itemconfigure %lxKNOB -strokewidth %d\n", + canvas, x, 4*x->x_thick+3); } static void vslider_draw_io(t_vslider* x,t_glist* glist, int old_snd_rcv_flags) { t_canvas *canvas=glist_getcanvas(glist); - iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags,"VSLDR"); + iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags); } static void vslider_draw_new(t_vslider *x, t_glist *glist) @@ -85,97 +66,66 @@ static void vslider_draw_new(t_vslider *x, t_glist *glist) int r = ypos + 2 + x->x_gui.x_h - (x->x_val + 50)/100; t_canvas *canvas=glist_getcanvas(glist); + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag); scalehandle_draw_new(x->x_gui. x_handle,canvas); scalehandle_draw_new(x->x_gui.x_lhandle,canvas); - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_border) -fill #%6.6x " - "-tags {%lxBASE %lxVSLDR %s text iemgui border}\n", - canvas, xpos, ypos, - xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+5, - x->x_gui.x_bcol, x, x, nlet_tag); - sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth 3 " - "-stroke #%6.6x -tags {%lxKNOB %lxVSLDR %s text iemgui}\n", - canvas, xpos+2, r, - xpos + x->x_gui.x_w-2, r, x->x_gui.x_fcol, x, x, nlet_tag); - iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag,"VSLDR"); + sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth 3 " + "-stroke #%6.6x -tags {%lxKNOB %lxOBJ %s text iemgui}\n", + canvas, xpos+2, r, + xpos + x->x_gui.x_w-2, r, x->x_gui.x_fcol, x, x, nlet_tag); + iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag); vslider_draw_io(x,glist,7); } static void vslider_draw_move(t_vslider *x, t_glist *glist) { + t_canvas *canvas=glist_getcanvas(glist); + if (!glist_isvisible(canvas)) return; int xpos=text_xpix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist); int r = ypos + 2 + x->x_gui.x_h - (x->x_val + 50)/100; - 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 %lxBASE %d %d %d %d\n", - canvas, x, - xpos, ypos, - xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+5); - sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", - canvas, x, xpos+2, r, - xpos + x->x_gui.x_w-2, r); - iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); - if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxVSLDR%so%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, - xpos, ypos + x->x_gui.x_h+4, - xpos+7, ypos + x->x_gui.x_h+5); - if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxVSLDR%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, - xpos, ypos, - xpos+7, ypos+1); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_selected) - { - vslider_draw_select(x, x->x_gui.x_glist); - } - } + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + 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+5); + sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", + canvas, x, xpos+2, r, xpos + x->x_gui.x_w-2, r); + iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); + iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag); + if (x->x_gui.x_selected) vslider_draw_select(x, x->x_gui.x_glist); } static void vslider_draw_config(t_vslider* x,t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); iemgui_label_draw_config(&x->x_gui,canvas); - sys_vgui(".x%lx.c itemconfigure %lxKNOB " - "-stroke #%6.6x\n .x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", - canvas, x, x->x_gui.x_fcol, canvas, x, x->x_gui.x_bcol); - /*sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, - x, x->x_gui.x_bcol);*/ + iemgui_base_draw_config(&x->x_gui,canvas); + sys_vgui(".x%lx.c itemconfigure %lxKNOB -stroke #%6.6x\n", + canvas, x, x->x_gui.x_fcol); } static void vslider_draw_select(t_vslider *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); + iemgui_base_draw_config(&x->x_gui,canvas); if(x->x_gui.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)) { - sys_vgui(".x%lx.c itemconfigure %lxBASE " - "-stroke $pd_colors(selection)\n", canvas, x); - scalehandle_draw_select2(&x->x_gui,glist,"VSLDR", + scalehandle_draw_select2(&x->x_gui,glist, x->x_gui.x_w-1,x->x_gui.x_h+5-1); } } else { - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", - canvas, x, IEM_GUI_COLOR_NORMAL); scalehandle_draw_erase2(&x->x_gui,glist); } iemgui_label_draw_select(&x->x_gui,canvas); - iemgui_tag_selected(&x->x_gui,canvas,"VSLDR"); + iemgui_tag_selected(&x->x_gui,canvas); } void vslider_check_minmax(t_vslider *x, double min, double max); @@ -258,7 +208,7 @@ void vslider_draw(t_vslider *x, t_glist *glist, int mode) else if(mode == IEM_GUI_DRAW_MODE_SELECT) vslider_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) - iemgui_draw_erase(&x->x_gui, glist, "VSLDR"); + iemgui_draw_erase(&x->x_gui, glist); else if(mode == IEM_GUI_DRAW_MODE_CONFIG) vslider_draw_config(x, glist); else if(mode >= IEM_GUI_DRAW_MODE_IO) @@ -427,16 +377,8 @@ static void vslider_dialog(t_vslider *x, t_symbol *s, int argc, t_atom *argv) //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); - /* forcing redraw of the scale handle */ - if (x->x_gui.x_selected) - { - vslider_draw_select(x, x->x_gui.x_glist); - } - - // 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); + if (x->x_gui.x_selected) vslider_draw_select(x, x->x_gui.x_glist); + scrollbar_update(x->x_gui.x_glist); } static void vslider_motion(t_vslider *x, t_floatarg dx, t_floatarg dy) diff --git a/pd/src/g_vumeter.c b/pd/src/g_vumeter.c index 0a7fbd2ec..bfce538ec 100644 --- a/pd/src/g_vumeter.c +++ b/pd/src/g_vumeter.c @@ -81,7 +81,7 @@ void vu_check_height(t_vu *x, int h); /* ----- vu gui-peak- & rms- vu-meter-display ---------- */ t_widgetbehavior vu_widgetbehavior; -static t_class *vu_class; +t_class *vu_class; /* widget helper functions */ @@ -145,328 +145,145 @@ static void vu_draw_update(t_gobj *client, t_glist *glist) x->x_updatepeak = 0; } } - + +void vu_draw_io(t_vu *x, t_glist* glist, int old_snd_rcv_flags) +{ + t_canvas *canvas=glist_getcanvas(glist); + iemgui_io_draw(&x->x_gui,canvas,old_snd_rcv_flags); +} static void vu_draw_new(t_vu *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - int xpos=text_xpix(&x->x_gui.x_obj, glist); - int ypos=text_ypix(&x->x_gui.x_obj, glist); - int w4=x->x_gui.x_w/4, mid=xpos+x->x_gui.x_w/2, - quad1=xpos+w4+1; - int quad3=xpos+x->x_gui.x_w-w4, - end=xpos+x->x_gui.x_w+4; + int x1=text_xpix(&x->x_gui.x_obj, glist); + int y1=text_ypix(&x->x_gui.x_obj, glist); + int w4=x->x_gui.x_w/4, mid=x1+x->x_gui.x_w/2, + quad1=x1+w4+1; + int quad3=x1+x->x_gui.x_w-w4, + end=x1+x->x_gui.x_w+4; int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2; - int led_col, yyy, i, k4=ypos-k3; + int led_col, yyy, i, k4=y1-k3; + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag); scalehandle_draw_new(x->x_gui. x_handle,canvas); scalehandle_draw_new(x->x_gui.x_lhandle,canvas); - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_border) -fill #%6.6x " - "-tags {%lxBASE %lxVU %s text iemgui border}\n", - canvas, xpos, ypos, xpos+x->x_gui.x_w+2, - ypos+x->x_gui.x_h+4, x->x_gui.x_bcol, x, x, nlet_tag); - for(i = 1; i <= IEM_VU_STEPS; i++) - { - led_col = iemgui_vu_col[i]; - yyy = k4 + k1 * (k2-i); - sys_vgui(".x%lx.c create polyline %d %d %d %d " - "-strokewidth %d -stroke #%6.6x " - "-tags {%lxRLED%d %lxVU %s text iemgui}\n", - canvas, quad1+1, yyy+2, quad3, yyy+2, - x->x_led_size, iemgui_color_hex[led_col], x, i, x, nlet_tag); - if(((i+2) & 3) && (x->x_scale)) - sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " - "-font {{%s} -%d %s} -fill #%6.6x " - "-tags {%lxSCALE%d %lxVU %s text iemgui}\n", - canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], - iemgui_font(&x->x_gui), x->x_gui.x_fontsize, - sys_fontweight, x->x_gui.x_lcol, x, i, x, nlet_tag); - } - if(x->x_scale) - { - i=IEM_VU_STEPS+1; - yyy = k4 + k1*(k2-i); + for(i = 1; i <= IEM_VU_STEPS+1; i++) + { + yyy = k4 + k1 * (k2-i); + if(((i+2) & 3) && (x->x_scale)) sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " - "-font {{%s} -%d %s} -fill #%6.6x " - "-tags {%lxSCALE%d %lxVU %s text iemgui}\n", - canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], - iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x, i, x, nlet_tag); - } - sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x " - "-stroke #%6.6x -tags {%lxRCOVER %lxVU %s text iemgui}\n", - canvas, quad1+1, ypos+1, quad3, - ypos+1 + k1*IEM_VU_STEPS, x->x_gui.x_bcol, x->x_gui.x_bcol, - x, x, nlet_tag); - sys_vgui(".x%lx.c create polyline %d %d %d %d " - "-strokewidth %d -fill #%6.6x " - "-tags {%lxPLED %lxVU %s text iemgui}\n", - canvas, mid+1, ypos+12, - mid+1, ypos+12, x->x_led_size, x->x_gui.x_bcol, x, x, nlet_tag); - iemgui_label_draw_new(&x->x_gui,canvas,xpos,ypos,nlet_tag,"VU"); - if (!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) - { - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_nlet) " - "-tags {%lxVU%so%d %so%d %lxVU %s outlet iemgui}\n", - canvas, - xpos, ypos + x->x_gui.x_h+3, - xpos + IOWIDTH, ypos + x->x_gui.x_h+4, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_nlet) " - "-tags {%lxVU%so%d %so%d %lxVU %s outlet iemgui}\n", - canvas, - xpos+x->x_gui.x_w+2-IOWIDTH, ypos + x->x_gui.x_h+3, - xpos+x->x_gui.x_w+2, ypos + x->x_gui.x_h+4, - x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); - } - if (!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) - { - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_nlet) " - "-tags {%lxVU%si%d %si%d %lxVU %s inlet iemgui}\n", - canvas, - xpos, ypos, - xpos + IOWIDTH, ypos+1, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_nlet) " - "-tags {%lxVU%si%d %si%d %lxVU %s inlet iemgui}\n", - canvas, - xpos+x->x_gui.x_w+2-IOWIDTH, ypos, - xpos+x->x_gui.x_w+2, ypos+1, - x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); - } - x->x_updaterms = x->x_updatepeak = 1; - sys_queuegui(x, x->x_gui.x_glist, vu_draw_update); - //} + "-font {{%s} -%d %s} -fill #%6.6x " + "-tags {%lxSCALEN %lxSCALE%d %lxOBJ %s text iemgui}\n", + canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], + iemgui_font(&x->x_gui), x->x_gui.x_fontsize, + sys_fontweight, x->x_gui.x_lcol, x, x, i, x, nlet_tag); + + led_col = iemgui_vu_col[i]; + if (i<=IEM_VU_STEPS) sys_vgui(".x%lx.c create polyline %d %d %d %d " + "-strokewidth %d -stroke #%6.6x " + "-tags {%lxRLED%d %lxOBJ %s text iemgui}\n", + canvas, quad1+1, yyy+2, quad3, yyy+2, + x->x_led_size, iemgui_color_hex[led_col], x, i, x, nlet_tag); + } + sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x " + "-stroke #%6.6x -tags {%lxRCOVER %lxOBJ %s text iemgui}\n", + canvas, quad1+1, y1+1, quad3, y1+1 + k1*IEM_VU_STEPS, + x->x_gui.x_bcol, x->x_gui.x_bcol, x, x, nlet_tag); + sys_vgui(".x%lx.c create polyline %d %d %d %d " + "-strokewidth %d -fill #%6.6x " + "-tags {%lxPLED %lxOBJ %s text iemgui}\n", + canvas, mid+1, y1+12, + mid+1, y1+12, x->x_led_size, x->x_gui.x_bcol, x, x, nlet_tag); + iemgui_label_draw_new(&x->x_gui,canvas,x1,y1,nlet_tag); + vu_draw_io(x,glist,7); + x->x_updaterms = x->x_updatepeak = 1; + sys_queuegui(x, x->x_gui.x_glist, vu_draw_update); } static void vu_draw_move(t_vu *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); + if (!glist_isvisible(canvas)) return; - if (glist_isvisible(canvas)) + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + int xpos=text_xpix(&x->x_gui.x_obj, glist); + int ypos=text_ypix(&x->x_gui.x_obj, glist); + int w4=x->x_gui.x_w/4, quad1=xpos+w4+1; + int quad3=xpos+x->x_gui.x_w-w4, + end=xpos+x->x_gui.x_w+4; + int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2; + int yyy, i, k4=ypos-k3; + sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", + canvas, x, xpos, ypos, xpos+x->x_gui.x_w+2,ypos+x->x_gui.x_h+4); + for(i=1; i<=IEM_VU_STEPS; i++) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - int xpos=text_xpix(&x->x_gui.x_obj, glist); - int ypos=text_ypix(&x->x_gui.x_obj, glist); - int w4=x->x_gui.x_w/4, quad1=xpos+w4+1; - int quad3=xpos+x->x_gui.x_w-w4, - end=xpos+x->x_gui.x_w+4; - int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2; - int yyy, i, k4=ypos-k3; - - sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", - canvas, x, xpos, ypos, - xpos+x->x_gui.x_w+2,ypos+x->x_gui.x_h+4); - for(i=1; i<=IEM_VU_STEPS; i++) - { - yyy = k4 + k1*(k2-i); - sys_vgui(".x%lx.c coords %lxRLED%d %d %d %d %d\n", - canvas, x, i, quad1+1, yyy+2, quad3, yyy+2); - if(((i+2)&3) && (x->x_scale)) - sys_vgui(".x%lx.c coords %lxSCALE%d %d %d\n", - canvas, x, i, end+1, yyy+k3+2); - } - if(x->x_scale) - { - i=IEM_VU_STEPS+1; - yyy = k4 + k1*(k2-i); + yyy = k4 + k1*(k2-i); + sys_vgui(".x%lx.c coords %lxRLED%d %d %d %d %d\n", + canvas, x, i, quad1+1, yyy+2, quad3, yyy+2); + if(((i+2)&3) && (x->x_scale)) sys_vgui(".x%lx.c coords %lxSCALE%d %d %d\n", - canvas, x, i, end+1, yyy+k3+2); - } - x->x_updaterms = x->x_updatepeak = 1; - sys_queuegui(x, glist, vu_draw_update); - iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); - if(!iemgui_has_snd(&x->x_gui) && canvas == x->x_gui.x_glist) - { - sys_vgui(".x%lx.c coords %lxVU%so%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, - xpos, ypos + x->x_gui.x_h+3, - xpos + IOWIDTH, ypos + x->x_gui.x_h+4); - sys_vgui(".x%lx.c coords %lxVU%so%d %d %d %d %d\n", - canvas, x, nlet_tag, 1, - xpos+x->x_gui.x_w+2-IOWIDTH, ypos + x->x_gui.x_h+3, - xpos+x->x_gui.x_w+2, ypos + x->x_gui.x_h+4); - } - if(!iemgui_has_rcv(&x->x_gui) && canvas == x->x_gui.x_glist) - { - sys_vgui(".x%lx.c coords %lxVU%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, - xpos, ypos, - xpos + IOWIDTH, ypos+1); - sys_vgui(".x%lx.c coords %lxVU%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 1, - xpos+x->x_gui.x_w+2-IOWIDTH, ypos, - xpos+x->x_gui.x_w+2, ypos+1); - } - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_selected) - vu_draw_select(x, x->x_gui.x_glist); - } -} - -static void vu_draw_config(t_vu* x, t_glist* glist) -{ - int i; - t_canvas *canvas=glist_getcanvas(glist); - for(i = 1; i <= IEM_VU_STEPS; i++) - { - sys_vgui(".x%lx.c itemconfigure %lxRLED%d -strokewidth %d\n", - canvas, x, i, x->x_led_size); - if(((i + 2) & 3) && (x->x_scale)) - if (x->x_gui.x_selected) - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " - "-font {{%s} -%d %s} -fill $pd_colors(selection)\n", - canvas, x, i, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), - x->x_gui.x_fontsize, sys_fontweight); - else - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " - "-font {{%s} -%d %s} -fill #%6.6x\n", - canvas, x, i, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), - x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol); + canvas, x, i, end+1, yyy+k3+2); } if(x->x_scale) { - i = IEM_VU_STEPS + 1; - if (x->x_gui.x_selected) - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " - "-font {{%s} -%d %s} -fill $pd_colors(selection)\n", - canvas, x, i, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), - x->x_gui.x_fontsize, sys_fontweight); - else - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " - "-font {{%s} -%d %s} -fill #%6.6x\n", - canvas, x, i, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), - x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol); + i=IEM_VU_STEPS+1; + yyy = k4 + k1*(k2-i); + sys_vgui(".x%lx.c coords %lxSCALE%d %d %d\n", + canvas, x, i, end+1, yyy+k3+2); } - iemgui_label_draw_config(&x->x_gui,canvas); - sys_vgui(".x%lx.c itemconfigure %lxRCOVER -fill #%6.6x -stroke #%6.6x\n" - ".x%lx.c itemconfigure %lxPLED -strokewidth %d\n" - ".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", - canvas, x, x->x_gui.x_bcol, x->x_gui.x_bcol, - canvas, x, x->x_led_size, - canvas, x, x->x_gui.x_bcol); + x->x_updaterms = x->x_updatepeak = 1; + sys_queuegui(x, glist, vu_draw_update); + iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos); + iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag); + if (x->x_gui.x_selected) vu_draw_select(x, x->x_gui.x_glist); } -static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags) +static void vu_draw_config(t_vu* x, t_glist* glist) { - int xpos=text_xpix(&x->x_gui.x_obj, glist); - int ypos=text_ypix(&x->x_gui.x_obj, glist); + int i; t_canvas *canvas=glist_getcanvas(glist); - - if (glist_isvisible(canvas) && canvas == x->x_gui.x_glist) + char lcol[8]; sprintf(lcol, "%6.6x", x->x_gui.x_lcol); + for(i = 1; i <= IEM_VU_STEPS+1; i++) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - if ((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && - !iemgui_has_snd(&x->x_gui)) - { - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_nlet) " - "-tags {%lxVU%so%d %so%d %lxVU %s outlet}\n", - canvas, xpos, ypos + x->x_gui.x_h+3, xpos + IOWIDTH, - ypos + x->x_gui.x_h+4, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-stroke $pd_colors(iemgui_nlet) " - "-tags {%lxVU%so%d %so%d %lxVU %s outlet}\n", - canvas, - xpos+x->x_gui.x_w+2-IOWIDTH, ypos + x->x_gui.x_h+3, - xpos+x->x_gui.x_w+2, ypos + x->x_gui.x_h+4, - x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); - } - if (!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && - iemgui_has_snd(&x->x_gui)) - { - sys_vgui(".x%lx.c delete %lxVU%so%d\n", canvas, x, nlet_tag, 0); - sys_vgui(".x%lx.c delete %lxVU%so%d\n", canvas, x, nlet_tag, 1); - } - if ((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && - !iemgui_has_rcv(&x->x_gui)) - { - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-tags {%lxVU%si%d %si%d %lxVU %s outlet}\n", - canvas, - xpos, ypos, - xpos + IOWIDTH, ypos+1, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d " - "-tags {%lxVU%si%d %si%d %lxVU %s outlet}\n", - canvas, - xpos+x->x_gui.x_w+2-IOWIDTH, ypos, - xpos+x->x_gui.x_w+2, ypos+1, - x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); - } - if (!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && - iemgui_has_rcv(&x->x_gui)) - { - sys_vgui(".x%lx.c delete %lxVU%si%d\n", canvas, x, nlet_tag, 0); - sys_vgui(".x%lx.c delete %lxVU%si%d\n", canvas, x, nlet_tag, 1); - } + if (i <= IEM_VU_STEPS) + sys_vgui(".x%lx.c itemconfigure %lxRLED%d -strokewidth %d\n", + canvas, x, i, x->x_led_size); + sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " + "-font {{%s} -%d %s} -fill %s\n", + canvas, x, i, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), + x->x_gui.x_fontsize, sys_fontweight, + ((i + 2) & 3) && (x->x_scale) ? selection_color : lcol); } + iemgui_label_draw_config(&x->x_gui,canvas); + sys_vgui(".x%lx.c itemconfigure %lxRCOVER -fill #%6.6x -stroke #%6.6x\n", + canvas, x, x->x_gui.x_bcol, x->x_gui.x_bcol); + sys_vgui(".x%lx.c itemconfigure %lxPLED -strokewidth %d\n", + canvas, x, x->x_led_size); + iemgui_base_draw_config(&x->x_gui,canvas); } static void vu_draw_select(t_vu* x,t_glist* glist) { int i; t_canvas *canvas=glist_getcanvas(glist); - if(x->x_gui.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)) - { - sys_vgui(".x%lx.c itemconfigure %lxBASE " - "-stroke $pd_colors(selection)\n", canvas, x); - for(i = 1; i <= IEM_VU_STEPS; i++) - { - if(((i + 2) & 3) && (x->x_scale)) - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d " - "-fill $pd_colors(selection)\n", canvas, x, i); - } - if(x->x_scale) - { - i=IEM_VU_STEPS+1; - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d " - "-fill $pd_colors(selection)\n", canvas, x, i); - } - scalehandle_draw_select2(&x->x_gui,glist,"VU", - x->x_gui.x_w+2-1,x->x_gui.x_h+4-1); - } + iemgui_base_draw_config(&x->x_gui,canvas); + char lcol[8]; sprintf(lcol,"#%6.6x", x->x_gui.x_lcol); + int issel = x->x_gui.x_selected && x->x_gui.x_glist==canvas; + sys_vgui(".x%lx.c itemconfigure %lxSCALEN " + "-fill %s\n", canvas, x, issel ? selection_color : lcol); + if(issel) { + scalehandle_draw_select2(&x->x_gui,glist, + x->x_gui.x_w+2-1,x->x_gui.x_h+4-1); } else { - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", - canvas, x, IEM_GUI_COLOR_NORMAL); - for(i = 1; i <= IEM_VU_STEPS; i++) - { - if(((i + 2) & 3) && (x->x_scale)) - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill #%6.6x\n", - canvas, x, i, x->x_gui.x_lcol); - } - if(x->x_scale) - { - i = IEM_VU_STEPS + 1; - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill #%6.6x\n", - canvas, x, i, x->x_gui.x_lcol); - } scalehandle_draw_erase2(&x->x_gui,glist); } iemgui_label_draw_select(&x->x_gui,canvas); - iemgui_tag_selected(&x->x_gui,canvas,"VU"); + iemgui_tag_selected(&x->x_gui,canvas); } static void vu__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, @@ -545,7 +362,7 @@ void vu_draw(t_vu *x, t_glist *glist, int mode) else if(mode == IEM_GUI_DRAW_MODE_SELECT) vu_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) - iemgui_draw_erase(&x->x_gui, glist, "VU"); + iemgui_draw_erase(&x->x_gui, glist); else if(mode == IEM_GUI_DRAW_MODE_CONFIG) vu_draw_config(x, glist); else if(mode >= IEM_GUI_DRAW_MODE_IO) @@ -653,9 +470,9 @@ static void vu_getrect(t_gobj *z, t_glist *glist, int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2, k4=ypos-k3; *xp1 = text_xpix(&x->x_gui.x_obj, glist); - *yp1 = text_ypix(&x->x_gui.x_obj, glist) + 2; + *yp1 = text_ypix(&x->x_gui.x_obj, glist); *xp2 = *xp1 + x->x_gui.x_w + 2; - *yp2 = *yp1 + x->x_gui.x_h + 2; + *yp2 = *yp1 + x->x_gui.x_h + 4; iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); @@ -733,7 +550,7 @@ static void vu_scale(t_vu *x, t_floatarg fscale) if((i + 2) & 3) sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " "-font {{%s} -%d %s} -fill #%6.6x " - "-tags {%lxSCALE%d %lxVU %lx}\n", + "-tags {%lxSCALE%d %lxOBJ %lx}\n", canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, i, x, x); @@ -742,7 +559,7 @@ static void vu_scale(t_vu *x, t_floatarg fscale) yyy = k4 + k1*(k2-i); sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " "-font {{%s} -%d %s} -fill #%6.6x " - "-tags {%lxSCALE%d %lxVU %lx}\n", + "-tags {%lxSCALE%d %lxOBJ %lx}\n", canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, i, x, x); @@ -801,16 +618,8 @@ static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv) //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE); - /* forcing redraw of the scale handle */ - if (x->x_gui.x_selected) - { - vu_draw_select(x, x->x_gui.x_glist); - } - - // 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); + if (x->x_gui.x_selected) vu_draw_select(x, x->x_gui.x_glist); + scrollbar_update(x->x_gui.x_glist); } static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av) @@ -916,6 +725,8 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.x_ldx = ldx; x->x_gui.x_ldy = ldy; + x->x_gui.x_snd = s_empty; + if(fs < 4) fs = 4; x->x_gui.x_fontsize = fs; -- GitLab