63acf6399139e0decff07913e528fed2d3c1a6a1
[blender.git] / source / blender / src / buttons_scene.c
1 /**
2  * $Id$ 
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32
33 #include <time.h>
34 #include <math.h>
35 #include <stdlib.h>
36 #include <string.h>
37
38 #include "MEM_guardedalloc.h"
39 #include "DNA_node_types.h"
40 #include "DNA_screen_types.h"
41 #include "DNA_space_types.h"
42 #include "DNA_scene_types.h"
43 #include "DNA_sound_types.h"
44 #include "DNA_userdef_types.h"
45 #include "DNA_packedFile_types.h"
46
47 #include "BKE_global.h"
48 #include "BKE_main.h"
49 #include "BKE_node.h"
50 #include "BKE_library.h"
51 #include "BKE_scene.h"
52 #include "BKE_sound.h"
53 #include "BKE_packedFile.h"
54 #include "BKE_utildefines.h"
55
56 #include "BLI_blenlib.h"
57
58 #include "BSE_filesel.h"
59
60 #include "BIF_gl.h"
61 #include "BIF_graphics.h"
62 #include "BIF_glutil.h"
63 #include "BIF_interface.h"
64 #include "BIF_keyval.h"
65 #include "BIF_mainqueue.h"
66 #include "BIF_mywindow.h"
67 #include "BIF_resources.h"
68 #include "BIF_renderwin.h"
69 #include "BIF_screen.h"
70 #include "BIF_space.h"
71 #include "BIF_toolbox.h"
72
73 #include "BIF_butspace.h"
74
75 #include "mydevice.h"
76 #include "blendef.h"
77
78 /* -----includes for this file specific----- */
79
80 #include "DNA_image_types.h"
81 #include "BKE_writeavi.h"
82 #include "BKE_image.h"
83 #include "BIF_writeimage.h"
84 #include "BIF_writeavicodec.h"
85 #include "BIF_editsound.h"
86 #include "BSE_seqaudio.h"
87 #include "BSE_headerbuttons.h"
88
89 #include "butspace.h" // own module
90
91 #ifdef WITH_QUICKTIME
92 #include "quicktime_export.h"
93 #endif
94
95
96 /* here the calls for scene buttons
97    - render
98    - world
99    - anim settings, audio
100 */
101
102 /* prototypes */
103 void playback_anim(void);
104
105 /* ************************ SOUND *************************** */
106 static void load_new_sample(char *str)  /* called from fileselect */
107 {
108         char name[FILE_MAXDIR+FILE_MAXFILE];
109         bSound *sound;
110         bSample *sample, *newsample;
111
112         sound = G.buts->lockpoin;
113
114         if (sound) {
115                 // save values
116                 sample = sound->sample;
117                 strcpy(name, sound->sample->name);
118
119                 strcpy(sound->name, str);
120                 sound_set_sample(sound, NULL);
121                 sound_initialize_sample(sound);
122
123                 if (sound->sample->type == SAMPLE_INVALID) {
124                         error("Not a valid sample: %s", str);
125
126                         newsample = sound->sample;
127
128                         // restore values
129                         strcpy(sound->name, name);
130                         sound_set_sample(sound, sample);
131
132                         // remove invalid sample
133
134                         sound_free_sample(newsample);
135                         BLI_remlink(samples, newsample);
136                         MEM_freeN(newsample);
137                 }
138         }
139
140         BIF_undo_push("Load new audio file");
141         allqueue(REDRAWBUTSSCENE, 0);
142
143 }
144
145
146 void do_soundbuts(unsigned short event)
147 {
148         char name[FILE_MAXDIR+FILE_MAXFILE];
149         bSound *sound;
150         bSample *sample;
151         bSound* tempsound;
152         ID *id;
153         
154         sound = G.buts->lockpoin;
155         
156         switch(event) {
157         case B_SOUND_REDRAW:
158                 allqueue(REDRAWBUTSSCENE, 0);
159                 break;
160
161         case B_SOUND_LOAD_SAMPLE:
162                 if (sound) strcpy(name, sound->name);
163                 else strcpy(name, U.sounddir);
164                         
165                 activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_new_sample);
166                 break;
167
168         case B_SOUND_PLAY_SAMPLE:
169                 if (sound) {
170                         if (sound->sample->type != SAMPLE_INVALID) {
171                                 sound_play_sound(sound);
172                                 allqueue(REDRAWBUTSSCENE, 0);
173                         }
174                 }
175                 break;
176
177         case B_SOUND_MENU_SAMPLE:
178                 if (G.buts->menunr == -2) {
179                         if (sound) {
180                                 activate_databrowse((ID *)sound->sample, ID_SAMPLE, 0, B_SOUND_MENU_SAMPLE, &G.buts->menunr, do_soundbuts);
181                         }
182                 } else if (G.buts->menunr > 0) {
183                         sample = BLI_findlink(samples, G.buts->menunr - 1);
184                         if (sample && sound) {
185                                 BLI_strncpy(sound->name, sample->name, sizeof(sound->name));
186                                 sound_set_sample(sound, sample);
187                                 do_soundbuts(B_SOUND_REDRAW);
188                         }
189                 }
190                         
191                 break;
192         case B_SOUND_NAME_SAMPLE:
193                 load_new_sample(sound->name);
194                 break;
195         
196         case B_SOUND_UNPACK_SAMPLE:
197                 if(sound && sound->sample) {
198                         sample = sound->sample;
199                         
200                         if (sample->packedfile) {
201                                 if (G.fileflags & G_AUTOPACK) {
202                                         if (okee("Disable AutoPack ?")) {
203                                                 G.fileflags &= ~G_AUTOPACK;
204                                         }
205                                 }
206                                 
207                                 if ((G.fileflags & G_AUTOPACK) == 0) {
208                                         unpackSample(sample, PF_ASK);
209                                 }
210                         } else {
211                                 sound_set_packedfile(sample, newPackedFile(sample->name));
212                         }
213                         allqueue(REDRAWHEADERS, 0);
214                         do_soundbuts(B_SOUND_REDRAW);
215                 }
216                 break;
217
218         case B_SOUND_COPY_SOUND:
219                 if (sound) {
220                         tempsound = sound_make_copy(sound);
221                         sound = tempsound;
222                         id = &sound->id;
223                         G.buts->lockpoin = (bSound*)id;
224                         BIF_undo_push("Copy sound");
225                         do_soundbuts(B_SOUND_REDRAW);
226                 }
227                 break;
228
229         case B_SOUND_RECALC:
230                 waitcursor(1);
231                 sound = G.main->sound.first;
232                 while (sound) {
233                         free(sound->stream);
234                         sound->stream = 0;
235                         audio_makestream(sound);
236                         sound = (bSound *) sound->id.next;
237                 }
238                 waitcursor(0);
239                 allqueue(REDRAWSEQ, 0);
240                 break;
241
242         case B_SOUND_RATECHANGED:
243
244                 allqueue(REDRAWBUTSSCENE, 0);
245                 allqueue(REDRAWSEQ, 0);
246                 break;
247
248         case B_SOUND_MIXDOWN:
249                 audio_mixdown();
250                 break;
251
252         default: 
253                 if (G.f & G_DEBUG) {
254                         printf("do_soundbuts: unhandled event %d\n", event);
255                 }
256         }
257 }
258
259
260 static void sound_panel_listener(void)
261 {
262         uiBlock *block;
263         int xco= 100, yco=100, mixrate;
264         char mixrateinfo[256];
265         
266         block= uiNewBlock(&curarea->uiblocks, "sound_panel_listener", UI_EMBOSS, UI_HELV, curarea->win);
267         if(uiNewPanel(curarea, block, "Listener", "Sound", 320, 0, 318, 204)==0) return;
268
269         mixrate = sound_get_mixrate();
270         sprintf(mixrateinfo, "Game Mixrate: %d Hz", mixrate);
271         uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
272
273         yco -= 30;
274         uiDefBut(block, LABEL, 0, "Game listener settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
275
276         yco -= 30;
277         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
278                 xco,yco,195,24,&G.listener->gain, 0.0, 1.0, 1.0, 0, "Sets the maximum volume for the overall sound");
279         
280         yco -= 30;
281         uiDefBut(block, LABEL, 0, "Game Doppler effect settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
282
283         yco -= 30;
284         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Doppler: ",
285         xco,yco,195,24,&G.listener->dopplerfactor, 0.0, 10.0, 1.0, 0, "Use this for scaling the doppler effect");
286         
287         yco -=30;
288         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Velocity: ",
289         xco,yco,195,24,&G.listener->dopplervelocity,0.0,10000.0, 1.0,0, "Sets the propagation speed of sound");
290
291         
292 }
293
294 static void sound_panel_sequencer(void)
295 {
296         uiBlock *block;
297         short xco, yco;
298         char mixrateinfo[256];
299         
300         block= uiNewBlock(&curarea->uiblocks, "sound_panel_sequencer", UI_EMBOSS, UI_HELV, curarea->win);
301         if(uiNewPanel(curarea, block, "Sequencer", "Sound", 640, 0, 318, 204)==0) return;
302
303         /* audio sequence engine settings ------------------------------------------------------------------ */
304
305         xco = 1010;
306         yco = 195;
307
308         uiDefBut(block, LABEL, 0, "Audio sequencer settings", xco,yco,295,20, 0, 0, 0, 0, 0, "");
309
310         yco -= 25;
311         sprintf(mixrateinfo, "Mixing/Sync (latency: %d ms)", (int)( (((float)U.mixbufsize)/(float)G.scene->audio.mixrate)*1000.0 ) );
312         uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
313
314         yco -= 25;              
315         uiDefButI(block, ROW, B_SOUND_RATECHANGED, "44.1 kHz",  xco,yco,75,20, &G.scene->audio.mixrate, 2.0, 44100.0, 0, 0, "Mix at 44.1 kHz");
316         uiDefButI(block, ROW, B_SOUND_RATECHANGED, "48.0 kHz",          xco+80,yco,75,20, &G.scene->audio.mixrate, 2.0, 48000.0, 0, 0, "Mix at 48 kHz");
317         uiDefBut(block, BUT, B_SOUND_RECALC, "Recalc",          xco+160,yco,75,20, 0, 0, 0, 0, 0, "Recalculate samples");
318
319         yco -= 25;
320         uiDefButBitS(block, TOG, AUDIO_SYNC, B_SOUND_CHANGED, "Sync",   xco,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio");
321         uiDefButBitS(block, TOG, AUDIO_SCRUB, B_SOUND_CHANGED, "Scrub",         xco+120,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Scrub when changing frames");
322
323         yco -= 25;
324         uiDefBut(block, LABEL, 0, "Main mix", xco,yco,295,20, 0, 0, 0, 0, 0, "");
325
326         yco -= 25;              
327         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Main (dB): ",
328                 xco,yco,235,24,&G.scene->audio.main, -24.0, 6.0, 0, 0, "Set the audio master gain/attenuation in dB");
329
330         yco -= 25;
331         uiDefButBitS(block, TOG, AUDIO_MUTE, 0, "Mute", xco,yco,235,24, &G.scene->audio.flag, 0, 0, 0, 0, "Mute audio from sequencer");         
332         
333         yco -= 35;
334         uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN",        xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio");
335         
336 }
337
338 static void sound_panel_sound(bSound *sound)
339 {
340         static int packdummy=0;
341         ID *id, *idfrom;
342         uiBlock *block;
343         bSample *sample;
344         char *strp, str[32], ch[256];
345
346         block= uiNewBlock(&curarea->uiblocks, "sound_panel_sound", UI_EMBOSS, UI_HELV, curarea->win);
347         if(uiNewPanel(curarea, block, "Sound", "Sound", 0, 0, 318, 204)==0) return;
348         
349         uiDefBut(block, LABEL, 0, "Blender Sound block",10,180,195,20, 0, 0, 0, 0, 0, "");
350         
351         // warning: abuse of texnr here! (ton didnt code!)
352         buttons_active_id(&id, &idfrom);
353         std_libbuttons(block, 10, 160, 0, NULL, B_SOUNDBROWSE2, ID_SO, 0, id, idfrom, &(G.buts->texnr), 1, 0, 0, 0, 0);
354
355         if (sound) {
356         
357                 uiDefBut(block, BUT, B_SOUND_COPY_SOUND, "Copy sound", 220,160,90,20, 0, 0, 0, 0, 0, "Make another copy (duplicate) of the current sound");
358
359                 uiSetButLock(sound->id.lib!=0, "Can't edit library data");
360                 sound_initialize_sample(sound);
361                 sample = sound->sample;
362
363                 /* info string */
364                 if (sound->sample && sound->sample->len) {
365                         char *tmp;
366                         if (sound->sample->channels == 1) tmp= "Mono";
367                         else if (sound->sample->channels == 2) tmp= "Stereo";
368                         else tmp= "Unknown";
369                         
370                         sprintf(ch, "Sample: %s, %d bit, %d Hz, %d samples", tmp, sound->sample->bits, sound->sample->rate, (sound->sample->len/(sound->sample->bits/8)/sound->sample->channels));
371                         uiDefBut(block, LABEL, 0, ch,                   35,140,225,20, 0, 0, 0, 0, 0, "");
372                 }
373                 else {
374                         uiDefBut(block, LABEL, 0, "Sample: No sample info available.",35,140,225,20, 0, 0, 0, 0, 0, "");
375                 }
376
377                 /* sample browse buttons */
378
379                 id= (ID *)sound->sample;
380                 IDnames_to_pupstring(&strp, NULL, NULL, samples, id, &(G.buts->menunr));
381                 if (strp[0]) uiDefButS(block, MENU, B_SOUND_MENU_SAMPLE, strp, 10,120,23,20, &(G.buts->menunr), 0, 0, 0, 0, "Select another loaded sample");
382                 MEM_freeN(strp);
383                 
384                 uiDefBut(block, TEX, B_SOUND_NAME_SAMPLE, "",           35,120,225,20, sound->name, 0.0, 79.0, 0, 0, "The sample file used by this Sound");
385                 
386                 sprintf(str, "%d", sample->id.us);
387                 uiDefBut(block, BUT, B_SOUND_UNLINK_SAMPLE, str,        260,120,25,20, 0, 0, 0, 0, 0, "The number of users");
388                 
389                 if (sound->sample->packedfile) packdummy = 1;
390                 else packdummy = 0;
391                 
392                 uiDefIconButBitI(block, TOG, 1, B_SOUND_UNPACK_SAMPLE, ICON_PACKAGE,
393                         285, 120,25,24, &packdummy, 0, 0, 0, 0,"Pack/Unpack this sample");
394                 
395                 uiDefBut(block, BUT, B_SOUND_LOAD_SAMPLE, "Load sample", 10, 95,150,24, 0, 0, 0, 0, 0, "Load a different sample file");
396
397                 uiDefBut(block, BUT, B_SOUND_PLAY_SAMPLE, "Play",       160, 95, 150, 24, 0, 0.0, 0, 0, 0, "Playback sample using settings below");
398                 
399                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
400                         10,70,150,20, &sound->volume, 0.0, 1.0, 0, 0, "Game engine only: Set the volume of this sound");
401
402                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pitch: ",
403                         160,70,150,20, &sound->pitch, -12.0, 12.0, 0, 0, "Game engine only: Set the pitch of this sound");
404
405                 /* looping */
406                 uiDefButBitI(block, TOG, SOUND_FLAGS_LOOP, B_SOUND_REDRAW, "Loop",
407                         10, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Game engine only: Toggle between looping on/off");
408
409                 if (sound->flags & SOUND_FLAGS_LOOP) {
410                         uiDefButBitI(block, TOG, SOUND_FLAGS_BIDIRECTIONAL_LOOP, B_SOUND_REDRAW, "Ping Pong",
411                                 105, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Game engine only: Toggle between A->B and A->B->A looping");
412                         
413                 }
414         
415
416                 /* 3D settings ------------------------------------------------------------------ */
417
418                 if (sound->sample->channels == 1) {
419                         uiDefButBitI(block, TOG, SOUND_FLAGS_3D, B_SOUND_REDRAW, "3D Sound",
420                                 10, 10, 90, 20, &sound->flags, 0, 0, 0, 0, "Game engine only: Turns 3D sound on");
421                         
422                         if (sound->flags & SOUND_FLAGS_3D) {
423                                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ",
424                                         100,10,210,20, &sound->attenuation, 0.0, 5.0, 1.0, 0, "Game engine only: Sets the surround scaling factor for this sound");
425                                 
426                         }
427                 }
428         }
429 }
430
431
432 /* ************************* SCENE *********************** */
433
434
435 static void output_pic(char *name)
436 {
437         strcpy(G.scene->r.pic, name);
438         allqueue(REDRAWBUTSSCENE, 0);
439         BIF_undo_push("Change output picture directory");
440 }
441
442 static void backbuf_pic(char *name)
443 {
444         Image *ima;
445         
446         strcpy(G.scene->r.backbuf, name);
447         allqueue(REDRAWBUTSSCENE, 0);
448
449         ima= add_image(name);
450         if(ima) {
451                 free_image_buffers(ima);        /* force read again */
452                 ima->ok= 1;
453         }
454         BIF_undo_push("Change background picture");
455 }
456
457 static void ftype_pic(char *name)
458 {
459         strcpy(G.scene->r.ftype, name);
460         allqueue(REDRAWBUTSSCENE, 0);
461 }
462
463 static void scene_chain_cleanup(Scene *sc) {
464         while(sc) {
465                 sc->dirty = SCE_CLEAN;
466                 sc = sc->set;
467     }
468 }
469
470 static void scene_change_set(Scene *sc, Scene *set) {
471         Scene *scene = G.main->scene.first;
472         int clean = SCE_CLEAN;
473         int breakout = 0;
474         if (sc->set!=set) {
475                 sc->set= set;
476                 while(breakout==0 && scene) {
477                         Scene *setchain = scene;
478                         while(breakout==0 && setchain) {
479                                 clean = setchain->dirty;
480                                 if(clean == SCE_DIRTY) {
481                                         /* we have not reached yet end of chain, and we
482                                         * encountered dirty node - we have a cycle.
483                                         * sc->set = 0, clean the chain and break out.
484                                         */
485                                         error("Can't change set. It would create a loop!");
486                                         sc->set = 0;
487                                         breakout = 1;
488                                         scene_chain_cleanup(scene);
489                                         
490                                 }
491                                 
492                                 if(breakout == 0) {
493                                         setchain->dirty = SCE_DIRTY;
494                                         setchain = setchain->set;
495                                 }
496                         }
497                         
498                         if(breakout == 0) {
499                                 scene_chain_cleanup(scene);
500                                 scene = scene->id.next;
501                         }
502                 }
503                 
504                 allqueue(REDRAWBUTSSCENE, 0);
505                 allqueue(REDRAWVIEW3D, 0);
506                 BIF_undo_push("Change set Scene");
507         }
508 }
509
510 static void run_playanim(char *file) {
511         extern char bprogname[];        /* usiblender.c */
512         char str[FILE_MAXDIR+FILE_MAXFILE];
513         int pos[2], size[2];
514
515         /* image size not so relevant for now */
516         calc_renderwin_rectangle(640, 480, G.winpos, pos, size);
517
518         sprintf(str, "%s -a -p %d %d \"%s\"", bprogname, pos[0], pos[1], file);
519         system(str);
520 }
521
522 void playback_anim(void)
523 {       
524         char file[FILE_MAXDIR+FILE_MAXFILE];
525         
526 #ifdef WITH_QUICKTIME
527         if(G.scene->r.imtype == R_QUICKTIME)
528                 makeqtstring(file);
529         else
530 #endif
531                 makeavistring(&G.scene->r, file);
532         if(BLI_exist(file)) {
533                 run_playanim(file);
534         }
535         else {
536                 BKE_makepicstring(file, G.scene->r.sfra);
537                 if(BLI_exist(file)) {
538                         run_playanim(file);
539                 }
540                 else error("Can't find image: %s", file);
541         }
542 }
543
544 void do_render_panels(unsigned short event)
545 {
546         ScrArea *sa;
547         ID *id;
548
549         switch(event) {
550
551         case B_DORENDER:
552                 BIF_do_render(0);
553                 break;
554         case B_RTCHANGED:
555                 allqueue(REDRAWALL, 0);
556                 break;
557         case B_SWITCHRENDER:
558                 /* new panels added, so... */
559                 G.buts->re_align= 1;
560                 allqueue(REDRAWBUTSSCENE, 0);
561                 break;
562         case B_PLAYANIM:
563                 playback_anim();
564                 break;
565                 
566         case B_DOANIM:
567                 BIF_do_render(1);
568                 break;
569         
570         case B_FS_PIC:
571                 sa= closest_bigger_area();
572                 areawinset(sa->win);
573                 if(G.qual == LR_CTRLKEY)
574                         activate_imageselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic);
575                 else
576                         activate_fileselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic);
577                 break;
578
579         case B_FS_BACKBUF:
580                 sa= closest_bigger_area();
581                 areawinset(sa->win);
582                 if(G.qual == LR_CTRLKEY)
583                         activate_imageselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
584                 else
585                         activate_fileselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
586                 break;
587
588         case B_FS_FTYPE:
589                 sa= closest_bigger_area();
590                 areawinset(sa->win);
591                 if(G.qual == LR_CTRLKEY)
592                         activate_imageselect(FILE_SPECIAL, "SELECT FTYPE", G.scene->r.ftype, ftype_pic);
593                 else
594                         activate_fileselect(FILE_SPECIAL, "SELECT FTYPE", G.scene->r.ftype, ftype_pic);
595                 break;
596         
597         case B_PR_PAL:
598                 G.scene->r.xsch= 720;
599                 G.scene->r.ysch= 576;
600                 G.scene->r.xasp= 54;
601                 G.scene->r.yasp= 51;
602                 G.scene->r.size= 100;
603                 G.scene->r.frs_sec= 25;
604                 G.scene->r.mode &= ~R_PANORAMA;
605                 G.scene->r.xparts=  G.scene->r.yparts= 4;
606                 
607                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
608                 BIF_undo_push("Set PAL");
609                 allqueue(REDRAWBUTSSCENE, 0);
610                 allqueue(REDRAWVIEWCAM, 0);
611                 break;
612
613         case B_FILETYPEMENU:
614                 allqueue(REDRAWBUTSSCENE, 0);
615 #if defined (_WIN32) || defined (__APPLE__)
616                 // fall through to codec settings if this is the first
617                 // time R_AVICODEC is selected for this scene.
618                 if (((G.scene->r.imtype == R_AVICODEC) 
619                          && (G.scene->r.avicodecdata == NULL)) ||
620                         ((G.scene->r.imtype == R_QUICKTIME) 
621                          && (G.scene->r.qtcodecdata == NULL))) {
622                 } else {
623                   break;
624                 }
625 #endif /*_WIN32 || __APPLE__ */
626
627         case B_SELECTCODEC:
628 #if defined (_WIN32) || defined (__APPLE__)
629                 if ((G.scene->r.imtype == R_QUICKTIME)) { /* || (G.scene->r.qtcodecdata)) */
630 #ifdef WITH_QUICKTIME
631                         get_qtcodec_settings();
632 #endif /* WITH_QUICKTIME */
633                 }
634 #if defined (_WIN32) && !defined(FREE_WINDOWS)
635                 else
636                         get_avicodec_settings();
637 #endif /* _WIN32 && !FREE_WINDOWS */
638 #endif /* _WIN32 || __APPLE__ */
639                 break;
640
641         case B_PR_FULL:
642                 G.scene->r.xsch= 1280;
643                 G.scene->r.ysch= 1024;
644                 G.scene->r.xasp= 1;
645                 G.scene->r.yasp= 1;
646                 G.scene->r.size= 100;
647                 G.scene->r.mode &= ~R_PANORAMA;
648                 G.scene->r.xparts=  G.scene->r.yparts= 4;
649
650                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
651                 BIF_undo_push("Set FULL");
652                 allqueue(REDRAWBUTSSCENE, 0);
653                 allqueue(REDRAWVIEWCAM, 0);
654                 break;
655         case B_PR_PRV:
656                 G.scene->r.xsch= 640;
657                 G.scene->r.ysch= 512;
658                 G.scene->r.xasp= 1;
659                 G.scene->r.yasp= 1;
660                 G.scene->r.size= 50;
661                 G.scene->r.mode &= ~R_PANORAMA;
662                 G.scene->r.xparts=  G.scene->r.yparts= 4;
663
664                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
665                 allqueue(REDRAWVIEWCAM, 0);
666                 allqueue(REDRAWBUTSSCENE, 0);
667                 break;
668         case B_PR_CDI:
669                 G.scene->r.xsch= 384;
670                 G.scene->r.ysch= 280;
671                 G.scene->r.xasp= 1;
672                 G.scene->r.yasp= 1;
673                 G.scene->r.size= 100;
674                 G.scene->r.mode &= ~R_PANORAMA;
675                 G.scene->r.xparts=  G.scene->r.yparts= 4;
676
677                 BLI_init_rctf(&G.scene->r.safety, 0.15, 0.85, 0.15, 0.85);
678                 allqueue(REDRAWVIEWCAM, 0);
679                 allqueue(REDRAWBUTSSCENE, 0);
680                 break;
681         case B_PR_PAL169:
682                 G.scene->r.xsch= 720;
683                 G.scene->r.ysch= 576;
684                 G.scene->r.xasp= 64;
685                 G.scene->r.yasp= 45;
686                 G.scene->r.size= 100;
687                 G.scene->r.frs_sec= 25;
688                 G.scene->r.mode &= ~R_PANORAMA;
689                 G.scene->r.xparts=  G.scene->r.yparts= 4;
690
691                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
692                 BIF_undo_push("Set PAL 16/9");
693                 allqueue(REDRAWVIEWCAM, 0);
694                 allqueue(REDRAWBUTSSCENE, 0);
695                 break;
696         case B_PR_D2MAC:
697                 G.scene->r.xsch= 1024;
698                 G.scene->r.ysch= 576;
699                 G.scene->r.xasp= 1;
700                 G.scene->r.yasp= 1;
701                 G.scene->r.size= 50;
702                 G.scene->r.mode &= ~R_PANORAMA;
703                 G.scene->r.xparts=  G.scene->r.yparts= 4;
704
705                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
706                 allqueue(REDRAWVIEWCAM, 0);
707                 allqueue(REDRAWBUTSSCENE, 0);
708                 break;
709         case B_PR_MPEG:
710                 G.scene->r.xsch= 368;
711                 G.scene->r.ysch= 272;
712                 G.scene->r.xasp= 105;
713                 G.scene->r.yasp= 100;
714                 G.scene->r.size= 100;
715                 G.scene->r.mode &= ~R_PANORAMA;
716                 G.scene->r.xparts=  G.scene->r.yparts= 4;
717
718                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
719                 allqueue(REDRAWVIEWCAM, 0);
720                 allqueue(REDRAWBUTSSCENE, 0);
721                 break;
722         case B_PR_PC:
723                 G.scene->r.xsch= 640;
724                 G.scene->r.ysch= 480;
725                 G.scene->r.xasp= 100;
726                 G.scene->r.yasp= 100;
727                 G.scene->r.size= 100;
728                 G.scene->r.mode &= ~R_PANORAMA;
729                 G.scene->r.xparts=  G.scene->r.yparts= 4;
730
731                 BLI_init_rctf(&G.scene->r.safety, 0.0, 1.0, 0.0, 1.0);
732                 BIF_undo_push("Set PC");
733                 allqueue(REDRAWVIEWCAM, 0);
734                 allqueue(REDRAWBUTSSCENE, 0);
735                 break;
736         case B_PR_PRESET:
737                 G.scene->r.xsch= 720;
738                 G.scene->r.ysch= 576;
739                 G.scene->r.xasp= 54;
740                 G.scene->r.yasp= 51;
741                 G.scene->r.size= 100;
742                 G.scene->r.mode= R_OSA+R_SHADOW+R_FIELDS;
743                 G.scene->r.imtype= R_TARGA;
744                 G.scene->r.xparts=  G.scene->r.yparts= 4;
745
746                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
747                 BIF_undo_push("Set Default");
748                 allqueue(REDRAWVIEWCAM, 0);
749                 allqueue(REDRAWBUTSSCENE, 0);
750                 break;
751         case B_PR_PANO:
752                 G.scene->r.xsch= 36;
753                 G.scene->r.ysch= 176;
754                 G.scene->r.xasp= 115;
755                 G.scene->r.yasp= 100;
756                 G.scene->r.size= 100;
757                 G.scene->r.mode |= R_PANORAMA;
758                 G.scene->r.xparts=  16;
759                 G.scene->r.yparts= 1;
760
761                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
762                 BIF_undo_push("Set Panorama");
763                 allqueue(REDRAWVIEWCAM, 0);
764                 allqueue(REDRAWBUTSSCENE, 0);
765                 break;
766         case B_PR_NTSC:
767                 G.scene->r.xsch= 720;
768                 G.scene->r.ysch= 480;
769                 G.scene->r.xasp= 10;
770                 G.scene->r.yasp= 11;
771                 G.scene->r.size= 100;
772                 G.scene->r.frs_sec= 30;
773                 G.scene->r.mode &= ~R_PANORAMA;
774                 G.scene->r.xparts=  G.scene->r.yparts= 2;
775                 
776                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
777                 BIF_undo_push("Set NTSC");
778                 allqueue(REDRAWBUTSSCENE, 0);
779                 allqueue(REDRAWVIEWCAM, 0);
780                 break;
781
782         case B_SETBROWSE:
783                 id= (ID*) G.scene->set;
784                 
785                 if (G.buts->menunr==-2) {
786                          activate_databrowse(id, ID_SCE, 0, B_SETBROWSE, &G.buts->menunr, do_render_panels);
787                 } else if (G.buts->menunr>0) {
788                         Scene *newset= (Scene*) BLI_findlink(&G.main->scene, G.buts->menunr-1);
789                         
790                         if (newset==G.scene)
791                                 error("Not allowed");
792                         else if (newset)
793                                 scene_change_set(G.scene, newset);
794                 }  
795                 break;
796         case B_CLEARSET:
797                 scene_change_set(G.scene, NULL);
798                 break;
799         case B_FBUF_REDO:
800 //              if(R.rectftot) {
801                         /* copy is needed... not so nice, but how better? */
802 //                      R.r.postgamma= G.scene->r.postgamma;
803 //                      R.r.postigamma= 1.0/R.r.postgamma;
804 //                      R.r.postadd= G.scene->r.postadd;
805 //                      R.r.postmul= G.scene->r.postmul;
806 //                      R.r.posthue= G.scene->r.posthue;
807 //                      R.r.postsat= G.scene->r.postsat;
808 //                      R.r.dither_intensity= G.scene->r.dither_intensity;
809                         
810 //                      _floatbuffer_to_output();
811 //                      BIF_redraw_render_rect();
812 //              }
813                 break;
814         case B_SET_EDGE:
815                 G.scene->r.mode &= ~R_ZBLUR;
816                 allqueue(REDRAWBUTSSCENE, 0);
817                 break;
818         case B_SET_ZBLUR:
819                 G.scene->r.mode &= ~R_EDGE;
820                 allqueue(REDRAWBUTSSCENE, 0);
821                 break;
822         case B_ADD_RENDERLAYER:
823                 if(G.scene->r.actlay==32767) {
824                         scene_add_render_layer(G.scene);
825                         G.scene->r.actlay= BLI_countlist(&G.scene->r.layers) - 1;
826                 }
827                 allqueue(REDRAWBUTSSCENE, 0);
828                 allqueue(REDRAWNODE, 0);
829         }
830 }
831
832 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
833 static uiBlock *edge_render_menu(void *arg_unused)
834 {
835         uiBlock *block;
836         
837         block= uiNewBlock(&curarea->uiblocks, "edge render", UI_EMBOSS, UI_HELV, curarea->win);
838                 
839         /* use this for a fake extra empy space around the buttons */
840         uiDefBut(block, LABEL, 0, "",  290, -15, 220, 115, NULL,  0, 0, 0, 0, "");
841         
842         uiBlockBeginAlign(block);
843         uiDefButS(block, NUM, 0,"Eint:",        370,75,135,19,  &G.scene->r.edgeint, 0.0, 255.0, 0, 0,
844                   "Sets edge intensity for Toon shading");
845         uiDefButS(block, NUM, 0,"AntiShift",370,55,135,19,  &(G.scene->r.same_mat_redux), 0, 255.0, 0, 0,
846                   "For unified renderer: reduce intensity on boundaries "
847                   "with identical materials with this number.");
848
849         uiBlockBeginAlign(block);
850         uiDefButI(block, TOG, 0,"Shift",        295,75,70,19,  &G.compat, 0, 0, 0, 0,
851                   "For unified renderer: use old offsets for edges");
852         uiDefButI(block, TOG, 0,"All",          295,55,70,19,  &G.notonlysolid, 0, 0, 0, 0,
853                   "For unified renderer: also consider transparent faces for toon shading");
854         uiBlockEndAlign(block);
855         
856         /* colour settings for the toon shading */
857         uiDefButF(block, COL, 0, "",            295,-10,30,60,  &(G.scene->r.edgeR), 0, 0, 0, B_EDGECOLSLI, "");
858         
859         uiBlockBeginAlign(block);
860         uiDefButF(block, NUMSLI, 0, "R ",   330, 30, 175,19,   &G.scene->r.edgeR, 0.0, 1.0, B_EDGECOLSLI, 0,
861                   "For unified renderer: Colour for edges in toon shading mode.");
862         uiDefButF(block, NUMSLI, 0, "G ",       330, 10, 175,19,  &G.scene->r.edgeG, 0.0, 1.0, B_EDGECOLSLI, 0,
863                   "For unified renderer: Colour for edges in toon shading mode.");
864         uiDefButF(block, NUMSLI, 0, "B ",       330, -10, 175,19,  &G.scene->r.edgeB, 0.0, 1.0, B_EDGECOLSLI, 0,
865                   "For unified renderer: Colour for edges in toon shading mode.");
866
867         
868         uiBlockSetDirection(block, UI_TOP);
869         
870         return block;
871 }
872
873 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
874 static uiBlock *post_render_menu(void *arg_unused)
875 {
876         uiBlock *block;
877         
878         block= uiNewBlock(&curarea->uiblocks, "post render", UI_EMBOSS, UI_HELV, curarea->win);
879                 
880         /* use this for a fake extra empy space around the buttons */
881         uiDefBut(block, LABEL, 0, "",                   -10, -10, 200, 120, NULL, 0, 0, 0, 0, "");
882         uiBlockBeginAlign(block);
883         uiDefButF(block, NUMSLI, 0, "Add:",             0,80,180,19, &G.scene->r.postadd, -1.0, 1.0, 0, 0, "");
884         uiDefButF(block, NUMSLI, 0, "Mul:",             0,60,180,19,  &G.scene->r.postmul, 0.01, 4.0, 0, 0, "");
885         uiDefButF(block, NUMSLI, 0, "Gamma:",   0,40,180,19,  &G.scene->r.postgamma, 0.1, 4.0, 0, 0, "");
886         uiDefButF(block, NUMSLI, 0, "Hue:",             0,20,180,19,  &G.scene->r.posthue, -0.5, 0.5, 0, 0, "");
887         uiDefButF(block, NUMSLI, 0, "Sat:",             0, 0,180,19,  &G.scene->r.postsat, 0.0, 4.0, 0, 0, "");
888
889         uiBlockSetDirection(block, UI_TOP);
890         
891         addqueue(curarea->win, UI_BUT_EVENT, B_FBUF_REDO);
892         
893         return block;
894 }
895
896 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
897 static uiBlock *framing_render_menu(void *arg_unused)
898 {
899         uiBlock *block;
900         short yco = 190, xco = 0;
901         int randomcolorindex = 1234;
902
903         block= uiNewBlock(&curarea->uiblocks, "framing_options", UI_EMBOSS, UI_HELV, curarea->win);
904
905         /* use this for a fake extra empy space around the buttons */
906         uiDefBut(block, LABEL, 0, "",                   -5, -10, 295, 224, NULL, 0, 0, 0, 0, "");
907
908         uiDefBut(block, LABEL, 0, "Framing:", xco, yco, 68,19, 0, 0, 0, 0, 0, "");
909         uiBlockBeginAlign(block);
910         uiDefButC(block, ROW, 0, "Stretch",     xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_SCALE , 0, 0, "Stretch or squeeze the viewport to fill the display window");
911         uiDefButC(block, ROW, 0, "Expose",      xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_EXTEND, 0, 0, "Show the entire viewport in the display window, viewing more horizontally or vertically");
912         uiDefButC(block, ROW, 0, "Letterbox",       xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_BARS  , 0, 0, "Show the entire viewport in the display window, using bar horizontally or vertically");
913         uiBlockEndAlign(block);
914
915         yco -= 25;
916         xco = 40;
917
918         uiDefButF(block, COL, 0, "",                0, yco - 58 + 18, 33, 58, &G.scene->framing.col[0], 0, 0, 0, randomcolorindex, "");
919
920         uiBlockBeginAlign(block);
921         uiDefButF(block, NUMSLI, 0, "R ", xco,yco,243,18, &G.scene->framing.col[0], 0.0, 1.0, randomcolorindex, 0, "Set the red component of the bars");
922         yco -= 20;
923         uiDefButF(block, NUMSLI, 0, "G ", xco,yco,243,18, &G.scene->framing.col[1], 0.0, 1.0, randomcolorindex, 0, "Set the green component of the bars");
924         yco -= 20;
925         uiDefButF(block, NUMSLI, 0, "B ", xco,yco,243,18, &G.scene->framing.col[2], 0.0, 1.0, randomcolorindex, 0, "Set the blue component of the bars");
926         uiBlockEndAlign(block);
927         
928         xco = 0;
929         uiDefBut(block, LABEL, 0, "Fullscreen:",                xco, yco-=30, 100, 19, 0, 0.0, 0.0, 0, 0, "");
930         uiDefButS(block, TOG, 0, "Fullscreen", xco+70, yco, 68, 19, &G.scene->r.fullscreen, 0.0, 0.0, 0, 0, "Starts player in a new fullscreen display");
931         uiBlockBeginAlign(block);
932         uiDefButS(block, NUM, 0, "X:",          xco+40, yco-=27, 100, 19, &G.scene->r.xplay, 10.0, 2000.0, 0, 0, "Displays current X screen/window resolution. Click to change.");
933         uiDefButS(block, NUM, 0, "Y:",          xco+140, yco, 100, 19, &G.scene->r.yplay,    10.0, 2000.0, 0, 0, "Displays current Y screen/window resolution. Click to change.");
934         uiDefButS(block, NUM, 0, "Freq:",       xco+40, yco-=21, 100, 19, &G.scene->r.freqplay, 10.0, 2000.0, 0, 0, "Displays clock frequency of fullscreen display. Click to change.");
935         uiDefButS(block, NUM, 0, "Bits:",       xco+140, yco, 100, 19, &G.scene->r.depth, 8.0, 32.0, 800.0, 0, "Displays bit depth of full screen display. Click to change.");
936         uiBlockEndAlign(block);
937
938         /* stereo settings */
939         /* can't use any definition from the game engine here so hardcode it. Change it here when it changes there!
940          * RAS_IRasterizer has definitions:
941          * RAS_STEREO_NOSTEREO           1
942          * RAS_STEREO_QUADBUFFERED 2
943          * RAS_STEREO_ABOVEBELOW         3
944          * RAS_STEREO_INTERLACED         4       future
945          * RAS_STEREO_ANAGLYPH          5
946          * RAS_STEREO_SIDEBYSIDE        6
947          * RAS_STEREO_VINTERLACE        7
948          */
949         uiBlockBeginAlign(block);
950         uiDefButS(block, ROW, 0, "No Stereo", xco, yco-=30, 88, 19, &(G.scene->r.stereomode), 7.0, 1.0, 0, 0, "Disables stereo");
951         uiDefButS(block, ROW, 0, "Pageflip", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 2.0, 0, 0, "Enables hardware pageflip stereo method");
952         uiDefButS(block, ROW, 0, "Syncdouble", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 3.0, 0, 0, "Enables syncdoubling stereo method");
953         uiDefButS(block, ROW, 0, "Anaglyph", xco-=180, yco-=21, 88, 19, &(G.scene->r.stereomode), 7.0, 5.0, 0, 0, "Enables anaglyph (Red-Blue) stereo method");
954         uiDefButS(block, ROW, 0, "Side by Side", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 6.0, 0, 0, "Enables side by side left and right images");
955         uiDefButS(block, ROW, 0, "V Interlace", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 7.0, 0, 0, "Enables interlaced vertical strips for autostereo display");
956         
957         uiBlockEndAlign(block);
958
959         uiBlockSetDirection(block, UI_TOP);
960
961         return block;
962 }
963
964
965 static char *imagetype_pup(void)
966 {
967         static char string[1024];
968         char formatstring[1024];
969         char appendstring[1024];
970
971         strcpy(formatstring, "Save image as: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
972
973 #ifdef __sgi
974         strcat(formatstring, "|%s %%x%d");      // add space for Movie
975 #endif
976
977         strcat(formatstring, "|%s %%x%d");      // add space for PNG
978         strcat(formatstring, "|%s %%x%d");      // add space for BMP
979         strcat(formatstring, "|%s %%x%d");      // add space for Radiance HDR
980
981 #ifdef _WIN32
982         strcat(formatstring, "|%s %%x%d");      // add space for AVI Codec
983 #endif
984
985 #ifdef WITH_QUICKTIME
986         if(G.have_quicktime)
987                 strcat(formatstring, "|%s %%x%d");      // add space for Quicktime
988 #endif
989
990         if(G.have_quicktime) {
991                 sprintf(string, formatstring,
992                         "AVI Raw",        R_AVIRAW,
993                         "AVI Jpeg",       R_AVIJPEG,
994 #ifdef _WIN32
995                         "AVI Codec",      R_AVICODEC,
996 #endif
997 #ifdef WITH_QUICKTIME
998                         "QuickTime",      R_QUICKTIME,
999 #endif
1000                         "Targa",          R_TARGA,
1001                         "Targa Raw",      R_RAWTGA,
1002                         "PNG",            R_PNG,
1003                         "BMP",            R_BMP,
1004                         "Jpeg",           R_JPEG90,
1005                         "HamX",           R_HAMX,
1006                         "Iris",           R_IRIS,
1007                         "Iris + Zbuffer", R_IRIZ,
1008                         "Radiance HDR",   R_RADHDR
1009 #ifdef __sgi
1010                         ,"Movie",          R_MOVIE
1011 #endif
1012                 );
1013         } else {
1014                 sprintf(string, formatstring,
1015                         "AVI Raw",        R_AVIRAW,
1016                         "AVI Jpeg",       R_AVIJPEG,
1017 #ifdef _WIN32
1018                         "AVI Codec",      R_AVICODEC,
1019 #endif
1020                         "Targa",          R_TARGA,
1021                         "Targa Raw",      R_RAWTGA,
1022                         "PNG",            R_PNG,
1023                         "BMP",            R_BMP,
1024                         "Jpeg",           R_JPEG90,
1025                         "HamX",           R_HAMX,
1026                         "Iris",           R_IRIS,
1027                         "Iris + Zbuffer", R_IRIZ,
1028                         "Radiance HDR",   R_RADHDR
1029 #ifdef __sgi
1030                         ,"Movie",          R_MOVIE
1031 #endif
1032                 );
1033         }
1034
1035 #ifdef WITH_OPENEXR
1036         strcpy(formatstring, "|%s %%x%d");
1037         sprintf(appendstring, formatstring, "OpenEXR", R_OPENEXR);
1038         strcat(string, appendstring);
1039 #endif
1040         
1041         if (G.have_libtiff) {
1042                 strcpy(formatstring, "|%s %%x%d");
1043                 sprintf(appendstring, formatstring, "TIFF", R_TIFF);
1044                 strcat(string, appendstring);
1045         }
1046
1047         return (string);
1048 }
1049
1050 #ifdef _WIN32
1051 static char *avicodec_str(void)
1052 {
1053         static char string[1024];
1054
1055         sprintf(string, "Codec: %s", G.scene->r.avicodecdata->avicodecname);
1056
1057         return string;
1058 }
1059 #endif
1060
1061 static void render_panel_output(void)
1062 {
1063         ID *id;
1064         int a,b;
1065         uiBlock *block;
1066         char *strp;
1067
1068
1069         block= uiNewBlock(&curarea->uiblocks, "render_panel_output", UI_EMBOSS, UI_HELV, curarea->win);
1070         if(uiNewPanel(curarea, block, "Output", "Render", 0, 0, 318, 204)==0) return;
1071         
1072         uiBlockBeginAlign(block);
1073         uiDefIconBut(block, BUT, B_FS_PIC, ICON_FILESEL,        10, 190, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Pics dir/name");
1074         uiDefBut(block, TEX,0,"",                                                       31, 190, 279, 20,G.scene->r.pic, 0.0,79.0, 0, 0, "Directory/name to save rendered Pics to");
1075         uiDefIconBut(block, BUT,B_FS_BACKBUF, ICON_FILESEL, 10, 168, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Backbuf image");
1076         uiDefBut(block, TEX,0,"",                                                       31, 168, 279, 20,G.scene->r.backbuf, 0.0,79.0, 0, 0, "Image to use as background for rendering");
1077         uiDefIconBut(block, BUT,B_FS_FTYPE, ICON_FILESEL,       10, 146, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Ftype image");
1078         uiDefBut(block, TEX,0,"",                                                       31, 146, 279, 20,G.scene->r.ftype,0.0,79.0, 0, 0, "Image to use with FTYPE Image type");
1079         uiBlockEndAlign(block);
1080         
1081         
1082         /* SET BUTTON */
1083         uiBlockBeginAlign(block);
1084         id= (ID *)G.scene->set;
1085         IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->scene), id, &(G.buts->menunr));
1086         if(strp[0])
1087                 uiDefButS(block, MENU, B_SETBROWSE, strp, 10, 120, 20, 20, &(G.buts->menunr), 0, 0, 0, 0, "Scene to link as a Set");
1088         MEM_freeN(strp);
1089
1090         if(G.scene->set) {
1091                 uiSetButLock(1, NULL);
1092                 uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 0, "",        31, 120, 100, 20, &(G.scene->set), "Name of the Set");
1093                 uiClearButLock();
1094                 uiDefIconBut(block, BUT, B_CLEARSET, ICON_X,            132, 120, 20, 20, 0, 0, 0, 0, 0, "Remove Set link");
1095         }
1096         uiBlockEndAlign(block);
1097
1098         uiBlockSetCol(block, TH_BUT_SETTING1);
1099         uiDefButBitS(block, TOG, R_BACKBUF, B_NOP,"Backbuf",    10, 94, 80, 20, &G.scene->r.bufflag, 0, 0, 0, 0, "Enable/Disable use of Backbuf image");        
1100         uiDefButBitI(block, TOG, R_THREADS, B_NOP,"Threads",    10, 68, 80, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable/Disable render in two threads");  
1101         uiBlockSetCol(block, TH_AUTO);
1102                 
1103         uiBlockBeginAlign(block);
1104         for(b=2; b>=0; b--)
1105                 for(a=0; a<3; a++)
1106                         uiDefButBitS(block, TOG, 1<<(3*b+a), 800,"",    (short)(10+18*a),(short)(10+14*b),16,12, &G.winpos, 0, 0, 0, 0, "Render window placement on screen");
1107         uiBlockEndAlign(block);
1108
1109         uiBlockBeginAlign(block);
1110         uiDefButS(block, ROW, B_REDR, "DispWin",        72, 10, 60, 20, &G.displaymode, 0.0, (float)R_DISPLAYWIN, 0, 0, "Sets render output to display in a seperate window");
1111         uiDefButS(block, ROW, B_REDR, "DispView",       134, 10, 60, 20, &G.displaymode, 0.0, (float)R_DISPLAYVIEW, 0, 0, "Sets render output to display in 3D view");
1112         uiBlockEndAlign(block);
1113
1114         uiDefButBitS(block, TOG, R_EXTENSION, 0, "Extensions", 205, 10, 105, 19, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds extensions to the output when rendering animations");
1115
1116         /* Dither control */
1117         uiDefButF(block, NUM,B_DIFF, "Dither:",         205,31,105,19, &G.scene->r.dither_intensity, 0.0, 2.0, 0, 0, "The amount of dithering noise present in the output image (0.0 = no dithering)");
1118         
1119         /* Toon shading buttons */
1120         uiBlockBeginAlign(block);
1121         uiDefButBitI(block, TOG, R_EDGE, 0,"Edge",   100, 94, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon edge shading");
1122         uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 170, 94, 140, 20, "Display edge settings");
1123         
1124         /* postprocess render buttons */
1125         uiBlockBeginAlign(block);
1126 //      if(R.rectftot)
1127 //              uiDefIconTextButBitI(block, TOG, R_FBUF, B_NOP, ICON_IMAGE_DEHLT," Fbuf", 100, 68, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Keep RGBA float buffer after render; buffer available");
1128 //      else
1129 //              uiDefButBitI(block, TOG, R_FBUF, 0,"Fbuf",  100, 68, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Keep RGBA float buffer after render, no buffer available now");
1130         uiDefBlockBut(block, post_render_menu, NULL, "Post process", 170, 68, 140, 20, "Applies on RGBA floats while render or with Fbuf available");
1131         uiBlockEndAlign(block);
1132         
1133         /* removed, for time being unified and normal render will use same gamma for blending (2.0) */
1134         //if (G.scene->r.mode & R_GAMMA) {
1135         //      uiDefButF(block, NUMSLI, B_NOP,"Gamma:",                10, 68, 142, 20,
1136         //                       &(G.scene->r.gamma), 0.2, 5.0, B_GAMMASLI, 0,
1137         //                       "The gamma value for blending oversampled images (1.0 = no correction).");
1138         //}
1139 }
1140
1141 static void render_panel_render(void)
1142 {
1143         uiBlock *block;
1144         char str[256];
1145
1146         block= uiNewBlock(&curarea->uiblocks, "render_panel_render", UI_EMBOSS, UI_HELV, curarea->win);
1147         if(uiNewPanel(curarea, block, "Render", "Render", 320, 0, 318, 204)==0) return;
1148
1149         uiBlockBeginAlign(block);
1150         uiDefBut(block, BUT,B_DORENDER,"RENDER",        369, 164, 191,37, 0, 0, 0, 0, 0, "Start the rendering");
1151         /* yafray: on request, render engine menu is back again, and moved to Render panel */
1152         uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0|YafRay %x1", 
1153                                                                                                 369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");        
1154
1155         uiBlockBeginAlign(block);
1156         uiDefButBitI(block, TOG, R_OSA, 0, "OSA",               369,109,122,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)");
1157         uiDefButS(block, ROW,B_DIFF,"5",                        369,88,29,20,&G.scene->r.osa,2.0,5.0, 0, 0, "Sets oversample level to 5");
1158         uiDefButS(block, ROW,B_DIFF,"8",                        400,88,29,20,&G.scene->r.osa,2.0,8.0, 0, 0, "Sets oversample level to 8 (Recommended)");
1159         uiDefButS(block, ROW,B_DIFF,"11",                       431,88,29,20,&G.scene->r.osa,2.0,11.0, 0, 0, "Sets oversample level to 11");
1160         uiDefButS(block, ROW,B_DIFF,"16",                       462,88,29,20,&G.scene->r.osa,2.0,16.0, 0, 0, "Sets oversample level to 16");
1161         uiBlockEndAlign(block);
1162
1163         uiBlockBeginAlign(block);
1164         uiDefButBitI(block, TOG, R_MBLUR, 0, "MBLUR",   496,109,64,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Motion Blur calculation");
1165         uiDefButF(block, NUM,B_DIFF,"Bf:",                      496,88,64,20,&G.scene->r.blurfac, 0.01, 5.0, 10, 2, "Sets motion blur factor");
1166         uiBlockEndAlign(block);
1167
1168         uiBlockBeginAlign(block);
1169         uiDefButS(block, NUM,B_DIFF,"Xparts:",          369,46,95,29,&G.scene->r.xparts,2.0, 64.0, 0, 0, "Sets the number of horizontal parts to render image in (For panorama sets number of camera slices)");
1170         uiDefButS(block, NUM,B_DIFF,"Yparts:",          465,46,95,29,&G.scene->r.yparts,2.0, 64.0, 0, 0, "Sets the number of vertical parts to render image in");
1171         uiBlockEndAlign(block);
1172
1173         uiBlockBeginAlign(block);
1174         uiDefButS(block, ROW,800,"Sky",         369,13,35,20,&G.scene->r.alphamode,3.0,0.0, 0, 0, "Fill background with sky");
1175         uiDefButS(block, ROW,800,"Premul",      405,13,50,20,&G.scene->r.alphamode,3.0,1.0, 0, 0, "Multiply alpha in advance");
1176         uiDefButS(block, ROW,800,"Key",         456,13,35,20,&G.scene->r.alphamode,3.0,2.0, 0, 0, "Alpha and colour values remain unchanged");
1177         uiBlockEndAlign(block);
1178
1179         if(G.scene->r.mode & R_RAYTRACE)
1180                 uiDefButS(block, MENU, B_DIFF,"Octree resolution %t|64 %x64|128 %x128|256 %x256|512 %x512",     496,13,64,20,&G.scene->r.ocres,0.0,0.0, 0, 0, "Octree resolution for ray tracing");
1181
1182         uiBlockBeginAlign(block);
1183         uiDefButBitI(block, TOG, R_SHADOW, 0,"Shadow",  565,172,60,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable shadow calculation");
1184         uiDefButBitI(block, TOG, R_ENVMAP, 0,"EnvMap",  627,172,60,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable environment map rendering");
1185         uiDefButBitI(block, TOG, R_PANORAMA, 0,"Pano",  565,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable panorama rendering (output width is multiplied by Xparts)");
1186         uiDefButBitI(block, TOG, R_RAYTRACE, B_REDR,"Ray",606,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable ray tracing");
1187         uiDefButBitI(block, TOG, R_RADIO, 0,"Radio",    647,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable radiosity rendering");
1188         uiBlockEndAlign(block);
1189         
1190         uiBlockBeginAlign(block);
1191         uiDefButS(block, ROW,B_DIFF,"100%",                     565,109,122,20,&G.scene->r.size,1.0,100.0, 0, 0, "Set render size to defined size");
1192         uiDefButS(block, ROW,B_DIFF,"75%",                      565,88,40,20,&G.scene->r.size,1.0,75.0, 0, 0, "Set render size to 3/4 of defined size");
1193         uiDefButS(block, ROW,B_DIFF,"50%",                      606,88,40,20,&G.scene->r.size,1.0,50.0, 0, 0, "Set render size to 1/2 of defined size");
1194         uiDefButS(block, ROW,B_DIFF,"25%",                      647,88,40,20,&G.scene->r.size,1.0,25.0, 0, 0, "Set render size to 1/4 of defined size");
1195         uiBlockEndAlign(block);
1196
1197         uiBlockBeginAlign(block);
1198         uiDefButBitI(block, TOG, R_FIELDS, 0,"Fields",  565,55,60,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables field rendering");
1199         uiDefButBitI(block, TOG, R_ODDFIELD, 0,"Odd",   627,55,39,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Odd field first rendering (Default: Even field)");
1200         uiDefButBitI(block, TOG, R_FIELDSTILL, 0,"X",           668,55,19,20,&G.scene->r.mode, 0, 0, 0, 0, "Disables time difference in field calculations");
1201         
1202         sprintf(str, "Filter%%t|Box %%x%d|Tent %%x%d|Quad %%x%d|Cubic %%x%d|Gauss %%x%d|CatRom %%x%d|Mitch %%x%d", R_FILTER_BOX, R_FILTER_TENT, R_FILTER_QUAD, R_FILTER_CUBIC, R_FILTER_GAUSS, R_FILTER_CATROM, R_FILTER_MITCH);
1203         uiDefButS(block, MENU, B_DIFF,str,              565,34,60,20, &G.scene->r.filtertype, 0, 0, 0, 0, "Set sampling filter for antialiasing");
1204         uiDefButF(block, NUM,B_DIFF,"",                 627,34,60,20,&G.scene->r.gauss,0.5, 1.5, 10, 2, "Sets the filter size");
1205         
1206         uiDefButBitI(block, TOG, R_BORDER, REDRAWVIEWCAM, "Border",     565,13,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Render a small cut-out of the image");
1207         uiDefButBitI(block, TOG, R_GAMMA, B_REDR, "Gamma",      627,13,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction");
1208         uiBlockEndAlign(block);
1209
1210 }
1211
1212 static void render_panel_anim(void)
1213 {
1214         uiBlock *block;
1215
1216
1217         block= uiNewBlock(&curarea->uiblocks, "render_panel_anim", UI_EMBOSS, UI_HELV, curarea->win);
1218         if(uiNewPanel(curarea, block, "Anim", "Render", 640, 0, 318, 204)==0) return;
1219
1220
1221         uiDefBut(block, BUT,B_DOANIM,"ANIM",            692,142,192,47, 0, 0, 0, 0, 0, "Start rendering a sequence");
1222
1223         uiBlockSetCol(block, TH_BUT_SETTING1);
1224         uiBlockBeginAlign(block);
1225         uiDefButBitS(block, TOG, R_DOSEQ, B_NOP, "Do Sequence",692,114,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Enables sequence output rendering (Default: 3D rendering)");
1226         uiDefButBitS(block, TOG, R_DOCOMP, B_NOP, "Do Composit",692,90,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Uses compositing nodes for output rendering");
1227         uiBlockEndAlign(block);
1228
1229         uiBlockSetCol(block, TH_AUTO);
1230         uiDefBut(block, BUT,B_PLAYANIM, "PLAY",692,40,94,33, 0, 0, 0, 0, 0, "Play animation of rendered images/avi (searches Pics: field)");
1231         uiDefButS(block, NUM, B_RTCHANGED, "rt:",789,40,95,33, &G.rt, -1000.0, 1000.0, 0, 0, "General testing/debug button");
1232
1233         uiBlockBeginAlign(block);
1234         uiDefButS(block, NUM,REDRAWSEQ,"Sta:",692,10,94,24, &G.scene->r.sfra,1.0,MAXFRAMEF, 0, 0, "The start frame of the animation");
1235         uiDefButS(block, NUM,REDRAWSEQ,"End:",789,10,95,24, &G.scene->r.efra,1.0,MAXFRAMEF, 0, 0, "The end  frame of the animation");
1236         uiBlockEndAlign(block);
1237 }
1238
1239 static void render_panel_format(void)
1240 {
1241         uiBlock *block;
1242         int yofs;
1243
1244
1245         block= uiNewBlock(&curarea->uiblocks, "render_panel_format", UI_EMBOSS, UI_HELV, curarea->win);
1246         if(uiNewPanel(curarea, block, "Format", "Render", 960, 0, 318, 204)==0) return;
1247         uiDefBlockBut(block, framing_render_menu, NULL, 
1248                                   "Game framing settings", 
1249                                   892, 169, 227, 20, "Display game framing settings");
1250         /* uiDefIconTextBlockBut(block, framing_render_menu, NULL, 
1251                                                    ICON_BLOCKBUT_CORNER, 
1252                                                    "Game framing settings", 
1253                                                    892, 169, 227, 20, 
1254                                                    "Display game framing settings"); */
1255
1256         uiBlockBeginAlign(block);
1257         uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeX:",    892 ,136,112,27, &G.scene->r.xsch, 4.0, 10000.0, 0, 0, "The image width in pixels");
1258         uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeY:",    1007,136,112,27, &G.scene->r.ysch, 4.0,10000.0, 0, 0, "The image height in scanlines");
1259         uiDefButS(block, NUM,REDRAWVIEWCAM,"AspX:",     892 ,114,112,20, &G.scene->r.xasp, 1.0,200.0, 0, 0, "The horizontal aspect ratio");
1260         uiDefButS(block, NUM,REDRAWVIEWCAM,"AspY:",     1007,114,112,20, &G.scene->r.yasp, 1.0,200.0, 0, 0, "The vertical aspect ratio");
1261         uiBlockEndAlign(block);
1262
1263         yofs = 54;
1264
1265 #ifdef __sgi
1266         yofs = 76;
1267         uiDefButS(block, NUM,B_DIFF,"MaxSize:",                 892,32,165,20, &G.scene->r.maximsize, 0.0, 500.0, 0, 0, "Maximum size per frame to save in an SGI movie");
1268         uiDefButBitI(block, TOG, R_COSMO, 0,"Cosmo",    1059,32,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Attempt to save SGI movies using Cosmo hardware");
1269 #endif
1270
1271         
1272         uiDefButS(block, MENU,B_FILETYPEMENU,imagetype_pup(),   892,yofs,174,20, &G.scene->r.imtype, 0, 0, 0, 0, "Images are saved in this file format");
1273         uiDefButBitI(block, TOG, R_MOVIECROP, B_DIFF, "Crop",   1068,yofs,51,20, &G.scene->r.mode, 0, 0, 0, 0, "Exclude border rendering from total image");
1274
1275         yofs -= 22;
1276
1277         if(G.scene->r.quality==0) G.scene->r.quality= 90;
1278
1279 #ifdef WITH_QUICKTIME
1280         if (G.scene->r.imtype == R_AVICODEC || G.scene->r.imtype == R_QUICKTIME) {
1281 #else /* WITH_QUICKTIME */
1282         if (0) {
1283 #endif
1284                 if(G.scene->r.imtype == R_QUICKTIME) {
1285 #ifdef WITH_QUICKTIME
1286 #if defined (_WIN32) || defined (__APPLE__)
1287                         //glColor3f(0.65, 0.65, 0.7);
1288                         //glRecti(892,yofs+46,892+225,yofs+45+20);
1289                         if(G.scene->r.qtcodecdata == NULL)
1290                                 uiDefBut(block, LABEL, 0, "Codec: not set",  892,yofs+44,225,20, 0, 0, 0, 0, 0, "");
1291                         else
1292                                 uiDefBut(block, LABEL, 0, G.scene->r.qtcodecdata->qtcodecname,  892,yofs+44,225,20, 0, 0, 0, 0, 0, "");
1293                         uiDefBut(block, BUT,B_SELECTCODEC, "Set codec",  892,yofs,112,20, 0, 0, 0, 0, 0, "Set codec settings for Quicktime");
1294 #endif
1295 #endif /* WITH_QUICKTIME */
1296                 } else {
1297 #ifdef _WIN32
1298                         //glColor3f(0.65, 0.65, 0.7);
1299                         //glRecti(892,yofs+46,892+225,yofs+45+20);
1300                         if(G.scene->r.avicodecdata == NULL)
1301                                 uiDefBut(block, LABEL, 0, "Codec: not set.",  892,yofs+43,225,20, 0, 0, 0, 0, 0, "");
1302                         else
1303                                 uiDefBut(block, LABEL, 0, avicodec_str(),  892,yofs+43,225,20, 0, 0, 0, 0, 0, "");
1304 #endif
1305                         uiDefBut(block, BUT,B_SELECTCODEC, "Set codec",  892,yofs,112,20, 0, 0, 0, 0, 0, "Set codec settings for AVI");
1306                 }
1307 #ifdef WITH_OPENEXR
1308         } 
1309         else if (G.scene->r.imtype == R_OPENEXR ) {
1310                 if (G.scene->r.quality > 5) G.scene->r.quality = 0;
1311                 
1312                 uiBlockBeginAlign(block);
1313                 uiDefButBitS(block, TOG, R_OPENEXR_HALF, B_NOP,"Half",  892,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Use 16 bits float 'Half' type");
1314                 uiDefButBitS(block, TOG, R_OPENEXR_ZBUF, B_NOP,"Zbuf",  952,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Save the zbuffer as 32 bits unsigned int");
1315                 uiBlockEndAlign(block);
1316                 
1317                 uiDefButS(block, MENU,B_NOP, "Codec %t|None %x0|Pxr24 (lossy) %x1|ZIP (lossless) %x2|PIZ (lossless) %x3|RLE (lossless) %x4",  
1318                                                                                                                         892,yofs,112,20, &G.scene->r.quality, 0, 0, 0, 0, "Set codec settings for OpenEXR");
1319                 
1320 #endif
1321         } else {
1322                 if(G.scene->r.quality < 5) G.scene->r.quality = 90;     /* restore from openexr */
1323                 
1324                 uiDefButS(block, NUM,B_DIFF, "Quality:",           892,yofs,112,20, &G.scene->r.quality, 10.0, 100.0, 0, 0, "Quality setting for JPEG images, AVI Jpeg and SGI movies");
1325         }
1326         uiDefButS(block, NUM,B_FRAMEMAP,"Frs/sec:",   1006,yofs,113,20, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");
1327
1328
1329         uiBlockBeginAlign(block);
1330         uiDefButS(block, ROW,B_DIFF,"BW",                       892, 10,74,19, &G.scene->r.planes, 5.0,(float)R_PLANESBW, 0, 0, "Images are saved with BW (grayscale) data");
1331         uiDefButS(block, ROW,B_DIFF,"RGB",                  968, 10,74,19, &G.scene->r.planes, 5.0,(float)R_PLANES24, 0, 0, "Images are saved with RGB (color) data");
1332         uiDefButS(block, ROW,B_DIFF,"RGBA",                1044, 10,75,19, &G.scene->r.planes, 5.0,(float)R_PLANES32, 0, 0, "Images are saved with RGB and Alpha data (if supported)");
1333
1334         uiBlockBeginAlign(block);
1335         uiDefBut(block, BUT,B_PR_PAL, "PAL",            1146,170,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x576, Aspect ratio - 54x51, 25 fps");
1336         uiDefBut(block, BUT,B_PR_NTSC, "NTSC",          1146,150,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x480, Aspect ratio - 10x11, 30 fps");
1337         uiDefBut(block, BUT,B_PR_PRESET, "Default",     1146,130,100,18, 0, 0, 0, 0, 0, "Same as PAL, with render settings (OSA, Shadows, Fields)");
1338         uiDefBut(block, BUT,B_PR_PRV, "Preview",        1146,110,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x512, Render size 50%");
1339         uiDefBut(block, BUT,B_PR_PC, "PC",                      1146,90,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x480, Aspect ratio - 100x100");
1340         uiDefBut(block, BUT,B_PR_PAL169, "PAL 16:9",1146,70,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x576, Aspect ratio - 64x45");
1341         uiDefBut(block, BUT,B_PR_PANO, "PANO",          1146,50,100,18, 0, 0, 0, 0, 0, "Standard panorama settings");
1342         uiDefBut(block, BUT,B_PR_FULL, "FULL",          1146,30,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 1280x1024, Aspect ratio - 1x1");
1343         uiDefButBitI(block, TOG, R_UNIFIED, B_REDR, "Unified Renderer", 1146,10,100,18,  &G.scene->r.mode, 0, 0, 0, 0, "Use the unified renderer.");
1344         uiBlockEndAlign(block);
1345 }
1346
1347
1348 /* yafray: global illumination options panel */
1349 static void render_panel_yafrayGI()
1350 {
1351         uiBlock *block;
1352
1353         block= uiNewBlock(&curarea->uiblocks, "render_panel_yafrayGI", UI_EMBOSS, UI_HELV, curarea->win);
1354         uiNewPanelTabbed("Render", "Render");
1355         if(uiNewPanel(curarea, block, "YafRay GI", "Render", 320, 0, 318, 204)==0) return;
1356
1357         // label to force a boundbox for buttons not to be centered
1358         uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
1359
1360         uiDefBut(block, LABEL, 0, "Method", 5,175,70,20, 0, 1.0, 0, 0, 0, "");
1361         uiDefButS(block, MENU, B_REDR, "GiMethod %t|None %x0|SkyDome %x1|Full %x2", 70,175,89,20, &G.scene->r.GImethod, 0, 0, 0, 0, "Global Illumination Method");
1362
1363         uiDefBut(block, LABEL, 0, "Quality", 5,150,70,20, 0, 1.0, 0, 0, 0, "");
1364         uiDefButS(block, MENU, B_REDR, "GiQuality %t|None %x0|Low %x1|Medium %x2 |High %x3|Higher %x4|Best %x5|Use Blender AO settings %x6", 70,150,89,20, &G.scene->r.GIquality, 0, 0, 0, 0, "Global Illumination Quality");
1365
1366         if (G.scene->r.GImethod>0) {
1367                 uiDefButF(block, NUM, B_DIFF, "EmitPwr:", 5,35,154,20, &G.scene->r.GIpower, 0.01, 100.0, 10, 0, "arealight, material emit and background intensity scaling, 1 is normal");
1368                 if (G.scene->r.GImethod==2) uiDefButF(block, NUM, B_DIFF, "GI Pwr:", 5,10,154,20, &G.scene->r.GIindirpower, 0.01, 100.0, 10, 0, "GI indirect lighting intensity scaling, 1 is normal");
1369         }
1370
1371         if (G.scene->r.GImethod>0)
1372         {
1373                 if (G.scene->r.GIdepth==0) G.scene->r.GIdepth=2;
1374
1375                 if (G.scene->r.GImethod==2) {
1376                         uiDefButI(block, NUM, B_DIFF, "Depth:", 180,175,110,20, &G.scene->r.GIdepth, 1.0, 100.0, 10, 10, "Number of bounces of the indirect light");
1377                         uiDefButI(block, NUM, B_DIFF, "CDepth:", 180,150,110,20, &G.scene->r.GIcausdepth, 1.0, 100.0, 10, 10, "Number of bounces inside objects (for caustics)");
1378                         uiDefButBitS(block, TOG, 1,  B_REDR, "Photons",210,125,100,20, &G.scene->r.GIphotons, 0, 0, 0, 0, "Use global photons to help in GI");
1379                 }
1380
1381                 uiDefButBitS(block, TOG, 1, B_REDR, "Cache",6,125,95,20, &G.scene->r.GIcache, 0, 0, 0, 0, "Cache occlusion/irradiance samples (faster)");
1382                 if (G.scene->r.GIcache) 
1383                 {
1384                         uiDefButBitS(block,TOG, 1, B_REDR, "NoBump",108,125,95,20, &G.scene->r.YF_nobump, 0, 0, 0, 0, "Don't use bumpnormals for cache (faster, but no bumpmapping in total indirectly lit areas)");
1385                         uiDefBut(block, LABEL, 0, "Cache parameters:", 5,105,130,20, 0, 1.0, 0, 0, 0, "");
1386                         if (G.scene->r.GIshadowquality==0.0) G.scene->r.GIshadowquality=0.9;
1387                         uiDefButF(block, NUM, B_DIFF,"ShadQu:", 5,85,154,20,    &(G.scene->r.GIshadowquality), 0.01, 1.0 ,1,0, "Sets the shadow quality, keep it under 0.95 :-) ");
1388                         if (G.scene->r.GIpixelspersample==0) G.scene->r.GIpixelspersample=10;
1389                         uiDefButI(block, NUM, B_DIFF, "Prec:",  5,60,75,20, &G.scene->r.GIpixelspersample, 1, 50, 10, 10, "Maximum number of pixels without samples, the lower the better and slower");
1390                         if (G.scene->r.GIrefinement==0) G.scene->r.GIrefinement=1.0;
1391                         uiDefButF(block, NUM, B_DIFF, "Ref:", 84,60,75,20, &G.scene->r.GIrefinement, 0.001, 1.0, 1, 0, "Threshold to refine shadows EXPERIMENTAL. 1 = no refinement");
1392                 }
1393
1394                 if (G.scene->r.GImethod==2) {
1395                         if (G.scene->r.GIphotons)
1396                         {
1397                                 uiDefBut(block, LABEL, 0, "Photon parameters:", 170,105,130,20, 0, 1.0, 0, 0, 0, "");
1398                                 if(G.scene->r.GIphotoncount==0) G.scene->r.GIphotoncount=100000;
1399                                 uiDefButI(block, NUM, B_DIFF, "Count:", 170,85,140,20, &G.scene->r.GIphotoncount, 
1400                                                 0, 10000000, 10, 10, "Number of photons to shoot");
1401                                 if(G.scene->r.GIphotonradius==0.0) G.scene->r.GIphotonradius=1.0;
1402                                 uiDefButF(block, NUMSLI, B_DIFF,"Radius:", 170,60,140,20,       &(G.scene->r.GIphotonradius), 
1403                                                 0.00001, 100.0 ,0,0, "Radius to search for photons to mix (blur)");
1404                                 if(G.scene->r.GImixphotons==0) G.scene->r.GImixphotons=100;
1405                                 uiDefButI(block, NUM, B_DIFF, "MixCount:", 170,35,140,20, &G.scene->r.GImixphotons, 
1406                                                 0, 1000, 10, 10, "Number of photons to mix");
1407                                 uiDefButBitS(block, TOG, 1, B_REDR, "Tune Photons",170,10,140,20, &G.scene->r.GIdirect, 
1408                                                 0, 0, 0, 0, "Show the photonmap directly in the render for tuning");
1409                         }
1410                 }
1411
1412         }
1413 }
1414
1415 /* yafray: global  options panel */
1416 static void render_panel_yafrayGlobal()
1417 {
1418         uiBlock *block;
1419
1420         block= uiNewBlock(&curarea->uiblocks, "render_panel_yafrayGlobal", UI_EMBOSS, UI_HELV, curarea->win);
1421         uiNewPanelTabbed("Render", "Render");
1422         if(uiNewPanel(curarea, block, "YafRay", "Render", 320, 0, 318, 204)==0) return;
1423
1424         // label to force a boundbox for buttons not to be centered
1425         uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
1426
1427         uiDefButBitS(block, TOGN, 1, B_REDR, "xml", 5,180,75,20, &G.scene->r.YFexportxml,
1428                                         0, 0, 0, 0, "Export to an xml file and call yafray instead of plugin");
1429
1430         uiDefButF(block, NUMSLI, B_DIFF,"Bi ", 5,35,150,20,     &(G.scene->r.YF_raybias), 
1431                                 0.0, 10.0 ,0,0, "Shadow ray bias to avoid self shadowing");
1432         uiDefButI(block, NUM, B_DIFF, "Raydepth ", 5,60,150,20,
1433                                 &G.scene->r.YF_raydepth, 1.0, 80.0, 10, 10, "Maximum render ray depth from the camera");
1434         uiDefButF(block, NUMSLI, B_DIFF, "Gam ", 5,10,150,20, &G.scene->r.YF_gamma, 0.001, 5.0, 0, 0, "Gamma correction, 1 is off");
1435         uiDefButF(block, NUMSLI, B_DIFF, "Exp ", 160,10,150,20,&G.scene->r.YF_exposure, 0.0, 10.0, 0, 0, "Exposure adjustment, 0 is off");
1436         
1437         uiDefButI(block, NUM, B_DIFF, "Processors:", 160,60,150,20, &G.scene->r.YF_numprocs, 1.0, 8.0, 10, 10, "Number of processors to use");
1438
1439         /*AA Settings*/
1440         uiDefButBitS(block, TOGN, 1, B_REDR, "Auto AA", 5,140,150,20, &G.scene->r.YF_AA, 
1441                                         0, 0, 0, 0, "Set AA using OSA and GI quality, disable for manual control");
1442         uiDefButBitS(block, TOGN, 1, B_DIFF, "Clamp RGB", 160,140,150,20, &G.scene->r.YF_clamprgb, 1.0, 8.0, 10, 10, "For AA on fast high contrast changes. Not advisable for Bokeh! Dulls lens shape detail.");
1443         if(G.scene->r.YF_AA){
1444                 uiDefButI(block, NUM, B_DIFF, "AA Passes ", 5,115,150,20, &G.scene->r.YF_AApasses, 0, 64, 10, 10, "Number of AA passes (0 is no AA)");
1445                 uiDefButI(block, NUM, B_DIFF, "AA Samples ", 160,115,150,20, &G.scene->r.YF_AAsamples, 0, 2048, 10, 10, "Number of samples per pass");
1446                 uiDefButF(block, NUMSLI, B_DIFF, "Psz ", 5,90,150,20, &G.scene->r.YF_AApixelsize, 1.0, 2.0, 0, 0, "AA pixel filter size");
1447                 uiDefButF(block, NUMSLI, B_DIFF, "Thr ", 160,90,150,20, &G.scene->r.YF_AAthreshold, 0.000001, 1.0, 0, 0, "AA threshold");
1448         }
1449 }
1450
1451 #if 0
1452 static void render_panel_sfx(void)
1453 {
1454         uiBlock *block;
1455         
1456         block= uiNewBlock(&curarea->uiblocks, "editing_panel_camera_dof", UI_EMBOSS, UI_HELV, curarea->win);
1457         uiNewPanelTabbed("Output", "Render");
1458         if(uiNewPanel(curarea, block, "Post Effects", "Render", 320, 0, 318, 204)==0) return;
1459         
1460         uiBlockBeginAlign(block);
1461         uiDefButBitI(block, TOG, R_ZBLUR,B_SET_ZBLUR,"Zblur",   10,180,140,20,&G.scene->r.mode,0,0, 0, 0, "Apply blur based on depth values in z-buffer");
1462         uiDefButF(block, NUM,B_DIFF, "ZMin:",           10,160,140,20, &G.scene->r.zmin, 0.0, 1.0, 0, 0, "Specify the start distance with maximum blur");                               
1463         uiDefButF(block, NUM,B_DIFF, "Focus:",          10,140,140,20, &G.scene->r.focus, 0.0, 1.0, 0, 0, "Specify the focus distance (not blurred)");
1464         uiDefButF(block, NUM,B_DIFF, "Blur:",           10,120,140,20, &G.scene->r.zblur, 1.0, 100.0, 0, 0, "Specify the maximum blur radius"); 
1465         uiDefButF(block, NUM,B_DIFF, "Gamma:",          10,100,140,20, &G.scene->r.zgamma, 0.05, 2.0, 0, 0, "Use Gamma corrected addition of colors");
1466         uiDefButF(block, NUM,B_DIFF, "Sigma:",          10,80,140,20, &G.scene->r.zsigma, 1.0, 20.0, 0, 0, "Filter type control, higher value is stronger gaussian");
1467         
1468         /* Toon shading buttons */
1469         uiBlockBeginAlign(block);
1470         uiDefButBitI(block, TOG, R_EDGE, B_SET_EDGE, "Edge",    160, 180, 150, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon edge shading");
1471         uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 160, 160, 150, 20, "Display edge settings");
1472         
1473         /* postprocess render buttons */
1474         uiBlockBeginAlign(block);
1475         if(R.rectftot)
1476                 uiDefIconTextButI(block, TOG, R_FBUF, B_NOP, ICON_IMAGE_DEHLT," Fbuf", 160, 130, 150, 20, &G.scene->r.mode, 0, 0, 0, 0, "Keep RGBA float buffer after render; buffer available");
1477         else
1478                 uiDefButBitI(block, TOG, R_FBUF, 0,"Fbuf",              160, 130, 150, 20, &G.scene->r.mode, 0, 0, 0, 0, "Keep RGBA float buffer after render, no buffer available now");
1479         uiDefBlockBut(block, post_render_menu, NULL, "Post process", 160, 110, 150, 20, "Applies on RGBA floats while render or with Fbuf available");
1480         uiBlockEndAlign(block);
1481         
1482         /* Dither control */
1483         uiDefButF(block, NUM,B_DIFF, "Dither:",                 160,80,150,20, &G.scene->r.dither_intensity, 0.0, 2.0, 0, 0, "The amount of dithering noise present in the output image (0.0 = no dithering)");
1484         
1485 }
1486 #endif
1487
1488 static void layer_copy_func(void *lay_v, void *lay_p)
1489 {
1490         unsigned int *lay= lay_p;
1491         int laybit= (int)lay_v;
1492
1493         if(G.qual & LR_SHIFTKEY) {
1494                 if(*lay==0) *lay= 1<<laybit;
1495         }
1496         else
1497                 *lay= 1<<laybit;
1498         
1499         copy_view3d_lock(REDRAW);
1500         allqueue(REDRAWBUTSSCENE, 0);
1501 }
1502
1503 static void delete_scene_layer_func(void *srl_v, void *unused1)
1504 {
1505         if(BLI_countlist(&G.scene->r.layers)>1) {
1506                 BLI_remlink(&G.scene->r.layers, srl_v);
1507                 MEM_freeN(srl_v);
1508                 G.scene->r.actlay= 0;
1509                 
1510                 allqueue(REDRAWBUTSSCENE, 0);
1511                 allqueue(REDRAWNODE, 0);
1512         }
1513 }
1514
1515 static void rename_scene_layer_func(void *srl_v, void *unused_v)
1516 {
1517         if(G.scene->nodetree) {
1518                 SceneRenderLayer *srl= srl_v;
1519                 bNode *node;
1520                 for(node= G.scene->nodetree->nodes.first; node; node= node->next) {
1521                         if(node->type==CMP_NODE_R_RESULT) {
1522                                 if(node->custom1==G.scene->r.actlay)
1523                                         BLI_strncpy(node->name, srl->name, NODE_MAXSTR);
1524                         }
1525                 }
1526         }
1527         allqueue(REDRAWNODE, 0);
1528 }
1529
1530 static char *scene_layer_menu(void)
1531 {
1532         SceneRenderLayer *srl;
1533         int len= 32 + 32*BLI_countlist(&G.scene->r.layers);
1534         short a, nr;
1535         char *str= MEM_callocN(len, "menu layers");
1536         
1537         strcpy(str, "ADD NEW %x32767");
1538         a= strlen(str);
1539         for(nr=0, srl= G.scene->r.layers.first; srl; srl= srl->next, nr++) {
1540                 a+= sprintf(str+a, "|%s %%x%d", srl->name, nr);
1541         }
1542         
1543         return str;
1544 }
1545
1546 static void draw_3d_layer_buttons(uiBlock *block, unsigned int *poin, short xco, short yco, short dx, short dy, int event)
1547 {
1548         uiBut *bt;
1549         long a;
1550         
1551         uiBlockBeginAlign(block);
1552         for(a=0; a<5; a++) {
1553                 bt= uiDefButBitI(block, TOG, 1<<a, B_NOP, "",   (short)(xco+a*(dx/2)), yco+dy/2, (short)(dx/2), (short)(dy/2), poin, 0, 0, 0, 0, "");
1554                 uiButSetFunc(bt, layer_copy_func, (void *)a, poin);
1555         }
1556         for(a=0; a<5; a++) {
1557                 bt=uiDefButBitI(block, TOG, 1<<(a+10), B_NOP, "",       (short)(xco+a*(dx/2)), yco, (short)(dx/2), (short)(dy/2), poin, 0, 0, 0, 0, "");
1558                 uiButSetFunc(bt, layer_copy_func, (void *)(a+10), poin);
1559         }
1560         
1561         xco+= 7;
1562         uiBlockBeginAlign(block);
1563         for(a=5; a<10; a++) {
1564                 bt=uiDefButBitI(block, TOG, 1<<a, B_NOP, "",    (short)(xco+a*(dx/2)), yco+dy/2, (short)(dx/2), (short)(dy/2), poin, 0, 0, 0, 0, "");
1565                 uiButSetFunc(bt, layer_copy_func, (void *)a, poin);
1566         }
1567         for(a=5; a<10; a++) {
1568                 bt=uiDefButBitI(block, TOG, 1<<(a+10), B_NOP, "",       (short)(xco+a*(dx/2)), yco, (short)(dx/2), (short)(dy/2), poin, 0, 0, 0, 0, "");
1569                 uiButSetFunc(bt, layer_copy_func, (void *)(a+10), poin);
1570         }
1571         
1572         uiBlockEndAlign(block);
1573 }
1574
1575 static void render_panel_layers(void)
1576 {
1577         uiBlock *block;
1578         uiBut *bt;
1579         SceneRenderLayer *srl= BLI_findlink(&G.scene->r.layers, G.scene->r.actlay);
1580         char *strp;
1581         
1582         block= uiNewBlock(&curarea->uiblocks, "render_panel_layers", UI_EMBOSS, UI_HELV, curarea->win);
1583         uiNewPanelTabbed("Output", "Render");
1584         if(uiNewPanel(curarea, block, "Render Layers", "Render", 320, 0, 318, 204)==0) return;
1585         
1586         /* first, as reminder, the scene layers */
1587         uiDefBut(block, LABEL, 0, "Scene:",                             10,170,100,20, NULL, 0, 0, 0, 0, "");
1588         
1589         draw_3d_layer_buttons(block, &G.scene->lay, 130, 170, 35, 30, B_LAY);
1590         
1591         /* layer menu, name, delete button */
1592         uiBlockBeginAlign(block);
1593         strp= scene_layer_menu();
1594         uiDefButS(block, MENU, B_ADD_RENDERLAYER, strp, 10,130,23,20, &(G.scene->r.actlay), 0, 0, 0, 0, "Choose Active Render Layer");
1595         MEM_freeN(strp);
1596         
1597         bt= uiDefBut(block, TEX, REDRAWNODE, "",  33,130,252,20, srl->name, 0.0, 31.0, 0, 0, "");
1598         uiButSetFunc(bt, rename_scene_layer_func, srl, NULL);
1599         bt=uiDefIconBut(block, BUT, B_NOP, ICON_X,      285, 130, 25, 20, 0, 0, 0, 0, 0, "Deletes current Render Layer");
1600         uiButSetFunc(bt, delete_scene_layer_func, srl, NULL);
1601         uiBlockEndAlign(block);
1602
1603         /* RenderLayer visible-layers */
1604         uiDefBut(block, LABEL, 0, "Layer:",     10,95,100,20, NULL, 0, 0, 0, 0, "");
1605         draw_3d_layer_buttons(block, &srl->lay,         130, 95, 35, 30, B_NOP);
1606         
1607         uiBlockBeginAlign(block);
1608         uiDefButBitS(block, TOG, SCE_LAY_SOLID, B_NOP,"Solid",  10, 70, 75, 20, &srl->layflag, 0, 0, 0, 0, "Render Solid faces in this Layer"); 
1609         uiDefButBitS(block, TOG, SCE_LAY_ZTRA, B_NOP,"Ztra",    85, 70, 75, 20, &srl->layflag, 0, 0, 0, 0, "Render Z-Transparent faces in this Layer"); 
1610         uiDefButBitS(block, TOG, SCE_LAY_HALO, B_NOP,"Halo",    160, 70, 75, 20, &srl->layflag, 0, 0, 0, 0, "Render Halos in this Layer");      
1611         uiDefButBitS(block, TOG, SCE_LAY_STRAND, B_NOP,"Strand",        235, 70, 75, 20, &srl->layflag, 0, 0, 0, 0, "Render Particle Strands in this Layer");   
1612         uiBlockEndAlign(block);
1613
1614         uiDefBut(block, LABEL, 0, "Passes:",                                    10,30,150,20, NULL, 0, 0, 0, 0, "");
1615         uiBlockBeginAlign(block);
1616         uiDefButBitS(block, TOG, SCE_PASS_COMBINED, B_NOP,"Combined",   130, 30, 155, 20, &srl->passflag, 0, 0, 0, 0, "Deliver full combined RGBA buffer");     
1617         uiDefButBitS(block, TOG, SCE_PASS_Z, B_NOP,"Z",                 285, 30, 25, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Z values pass");  
1618         
1619         uiDefButBitS(block, TOG, SCE_PASS_DIFFUSE, B_NOP,"Diff",10, 10, 45, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Diffuse pass");    
1620         uiDefButBitS(block, TOG, SCE_PASS_SPEC, B_NOP,"Spec",   55, 10, 45, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Diffuse pass");    
1621         uiDefButBitS(block, TOG, SCE_PASS_SHADOW, B_NOP,"Shad", 100, 10, 45, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Diffuse pass");   
1622         uiDefButBitS(block, TOG, SCE_PASS_AO, B_NOP,"AO",               145, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Diffuse pass");   
1623         uiDefButBitS(block, TOG, SCE_PASS_MIRROR, B_NOP,"Mirr", 185, 10, 45, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Diffuse pass");   
1624         uiDefButBitS(block, TOG, SCE_PASS_NORMAL, B_NOP,"Nor",  230, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Diffuse pass");   
1625         uiDefButBitS(block, TOG, SCE_PASS_VECTOR, B_NOP,"Vec",  270, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Diffuse pass");   
1626 }       
1627
1628 void render_panels()
1629 {
1630
1631         render_panel_output();
1632 //      render_panel_sfx();
1633         render_panel_layers();
1634         render_panel_render();
1635         render_panel_anim();
1636         render_panel_format();
1637         /* yafray: GI & Global panel, only available when yafray enabled for rendering */
1638         if (G.scene->r.renderer==R_YAFRAY) {
1639                 if (G.scene->r.YF_gamma==0.0) G.scene->r.YF_gamma=1.0;
1640                 if (G.scene->r.YF_raybias==0.0) G.scene->r.YF_raybias=0.001;
1641                 if (G.scene->r.YF_raydepth==0) G.scene->r.YF_raydepth=5;
1642                 if (G.scene->r.YF_AApixelsize==0.0) G.scene->r.YF_AApixelsize=1.5;
1643                 if (G.scene->r.YF_AAthreshold==0.0) G.scene->r.YF_AAthreshold=0.05;
1644                 if (G.scene->r.GIpower==0.0) G.scene->r.GIpower=1.0;
1645                 if (G.scene->r.GIindirpower==0.0) G.scene->r.GIindirpower=1.0;
1646                 render_panel_yafrayGlobal();
1647                 render_panel_yafrayGI();
1648         }
1649
1650 }
1651
1652 /* --------------------------------------------- */
1653
1654 void anim_panels()
1655 {
1656         uiBlock *block;
1657
1658         block= uiNewBlock(&curarea->uiblocks, "anim_panel", UI_EMBOSS, UI_HELV, curarea->win);
1659         if(uiNewPanel(curarea, block, "Anim", "Anim", 0, 0, 318, 204)==0) return;
1660
1661         uiBlockBeginAlign(block);
1662         uiDefButS(block, NUM,B_FRAMEMAP,"Map Old:",     10,160,150,20,&G.scene->r.framapto,1.0,900.0, 0, 0, "Specify old mapping value in frames");
1663         uiDefButS(block, NUM,B_FRAMEMAP,"Map New:",     160,160,150,20,&G.scene->r.images,1.0,900.0, 0, 0, "Specify how many frames the Map Old will last");
1664
1665         uiBlockBeginAlign(block);
1666         uiDefButS(block, NUM,B_FRAMEMAP,"Frs/sec:",  10,130,150,20, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");
1667         uiDefButBitS(block, TOG, AUDIO_SYNC, B_SOUND_CHANGED, "Sync",160,130,150,20, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio");
1668         
1669         uiBlockBeginAlign(block);
1670         uiDefButS(block, NUM,REDRAWSEQ,"Sta:",  10,100,150,20,&G.scene->r.sfra,1.0,MAXFRAMEF, 0, 0, "Specify the start frame of the animation");
1671         uiDefButS(block, NUM,REDRAWSEQ,"End:",  160,100,150,20,&G.scene->r.efra,1.0,MAXFRAMEF, 0, 0, "Specify the end frame of the animation");
1672
1673
1674
1675 }
1676
1677 /* --------------------------------------------- */
1678
1679 void sound_panels()
1680 {
1681         bSound *sound;
1682
1683         /* paranoia check */
1684         sound = G.buts->lockpoin;
1685         if(sound && GS(sound->id.name)!=ID_SO) {
1686                 sound= NULL;
1687                 G.buts->lockpoin= NULL;
1688         }
1689         
1690         sound_panel_sound(sound);
1691         sound_panel_listener();
1692         sound_panel_sequencer();
1693 }
1694
1695
1696