fixed execution order bug that was causing the first two frame numbers to output...
[puredata.git] / packages / patches / fix_max.pat_exporting-0.41.4.patch
blob5da90baafcf3fa3a1150a53043aca58eef038e91
1 --- branches/pd-extended/0.41/pd/src/m_binbuf.c 2009/01/24 05:10:36 10609
2 +++ branches/pd-extended/0.41/pd/src/m_binbuf.c 2009/02/12 01:09:11 10760
3 @@ -952,14 +952,15 @@
4 t_binbuf *newb = binbuf_new();
5 t_atom *vec = oldb->b_vec;
6 t_int n = oldb->b_n, nextindex, stackdepth = 0, stack[MAXSTACK],
7 - nobj = 0, i;
8 + nobj = 0, i, gotfontsize = 0;
9 t_atom outmess[MAXSTACK], *nextmess;
10 + t_float fontsize = 10;
11 if (!maxtopd)
12 binbuf_addv(newb, "ss;", gensym("max"), gensym("v2"));
13 for (nextindex = 0; nextindex < n; )
15 int endmess, natom;
16 - char *first, *second;
17 + char *first, *second, *third;
18 for (endmess = nextindex; endmess < n && vec[endmess].a_type != A_SEMI;
19 endmess++)
21 @@ -1146,11 +1147,49 @@
23 else if (!strcmp(second, "user"))
25 - binbuf_addv(newb, "ssffs;",
26 - gensym("#X"), gensym("obj"),
27 - atom_getfloatarg(3, natom, nextmess),
28 - atom_getfloatarg(4, natom, nextmess),
29 - atom_getsymbolarg(2, natom, nextmess));
30 + third = (nextmess+2)->a_w.w_symbol->s_name;
31 + if (!strcmp(third, "hslider"))
32 + {
33 + t_float range = atom_getfloatarg(7, natom, nextmess);
34 + t_float multiplier = atom_getfloatarg(8, natom, nextmess);
35 + t_float offset = atom_getfloatarg(9, natom, nextmess);
36 + binbuf_addv(newb, "ssffsffffffsssfffffffff;",
37 + gensym("#X"), gensym("obj"),
38 + atom_getfloatarg(3, natom, nextmess),
39 + atom_getfloatarg(4, natom, nextmess),
40 + gensym("hsl"),
41 + atom_getfloatarg(6, natom, nextmess),
42 + atom_getfloatarg(5, natom, nextmess),
43 + offset,
44 + range + offset,
45 + 0., 0.,
46 + gensym("empty"), gensym("empty"), gensym("empty"),
47 + 0., -8., 0., 8., -262144., -1., -1., 0., 1.);
48 + }
49 + else if (!strcmp(third, "uslider"))
50 + {
51 + t_float range = atom_getfloatarg(7, natom, nextmess);
52 + t_float multiplier = atom_getfloatarg(8, natom, nextmess);
53 + t_float offset = atom_getfloatarg(9, natom, nextmess);
54 + binbuf_addv(newb, "ssffsffffffsssfffffffff;",
55 + gensym("#X"), gensym("obj"),
56 + atom_getfloatarg(3, natom, nextmess),
57 + atom_getfloatarg(4, natom, nextmess),
58 + gensym("vsl"),
59 + atom_getfloatarg(5, natom, nextmess),
60 + atom_getfloatarg(6, natom, nextmess),
61 + offset,
62 + range + offset,
63 + 0., 0.,
64 + gensym("empty"), gensym("empty"), gensym("empty"),
65 + 0., -8., 0., 8., -262144., -1., -1., 0., 1.);
66 + }
67 + else
68 + binbuf_addv(newb, "ssffs;",
69 + gensym("#X"), gensym("obj"),
70 + atom_getfloatarg(3, natom, nextmess),
71 + atom_getfloatarg(4, natom, nextmess),
72 + atom_getsymbolarg(2, natom, nextmess));
73 nobj++;
75 else if (!strcmp(second, "connect")||
76 @@ -1179,12 +1218,17 @@
77 stack[stackdepth] = nobj;
78 stackdepth++;
79 nobj = 0;
80 + if(!gotfontsize) { /* only the first canvas sets the font size */
81 + fontsize = atom_getfloatarg(6, natom, nextmess);
82 + gotfontsize = 1;
83 + }
84 + t_float x = atom_getfloatarg(2, natom, nextmess);
85 + t_float y = atom_getfloatarg(3, natom, nextmess);
86 binbuf_addv(newb, "ssffff;",
87 gensym("#N"), gensym("vpatcher"),
88 - atom_getfloatarg(2, natom, nextmess),
89 - atom_getfloatarg(3, natom, nextmess),
90 - atom_getfloatarg(4, natom, nextmess),
91 - atom_getfloatarg(5, natom, nextmess));
92 + x, y,
93 + atom_getfloatarg(4, natom, nextmess) + x,
94 + atom_getfloatarg(5, natom, nextmess) + y);
97 if (!strcmp(first, "#X"))
98 @@ -1193,12 +1237,17 @@
99 && (ISSYMBOL (&nextmess[4], "pd")))
101 binbuf_addv(newb, "ss;", gensym("#P"), gensym("pop"));
102 - binbuf_addv(newb, "ssffffss;",
103 - gensym("#P"), gensym("newobj"),
104 - atom_getfloatarg(2, natom, nextmess),
105 - atom_getfloatarg(3, natom, nextmess), 50., 1.,
106 - gensym("patcher"),
107 - atom_getsymbolarg(5, natom, nextmess));
108 + SETSYMBOL(outmess, gensym("#P"));
109 + SETSYMBOL(outmess + 1, gensym("newobj"));
110 + outmess[2] = nextmess[2];
111 + outmess[3] = nextmess[3];
112 + SETFLOAT(outmess + 4, 50.*(natom-5));
113 + SETFLOAT(outmess + 5, fontsize);
114 + SETSYMBOL(outmess + 6, gensym("p"));
115 + for (i = 5; i < natom; i++)
116 + outmess[i+2] = nextmess[i];
117 + SETSEMI(outmess + natom + 2);
118 + binbuf_add(newb, natom + 3, outmess);
119 if (stackdepth) stackdepth--;
120 nobj = stack[stackdepth];
121 nobj++;
122 @@ -1212,25 +1261,25 @@
123 gensym("inlet"),
124 atom_getfloatarg(2, natom, nextmess),
125 atom_getfloatarg(3, natom, nextmess),
126 - 15.);
127 + 10. + fontsize);
128 else if (classname == gensym("inlet~"))
129 binbuf_addv(newb, "ssffff;", gensym("#P"),
130 gensym("inlet"),
131 atom_getfloatarg(2, natom, nextmess),
132 atom_getfloatarg(3, natom, nextmess),
133 - 15., 1.);
134 + 10. + fontsize, 1.);
135 else if (classname == gensym("outlet"))
136 binbuf_addv(newb, "ssfff;", gensym("#P"),
137 gensym("outlet"),
138 atom_getfloatarg(2, natom, nextmess),
139 atom_getfloatarg(3, natom, nextmess),
140 - 15.);
141 + 10. + fontsize);
142 else if (classname == gensym("outlet~"))
143 binbuf_addv(newb, "ssffff;", gensym("#P"),
144 gensym("outlet"),
145 atom_getfloatarg(2, natom, nextmess),
146 atom_getfloatarg(3, natom, nextmess),
147 - 15., 1.);
148 + 10. + fontsize, 1.);
149 else if (classname == gensym("bng"))
150 binbuf_addv(newb, "ssffff;", gensym("#P"),
151 gensym("button"),
152 @@ -1255,16 +1304,65 @@
153 (atom_getfloatarg(6, natom, nextmess) == 1? 1 :
154 atom_getfloatarg(6, natom, nextmess) - 1),
155 atom_getfloatarg(7, natom, nextmess));
156 + else if (classname == gensym("hsl"))
158 + t_float slmin = atom_getfloatarg(7, natom, nextmess);
159 + t_float slmax = atom_getfloatarg(8, natom, nextmess);
160 + binbuf_addv(newb, "sssffffffff;", gensym("#P"),
161 + gensym("user"),
162 + gensym("hslider"),
163 + atom_getfloatarg(2, natom, nextmess),
164 + atom_getfloatarg(3, natom, nextmess),
165 + atom_getfloatarg(6, natom, nextmess),
166 + atom_getfloatarg(5, natom, nextmess),
167 + slmax - slmin + 1, /* range */
168 + 1., /* multiplier */
169 + slmin, /* offset */
170 + 0.);
172 + else if ( (classname == gensym("trigger")) ||
173 + (classname == gensym("t")) )
175 + SETSYMBOL(outmess, gensym("#P"));
176 + SETSYMBOL(outmess + 1, gensym("newex"));
177 + outmess[2] = nextmess[2];
178 + outmess[3] = nextmess[3];
179 + SETFLOAT(outmess + 4, 50.*(natom-4));
180 + SETFLOAT(outmess + 5, fontsize);
181 + outmess[6] = nextmess[4];
182 + t_symbol *arg;
183 + for (i = 5; i < natom; i++) {
184 + arg = atom_getsymbolarg(i, natom, nextmess);
185 + if (arg == gensym("a"))
186 + SETSYMBOL(outmess + i + 2, gensym("l"));
187 + else if (arg == gensym("anything"))
188 + SETSYMBOL(outmess + i + 2, gensym("l"));
189 + else if (arg == gensym("bang"))
190 + SETSYMBOL(outmess + i + 2, gensym("b"));
191 + else if (arg == gensym("float"))
192 + SETSYMBOL(outmess + i + 2, gensym("f"));
193 + else if (arg == gensym("list"))
194 + SETSYMBOL(outmess + i + 2, gensym("l"));
195 + else if (arg == gensym("symbol"))
196 + SETSYMBOL(outmess + i + 2, gensym("s"));
197 + else
198 + outmess[i+2] = nextmess[i];
200 + SETSEMI(outmess + natom + 2);
201 + binbuf_add(newb, natom + 3, outmess);
203 else
205 SETSYMBOL(outmess, gensym("#P"));
206 SETSYMBOL(outmess + 1, gensym("newex"));
207 outmess[2] = nextmess[2];
208 outmess[3] = nextmess[3];
209 - SETFLOAT(outmess + 4, 50);
210 - SETFLOAT(outmess + 5, 1);
211 + SETFLOAT(outmess + 4, 50.*(natom-4));
212 + SETFLOAT(outmess + 5, fontsize);
213 for (i = 4; i < natom; i++)
214 outmess[i+2] = nextmess[i];
215 + if (classname == gensym("osc~"))
216 + SETSYMBOL(outmess + 6, gensym("cycle~"));
217 SETSEMI(outmess + natom + 2);
218 binbuf_add(newb, natom + 3, outmess);
220 @@ -1279,8 +1377,8 @@
221 (strcmp(second, "msg") ? "comment" : "message")));
222 outmess[2] = nextmess[2];
223 outmess[3] = nextmess[3];
224 - SETFLOAT(outmess + 4, 50);
225 - SETFLOAT(outmess + 5, 1);
226 + SETFLOAT(outmess + 4, 50.*(natom-4));
227 + SETFLOAT(outmess + 5, fontsize);
228 for (i = 4; i < natom; i++)
229 outmess[i+2] = nextmess[i];
230 SETSEMI(outmess + natom + 2);
231 @@ -1289,10 +1387,13 @@
233 else if (!strcmp(second, "floatatom"))
235 + t_float width = atom_getfloatarg(4, natom, nextmess)*fontsize;
236 + if(width<8) width = 150; /* if pd width=0, set it big */
237 binbuf_addv(newb, "ssfff;",
238 gensym("#P"), gensym("flonum"),
239 atom_getfloatarg(2, natom, nextmess),
240 - atom_getfloatarg(3, natom, nextmess), 35);
241 + atom_getfloatarg(3, natom, nextmess),
242 + width);
243 nobj++;
245 else if (!strcmp(second, "connect"))