Re: [PD-dev] adding a built-in [change] object to the built-in GUI objects

2012-12-04 Thread Hans-Christoph Steiner

That's how I ended up implementing it, based on Jonathan's suggestion:
http://sourceforge.net/tracker/?func=detailaid=3591986group_id=55736atid=478072

.hc

On Dec 4, 2012, at 12:06 PM, Miller Puckette wrote:

 I'd suggest cacheing the pixel value, not the value value.  It's an easy
 fix and I can go through and do it while I'm waiting for other bugs to
 surface after trying to make all the 0.44-critical changes on the pile.
 (these are resolving my having broken the new build system in my 
 impoartation
 of portaudio, and also finally acting on the hip~ and inlet~ bugs.)
 
 cheers
 Miller
 
 On Fri, Nov 30, 2012 at 11:20:53PM -0500, Hans-Christoph Steiner wrote:
 
 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.
 
 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
 
 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


___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


[PD-dev] [ pure-data-Patches-2947822 ] space character in gui labels causes disaster

2012-12-04 Thread SourceForge . net
Patches item #2947822, was opened at 2010-02-08 05:12
Message generated for change (Comment added) made by eighthave
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=478072aid=2947822group_id=55736

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: puredata
Group: None
Status: Open
Resolution: Fixed
Priority: 5
Private: No
Submitted By: Matteo Sisti Sette (sistisette)
Assigned to: Miller Puckette (millerpuckette)
Summary: space character in gui labels causes disaster

Initial Comment:
Steps to reproduce:

1 - Open the attached patch

Note the size of the radio and toggle. Note also they have send symbols set 
to xxx and yyy respectively

2 - Click on the big bang at the top

This composes a symbol containing space characters and sends it as a label to 
both the radio and the toggle.

This seems to work: the label is actually set with spaces, and the radio and 
toggle still work.

However, if you right-click on any of them and try to select properties, the 
properties dialog won't open

3 - Now save the patch and close it

4 - Open the patch again. The radio and toggle properties have been completely 
reset: their size have been reset to default, and also the number property 
of the radio. They have lost their send symbol too: you can see the outlet 
and if you use them, the r objects won't receive anything.

However, if you open the properties dialog of the radio or toggle, you'll see 
that the send property is still there (not the same can be said for the size 
and number); if you now do Apply or Ok, the send symbol will be restored.


So, spaces in the label of a gui object cause weirdnesses and potential 
disaster. Note that data is lost (the properties of the gui objects) if the 
patch is saved after assigning such a label, and i is lost silently with no 
error message at any moment.

There are ather forbidden characters ithat don't behave properly n labels, 
such as the open square bracket [ (as reported in another bug report). 
However the space character is more disatrous as it causes data loss. 
Object should either accept ALL characters for a label, or properly detect and 
refuse forbidden characters, which should be documented, avoiding unexpected 
consequences.



--

Comment By: Hans-Christoph Steiner (eighthave)
Date: 2012-12-04 11:31

Message:
Patch #0001 should be applied regardless.  Its a simple fix that also
address having characters like  [ ] in labels.

As for patch #0002 , the iemguis also replace spaces with _ when you enter
the name in the Properies panel.  Symbols can have spaces, and you can set
the label with a [label symbol( message, so as IOhannes pointed out, the
missing piece of the puzzle is saving properly. Since patch #0002 makes Pd
write out the file format that is already supported, I think it would be
good to include it.

Then strnescape() will also have to change when we implement proper
escaping support throughout Pd.  Unless you have plans to implement that in
0.44, I think its definitely worth including incremental solutions like
patch #0002

--

Comment By: Miller Puckette (millerpuckette)
Date: 2012-12-03 19:27

Message:
Note the much simpler way the number box finesses this problem.  I'm
scared of adding
code to m_binbuf.c to escape spaces (what will happen when we later allow
backslashes
into the mix?).  But without the binbuf patch the fix to the IEM guis
doesn't work - so I'm
tempted for now just to do as in the number box - it's not incompatible to
do it right at
some ater date when we can thonk the whole thing through (it's all over the
Pd code and all
needs to be figured out together).

--

Comment By: IOhannes m zmölnig (zmoelnig)
Date: 2012-11-13 16:45

Message:
added another patch (0002_*) that implements escaping spaces and tabs when
saving the files to disk.

i  guess both patches should be applied for full fun.

--

Comment By: IOhannes m zmölnig (zmoelnig)
Date: 2012-11-13 15:36

Message:
the bug.pd file does not correctly show the labels with blanks after
reloading but it doesn't throw any warnings)

however, the bugfix-patch doesn't work for me.

nevertheless the problem is known and is not in the pd-gui communication,
but rather in the way the label is stored on disk (and then interpreted on
reload):  
afaict, blanks (and other special chars) really must be escaped with
backslash (e.g. A\ A\ A) when saved to disk

--

Comment By: Hans-Christoph Steiner (eighthave)
Date: 2012-11-13 12:52

Message:
the values were not quoted, so just quoting them with {} fixes it.