178d92459c77abf4e27be32b781a705162637492
[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_sequence_types.h"
45 #include "DNA_userdef_types.h"
46 #include "DNA_packedFile_types.h"
47
48 #include "BKE_global.h"
49 #include "BKE_main.h"
50 #include "BKE_node.h"
51 #include "BKE_library.h"
52 #include "BKE_scene.h"
53 #include "BKE_sound.h"
54 #include "BKE_packedFile.h"
55 #include "BKE_utildefines.h"
56
57 #include "BLI_blenlib.h"
58
59 #include "BSE_filesel.h"
60
61 #include "BIF_gl.h"
62 #include "BIF_graphics.h"
63 #include "BIF_glutil.h"
64 #include "BIF_interface.h"
65 #include "BIF_imasel.h"
66 #include "BIF_keyval.h"
67 #include "BIF_mainqueue.h"
68 #include "BIF_mywindow.h"
69 #include "BIF_meshtools.h"
70 #include "BIF_resources.h"
71 #include "BIF_renderwin.h"
72 #include "BIF_screen.h"
73 #include "BIF_space.h"
74 #include "BIF_toolbox.h"
75 #include "BIF_editseq.h"
76
77 #include "BIF_butspace.h"
78
79 #include "mydevice.h"
80 #include "blendef.h"
81
82 /* -----includes for this file specific----- */
83
84 #include "DNA_image_types.h"
85
86 #include "BKE_writeavi.h"
87 #include "BKE_writeffmpeg.h"
88 #include "BKE_image.h"
89 #include "BKE_plugin_types.h"
90
91 #include "BLI_threads.h"
92
93 #include "BIF_editsound.h"
94 #include "BIF_writeimage.h"
95 #include "BIF_writeavicodec.h"
96
97 #include "BSE_headerbuttons.h"
98 #include "BSE_sequence.h"
99 #include "BSE_seqeffects.h"
100 #include "BSE_seqscopes.h"
101 #include "BSE_seqaudio.h"
102
103 #include "RE_pipeline.h"
104
105 #include "butspace.h" // own module
106
107 #ifdef WITH_QUICKTIME
108 #include "quicktime_export.h"
109 #endif
110
111 #ifdef WITH_FFMPEG
112
113 #include <ffmpeg/avcodec.h> /* for PIX_FMT_* and CODEC_ID_* */
114 #include <ffmpeg/avformat.h>
115
116 static int ffmpeg_preset_sel = 0;
117
118 extern int is_container(int);
119
120 extern void makeffmpegstring(char* string);
121
122 #endif
123
124 /* here the calls for scene buttons
125    - render
126    - world
127    - anim settings, audio
128 */
129
130 /* prototypes */
131 void playback_anim(void);
132
133 /* ************************ SOUND *************************** */
134 static void load_new_sample(char *str)  /* called from fileselect */
135 {
136         char name[FILE_MAX];
137         bSound *sound;
138         bSample *sample, *newsample;
139
140         sound = G.buts->lockpoin;
141
142         if (sound) {
143                 // save values
144                 sample = sound->sample;
145                 strcpy(name, sound->sample->name);
146
147                 strcpy(sound->name, str);
148                 sound_set_sample(sound, NULL);
149                 sound_initialize_sample(sound);
150
151                 if (sound->sample->type == SAMPLE_INVALID) {
152                         error("Not a valid sample: %s", str);
153
154                         newsample = sound->sample;
155
156                         // restore values
157                         strcpy(sound->name, name);
158                         sound_set_sample(sound, sample);
159
160                         // remove invalid sample
161
162                         sound_free_sample(newsample);
163                         BLI_remlink(samples, newsample);
164                         MEM_freeN(newsample);
165                 }
166         }
167
168         BIF_undo_push("Load new audio file");
169         allqueue(REDRAWBUTSSCENE, 0);
170
171 }
172
173
174 void do_soundbuts(unsigned short event)
175 {
176         char name[FILE_MAX];
177         bSound *sound;
178         bSample *sample;
179         bSound* tempsound;
180         ID *id;
181         
182         sound = G.buts->lockpoin;
183         
184         switch(event) {
185         case B_SOUND_REDRAW:
186                 allqueue(REDRAWBUTSSCENE, 0);
187                 break;
188
189         case B_SOUND_LOAD_SAMPLE:
190                 if (sound) strcpy(name, sound->name);
191                 else strcpy(name, U.sounddir);
192                         
193                 activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_new_sample);
194                 break;
195
196         case B_SOUND_PLAY_SAMPLE:
197                 if (sound) {
198                         if (sound->sample->type != SAMPLE_INVALID) {
199                                 sound_play_sound(sound);
200                                 allqueue(REDRAWBUTSSCENE, 0);
201                         }
202                 }
203                 break;
204
205         case B_SOUND_MENU_SAMPLE:
206                 if (G.buts->menunr > 0) {
207                         sample = BLI_findlink(samples, G.buts->menunr - 1);
208                         if (sample && sound) {
209                                 BLI_strncpy(sound->name, sample->name, sizeof(sound->name));
210                                 sound_set_sample(sound, sample);
211                                 do_soundbuts(B_SOUND_REDRAW);
212                         }
213                 }
214                         
215                 break;
216         case B_SOUND_NAME_SAMPLE:
217                 load_new_sample(sound->name);
218                 break;
219         
220         case B_SOUND_UNPACK_SAMPLE:
221                 if(sound && sound->sample) {
222                         sample = sound->sample;
223                         
224                         if (sample->packedfile) {
225                                 if (G.fileflags & G_AUTOPACK) {
226                                         if (okee("Disable AutoPack ?")) {
227                                                 G.fileflags &= ~G_AUTOPACK;
228                                         }
229                                 }
230                                 
231                                 if ((G.fileflags & G_AUTOPACK) == 0) {
232                                         unpackSample(sample, PF_ASK);
233                                 }
234                         } else {
235                                 sound_set_packedfile(sample, newPackedFile(sample->name));
236                         }
237                         allqueue(REDRAWHEADERS, 0);
238                         do_soundbuts(B_SOUND_REDRAW);
239                 }
240                 break;
241
242         case B_SOUND_COPY_SOUND:
243                 if (sound) {
244                         tempsound = sound_make_copy(sound);
245                         sound = tempsound;
246                         id = &sound->id;
247                         G.buts->lockpoin = (bSound*)id;
248                         BIF_undo_push("Copy sound");
249                         do_soundbuts(B_SOUND_REDRAW);
250                 }
251                 break;
252
253         case B_SOUND_RECALC:
254                 waitcursor(1);
255                 sound = G.main->sound.first;
256                 while (sound) {
257                         free(sound->stream);
258                         sound->stream = 0;
259                         audio_makestream(sound);
260                         sound = (bSound *) sound->id.next;
261                 }
262                 waitcursor(0);
263                 allqueue(REDRAWSEQ, 0);
264                 break;
265
266         case B_SOUND_RATECHANGED:
267
268                 allqueue(REDRAWBUTSSCENE, 0);
269                 allqueue(REDRAWSEQ, 0);
270                 break;
271
272         case B_SOUND_MIXDOWN:
273                 audio_mixdown();
274                 break;
275
276         default: 
277                 if (G.f & G_DEBUG) {
278                         printf("do_soundbuts: unhandled event %d\n", event);
279                 }
280         }
281 }
282
283
284 static void sound_panel_listener(void)
285 {
286         uiBlock *block;
287         int xco= 100, yco=100, mixrate;
288         char mixrateinfo[256];
289         
290         block= uiNewBlock(&curarea->uiblocks, "sound_panel_listener", UI_EMBOSS, UI_HELV, curarea->win);
291         if(uiNewPanel(curarea, block, "Listener", "Sound", 320, 0, 318, 204)==0) return;
292
293         mixrate = sound_get_mixrate();
294         sprintf(mixrateinfo, "Game Mixrate: %d Hz", mixrate);
295         uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
296
297         yco -= 30;
298         uiDefBut(block, LABEL, 0, "Game listener settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
299
300         yco -= 30;
301         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
302                 xco,yco,195,24,&G.listener->gain, 0.0, 1.0, 1.0, 0, "Sets the maximum volume for the overall sound");
303         
304         yco -= 30;
305         uiDefBut(block, LABEL, 0, "Game Doppler effect settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
306
307         yco -= 30;
308         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Doppler: ",
309         xco,yco,195,24,&G.listener->dopplerfactor, 0.0, 10.0, 1.0, 0, "Use this for scaling the doppler effect");
310         
311         yco -=30;
312         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Velocity: ",
313         xco,yco,195,24,&G.listener->dopplervelocity,0.0,10000.0, 1.0,0, "Sets the propagation speed of sound");
314
315         
316 }
317
318 static void sound_panel_sequencer(void)
319 {
320         uiBlock *block;
321         short xco, yco;
322         char mixrateinfo[256];
323         
324         block= uiNewBlock(&curarea->uiblocks, "sound_panel_sequencer", UI_EMBOSS, UI_HELV, curarea->win);
325         if(uiNewPanel(curarea, block, "Sequencer", "Sound", 640, 0, 318, 204)==0) return;
326
327         /* audio sequence engine settings ------------------------------------------------------------------ */
328
329         xco = 1010;
330         yco = 195;
331
332         uiDefBut(block, LABEL, 0, "Audio sequencer settings", xco,yco,295,20, 0, 0, 0, 0, 0, "");
333
334         yco -= 25;
335         sprintf(mixrateinfo, "Mixing/Sync (latency: %d ms)", (int)( (((float)U.mixbufsize)/(float)G.scene->audio.mixrate)*1000.0 ) );
336         uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
337
338         yco -= 25;              
339         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");
340         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");
341         uiDefBut(block, BUT, B_SOUND_RECALC, "Recalc",          xco+160,yco,75,20, 0, 0, 0, 0, 0, "Recalculate samples");
342
343         yco -= 25;
344         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");
345         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");
346
347         yco -= 25;
348         uiDefBut(block, LABEL, 0, "Main mix", xco,yco,295,20, 0, 0, 0, 0, 0, "");
349
350         yco -= 25;              
351         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Main (dB): ",
352                 xco,yco,235,24,&G.scene->audio.main, -24.0, 6.0, 0, 0, "Set the audio master gain/attenuation in dB");
353
354         yco -= 25;
355         uiDefButBitS(block, TOG, AUDIO_MUTE, 0, "Mute", xco,yco,235,24, &G.scene->audio.flag, 0, 0, 0, 0, "Mute audio from sequencer");         
356         
357         yco -= 35;
358         uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN",        xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio (output goes to render output dir)");
359         
360 }
361
362 static char *make_sample_menu(void)
363 {
364         int len= BLI_countlist(samples);        /* BKE_sound.h */
365         
366         if(len) {
367                 bSample *sample;
368                 char *str;
369                 int nr, a=0;
370                 
371                 str= MEM_callocN(32*len, "menu");
372                 
373                 for(nr=1, sample= samples->first; sample; sample= sample->id.next, nr++) {
374                         a+= sprintf(str+a, "|%s %%x%d", sample->id.name+2, nr);
375                 }
376                 return str;
377         }
378         return NULL;
379 }
380
381 static void sound_panel_sound(bSound *sound)
382 {
383         static int packdummy=0;
384         ID *id, *idfrom;
385         uiBlock *block;
386         bSample *sample;
387         char *strp, ch[256];
388
389         block= uiNewBlock(&curarea->uiblocks, "sound_panel_sound", UI_EMBOSS, UI_HELV, curarea->win);
390         if(uiNewPanel(curarea, block, "Sound", "Sound", 0, 0, 318, 204)==0) return;
391         
392         uiDefBut(block, LABEL, 0, "Blender Sound block",10,180,195,20, 0, 0, 0, 0, 0, "");
393         
394         // warning: abuse of texnr here! (ton didnt code!)
395         buttons_active_id(&id, &idfrom);
396         std_libbuttons(block, 10, 160, 0, NULL, B_SOUNDBROWSE2, ID_SO, 0, id, idfrom, &(G.buts->texnr), 1, 0, 0, 0, 0);
397
398         if (sound) {
399         
400                 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");
401
402                 uiSetButLock(sound->id.lib!=0, ERROR_LIBDATA_MESSAGE);
403                 sound_initialize_sample(sound);
404                 sample = sound->sample;
405
406                 /* info string */
407                 if (sound->sample && sound->sample->len) {
408                         char *tmp;
409                         if (sound->sample->channels == 1) tmp= "Mono";
410                         else if (sound->sample->channels == 2) tmp= "Stereo";
411                         else tmp= "Unknown";
412                         
413                         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));
414                         uiDefBut(block, LABEL, 0, ch,                   35,140,225,20, 0, 0, 0, 0, 0, "");
415                 }
416                 else {
417                         uiDefBut(block, LABEL, 0, "Sample: No sample info available.",35,140,225,20, 0, 0, 0, 0, 0, "");
418                 }
419
420                 /* sample browse buttons */
421                 uiBlockBeginAlign(block);
422                 strp= make_sample_menu();
423                 if (strp) {
424                         uiDefButS(block, MENU, B_SOUND_MENU_SAMPLE, strp, 10,120,23,20, &(G.buts->menunr), 0, 0, 0, 0, "Select another loaded sample");
425                         MEM_freeN(strp);
426                 }
427                 uiDefBut(block, TEX, B_SOUND_NAME_SAMPLE, "",           35,120,250,20, sound->name, 0.0, 79.0, 0, 0, "The sample file used by this Sound");
428                 
429                 if (sound->sample->packedfile) packdummy = 1;
430                 else packdummy = 0;
431                 
432                 uiDefIconButBitI(block, TOG, 1, B_SOUND_UNPACK_SAMPLE, ICON_PACKAGE,
433                         285, 120,25,20, &packdummy, 0, 0, 0, 0,"Pack/Unpack this sample");
434                 
435                 uiBlockBeginAlign(block);
436                 uiDefBut(block, BUT, B_SOUND_LOAD_SAMPLE, "Load sample", 10, 95,150,24, 0, 0, 0, 0, 0, "Load a different sample file");
437
438                 uiDefBut(block, BUT, B_SOUND_PLAY_SAMPLE, "Play",       160, 95, 150, 24, 0, 0.0, 0, 0, 0, "Playback sample using settings below");
439                 
440                 uiBlockBeginAlign(block);
441                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
442                         10,70,150,20, &sound->volume, 0.0, 1.0, 0, 0, "Game engine only: Set the volume of this sound");
443
444                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pitch: ",
445                         160,70,150,20, &sound->pitch, -12.0, 12.0, 0, 0, "Game engine only: Set the pitch of this sound");
446
447                 /* looping */
448                 uiBlockBeginAlign(block);
449                 uiDefButBitI(block, TOG, SOUND_FLAGS_LOOP, B_SOUND_REDRAW, "Loop",
450                         10, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Game engine only: Toggle between looping on/off");
451
452                 if (sound->flags & SOUND_FLAGS_LOOP) {
453                         uiDefButBitI(block, TOG, SOUND_FLAGS_BIDIRECTIONAL_LOOP, B_SOUND_REDRAW, "Ping Pong",
454                                 105, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Game engine only: Toggle between A->B and A->B->A looping");
455                         
456                 }
457         
458
459                 /* 3D settings ------------------------------------------------------------------ */
460                 uiBlockBeginAlign(block);
461
462                 if (sound->sample->channels == 1) {
463                         uiDefButBitI(block, TOG, SOUND_FLAGS_3D, B_SOUND_REDRAW, "3D Sound",
464                                 10, 10, 90, 20, &sound->flags, 0, 0, 0, 0, "Game engine only: Turns 3D sound on");
465                         
466                         if (sound->flags & SOUND_FLAGS_3D) {
467                                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ",
468                                         100,10,210,20, &sound->attenuation, 0.0, 5.0, 1.0, 0, "Game engine only: Sets the surround scaling factor for this sound");
469                                 
470                         }
471                 }
472         }
473 }
474
475 /* ************************* Sequencer *********************** */
476
477 #define SEQ_PANEL_EDITING 1
478 #define SEQ_PANEL_INPUT   2
479 #define SEQ_PANEL_FILTER  4
480 #define SEQ_PANEL_EFFECT  8
481 #define SEQ_PANEL_PROXY   16
482
483 static char* seq_panel_blend_modes()
484 {
485         static char string[2048];
486
487         Sequence *last_seq = get_last_seq();
488
489         sprintf(string, "Blend mode: %%t|%s %%x%d",
490                 "Replace", SEQ_BLEND_REPLACE);
491
492         /*
493           Blending can only work without effect strips. 
494           Otherwise, one would have
495           to decide, what the effect strips IPO should do:
496           - drive the effect _or_
497           - drive the blend mode ?
498
499           Also: effectdata is used by these implicit effects,
500           so that would collide also.
501         */
502
503         if (!(last_seq->type & SEQ_EFFECT)) {
504                 int i;
505
506                 for (i = SEQ_EFFECT; i <= SEQ_EFFECT_MAX; i++) {
507                         if (get_sequence_effect_num_inputs(i) == 2) {
508                                 sprintf(string + strlen(string), 
509                                         "|%s %%x%d", 
510                                         give_seqname_by_type(i), i);
511                         }
512                 }
513         }
514         return string;
515 }
516
517 static void seq_panel_editing()
518 {
519         Sequence *last_seq = get_last_seq();
520         uiBlock *block;
521         static char strdata[1024];
522         char * str = strdata;
523         char * p;
524         int yco;
525
526         block = uiNewBlock(&curarea->uiblocks, "seq_panel_editing", 
527                            UI_EMBOSS, UI_HELV, curarea->win);
528
529         if(uiNewPanel(curarea, block, "Edit", "Sequencer", 
530                       10, 230, 318, 204) == 0) return;
531
532         uiDefBut(block, LABEL, 
533                  0, give_seqname(last_seq), 
534                  10,140,60,19, 0, 
535                  0, 0, 0, 0, "");
536
537         uiDefBut(block, TEX, 
538                  B_NOP, "Name: ", 
539                  70,140,180,19, last_seq->name+2, 
540                  0.0, 21.0, 100, 0, "");
541
542         uiDefButI(block, MENU, B_SEQ_BUT_RELOAD, seq_panel_blend_modes(), 
543                   10, 120, 120, 19, &last_seq->blend_mode, 
544                   0,0,0,0, "Strip Blend Mode");
545
546         if (last_seq->blend_mode > 0) {
547                 uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Blend:",
548                           130, 120, 120, 19, &last_seq->blend_opacity, 
549                           0.0, 100.0, 100.0, 0, 
550                           "Blend opacity");
551         }
552
553         uiDefButBitI(block, TOG, SEQ_MUTE,
554                      B_SEQ_BUT_RELOAD_ALL, "Mute",
555                      10,100,60,19, &last_seq->flag,
556                      0.0, 1.0, 0, 0,
557                      "Mute the current strip.");
558
559         uiDefButBitI(block, TOG, SEQ_LOCK,
560                      B_NOP, "Lock",
561                      70,100,60,19, &last_seq->flag,
562                      0.0, 1.0, 0, 0,
563                      "Lock strip, so that it can't be transformed.");
564         
565         uiDefButBitI(block, TOG, SEQ_IPO_FRAME_LOCKED,
566                      B_SEQ_BUT_RELOAD_ALL, "IPO Frame locked",
567                      130,100,120,19, &last_seq->flag,
568                      0.0, 1.0, 0, 0,
569                      "Lock the IPO coordinates to the "
570                      "global frame counter.");
571         
572         if (!(last_seq->flag & SEQ_LOCK)) {
573                 uiDefButI(block, NUM, 
574                           B_SEQ_BUT_TRANSFORM, "Start", 
575                           10, 80, 120, 20, &last_seq->start, 
576                           0.0, MAXFRAMEF, 0.0, 0.0, "Start of strip");
577                 uiDefButI(block, NUM, 
578                           B_SEQ_BUT_TRANSFORM, "Chan", 
579                           130, 80, 120, 20, &last_seq->machine, 
580                           0.0, MAXSEQ, 0.0, 0.0, "Channel used (Y position)");
581                 
582                 if (check_single_seq(last_seq)) {
583                         uiDefButI(block, NUM, 
584                                 B_SEQ_BUT_TRANSFORM, "End-Still", 
585                                 130, 60, 120, 19, &last_seq->endstill, 
586                                 0.0, MAXFRAMEF, 0.0, 0.0, "End still");
587                 } else {
588                         if (last_seq->type == SEQ_IMAGE) {
589                                 uiDefButI(block, NUM, 
590                                         B_SEQ_BUT_TRANSFORM, "Start-Still", 
591                                         10, 60, 120, 20, &last_seq->startstill, 
592                                         0.0, MAXFRAMEF, 0.0, 0.0, "Start still");
593                                 uiDefButI(block, NUM, 
594                                         B_SEQ_BUT_TRANSFORM, "End-Still", 
595                                         130, 60, 120, 19, &last_seq->endstill, 
596                                         0.0, MAXFRAMEF, 0.0, 0.0, "End still");
597                         } else {
598                                 uiDefButI(block, NUM, 
599                                         B_SEQ_BUT_TRANSFORM, "Start-Ofs", 
600                                         10, 60, 120, 20, &last_seq->startofs, 
601                                         0.0, last_seq->len - last_seq->endofs, 
602                                         0.0, 0.0, "Start offset");
603                                 uiDefButI(block, NUM, 
604                                         B_SEQ_BUT_TRANSFORM, "End-Ofs", 
605                                         130, 60, 120, 19, &last_seq->endofs, 
606                                         0.0, last_seq->len - last_seq->startofs, 
607                                         0.0, 0.0, "End offset");
608                         }
609                 }
610         }
611
612
613         if(last_seq->type & SEQ_EFFECT)
614                 sprintf(str, "Len: %d\nFrom %d - %d\n", last_seq->len, last_seq->startdisp, last_seq->enddisp-1);
615         else
616                 sprintf(str, "Len: %d(%d)\n", last_seq->enddisp-last_seq->startdisp, last_seq->len);
617
618         str += strlen(str);
619
620         if(last_seq->type==SEQ_IMAGE) {
621                 if (last_seq->len > 1) {
622                         /* CURRENT */
623                         StripElem * se= give_stripelem(last_seq, CFRA);
624                         StripElem * last;
625
626                         /* FIRST AND LAST */
627         
628                         if(last_seq->strip) {
629                                 se= last_seq->strip->stripdata;
630                                 last= se+last_seq->len-1;
631                                 if(last_seq->startofs) se+= last_seq->startofs;
632                                 if(last_seq->endofs) last-= last_seq->endofs;
633         
634                                 sprintf(str, "First: %s at %d\nLast: %s at %d\n", se->name, last_seq->startdisp, last->name, last_seq->enddisp-1);
635                         }
636                 } else { /* single image */
637                         if (last_seq->strip) {
638                                 sprintf(str, "Len: %d\n", last_seq->enddisp-last_seq->startdisp);
639                         }
640                 }
641
642                 str += strlen(str);
643
644                 /* orig size */
645                 if(last_seq->strip) {
646                         sprintf(str, "OrigSize: %d x %d\n", last_seq->strip->orx, last_seq->strip->ory);
647                 }
648         }
649         else if(last_seq->type==SEQ_MOVIE) {
650                 int sta= last_seq->startofs;
651                 int end= last_seq->len-1-last_seq->endofs;
652
653                 sprintf(str, "First: %d at %d\nLast: %d at %d\nCur: %d\n",
654                         sta, last_seq->startdisp, end, last_seq->enddisp-1,  
655                         (G.scene->r.cfra)-last_seq->startdisp);
656         }
657         else if(last_seq->type==SEQ_SCENE) {
658                 TStripElem * se= give_tstripelem(last_seq,  (G.scene->r.cfra));
659                 if(se && last_seq->scene) {
660                         sprintf(str, "First: %d\nLast: %d\nCur: %d\n", last_seq->sfra+se->nr, last_seq->sfra, last_seq->sfra+last_seq->len-1); 
661                 }
662         }
663         else if(last_seq->type==SEQ_RAM_SOUND
664                 || last_seq->type == SEQ_HD_SOUND) {
665
666                 int sta= last_seq->startofs;
667                 int end= last_seq->len-1-last_seq->endofs;
668
669                 sprintf(str, "First: %d at %d\nLast: %d at %d\nCur: %d\n",
670                         sta, last_seq->startdisp, end, last_seq->enddisp-1,  
671                         (G.scene->r.cfra)-last_seq->startdisp);
672         }
673         else if(last_seq->type == SEQ_SPEED) {
674                 SpeedControlVars * vars = 
675                         (SpeedControlVars*) last_seq->effectdata;
676
677                 if (vars) {
678                         sprintf(str, "Last mapped frame: %d at %d\n", 
679                                 vars->lastValidFrame, 
680                                 vars->lastValidFrame 
681                                 + last_seq->startdisp);
682                 }
683         }
684
685         str = strdata;
686         yco = 40;
687
688         while ((p = strchr(str, '\n'))) {
689                 *p = 0;
690                 uiDefBut(block, LABEL, 0, str, 10,yco,240,19, 0, 
691                          0, 0, 0, 0, "");
692                 str = p+1;
693                 yco -= 20;
694         }
695 }
696
697 static void seq_panel_input()
698 {
699         Sequence *last_seq = get_last_seq();
700         uiBlock *block;
701
702         block = uiNewBlock(&curarea->uiblocks, "seq_panel_input", 
703                            UI_EMBOSS, UI_HELV, curarea->win);
704
705         if(uiNewPanel(curarea, block, "Input", "Sequencer", 
706                       10, 230, 318, 204) == 0) return;
707
708         if (last_seq->type == SEQ_MOVIE 
709             || last_seq->type == SEQ_IMAGE) {
710                 uiDefBut(block, TEX, 
711                          B_SEQ_BUT_RELOAD_FILE, "Dir: ", 
712                          10,140,240,19, last_seq->strip->dir, 
713                          0.0, 160.0, 100, 0, "");
714         }
715
716         if (last_seq->type == SEQ_IMAGE) {
717                 StripElem * se = give_stripelem(last_seq, CFRA);
718
719                 if (se) {
720                         uiDefBut(block, TEX, 
721                                  B_SEQ_BUT_RELOAD_FILE, "File: ", 
722                                  10, 120, 240,19, se->name, 
723                                  0.0, 80.0, 100, 0, "");
724                 }
725
726         } else if (last_seq->type == SEQ_MOVIE || 
727                    last_seq->type == SEQ_HD_SOUND ||
728                    last_seq->type == SEQ_RAM_SOUND) {
729                 uiDefBut(block, TEX, 
730                          B_SEQ_BUT_RELOAD_FILE, "File: ", 
731                          10,120,240,19, last_seq->strip->stripdata->name, 
732                          0.0, 80.0, 100, 0, "");
733         }
734
735         if (last_seq->type == SEQ_MOVIE 
736             || last_seq->type == SEQ_IMAGE 
737             || last_seq->type == SEQ_SCENE) {
738                 uiDefButBitI(block, TOG, SEQ_USE_CROP,
739                              B_SEQ_BUT_RELOAD, "Use Crop",
740                              10,100,240,19, &last_seq->flag,
741                              0.0, 1.0, 0, 0,
742                              "Crop image before processing.");
743
744                 if (last_seq->flag & SEQ_USE_CROP) {
745                         if (!last_seq->strip->crop) {
746                                 last_seq->strip->crop = 
747                                         MEM_callocN(sizeof(struct StripCrop), 
748                                                     "StripCrop");
749                         }
750                         uiDefButI(block, NUM, 
751                                   B_SEQ_BUT_RELOAD, "Top", 
752                                   10, 80, 120, 20, 
753                                   &last_seq->strip->crop->top, 
754                                   0.0, 4096, 0.0, 0.0, "Top of source image");
755                         uiDefButI(block, NUM, 
756                                   B_SEQ_BUT_RELOAD, "Bottom", 
757                                   130, 80, 120, 20, 
758                                   &last_seq->strip->crop->bottom, 
759                                   0.0, 4096, 0.0, 0.0,
760                                   "Bottom of source image");
761                         
762                         uiDefButI(block, NUM, 
763                                   B_SEQ_BUT_RELOAD, "Left", 
764                                   10, 60, 120, 20,
765                                   &last_seq->strip->crop->left, 
766                                   0.0, 4096, 0.0, 0.0, "Left");
767                         uiDefButI(block, NUM, 
768                                   B_SEQ_BUT_RELOAD, "Right", 
769                                   130, 60, 120, 19, 
770                                   &last_seq->strip->crop->right, 
771                                   0.0, 4096, 0.0, 0.0, "Right");
772                 }
773                 
774                 uiDefButBitI(block, TOG, SEQ_USE_TRANSFORM,
775                              B_SEQ_BUT_RELOAD, "Use Translate",
776                              10,40,240,19, &last_seq->flag,
777                              0.0, 1.0, 0, 0,
778                              "Translate image before processing.");
779                 
780                 if (last_seq->flag & SEQ_USE_TRANSFORM) {
781                         if (!last_seq->strip->transform) {
782                                 last_seq->strip->transform = 
783                                         MEM_callocN(
784                                                 sizeof(struct StripTransform), 
785                                                 "StripTransform");
786                         }
787                         uiDefButI(block, NUM, 
788                                   B_SEQ_BUT_RELOAD, "X-Ofs", 
789                                   10, 20, 120, 20, 
790                                   &last_seq->strip->transform->xofs, 
791                                   0.0, 4096, 0.0, 0.0, "X Offset");
792                         uiDefButI(block, NUM, 
793                                   B_SEQ_BUT_RELOAD, "Y-Ofs", 
794                                   130, 20, 120, 20, 
795                                   &last_seq->strip->transform->yofs, 
796                                   0.0, 4096, 0.0, 0.0, "Y Offset");
797                 }
798         }
799
800         uiDefButI(block, NUM, 
801                   B_SEQ_BUT_RELOAD_FILE, "A-Start", 
802                   10, 0, 120, 20, &last_seq->anim_startofs, 
803                   0.0, last_seq->len + last_seq->anim_startofs, 0.0, 0.0, 
804                   "Animation start offset in file");
805         uiDefButI(block, NUM, 
806                   B_SEQ_BUT_RELOAD_FILE, "A-End", 
807                   130, 0, 120, 20, &last_seq->anim_endofs, 
808                   0.0, last_seq->len + last_seq->anim_endofs, 0.0, 0.0, 
809                   "Animation end offset in file");
810
811
812         if (last_seq->type == SEQ_MOVIE) {
813                 uiDefButI(block, NUM, B_SEQ_BUT_RELOAD, "MPEG-Preseek:",
814                           10, -20, 240,19, &last_seq->anim_preseek, 
815                           0.0, 50.0, 100,0,
816                           "On MPEG-seeking preseek this many frames");
817         }
818
819 }
820
821 static void seq_panel_filter_video()
822 {
823         Sequence *last_seq = get_last_seq();
824         uiBlock *block;
825         block = uiNewBlock(&curarea->uiblocks, "seq_panel_filter", 
826                            UI_EMBOSS, UI_HELV, curarea->win);
827
828         if(uiNewPanel(curarea, block, "Filter", "Sequencer", 
829                       10, 230, 318, 204) == 0) return;
830
831
832         uiBlockBeginAlign(block);
833
834
835         uiDefButBitI(block, TOG, SEQ_MAKE_PREMUL, 
836                      B_SEQ_BUT_RELOAD, "Convert to Premul", 
837                      10,110,150,19, &last_seq->flag, 
838                      0.0, 21.0, 100, 0, 
839                      "Converts RGB values to become premultiplied with Alpha");
840
841         uiDefButBitI(block, TOG, SEQ_FILTERY, 
842                      B_SEQ_BUT_RELOAD, "FilterY",       
843                      10,90,75,19, &last_seq->flag, 
844                      0.0, 21.0, 100, 0, 
845                      "For video movies to remove fields");
846
847         uiDefButBitI(block, TOG, SEQ_MAKE_FLOAT, 
848                      B_SEQ_BUT_RELOAD, "Make Float",    
849                      85,90,75,19, &last_seq->flag, 
850                      0.0, 21.0, 100, 0, 
851                      "Convert input to float data");
852                 
853         uiDefButBitI(block, TOG, SEQ_FLIPX, 
854                      B_SEQ_BUT_RELOAD, "FlipX", 
855                      10,70,75,19, &last_seq->flag, 
856                      0.0, 21.0, 100, 0, 
857                      "Flip on the X axis");
858         uiDefButBitI(block, TOG, SEQ_FLIPY, 
859                      B_SEQ_BUT_RELOAD, "FlipY", 
860                      85,70,75,19, &last_seq->flag, 
861                      0.0, 21.0, 100, 0, 
862                      "Flip on the Y axis");
863                 
864         uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Mul:",
865                   10,50,150,19, &last_seq->mul, 
866                   0.001, 5.0, 100, 0, 
867                   "Multiply colors");
868
869         uiDefButBitI(block, TOG, SEQ_REVERSE_FRAMES,
870                      B_SEQ_BUT_RELOAD, "Reverse Frames", 
871                      10,30,150,19, &last_seq->flag, 
872                      0.0, 21.0, 100, 0, 
873                      "Reverse frame order");
874
875         uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Strobe:",
876                   10,10,150,19, &last_seq->strobe, 
877                   1.0, 30.0, 100, 0, 
878                   "Only display every nth frame");
879
880         uiBlockEndAlign(block);
881
882 }
883
884
885 static void seq_panel_filter_audio()
886 {
887         Sequence *last_seq = get_last_seq();
888         uiBlock *block;
889         block = uiNewBlock(&curarea->uiblocks, "seq_panel_filter", 
890                            UI_EMBOSS, UI_HELV, curarea->win);
891
892         if(uiNewPanel(curarea, block, "Filter", "Sequencer", 
893                       10, 230, 318, 204) == 0) return;
894
895         uiBlockBeginAlign(block);
896         uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Gain (dB):", 10,50,150,19, &last_seq->level, -96.0, 6.0, 100, 0, "");
897         uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Pan:",         10,30,150,19, &last_seq->pan, -1.0, 1.0, 100, 0, "");
898         uiBlockEndAlign(block);
899 }
900
901 static void seq_panel_effect()
902 {
903         Sequence *last_seq = get_last_seq();
904         uiBlock *block;
905         block = uiNewBlock(&curarea->uiblocks, "seq_panel_effect", 
906                            UI_EMBOSS, UI_HELV, curarea->win);
907
908         if(uiNewPanel(curarea, block, "Effect", "Sequencer", 
909                       10, 230, 318, 204) == 0) return;
910
911         if(last_seq->type == SEQ_PLUGIN) {
912                 PluginSeq *pis;
913                 VarStruct *varstr;
914                 int a, xco, yco;
915
916                 get_sequence_effect(last_seq);/* make sure, plugin is loaded */
917
918                 pis= last_seq->plugin;
919                 if(pis->vars==0) return;
920
921                 varstr= pis->varstr;
922                 if(varstr) {
923                         for(a=0; a<pis->vars; a++, varstr++) {
924                                 xco= 150*(a/6)+10;
925                                 yco= 125 - 20*(a % 6)+1;
926                                 uiDefBut(block, varstr->type, B_SEQ_BUT_PLUGIN, varstr->name, xco,yco,150,19, &(pis->data[a]), varstr->min, varstr->max, 100, 0, varstr->tip);
927
928                         }
929                 }
930                 return;
931         } 
932
933         uiBlockBeginAlign(block);
934
935         if(last_seq->type==SEQ_WIPE){
936                 WipeVars *wipe = (WipeVars *)last_seq->effectdata;
937                 char formatstring[256];
938                         
939                 strncpy(formatstring, "Transition Type %t|Single Wipe%x0|Double Wipe %x1|Iris Wipe %x4|Clock Wipe %x5", 255);
940                 uiDefButS(block, MENU,B_SEQ_BUT_EFFECT, formatstring,   10,65,220,22, &wipe->wipetype, 0, 0, 0, 0, "What type of wipe should be performed");
941                 uiDefButF(block, NUM,B_SEQ_BUT_EFFECT,"Blur:",  10,40,220,22, &wipe->edgeWidth,0.0,1.0, 1, 2, "The percent width of the blur edge");
942                 switch(wipe->wipetype){ /*Skip Types that do not require angle*/
943                 case DO_IRIS_WIPE:
944                 case DO_CLOCK_WIPE:
945                         break;
946                         
947                 default:
948                         uiDefButF(block, NUM,B_SEQ_BUT_EFFECT,"Angle:", 10,15,220,22, &wipe->angle,-90.0,90.0, 1, 2, "The Angle of the Edge");
949                 }
950                 uiDefButS(block, TOG,B_SEQ_BUT_EFFECT,"Wipe In",  10,-10,220,22, &wipe->forward,0,0, 0, 0, "Controls Primary Direction of Wipe");                               
951         } else if(last_seq->type==SEQ_GLOW){
952                 GlowVars *glow = (GlowVars *)last_seq->effectdata;
953
954                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "Threshold:",   10,70,150,19, &glow->fMini, 0.0, 1.0, 0, 0, "Trigger Intensity");
955                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "Clamp:",                       10,50,150,19, &glow->fClamp, 0.0, 1.0, 0, 0, "Brightness limit of intensity");
956                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "Boost factor:",        10,30,150,19, &glow->fBoost, 0.0, 10.0, 0, 0, "Brightness multiplier");
957                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "Blur distance:",       10,10,150,19, &glow->dDist, 0.5, 20.0, 0, 0, "Radius of glow effect");
958                 uiDefButI(block, NUM, B_NOP, "Quality:", 10,-5,150,19, &glow->dQuality, 1.0, 5.0, 0, 0, "Accuracy of the blur effect");
959                 uiDefButI(block, TOG, B_NOP, "Only boost", 10,-25,150,19, &glow->bNoComp, 0.0, 0.0, 0, 0, "Show the glow buffer only");
960         }
961         else if(last_seq->type==SEQ_TRANSFORM){
962                 TransformVars *transform = (TransformVars *)last_seq->effectdata;
963
964                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "xScale Start:",        10,70,150,19, &transform->ScalexIni, 0.0, 10.0, 0, 0, "X Scale Start");
965                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "xScale End:",  160,70,150,19, &transform->ScalexFin, 0.0, 10.0, 0, 0, "X Scale End");
966                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "yScale Start:",        10,50,150,19, &transform->ScaleyIni, 0.0, 10.0, 0, 0, "Y Scale Start");
967                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "yScale End:",  160,50,150,19, &transform->ScaleyFin, 0.0, 10.0, 0, 0, "Y Scale End");
968                 
969                 uiDefButI(block, ROW, B_SEQ_BUT_EFFECT, "Percent", 10, 30, 150, 19, &transform->percent, 0.0, 1.0, 0.0, 0.0, "Percent Translate");
970                 uiDefButI(block, ROW, B_SEQ_BUT_EFFECT, "Pixels", 160, 30, 150, 19, &transform->percent, 0.0, 0.0, 0.0, 0.0, "Pixels Translate");
971                 if(transform->percent==1){
972                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "x Start:",     10,10,150,19, &transform->xIni, -500.0, 500.0, 0, 0, "X Position Start");
973                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "x End:",       160,10,150,19, &transform->xFin, -500.0, 500.0, 0, 0, "X Position End");
974                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "y Start:",     10,-10,150,19, &transform->yIni, -500.0, 500.0, 0, 0, "Y Position Start");
975                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "y End:",       160,-10,150,19, &transform->yFin, -500.0, 500.0, 0, 0, "Y Position End");
976                 } else {
977                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "x Start:",     10,10,150,19, &transform->xIni, -10000.0, 10000.0, 0, 0, "X Position Start");
978                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "x End:",       160,10,150,19, &transform->xFin, -10000.0, 10000.0, 0, 0, "X Position End");
979                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "y Start:",     10,-10,150,19, &transform->yIni, -10000.0, 10000.0, 0, 0, "Y Position Start");
980                         uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "y End:",       160,-10,150,19, &transform->yFin, -10000.0, 10000.0, 0, 0, "Y Position End");
981                         
982                 }
983                 
984                 
985                 
986                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "rot Start:",10,-30,150,19, &transform->rotIni, 0.0, 360.0, 0, 0, "Rotation Start");
987                 uiDefButF(block, NUM, B_SEQ_BUT_EFFECT, "rot End:",160,-30,150,19, &transform->rotFin, 0.0, 360.0, 0, 0, "Rotation End");
988                 
989                 uiDefButI(block, ROW, B_SEQ_BUT_EFFECT, "No Interpolat", 10, -50, 100, 19, &transform->interpolation, 0.0, 0.0, 0.0, 0.0, "No interpolation");
990                 uiDefButI(block, ROW, B_SEQ_BUT_EFFECT, "Bilinear", 101, -50, 100, 19, &transform->interpolation, 0.0, 1.0, 0.0, 0.0, "Bilinear interpolation");
991                 uiDefButI(block, ROW, B_SEQ_BUT_EFFECT, "Bicubic", 202, -50, 100, 19, &transform->interpolation, 0.0, 2.0, 0.0, 0.0, "Bicubic interpolation");
992         } else if(last_seq->type==SEQ_COLOR) {
993                 SolidColorVars *colvars = (SolidColorVars *)last_seq->effectdata;
994                 uiDefButF(block, COL, B_SEQ_BUT_RELOAD, "",10,90,150,19, colvars->col, 0, 0, 0, 0, "");
995         } else if(last_seq->type==SEQ_SPEED){
996                 SpeedControlVars *sp = 
997                         (SpeedControlVars *)last_seq->effectdata;
998                 
999                 uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Global Speed:",        10,70,150,19, &sp->globalSpeed, 0.0, 100.0, 0, 0, "Global Speed");
1000                 
1001                 uiDefButBitI(block, TOG, SEQ_SPEED_INTEGRATE,
1002                              B_SEQ_BUT_RELOAD, 
1003                              "IPO is velocity",
1004                              10,50,150,19, &sp->flags, 
1005                              0.0, 1.0, 0, 0, 
1006                              "Interpret the IPO value as a "
1007                              "velocity instead of a frame number");
1008
1009                 uiDefButBitI(block, TOG, SEQ_SPEED_BLEND,
1010                              B_SEQ_BUT_RELOAD, 
1011                              "Enable frame blending",
1012                              10,30,150,19, &sp->flags, 
1013                              0.0, 1.0, 0, 0, 
1014                              "Blend two frames into the "
1015                              "target for a smoother result");
1016                 
1017                 uiDefButBitI(block, TOG, SEQ_SPEED_COMPRESS_IPO_Y,
1018                              B_SEQ_BUT_RELOAD, 
1019                              "IPO value runs from [0..1]",
1020                              10,10,150,19, &sp->flags, 
1021                              0.0, 1.0, 0, 0, 
1022                              "Scale IPO value to get the "
1023                              "target frame number.");
1024         }
1025
1026         uiBlockEndAlign(block);
1027 }
1028
1029 static void seq_panel_proxy()
1030 {
1031         Sequence *last_seq = get_last_seq();
1032         uiBlock *block;
1033         block = uiNewBlock(&curarea->uiblocks, "seq_panel_proxy", 
1034                            UI_EMBOSS, UI_HELV, curarea->win);
1035
1036         if(uiNewPanel(curarea, block, "Proxy", "Sequencer", 
1037                       10, 230, 318, 204) == 0) return;
1038
1039         uiBlockBeginAlign(block);
1040
1041         uiDefButBitI(block, TOG, SEQ_USE_PROXY, 
1042                      B_SEQ_BUT_RELOAD, "Use Proxy", 
1043                      10,140,150,19, &last_seq->flag, 
1044                      0.0, 21.0, 100, 0, 
1045                      "Use a preview proxy for this strip");
1046         
1047         if (last_seq->flag & SEQ_USE_PROXY) {
1048
1049
1050         }
1051
1052         uiBlockEndAlign(block);
1053 }
1054
1055
1056 void sequencer_panels()
1057 {
1058         Sequence *last_seq = get_last_seq();
1059         int panels = 0;
1060         int type;
1061
1062         if(last_seq == NULL) {
1063                 return;
1064         }
1065         
1066         type = last_seq->type;
1067
1068         panels = SEQ_PANEL_EDITING;
1069
1070         if (type == SEQ_MOVIE || type == SEQ_IMAGE || type == SEQ_SCENE
1071             || type == SEQ_HD_SOUND) {
1072                 panels |= SEQ_PANEL_INPUT | SEQ_PANEL_FILTER | SEQ_PANEL_PROXY;
1073         }
1074
1075         if (type == SEQ_RAM_SOUND) {
1076                 panels |= SEQ_PANEL_FILTER;
1077         }
1078
1079         if (type == SEQ_PLUGIN || type >= SEQ_EFFECT) {
1080                 panels |= SEQ_PANEL_EFFECT | SEQ_PANEL_PROXY;
1081         }
1082
1083         if (panels & SEQ_PANEL_EDITING) {
1084                 seq_panel_editing();
1085         }
1086
1087         if (panels & SEQ_PANEL_INPUT) {
1088                 seq_panel_input();
1089         }
1090
1091         if (panels & SEQ_PANEL_FILTER) {
1092                 if (type == SEQ_RAM_SOUND || type == SEQ_HD_SOUND) {
1093                         seq_panel_filter_audio();
1094                 } else {
1095                         seq_panel_filter_video();
1096                 }
1097         }
1098
1099         if (panels & SEQ_PANEL_EFFECT) {
1100                 seq_panel_effect();
1101         }
1102
1103         if (panels & SEQ_PANEL_PROXY) {
1104                 seq_panel_proxy();
1105         }
1106 }
1107
1108
1109 void do_sequencer_panels(unsigned short event)
1110 {
1111         Sequence *last_seq = get_last_seq();
1112
1113         switch(event) {
1114         case B_SEQ_BUT_PLUGIN:
1115         case B_SEQ_BUT_EFFECT:
1116                 update_changed_seq_and_deps(last_seq, 0, 1);
1117                 break;
1118         case B_SEQ_BUT_RELOAD_FILE:
1119                 reload_sequence_new_file(last_seq);
1120                 break;
1121         case B_SEQ_BUT_RELOAD:
1122         case B_SEQ_BUT_RELOAD_ALL:
1123                 update_seq_ipo_rect(last_seq);
1124                 update_seq_icu_rects(last_seq);
1125
1126                 free_imbuf_seq();       // frees all
1127
1128                 break;
1129         case B_SEQ_BUT_TRANSFORM:
1130                 calc_sequence(last_seq);
1131                 if (test_overlap_seq(last_seq))
1132                         shuffle_seq(last_seq);
1133                 break;
1134         }
1135
1136         if (event == B_SEQ_BUT_RELOAD_ALL) {
1137                 allqueue(REDRAWALL, 0);
1138         } else {
1139                 allqueue(REDRAWSEQ, 0);
1140         }
1141 }
1142
1143
1144 /* ************************* SCENE *********************** */
1145
1146
1147 static void output_pic(char *name)
1148 {
1149         strcpy(G.scene->r.pic, name);
1150         allqueue(REDRAWBUTSSCENE, 0);
1151         BIF_undo_push("Change output picture directory");
1152 }
1153
1154 static void backbuf_pic(char *name)
1155 {
1156         Image *ima;
1157         
1158         strcpy(G.scene->r.backbuf, name);
1159         allqueue(REDRAWBUTSSCENE, 0);
1160
1161         ima= BKE_add_image_file(name);
1162         if(ima)
1163                 BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
1164
1165         BIF_undo_push("Change background picture");
1166 }
1167
1168 static void ftype_pic(char *name)
1169 {
1170         strcpy(G.scene->r.ftype, name);
1171         allqueue(REDRAWBUTSSCENE, 0);
1172 }
1173
1174 static void run_playanim(char *file) 
1175 {
1176         extern char bprogname[];        /* usiblender.c */
1177         char str[FILE_MAX];
1178         int pos[2], size[2];
1179
1180         /* use current settings for defining position of window. it actually should test image size */
1181         calc_renderwin_rectangle((G.scene->r.xsch*G.scene->r.size)/100, 
1182                                                          (G.scene->r.ysch*G.scene->r.size)/100, G.winpos, pos, size);
1183 #ifdef WIN32
1184         sprintf(str, "%s -a -p %d %d -f %d %g \"%s\"", bprogname, pos[0], pos[1], G.scene->r.frs_sec, G.scene->r.frs_sec_base, file);
1185 #else
1186         sprintf(str, "\"%s\" -a -p %d %d -f %d %g \"%s\"", bprogname, pos[0], pos[1], G.scene->r.frs_sec, G.scene->r.frs_sec_base, file);
1187 #endif
1188         system(str);
1189 }
1190
1191 void playback_anim(void)
1192 {       
1193         char file[FILE_MAX];
1194
1195         if(BKE_imtype_is_movie(G.scene->r.imtype)) {
1196                 switch (G.scene->r.imtype) {
1197 #ifdef WITH_QUICKTIME
1198                         case R_QUICKTIME:
1199                                 makeqtstring(file);
1200                                 break;
1201 #endif
1202 #ifdef WITH_FFMPEG
1203                 case R_FFMPEG:
1204                         makeffmpegstring(file);
1205                         break;
1206 #endif
1207                 default:
1208                         makeavistring(&G.scene->r, file);
1209                         break;
1210                 }
1211                 if(BLI_exist(file)) {
1212                         run_playanim(file);
1213                 }
1214                 else error("Can't find movie: %s", file);
1215         }
1216         else {
1217                 BKE_makepicstring(file, G.scene->r.pic, G.scene->r.sfra, G.scene->r.imtype);
1218                 if(BLI_exist(file)) {
1219                         run_playanim(file);
1220                 }
1221                 else error("Can't find image: %s", file);
1222         }
1223 }
1224
1225 #ifdef WITH_FFMPEG
1226 static void set_ffmpeg_preset(int preset);
1227 #endif
1228
1229 void do_render_panels(unsigned short event)
1230 {
1231         ScrArea *sa;
1232         ID *id;
1233
1234         switch(event) {
1235
1236         case B_DORENDER:
1237                 BIF_do_render(0);
1238                 break;
1239         case B_RTCHANGED:
1240                 allqueue(REDRAWALL, 0);
1241                 break;
1242         case B_SWITCHRENDER:
1243                 /* new panels added, so... */
1244                 G.buts->re_align= 1;
1245                 allqueue(REDRAWBUTSSCENE, 0);
1246                 break;
1247         case B_PLAYANIM:
1248                 playback_anim();
1249                 break;
1250                 
1251         case B_DOANIM:
1252                 BIF_do_render(1);
1253                 break;
1254         
1255         case B_FS_PIC:
1256                 sa= closest_bigger_area();
1257                 areawinset(sa->win);
1258                 if(G.qual == LR_CTRLKEY)
1259                         activate_imageselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic);
1260                 else
1261                         activate_fileselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic);
1262                 break;
1263
1264         case B_FS_BACKBUF:
1265                 sa= closest_bigger_area();
1266                 areawinset(sa->win);
1267                 if(G.qual == LR_CTRLKEY)
1268                         activate_imageselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
1269                 else
1270                         activate_fileselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
1271                 break;
1272
1273         case B_FS_FTYPE:
1274                 sa= closest_bigger_area();
1275                 areawinset(sa->win);
1276                 if(G.qual == LR_CTRLKEY)
1277                         activate_imageselect(FILE_SPECIAL, "SELECT FTYPE", G.scene->r.ftype, ftype_pic);
1278                 else
1279                         activate_fileselect(FILE_SPECIAL, "SELECT FTYPE", G.scene->r.ftype, ftype_pic);
1280                 break;
1281         
1282         case B_PR_PAL:
1283                 G.scene->r.xsch= 720;
1284                 G.scene->r.ysch= 576;
1285                 G.scene->r.xasp= 54;
1286                 G.scene->r.yasp= 51;
1287                 G.scene->r.size= 100;
1288                 G.scene->r.frs_sec= 25;
1289                 G.scene->r.frs_sec_base= 1;
1290                 G.scene->r.mode &= ~R_PANORAMA;
1291                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1292 #ifdef WITH_FFMPEG
1293                 G.scene->r.ffcodecdata.gop_size = 15;
1294 #endif          
1295                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1296                 BIF_undo_push("Set PAL");
1297                 allqueue(REDRAWBUTSSCENE, 0);
1298                 allqueue(REDRAWVIEWCAM, 0);
1299                 break;
1300
1301         case B_FILETYPEMENU:
1302                 allqueue(REDRAWBUTSSCENE, 0);
1303 #ifdef WITH_FFMPEG
1304                 if (G.scene->r.imtype == R_FFMPEG) {
1305                         if (G.scene->r.ffcodecdata.type <= 0 ||
1306                             G.scene->r.ffcodecdata.codec <= 0 ||
1307                             G.scene->r.ffcodecdata.audio_codec <= 0 ||
1308                             G.scene->r.ffcodecdata.video_bitrate <= 1) {
1309                                 G.scene->r.ffcodecdata.codec 
1310                                         = CODEC_ID_MPEG2VIDEO;
1311                                 set_ffmpeg_preset(FFMPEG_PRESET_DVD);
1312                         }
1313
1314                         if (G.scene->r.ffcodecdata.audio_codec <= 0) {
1315                                 G.scene->r.ffcodecdata.audio_codec 
1316                                         = CODEC_ID_MP2;
1317                                 G.scene->r.ffcodecdata.audio_bitrate = 128;
1318                         }
1319                         break;
1320                 }
1321 #endif
1322 #if defined (_WIN32) || defined (__APPLE__)
1323                 // fall through to codec settings if this is the first
1324                 // time R_AVICODEC is selected for this scene.
1325                 if (((G.scene->r.imtype == R_AVICODEC) 
1326                          && (G.scene->r.avicodecdata == NULL)) ||
1327                         ((G.scene->r.imtype == R_QUICKTIME) 
1328                          && (G.scene->r.qtcodecdata == NULL))) {
1329                 } else {
1330                   break;
1331                 }
1332 #endif /*_WIN32 || __APPLE__ */
1333
1334         case B_SELECTCODEC:
1335 #if defined (_WIN32) || defined (__APPLE__)
1336                 if ((G.scene->r.imtype == R_QUICKTIME)) { /* || (G.scene->r.qtcodecdata)) */
1337 #ifdef WITH_QUICKTIME
1338                         get_qtcodec_settings();
1339 #endif /* WITH_QUICKTIME */
1340                 }
1341 #if defined (_WIN32) && !defined(FREE_WINDOWS)
1342                 else
1343                         get_avicodec_settings();
1344 #endif /* _WIN32 && !FREE_WINDOWS */
1345 #endif /* _WIN32 || __APPLE__ */
1346                 break;
1347
1348         case B_PR_HD:
1349                 G.scene->r.xsch= 1920;
1350                 G.scene->r.ysch= 1080;
1351                 G.scene->r.xasp= 1;
1352                 G.scene->r.yasp= 1;
1353                 G.scene->r.size= 100;
1354                 G.scene->r.mode &= ~R_PANORAMA;
1355                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1356                 
1357                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1358                 BIF_undo_push("Set FULL");
1359                 allqueue(REDRAWBUTSSCENE, 0);
1360                 allqueue(REDRAWVIEWCAM, 0);
1361                 break;
1362         case B_PR_FULL:
1363                 G.scene->r.xsch= 1280;
1364                 G.scene->r.ysch= 1024;
1365                 G.scene->r.xasp= 1;
1366                 G.scene->r.yasp= 1;
1367                 G.scene->r.size= 100;
1368                 G.scene->r.mode &= ~R_PANORAMA;
1369                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1370
1371                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1372                 BIF_undo_push("Set FULL");
1373                 allqueue(REDRAWBUTSSCENE, 0);
1374                 allqueue(REDRAWVIEWCAM, 0);
1375                 break;
1376         case B_PR_PRV:
1377                 G.scene->r.xsch= 640;
1378                 G.scene->r.ysch= 512;
1379                 G.scene->r.xasp= 1;
1380                 G.scene->r.yasp= 1;
1381                 G.scene->r.size= 50;
1382                 G.scene->r.mode &= ~R_PANORAMA;
1383                 G.scene->r.xparts=  G.scene->r.yparts= 2;
1384
1385                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1386                 allqueue(REDRAWVIEWCAM, 0);
1387                 allqueue(REDRAWBUTSSCENE, 0);
1388                 break;
1389         case B_PR_PAL169:
1390                 G.scene->r.xsch= 720;
1391                 G.scene->r.ysch= 576;
1392                 G.scene->r.xasp= 64;
1393                 G.scene->r.yasp= 45;
1394                 G.scene->r.size= 100;
1395                 G.scene->r.frs_sec= 25;
1396                 G.scene->r.frs_sec_base= 1;
1397                 G.scene->r.mode &= ~R_PANORAMA;
1398                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1399 #ifdef WITH_FFMPEG
1400                 G.scene->r.ffcodecdata.gop_size = 15;
1401 #endif          
1402
1403                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1404                 BIF_undo_push("Set PAL 16/9");
1405                 allqueue(REDRAWVIEWCAM, 0);
1406                 allqueue(REDRAWBUTSSCENE, 0);
1407                 break;
1408         case B_PR_PC:
1409                 G.scene->r.xsch= 640;
1410                 G.scene->r.ysch= 480;
1411                 G.scene->r.xasp= 100;
1412                 G.scene->r.yasp= 100;
1413                 G.scene->r.size= 100;
1414                 G.scene->r.mode &= ~R_PANORAMA;
1415                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1416
1417                 BLI_init_rctf(&G.scene->r.safety, 0.0, 1.0, 0.0, 1.0);
1418                 BIF_undo_push("Set PC");
1419                 allqueue(REDRAWVIEWCAM, 0);
1420                 allqueue(REDRAWBUTSSCENE, 0);
1421                 break;
1422         case B_PR_PRESET:
1423                 G.scene->r.xsch= 720;
1424                 G.scene->r.ysch= 576;
1425                 G.scene->r.xasp= 54;
1426                 G.scene->r.yasp= 51;
1427                 G.scene->r.size= 100;
1428                 G.scene->r.mode= R_OSA+R_SHADOW+R_FIELDS;
1429                 G.scene->r.imtype= R_TARGA;
1430                 G.scene->r.xparts=  G.scene->r.yparts= 4;
1431
1432                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1433                 BIF_undo_push("Set Default");
1434                 allqueue(REDRAWVIEWCAM, 0);
1435                 allqueue(REDRAWBUTSSCENE, 0);
1436                 break;
1437         case B_PR_PANO:
1438                 G.scene->r.xsch= 576;
1439                 G.scene->r.ysch= 176;
1440                 G.scene->r.xasp= 115;
1441                 G.scene->r.yasp= 100;
1442                 G.scene->r.size= 100;
1443                 G.scene->r.mode |= R_PANORAMA;
1444                 G.scene->r.xparts=  16;
1445                 G.scene->r.yparts= 1;
1446
1447                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1448                 BIF_undo_push("Set Panorama");
1449                 allqueue(REDRAWVIEWCAM, 0);
1450                 allqueue(REDRAWBUTSSCENE, 0);
1451                 break;
1452         case B_PR_NTSC:
1453                 G.scene->r.xsch= 720;
1454                 G.scene->r.ysch= 480;
1455                 G.scene->r.xasp= 10;
1456                 G.scene->r.yasp= 11;
1457                 G.scene->r.size= 100;
1458                 G.scene->r.frs_sec= 30;
1459                 G.scene->r.frs_sec_base = 1.001;
1460                 G.scene->r.mode &= ~R_PANORAMA;
1461                 G.scene->r.xparts=  G.scene->r.yparts= 2;
1462 #ifdef WITH_FFMPEG
1463                 G.scene->r.ffcodecdata.gop_size = 18;
1464 #endif          
1465                 
1466                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
1467                 BIF_undo_push("Set NTSC");
1468                 allqueue(REDRAWBUTSSCENE, 0);
1469                 allqueue(REDRAWVIEWCAM, 0);
1470                 break;
1471
1472         case B_SETBROWSE:
1473                 id= (ID*) G.scene->set;
1474                 
1475                 if (G.buts->menunr==-2) {
1476                          activate_databrowse(id, ID_SCE, 0, B_SETBROWSE, &G.buts->menunr, do_render_panels);
1477                 } 
1478                 else if (G.buts->menunr>0) {
1479                         Scene *newset= (Scene*) BLI_findlink(&G.main->scene, G.buts->menunr-1);
1480                         
1481                         if (newset==G.scene)
1482                                 error("Can't use the same scene as its own set");
1483                         else if (newset) {
1484                                 G.scene->set= newset;
1485                                 if (scene_check_setscene(G.scene)==0)
1486                                         error("This would create a cycle");
1487
1488                                 allqueue(REDRAWBUTSSCENE, 0);
1489                                 allqueue(REDRAWVIEW3D, 0);
1490                                 BIF_undo_push("Change Set Scene");
1491                         }
1492                 }  
1493                 break;
1494         case B_CLEARSET:
1495                 G.scene->set= NULL;
1496                 allqueue(REDRAWBUTSSCENE, 0);
1497                 allqueue(REDRAWVIEW3D, 0);
1498                 BIF_undo_push("Clear Set Scene");
1499                 
1500                 break;
1501         case B_SET_EDGE:
1502                 allqueue(REDRAWBUTSSCENE, 0);
1503                 break;
1504         case B_SET_ZBLUR:
1505                 G.scene->r.mode &= ~R_EDGE;
1506                 allqueue(REDRAWBUTSSCENE, 0);
1507                 break;
1508         case B_ADD_RENDERLAYER:
1509                 if(G.scene->r.actlay==32767) {
1510                         scene_add_render_layer(G.scene);
1511                         G.scene->r.actlay= BLI_countlist(&G.scene->r.layers) - 1;
1512                 }
1513                 allqueue(REDRAWBUTSSCENE, 0);
1514                 allqueue(REDRAWNODE, 0);
1515                 break;
1516         case B_SET_PASS:
1517                 if(G.scene->nodetree) {
1518                         ntreeCompositForceHidden(G.scene->nodetree);
1519                         allqueue(REDRAWNODE, 0);
1520                 }
1521                 allqueue(REDRAWBUTSSCENE, 0);
1522                 allqueue(REDRAWOOPS, 0);
1523         }
1524 }
1525
1526 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
1527 static uiBlock *edge_render_menu(void *arg_unused)
1528 {
1529         uiBlock *block;
1530         
1531         block= uiNewBlock(&curarea->uiblocks, "edge render", UI_EMBOSS, UI_HELV, curarea->win);
1532                 
1533         /* use this for a fake extra empy space around the buttons */
1534         uiDefBut(block, LABEL, 0, "",  0, 0, 220, 115, NULL,  0, 0, 0, 0, "");
1535         
1536         uiDefButS(block, NUM, 0,"Eint:",        45,75,175,19,  &G.scene->r.edgeint, 0.0, 255.0, 0, 0,
1537                   "Sets edge intensity for Toon shading");
1538
1539         /* color settings for the toon shading */
1540         uiDefButF(block, COL, 0, "",            10, 10,30,60,  &(G.scene->r.edgeR), 0, 0, 0, B_EDGECOLSLI, "");
1541         
1542         uiBlockBeginAlign(block);
1543         uiDefButF(block, NUMSLI, 0, "R ",   45, 50, 175,19,   &G.scene->r.edgeR, 0.0, 1.0, B_EDGECOLSLI, 0,
1544                   "Color for edges in toon shading mode.");
1545         uiDefButF(block, NUMSLI, 0, "G ",       45, 30, 175,19,  &G.scene->r.edgeG, 0.0, 1.0, B_EDGECOLSLI, 0,
1546                   "Color for edges in toon shading mode.");
1547         uiDefButF(block, NUMSLI, 0, "B ",       45, 10, 175,19,  &G.scene->r.edgeB, 0.0, 1.0, B_EDGECOLSLI, 0,
1548                   "Color for edges in toon shading mode.");
1549
1550         
1551         uiBlockSetDirection(block, UI_TOP);
1552         
1553         return block;
1554 }
1555
1556
1557 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
1558 static uiBlock *framing_render_menu(void *arg_unused)
1559 {
1560         uiBlock *block;
1561         short yco = 190, xco = 0;
1562         int randomcolorindex = 1234;
1563
1564         block= uiNewBlock(&curarea->uiblocks, "framing_options", UI_EMBOSS, UI_HELV, curarea->win);
1565
1566         /* use this for a fake extra empy space around the buttons */
1567         uiDefBut(block, LABEL, 0, "",                   -5, -10, 295, 224, NULL, 0, 0, 0, 0, "");
1568
1569         uiDefBut(block, LABEL, 0, "Framing:", xco, yco, 68,19, 0, 0, 0, 0, 0, "");
1570         uiBlockBeginAlign(block);
1571         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");
1572         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");
1573         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");
1574         uiBlockEndAlign(block);
1575
1576         yco -= 25;
1577         xco = 40;
1578
1579         uiDefButF(block, COL, 0, "",                0, yco - 58 + 18, 33, 58, &G.scene->framing.col[0], 0, 0, 0, randomcolorindex, "");
1580
1581         uiBlockBeginAlign(block);
1582         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");
1583         yco -= 20;
1584         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");
1585         yco -= 20;
1586         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");
1587         uiBlockEndAlign(block);
1588         
1589         xco = 0;
1590         uiDefBut(block, LABEL, 0, "Fullscreen:",                xco, yco-=30, 100, 19, 0, 0.0, 0.0, 0, 0, "");
1591         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");
1592         uiBlockBeginAlign(block);
1593         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.");
1594         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.");
1595         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.");
1596         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.");
1597         uiBlockEndAlign(block);
1598
1599         /* stereo settings */
1600         /* can't use any definition from the game engine here so hardcode it. Change it here when it changes there!
1601          * RAS_IRasterizer has definitions:
1602          * RAS_STEREO_NOSTEREO           1
1603          * RAS_STEREO_QUADBUFFERED 2
1604          * RAS_STEREO_ABOVEBELOW         3
1605          * RAS_STEREO_INTERLACED         4       future
1606          * RAS_STEREO_ANAGLYPH          5
1607          * RAS_STEREO_SIDEBYSIDE        6
1608          * RAS_STEREO_VINTERLACE        7
1609          */
1610         uiBlockBeginAlign(block);
1611         uiDefButS(block, ROW, 0, "No Stereo", xco, yco-=30, 88, 19, &(G.scene->r.stereomode), 7.0, 1.0, 0, 0, "Disables stereo");
1612         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");
1613         uiDefButS(block, ROW, 0, "Syncdouble", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 3.0, 0, 0, "Enables syncdoubling stereo method");
1614         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");
1615         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");
1616         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");
1617         
1618         uiBlockEndAlign(block);
1619
1620         uiBlockSetDirection(block, UI_TOP);
1621
1622         return block;
1623 }
1624
1625 #ifdef WITH_FFMPEG
1626
1627 static char* ffmpeg_format_pup(void) 
1628 {
1629         static char string[2048];
1630         char formatstring[2048];
1631 #if 0
1632        int i = 0;
1633        int stroffs = 0;
1634        AVOutputFormat* next = first_oformat;
1635        formatstring = "FFMpeg format: %%t";
1636       sprintf(string, formatstring);
1637        formatstring = "|%s %%x%d";
1638        /* FIXME: This should only be generated once */
1639        while (next != NULL) {
1640                if (next->video_codec != CODEC_ID_NONE && !(next->flags & AVFMT_NOFILE)) {
1641                        sprintf(string+stroffs, formatstring, next->name, i++);
1642                        stroffs += strlen(string+stroffs);
1643                }
1644                next = next->next;
1645        }
1646        return string;
1647 #endif
1648        strcpy(formatstring, "FFMpeg format: %%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");
1649        sprintf(string, formatstring,
1650                "MPEG-1", FFMPEG_MPEG1,
1651                "MPEG-2", FFMPEG_MPEG2,
1652                "MPEG-4", FFMPEG_MPEG4,
1653                "AVI",    FFMPEG_AVI,
1654                "Quicktime", FFMPEG_MOV,
1655                "DV", FFMPEG_DV,
1656                "H264", FFMPEG_H264,
1657                "XVid", FFMPEG_XVID);
1658        return string;
1659 }
1660
1661 static char* ffmpeg_preset_pup(void) 
1662 {
1663         static char string[2048];
1664         char formatstring[2048];
1665
1666        strcpy(formatstring, "FFMpeg preset: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
1667        sprintf(string, formatstring,
1668                "", FFMPEG_PRESET_NONE,
1669                "DVD", FFMPEG_PRESET_DVD,
1670                "SVCD", FFMPEG_PRESET_SVCD,
1671                "VCD", FFMPEG_PRESET_VCD,
1672                "DV", FFMPEG_PRESET_DV);
1673        return string;
1674 }
1675
1676
1677 static char* ffmpeg_codec_pup(void) {
1678        static char string[2048];
1679        char formatstring[2048];
1680        strcpy(formatstring, "FFMpeg format: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
1681        sprintf(string, formatstring,
1682                "MPEG1", CODEC_ID_MPEG1VIDEO,
1683                "MPEG2", CODEC_ID_MPEG2VIDEO,
1684                "MPEG4(divx)", CODEC_ID_MPEG4,
1685                "HuffYUV", CODEC_ID_HUFFYUV,
1686                "DV", CODEC_ID_DVVIDEO,
1687                "H264", CODEC_ID_H264,
1688                "XVid", CODEC_ID_XVID);
1689        return string;
1690
1691 }
1692
1693 static char* ffmpeg_audio_codec_pup(void) {
1694        static char string[2048];
1695        char formatstring[2048];
1696        strcpy(formatstring, "FFMpeg format: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
1697        sprintf(string, formatstring,
1698                "MP2", CODEC_ID_MP2,
1699                "MP3", CODEC_ID_MP3,
1700                "AC3", CODEC_ID_AC3,
1701                "AAC", CODEC_ID_AAC,
1702                "PCM", CODEC_ID_PCM_S16LE);
1703        return string;
1704
1705 }
1706
1707 #endif
1708
1709 static char *imagetype_pup(void)
1710 {
1711         static char string[1024];
1712         char formatstring[1024];
1713         char appendstring[1024];
1714
1715         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");
1716
1717 #ifdef __sgi
1718         strcat(formatstring, "|%s %%x%d");      // add space for Movie
1719 #endif
1720
1721         strcat(formatstring, "|%s %%x%d");      // add space for PNG
1722 /*  Commented out until implemented
1723 #ifdef WITH_DDS
1724         strcat(formatstring, "|%s %%x%d");      // add space for DDS
1725 #endif
1726 */
1727         strcat(formatstring, "|%s %%x%d");      // add space for BMP
1728         strcat(formatstring, "|%s %%x%d");      // add space for Radiance HDR
1729         strcat(formatstring, "|%s %%x%d");      // add space for Cineon
1730         strcat(formatstring, "|%s %%x%d");      // add space for DPX
1731         
1732 #ifdef _WIN32
1733         strcat(formatstring, "|%s %%x%d");      // add space for AVI Codec
1734 #endif
1735
1736 #ifdef WITH_FFMPEG
1737        strcat(formatstring, "|%s %%x%d"); // Add space for ffmpeg
1738 #endif
1739        strcat(formatstring, "|%s %%x%d"); // Add space for frameserver
1740
1741 #ifdef WITH_QUICKTIME
1742         if(G.have_quicktime)
1743                 strcat(formatstring, "|%s %%x%d");      // add space for Quicktime
1744 #endif
1745
1746         if(G.have_quicktime) {
1747                 sprintf(string, formatstring,
1748                         "Frameserver",   R_FRAMESERVER,
1749 #ifdef WITH_FFMPEG
1750                        "FFMpeg",         R_FFMPEG,
1751 #endif
1752                         "AVI Raw",        R_AVIRAW,
1753                         "AVI Jpeg",       R_AVIJPEG,
1754 #ifdef _WIN32
1755                         "AVI Codec",      R_AVICODEC,
1756 #endif
1757 #ifdef WITH_QUICKTIME
1758                         "QuickTime",      R_QUICKTIME,
1759 #endif
1760                         "Targa",          R_TARGA,
1761                         "Targa Raw",      R_RAWTGA,
1762                         "PNG",            R_PNG,
1763 /* commented out until implemented 
1764 #ifdef WITH_DDS
1765                         "DDS",            R_DDS,
1766 #endif
1767 */
1768                         "BMP",            R_BMP,
1769                         "Jpeg",           R_JPEG90,
1770                         "HamX",           R_HAMX,
1771                         "Iris",           R_IRIS,
1772                         "Radiance HDR",   R_RADHDR,
1773                         "Cineon",                 R_CINEON,
1774                         "DPX",                    R_DPX
1775 #ifdef __sgi
1776                         ,"Movie",          R_MOVIE
1777 #endif
1778                 );
1779         } else {
1780                 sprintf(string, formatstring,
1781                         "Frameserver",   R_FRAMESERVER,
1782 #ifdef WITH_FFMPEG
1783                        "FFMpeg",         R_FFMPEG,
1784 #endif
1785                         "AVI Raw",        R_AVIRAW,
1786                         "AVI Jpeg",       R_AVIJPEG,
1787 #ifdef _WIN32
1788                         "AVI Codec",      R_AVICODEC,
1789 #endif
1790                         "Targa",          R_TARGA,
1791                         "Targa Raw",      R_RAWTGA,
1792                         "PNG",            R_PNG,
1793 #ifdef WITH_DDS
1794                         "DDS",            R_DDS,
1795 #endif
1796                         "BMP",            R_BMP,
1797                         "Jpeg",           R_JPEG90,
1798                         "HamX",           R_HAMX,
1799                         "Iris",           R_IRIS,
1800                         "Radiance HDR",   R_RADHDR,
1801                         "Cineon",                 R_CINEON,
1802                         "DPX",                    R_DPX
1803 #ifdef __sgi
1804                         ,"Movie",          R_MOVIE
1805 #endif
1806                 );
1807         }
1808
1809 #ifdef WITH_OPENEXR
1810         strcpy(formatstring, "|%s %%x%d");
1811         sprintf(appendstring, formatstring, "OpenEXR", R_OPENEXR);
1812         strcat(string, appendstring);
1813         sprintf(appendstring, formatstring, "MultiLayer", R_MULTILAYER);
1814         strcat(string, appendstring);
1815 #endif
1816         
1817         if (G.have_libtiff) {
1818                 strcpy(formatstring, "|%s %%x%d");
1819                 sprintf(appendstring, formatstring, "TIFF", R_TIFF);
1820                 strcat(string, appendstring);
1821         }
1822
1823         return (string);
1824 }
1825
1826 #ifdef _WIN32
1827 static char *avicodec_str(void)
1828 {
1829         static char string[1024];
1830
1831         sprintf(string, "Codec: %s", G.scene->r.avicodecdata->avicodecname);
1832
1833         return string;
1834 }
1835 #endif
1836
1837 static void render_panel_output(void)
1838 {
1839         ID *id;
1840         int a,b;
1841         uiBlock *block;
1842         char *strp;
1843
1844
1845         block= uiNewBlock(&curarea->uiblocks, "render_panel_output", UI_EMBOSS, UI_HELV, curarea->win);
1846         if(uiNewPanel(curarea, block, "Output", "Render", 0, 0, 318, 204)==0) return;
1847         
1848         uiBlockBeginAlign(block);
1849         uiDefIconBut(block, BUT, B_FS_PIC, ICON_FILESEL,        10, 190, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Pics dir/name");
1850         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");
1851         uiDefIconBut(block, BUT,B_FS_BACKBUF, ICON_FILESEL, 10, 168, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Backbuf image");
1852         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");
1853         uiDefIconBut(block, BUT,B_FS_FTYPE, ICON_FILESEL,       10, 146, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Ftype image");
1854         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");
1855         uiBlockEndAlign(block);
1856         
1857         
1858         /* SET BUTTON */
1859         uiBlockBeginAlign(block);
1860         id= (ID *)G.scene->set;
1861         IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->scene), id, &(G.buts->menunr));
1862         if(strp[0])
1863                 uiDefButS(block, MENU, B_SETBROWSE, strp, 10, 120, 20, 20, &(G.buts->menunr), 0, 0, 0, 0, "Scene to link as a Set");
1864         MEM_freeN(strp);
1865
1866         if(G.scene->set) {
1867                 uiSetButLock(1, NULL);
1868                 uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, B_NOP, "",    31, 120, 100, 20, &(G.scene->set), "Name of the Set");
1869                 uiClearButLock();
1870                 uiDefIconBut(block, BUT, B_CLEARSET, ICON_X,            132, 120, 20, 20, 0, 0, 0, 0, 0, "Remove Set link");
1871         }
1872         uiBlockEndAlign(block);
1873
1874         uiBlockSetCol(block, TH_BUT_SETTING1);
1875         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");        
1876         uiDefButS(block, NUM, B_NOP, "Threads:",                                10, 68, 100, 20, &G.scene->r.threads, 1, BLENDER_MAX_THREADS, 0, 0, "Amount of threads for render (takes advantage of multi-core and multi-processor computers)");
1877         uiBlockSetCol(block, TH_AUTO);
1878                 
1879         uiBlockBeginAlign(block);
1880         for(b=2; b>=0; b--)
1881                 for(a=0; a<3; a++)
1882                         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");
1883         uiBlockEndAlign(block);
1884
1885         uiDefButBitS(block, TOG, R_EXR_TILE_FILE, B_NOP, "Save Buffers", 72, 31, 120, 19, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Save the tiles for all RenderLayers and used SceneNodes to files, to save memory");
1886         
1887         uiDefButS(block, MENU, B_REDR, "Render Display %t|Render Window %x1|Image Editor %x0|Full Screen %x2",  
1888                                         72, 10, 120, 19, &G.displaymode, 0.0, (float)R_DISPLAYWIN, 0, 0, "Sets render output display");
1889
1890         uiDefButBitS(block, TOG, R_EXTENSION, B_NOP, "Extensions", 205, 10, 105, 19, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds filetype extensions to the filename when rendering animations");
1891
1892         /* Dither control */
1893         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)");
1894         
1895         /* Toon shading buttons */
1896         uiBlockBeginAlign(block);
1897         uiDefButBitI(block, TOG, R_EDGE, B_NOP,"Edge",   100, 94, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon Edge-enhance");
1898         uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 170, 94, 140, 20, "Display Edge settings");
1899         uiBlockEndAlign(block);
1900         
1901         uiBlockBeginAlign(block);
1902         uiDefButBitS(block, TOG, R_NO_TEX, B_NOP, "Disable Tex", 115, 68, 70, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Disables Textures for render");
1903         uiDefButBitS(block, TOG, R_FREE_IMAGE, B_NOP, "Free Tex Images", 205, 68, 100, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Frees all Images used by Textures after each render");
1904         uiBlockEndAlign(block);
1905 }
1906
1907 static void do_bake_func(void *unused_v, void *unused_p)
1908 {
1909         objects_bake_render(0);
1910 }
1911
1912 static void render_panel_bake(void)
1913 {
1914         uiBlock *block;
1915         uiBut *but;
1916         
1917         block= uiNewBlock(&curarea->uiblocks, "render_panel_bake", UI_EMBOSS, UI_HELV, curarea->win);
1918         uiNewPanelTabbed("Anim", "Render");
1919         if(uiNewPanel(curarea, block, "Bake", "Render", 320, 0, 318, 204)==0) return;
1920         
1921         but= uiDefBut(block, BUT, B_NOP, "BAKE",        10, 150, 190,40, 0, 0, 0, 0, 0, "Start the bake render for selected Objects");
1922         uiButSetFunc(but, do_bake_func, NULL, NULL);
1923
1924         uiBlockBeginAlign(block);
1925         uiDefButBitS(block, TOG, R_BAKE_TO_ACTIVE, B_DIFF, "Selected to Active", 10,120,190,20,&G.scene->r.bake_flag, 0.0, 0, 0, 0, "Bake shading on the surface of selected objects to the active object");
1926         uiDefButF(block, NUM, B_DIFF, "Dist:", 10,100,(G.scene->r.bake_mode == RE_BAKE_NORMALS)? 95: 190,20,&G.scene->r.bake_maxdist, 0.0, 10.0, 1, 0, "Maximum distance from active object to other object");
1927
1928         if(G.scene->r.bake_mode == RE_BAKE_NORMALS)
1929                 uiDefButS(block, MENU, B_DIFF, "Normal Space %t|Camera %x0|World %x1|Object %x2|Tangent %x3", 
1930                         105,100,95,20, &G.scene->r.bake_normal_space, 0, 0, 0, 0, "Choose normal space for baking");
1931         uiBlockEndAlign(block);
1932
1933 #if 0   
1934         uiBlockBeginAlign(block);
1935         uiDefButBitS(block, TOG, R_BAKE_OSA, B_DIFF, "OSA",             10,120,190,20, &G.scene->r.bake_flag, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)");
1936         uiDefButS(block, ROW,B_DIFF,"5",                        10,100,50,20,&G.scene->r.bake_osa,2.0,5.0, 0, 0, "Sets oversample level to 5");
1937         uiDefButS(block, ROW,B_DIFF,"8",                        60,100,45,20,&G.scene->r.bake_osa,2.0,8.0, 0, 0, "Sets oversample level to 8");
1938         uiDefButS(block, ROW,B_DIFF,"11",                       105,100,45,20,&G.scene->r.bake_osa,2.0,11.0, 0, 0, "Sets oversample level to 11");
1939         uiDefButS(block, ROW,B_DIFF,"16",                       150,100,50,20,&G.scene->r.bake_osa,2.0,16.0, 0, 0, "Sets oversample level to 16");
1940 #endif  
1941         uiBlockBeginAlign(block);
1942         uiDefButS(block, ROW,B_REDR,"Full Render",              210,170,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_ALL, 0, 0, "");
1943         uiDefButS(block, ROW,B_REDR,"Ambient Occlusion",210,150,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_AO, 0, 0, "");
1944         uiDefButS(block, ROW,B_REDR,"Normals",          210,130,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_NORMALS, 0, 0, "");
1945         uiDefButS(block, ROW,B_REDR,"Textures",         210,110,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_TEXTURE, 0, 0, "");
1946         uiDefButS(block, ROW,B_REDR,"Displacement",             210,90,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_DISPLACEMENT, 0, 0, "");
1947         uiBlockEndAlign(block);
1948         
1949         uiDefButBitS(block, TOG, R_BAKE_CLEAR, B_DIFF, "Clear",         210,60,120,20,&G.scene->r.bake_flag, 0.0, 0, 0, 0, "Clear Images before baking");
1950         
1951         uiDefButS(block, NUM, B_DIFF,"Margin:",                         210,30,120,20,&G.scene->r.bake_filter, 0.0, 32.0, 0, 0, "Amount of pixels to extend the baked result with, as post process filter");
1952 }
1953
1954 static void render_panel_render(void)
1955 {
1956         uiBlock *block;
1957         char str[256];
1958
1959         block= uiNewBlock(&curarea->uiblocks, "render_panel_render", UI_EMBOSS, UI_HELV, curarea->win);
1960         if(uiNewPanel(curarea, block, "Render", "Render", 320, 0, 318, 204)==0) return;
1961
1962         uiBlockBeginAlign(block);
1963         uiDefBut(block, BUT,B_DORENDER,"RENDER",        369, 164, 191,37, 0, 0, 0, 0, 0, "Render the current frame (F12)");
1964 #ifndef DISABLE_YAFRAY
1965         /* yafray: on request, render engine menu is back again, and moved to Render panel */
1966         uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0|YafRay %x1", 
1967                                                                                                 369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");        
1968 #else
1969         uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0", 
1970                                                                                                 369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");        
1971 #endif /* disable yafray */
1972
1973         uiBlockBeginAlign(block);
1974         uiDefButBitI(block, TOG, R_OSA, B_DIFF, "OSA",  369,109,122,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)");
1975         uiDefButS(block, ROW,B_DIFF,"5",                        369,88,29,20,&G.scene->r.osa,2.0,5.0, 0, 0, "Render 5 samples per pixel for smooth edges (Fast)");
1976         uiDefButS(block, ROW,B_DIFF,"8",                        400,88,29,20,&G.scene->r.osa,2.0,8.0, 0, 0, "Render 8 samples per pixel for smooth edges (Recommended)");
1977         uiDefButS(block, ROW,B_DIFF,"11",                       431,88,29,20,&G.scene->r.osa,2.0,11.0, 0, 0, "Render 11 samples per pixel for smooth edges (High Quality)");
1978         uiDefButS(block, ROW,B_DIFF,"16",                       462,88,29,20,&G.scene->r.osa,2.0,16.0, 0, 0, "Render 16 samples per pixel for smooth edges (Highest Quality)");
1979         uiBlockEndAlign(block);
1980
1981         uiBlockBeginAlign(block);
1982         uiDefButBitI(block, TOG, R_MBLUR, B_REDR, "MBLUR",      496,109,64,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Motion Blur calculation");
1983         uiDefButF(block, NUM,B_DIFF,"Bf:",                      496,88,64,20,&G.scene->r.blurfac, 0.01, 5.0, 10, 2, "Sets motion blur factor");
1984         uiBlockEndAlign(block);
1985
1986         uiBlockBeginAlign(block);
1987         uiDefButS(block, NUM,B_DIFF,"Xparts:",          369,46,95,29,&G.scene->r.xparts,1.0, 512.0, 0, 0, "Sets the number of horizontal parts to render image in (For panorama sets number of camera slices)");
1988         uiDefButS(block, NUM,B_DIFF,"Yparts:",          465,46,95,29,&G.scene->r.yparts,1.0, 64.0, 0, 0, "Sets the number of vertical parts to render image in");
1989         uiBlockEndAlign(block);
1990
1991         uiBlockBeginAlign(block);
1992         uiDefButS(block, ROW,800,"Sky",         369,13,35,20,&G.scene->r.alphamode,3.0,0.0, 0, 0, "Fill background with sky");
1993         uiDefButS(block, ROW,800,"Premul",      405,13,50,20,&G.scene->r.alphamode,3.0,1.0, 0, 0, "Multiply alpha in advance");
1994         uiDefButS(block, ROW,800,"Key",         456,13,35,20,&G.scene->r.alphamode,3.0,2.0, 0, 0, "Alpha and color values remain unchanged");
1995         uiBlockEndAlign(block);
1996
1997         if(G.scene->r.mode & R_RAYTRACE)
1998                 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");
1999
2000         uiBlockBeginAlign(block);
2001         uiDefButBitI(block, TOG, R_SHADOW, B_REDR,"Shadow",     565,172,60,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable shadow calculation");
2002         uiDefButBitI(block, TOG, R_ENVMAP, B_REDR,"EnvMap",     627,172,60,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable environment map rendering");
2003         uiDefButBitI(block, TOG, R_PANORAMA, B_REDR,"Pano",     565,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable panorama rendering (output width is multiplied by Xparts)");
2004         uiDefButBitI(block, TOG, R_RAYTRACE, B_REDR,"Ray",606,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable ray tracing");
2005         uiDefButBitI(block, TOG, R_RADIO, B_REDR,"Radio",       647,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable radiosity rendering");
2006         uiBlockEndAlign(block);
2007         
2008         uiBlockBeginAlign(block);
2009         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");
2010         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");
2011         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");
2012         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");
2013         uiBlockEndAlign(block);
2014
2015         uiBlockBeginAlign(block);
2016         uiDefButBitI(block, TOG, R_FIELDS, B_REDR,"Fields",  565,55,60,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables field rendering");
2017         uiDefButBitI(block, TOG, R_ODDFIELD, B_REDR,"Odd",      627,55,39,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Odd field first rendering (Default: Even field)");
2018         uiDefButBitI(block, TOG, R_FIELDSTILL, B_REDR,"X",              668,55,19,20,&G.scene->r.mode, 0, 0, 0, 0, "Disables time difference in field calculations");
2019         
2020         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);
2021         uiDefButS(block, MENU, B_DIFF,str,              565,34,60,20, &G.scene->r.filtertype, 0, 0, 0, 0, "Set sampling filter for antialiasing");
2022         uiDefButF(block, NUM,B_DIFF,"",                 627,34,60,20,&G.scene->r.gauss,0.5, 1.5, 10, 2, "Sets the filter size");
2023         
2024         uiDefButBitI(block, TOG, R_BORDER, REDRAWVIEWCAM, "Border",     565,13,122,20, &G.scene->r.mode, 0, 0, 0, 0, "Render a small cut-out of the image (Shift+B to set in the camera view)");
2025         uiBlockEndAlign(block);
2026
2027 }
2028
2029 static void render_panel_anim(void)
2030 {
2031         uiBlock *block;
2032
2033
2034         block= uiNewBlock(&curarea->uiblocks, "render_panel_anim", UI_EMBOSS, UI_HELV, curarea->win);
2035         if(uiNewPanel(curarea, block, "Anim", "Render", 640, 0, 318, 204)==0) return;
2036
2037
2038         uiDefBut(block, BUT,B_DOANIM,"ANIM",            692,142,192,47, 0, 0, 0, 0, 0, "Render the animation to disk (start to end frame)");
2039
2040         uiBlockSetCol(block, TH_BUT_SETTING1);
2041         uiBlockBeginAlign(block);
2042         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)");
2043         uiDefButBitS(block, TOG, R_DOCOMP, B_NOP, "Do Composite",692,90,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Uses compositing nodes for output rendering");
2044         uiBlockEndAlign(block);
2045
2046         uiBlockSetCol(block, TH_AUTO);
2047         uiDefBut(block, BUT,B_PLAYANIM, "PLAY",692,40,94,33, 0, 0, 0, 0, 0, "Play rendered images/avi animation (Ctrl+F11), (Play Hotkeys: A-Noskip, P-PingPong)");
2048         uiDefButS(block, NUM, B_RTCHANGED, "rt:",789,40,95,33, &G.rt, -1000.0, 1000.0, 0, 0, "General testing/debug button");
2049
2050         uiBlockBeginAlign(block);
2051         uiDefButI(block, NUM,REDRAWSEQ,"Sta:",692,10,94,24, &G.scene->r.sfra,1.0,MAXFRAMEF, 0, 0, "The start frame of the animation (inclusive)");
2052         uiDefButI(block, NUM,REDRAWSEQ,"End:",789,10,95,24, &G.scene->r.efra,SFRA,MAXFRAMEF, 0, 0, "The end  frame of the animation  (inclusive)");
2053         uiBlockEndAlign(block);
2054 }
2055
2056 #ifdef WITH_FFMPEG
2057 static void set_ffmpeg_preset(int preset)
2058 {
2059         int isntsc = (G.scene->r.frs_sec != 25);
2060         switch (preset) {
2061         case FFMPEG_PRESET_VCD:
2062                 G.scene->r.ffcodecdata.type = FFMPEG_MPEG1;
2063                 G.scene->r.ffcodecdata.video_bitrate = 1150;
2064                 G.scene->r.xsch = 352;
2065                 G.scene->r.ysch = isntsc ? 240 : 288;
2066                 G.scene->r.ffcodecdata.gop_size = isntsc ? 18 : 15;
2067                 G.scene->r.ffcodecdata.rc_max_rate = 1150;
2068                 G.scene->r.ffcodecdata.rc_min_rate = 1150;
2069                 G.scene->r.ffcodecdata.rc_buffer_size = 40*8;
2070                 G.scene->r.ffcodecdata.mux_packet_size = 2324;
2071                 G.scene->r.ffcodecdata.mux_rate = 2352 * 75 * 8;
2072                 break;
2073         case FFMPEG_PRESET_SVCD:
2074                 G.scene->r.ffcodecdata.type = FFMPEG_MPEG2;
2075                 G.scene->r.ffcodecdata.video_bitrate = 2040;
2076                 G.scene->r.xsch = 480;
2077                 G.scene->r.ysch = isntsc ? 480 : 576;
2078                 G.scene->r.ffcodecdata.gop_size = isntsc ? 18 : 15;
2079                 G.scene->r.ffcodecdata.rc_max_rate = 2516;
2080                 G.scene->r.ffcodecdata.rc_min_rate = 0;
2081                 G.scene->r.ffcodecdata.rc_buffer_size = 224*8;
2082                 G.scene->r.ffcodecdata.mux_packet_size = 2324;
2083                 G.scene->r.ffcodecdata.mux_rate = 0;
2084                 
2085                 break;
2086         case FFMPEG_PRESET_DVD:
2087                 G.scene->r.ffcodecdata.type = FFMPEG_MPEG2;
2088                 G.scene->r.ffcodecdata.video_bitrate = 6000;
2089                 G.scene->r.xsch = 720;
2090                 G.scene->r.ysch = isntsc ? 480 : 576;
2091                 G.scene->r.ffcodecdata.gop_size = isntsc ? 18 : 15;
2092                 G.scene->r.ffcodecdata.rc_max_rate = 9000;
2093                 G.scene->r.ffcodecdata.rc_min_rate = 0;
2094                 G.scene->r.ffcodecdata.rc_buffer_size = 224*8;
2095                 G.scene->r.ffcodecdata.mux_packet_size = 2048;
2096                 G.scene->r.ffcodecdata.mux_rate = 10080000;
2097                 
2098                 break;
2099         case FFMPEG_PRESET_DV:
2100                 G.scene->r.ffcodecdata.type = FFMPEG_DV;
2101                 G.scene->r.xsch = 720;
2102                 G.scene->r.ysch = isntsc ? 480 : 576;
2103                 break;
2104         }
2105 }
2106
2107 static void render_panel_ffmpeg_video(void)
2108 {
2109         uiBlock *block;
2110         int yofs;
2111         int xcol1;
2112         int xcol2;
2113         
2114         block = uiNewBlock(&curarea->uiblocks, "render_panel_ffmpeg_video", 
2115                                            UI_EMBOSS, UI_HELV, curarea->win);
2116         
2117         uiNewPanelTabbed("Format", "Render");
2118         if (uiNewPanel(curarea, block, "Video", "Render", 960, 0, 318, 204)== 0) 
2119                 return;
2120         
2121         if (ffmpeg_preset_sel != 0) {
2122                 set_ffmpeg_preset(ffmpeg_preset_sel);
2123                 ffmpeg_preset_sel = 0;
2124                 allqueue(REDRAWBUTSSCENE, 0);
2125         }
2126         
2127         xcol1 = 872;
2128         xcol2 = 1002;
2129         
2130         yofs = 54;
2131         uiDefBut(block, LABEL, B_DIFF, "Format", xcol1, yofs+88, 
2132                          110, 20, 0, 0, 0, 0, 0, "");
2133         uiDefBut(block, LABEL, B_DIFF, "Preset", xcol2, yofs+88, 
2134                          110, 20, 0, 0, 0, 0, 0, "");
2135         uiDefButI(block, MENU, B_DIFF, ffmpeg_format_pup(), 
2136                           xcol1, yofs+66, 110, 20, &G.scene->r.ffcodecdata.type, 
2137                           0,0,0,0, "output file format");
2138         uiDefButI(block, NUM, B_DIFF, "Bitrate", 
2139                           xcol1, yofs+44, 110, 20, 
2140                           &G.scene->r.ffcodecdata.video_bitrate, 
2141                           1, 14000, 0, 0, "Video bitrate(kb/s)");
2142         uiDefButI(block, NUM, B_DIFF, "Min Rate", 
2143                           xcol1, yofs+22, 110, 20, &G.scene->r.ffcodecdata.rc_min_rate, 
2144                           0, 14000, 0, 0, "Rate control: min rate(kb/s)");
2145         uiDefButI(block, NUM, B_DIFF, "Max Rate", 
2146                           xcol1, yofs, 110, 20, &G.scene->r.ffcodecdata.rc_max_rate, 
2147                           1, 14000, 0, 0, "Rate control: max rate(kb/s)");
2148         
2149         uiDefButI(block, NUM, B_DIFF, "Mux Rate", 
2150                           xcol1, yofs-22, 110, 20, 
2151                           &G.scene->r.ffcodecdata.mux_rate, 
2152                           0, 100000000, 0, 0, "Mux rate (bits/s(!))");
2153         
2154         
2155         uiDefButI(block, MENU, B_REDR, ffmpeg_preset_pup(), 
2156                           xcol2, yofs+66, 110, 20, &ffmpeg_preset_sel, 
2157                           0,0,0,0, "Output file format preset selection");
2158         uiDefButI(block, NUM, B_DIFF, "GOP Size", 
2159                           xcol2, yofs+44, 110, 20, &G.scene->r.ffcodecdata.gop_size, 
2160                           0, 100, 0, 0, "Distance between key frames");
2161         uiDefButI(block, NUM, B_DIFF, "Buffersize", 
2162                           xcol2, yofs+22, 110, 20,
2163                           &G.scene->r.ffcodecdata.rc_buffer_size, 
2164                           0, 2000, 0, 0, "Rate control: buffer size (kb)");
2165         uiDefButI(block, NUM, B_DIFF, "Mux PSize", 
2166                           xcol2, yofs, 110, 20, 
2167                           &G.scene->r.ffcodecdata.mux_packet_size, 
2168                           0, 16384, 0, 0, "Mux packet size (byte)");
2169         
2170         uiDefButBitI(block, TOG, FFMPEG_AUTOSPLIT_OUTPUT, B_NOP,
2171                                  "Autosplit Output", 
2172                                  xcol2, yofs-22, 110, 20, 
2173                                  &G.scene->r.ffcodecdata.flags, 
2174                                  0, 1, 0,0, "Autosplit output at 2GB boundary.");
2175         
2176         
2177         if (ELEM(G.scene->r.ffcodecdata.type, FFMPEG_AVI, FFMPEG_MOV)) {
2178                 uiDefBut(block, LABEL, 0, "Codec", 
2179                                 xcol1, yofs-44, 110, 20, 0, 0, 0, 0, 0, "");
2180                 uiDefButI(block, MENU,B_REDR, ffmpeg_codec_pup(), 
2181                                   xcol1, yofs-66, 110, 20, 
2182                                   &G.scene->r.ffcodecdata.codec, 
2183                                   0,0,0,0, "FFMpeg codec to use");
2184         }
2185 }
2186
2187 static void render_panel_ffmpeg_audio(void)
2188 {
2189         uiBlock *block;
2190         int yofs;
2191         int xcol;
2192         
2193         block = uiNewBlock(&curarea->uiblocks, "render_panel_ffmpeg_audio", UI_EMBOSS, UI_HELV, curarea->win);
2194         uiNewPanelTabbed("Format", "Render");
2195         if (uiNewPanel(curarea, block, "Audio", "Render", 960, 0, 318, 204) == 0) return;
2196         
2197         yofs = 54;
2198         xcol = 892;
2199         
2200         uiDefButBitI(block, TOG, FFMPEG_MULTIPLEX_AUDIO, B_NOP,
2201                                  "Multiplex audio", xcol, yofs, 225, 20, 
2202                                  &G.scene->r.ffcodecdata.flags, 
2203                                  0, 1, 0,0, "Interleave audio with the output video");
2204         uiDefBut(block, LABEL, 0, "Codec", 
2205                          xcol, yofs-22, 225, 20, 0, 0, 0, 0, 0, "");
2206         uiDefButI(block, MENU,B_NOP, ffmpeg_audio_codec_pup(), 
2207                           xcol, yofs-44, 225, 20, 
2208                           &G.scene->r.ffcodecdata.audio_codec, 
2209                           0,0,0,0, "FFMpeg codec to use");
2210         uiDefButI(block, NUM, B_DIFF, "Bitrate", 
2211                           xcol, yofs-66, 110, 20, 
2212                           &G.scene->r.ffcodecdata.audio_bitrate, 
2213                           32, 384, 0, 0, "Audio bitrate(kb/s)");
2214 }
2215 #endif
2216
2217 static void render_panel_stamp(void)
2218 {
2219         uiBlock *block;
2220         int yofs=0, xofs=550;
2221
2222         block= uiNewBlock (&curarea->uiblocks, "render_panel_stamp", UI_EMBOSS, UI_HELV, curarea->win);
2223         uiNewPanelTabbed ("Format", "Render");
2224         if(uiNewPanel (curarea, block, "Stamp", "Render", 960, 0, 318, 204)==0) return;
2225
2226         if (G.scene->r.scemode & R_STAMP_INFO) {
2227                 uiBlockBeginAlign(block);
2228                 uiDefButBitI(block, TOG, R_STAMP_NOTE, B_REDR, "Note", xofs, yofs, 120, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp user data");
2229                 uiDefBut(block, TEX, B_NOP, "", xofs+120, yofs, 180, 19, &G.scene->r.stamp_udata, 0.0, 128.0, 100, 0, "User Note");
2230                 uiBlockEndAlign(block);
2231                 yofs += 30; /* gap */
2232                 
2233                 
2234                 yofs += 80;
2235                 /* Order is important for alligning ... grr */
2236                 uiBlockBeginAlign(block);
2237                 uiDefButBitI(block, TOG, R_STAMP_FILENAME, B_REDR, "Filename", xofs, yofs, 120, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp blend filename");
2238                 yofs -= 20;
2239                 uiDefButBitI(block, TOG, R_STAMP_SCENE, B_REDR, "Scene", xofs, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp scene name");
2240                 uiDefButBitI(block, TOG, R_STAMP_CAMERA, B_REDR, "Camera", xofs+60, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp camera name");
2241                 yofs -= 20;
2242                 uiDefButBitI(block, TOG, R_STAMP_TIME, B_REDR, "Time", xofs, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp time (HH:MM:SS)");
2243                 uiDefButBitI(block, TOG, R_STAMP_DATE, B_REDR, "Date", xofs+60, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp date");
2244                 yofs -= 20;
2245                 uiDefButBitI(block, TOG, R_STAMP_FRAME, B_REDR, "Frame", xofs, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp frame number");
2246                 uiDefButBitI(block, TOG, R_STAMP_MARKER, B_REDR, "Marker", xofs+60, yofs, 60, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp the last marker");
2247                 yofs -= 20;
2248                 uiDefButBitI(block, TOG, R_STAMP_SEQSTRIP, B_REDR, "Sequence Strip", xofs, yofs, 120, 19, &G.scene->r.stamp, 0, 0, 0, 0, "Stamp the forground sequence strip name");
2249                 uiBlockEndAlign(block);
2250                 yofs += 80;
2251                 
2252                 /* draw font selector */
2253                 if (G.scene->r.stamp & R_STAMP_DRAW) {
2254                         uiDefButS(block, MENU, B_REDR, "Stamp Font Size%t|Tiny Text%x1|Small Text%x2|Medium Text%x3|Large Text%x0|Extra Large Text%x4|",
2255                                         xofs+130, yofs, 170, 19, &G.scene->r.stamp_font_id, 0, 0, 0, 0, "Choose stamp text size");
2256                         
2257                         /* draw fg/bg next to the scene */
2258                         yofs -= 25;
2259                         uiDefBut(block, LABEL, B_NOP, "Text Color", xofs+130, yofs, 70, 19, 0, 0, 0, 0, 0, "");
2260                         uiDefBut(block, LABEL, B_NOP, "Background", xofs+215, yofs, 70, 19, 0, 0, 0, 0, 0, "");
2261                         yofs -= 20;
2262                         uiDefButF(block, COL, B_NOP, "", xofs+130, yofs, 80, 19, G.scene->r.fg_stamp, 0, 0, 0, 0, "Foreground text color");
2263                         uiDefButF(block, COL, B_NOP, "", xofs+220, yofs, 80, 19, G.scene->r.bg_stamp, 0, 0, 0, 0, "Background color");
2264                         yofs -= 30;
2265                         uiDefButF(block, NUMSLI, B_NOP, "A ", xofs+130, yofs, 170, 19, &G.scene->r.bg_stamp[3], 0, 1.0, 0, 0, "Alpha for text background");
2266                         yofs += 105;
2267                 } else {
2268                         yofs += 30;
2269                 }
2270                 
2271                 uiDefButBitS(block, TOG, R_STAMP_INFO, B_REDR, "Enable Stamp", xofs, yofs, 120, 20, &G.scene->r.scemode, 0, 0, 0, 0, "Disable stamp info in images metadata");
2272                 uiDefButBitI(block, TOG, R_STAMP_DRAW, B_REDR, "Draw Stamp", xofs+130, yofs, 170, 20, &G.scene->r.stamp, 0, 0, 0, 0, "Draw the stamp info into each frame");
2273                 yofs += 20;
2274         }
2275         else {
2276                 uiDefButBitS(block, TOG, R_STAMP_INFO, B_REDR, "Enable Stamp", xofs, 142, 120, 20, &G.scene->r.scemode, 0, 0, 0, 0, "Enable stamp info to image metadata");
2277                 yofs += 20;
2278                 uiDefBut(block, LABEL, 0, "", xofs, yofs, 300, 19, 0, 0, 0, 0, 0, "");
2279         }
2280 }
2281
2282 static void render_panel_format(void)
2283 {
2284         uiBlock *block;
2285         int yofs;
2286
2287
2288         block= uiNewBlock(&curarea->uiblocks, "render_panel_format", UI_EMBOSS, UI_HELV, curarea->win);
2289         if(uiNewPanel(curarea, block, "Format", "Render", 960, 0, 318, 204)==0) return;
2290         uiDefBlockBut(block, framing_render_menu, NULL, 
2291                                   "Game framing settings", 
2292                                   892, 169, 227, 20, "Display game framing settings");
2293         /* uiDefIconTextBlockBut(block, framing_render_menu, NULL, 
2294                                                    ICON_BLOCKBUT_CORNER, 
2295                                                    "Game framing settings", 
2296                                                    892, 169, 227, 20, 
2297                                                    "Display game framing settings"); */
2298
2299         uiBlockBeginAlign(block);
2300         uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeX:",    892 ,136,112,27, &G.scene->r.xsch, 4.0, 10000.0, 0, 0, "The image width in pixels");
2301         uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeY:",    1007,136,112,27, &G.scene->r.ysch, 4.0,10000.0, 0, 0, "The image height in scanlines");
2302         uiDefButS(block, NUM,REDRAWVIEWCAM,"AspX:",     892 ,114,112,20, &G.scene->r.xasp, 1.0,200.0, 0, 0, "The horizontal aspect ratio");
2303         uiDefButS(block, NUM,REDRAWVIEWCAM,"AspY:",     1007,114,112,20, &G.scene->r.yasp, 1.0,200.0, 0, 0, "The vertical aspect ratio");
2304         uiBlockEndAlign(block);
2305
2306         yofs = 54;
2307
2308 #ifdef __sgi
2309         yofs = 76;
2310         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");
2311         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");
2312 #endif
2313
2314         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");
2315         uiDefButBitI(block, TOG, R_CROP, B_DIFF, "Crop",        1068,yofs,51,20, &G.scene->r.mode, 0, 0, 0, 0, "When Border render, the resulting image gets cropped");
2316
2317         yofs -= 22;
2318
2319         if(G.scene->r.quality==0) G.scene->r.quality= 90;
2320
2321 #ifdef WITH_QUICKTIME
2322         if (G.scene->r.imtype == R_AVICODEC || G.scene->r.imtype == R_QUICKTIME) {
2323 #else /* WITH_QUICKTIME */
2324         if (0) {
2325 #endif
2326                 if(G.scene->r.imtype == R_QUICKTIME) {
2327 #ifdef WITH_QUICKTIME
2328 #if defined (_WIN32) || defined (__APPLE__)
2329                         //glColor3f(0.65, 0.65, 0.7);
2330                         //glRecti(892,yofs+46,892+225,yofs+45+20);
2331                         if(G.scene->r.qtcodecdata == NULL)
2332                                 uiDefBut(block, LABEL, 0, "Codec: not set",  892,yofs+44,225,20, 0, 0, 0, 0, 0, "");
2333                         else
2334                                 uiDefBut(block, LABEL, 0, G.scene->r.qtcodecdata->qtcodecname,  892,yofs+44,225,20, 0, 0, 0, 0, 0, "");
2335                         uiDefBut(block, BUT,B_SELECTCODEC, "Set codec",  892,yofs,74,20, 0, 0, 0, 0, 0, "Set codec settings for Quicktime");
2336 #endif
2337 #endif /* WITH_QUICKTIME */
2338                 } else {
2339 #ifdef _WIN32
2340                         //glColor3f(0.65, 0.65, 0.7);
2341                         //glRecti(892,yofs+46,892+225,yofs+45+20);
2342                         if(G.scene->r.avicodecdata == NULL)
2343                                 uiDefBut(block, LABEL, 0, "Codec: not set.",  892,yofs+43,225,20, 0, 0, 0, 0, 0, "");
2344                         else
2345                                 uiDefBut(block, LABEL, 0, avicodec_str(),  892,yofs+43,225,20, 0, 0, 0, 0, 0, "");
2346 #endif
2347                         uiDefBut(block, BUT,B_SELECTCODEC, "Set codec",  892,yofs,74,20, 0, 0, 0, 0, 0, "Set codec settings for AVI");
2348                 }
2349 #ifdef WITH_OPENEXR
2350         } 
2351         else if (ELEM(G.scene->r.imtype, R_OPENEXR, R_MULTILAYER)) {
2352                 if (G.scene->r.quality > 5) G.scene->r.quality = 2;
2353                 
2354                 if(G.scene->r.imtype==R_OPENEXR) {
2355                         uiBlockBeginAlign(block);
2356                         uiDefButBitS(block, TOG, R_OPENEXR_HALF, B_NOP,"Half",  892,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Use 16 bit floats instead of 32 bit floats per channel");
2357                         uiDefButBitS(block, TOG, R_OPENEXR_ZBUF, B_NOP,"Zbuf",  952,yofs+44,60,20, &G.scene->r.subimtype, 0, 0, 0, 0, "Save the z-depth per pixel (32 bit unsigned int zbuffer)");
2358                         uiBlockEndAlign(block);
2359                         uiDefButBitS(block, TOG, R_PREVIEW_JPG, B_NOP,"Preview",1027,yofs+44,90,20, &G.scene->r.subimtype, 0, 0, 0, 0, "When animation render, save JPG preview images in same directory");
2360                 }               
2361                 uiDefButS(block, MENU,B_NOP, "Codec %t|None %x0|Pxr24 (lossy) %x1|ZIP (lossless) %x2|PIZ (lossless) %x3|RLE (lossless) %x4",  
2362                                                                                                                         892,yofs,74,20, &G.scene->r.quality, 0, 0, 0, 0, "Set codec settings for OpenEXR");
2363                 
2364 #endif
2365         } else {
2366                 if(G.scene->r.quality < 5) G.scene->r.quality = 90;     /* restore from openexr */
2367                 
2368                 uiDefButS(block, NUM,B_DIFF, "Q:",           892,yofs,74,20, &G.scene->r.quality, 10.0, 100.0, 0, 0, "Quality setting for JPEG images, AVI Jpeg and SGI movies");
2369         }
2370         uiDefButS(block, NUM,B_FRAMEMAP,"FPS:",   968,yofs,75,20, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");
2371         uiDefButF(block, NUM,B_FRAMEMAP,"/",  1043,yofs,75,20, &G.scene->r.frs_sec_base, 1.0, 120.0, 0.1, 3, "Frames per second base");
2372
2373
2374         uiBlockBeginAlign(block);
2375         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");
2376         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");
2377         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)");
2378
2379         uiBlockBeginAlign(block);
2380         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");
2381         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");
2382         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)");
2383         uiDefBut(block, BUT,B_PR_PRV, "Preview",        1146,110,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x512, Render size 50%");
2384         uiDefBut(block, BUT,B_PR_PC, "PC",                      1146,90,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x480, Aspect ratio - 100x100");
2385         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");
2386         uiDefBut(block, BUT,B_PR_PANO, "PANO",          1146,50,100,18, 0, 0, 0, 0, 0, "Standard panorama settings");
2387         uiDefBut(block, BUT,B_PR_FULL, "FULL",          1146,30,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 1280x1024, Aspect ratio - 1x1");
2388         uiDefBut(block, BUT,B_PR_HD, "HD",              1146,10,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 1920x1080, Aspect ratio - 1x1");
2389         uiBlockEndAlign(block);
2390 }
2391
2392 #ifndef DISABLE_YAFRAY /* disable yafray stuff */
2393 /* yafray: global illumination options panel */
2394 static void render_panel_yafrayGI()
2395 {
2396         uiBlock *block;
2397
2398         block= uiNewBlock(&curarea->uiblocks, "render_panel_yafrayGI", UI_EMBOSS, UI_HELV, curarea->win);
2399         uiNewPanelTabbed("Render", "Render");
2400         if(uiNewPanel(curarea, block, "YafRay GI", "Render", 320, 0, 318, 204)==0) return;
2401
2402         // label to force a boundbox for buttons not to be centered
2403         uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
2404
2405         uiDefBut(block, LABEL, 0, "Method", 5,175,70,20, 0, 1.0, 0, 0, 0, "");
2406         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");
2407
2408         uiDefBut(block, LABEL, 0, "Quality", 5,150,70,20, 0, 1.0, 0, 0, 0, "");
2409         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");
2410
2411         if (G.scene->r.GImethod>0) {
2412                 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");
2413                 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");
2414         }
2415
2416         if (G.scene->r.GImethod>0)
2417         {
2418                 if (G.scene->r.GIdepth==0) G.scene->r.GIdepth=2;
2419
2420                 if (G.scene->r.GImethod==2) {
2421                         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");
2422                         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)");
2423                         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");
2424                 }
2425
2426                 uiDefButBitS(block, TOG, 1, B_REDR, "Cache",6,125,95,20, &G.scene->r.GIcache, 0, 0, 0, 0, "Cache occlusion/irradiance samples (faster)");
2427                 if (G.scene->r.GIcache) 
2428                 {
2429                         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)");
2430                         uiDefBut(block, LABEL, 0, "Cache parameters:", 5,105,130,20, 0, 1.0, 0, 0, 0, "");
2431                         if (G.scene->r.GIshadowquality==0.0) G.scene->r.GIshadowquality=0.9;
2432                         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 :-) ");
2433                         if (G.scene->r.GIpixelspersample==0) G.scene->r.GIpixelspersample=10;
2434                         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");
2435                         if (G.scene->r.GIrefinement==0) G.scene->r.GIrefinement=1.0;
2436                         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");
2437                 }
2438
2439                 if (G.scene->r.GImethod==2) {
2440                         if (G.scene->r.GIphotons)
2441                         {
2442                                 uiDefBut(block, LABEL, 0, "Photon parameters:", 170,105,130,20, 0, 1.0, 0, 0, 0, "");
2443                                 if(G.scene->r.GIphotoncount==0) G.scene->r.GIphotoncount=100000;
2444                                 uiDefButI(block, NUM, B_DIFF, "Count:", 170,85,140,20, &G.scene->r.GIphotoncount, 
2445                                                 0, 10000000, 10, 10, "Number of photons to shoot");
2446                                 if(G.scene->r.GIphotonradius==0.0) G.scene->r.GIphotonradius=1.0;
2447                                 uiDefButF(block, NUMSLI, B_DIFF,"Radius:", 170,60,140,20,       &(G.scene->r.GIphotonradius), 
2448                                                 0.00001, 100.0 ,0,0, "Radius to search for photons to mix (blur)");
2449                                 if(G.scene->r.GImixphotons==0) G.scene->r.GImixphotons=100;
2450                                 uiDefButI(block, NUM, B_DIFF, "MixCount:", 170,35,140,20, &G.scene->r.GImixphotons, 
2451                                                 0, 1000, 10, 10, "Number of photons to mix");
2452                                 uiDefButBitS(block, TOG, 1, B_REDR, "Tune Photons",170,10,140,20, &G.scene->r.GIdirect, 
2453                                                 0, 0, 0, 0, "Show the photonmap directly in the render for tuning");
2454                         }
2455                 }
2456
2457         }
2458 }
2459
2460 /* yafray: global  options panel */
2461 static void render_panel_yafrayGlobal()
2462 {
2463         uiBlock *block;
2464
2465         block= uiNewBlock(&curarea->uiblocks, "render_panel_yafrayGlobal", UI_EMBOSS, UI_HELV, curarea->win);
2466         uiNewPanelTabbed("Render", "Render");
2467         if(uiNewPanel(curarea, block, "YafRay", "Render", 320, 0, 318, 204)==0) return;
2468
2469         // label to force a boundbox for buttons not to be centered
2470         uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
2471
2472         uiDefButBitS(block, TOGN, 1, B_REDR, "xml", 5,180,75,20, &G.scene->r.YFexportxml,
2473                                         0, 0, 0, 0, "Export to an xml file and call yafray instead of plugin");
2474
2475         uiDefButF(block, NUMSLI, B_DIFF,"Bi ", 5,35,150,20,     &(G.scene->r.YF_raybias), 
2476                                 0.0, 10.0 ,0,0, "Shadow ray bias to avoid self shadowing");
2477         uiDefButI(block, NUM, B_DIFF, "Raydepth ", 5,60,150,20,
2478                                 &G.scene->r.YF_raydepth, 1.0, 80.0, 10, 10, "Maximum render ray depth from the camera");
2479         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");
2480         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");
2481         
2482         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");
2483
2484         /*AA Settings*/
2485         uiDefButBitS(block, TOGN, 1, B_REDR, "Auto AA", 5,140,150,20, &G.scene->r.YF_AA, 
2486                                         0, 0, 0, 0, "Set AA using OSA and GI quality, disable for manual control");
2487         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.");
2488         if(G.scene->r.YF_AA){
2489                 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)");
2490                 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");
2491                 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");
2492                 uiDefButF(block, NUMSLI, B_DIFF, "Thr ", 160,90,150,20, &G.scene->r.YF_AAthreshold, 0.000001, 1.0, 0, 0, "AA threshold");
2493         }
2494 }
2495 #endif /* disable yafray stuff */
2496
2497 static void layer_copy_func(void *lay_v, void *lay_p)
2498 {
2499         unsigned int *lay= lay_p;
2500         int laybit= (int)lay_v;
2501
2502         if(G.qual & LR_SHIFTKEY) {
2503                 if(*lay==0) *lay= 1<<laybit;
2504         }
2505         else
2506                 *lay= 1<<laybit;
2507         
2508         copy_view3d_lock(REDRAW);
2509         allqueue(REDRAWBUTSSCENE, 0);
2510 }
2511
2512 static void delete_scene_layer_func(void *srl_v, void *act_i)
2513 {
2514         if(BLI_countlist(&G.scene->r.layers)>1) {
2515                 long act= (long)act_i;
2516                 
2517                 BLI_remlink(&G.scene->r.layers, srl_v);
2518                 MEM_freeN(srl_v);
2519                 G.scene->r.actlay= 0;
2520                 
2521                 if(G.scene->nodetree) {
2522                         bNode *node;
2523                         for(node= G.scene->nodetree->nodes.first; node; node= node->next) {
2524                                 if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) {
2525                                         if(node->custom1==act)
2526                                                 node->custom1= 0;
2527                                         else if(node->custom1>act)
2528                                                 node->custom1--;
2529                                 }
2530                         }
2531                 }
2532                 allqueue(REDRAWBUTSSCENE, 0);
2533                 allqueue(REDRAWNODE, 0);
2534         }
2535 }
2536
2537 static void rename_scene_layer_func(void *srl_v, void *unused_v)
2538 {
2539         if(G.scene->nodetree) {
2540                 SceneRenderLayer *srl= srl_v;
2541                 bNode *node;
2542                 for(node= G.scene->nodetree->nodes.first; node; node= node->next) {
2543                         if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) {
2544                                 if(node->custom1==G.scene->r.actlay)
2545                                         BLI_strncpy(node->name, srl->name, NODE_MAXSTR);
2546                         }
2547                 }
2548         }
2549         allqueue(REDRAWBUTSSCENE, 0);
2550         allqueue(REDRAWOOPS, 0);
2551         allqueue(REDRAWNODE, 0);
2552 }
2553
2554 static char *scene_layer_menu(void)
2555 {
2556         SceneRenderLayer *srl;
2557         int len= 32 + 32*BLI_countlist(&G.scene->r.layers);
2558         short a, nr;
2559         char *str= MEM_callocN(len, "menu layers");
2560         
2561         strcpy(str, "ADD NEW %x32767");
2562         a= strlen(str);
2563         for(nr=0, srl= G.scene->r.layers.first; srl; srl= srl->next, nr++) {
2564                 if(srl->layflag & SCE_LAY_DISABLE)
2565                         a+= sprintf(str+a, "|%s %%i%d %%x%d", srl->name, ICON_BLANK1, nr);
2566                 else 
2567                         a+= sprintf(str+a, "|%s %%i%d %%x%d", srl->name, ICON_CHECKBOX_HLT, nr);
2568         }
2569         
2570         return str;
2571 }
2572
2573 static void draw_3d_layer_buttons(uiBlock *block, unsigned int *poin, short xco, short yco, short dx, short dy)
2574 {
2575         uiBut *bt;
2576         long a;
2577         
2578         uiBlockBeginAlign(block);
2579         for(a=0; a<5; a++) {
2580                 bt= uiDefButBitI(block, TOG, 1<<a, B_NOP, "",   (short)(xco+a*(dx/2)), yco+dy/2, (short)(dx/2), (short)(dy/2), (int *)poin, 0, 0, 0, 0, "");
2581                 uiButSetFunc(bt, layer_copy_func, (void *)a, poin);
2582         }
2583         for(a=0; a<5; a++) {
2584                 bt=uiDefButBitI(block, TOG, 1<<(a+10), B_NOP, "",       (short)(xco+a*(dx/2)), yco, (short)(dx/2), (short)(dy/2), (int *)poin, 0, 0, 0, 0, "");
2585                 uiButSetFunc(bt, layer_copy_func, (void *)(a+10), poin);
2586         }
2587         
2588         xco+= 7;
2589         uiBlockBeginAlign(block);
2590         for(a=5; a<10; a++) {
2591                 bt=uiDefButBitI(block, TOG, 1<<a, B_NOP, "",    (short)(xco+a*(dx/2)), yco+dy/2, (short)(dx/2), (short)(dy/2), (int *)poin, 0, 0, 0, 0, "");
2592                 uiButSetFunc(bt, layer_copy_func, (void *)a, poin);
2593         }
2594         for(a=5; a<10; a++) {
2595                 bt=uiDefButBitI(block, TOG, 1<<(a+10), B_NOP, "",       (short)(xco+a*(dx/2)), yco, (short)(dx/2), (short)(dy/2), (int *)poin, 0, 0, 0, 0, "");
2596                 uiButSetFunc(bt, layer_copy_func, (void *)(a+10), poin);
2597         }
2598         
2599         uiBlockEndAlign(block);
2600 }
2601
2602 static void render_panel_layers(void)
2603 {
2604         uiBlock *block;
2605         uiBut *bt;
2606         SceneRenderLayer *srl= BLI_findlink(&G.scene->r.layers, G.scene->r.actlay);
2607         char *strp;
2608         
2609         if(srl==NULL) {
2610                 G.scene->r.actlay= 0;
2611                 srl= G.scene->r.layers.first;
2612         }
2613         
2614         block= uiNewBlock(&curarea->uiblocks, "render_panel_layers", UI_EMBOSS, UI_HELV, curarea->win);
2615         uiNewPanelTabbed("Output", "Render");
2616         if(uiNewPanel(curarea, block, "Render Layers", "Render", 320, 0, 318, 204)==0) return;
2617         
2618         /* first, as reminder, the scene layers */
2619         uiDefBut(block, LABEL, 0, "Scene:",                             10,170,100,20, NULL, 0, 0, 0, 0, "");
2620         draw_3d_layer_buttons(block, &G.scene->lay,             130, 170, 35, 30);
2621         
2622         /* layer disable, menu, name, delete button */
2623         uiBlockBeginAlign(block);
2624         uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, B_REDR, ICON_CHECKBOX_HLT-1, 10, 145, 20, 20, &srl->layflag, 0.0, 0.0, 0, 0, "Disable or enable this RenderLayer");
2625         strp= scene_layer_menu();
2626         uiDefButS(block, MENU, B_ADD_RENDERLAYER, strp, 30,145,23,20, &(G.scene->r.actlay), 0, 0, 0, 0, "Choose Active Render Layer");
2627         MEM_freeN(strp);
2628         
2629         /* name max 20, exr format limit... */
2630         bt= uiDefBut(block, TEX, REDRAWNODE, "",  53,145,172,20, srl->name, 0.0, 20.0, 0, 0, "");
2631         uiButSetFunc(bt, rename_scene_layer_func, srl, NULL);
2632         
2633         uiDefButBitS(block, TOG, R_SINGLE_LAYER, B_NOP, "Single",       230,145,60,20, &G.scene->r.scemode, 0, 0, 0, 0, "Only render this layer");      
2634         bt=uiDefIconBut(block, BUT, B_NOP, ICON_X,      285, 145, 25, 20, 0, 0, 0, 0, 0, "Deletes current Render Layer");
2635         uiButSetFunc(bt, delete_scene_layer_func, srl, (void *)(long)G.scene->r.actlay);
2636         uiBlockEndAlign(block);
2637
2638         /* RenderLayer visible-layers */
2639         uiDefBut(block, LABEL, 0, "Layer:",                     10,110,100,20, NULL, 0, 0, 0, 0, "");
2640         draw_3d_layer_buttons(block, &srl->lay,         130,110, 35, 30);
2641         
2642         uiBlockBeginAlign(block);
2643         uiDefButBitI(block, TOG, SCE_LAY_ALL_Z, B_NOP,"AllZ",   10, 85, 40, 20, &srl->layflag, 0, 0, 0, 0, "Fill in Z values for all not-rendered faces, for masking"); 
2644         uiBlockBeginAlign(block);
2645         uiDefButBitI(block, TOG, SCE_LAY_SOLID, B_NOP,"Solid",  50,  85, 45, 20, &srl->layflag, 0, 0, 0, 0, "Render Solid faces in this Layer");        
2646         uiDefButBitI(block, TOG, SCE_LAY_HALO, B_NOP,"Halo",    95,  85, 40, 20, &srl->layflag, 0, 0, 0, 0, "Render Halos in this Layer (on top of Solid)");    
2647         uiDefButBitI(block, TOG, SCE_LAY_ZTRA, B_NOP,"Ztra",    135, 85, 40, 20, &srl->layflag, 0, 0, 0, 0, "Render Z-Transparent faces in this Layer (On top of Solid and Halos)");    
2648         uiDefButBitI(block, TOG, SCE_LAY_SKY, B_NOP,"Sky",              175, 85, 40, 20, &srl->layflag, 0, 0, 0, 0, "Render Sky or backbuffer in this Layer");  
2649         uiDefButBitI(block, TOG, SCE_LAY_EDGE, B_NOP,"Edge",    215, 85, 45, 20, &srl->layflag, 0, 0, 0, 0, "Render Edge-enhance in this Layer (only works for Solid faces)");  
2650         uiDefButBitI(block, TOG, SCE_LAY_STRAND, B_NOP,"Strand",260, 85, 50, 20, &srl->layflag, 0, 0, 0, 0, "Render Strands in this Layer");    
2651         
2652         uiDefIDPoinBut(block, test_grouppoin_but, ID_GR, B_SET_PASS, "Light:",  10, 65, 150, 20, &(srl->light_override), "Name of Group to use as Lamps instead");
2653         uiDefIDPoinBut(block, test_matpoin_but, ID_MA, B_SET_PASS, "Mat:",      160, 65, 150, 20, &(srl->mat_override), "Name of Material to use as Materials instead");
2654         uiBlockEndAlign(block);
2655
2656         uiBlockBeginAlign(block);
2657         uiDefButBitI(block, TOG, SCE_PASS_COMBINED, B_SET_PASS,"Combined",      10, 30, 80, 20, &srl->passflag, 0, 0, 0, 0, "Deliver full combined RGBA buffer");       
2658         uiDefButBitI(block, TOG, SCE_PASS_Z, B_SET_PASS,"Z",                    90, 30, 30, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Z values pass");   
2659         uiDefButBitI(block, TOG, SCE_PASS_VECTOR, B_SET_PASS,"Vec",             120, 30, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Speed Vector pass");      
2660         uiDefButBitI(block, TOG, SCE_PASS_NORMAL, B_SET_PASS,"Nor",             160, 30, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Normal pass");    
2661         uiDefButBitI(block, TOG, SCE_PASS_UV, B_SET_PASS,"UV",                  200, 30, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Texture UV pass");        
2662         uiDefButBitI(block, TOG, SCE_PASS_INDEXOB, B_SET_PASS,"IndexOb",240, 30, 70, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Object Index pass");      
2663         
2664         uiDefButBitI(block, TOG, SCE_PASS_RGBA, B_SET_PASS,"Col",                               10, 10, 35, 20, &srl->passflag, 0, 0, 0, 0, "Deliver shade-less Color pass");   
2665         uiDefButBitI(block, TOG, SCE_PASS_DIFFUSE, B_SET_PASS,"Diff",                   45, 10, 35, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Diffuse pass");    
2666         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_SPEC, B_SET_PASS,"Spec",              80, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Specular pass");   
2667         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_SHADOW, B_SET_PASS,"Shad",    120, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Shadow pass");    
2668         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_AO, B_SET_PASS,"AO",                  160, 10, 30, 20, &srl->passflag, 0, 0, 0, 0, "Deliver AO pass");        
2669         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_REFLECT, B_SET_PASS,"Refl",   190, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Raytraced Reflection pass");      
2670         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_REFRACT, B_SET_PASS,"Refr",   230, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Raytraced Refraction pass");      
2671         uiDefButBitI(block, BUT_TOGDUAL, SCE_PASS_RADIO, B_SET_PASS,"Rad",              270, 10, 40, 20, &srl->passflag, 0, 0, 0, 0, "Deliver Radiosity pass"); 
2672 }       
2673
2674 void render_panels()
2675 {
2676
2677         render_panel_output();
2678         render_panel_layers();
2679         render_panel_render();
2680         render_panel_anim();
2681         render_panel_bake();
2682
2683         render_panel_format();
2684         render_panel_stamp();
2685 #ifdef WITH_FFMPEG
2686        if (G.scene->r.imtype == R_FFMPEG) {
2687                    render_panel_ffmpeg_video();
2688                render_panel_ffmpeg_audio();
2689        }
2690 #endif
2691
2692 #ifndef DISABLE_YAFRAY
2693         /* yafray: GI & Global panel, only available when yafray enabled for rendering */
2694         if (G.scene->r.renderer==R_YAFRAY) {
2695                 if (G.scene->r.YF_gamma==0.0) G.scene->r.YF_gamma=1.0;
2696                 if (G.scene->r.YF_raybias==0.0) G.scene->r.YF_raybias=0.001;
2697                 if (G.scene->r.YF_raydepth==0) G.scene->r.YF_raydepth=5;
2698                 if (G.scene->r.YF_AApixelsize==0.0) G.scene->r.YF_AApixelsize=1.5;
2699                 if (G.scene->r.YF_AAthreshold==0.0) G.scene->r.YF_AAthreshold=0.05;
2700                 if (G.scene->r.GIpower==0.0) G.scene->r.GIpower=1.0;
2701                 if (G.scene->r.GIindirpower==0.0) G.scene->r.GIindirpower=1.0;
2702                 render_panel_yafrayGlobal();
2703                 render_panel_yafrayGI();
2704         }
2705 #endif
2706
2707 }
2708
2709 /* --------------------------------------------- */
2710
2711 void anim_panels()
2712 {
2713         uiBlock *block;
2714
2715         block= uiNewBlock(&curarea->uiblocks, "anim_panel", UI_EMBOSS, UI_HELV, curarea->win);
2716         if(uiNewPanel(curarea, block, "Anim", "Anim", 0, 0, 318, 204)==0) return;
2717
2718         uiBlockBeginAlign(block);
2719         uiDefButI(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");
2720         uiDefButI(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");
2721
2722         uiBlockBeginAlign(block);
2723         uiDefButS(block, NUM,B_FRAMEMAP,"FPS:",  10,130,75,20, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");
2724         uiDefButF(block, NUM,B_FRAMEMAP,"/",  85,130,75,20, &G.scene->r.frs_sec_base, 1.0, 120.0, 0.1, 3, "Frames per second base");
2725
2726         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");
2727         
2728         uiBlockBeginAlign(block);
2729         uiDefButI(block, NUM,REDRAWALL,"Sta:",  10,100,150,20,&G.scene->r.sfra,1.0,MAXFRAMEF, 0, 0, "Specify the start frame of the animation");
2730         uiDefButI(block, NUM,REDRAWALL,"End:",  160,100,150,20,&G.scene->r.efra,1.0,MAXFRAMEF, 0, 0, "Specify the end frame of the animation");
2731
2732         uiBlockBeginAlign(block);
2733         uiDefButS(block, NUM, REDRAWTIME, "Steps:",10, 70, 150, 20,&(G.scene->jumpframe), 1, 100, 1, 100, "Set spacing between frames changes with up and down arrow keys");
2734
2735
2736 }
2737
2738 /* --------------------------------------------- */
2739
2740 void sound_panels()
2741 {
2742         bSound *sound;
2743
2744         /* paranoia check */
2745         sound = G.buts->lockpoin;
2746         if(sound && GS(sound->id.name)!=ID_SO) {
2747                 sound= NULL;
2748                 G.buts->lockpoin= NULL;
2749         }
2750         
2751         sound_panel_sound(sound);
2752         sound_panel_listener();
2753         sound_panel_sequencer();
2754 }
2755
2756
2757