From 38c855f181cc40302b7fcd21bd9681da35733e16 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Thu, 5 Sep 2013 19:41:31 -0400 Subject: [PATCH] revamped iemgui nlet color detection by embedding var in t_text --- pd/src/g_bang.c | 2 ++ pd/src/g_editor.c | 43 ++++++++++--------------------------------- pd/src/g_hdial.c | 2 ++ pd/src/g_hslider.c | 2 ++ pd/src/g_mycanvas.c | 2 ++ pd/src/g_numbox.c | 2 ++ pd/src/g_text.c | 6 ++++++ pd/src/g_toggle.c | 2 ++ pd/src/g_vdial.c | 2 ++ pd/src/g_vslider.c | 2 ++ pd/src/g_vumeter.c | 2 ++ 11 files changed, 34 insertions(+), 33 deletions(-) diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c index c65021543..b24add70b 100644 --- a/pd/src/g_bang.c +++ b/pd/src/g_bang.c @@ -906,6 +906,8 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.label_offset_y = 0; x->x_gui.label_vis = 0; + x->x_gui.x_obj.te_iemgui = 1; + return (x); } diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index a7d82c694..6815eeac9 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -102,33 +102,9 @@ static t_canvas *c_selection; /* iemgui uses black inlets and outlets while default objects use gray ones add here more as necessary */ -int gobj_filter_highlight_behavior(t_rtext *y) { +int gobj_filter_highlight_behavior(t_text *y) { - char *buf; - char name[4]; - int bufsize, i; - rtext_gettext(y, &buf, &bufsize); - if (bufsize > 3) bufsize = 3; - for (i = 0; i < bufsize; i++) { - name[i] = buf[i]; - } - name[i]='\0'; - //fprintf(stderr,"object name = >%s<\n", name); - if (!strcmp(name, "bng") || - !strcmp(name, "nbx") || - !strcmp(name, "hdl") || - !strcmp(name, "hsl") || - !strcmp(name, "tgl") || - !strcmp(name, "vdl") || - !strcmp(name, "vsl") || - !strcmp(name, "vu ") || - /* alternative names for hradio and vradio when invoked from the menu */ - !strcmp(name, "hra") || - !strcmp(name, "vra") - ) - return 1; - - return 0; + return (y->te_iemgui); } /* ---------------- generic widget behavior ------------------------- */ @@ -2967,7 +2943,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, } if (yr) { - last_outlet_filter = gobj_filter_highlight_behavior(yr); + last_outlet_filter = gobj_filter_highlight_behavior((t_text *)&ob->ob_g); //fprintf(stderr,"last_outlet_filter == %d\n", last_outlet_filter); sprintf(x->gl_editor->canvas_cnct_outlet_tag, "%so%d", @@ -3025,7 +3001,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, if (yr) { - last_inlet_filter = gobj_filter_highlight_behavior(yr); + last_inlet_filter = gobj_filter_highlight_behavior((t_text *)&ob->ob_g); //fprintf(stderr,"last_inlet_filter == %d\n", last_inlet_filter); sprintf(x->gl_editor->canvas_cnct_inlet_tag, "%si%d", @@ -3973,7 +3949,7 @@ void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit) } if (y) { - last_inlet_filter = gobj_filter_highlight_behavior(y); + last_inlet_filter = gobj_filter_highlight_behavior((t_text *)&ob2->ob_g); //fprintf(stderr,"last_inlet_filter == %d\n", last_inlet_filter); sprintf(x->gl_editor->canvas_cnct_inlet_tag, "%si%d", @@ -4251,7 +4227,7 @@ static void canvas_displaceselection(t_canvas *x, int dx, int dy) //fprintf(stderr,"canvas_displaceselection %d %d\n", dx, dy); t_selection *y; int resortin = 0, resortout = 0; - old_displace = 0; + //old_displace = 0; if (!we_are_undoing && !canvas_undo_already_set_move && x->gl_editor->e_selection) { //canvas_setundo(x, canvas_undo_move, canvas_undo_set_move(x, 1), @@ -4271,7 +4247,8 @@ static void canvas_displaceselection(t_canvas *x, int dx, int dy) else { /* we will move the non-conforming objects the old way */ gobj_displace(y->sel_what, x, dx, dy); - old_displace = 1; + canvas_restore_original_position(x, y->sel_what, 0, -1); + //old_displace = 1; //fprintf(stderr, "displaceselection\n"); } t_class *cl = pd_class(&y->sel_what->g_pd); @@ -4290,8 +4267,8 @@ static void canvas_displaceselection(t_canvas *x, int dx, int dy) // to proper ordering of objects as they have been redrawn on top // of everything else rather than where they were supposed to be // (e.g. possibly in the middle or at the bottom) - if (old_displace) canvas_redraw(x); - old_displace = 0; + //if (old_displace) canvas_redraw(x); + //old_displace = 0; } /* this routine is called whenever a key is pressed or released. "x" diff --git a/pd/src/g_hdial.c b/pd/src/g_hdial.c index c36fe2d60..6d20c884d 100644 --- a/pd/src/g_hdial.c +++ b/pd/src/g_hdial.c @@ -1001,6 +1001,8 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old) x->x_gui.label_offset_y = 0; x->x_gui.label_vis = 0; + x->x_gui.x_obj.te_iemgui = 1; + return (x); } diff --git a/pd/src/g_hslider.c b/pd/src/g_hslider.c index 046a42199..ab79164ec 100644 --- a/pd/src/g_hslider.c +++ b/pd/src/g_hslider.c @@ -1010,6 +1010,8 @@ static void *hslider_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.label_offset_y = 0; x->x_gui.label_vis = 0; + x->x_gui.x_obj.te_iemgui = 1; + return (x); } diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c index cef020264..089b57562 100644 --- a/pd/src/g_mycanvas.c +++ b/pd/src/g_mycanvas.c @@ -699,6 +699,8 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.label_offset_y = 0; x->x_gui.label_vis = 0; + x->x_gui.x_obj.te_iemgui = 1; + return (x); } diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c index 7fc023269..ad488065e 100644 --- a/pd/src/g_numbox.c +++ b/pd/src/g_numbox.c @@ -1320,6 +1320,8 @@ static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv) x->x_scaleheight = 0; x->x_tmpfontsize = 0; + x->x_gui.x_obj.te_iemgui = 1; + return (x); } diff --git a/pd/src/g_text.c b/pd/src/g_text.c index 92da3b82c..005d91bff 100644 --- a/pd/src/g_text.c +++ b/pd/src/g_text.c @@ -56,6 +56,7 @@ void glist_text(t_glist *gl, t_symbol *s, int argc, t_atom *argv) t_atom at; x->te_width = 0; /* don't know it yet. */ x->te_type = T_TEXT; + x->te_iemgui = 0; x->te_binbuf = binbuf_new(); if (argc > 1) { @@ -168,6 +169,9 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix, int selected, x->te_ypix = ypix; x->te_width = 0; x->te_type = T_OBJECT; + /* let's see if iemgui objects did not already set the value to 1, otherwise set it explicitly to 0 */ + if (x->te_iemgui != 1) + x->te_iemgui = 0; glist_add(gl, &x->te_g); if (selected) @@ -640,6 +644,7 @@ void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv) x->m_messresponder.mr_outlet = outlet_new(&x->m_text, &s_float); x->m_text.te_width = 0; /* don't know it yet. */ x->m_text.te_type = T_MESSAGE; + x->m_text.te_iemgui = 0; x->m_text.te_binbuf = binbuf_new(); x->m_glist = gl; x->m_clock = clock_new(x, (t_method)message_tick); @@ -1093,6 +1098,7 @@ void canvas_atom(t_glist *gl, t_atomtype type, t_atom at; x->a_text.te_width = 0; /* don't know it yet. */ x->a_text.te_type = T_ATOM; + x->a_text.te_iemgui = 0; x->a_text.te_binbuf = binbuf_new(); x->a_glist = gl; x->a_atom.a_type = type; diff --git a/pd/src/g_toggle.c b/pd/src/g_toggle.c index 691de9314..ce54bb479 100644 --- a/pd/src/g_toggle.c +++ b/pd/src/g_toggle.c @@ -837,6 +837,8 @@ static void *toggle_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.label_offset_y = 0; x->x_gui.label_vis = 0; + x->x_gui.x_obj.te_iemgui = 1; + return (x); } diff --git a/pd/src/g_vdial.c b/pd/src/g_vdial.c index c4321f864..d6e1b5a17 100644 --- a/pd/src/g_vdial.c +++ b/pd/src/g_vdial.c @@ -1005,6 +1005,8 @@ static void *vradio_donew(t_symbol *s, int argc, t_atom *argv, int old) x->x_gui.label_offset_y = 0; x->x_gui.label_vis = 0; + x->x_gui.x_obj.te_iemgui = 1; + return (x); } diff --git a/pd/src/g_vslider.c b/pd/src/g_vslider.c index b1a4e8729..b1df04342 100644 --- a/pd/src/g_vslider.c +++ b/pd/src/g_vslider.c @@ -999,6 +999,8 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.label_offset_y = 0; x->x_gui.label_vis = 0; + x->x_gui.x_obj.te_iemgui = 1; + return (x); } diff --git a/pd/src/g_vumeter.c b/pd/src/g_vumeter.c index c09ad7388..d8e898651 100644 --- a/pd/src/g_vumeter.c +++ b/pd/src/g_vumeter.c @@ -1181,6 +1181,8 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.label_offset_y = 0; x->x_gui.label_vis = 0; + x->x_gui.x_obj.te_iemgui = 1; + return (x); } -- GitLab