----- Original Message -----
From: Hans-Christoph Steiner hans@at.or.at To: "pd-dev@iem.at List" pd-dev@iem.at Cc: Sent: Friday, November 30, 2012 11:20 PM Subject: [PD-dev] adding a built-in [change] object to the built-in GUI objects
Lots of patches use the built-in GUI objects for displays, and often a fast stream of events is hooked straight up to the GUI object, causing the GUI object to send many pointless updates, like draw commands when the number hasn't changed, or multiple draw commands per screen refresh cycle.
The multiple draw commands per screen refresh cycle seems like the more common source of needless draw commands.
I propose to only send the GUI update commands when the relevant value has changed. I think this should apply to both the main element, like the slider knob, and the label for that GUI object, since that's often used as a display. The code change is pretty simple, but I was wondering if people thought there could be any problems caused by this
At the end of hslider_set, why not just check if x->x_value==(int)(100.0*g + 0.49999) before assigning it? If its already equal just return.
Here is the needed change, for example, for the hslider knob:
index b352fb9..88681fc 100644 --- a/src/g_all_guis.h +++ b/src/g_all_guis.h @@ -185,6 +185,7 @@ typedef struct _hslider t_iemgui x_gui; int x_pos; int x_val; + int x_prev_val; int x_center; int x_thick; int x_lin0_log1; index 470771a..e1a3c83 100644 --- a/src/g_hslider.c +++ b/src/g_hslider.c @@ -33,7 +33,7 @@ static t_class *hslider_class; static void hslider_draw_update(t_gobj *client, t_glist *glist) { t_hslider *x = (t_hslider *)client; - if (glist_isvisible(glist)) + if (glist_isvisible(glist) && x->x_val != x->x_prev_val) { int r = text_xpix(&x->x_gui.x_obj, glist) + (x->x_val + 50)/100; int ypos=text_ypix(&x->x_gui.x_obj, glist); @@ -57,6 +57,7 @@ static void hslider_draw_update(t_gobj *client, t_glist *glist) x->x_thick = 0; } } + x->x_prev_val = x->x_val; } }
Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev