svn merge -r 13177:13240 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / blender / src / header_info.c
1 /**
2  * header_info.c oct-2003
3  *
4  * Functions to draw the "User Preferences" window header
5  * and handle user events sent to it.
6  * 
7  *
8  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version. The Blender
14  * Foundation also sells licenses for use in proprietary software under
15  * the Blender License.  See http://www.blender.org/BL/ for information
16  * about this.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA.
26  *
27  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
28  * All rights reserved.
29  *
30  * The Original Code is: all of this file.
31  *
32  * Contributor(s): none yet.
33  *
34  * ***** END GPL/BL DUAL LICENSE BLOCK *****
35  */
36  
37 #include <math.h>
38 #include <stdlib.h>
39 #include <string.h>
40
41 #ifdef HAVE_CONFIG_H
42 #include <config.h>
43 #endif
44
45 #include "DNA_group_types.h"
46 #include "DNA_ID.h"
47 #include "DNA_image_types.h"
48 #include "DNA_lamp_types.h"
49 #include "DNA_object_types.h"
50 #include "DNA_packedFile_types.h"
51 #include "DNA_scene_types.h"
52 #include "DNA_screen_types.h"
53 #include "DNA_space_types.h"
54 #include "DNA_userdef_types.h"
55 #include "DNA_world_types.h"
56
57 #include "BDR_editcurve.h"
58 #include "BDR_editmball.h"
59 #include "BDR_editobject.h"
60 #include "BDR_editface.h"
61 #include "BDR_vpaint.h"
62
63 #include "BIF_editarmature.h"
64 #include "BIF_editfont.h"
65 #include "BIF_editmesh.h"
66 #include "BIF_gl.h"
67 #include "BIF_interface.h"
68 #include "BIF_language.h"
69 #include "BIF_mainqueue.h"
70 #include "BIF_meshtools.h"
71 #include "BIF_previewrender.h"
72 #include "BIF_renderwin.h"
73 #include "BIF_resources.h"
74 #include "BIF_screen.h"
75 #include "BIF_space.h"
76 #include "BIF_toets.h"
77 #include "BIF_toolbox.h"
78 #include "BIF_usiblender.h"
79 #include "BIF_writeimage.h"
80 #include "BIF_drawscene.h"
81 #ifdef WITH_VERSE
82 #include "BIF_verse.h"
83 #endif
84
85 #include "BKE_blender.h"
86 #include "BKE_depsgraph.h"
87 #include "BKE_exotic.h"
88 #include "BKE_global.h"
89 #include "BKE_image.h"
90 #include "BKE_library.h"
91 #include "BKE_main.h"
92 #include "BKE_node.h"
93 #include "BKE_packedFile.h"
94 #include "BKE_scene.h"
95 #include "BKE_world.h"
96
97 #ifdef WITH_VERSE
98 #include "BKE_verse.h"
99 #endif
100
101 #include "BLI_arithb.h"
102 #include "BLI_blenlib.h"
103 #include "BLI_bpath.h"
104 #include "BLO_writefile.h"
105
106 #include "BSE_editipo.h"
107 #include "BSE_filesel.h"
108 #include "BIF_imasel.h"
109 #include "BSE_headerbuttons.h"
110 #include "BSE_node.h"
111 #include "BSE_sequence.h"
112 #include "BSE_edit.h"
113
114 #include "IMB_imbuf_types.h"
115
116 #include "MEM_guardedalloc.h"
117
118 #include "BPY_extern.h"
119 #include "BPY_menus.h"
120
121 #include "blendef.h"
122 #include "interface.h"
123 #include "mydevice.h"
124
125 extern char versionstr[]; /* from blender.c */
126
127 /*----------------------------------*/
128 /* Progress bar vars and functions: */
129
130 /* strubi shamelessly abused the status line as a progress bar...
131  * feel free to kill him after release */
132
133 static int g_progress_bar = 0;
134 static char *g_progress_info = 0;
135 static float g_done;
136
137 int start_progress_bar(void)
138 {
139         g_progress_bar = 1;
140         return 1;               // we never fail (yet)
141 }
142
143 void end_progress_bar(void)
144 {
145         g_progress_bar = 0;
146 }
147
148 static void update_progress_bar(float done, char *info)
149 {
150         g_done = done;
151         g_progress_info = info;
152 }
153
154 /** Progress bar
155         'done': a value between 0.0 and 1.0, showing progress
156         'info': a info text what is currently being done
157
158         Make sure that the progress bar is always called with:
159         done = 0.0 first
160                 and
161         done = 1.0 last -- or alternatively use:
162
163         start_progressbar();
164         do_stuff_and_callback_progress_bar();
165         end_progressbar();
166 */
167
168 int progress_bar(float done, char *busy_info)
169 {
170         ScrArea *sa;
171         short val; 
172
173         /* User break (ESC) */
174         while (qtest()) {
175                 if (extern_qread(&val) == ESCKEY) 
176                         return 0;
177         }
178         if (done == 0.0) {
179                 start_progress_bar();
180         } else if (done > 0.99) {
181                 end_progress_bar();
182         }
183
184         sa= G.curscreen->areabase.first;
185         while(sa) {
186                 if (sa->spacetype == SPACE_INFO) {
187                         update_progress_bar(done, busy_info);
188
189                         curarea = sa;
190
191                         scrarea_do_headdraw(curarea);
192                         areawinset(curarea->win);
193                         sa->head_swap= WIN_BACK_OK;
194                         screen_swapbuffers();
195                 }
196                 sa = sa->next;
197         }
198         return 1;
199 }
200 /* -- End of progress bar definitions ------- */
201
202 extern char temp_dir[]; /* XXXXX BAD BAD BAD from exotic.c */
203
204 void write_vrml_fs()
205 {
206         if(G.obedit) {
207                 error("Can't save VRML. Press TAB to leave EditMode");
208         }
209         else {
210                 if(temp_dir[0]==0) strcpy(temp_dir, G.sce);
211         
212                 activate_fileselect(FILE_SPECIAL, "Export VRML 1.0", temp_dir, write_vrml);
213         }  
214 }
215
216 void write_dxf_fs()
217 {
218         if(G.obedit) {
219                 error("Can't save DXF. Press TAB to leave EditMode");
220         }
221         else {
222
223                 if(temp_dir[0]==0) strcpy(temp_dir, G.sce);
224
225                 activate_fileselect(FILE_SPECIAL, "Export DXF", temp_dir, write_dxf);   
226         }
227 }
228
229 void write_stl_fs()
230 {
231         if(G.obedit) {
232                 error("Can't save STL. Press TAB to leave EditMode");
233         }
234         else {
235
236                 if(temp_dir[0]==0) strcpy(temp_dir, G.sce);
237
238                 activate_fileselect(FILE_SPECIAL, "Export STL", temp_dir, write_stl);
239         }
240 }
241 /* ------------ */
242
243 int buttons_do_unpack()
244 {
245         int how;
246         char menu[2048];
247         char *line = menu;
248         int ret_value = RET_OK, count = 0;
249
250         count = countPackedFiles();
251
252         if(!count) {
253                 pupmenu("No packed files. Autopack disabled");
254                 return ret_value;
255         }
256         if (count == 1)
257                 line += sprintf(line, "Unpack 1 file%%t");
258         else
259                 line += sprintf(line, "Unpack %d files%%t", count);
260         
261         line += sprintf(line, "|Use files in current directory (create when necessary)%%x%d", PF_USE_LOCAL);
262         line += sprintf(line, "|Write files to current directory (overwrite existing files)%%x%d", PF_WRITE_LOCAL);
263         line += sprintf(line, "|%%l|Use files in original location (create when necessary)%%x%d", PF_USE_ORIGINAL);
264         line += sprintf(line, "|Write files to original location (overwrite existing files)%%x%d", PF_WRITE_ORIGINAL);
265         line += sprintf(line, "|%%l|Disable AutoPack, keep all packed files %%x%d", PF_KEEP);
266         line += sprintf(line, "|Ask for each file %%x%d", PF_ASK);
267
268         how = pupmenu(menu);
269
270         if(how == -1)
271                 ret_value = RET_CANCEL;
272         else {
273                 if (how != PF_KEEP) unpackAll(how);
274                 G.fileflags &= ~G_AUTOPACK;
275         }
276         
277         return ret_value;
278 }
279
280 /* here, because of all creator stuff */
281
282 Scene *copy_scene(Scene *sce, int level)
283 {
284         /* level 0: al objects shared
285          * level 1: al object-data shared
286          * level 2: full copy
287          */
288         Scene *scen;
289         Base *base, *obase;
290
291         /* level 0 */
292         scen= copy_libblock(sce);
293         duplicatelist(&(scen->base), &(sce->base));
294         
295         clear_id_newpoins();
296         
297         id_us_plus((ID *)scen->world);
298         id_us_plus((ID *)scen->set);
299
300         scen->ed= NULL;
301         scen->radio= NULL;
302         scen->theDag= NULL;
303         scen->toolsettings= MEM_dupallocN(sce->toolsettings);
304
305         duplicatelist(&(scen->markers), &(sce->markers));
306         duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces));
307         duplicatelist(&(scen->r.layers), &(sce->r.layers));
308         
309         scen->nodetree= ntreeCopyTree(sce->nodetree, 0);
310         
311         obase= sce->base.first;
312         base= scen->base.first;
313         while(base) {
314                 id_us_plus(&base->object->id);
315                 if(obase==sce->basact) scen->basact= base;
316
317                 obase= obase->next;
318                 base= base->next;
319         }
320
321         if(level==0) return scen;
322
323         /* level 1 */
324         G.scene= scen;
325         
326         single_object_users(0);
327
328         /*      camera */
329         ID_NEW(G.scene->camera);
330
331         /* level 2 */
332         if(level>=2) {
333                 if(scen->world) {
334                         id_us_plus(&scen->world->id);
335                         scen->world= copy_world(scen->world);
336                 }
337                 single_obdata_users(0);
338                 single_mat_users_expand();
339                 single_tex_users_expand();
340                 
341                 scen->radio= MEM_dupallocN(sce->radio);
342                 
343         }
344
345         clear_id_newpoins();
346
347         BPY_copy_scriptlink(&sce->scriptlink);
348         // make a private copy of the avicodecdata
349
350         if (sce->r.avicodecdata) {
351
352                 scen->r.avicodecdata = MEM_dupallocN(sce->r.avicodecdata);
353                 scen->r.avicodecdata->lpFormat = MEM_dupallocN(scen->r.avicodecdata->lpFormat);
354                 scen->r.avicodecdata->lpParms = MEM_dupallocN(scen->r.avicodecdata->lpParms);
355         }
356
357         // make a private copy of the qtcodecdata
358
359         if (sce->r.qtcodecdata) {
360                 scen->r.qtcodecdata = MEM_dupallocN(sce->r.qtcodecdata);
361                 scen->r.qtcodecdata->cdParms = MEM_dupallocN(scen->r.qtcodecdata->cdParms);
362         }
363
364         return scen;
365 }
366
367 void do_info_buttons(unsigned short event)
368 {
369         bScreen *sc, *oldscreen;
370         Scene *sce, *sce1;
371         ScrArea *sa;
372         int nr;
373
374         switch(event) {
375         case B_INFOSCR:         /* menu select screen */
376
377                 if( G.curscreen->screennr== -2) {
378                         if(curarea->winy <50) {
379                                 sa= closest_bigger_area();
380                                 areawinset(sa->win);
381                         }
382                         activate_databrowse((ID *)G.curscreen, ID_SCR, 0, B_INFOSCR,
383                                                                                         &G.curscreen->screennr, do_info_buttons);
384                         return;
385                 }
386                 if( G.curscreen->screennr < 0) return;
387
388                 sc= G.main->screen.first;
389                 nr= 1;
390                 while(sc) {
391                         if(nr==G.curscreen->screennr) {
392                                 if(is_allowed_to_change_screen(sc)) setscreen(sc);
393                                 else error("Unable to perform function in EditMode");
394                                 break;
395                         }
396                         nr++;
397                         sc= sc->id.next;
398                 }
399                 /* last item: NEW SCREEN */
400                 if(sc==0) {
401                         nr= pupmenu("New Screen%t|Empty%x1|Duplicate%x2");
402
403                         if(nr==1) default_twosplit();
404                         if(nr==2) duplicate_screen();
405                 }
406                 break;
407         case B_INFODELSCR:
408 /*do this event only with buttons, so it can never be called with full-window*/
409
410                 if(G.curscreen->id.prev) sc= G.curscreen->id.prev;
411                 else if(G.curscreen->id.next) sc= G.curscreen->id.next;
412                 else return;
413                 if(okee("Delete current screen")) {
414                         /* find new G.curscreen */
415
416                         oldscreen= G.curscreen;
417                         setscreen(sc);          /* this test if sc has a full */
418                         unlink_screen(oldscreen);
419                         free_libblock(&G.main->screen, oldscreen);
420                 }
421                 scrarea_queue_headredraw(curarea);
422
423                 break;
424         case B_INFOSCE:         /* menu select scene */
425
426                 if( G.curscreen->scenenr== -2) {
427                         if(curarea->winy <50) {
428                                 sa= closest_bigger_area();
429                                 areawinset(sa->win);
430                         }
431                         activate_databrowse((ID *)G.scene, ID_SCE, 0, B_INFOSCE,
432                                                                                         &G.curscreen->scenenr, do_info_buttons);
433                         return;
434                 }
435                 if( G.curscreen->scenenr < 0) return;
436
437                 sce= G.main->scene.first;
438                 nr= 1;
439                 while(sce) {
440                         if(nr==G.curscreen->scenenr) {
441                                 if(sce!=G.scene) set_scene(sce);
442                                 break;
443                         }
444                         nr++;
445                         sce= sce->id.next;
446                 }
447                 /* last item: NEW SCENE */
448                 if(sce==0) {
449                         nr= pupmenu("Add scene%t|Empty|Link Objects|Link ObData|Full Copy");
450                         if(nr<= 0) return;
451                         if(nr==1) {
452                                 ListBase lb;
453                                 
454                                 sce= add_scene(G.scene->id.name+2);
455                                 /* pretty bad ass copying here. we should use copy_scene to do all (ton) */
456                                 lb= sce->r.layers;
457                                 sce->r= G.scene->r;
458                                 sce->r.layers= lb;
459 #ifdef _WIN32
460                                 if (sce->r.avicodecdata) {
461                                         sce->r.avicodecdata = MEM_dupallocN(G.scene->r.avicodecdata);
462                                         sce->r.avicodecdata->lpFormat = MEM_dupallocN(G.scene->r.avicodecdata->lpFormat);
463                                         sce->r.avicodecdata->lpParms = MEM_dupallocN(G.scene->r.avicodecdata->lpParms);
464                                 }
465 #endif
466 #ifdef WITH_QUICKTIME
467                                 if (sce->r.qtcodecdata) {
468                                         sce->r.qtcodecdata = MEM_dupallocN(G.scene->r.qtcodecdata);
469                                         sce->r.qtcodecdata->cdParms = MEM_dupallocN(G.scene->r.qtcodecdata->cdParms);
470                                 }
471 #endif
472                         }
473                         else sce= copy_scene(G.scene, nr-2);
474
475                         set_scene(sce);
476                 }
477                 countall();
478                 BIF_preview_changed(ID_TE);
479
480                 break;
481         case B_INFODELSCE:
482
483                 if(G.scene->id.prev) sce= G.scene->id.prev;
484                 else if(G.scene->id.next) sce= G.scene->id.next;
485                 else return;
486                 if(okee("Delete current scene")) {
487                         /* Note, anything besides free_libblock needs to be added in
488                          * Python Scene.c for Blender.Scene.Unlink() */
489                         
490                         
491                         /* exit modes... could become single call once */
492                         exit_editmode(EM_FREEDATA|EM_WAITCURSOR);
493                         exit_paint_modes();
494                         
495                         /* check all sets */
496                         for (sce1= G.main->scene.first; sce1; sce1= sce1->id.next) {
497                                 if(sce1->set == G.scene) sce1->set= 0;
498                         }
499                         
500                         /* check all sequences */
501                         clear_scene_in_allseqs(G.scene);
502
503                         /* check render layer nodes in other scenes */
504                         clear_scene_in_nodes(G.scene);
505                         
506                         /* al screens */
507                         
508                         for (sc= G.main->screen.first; sc; sc= sc->id.next ) {
509                                 if(sc->scene == G.scene) sc->scene= sce;
510                         }
511                         free_libblock(&G.main->scene, G.scene);
512                         set_scene(sce);
513                         countall();
514                 }
515
516                 break;
517         }
518 }
519
520 static void check_packAll()
521 {
522         // first check for dirty images
523         Image *ima;
524
525         for(ima = G.main->image.first; ima; ima= ima->id.next) {
526                 if (ima->ibufs.first) { /* XXX FIX */
527                         ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
528
529                         if (ibuf && (ibuf->userflags &= IB_BITMAPDIRTY))
530                                 break;
531                 }
532         }
533         
534         if (ima == NULL || okee("Some images are painted on. These changes will be lost. Continue ?")) {
535                 packAll();
536                 G.fileflags |= G_AUTOPACK;
537         }
538 }
539
540 static int write_runtime(char *str, char *exename)
541 {
542         char *freestr= NULL;
543         char *ext = 0;
544
545 #ifdef _WIN32
546         ext = ".exe";
547 #endif
548
549 #ifdef __APPLE__
550         ext = ".app";
551 #endif
552         if (ext && (!BLI_testextensie(str, ext))) {
553                 freestr= MEM_mallocN(strlen(str) + strlen(ext) + 1, "write_runtime_check");
554                 sprintf(freestr,"%s%s", str, ext);
555                 str= freestr;
556         }
557
558         if (!BLI_exists(str) || saveover(str))
559                 BLO_write_runtime(str, exename);
560
561         if (freestr)
562                 MEM_freeN(freestr);
563  
564         return 0;
565 }
566
567 static void write_runtime_check_dynamic(char *str) 
568 {
569         write_runtime(str, "blenderdynplayer.exe");
570 }
571
572 static void write_runtime_check(char *str) 
573 {
574         char player[128];
575
576         strcpy(player, "blenderplayer");
577
578 #ifdef _WIN32
579         strcat(player, ".exe");
580 #endif
581
582 #ifdef __APPLE__
583         strcat(player, ".app");
584 #endif
585
586         write_runtime(str, player);
587 }
588 /* end keyed functions */
589
590 /************************** MAIN MENU *****************************/
591 /************************** FILE *****************************/
592
593
594 static void do_info_file_importmenu(void *arg, int event)
595 {
596         ScrArea *sa;
597
598         if(curarea->spacetype==SPACE_INFO) {
599                 sa= find_biggest_area_of_type(SPACE_SCRIPT);
600                 if (!sa) sa= closest_bigger_area();
601                 areawinset(sa->win);
602         }
603
604         /* events >=3 are registered bpython scripts */
605         if (event >= 3) {
606                 BPY_menu_do_python(PYMENU_IMPORT, event - 3);
607                 BIF_undo_push("Import file");
608         }
609         else {
610                 switch(event) {
611                                                                         
612                 case 0: /* DXF */
613                         activate_fileselect(FILE_BLENDER, "Import DXF", G.sce, BIF_read_file);
614                         break;
615                 case 1: /* VRML 1.0 */
616                         activate_fileselect(FILE_BLENDER, "Import VRML 1.0", G.sce, BIF_read_file);
617                         break;
618                 case 2: /* STL */
619                         activate_fileselect(FILE_BLENDER, "Import STL", G.sce, BIF_read_file);
620                         break;
621
622                 }
623         }
624         allqueue(REDRAWINFO, 0);
625 }
626
627 static uiBlock *info_file_importmenu(void *arg_unused)
628 {
629         uiBlock *block;
630         short yco = 20, menuwidth = 120;
631         BPyMenu *pym;
632         int i = 0;
633
634         block= uiNewBlock(&curarea->uiblocks, "importmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
635         uiBlockSetButmFunc(block, do_info_file_importmenu, NULL);
636         //uiBlockSetXOfs(block, -50);  // offset to parent button
637         
638         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "VRML 1.0...",
639                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "");
640         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "DXF...",
641                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "");
642         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "STL...",
643                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
644
645         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
646
647         for (pym = BPyMenuTable[PYMENU_IMPORT]; pym; pym = pym->next, i++) {
648                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+3, pym->tooltip?pym->tooltip:pym->filename);
649         }
650
651         uiBlockSetDirection(block, UI_RIGHT);
652         uiTextBoundsBlock(block, 60);
653
654         return block;
655 }
656
657 static void do_info_file_exportmenu(void *arg, int event)
658 {
659         ScrArea *sa;
660
661         if(curarea->spacetype==SPACE_INFO) {
662                 sa= find_biggest_area_of_type(SPACE_SCRIPT);
663                 if (!sa) sa= closest_bigger_area();
664                 areawinset(sa->win);
665         }
666
667         /* events >=3 are registered bpython scripts */
668         if (event >= 3) BPY_menu_do_python(PYMENU_EXPORT, event - 3);
669
670         else switch(event) {
671                                                                         
672         case 0:
673                 write_vrml_fs();
674                 break;
675         case 1:
676                 write_dxf_fs();
677                 break;
678         case 2:
679                 write_stl_fs();
680                 break;
681         }
682         allqueue(REDRAWINFO, 0);
683 }
684
685 static uiBlock *info_file_exportmenu(void *arg_unused)
686 {
687         uiBlock *block;
688         short yco = 20, menuwidth = 120;
689         BPyMenu *pym;
690         int i = 0;
691
692         block= uiNewBlock(&curarea->uiblocks, "exportmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
693         uiBlockSetButmFunc(block, do_info_file_exportmenu, NULL);
694         //uiBlockSetXOfs(block, -50);  // offset to parent button
695
696         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "VRML 1.0...|Ctrl F2",
697                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "");
698         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "DXF...|Shift F2",
699                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "");
700         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "STL...",
701                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
702
703         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
704
705         /* note that we acount for the 3 previous entries with i+3: */
706         for (pym = BPyMenuTable[PYMENU_EXPORT]; pym; pym = pym->next, i++) {
707                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, 
708                                  NULL, 0.0, 0.0, 1, i+3, 
709                                  pym->tooltip?pym->tooltip:pym->filename);
710         }
711
712
713         uiBlockSetDirection(block, UI_RIGHT);
714         uiTextBoundsBlock(block, 60);
715
716         return block;
717 }
718
719 #ifdef WITH_VERSE
720
721 extern ListBase session_list;
722
723 static void do_verse_filemenu(void *arg, int event)
724 {
725         char address[64];               /* lenght of domain name is 63 characters or less */
726         VerseSession *session = NULL;
727         ScrArea *sa;
728         
729         if(curarea->spacetype==SPACE_INFO) {
730                 sa= closest_bigger_area();
731                 areawinset(sa->win);
732         }
733
734         switch(event) {
735                 case 0:
736                         waitcursor(1);
737                         printf("Connecting to localhost!\n");
738                         b_verse_connect("localhost");
739                         waitcursor(0);
740                         break;
741                 case 1:
742                         address[0] = '\0';
743                         if(sbutton(address, 0, 63, "Server:")) {
744                                 waitcursor(1);
745                                 printf("Connecting to %s\n", address);
746                                 b_verse_connect(address);
747                                 waitcursor(0);
748                         }
749                         break;
750                 case 2:
751                         session = session_menu();
752                         if(session) {
753                                 printf("Disconnecting session: %s!\n", session->address);
754                                 end_verse_session(session);
755                         }
756                         break;
757                 case 3:
758                         printf("Disconnecting all sessions!\n");
759                         end_all_verse_sessions();
760                         break;
761         case 4:
762             printf("sending get to master server\n");
763             b_verse_ms_get();
764             break;
765         }
766 }
767
768 static uiBlock *verse_filemenu(void *unusedargs)
769 {
770         uiBlock *block;
771         short yco = 20, menuwidth = 120;
772
773         block= uiNewBlock(&curarea->uiblocks, "verse_filemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
774         uiBlockSetButmFunc(block, do_verse_filemenu, NULL);
775                 
776         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Connect to localhost", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
777         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Connect ...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
778         if(session_list.first != NULL) {
779                 if(session_list.first != session_list.last) {
780                         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Disconnect ...",
781                                         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
782                         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Disconnect all",
783                                         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
784                 }
785                 else {
786                         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Disconnect",
787                                         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
788                 }
789                 
790         }
791         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Get Servers", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
792
793         uiBlockSetDirection(block, UI_RIGHT);
794         uiTextBoundsBlock(block, 60);
795
796         return block;
797 }
798 #endif
799
800 static void do_info_filemenu(void *arg, int event)
801 {
802         ScrArea *sa;
803         char dir[FILE_MAXDIR];
804         
805         if(curarea->spacetype==SPACE_INFO) {
806                 sa= closest_bigger_area();
807                 areawinset(sa->win);
808         }
809
810         /* these are no defines, easier this way, the codes are in the function below */
811         switch(event) {
812         case 0:
813                 if (okee("Erase All")) {
814                         if (!BIF_read_homefile(0))
815                                 error("No file ~/.B.blend");
816                 }
817                 break;
818         case 1: /* open */
819                 activate_fileselect(FILE_BLENDER, "Open", G.sce, BIF_read_file);
820                 break;
821         case 3: /* append */
822                 activate_fileselect(FILE_LOADLIB, "Load Library", G.lib, 0);
823                 break;
824         case 4: /* save */
825                 strcpy(dir, G.sce);
826                 untitled(dir);
827                 activate_fileselect(FILE_BLENDER, "Save As", dir, BIF_write_file);
828                 break;
829         case 5:
830                 strcpy(dir, G.sce);
831                 if (untitled(dir)) {
832                         activate_fileselect(FILE_BLENDER, "Save As", dir, BIF_write_file);
833                 } else {
834                         /* do NOT ask everytime for overwriting... */
835                         G.save_over = 1;
836                         BIF_write_file(dir);
837                         free_filesel_spec(dir);
838                 }
839                 break;
840         case 6: /* save image */
841                 BIF_save_rendered_image_fs();
842                 break;
843         case 7:
844                 activate_imageselect(FILE_LOADLIB, "Load Library", G.lib, 0);
845                 break;
846         case 22: /* save runtime */
847                 activate_fileselect(FILE_SPECIAL, "Save Runtime", "", write_runtime_check);
848                 break;
849         case 23: /* save dynamic runtime */
850                 activate_fileselect(FILE_SPECIAL, "Save Dynamic Runtime", "", write_runtime_check_dynamic);
851                 break;
852         case 24:
853                 BIF_screendump(0);
854                 break;
855         case 25:
856                 BIF_screendump(1);
857                 break;
858         case 13:
859                 exit_usiblender();
860                 break;
861         case 15:        /* recover previous session */
862                 {
863                         extern short winqueue_break; /* editscreen.c */
864                         int save_over;
865                         char str[FILE_MAXDIR+FILE_MAXFILE];
866                         char scestr[FILE_MAXDIR+FILE_MAXFILE];
867                         
868                         strcpy(scestr, G.sce);  /* temporal store */
869                         save_over = G.save_over;
870                         BLI_make_file_string("/", str, U.tempdir, "quit.blend");
871                         BKE_read_file(str, NULL);
872                         G.save_over = save_over;
873                         strcpy(G.sce, scestr);
874
875                         winqueue_break= 1;      /* leave queues everywhere */
876                 
877                         BKE_reset_undo();
878                         BKE_write_undo("original");     /* save current state */
879                         refresh_interface_font();
880                 }
881                 break;
882         case 31: /* save default settings */
883                 BIF_write_homefile();
884                 break;
885         case 32:
886                 if (okee("Erase All")) {
887                         if (!BIF_read_homefile(1))
888                                 error("Can't read data from memory!");
889                 }
890                 break;
891         case 35: /* compress toggle */
892                 U.flag ^= (USER_FILECOMPRESS);
893                 break;
894         }
895         
896         allqueue(REDRAWINFO, 0);
897 }
898
899 static void do_info_operecentmenu(void *arg, int event)
900 {
901         struct RecentFile *recent;
902
903         if(event==0 && G.sce[0]) {
904                 BIF_read_file(G.sce);
905         }
906         else {  /* Global */
907                 recent = BLI_findlink(&(G.recent_files), event-1);
908                 BIF_read_file(recent->filename);
909         }
910 }
911
912 static uiBlock *info_openrecentmenu(void *arg_unused)
913 {
914         uiBlock *block;
915         short yco = 20, menuwidth = 120, i;
916         struct RecentFile *recent;
917
918         block= uiNewBlock(&curarea->uiblocks, "info_openrecentmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
919         uiBlockSetButmFunc(block, do_info_operecentmenu, NULL);
920
921         if (G.sce[0]) {
922                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, G.sce, 0, yco-=20,
923                                 menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
924         }
925
926         for (recent = G.recent_files.first, i=0; i<U.recent_files && recent; recent = recent->next, i++) {
927                 if (strcmp(recent->filename, G.sce)!=0) {
928                         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, recent->filename, 0, yco-=20,
929                                         menuwidth, 19, NULL, 0.0, 0.0, 1, i+1, "");
930                 }
931         }
932
933         uiBlockSetDirection(block, UI_RIGHT);
934         uiTextBoundsBlock(block, 60);
935         return block;
936 }
937
938 static void do_info_externalfiles(void *arg, int event)
939 {
940         switch (event) {
941                 
942         case 1: /* pack data */
943                 check_packAll();
944                 break;
945 #if 0
946         case 2: /* unpack to current dir */
947                 unpackAll(PF_WRITE_LOCAL);
948                 G.fileflags &= ~G_AUTOPACK;
949                 break;
950 #endif
951         case 3: /* unpack data */
952                 if (buttons_do_unpack() != RET_CANCEL) {
953                         /* Clear autopack bit only if user selected one of the unpack options */
954                         G.fileflags &= ~G_AUTOPACK;
955                 }
956                 break;
957         case 10: /* make all paths relative */
958                 if (G.relbase_valid) {
959                         int tot,changed,failed,linked;
960                         char str[512];
961                         char txtname[24]; /* text block name */
962                         txtname[0] = '\0';
963                         makeFilesRelative(txtname, &tot, &changed, &failed, &linked);
964                         if (failed) sprintf(str, "Make Relative%%t|Total files %i|Changed %i|Failed %i, See Text \"%s\"|Linked %i", tot, changed, failed, txtname, linked);
965                         else            sprintf(str, "Make Relative%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
966                         pupmenu(str);
967                 } else {
968                         pupmenu("Can't set relative paths with an unsaved blend file");
969                 }
970                 break;
971         case 11: /* make all paths relative */
972                 {
973                         int tot,changed,failed,linked;
974                         char str[512];
975                         char txtname[24]; /* text block name */
976                         txtname[0] = '\0';
977                         makeFilesAbsolute(txtname, &tot, &changed, &failed, &linked);
978                         sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
979                         if (failed) sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i, See Text \"%s\"|Linked %i", tot, changed, failed, txtname, linked);
980                         else            sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
981                         
982                         pupmenu(str);
983                 }
984                 break;
985         case 12: /* check images exist */
986                 {
987                         char txtname[24]; /* text block name */
988                         txtname[0] = '\0';
989                         
990                         /* run the missing file check */
991                         checkMissingFiles( txtname );
992                         
993                         if (txtname[0] == '\0') {
994                                 okee("No external files missing");
995                         } else {
996                                 char str[128];
997                                 sprintf(str, "Missing files listed in Text \"%s\"", txtname );
998                                 error(str);
999                         }
1000                 }
1001                 break;
1002         case 13: /* search for referenced files that are not available  */
1003                 if(curarea->spacetype==SPACE_INFO) {
1004                         ScrArea *sa;
1005                         sa= closest_bigger_area();
1006                         areawinset(sa->win);
1007                 }
1008                 activate_fileselect(FILE_SPECIAL, "Find Missing Files", "", findMissingFiles);
1009                 break;
1010         }
1011         
1012         allqueue(REDRAWINFO, 0);
1013 }
1014
1015 static uiBlock *info_externalfiles(void *arg_unused)
1016 {
1017         uiBlock *block;
1018         short yco = 20, menuwidth = 120;
1019
1020         block= uiNewBlock(&curarea->uiblocks, "info_externalfiles", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1021         uiBlockSetButmFunc(block, do_info_externalfiles, NULL);
1022
1023         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pack into Blend",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1024 #if 0
1025         uiDefBut(block, BUTM, 1, "Unpack Data to current dir",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Removes all packed files from the project and saves them to the current directory");
1026 #endif
1027         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unpack into Files...",                           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1028
1029         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1030         
1031         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Relative",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, "");
1032         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Absolute",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 11, "");
1033         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Report Missing Files",                           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, "");
1034         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Missing Files",                             0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 13, "");
1035
1036         uiBlockSetDirection(block, UI_RIGHT);
1037         uiTextBoundsBlock(block, 60);
1038         return block;
1039 }
1040
1041 static uiBlock *info_filemenu(void *arg_unused)
1042 {
1043         uiBlock *block;
1044         short yco=0;
1045         short menuwidth=120;
1046
1047         block= uiNewBlock(&curarea->uiblocks, "info_filemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1048         uiBlockSetButmFunc(block, do_info_filemenu, NULL);
1049         
1050         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "New|Ctrl X",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
1051         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Open...|F1",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1052 #ifdef WITH_VERSE
1053         uiDefIconTextBlockBut(block, verse_filemenu, NULL, ICON_RIGHTARROW_THIN, "Verse", 0, yco-=20, menuwidth, 19, "");
1054 #endif
1055         uiDefIconTextBlockBut(block, info_openrecentmenu, NULL, ICON_RIGHTARROW_THIN, "Open Recent",0, yco-=20, 120, 19, "");
1056         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Recover Last Session",                           0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, "");
1057
1058         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1059
1060         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save|Ctrl W",                            0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
1061         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save As...|F2",                  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
1062         
1063         if(U.flag & USER_FILECOMPRESS) {
1064                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Compress File",     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 35, "Enable file compression");
1065         } else {
1066                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Compress File",   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 35, "Enable file compression");
1067         }
1068
1069         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1070
1071         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Rendered Image...|F3",                      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
1072         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Screenshot Subwindow|Ctrl F3",                   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 24, "");
1073         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Screenshot All|Ctrl Shift F3",                   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 25, "");
1074 #if GAMEBLENDER == 1
1075         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Runtime...",                        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 22, "");
1076 #ifdef _WIN32
1077         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Dynamic Runtime...",                0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 23, "");
1078 #endif
1079 #endif
1080         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1081
1082         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Default Settings|Ctrl U",                   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 31, "");
1083         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Load Factory Settings",                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 32, "");
1084
1085
1086         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1087
1088         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Append or Link|Shift F1",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
1089         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Append or Link (Image Browser)|Ctrl F1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
1090         uiDefIconTextBlockBut(block, info_file_importmenu, NULL, ICON_RIGHTARROW_THIN, "Import", 0, yco-=20, menuwidth, 19, "");
1091         uiDefIconTextBlockBut(block, info_file_exportmenu, NULL, ICON_RIGHTARROW_THIN, "Export", 0, yco-=20, menuwidth, 19, "");
1092         
1093         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1094         
1095         uiDefIconTextBlockBut(block, info_externalfiles, NULL, ICON_RIGHTARROW_THIN, "External Data",0, yco-=20, 120, 19, "");
1096         
1097         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1098         
1099         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Quit Blender|Ctrl Q",                            0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, "");
1100
1101         uiBlockSetDirection(block, UI_DOWN);
1102         uiTextBoundsBlock(block, 80);
1103
1104         return block;
1105 }
1106
1107 /**************************** ADD ******************************/
1108
1109 void do_info_add_meshmenu(void *arg, int event)
1110 {
1111         if (event>=20) {
1112                 BPY_menu_do_python(PYMENU_ADDMESH, event - 20);
1113         } else {
1114                 switch(event) {         
1115                         case 0:
1116                                 /* Plane */
1117                                 add_primitiveMesh(0);
1118                                 break;
1119                         case 1:
1120                                 /* Cube */
1121                                 add_primitiveMesh(1);
1122                                 break;
1123                         case 2:
1124                                 /* Circle */
1125                                 add_primitiveMesh(4);
1126                                 break;
1127                         case 3:
1128                                 /* UVsphere */
1129                                 add_primitiveMesh(11);
1130                                 break;
1131                         case 4:
1132                                 /* IcoSphere */
1133                                 add_primitiveMesh(12);
1134                                 break;
1135                         case 5:
1136                                 /* Cylinder */
1137                                 add_primitiveMesh(5);
1138                                 break;
1139                         case 7:
1140                                 /* Cone */
1141                                 add_primitiveMesh(7);
1142                                 break;
1143                         case 8:
1144                                 /* Grid */
1145                                 add_primitiveMesh(10);
1146                                 break;
1147                         case 9:
1148                                 /* Monkey */
1149                                 add_primitiveMesh(13);
1150                                 break;
1151                         default:
1152                                 break;
1153                 }
1154         }
1155         allqueue(REDRAWINFO, 0);
1156 }
1157
1158 static uiBlock *info_add_meshmenu(void *arg_unused)
1159 {
1160 /*              static short tog=0; */
1161         uiBlock *block;
1162         short yco= 0;
1163         
1164         /* Python Menu */
1165         BPyMenu *pym;
1166         int i=0;
1167         
1168         block= uiNewBlock(&curarea->uiblocks, "add_meshmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1169         uiBlockSetButmFunc(block, do_info_add_meshmenu, NULL);
1170         
1171         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Plane|",                         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1172         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cube|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1173         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Circle|",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1174         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "UVsphere",                       0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1175         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "IcoSphere|",                     0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1176         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cylinder|",                      0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "");
1177         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cone|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 7, "");
1178         uiDefIconTextBut(block, SEPR, 0, ICON_BLANK1, "",                                       0, yco-=6,      160, 6,  NULL, 0.0, 0.0, 0, 0, "");
1179         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grid|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 8, "");
1180         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Monkey|",                        0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 9, "");
1181
1182
1183         pym = BPyMenuTable[PYMENU_ADDMESH];
1184         if (pym) {
1185                 uiDefIconTextBut(block, SEPR, 0, ICON_BLANK1, "",                                       0, yco-=6,      160, 6,  NULL, 0.0, 0.0, 0, 0, "");
1186                 
1187                 for (; pym; pym = pym->next, i++) {
1188                         uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, i+20, pym->tooltip?pym->tooltip:pym->filename);
1189                 }
1190         }
1191                 
1192         uiBlockSetDirection(block, UI_RIGHT);
1193         uiTextBoundsBlock(block, 50);
1194                 
1195         return block;
1196 }
1197
1198 void do_info_add_curvemenu(void *arg, int event)
1199 {
1200
1201         switch(event) {         
1202                 case 0:
1203                         /* Bezier Curve */
1204                         add_primitiveCurve(10);
1205                         break;
1206                 case 1:
1207                         /* Bezier Circle */
1208                         add_primitiveCurve(11);
1209                         break;
1210                 case 2:
1211                         /* NURB Curve */
1212                         add_primitiveCurve(40);
1213                         break;
1214                 case 3:
1215                         /* NURB Circle */
1216                         add_primitiveCurve(41);
1217                         break;
1218                 case 4:
1219                         /* Path */
1220                         add_primitiveCurve(46);
1221                         break;
1222                 default:
1223                         break;
1224         }
1225         allqueue(REDRAWINFO, 0);
1226 }
1227
1228 static uiBlock *info_add_curvemenu(void *arg_unused)
1229 {
1230 /*              static short tog=0; */
1231         uiBlock *block;
1232         short yco= 0;
1233         
1234         block= uiNewBlock(&curarea->uiblocks, "add_curvemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1235         uiBlockSetButmFunc(block, do_info_add_curvemenu, NULL);
1236         
1237         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Bezier Curve|",  0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1238         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Bezier Circle|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1239         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Curve|",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1240         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Circle",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1241         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Path|",                  0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1242
1243         uiBlockSetDirection(block, UI_RIGHT);
1244         uiTextBoundsBlock(block, 50);
1245                 
1246         return block;
1247 }
1248
1249
1250 void do_info_add_surfacemenu(void *arg, int event)
1251 {
1252
1253         switch(event) {         
1254                 case 0:
1255                         /* Curve */
1256                         add_primitiveNurb(0);
1257                         break;
1258                 case 1:
1259                         /* Circle */
1260                         add_primitiveNurb(1);
1261                         break;
1262                 case 2:
1263                         /* Surface */
1264                         add_primitiveNurb(2);
1265                         break;
1266                 case 3:
1267                         /* Tube */
1268                         add_primitiveNurb(3);
1269                         break;
1270                 case 4:
1271                         /* Sphere */
1272                         add_primitiveNurb(4);
1273                         break;
1274                 case 5:
1275                         /* Donut */
1276                         add_primitiveNurb(5);
1277                         break;
1278                 default:
1279                         break;
1280         }
1281         allqueue(REDRAWINFO, 0);
1282 }
1283
1284 static uiBlock *info_add_surfacemenu(void *arg_unused)
1285 {
1286 /*              static short tog=0; */
1287         uiBlock *block;
1288         short yco= 0;
1289         
1290         block= uiNewBlock(&curarea->uiblocks, "add_surfacemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1291         uiBlockSetButmFunc(block, do_info_add_surfacemenu, NULL);
1292         
1293         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Curve|",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1294         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Circle|",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1295         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Surface|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1296         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Tube",             0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1297         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Sphere|",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1298         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Donut|",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "");
1299         uiBlockSetDirection(block, UI_RIGHT);
1300         uiTextBoundsBlock(block, 50);
1301                 
1302         return block;
1303 }
1304
1305 void do_info_add_metamenu(void *arg, int event)
1306 {
1307
1308         switch(event) {         
1309                 case 0:
1310                         /* Ball */
1311                         add_primitiveMball(1);
1312                         break;
1313                 case 1:
1314                         /* Tube */
1315                         add_primitiveMball(2);
1316                         break;
1317                 case 2:
1318                         /* Plane */
1319                         add_primitiveMball(3);
1320                         break;
1321                 case 3:
1322                         /* Elipsoid */
1323                         add_primitiveMball(4);
1324                         break;
1325                 case 4:
1326                         /* Cube */
1327                         add_primitiveMball(5);
1328                         break;
1329                 default:
1330                         break;
1331         }
1332         allqueue(REDRAWINFO, 0);
1333 }
1334
1335
1336 static uiBlock *info_add_metamenu(void *arg_unused)
1337 {
1338 /*              static short tog=0; */
1339         uiBlock *block;
1340         short xco= 0;
1341         
1342         block= uiNewBlock(&curarea->uiblocks, "add_metamenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1343         uiBlockSetButmFunc(block, do_info_add_metamenu, NULL);
1344         
1345         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,"Meta Ball|",              0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1346         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Tube|",             0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1347         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Plane|",            0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1348         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Ellipsoid|",        0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1349         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Cube|",             0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1350
1351         uiBlockSetDirection(block, UI_RIGHT);
1352         uiTextBoundsBlock(block, 50);
1353                 
1354         return block;
1355 }
1356
1357 void do_info_add_lampmenu(void *arg, int event)
1358 {
1359
1360         switch(event) {         
1361                 case 0: /* lamp */
1362                         add_objectLamp(LA_LOCAL);
1363                         break;
1364                 case 1: /* sun */
1365                         add_objectLamp(LA_SUN);
1366                         break;
1367                 case 2: /* spot */
1368                         add_objectLamp(LA_SPOT);
1369                         break;
1370                 case 3: /* hemi */
1371                         add_objectLamp(LA_HEMI);
1372                         break;
1373                 case 4: /* area */
1374                         add_objectLamp(LA_AREA);
1375                         break;
1376                 case 5: /* YafRay photon lamp */
1377                         if (G.scene->r.renderer==R_YAFRAY)
1378                                 add_objectLamp(LA_YF_PHOTON);
1379                         break;
1380                 default:
1381                         break;
1382         }
1383         allqueue(REDRAWINFO, 0);
1384 }
1385
1386 static uiBlock *info_add_lampmenu(void *arg_unused)
1387 {
1388 /*              static short tog=0; */
1389         uiBlock *block;
1390         short yco= 0;
1391         
1392         block= uiNewBlock(&curarea->uiblocks, "add_lampmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1393         uiBlockSetButmFunc(block, do_info_add_lampmenu, NULL);
1394         
1395         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Lamp|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1396         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Sun|",                           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1397         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Spot|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1398         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hemi|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1399         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Area|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1400         if (G.scene->r.renderer==R_YAFRAY)
1401                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Photon|",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "");
1402         
1403         uiBlockSetDirection(block, UI_RIGHT);
1404         uiTextBoundsBlock(block, 50);
1405                 
1406         return block;
1407 }
1408
1409 static void do_info_add_groupmenu(void *arg, int event)
1410 {
1411         Object *ob;
1412         
1413         add_object_draw(OB_EMPTY);
1414         ob= OBACT;
1415         
1416         ob->dup_group= BLI_findlink(&G.main->group, event);
1417         if(ob->dup_group) {
1418                 id_us_plus((ID *)ob->dup_group);
1419                 ob->transflag |= OB_DUPLIGROUP;
1420                 DAG_scene_sort(G.scene);
1421         }
1422 }
1423
1424
1425 static uiBlock *info_add_groupmenu(void *arg_unused)
1426 {
1427         Group *group;
1428         uiBlock *block;
1429         short yco= 0;
1430         int a;
1431         
1432         block= uiNewBlock(&curarea->uiblocks, "add_groupmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1433         uiBlockSetButmFunc(block, do_info_add_groupmenu, NULL);
1434         
1435         for(a=0, group= G.main->group.first; group; group= group->id.next, a++) {
1436                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, group->id.name+2,                         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, a, "");
1437         }
1438         
1439         uiBlockSetDirection(block, UI_RIGHT);
1440         uiTextBoundsBlock(block, 50);
1441                 
1442         return block;
1443 }
1444
1445 void do_info_addmenu(void *arg, int event)
1446 {
1447         switch(event) {         
1448                 case 0:
1449                         /* Mesh */
1450                         break;
1451                 case 1:
1452                         /* Curve */
1453                         break;
1454                 case 2:
1455                         /* Surface */
1456                         break;
1457                 case 3:
1458                         /* Metaball */
1459                         break;
1460                 case 4:
1461                         /* Text (argument is discarded) */
1462                         add_primitiveFont(event);
1463                         break;
1464                 case 5:
1465                         /* Empty */
1466                         add_object_draw(OB_EMPTY);
1467                         break;
1468                 case 6:
1469                         /* Camera */
1470                         add_object_draw(OB_CAMERA);
1471                         break;
1472                 case 8:
1473                         /* Armature */
1474                         add_primitiveArmature(OB_ARMATURE);
1475                         break;
1476                 case 9:
1477                         /* Lattice */
1478                         add_object_draw(OB_LATTICE);
1479                         break;
1480                 case 10:
1481                         /* group instance not yet */
1482                         break;
1483                 default:
1484                         break;
1485         }
1486         allqueue(REDRAWINFO, 0);
1487 }
1488
1489
1490 static uiBlock *info_addmenu(void *arg_unused)
1491 {
1492 /*              static short tog=0; */
1493         uiBlock *block;
1494         short yco= 0;
1495
1496         block= uiNewBlock(&curarea->uiblocks, "addmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1497         uiBlockSetButmFunc(block, do_info_addmenu, NULL);
1498         
1499         uiDefIconTextBlockBut(block, info_add_meshmenu, NULL, ICON_RIGHTARROW_THIN, "Mesh", 0, yco-=20, 120, 19, "");
1500         uiDefIconTextBlockBut(block, info_add_curvemenu, NULL, ICON_RIGHTARROW_THIN, "Curve", 0, yco-=20, 120, 19, "");
1501         uiDefIconTextBlockBut(block, info_add_surfacemenu, NULL, ICON_RIGHTARROW_THIN, "Surface", 0, yco-=20, 120, 19, "");
1502         uiDefIconTextBlockBut(block, info_add_metamenu, NULL, ICON_RIGHTARROW_THIN, "Meta", 0, yco-=20, 120, 19, "");
1503         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Text",                           0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 4, "");
1504         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Empty",                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 5, "");
1505         
1506         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1507         
1508         uiDefIconTextBlockBut(block, info_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, "");
1509         
1510         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1511         
1512         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Camera",                         0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 6, "");
1513         uiDefIconTextBlockBut(block, info_add_lampmenu, NULL, ICON_RIGHTARROW_THIN, "Lamp", 0, yco-=20, 120, 19, "");
1514         
1515         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1516         
1517         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Armature",                       0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 8, "");
1518         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Lattice",                        0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 9, "");
1519
1520         uiBlockSetDirection(block, UI_DOWN);
1521         uiTextBoundsBlock(block, 80);
1522                 
1523         return block;
1524 }
1525
1526 /************************** GAME *****************************/
1527
1528         
1529 static void do_info_gamemenu(void *arg, int event)
1530 {
1531         switch (event) {
1532         case G_FILE_ENABLE_ALL_FRAMES:
1533         case G_FILE_DIAPLAY_LISTS:
1534         case G_FILE_SHOW_FRAMERATE:
1535         case G_FILE_SHOW_DEBUG_PROPS:
1536         case G_FILE_AUTOPLAY:
1537         case G_FILE_GAME_TO_IPO:
1538         case G_FILE_GAME_MAT:
1539         case G_FILE_SHOW_PHYSICS:
1540                 G.fileflags ^= event;
1541                 break;
1542         default:
1543                 ; /* ignore the rest */
1544         }
1545 }
1546
1547 static uiBlock *info_gamemenu(void *arg_unused)
1548 {
1549 /*              static short tog=0; */
1550         uiBlock *block;
1551         short yco= 0;
1552         short menuwidth=120;
1553         
1554         block= uiNewBlock(&curarea->uiblocks, "gamemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1555         uiBlockSetButmFunc(block, do_info_gamemenu, NULL);
1556         
1557         uiDefIconTextBut(block, BUTM, B_STARTGAME, ICON_BLANK1, "Start Game|P",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
1558         
1559         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 1, 0, "");
1560
1561
1562         if(G.fileflags & G_FILE_ENABLE_ALL_FRAMES) {
1563                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Enable All Frames",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_ENABLE_ALL_FRAMES, "");
1564         } else {
1565                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Enable All Frames",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_ENABLE_ALL_FRAMES, "");
1566         }
1567         
1568         if(G.fileflags & G_FILE_GAME_TO_IPO) {
1569                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Record Game Physics to IPO",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_TO_IPO, "");
1570         } else {
1571
1572         if(G.fileflags & G_FILE_DIAPLAY_LISTS) {
1573                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Generate Display Lists",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_DIAPLAY_LISTS, "");
1574         } else {
1575                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Generate Display Lists",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_DIAPLAY_LISTS, "");
1576         }       
1577                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Record Game Physics to IPO",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_TO_IPO, "");
1578         }
1579         
1580         if(G.fileflags & G_FILE_GAME_MAT) {
1581                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Use Blender Materials",     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_MAT, "");
1582         } else {
1583                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Use Blender Materials",   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_MAT, "");
1584         }       
1585
1586
1587
1588         if(G.fileflags & G_FILE_SHOW_FRAMERATE) {
1589                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Show Framerate and Profile",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_FRAMERATE, "");
1590         } else {
1591                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Show Framerate and Profile",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_FRAMERATE, "");
1592         }
1593
1594
1595         if(G.fileflags & G_FILE_SHOW_PHYSICS) {
1596                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Show Physics Visualization",                0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_PHYSICS, "");
1597         } else {
1598                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Show Physics Visualization",              0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_PHYSICS, "");
1599         }
1600         
1601         if(G.fileflags & G_FILE_SHOW_DEBUG_PROPS) {
1602                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Show Debug Properties",             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_DEBUG_PROPS, "");
1603         } else {
1604                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Show Debug Properties",           0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_DEBUG_PROPS, "");
1605         }
1606         
1607         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 1, 0, "");
1608
1609         if(G.fileflags & G_FILE_AUTOPLAY) {
1610                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Autostart",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_AUTOPLAY, "");
1611         } else {
1612                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Autostart",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_AUTOPLAY, "");
1613         }
1614
1615         uiBlockSetDirection(block, UI_DOWN);
1616         uiTextBoundsBlock(block, 70);
1617         
1618         return block;
1619 }
1620 /************************** TIMELINE *****************************/
1621
1622 static void do_info_timelinemenu(void *arg, int event)
1623 {
1624         /* needed to check for valid selected objects */
1625         Base *base=NULL;
1626         Object *ob=NULL;
1627         //char file[FILE_MAXDIR+FILE_MAXFILE];
1628
1629         base= BASACT;
1630         if (base) ob= base->object;
1631
1632         switch(event) {
1633         case 1:
1634                 /* Show Keyframes */
1635                 if (!ob) error("Select an object before showing its keyframes");
1636                 else set_ob_ipoflags();
1637                 break;
1638         case 2:
1639                 /* Show and select Keyframes */
1640                 if (!ob) error("Select an object before showing and selecting its keyframes");
1641                 else select_select_keys();
1642                         break;
1643                 case 3:
1644                 /* select next keyframe */
1645                 if (!ob) error("Select an object before selecting its next keyframe");
1646                 else nextkey_obipo(1);
1647                         break;
1648                 case 4:
1649                 /* select previous keyframe */
1650                 if (!ob) error("Select an object before selecting its previous keyframe");
1651                 else nextkey_obipo(-1);
1652                 break;
1653                 case 5:
1654                 /* next keyframe */
1655                 if (!ob) error("Select an object before going to its next keyframe");
1656                 else movekey_obipo(1);
1657                         break;
1658                 case 6:
1659                 /* previous keyframe */
1660                 if (!ob) error("Select an object before going to its previous keyframe");
1661                 else movekey_obipo(-1);
1662                 break;
1663         case 7:
1664                 /* next frame */
1665                 CFRA++;
1666                 update_for_newframe();
1667                 break;
1668                 case 8:
1669                 /* previous frame */
1670                 CFRA--;
1671                 if(CFRA<1) CFRA=1;
1672                 update_for_newframe();
1673                 break;
1674         case 9:
1675                 /* forward 10 frames */
1676                 CFRA+= 10;
1677                 update_for_newframe();
1678                 break;
1679         case 10:
1680                 /* back 10 frames */
1681                 CFRA-= 10;
1682                 if(CFRA<1) CFRA=1;
1683                 update_for_newframe();
1684                 break;
1685         case 11:
1686                 /* end frame */
1687                 CFRA= EFRA;
1688                 update_for_newframe();
1689                 break;
1690         case 12:
1691                 /* start frame */
1692                 CFRA= SFRA;
1693                 update_for_newframe();
1694                 break;
1695         }
1696         allqueue(REDRAWINFO, 0);
1697 }
1698
1699 static uiBlock *info_timelinemenu(void *arg_unused)
1700 {
1701 /*              static short tog=0; */
1702         uiBlock *block;
1703         char str[26];
1704         short yco= 0;
1705         short menuwidth=120;
1706
1707         block= uiNewBlock(&curarea->uiblocks, "timelinemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1708         uiBlockSetButmFunc(block, do_info_timelinemenu, NULL);
1709         
1710         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Keyframes|K",               0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1711         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show and Select Keyframes|Shift K",0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
1712         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Next Keyframe|PageUp",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
1713         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Previous Keyframe|PageDown",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
1714
1715         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1716
1717         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Next Keyframe|Ctrl PageUp",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
1718         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Previous Keyframe|Ctrl PageDown",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
1719
1720         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1721
1722         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Next Frame|RightArrow",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
1723         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Previous Frame|LeftArrow",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
1724         
1725         sprintf(str, "Forward %d Frames|UpArrow", G.scene->jumpframe);
1726         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, str,      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
1727         sprintf(str, "Back %d Frames|DownArrow", G.scene->jumpframe);
1728         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, str,      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
1729
1730         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1731
1732         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "End Frame|Shift RightArrow",     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
1733         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Start Frame|Shift LeftArrow",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
1734
1735         uiBlockSetDirection(block, UI_DOWN);
1736         uiTextBoundsBlock(block, 80);
1737
1738         return block;
1739 }
1740
1741 /************************** RENDER *****************************/
1742
1743 void do_info_render_bakemenu(void *arg, int event)
1744 {
1745         switch (event) {
1746         case R_BAKE_TO_ACTIVE:
1747                 G.scene->r.bake_flag ^= event;
1748                 break;
1749         default:
1750                 objects_bake_render(event);
1751         }       
1752         
1753         allqueue(REDRAWINFO, 0);
1754 }
1755
1756 static uiBlock *info_render_bakemenu(void *arg_unused)
1757 {
1758         uiBlock *block;
1759         short yco= 0, menuwidth=160;
1760         
1761         block= uiNewBlock(&curarea->uiblocks, "render_bakemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1762         uiBlockSetButmFunc(block, do_info_render_bakemenu, NULL);
1763         
1764         if(G.scene->r.bake_flag & R_BAKE_TO_ACTIVE) {
1765                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Selected to Active",                0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, R_BAKE_TO_ACTIVE, "");
1766         } else {
1767                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Selected to Active",              0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, R_BAKE_TO_ACTIVE, "");
1768         }
1769         
1770         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1771         
1772         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Full Render|Ctrl Alt B, 1",                              0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1773         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Ambient Occlusion|Ctrl Alt B, 2",                                0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
1774         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Normals|Ctrl Alt B, 3",                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
1775         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Texture Only|Ctrl Alt B, 4",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
1776         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Displacement|Ctrl Alt B, 5",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");   
1777
1778         uiBlockSetDirection(block, UI_RIGHT);
1779         uiTextBoundsBlock(block, 50);
1780                 
1781         return block;
1782 }
1783
1784 static void do_info_rendermenu(void *arg, int event)
1785 {
1786         ScrArea *sa;
1787         extern void playback_anim();
1788
1789         /* events >=10 are registered bpython scripts */
1790         if (event >= 10) {
1791                 if(curarea->spacetype==SPACE_INFO) {
1792                         sa= find_biggest_area_of_type(SPACE_SCRIPT);
1793                         if (!sa) sa= closest_bigger_area();
1794                         areawinset(sa->win);
1795                 }
1796
1797                 BPY_menu_do_python(PYMENU_RENDER, event - 10);
1798                 BIF_undo_push("Rendering Script");
1799         }
1800         else {
1801         switch(event) {
1802                         
1803                 case 0:
1804                         BIF_do_render(0);
1805                         break;
1806                 case 1:
1807                         BIF_do_render(1);
1808                         break;
1809
1810                         /* note: dont use select_area() for setting active areas for opengl render */
1811                         /* its hackish and instable... code here was removed */
1812                 
1813                 case 4:
1814                         BIF_toggle_render_display();
1815                         break;
1816                 case 5:
1817                         playback_anim();
1818                         break;
1819                 case 6:
1820                         /* dodgy hack turning on SHIFT key to do a proper render border select
1821                         set_render_border(); only works when 3d window active
1822                         
1823                         This code copied from toolbox.c, only works when 3d window is cameraview */
1824
1825                         if(select_area(SPACE_VIEW3D)) {
1826                                 mainqenter(LEFTSHIFTKEY, 1);
1827                                 mainqenter(BKEY, 1);
1828                                 mainqenter(BKEY, 0);
1829                                 mainqenter(EXECUTE, 1);
1830                                 mainqenter(LEFTSHIFTKEY, 0);
1831                         }
1832
1833                         break;
1834
1835                 case 7:
1836                         extern_set_butspace(F10KEY, 0);
1837                         break;
1838                 }
1839         }
1840         allqueue(REDRAWINFO, 0);
1841 }
1842
1843 static uiBlock *info_rendermenu(void *arg_unused)
1844 {
1845         uiBlock *block;
1846         BPyMenu *pym;
1847         short yco= 0;
1848         short menuwidth=120;
1849         int i=0;
1850         
1851         block= uiNewBlock(&curarea->uiblocks, "rendermenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1852         uiBlockSetButmFunc(block, do_info_rendermenu, NULL);
1853         
1854         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Render Current Frame|F12",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
1855         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Render Animation|Ctrl F12",              0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1856         
1857         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1858         
1859         uiDefIconTextBlockBut(block, info_render_bakemenu, NULL, ICON_RIGHTARROW_THIN, "Bake Render Meshes", 0, yco-=20, 120, 19, "");
1860
1861         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1862
1863         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Render Buffer|F11",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
1864         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Rendered Animation|Ctrl F11",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
1865
1866         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1867
1868         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Render Border|Shift B",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
1869
1870         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1871
1872         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Render Settings|F10",            0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
1873
1874         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1875
1876         for (pym = BPyMenuTable[PYMENU_RENDER]; pym; pym = pym->next, i++) {
1877                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+10, pym->tooltip?pym->tooltip:pym->filename);
1878         }
1879
1880         uiBlockSetDirection(block, UI_DOWN);
1881         uiTextBoundsBlock(block, 80);
1882
1883         return block;
1884 }
1885
1886 /************************** HELP *****************************/
1887
1888 static void do_info_help_websitesmenu(void *arg, int event)
1889 {
1890         BPY_menu_do_python(PYMENU_HELPWEBSITES, event);
1891
1892         allqueue(REDRAWVIEW3D, 0);
1893 }
1894
1895
1896 static uiBlock *info_help_websitesmenu(void *arg_unused)
1897 {
1898         uiBlock *block;
1899         BPyMenu *pym;
1900         short yco = 20, menuwidth = 120;
1901         int i = 0;
1902
1903         block= uiNewBlock(&curarea->uiblocks, "info_help_websitesmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1904         uiBlockSetButmFunc(block, do_info_help_websitesmenu, NULL);
1905         
1906         for (pym = BPyMenuTable[PYMENU_HELPWEBSITES]; pym; pym = pym->next, i++) {
1907                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i, pym->tooltip?pym->tooltip:pym->filename);
1908         }
1909         
1910         uiBlockSetDirection(block, UI_RIGHT);
1911         uiTextBoundsBlock(block, 60);
1912                 
1913         return block;
1914 }
1915
1916 static void do_info_help_systemmenu(void *arg, int event)
1917 {
1918         /* events >=10 are registered bpython scripts */
1919         if (event >= 10) BPY_menu_do_python(PYMENU_HELPSYSTEM, event - 10);
1920         else {
1921                 switch(event) {
1922
1923                 case 1: /* Benchmark */
1924                         /* dodgy hack turning on CTRL ALT SHIFT key to do a benchmark 
1925                          *      rather than copying lines and lines of code from toets.c :( 
1926                          */
1927         
1928                         if(select_area(SPACE_VIEW3D)) {
1929                                 mainqenter(LEFTSHIFTKEY, 1);
1930                                 mainqenter(LEFTCTRLKEY, 1);
1931                                 mainqenter(LEFTALTKEY, 1);
1932                                 mainqenter(TKEY, 1);
1933                                 mainqenter(TKEY, 0);
1934                                 mainqenter(EXECUTE, 1);
1935                                 mainqenter(LEFTSHIFTKEY, 0);
1936                                 mainqenter(LEFTCTRLKEY, 0);
1937                                 mainqenter(LEFTALTKEY, 0);
1938                         }
1939                         break;
1940                 }
1941         }
1942
1943         allqueue(REDRAWVIEW3D, 0);
1944 }
1945
1946
1947 static uiBlock *info_help_systemmenu(void *arg_unused)
1948 {
1949         uiBlock *block;
1950         BPyMenu *pym;
1951         short yco = 20, menuwidth = 120;
1952         int i = 0;
1953
1954         block= uiNewBlock(&curarea->uiblocks, "info_help_systemmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1955         uiBlockSetButmFunc(block, do_info_help_systemmenu, NULL);
1956         
1957         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Benchmark",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1958         
1959         for (pym = BPyMenuTable[PYMENU_HELPSYSTEM]; pym; pym = pym->next, i++) {
1960                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+10, pym->tooltip?pym->tooltip:pym->filename);
1961         }
1962         
1963         uiBlockSetDirection(block, UI_RIGHT);
1964         uiTextBoundsBlock(block, 60);
1965                 
1966         return block;
1967 }
1968
1969 static void do_info_helpmenu(void *arg, int event)
1970 {
1971         ScrArea *sa;
1972
1973         if(curarea->spacetype==SPACE_INFO) {
1974                 sa= find_biggest_area_of_type(SPACE_SCRIPT);
1975                 if (!sa) sa= closest_bigger_area();
1976                 areawinset(sa->win);
1977         }
1978
1979         /* events >=10 are registered bpython scripts */
1980         if (event >= 10) BPY_menu_do_python(PYMENU_HELP, event - 10);
1981         else {
1982                 switch(event) {
1983                                                                         
1984                 case 0: /* About Blender */
1985                         break;
1986                 }
1987         }
1988
1989         allqueue(REDRAWINFO, 0);
1990 }
1991
1992 static uiBlock *info_helpmenu(void *arg_unused)
1993 {
1994 /*              static short tog=0; */
1995         uiBlock *block;
1996         short yco= 0;
1997         short menuwidth=120;
1998         BPyMenu *pym;
1999         int i = 0;
2000         
2001         block= uiNewBlock(&curarea->uiblocks, "info_helpmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
2002         uiBlockSetButmFunc(block, do_info_helpmenu, NULL);
2003         
2004         uiDefIconTextBut(block, BUTM, B_SHOWSPLASH, ICON_BLANK1, "About Blender...",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
2005         
2006         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2007         
2008         for (pym = BPyMenuTable[PYMENU_HELP]; pym; pym = pym->next, i++) {
2009                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+10, pym->tooltip?pym->tooltip:pym->filename);
2010         }
2011         
2012         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2013         
2014         uiDefIconTextBlockBut(block, info_help_websitesmenu, NULL, ICON_RIGHTARROW_THIN, "Websites", 0, yco-=20, 120, 19, "");
2015         
2016         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2017         
2018         uiDefIconTextBlockBut(block, info_help_systemmenu, NULL, ICON_RIGHTARROW_THIN, "System", 0, yco-=20, 120, 19, "");
2019
2020         uiBlockSetDirection(block, UI_DOWN);
2021         uiTextBoundsBlock(block, 80);
2022
2023         return block;
2024 }
2025
2026 /************************** END MAIN MENU *****************************/
2027 /* ugly global yes, for renderwin.c to write to */
2028 char info_time_str[32]="";
2029
2030 static void info_text(int x, int y)
2031 {
2032         Object *ob= OBACT;
2033         extern float hashvectf[];
2034         extern unsigned long mem_in_use, mmap_in_use;
2035         unsigned int swatch_color;
2036         float fac1, fac2, fac3;
2037         char infostr[300], memstr[64];
2038         char *headerstr, *s;
2039         int hsize;
2040
2041         s= memstr + sprintf(memstr," | Mem:%.2fM ", ((mem_in_use-mmap_in_use)>>10)/1024.0);
2042         if(mmap_in_use)
2043                 sprintf(s,"(%.2fM) ", ((mmap_in_use)>>10)/1024.0);
2044
2045         
2046         if(G.obedit) {
2047                 s = infostr;
2048
2049                 s+= sprintf(s, "%s", G.editModeTitleExtra);
2050                 if(G.obedit->type==OB_MESH) {
2051                         if(G.scene->selectmode & SCE_SELECT_VERTEX)
2052                                 s+= sprintf(s,"Ve:%d-%d | Ed:%d-%d | Fa:%d-%d",
2053                                                 G.totvertsel, G.totvert, G.totedgesel, G.totedge, G.totfacesel, G.totface);
2054                         else if(G.scene->selectmode & SCE_SELECT_EDGE)
2055                                 s+= sprintf(s,"Ed:%d-%d | Fa:%d-%d",
2056                                                 G.totedgesel, G.totedge, G.totfacesel, G.totface);
2057                         else 
2058                                 s+= sprintf(s,"Fa:%d-%d", G.totfacesel, G.totface);
2059                 }
2060                 else if(G.obedit->type==OB_ARMATURE) {
2061                         s+= sprintf(s,"Ve:%d-%d | Bo:%d-%d", G.totvertsel, G.totvert, G.totbonesel, G.totbone);
2062                 }
2063                 else {
2064                         s+= sprintf(s,"Ve:%d-%d", G.totvertsel, G.totvert);
2065                 }
2066
2067                 strcat(s, memstr);
2068         }
2069         else if(ob && (ob->flag & OB_POSEMODE)) {
2070                 sprintf(infostr,"Bo:%d-%d %s",
2071                                         G.totbonesel, G.totbone, memstr);
2072         }
2073         else {
2074                 sprintf(infostr,"Ve:%d | Fa:%d | Ob:%d-%d | La:%d %s | Time:%s | ",
2075                         G.totvert, G.totface, G.totobj, G.totobjsel, G.totlamp, memstr, info_time_str);
2076         }
2077         if(ob) {
2078                 strcat(infostr, ob->id.name+2);
2079         }
2080
2081         if (g_progress_bar && g_progress_info) {
2082                 headerstr= g_progress_info;
2083         } else {
2084                 headerstr= versionstr; 
2085         }
2086
2087         if      (g_progress_bar) {
2088                 hsize = 4 + (138.0 * g_done);
2089                 fac1 = 0.5 * g_done; /* do some rainbow colors on progress */
2090                 fac2 = 1.0;
2091                 fac3 = 0.9;
2092         } else {
2093                 hsize= 30+BIF_GetStringWidth(G.font, headerstr, (U.transopts & USER_TR_BUTTONS));
2094
2095                 /* promise! Never change these lines again! (zr & ton did!) */
2096                 fac1= fabs(hashvectf[ 2*G.version+4]);
2097                 fac2= 0.5+0.1*hashvectf[ G.version+3];
2098                 fac3= 0.7;
2099         }
2100         
2101         swatch_color= hsv_to_cpack(fac1, fac2, fac3);
2102
2103         cpack( swatch_color );
2104         glRecti(x-24,  y-6,  x-30+hsize,        y+14);
2105
2106         glColor3ub(0, 0, 0); /* makes text black colored rect */
2107         
2108         glRasterPos2i(x, y);
2109         BIF_RasterPos(x, y);
2110
2111         BIF_DrawString(G.font, headerstr, (U.transopts & USER_TR_MENUS));
2112         hsize= BIF_GetStringWidth(G.font, headerstr, (U.transopts & USER_TR_BUTTONS));
2113         
2114         BIF_ThemeColor(TH_MENU_TEXT); /* makes text readable on dark theme */
2115         
2116         glRasterPos2i(x+hsize+10,       y);
2117         BIF_RasterPos(x+hsize+10,       y);
2118         
2119         BIF_DrawString(G.font, infostr, (U.transopts & USER_TR_MENUS));
2120 }
2121
2122 void info_buttons(void)
2123 {
2124         uiBlock *block;
2125         short xco= 42;
2126         int xmax;
2127
2128         block= uiNewBlock(&curarea->uiblocks, "header info", UI_EMBOSSN, UI_HELV, curarea->headwin);
2129
2130         if(area_is_active_area(curarea)) uiBlockSetCol(block, TH_HEADER);
2131         else uiBlockSetCol(block, TH_HEADERDESEL);
2132         
2133         if(curarea->flag & HEADER_NO_PULLDOWN) {
2134                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU, ICON_DISCLOSURE_TRI_RIGHT,
2135                                 xco,2,XIC,YIC-2,
2136                                 &(curarea->flag), 0, 0, 0, 0, "Enables display of pulldown menus");
2137         } else {
2138                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU, ICON_DISCLOSURE_TRI_DOWN,
2139                                 xco,2,XIC,YIC-2,
2140                                 &(curarea->flag), 0, 0, 0, 0, "Hides pulldown menus");
2141         }
2142         xco+=XIC;
2143
2144         if((curarea->flag & HEADER_NO_PULLDOWN)==0) {
2145         
2146                 uiBlockSetEmboss(block, UI_EMBOSSP);
2147
2148                 /* the 'xmax - 3' rather than xmax is to prevent some weird flickering where the highlighted
2149                  * menu is drawn wider than it should be. The ypos of -1 is to make it properly fill the
2150                  * height of the header */
2151                 xmax= GetButStringLength("File");
2152                 uiDefPulldownBut(block, info_filemenu, NULL, "File",    xco, -1, xmax-3, 22, "");
2153                 xco+= xmax;
2154
2155                 xmax= GetButStringLength("Add");
2156                 uiDefPulldownBut(block, info_addmenu, NULL, "Add",      xco, -1, xmax-3, 22, "");
2157                 xco+= xmax;
2158
2159                 xmax= GetButStringLength("Timeline");
2160                 uiDefPulldownBut(block, info_timelinemenu, NULL, "Timeline",    xco, -1, xmax-3, 22, "");
2161                 xco+= xmax;
2162
2163                 xmax= GetButStringLength("Game");
2164                 uiDefPulldownBut(block, info_gamemenu, NULL, "Game",    xco, -1, xmax-3, 22, "");
2165                 xco+= xmax;
2166
2167                 xmax= GetButStringLength("Render");
2168                 uiDefPulldownBut(block, info_rendermenu, NULL, "Render",        xco, -1, xmax-3, 22, "");
2169                 xco+= xmax;
2170
2171                 xmax= GetButStringLength("Help");
2172                 uiDefPulldownBut(block, info_helpmenu, NULL, "Help",    xco, -1, xmax-3, 22, "");
2173                 xco+= xmax;
2174
2175         }
2176
2177         /* pack icon indicates a packed file */
2178         
2179         if (G.fileflags & G_AUTOPACK) {
2180                 uiBlockSetEmboss(block, UI_EMBOSSN);
2181                 uiDefIconBut(block, LABEL, 0, ICON_PACKAGE, xco, 0, XIC, YIC, &G.fileflags, 0.0, 0.0, 0, 0, "Indicates this is a Packed file. See File menu.");
2182                 xco += XIC;
2183         }
2184
2185         if (curarea->full == 0) {
2186                 curarea->butspacetype= SPACE_INFO;
2187                 uiBlockSetEmboss(block, UI_EMBOSS);
2188                 uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 8,0,XIC+10,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
2189                 
2190                 /* STD SCREEN BUTTONS */
2191                 xco= std_libbuttons(block, xco, 0, 0, NULL, B_INFOSCR, ID_SCR, 0, (ID *)G.curscreen, 0, &G.curscreen->screennr, 1, 1, B_INFODELSCR, 0, 0);
2192                 
2193                 xco +=8;
2194         
2195                 /* STD SCENE BUTTONS */
2196                 xco= std_libbuttons(block, xco, 0, 0, NULL, B_INFOSCE, ID_SCE, 0, (ID *)G.scene, 0, &G.curscreen->scenenr, 1, 1, B_INFODELSCE, 0, 0);
2197         }
2198         else xco= 430;
2199         
2200 BIF_SetScale(block->aspect);
2201         info_text(xco+24, 6);
2202         
2203         uiBlockSetEmboss(block, UI_EMBOSSN);
2204         uiDefIconBut(block, BUT, B_SHOWSPLASH, ICON_BLENDER, xco+2, 0,XIC,YIC, 0, 0, 0, 0, 0, "Click to display Splash Screen");
2205
2206         /* always do as last */
2207         curarea->headbutlen= xco+2*XIC;
2208
2209 #if 0
2210 // #ifdef _WIN32        // FULLSCREEN
2211         if(U.uiflag & USER_FLIPFULLSCREEN) {
2212                 uiDefIconBut(block, BUT, B_FLIPFULLSCREEN, ICON_WINDOW_WINDOW,
2213                                 (short)(curarea->winx-XIC-5), 0,XIC,YIC,
2214                                 0, 0, 0, 0, 0, "Toggles Blender to fullscreen mode");/* dir             */
2215         } else {
2216                 uiDefIconBut(block, BUT, B_FLIPFULLSCREEN, ICON_WINDOW_FULLSCREEN,
2217                                 (short)(curarea->winx-XIC-5), 0,XIC,YIC,
2218                                 0, 0, 0, 0, 0, "Toggles Blender to fullscreen mode");/* dir             */
2219         }
2220 #endif
2221         
2222         uiDrawBlock(block);
2223 }