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