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