-fixed bug; ALT+LeftMouse emulates MiddleMouse again.
[blender.git] / source / blender / src / space.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  *
32  *
33  * - here initialize and free and handling SPACE data
34  */
35
36 #include <string.h>
37 #include <stdio.h>
38
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
42
43 #ifdef WIN32
44 #include "BLI_winstuff.h"
45 #endif
46
47 #include "MEM_guardedalloc.h"
48
49 #ifdef INTERNATIONAL
50 #include "BIF_language.h"
51 #endif
52
53 #include "IMB_imbuf_types.h"
54 #include "IMB_imbuf.h"
55
56 #include "BLI_blenlib.h"
57 #include "BLI_arithb.h"
58 #include "BLI_editVert.h"
59 #include "BLI_linklist.h"
60
61 #include "DNA_action_types.h"
62 #include "DNA_curve_types.h"
63 #include "DNA_image_types.h"
64 #include "DNA_ipo_types.h"
65 #include "DNA_mesh_types.h"
66 #include "DNA_object_types.h"
67 #include "DNA_scene_types.h"
68 #include "DNA_screen_types.h"
69 #include "DNA_sequence_types.h"
70 #include "DNA_sound_types.h"
71 #include "DNA_space_types.h"
72 #include "DNA_userdef_types.h"
73 #include "DNA_view2d_types.h"
74 #include "DNA_view3d_types.h"
75
76 #include "BKE_blender.h"
77 #include "BKE_curve.h"
78 #include "BKE_displist.h"
79 #include "BKE_global.h"
80 #include "BKE_ipo.h"
81 #include "BKE_main.h"
82 #include "BKE_scene.h"
83 #include "BKE_utildefines.h"
84
85 #include "BIF_butspace.h"
86 #include "BIF_drawimage.h"
87 #include "BIF_drawseq.h"
88 #include "BIF_drawtext.h"
89 #include "BIF_editarmature.h"
90 #include "BIF_editfont.h"
91 #include "BIF_editika.h"
92 #include "BIF_editkey.h"
93 #include "BIF_editlattice.h"
94 #include "BIF_editmesh.h"
95 #include "BIF_editoops.h"
96 #include "BIF_editseq.h"
97 #include "BIF_editsima.h"
98 #include "BIF_editsound.h"
99 #include "BIF_editview.h"
100 #include "BIF_gl.h"
101 #include "BIF_imasel.h"
102 #include "BIF_interface.h"
103 #include "BIF_mywindow.h"
104 #include "BIF_oops.h"
105 #include "BIF_resources.h"
106 #include "BIF_screen.h"
107 #include "BIF_space.h"
108 #include "BIF_spacetypes.h"
109 #include "BIF_toets.h"
110 #include "BIF_toolbox.h"
111 #include "BIF_usiblender.h"
112 #include "BIF_previewrender.h"
113
114 #include "BSE_edit.h"
115 #include "BSE_view.h"
116 #include "BSE_editipo.h"
117 #include "BSE_drawipo.h"
118 #include "BSE_drawview.h"
119 #include "BSE_drawnla.h"
120 #include "BSE_filesel.h"
121 #include "BSE_headerbuttons.h"
122 #include "BSE_editnla_types.h"
123
124 #include "BDR_vpaint.h"
125 #include "BDR_editmball.h"
126 #include "BDR_editobject.h"
127 #include "BDR_editcurve.h"
128 #include "BDR_editface.h"
129 #include "BDR_drawmesh.h"
130 #include "BDR_drawobject.h"
131
132 #include "BLO_readfile.h" /* for BLO_blendhandle_close */
133
134 #include "mydevice.h"
135 #include "blendef.h"
136 #include "datatoc.h"
137
138 #include "BPY_extern.h" // Blender Python library
139
140 #include "TPT_DependKludge.h"
141 #ifdef NAN_TPT
142 #include "BSE_trans_types.h"
143 #include "IMG_Api.h"
144 #endif /* NAN_TPT */
145
146 #include "SYS_System.h" /* for the user def menu ... should move elsewhere. */
147
148 extern void StartKetsjiShell(ScrArea *area, char* startscenename, struct Main* maggie, int always_use_expand_framing);
149
150 /**
151  * When the mipmap setting changes, we want to redraw the view right
152  * away to reflect this setting.
153  */
154 void space_mipmap_button_function(int event);
155
156
157 unsigned short convert_for_nonumpad(unsigned short event);
158 void free_soundspace(SpaceSound *ssound);
159
160 /* *************************************** */
161
162 /* don't know yet how the handlers will evolve, for simplicity
163    i choose for an array with eventcodes, this saves in a file!
164    */
165 void add_blockhandler(ScrArea *sa, short eventcode, short val)
166 {
167         SpaceLink *sl= sa->spacedata.first;
168         short a;
169         
170         // find empty spot
171         for(a=0; a<SPACE_MAXHANDLER; a+=2) {
172                 if( sl->blockhandler[a]==eventcode ) {
173                         sl->blockhandler[a+1]= val;
174                         break;
175                 }
176                 else if( sl->blockhandler[a]==0) {
177                         sl->blockhandler[a]= eventcode;
178                         sl->blockhandler[a+1]= val;
179                         break;
180                 }
181         }
182         if(a==SPACE_MAXHANDLER) printf("error; max (4) blockhandlers reached!\n");
183 }
184
185 void rem_blockhandler(ScrArea *sa, short eventcode)
186 {
187         SpaceLink *sl= sa->spacedata.first;
188         short a;
189         
190         for(a=0; a<SPACE_MAXHANDLER; a+=2) {
191                 if( sl->blockhandler[a]==eventcode) {
192                         sl->blockhandler[a]= 0;
193                         break;
194                 }
195         }
196 }
197
198
199
200
201 /* ************* SPACE: VIEW3D  ************* */
202
203 /*  extern void drawview3dspace(ScrArea *sa, void *spacedata); BSE_drawview.h */
204
205
206 void copy_view3d_lock(short val)
207 {
208         bScreen *sc;
209         int bit;
210         
211         /* from G.scene copy to the other views */
212         sc= G.main->screen.first;
213         
214         while(sc) {
215                 if(sc->scene==G.scene) {
216                         ScrArea *sa= sc->areabase.first;
217                         while(sa) {
218                                 SpaceLink *sl= sa->spacedata.first;
219                                 while(sl) {
220                                         if(sl->spacetype==SPACE_OOPS && val==REDRAW) {
221                                                 if(sa->win) scrarea_queue_winredraw(sa);
222                                         }
223                                         else if(sl->spacetype==SPACE_VIEW3D) {
224                                                 View3D *vd= (View3D*) sl;
225                                                 if(vd->scenelock && vd->localview==0) {
226                                                         vd->lay= G.scene->lay;
227                                                         vd->camera= G.scene->camera;
228                                                         
229                                                         if(vd->camera==0 && vd->persp>1) vd->persp= 1;
230                                                         
231                                                         if( (vd->lay & vd->layact) == 0) {
232                                                                 bit= 0;
233                                                                 while(bit<32) {
234                                                                         if(vd->lay & (1<<bit)) {
235                                                                                 vd->layact= 1<<bit;
236                                                                                 break;
237                                                                         }
238                                                                         bit++;
239                                                                 }
240                                                         }
241                                                         
242                                                         if(val==REDRAW && vd==sa->spacedata.first) {
243                                                                 if(sa->win) scrarea_queue_redraw(sa);
244                                                         }
245                                                 }
246                                         }
247                                         sl= sl->next;
248                                 }
249                                 sa= sa->next;
250                         }
251                 }
252                 sc= sc->id.next;
253         }
254 }
255
256 void handle_view3d_lock()
257 {
258         if (G.vd != NULL) {
259                 if(G.vd->localview==0 && G.vd->scenelock && curarea->spacetype==SPACE_VIEW3D) {
260
261                         /* copy to scene */
262                         G.scene->lay= G.vd->lay;
263                         G.scene->camera= G.vd->camera;
264         
265                         copy_view3d_lock(REDRAW);
266                 }
267         }
268 }
269
270 void space_set_commmandline_options(void) {
271         SYS_SystemHandle syshandle;
272         int a;
273                 
274         if ( (syshandle = SYS_GetSystem()) ) {
275                 /* User defined settings */
276                 a= (U.gameflags & USERDEF_VERTEX_ARRAYS);
277                 SYS_WriteCommandLineInt(syshandle, "vertexarrays", a);
278
279                 a= (U.gameflags & USERDEF_DISABLE_SOUND);
280                 SYS_WriteCommandLineInt(syshandle, "noaudio", a);
281
282                 a= (U.gameflags & USERDEF_DISABLE_MIPMAP);
283                 set_mipmap(!a);
284                 SYS_WriteCommandLineInt(syshandle, "nomipmap", a);
285
286                 /* File specific settings: */
287                 /* Only test the first one. These two are switched
288                  * simultaneously. */
289                 a= (G.fileflags & G_FILE_SHOW_FRAMERATE);
290                 SYS_WriteCommandLineInt(syshandle, "show_framerate", a);
291                 SYS_WriteCommandLineInt(syshandle, "show_profile", a);
292
293                 /* When in wireframe mode, always draw debug props. */
294                 if (G.vd) {
295                         a = ( (G.fileflags & G_FILE_SHOW_DEBUG_PROPS) 
296                                   || (G.vd->drawtype == OB_WIRE)          
297                                   || (G.vd->drawtype == OB_SOLID)         );
298                         SYS_WriteCommandLineInt(syshandle, "show_properties", a);
299                 }
300
301                 a= (G.fileflags & G_FILE_ENABLE_ALL_FRAMES);
302                 SYS_WriteCommandLineInt(syshandle, "fixedtime", a);
303         }
304 }
305
306 #if GAMEBLENDER == 1
307         /**
308          * These two routines imported from the gameengine, 
309          * I suspect a lot of the resetting stuff is cruft
310          * and can be removed, but it should be checked.
311          */
312 static void SaveState(void)
313 {
314         glPushAttrib(GL_ALL_ATTRIB_BITS);
315
316         init_realtime_GL();
317         init_gl_stuff();
318
319         if(G.scene->camera==0 || G.scene->camera->type!=OB_CAMERA)
320                 error("no (correct) camera");
321
322         waitcursor(1);
323 }
324
325 static void RestoreState(void)
326 {
327         curarea->win_swap = 0;
328         curarea->head_swap=0;
329         allqueue(REDRAWVIEW3D, 0);
330         allqueue(REDRAWBUTSALL, 0);
331         reset_slowparents();
332         waitcursor(0);
333         G.qual= 0;
334         glPopAttrib();
335 }
336
337 static LinkNode *save_and_reset_all_scene_cfra(void)
338 {
339         LinkNode *storelist= NULL;
340         Scene *sc;
341         
342         for (sc= G.main->scene.first; sc; sc= sc->id.next) {
343                 BLI_linklist_prepend(&storelist, (void*) (long) sc->r.cfra);
344                 sc->r.cfra= 1;
345
346                 set_scene_bg(sc);
347         }
348         
349         BLI_linklist_reverse(&storelist);
350         
351         return storelist;
352 }
353
354 static void restore_all_scene_cfra(LinkNode *storelist) {
355         LinkNode *sc_store= storelist;
356         Scene *sc;
357         
358         for (sc= G.main->scene.first; sc; sc= sc->id.next) {
359                 int stored_cfra= (int) sc_store->link;
360                 
361                 sc->r.cfra= stored_cfra;
362                 set_scene_bg(sc);
363                 
364                 sc_store= sc_store->next;
365         }
366         
367         BLI_linklist_free(storelist, NULL);
368 }
369 #endif
370
371 void start_game(void)
372 {
373 #if GAMEBLENDER == 1
374         Scene *sc, *startscene = G.scene;
375         LinkNode *scene_cfra_store;
376
377                 /* XXX, silly code -  the game engine can
378                  * access any scene through logic, so we try 
379                  * to make sure each scene has a valid camera, 
380                  * just in case the game engine tries to use it.
381                  * 
382                  * Better would be to make a better routine
383                  * in the game engine for finding the camera.
384                  *  - zr
385                  */
386         for (sc= G.main->scene.first; sc; sc= sc->id.next) {
387                 if (!sc->camera) {
388                         Base *base;
389         
390                         for (base= sc->base.first; base; base= base->next)
391                                 if (base->object->type==OB_CAMERA)
392                                         break;
393                         
394                         sc->camera= base?base->object:NULL;
395                 }
396         }
397
398         /* these two lines make sure front and backbuffer are equal. for swapbuffers */
399         markdirty_all();
400         screen_swapbuffers();
401
402         /* can start from header */
403         mywinset(curarea->win);
404     
405         scene_cfra_store= save_and_reset_all_scene_cfra();
406         
407         BPY_end_python();
408
409         sound_stop_all_sounds();
410
411         /* Before jumping into Ketsji, we configure some settings. */
412         space_set_commmandline_options();
413
414         SaveState();
415         StartKetsjiShell(curarea, startscene->id.name+2, G.main, 1);
416         RestoreState();
417
418         BPY_start_python();
419
420         restore_all_scene_cfra(scene_cfra_store);
421         set_scene_bg(startscene);
422         
423         if (G.flags & G_FLAGS_AUTOPLAY)
424                 exit_usiblender();
425
426                 /* groups could have changed ipo */
427         allqueue(REDRAWNLA, 0);
428         allqueue(REDRAWACTION, 0);
429         allspace(REMAKEIPO, 0);
430         allqueue(REDRAWIPO, 0);
431 #else
432         notice("Game engine is disabled in this release!");
433 #endif
434 }
435
436 static void changeview3dspace(ScrArea *sa, void *spacedata)
437 {
438         setwinmatrixview3d(0);  /* 0= no pick rect */
439 }
440
441         /* Callable from editmode and faceselect mode from the
442          * moment, would be nice (and is easy) to generalize
443          * to any mode.
444          */
445 static void align_view_to_selected(View3D *v3d)
446 {
447         int nr= pupmenu("Align view%t|To selection (top)%x2|To selection (front)%x1|To selection (side)%x0");
448
449         if (nr!=-1) {
450                 int axis= nr;
451
452                 if ((G.obedit) && (G.obedit->type == OB_MESH)) {
453                         editmesh_align_view_to_selected(v3d, axis);
454                         addqueue(v3d->area->win, REDRAW, 1);
455                 } else if (G.f & G_FACESELECT) {
456                         Object *obact= OBACT;
457                         if (obact && obact->type==OB_MESH) {
458                                 Mesh *me= obact->data;
459
460                                 if (me->tface) {
461                                         faceselect_align_view_to_selected(v3d, me, axis);
462                                         addqueue(v3d->area->win, REDRAW, 1);
463                                 }
464                         }
465                 }
466         }
467 }
468
469 void select_children(Object *ob, int recursive)
470 {
471         Base *base;
472
473         for (base= FIRSTBASE; base; base= base->next)
474                 if (ob == base->object->parent) {
475                         base->flag |= SELECT;
476                         base->object->flag |= SELECT;
477                         if (recursive) select_children(base->object, 1);
478                 }
479 }
480
481 void select_parent(void)        /* Makes parent active and de-selected OBACT */
482 {
483         Base *base, *startbase, *basact=NULL, *oldbasact;
484
485         if (!(OBACT->parent)) return;
486         BASACT->flag &= (~SELECT);
487         BASACT->object->flag &= (~SELECT);
488         startbase=  FIRSTBASE;
489         if(BASACT && BASACT->next) startbase= BASACT->next;
490         base = startbase;
491         while(base) {
492                 if(base->object==BASACT->object->parent) { basact=base; break; }
493                 base=base->next;
494                 if(base==0) base= FIRSTBASE;
495                 if(base==startbase) break;
496         }
497         oldbasact = BASACT;
498         BASACT = basact;
499         basact->flag |= SELECT;         
500         if(oldbasact) if(oldbasact != basact) draw_object_ext(oldbasact);
501         basact->object->flag= basact->flag;
502         draw_object_ext(basact);
503         set_active_base(basact);
504 }
505
506 void group_menu(void)
507 {
508         Base *base;
509         short nr;
510         char *str;
511
512         /* make menu string */
513         
514         str= MEM_mallocN(160, "groupmenu");
515         strcpy(str, "Group selection%t|Children%x1|"
516                     "Immediate children%x2|Parent%x3|"
517                     "Objects on shared layers%x4");
518
519         /* here we go */
520         
521         nr= pupmenu(str);
522         MEM_freeN(str);
523
524         if(nr==4) {
525                 base= FIRSTBASE;
526                 while(base) {
527                         if (base->lay & OBACT->lay) {
528                                 base->flag |= SELECT;
529                                 base->object->flag |= SELECT;
530                         }
531                         base= base->next;
532                 }               
533         }
534         else if(nr==2) select_children(OBACT, 0);
535         else if(nr==1) select_children(OBACT, 1);
536         else if(nr==3) select_parent();
537         
538         allqueue(REDRAWVIEW3D, 0);
539         allqueue(REDRAWBUTSOBJECT, 0);
540         allspace(REMAKEIPO, 0);
541         allqueue(REDRAWIPO, 0);
542 }
543
544 void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
545 {
546         unsigned short event= evt->event;
547         short val= evt->val;
548         char ascii= evt->ascii;
549         View3D *v3d= curarea->spacedata.first;
550         Object *ob;
551         float *curs;
552         int doredraw= 0, pupval;
553         
554         if(curarea->win==0) return;     /* when it comes from sa->headqread() */
555         
556         
557         if(val) {
558
559                 if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
560                 if(event==MOUSEY) return;
561                 
562                 if(event==UI_BUT_EVENT) do_butspace(val); // temporal, view3d deserves own queue?
563
564                 
565                 /* TEXTEDITING?? */
566                 if((G.obedit) && G.obedit->type==OB_FONT) {
567                         switch(event) {
568                         
569                         case LEFTMOUSE:
570                                 mouse_cursor();
571                                 break;
572                         case MIDDLEMOUSE:
573                                 /* use '&' here, because of alt+leftmouse which emulates middlemouse */
574                                 if(U.flag & VIEWMOVE) {
575                                         if((G.qual & LR_SHIFTKEY))
576                                                 viewmove(0);
577                                         else if(G.qual & LR_CTRLKEY)
578                                                 viewmove(2);
579                                         else
580                                                 viewmove(1);
581                                 }
582                                 else {
583                                         if((G.qual & LR_SHIFTKEY))
584                                                 viewmove(1);
585                                         else if(G.qual & LR_CTRLKEY)
586                                                 viewmove(2);
587                                         else
588                                                 viewmove(0);
589                                 }
590                                 break;
591                                 
592                         case WHEELUPMOUSE:
593                                 /* Regular:   Zoom in */
594                                 /* Shift:     Scroll up */
595                                 /* Ctrl:      Scroll right */
596                                 /* Alt-Shift: Rotate up */
597                                 /* Alt-Ctrl:  Rotate right */
598
599                                 if( G.qual & LR_SHIFTKEY ) {
600                                         if( G.qual & LR_ALTKEY ) { 
601                                                 G.qual &= ~LR_SHIFTKEY;
602                                                 persptoetsen(PAD2);
603                                                 G.qual |= LR_SHIFTKEY;
604                                         } else {
605                                                 persptoetsen(PAD2);
606                                         }
607                                 } else if( G.qual & LR_CTRLKEY ) {
608                                         if( G.qual & LR_ALTKEY ) { 
609                                                 G.qual &= ~LR_CTRLKEY;
610                                                 persptoetsen(PAD4);
611                                                 G.qual |= LR_CTRLKEY;
612                                         } else {
613                                                 persptoetsen(PAD4);
614                                         }
615                                 } else if(U.uiflag & WHEELZOOMDIR) 
616                                         persptoetsen(PADMINUS);
617                                 else
618                                         persptoetsen(PADPLUSKEY);
619
620                                 doredraw= 1;
621                                 break;
622
623                         case WHEELDOWNMOUSE:
624                                 /* Regular:   Zoom out */
625                                 /* Shift:     Scroll down */
626                                 /* Ctrl:      Scroll left */
627                                 /* Alt-Shift: Rotate down */
628                                 /* Alt-Ctrl:  Rotate left */
629
630                                 if( G.qual & LR_SHIFTKEY ) {
631                                         if( G.qual & LR_ALTKEY ) { 
632                                                 G.qual &= ~LR_SHIFTKEY;
633                                                 persptoetsen(PAD8);
634                                                 G.qual |= LR_SHIFTKEY;
635                                         } else {
636                                                 persptoetsen(PAD8);
637                                         }
638                                 } else if( G.qual & LR_CTRLKEY ) {
639                                         if( G.qual & LR_ALTKEY ) { 
640                                                 G.qual &= ~LR_CTRLKEY;
641                                                 persptoetsen(PAD6);
642                                                 G.qual |= LR_CTRLKEY;
643                                         } else {
644                                                 persptoetsen(PAD6);
645                                         }
646                                 } else if(U.uiflag & WHEELZOOMDIR) 
647                                         persptoetsen(PADPLUSKEY);
648                                 else
649                                         persptoetsen(PADMINUS);
650                                 
651                                 doredraw= 1;
652                                 break;
653
654                         case UKEY:
655                                 if(G.qual==LR_ALTKEY) {
656                                         remake_editText();
657                                         doredraw= 1;
658                                 } 
659                                 else {
660                                         do_textedit(event, val, ascii);
661                                 }
662                                 break;
663                         case VKEY:
664                                 if(G.qual==LR_ALTKEY) {
665                                         paste_editText();
666                                         doredraw= 1;
667                                 } 
668                                 else {
669                                         do_textedit(event, val, ascii);
670                                 }
671                                 break;
672                         case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
673                         case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
674                         case PADENTER:
675                                 persptoetsen(event);
676                                 doredraw= 1;
677                                 break;
678                                 
679                         default:
680                                 do_textedit(event, val, ascii);
681                                 break;
682                         }
683                 }
684                 else {
685                         switch(event) {
686                         
687                         case BACKBUFDRAW:
688                                 backdrawview3d(1);
689                                 break;
690                                 
691                         case LEFTMOUSE:
692                                 if ((G.obedit) || !(G.f&(G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) {
693                                         mouse_cursor();
694                                 }
695                                 else if (G.f & G_VERTEXPAINT) {
696                                         vertex_paint();
697                                 }
698                                 else if (G.f & G_WEIGHTPAINT){
699                                         weight_paint();
700                                 }
701                                 else if (G.f & G_TEXTUREPAINT) {
702                                         face_draw();
703                                 }
704                                 break;
705                         case MIDDLEMOUSE:
706                                 /* use '&' here, because of alt+leftmouse which emulates middlemouse */
707                                 if(U.flag & VIEWMOVE) {
708                                         if((G.qual & LR_SHIFTKEY))
709                                                 viewmove(0);
710                                         else if(G.qual & LR_CTRLKEY)
711                                                 viewmove(2);
712                                         else
713                                                 viewmove(1);
714                                 }
715                                 else {
716                                         if((G.qual & LR_SHIFTKEY))
717                                                 viewmove(1);
718                                         else if(G.qual & LR_CTRLKEY)
719                                                 viewmove(2);
720                                         else
721                                                 viewmove(0);
722                                 }
723                                 break;
724                         case RIGHTMOUSE:
725                                 if((G.obedit) && (G.qual & LR_CTRLKEY)==0) {
726                                         if(G.obedit->type==OB_MESH)
727                                                 mouse_mesh();
728                                         else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
729                                                 mouse_nurb();
730                                         else if(G.obedit->type==OB_MBALL)
731                                                 mouse_mball();
732                                         else if(G.obedit->type==OB_LATTICE)
733                                                 mouse_lattice();
734                                         else if(G.obedit->type==OB_ARMATURE)
735                                                 mouse_armature();
736                                 }
737                                 else if((G.obedit) && (G.qual & (LR_CTRLKEY|LR_ALTKEY)))
738                                         mouse_mesh();
739                                 else if(G.obpose) { 
740                                         if (G.obpose->type==OB_ARMATURE)
741                                                 mousepose_armature();
742                                 }
743                                 else if(G.qual==LR_CTRLKEY)
744                                         mouse_select();
745                                 else if(G.f & G_FACESELECT)
746                                         face_select();
747                                 else if( G.f & (G_VERTEXPAINT|G_TEXTUREPAINT))
748                                         sample_vpaint();
749                                 else
750                                         mouse_select();
751                                 break;
752
753                         case WHEELUPMOUSE:
754                                 /* Regular:   Zoom in */
755                                 /* Shift:     Scroll up */
756                                 /* Ctrl:      Scroll right */
757                                 /* Alt-Shift: Rotate up */
758                                 /* Alt-Ctrl:  Rotate right */
759
760                                 if( G.qual & LR_SHIFTKEY ) {
761                                         if( G.qual & LR_ALTKEY ) { 
762                                                 G.qual &= ~LR_SHIFTKEY;
763                                                 persptoetsen(PAD2);
764                                                 G.qual |= LR_SHIFTKEY;
765                                         } else {
766                                                 persptoetsen(PAD2);
767                                         }
768                                 } else if( G.qual & LR_CTRLKEY ) {
769                                         if( G.qual & LR_ALTKEY ) { 
770                                                 G.qual &= ~LR_CTRLKEY;
771                                                 persptoetsen(PAD4);
772                                                 G.qual |= LR_CTRLKEY;
773                                         } else {
774                                                 persptoetsen(PAD4);
775                                         }
776                                 } else if(U.uiflag & WHEELZOOMDIR) 
777                                         persptoetsen(PADMINUS);
778                                 else
779                                         persptoetsen(PADPLUSKEY);
780
781                                 doredraw= 1;
782                                 break;
783                         case WHEELDOWNMOUSE:
784                                 /* Regular:   Zoom out */
785                                 /* Shift:     Scroll down */
786                                 /* Ctrl:      Scroll left */
787                                 /* Alt-Shift: Rotate down */
788                                 /* Alt-Ctrl:  Rotate left */
789
790                                 if( G.qual & LR_SHIFTKEY ) {
791                                         if( G.qual & LR_ALTKEY ) { 
792                                                 G.qual &= ~LR_SHIFTKEY;
793                                                 persptoetsen(PAD8);
794                                                 G.qual |= LR_SHIFTKEY;
795                                         } else {
796                                                 persptoetsen(PAD8);
797                                         }
798                                 } else if( G.qual & LR_CTRLKEY ) {
799                                         if( G.qual & LR_ALTKEY ) { 
800                                                 G.qual &= ~LR_CTRLKEY;
801                                                 persptoetsen(PAD6);
802                                                 G.qual |= LR_CTRLKEY;
803                                         } else {
804                                                 persptoetsen(PAD6);
805                                         }
806                                 } else if(U.uiflag & WHEELZOOMDIR) 
807                                         persptoetsen(PADPLUSKEY);
808                                 else
809                                         persptoetsen(PADMINUS);
810                                 
811                                 doredraw= 1;
812                                 break;
813                         
814                         case ONEKEY:
815                                 ob= OBACT;
816                                 if(G.qual==LR_CTRLKEY) {
817                                         if(G.obedit) {
818                                                         flip_subdivison(G.obedit, 1);
819                                         }
820                                         else if(ob->type == OB_MESH) {
821                                                 flip_subdivison(ob, 1);
822                                         }
823                                 }
824                                 else
825                                         do_layer_buttons(0); break;
826                         case TWOKEY:
827                                 ob= OBACT;
828                                 if(G.qual==LR_CTRLKEY) {
829                                         if(G.obedit) {
830                                                         flip_subdivison(G.obedit, 2);
831                                         }
832                                         else if(ob->type == OB_MESH) {
833                                                 flip_subdivison(ob, 2);
834                                         }
835                                 }
836                                 else
837                                         do_layer_buttons(1); 
838                                 break;
839                         case THREEKEY:
840                                 ob= OBACT;
841                                 if(G.qual==LR_CTRLKEY) {
842                                         if(G.obedit) {
843                                                         flip_subdivison(G.obedit, 3);
844                                         }
845                                         else if(ob->type == OB_MESH) {
846                                                 flip_subdivison(ob, 3);
847                                         }
848                                 }
849                                 else
850                                         do_layer_buttons(2); break;
851                         case FOURKEY:
852                                 ob= OBACT;
853                                 if(G.qual & LR_CTRLKEY) {
854                                         if(G.obedit) {
855                                                         flip_subdivison(G.obedit, 4);
856                                         }
857                                         else if(ob->type == OB_MESH) {
858                                                 flip_subdivison(ob, 4);
859                                         }
860                                 }
861                                 else
862                                 do_layer_buttons(3); break;
863                         case FIVEKEY:
864                                 do_layer_buttons(4); break;
865                         case SIXKEY:
866                                 do_layer_buttons(5); break;
867                         case SEVENKEY:
868                                 do_layer_buttons(6); break;
869                         case EIGHTKEY:
870                                 do_layer_buttons(7); break;
871                         case NINEKEY:
872                                 do_layer_buttons(8); break;
873                         case ZEROKEY:
874                                 do_layer_buttons(9); break;
875                         case MINUSKEY:
876                                 do_layer_buttons(10); break;
877                         case EQUALKEY:
878                                 do_layer_buttons(11); break;
879                         case ACCENTGRAVEKEY:
880                                 do_layer_buttons(-1); break;
881                                 
882                         case AKEY:
883                                 if(G.qual & LR_CTRLKEY) apply_object(); // also with shift!
884                                 else if((G.qual==LR_SHIFTKEY)) {
885                                         toolbox_n_add();
886                                 }
887                                 else {
888                                         if(G.obedit) {
889                                                 if(G.obedit->type==OB_MESH)
890                                                         deselectall_mesh();
891                                                 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
892                                                         deselectall_nurb();
893                                                 else if(G.obedit->type==OB_MBALL)
894                                                         deselectall_mball();
895                                                 else if(G.obedit->type==OB_LATTICE)
896                                                         deselectall_Latt();
897                                                 else if(G.obedit->type==OB_ARMATURE)
898                                                         deselectall_armature();
899                                         }
900                                         else if (G.obpose){
901                                                 switch (G.obpose->type){
902                                                 case OB_ARMATURE:
903                                                         deselectall_posearmature(1);
904                                                         break;
905                                                 }
906                                         }
907                                         else {
908                                                 if(G.f & G_FACESELECT) deselectall_tface();
909                                                 else {
910                                                         /* by design, the center of the active object 
911                                                          * (which need not necessarily by selected) will
912                                                          * still be drawn as if it were selected.
913                                                          */
914                                                         deselectall();
915                                                 }
916                                         }
917                                 }
918                                 break;
919                         case BKEY:
920                                 if((G.qual==LR_SHIFTKEY))
921                                         set_render_border();
922                                 else if((G.qual==0))
923                                         borderselect();
924                                 break;
925                         case CKEY:
926                                 if(G.qual==LR_CTRLKEY) {
927                                         copymenu();
928                                 }
929                                 else if(G.qual==LR_ALTKEY) {
930                                         convertmenu();  /* editobject.c */
931                                 }
932                                 else if((G.qual==LR_SHIFTKEY)) {
933                                         view3d_home(1);
934                                         curs= give_cursor();
935                                         curs[0]=curs[1]=curs[2]= 0.0;
936                                         allqueue(REDRAWVIEW3D, 0);
937                                 }
938                                 else if((G.obedit) && ELEM(G.obedit->type, OB_CURVE, OB_SURF) ) {
939                                         makecyclicNurb();
940                                         makeDispList(G.obedit);
941                                         allqueue(REDRAWVIEW3D, 0);
942                                 }
943                                 else if((G.qual==0)){
944                                         curs= give_cursor();
945                                         G.vd->ofs[0]= -curs[0];
946                                         G.vd->ofs[1]= -curs[1];
947                                         G.vd->ofs[2]= -curs[2];
948                                         scrarea_queue_winredraw(curarea);
949                                 }
950                         
951                                 break;
952                         case DKEY:
953                                 if((G.qual==LR_SHIFTKEY)) {
954                                         duplicate_context_selected();
955                                 }
956                                 else if(G.qual==LR_ALTKEY) {
957                                         if(G.obpose)
958                                                 error ("Duplicate not possible in posemode.");
959                                         else if((G.obedit==0))
960                                                 adduplicate(0);
961                                 }
962                                 else if(G.qual==LR_CTRLKEY) {
963                                         imagestodisplist();
964                                 }
965                                 else if((G.qual==0)){
966                                         pupval= pupmenu("Draw mode%t|BoundBox %x1|Wire %x2|OpenGL Solid %x3|Shaded Solid %x4|Textured Solid %x5");
967                                         if(pupval>0) {
968                                                 G.vd->drawtype= pupval;
969                                                 doredraw= 1;
970                                         
971                                         }
972                                 }
973                                 
974                                 break;
975                         case EKEY:
976                                 if (G.qual==0){
977                                         if(G.obedit) {
978                                                 if(G.obedit->type==OB_MESH)
979                                                         extrude_mesh();
980                                                 else if(G.obedit->type==OB_CURVE)
981                                                         addvert_Nurb('e');
982                                                 else if(G.obedit->type==OB_SURF)
983                                                         extrude_nurb();
984                                                 else if(G.obedit->type==OB_ARMATURE)
985                                                         extrude_armature();
986                                         }
987                                         else {
988                                                 ob= OBACT;
989                                                 if(ob && ob->type==OB_IKA) if(okee("extrude IKA"))
990                                                         extrude_ika(ob, 1);
991                                         }
992                                 }
993                                 break;
994                         case FKEY:
995                                 if(G.obedit) {
996                                         if(G.obedit->type==OB_MESH) {
997                                                 if((G.qual==LR_SHIFTKEY))
998                                                         fill_mesh();
999                                                 else if(G.qual==LR_ALTKEY)
1000                                                         beauty_fill();
1001                                                 else if(G.qual==LR_CTRLKEY)
1002                                                         edge_flip();
1003                                                 else if (G.qual==0)
1004                                                         addedgevlak_mesh();
1005                                         }
1006                                         else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) addsegment_nurb();
1007                                 }
1008                                 else if(G.qual==LR_CTRLKEY)
1009                                         sort_faces();
1010                                 else if((G.qual==LR_SHIFTKEY))
1011                                         fly();
1012                                 else {
1013                                                 set_faceselect();
1014                                         }
1015                                 
1016                                 break;
1017                         case GKEY:
1018                                 /* RMGRP if(G.qual & LR_CTRLKEY) add_selected_to_group();
1019                                 else if(G.qual & LR_ALTKEY) rem_selected_from_group(); */
1020                                 
1021                                 if((G.qual==LR_SHIFTKEY))
1022                                         group_menu();
1023                                 else if(G.qual==LR_ALTKEY)
1024                                         clear_object('g');
1025                                 else if((G.qual==0))
1026                                         transform('g');
1027                                 break;
1028                         case HKEY:
1029                                 if(G.obedit) {
1030                                         if(G.obedit->type==OB_MESH) {
1031                                                 if(G.qual==LR_ALTKEY)
1032                                                         reveal_mesh();
1033                                                 else if((G.qual==LR_SHIFTKEY))
1034                                                         hide_mesh(1);
1035                                                 else if((G.qual==0)) 
1036                                                         hide_mesh(0);
1037                                         }
1038                                         else if(G.obedit->type== OB_SURF) {
1039                                                 if(G.qual==LR_ALTKEY)
1040                                                         revealNurb();
1041                                                 else if((G.qual==LR_SHIFTKEY))
1042                                                         hideNurb(1);
1043                                                 else if((G.qual==0))
1044                                                         hideNurb(0);
1045                                         }
1046                                         else if(G.obedit->type==OB_CURVE) {
1047                                                 if(G.qual==LR_CTRLKEY)
1048                                                         autocalchandlesNurb_all(1);     /* flag=1, selected */
1049                                                 else if((G.qual==LR_SHIFTKEY))
1050                                                         sethandlesNurb(1);
1051                                                 else if((G.qual==0))
1052                                                         sethandlesNurb(3);
1053                                                 
1054                                                 makeDispList(G.obedit);
1055                                                 
1056                                                 allqueue(REDRAWVIEW3D, 0);
1057                                         }
1058                                 }
1059                                 else if(G.f & G_FACESELECT)
1060                                         hide_tface();
1061                                 
1062                                 break;
1063                         case IKEY:
1064                                 break;
1065                                 
1066                         case JKEY:
1067                                 if(G.qual==LR_CTRLKEY) {
1068                                         if( (ob= OBACT) ) {
1069                                                 if(ob->type == OB_MESH)
1070                                                         join_mesh();
1071                                                 else if(ob->type == OB_CURVE)
1072                                                         join_curve(OB_CURVE);
1073                                                 else if(ob->type == OB_SURF)
1074                                                         join_curve(OB_SURF);
1075                                                 else if(ob->type == OB_ARMATURE)
1076                                                         join_armature ();
1077                                         }
1078                                         else if ((G.obedit) && ELEM(G.obedit->type, OB_CURVE, OB_SURF))
1079                                                 addsegment_nurb();
1080                                 }
1081                                 else if(G.obedit) {
1082                                         if(G.obedit->type==OB_MESH) {
1083                                                 join_triangles();
1084                                         }
1085                                 }
1086
1087                                 break;
1088                         case KKEY:
1089                                 if(G.obedit) {
1090                                         if (G.obedit->type==OB_MESH) {
1091                                                 if (G.qual==LR_SHIFTKEY)
1092                                                         KnifeSubdivide(KNIFE_PROMPT);
1093                                                 else if (G.qual==0)
1094                                                         LoopMenu();
1095                                         }
1096                                         else if(G.obedit->type==OB_SURF)
1097                                                 printknots();
1098                                 }
1099                                 else {
1100                                         if((G.qual==LR_SHIFTKEY)) {
1101                                                 if(G.f & G_FACESELECT)
1102                                                         clear_vpaint_selectedfaces();
1103                                                 else if(G.f & G_VERTEXPAINT)
1104                                                         clear_vpaint();
1105                                                 else
1106                                                         select_select_keys();
1107                                         }
1108                                         else if(G.qual==LR_CTRLKEY)
1109                                                 make_skeleton();
1110 /*                                      else if(G.qual & LR_ALTKEY) delete_skeleton(); */
1111                                         else if (G.qual==0)
1112                                                 set_ob_ipoflags();
1113                                 }
1114                                 
1115                                 break;
1116                         case LKEY:
1117                                 if(G.obedit) {
1118                                         if(G.obedit->type==OB_MESH)
1119                                                 selectconnected_mesh(G.qual);
1120                                         if(G.obedit->type==OB_ARMATURE)
1121                                                 selectconnected_armature();
1122                                         else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
1123                                                 selectconnected_nurb();
1124                                 }
1125                                 else if(G.obpose) {
1126                                         if(G.obpose->type==OB_ARMATURE)
1127                                                 selectconnected_posearmature();
1128                                 }
1129                                 else {
1130                                         if((G.qual==LR_SHIFTKEY))
1131                                                 selectlinks();
1132                                         else if(G.qual==LR_CTRLKEY)
1133                                                 linkmenu();
1134                                         else if(G.f & G_FACESELECT)
1135                                                 select_linked_tfaces();
1136                                         else if((G.qual==0))
1137                                                 make_local();
1138                                 }
1139                                 break;
1140                         case MKEY:
1141                                 if(G.obedit){
1142                                         if(G.qual==LR_ALTKEY) {
1143                                                 if(G.obedit->type==OB_MESH)
1144                                                         mergemenu();
1145                                         }
1146                                         else if((G.qual==0))
1147                                                 mirrormenu();
1148                                 }
1149                                 else if((G.qual==0)){
1150                                      movetolayer();
1151                                 }
1152                                 break;
1153                         case NKEY:
1154                                 if((G.qual==0)) {
1155                                         add_blockhandler(curarea, VIEW3D_HANDLER_OBJECT, UI_PNL_TO_MOUSE);
1156                                         allqueue(REDRAWVIEW3D, 0);
1157                                 }
1158                                 else if(G.obedit) {
1159                                         switch (G.obedit->type){
1160                                         case OB_ARMATURE:
1161                                                 if(G.qual==LR_CTRLKEY){
1162                                                         if (okee("Recalc bone roll angles")) {
1163                                                                 auto_align_armature();
1164                                                                 allqueue(REDRAWVIEW3D, 0);
1165                                                         }
1166                                                 }
1167                                                 break;
1168                                         case OB_MESH: 
1169                                                 if(G.qual==(LR_SHIFTKEY|LR_CTRLKEY)) {
1170                                                         if(okee("Recalc normals inside")) {
1171                                                                 undo_push_mesh("Recalc normals inside");
1172                                                                 righthandfaces(2);
1173                                                                 allqueue(REDRAWVIEW3D, 0);
1174                                                         }
1175                                                 }
1176                                                 else if(G.qual==LR_CTRLKEY){
1177                                                         if(okee("Recalc normals outside")) {
1178                                                                 undo_push_mesh("Recalc normals outside");
1179                                                                 righthandfaces(1);
1180                                                                 allqueue(REDRAWVIEW3D, 0);
1181                                                         }
1182                                                 }
1183                                                 break;
1184                                         }
1185                                 }
1186                                 
1187                                 break;
1188                         case OKEY:
1189                                 ob= OBACT;
1190                                 if(G.obedit) {
1191                                         extern int prop_mode;
1192
1193                                         if (G.qual==LR_SHIFTKEY) {
1194                                                 prop_mode= !prop_mode;
1195                                                 allqueue(REDRAWHEADERS, 0);
1196                                         }
1197                                         else if((G.qual==0)) {
1198                                                 G.f ^= G_PROPORTIONAL;
1199                                                 allqueue(REDRAWHEADERS, 0);
1200                                         }
1201                                 }
1202                                 else if((G.qual==LR_SHIFTKEY)) {
1203                                         if(ob && ob->type == OB_MESH) {
1204                                                 flip_subdivison(ob, 0);
1205                                         }
1206                                 }
1207                                 else if(G.qual==LR_ALTKEY) clear_object('o');
1208                                 break;
1209
1210                         case PKEY:
1211                                 
1212                                 if(G.obedit) {
1213                                         if(G.qual==LR_CTRLKEY)
1214                                                 make_parent();
1215                                         else if((G.qual==0) && G.obedit->type==OB_MESH)
1216                                                 separatemenu();
1217                                         else if ((G.qual==0) && ELEM(G.obedit->type, OB_CURVE, OB_SURF))
1218                                                 separate_nurb();
1219                                 }
1220                                 else if(G.qual==LR_CTRLKEY)
1221                                         make_parent();
1222                                 else if(G.qual==LR_ALTKEY)
1223                                         clear_parent();
1224                                 else if((G.qual==0)) {
1225                         start_game();
1226                                 }
1227                                 break;                          
1228                         case RKEY:
1229                                 if((G.obedit==0) && (G.f & G_FACESELECT) && (G.qual==0))
1230                                         rotate_uv_tface();
1231                                 else if(G.qual==LR_ALTKEY)
1232                                         clear_object('r');
1233                                 else if (G.obedit) {
1234                                         if((G.qual==LR_SHIFTKEY)) {
1235                                                 if ELEM(G.obedit->type,  OB_CURVE, OB_SURF)                                     
1236                                                         selectrow_nurb();
1237                                                 else if (G.obedit->type==OB_MESH)
1238                                                         loop('s');
1239                                         }
1240                                         else if(G.qual==LR_CTRLKEY) {
1241                                                 if (G.obedit->type==OB_MESH)
1242                                                         loop('c');
1243                                         }
1244                                         else if((G.qual==0))
1245                                                 transform('r');
1246                                 }
1247                                 else if((G.qual==0))
1248                                         transform('r');
1249                                 break;
1250                         case SKEY:
1251                                 if(G.obedit) {
1252                                         if(G.qual==LR_ALTKEY)
1253                                                 transform('N'); /* scale along normal */
1254                                         else if(G.qual==LR_CTRLKEY)
1255                                                 transform('S');
1256                                         else if(G.qual==LR_SHIFTKEY)
1257                                                 snapmenu();
1258                                         else if((G.qual==0))
1259                                                 transform('s');
1260                                 }
1261                                 else if(G.qual==LR_ALTKEY) {
1262                                         clear_object('s');
1263                                 }
1264                                 else if((G.qual==LR_SHIFTKEY))
1265                                         snapmenu();
1266                                 else if((G.qual==0))
1267                                         transform('s');
1268                                 break;
1269                         case TKEY:
1270                                 if(G.obedit){
1271                                         if((G.qual==LR_CTRLKEY) && G.obedit->type==OB_MESH) {
1272                                                 convert_to_triface(0);
1273                                                 allqueue(REDRAWVIEW3D, 0);
1274                                                 countall();
1275                                                 makeDispList(G.obedit);
1276                                         }
1277                                         else if((G.qual==LR_ALTKEY) && G.obedit->type==OB_CURVE)
1278                                                 clear_tilt();
1279                                         else if((G.qual==0))
1280                                                 transform('t');
1281                                 }
1282                                 else if(G.qual==LR_CTRLKEY) {
1283                                         make_track();
1284                                 }
1285                                 else if(G.qual==LR_ALTKEY) {
1286                                         clear_track();
1287                                 }
1288                                 else if((G.qual==0)){
1289                                         texspace_edit();
1290                                 }
1291                                 
1292                                 break;
1293                         case UKEY:
1294                                 if(G.obedit) {
1295                                         if(G.obedit->type==OB_MESH){
1296                                                 if (G.qual==LR_ALTKEY)
1297                                                         undo_menu_mesh();
1298                                                 else if (G.qual==LR_SHIFTKEY)
1299                                                         undo_redo_mesh();
1300                                                 else if((G.qual==0))
1301                                                         undo_pop_mesh(1);
1302                                         }
1303                                         else if(G.obedit->type==OB_ARMATURE)
1304                                                 remake_editArmature();
1305                                         else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
1306                                                 remake_editNurb();
1307                                         else if(G.obedit->type==OB_LATTICE)
1308                                                 remake_editLatt();
1309                                 }
1310                                 else if((G.qual==0)){
1311                                         if (G.f & G_FACESELECT)
1312                                                 uv_autocalc_tface();
1313                                         else if(G.f & G_WEIGHTPAINT)
1314                                                 wpaint_undo();
1315                                         else if(G.f & G_VERTEXPAINT)
1316                                                 vpaint_undo();
1317                                         else
1318                                                 single_user();
1319                                 }
1320                                 
1321                                 break;
1322                         case VKEY:
1323                                 ob= OBACT;
1324                                 if((G.qual==LR_SHIFTKEY)) {
1325                                         if ((G.obedit) && G.obedit->type==OB_MESH) {
1326                                                 align_view_to_selected(v3d);
1327                                         }
1328                                         else if (G.f & G_FACESELECT) {
1329                                                 align_view_to_selected(v3d);
1330                                         }
1331                                 }
1332                                 else if(G.qual==LR_ALTKEY)
1333                                         image_aspect();
1334                                 else if (G.qual==0){
1335                                         if(G.obedit) {
1336                                                 if(G.obedit->type==OB_CURVE) {
1337                                                         sethandlesNurb(2);
1338                                                         makeDispList(G.obedit);
1339                                                         allqueue(REDRAWVIEW3D, 0);
1340                                                 }
1341                                         }
1342                                         else if(ob && ob->type == OB_MESH) 
1343                                                 set_vpaint();
1344                                 }
1345                                 break;
1346                         case WKEY:
1347                                 if((G.qual==LR_SHIFTKEY)) {
1348                                         transform('w');
1349                                 }
1350                                 else if(G.qual==LR_ALTKEY) {
1351                                         /* if(G.obedit && G.obedit->type==OB_MESH) write_videoscape(); */
1352                                 }
1353                                 else if(G.qual==LR_CTRLKEY) {
1354                                         if(G.obedit) {
1355                                                 if ELEM(G.obedit->type,  OB_CURVE, OB_SURF) {
1356                                                         switchdirectionNurb2();
1357                                                 }
1358                                         }
1359                                 }
1360                                 else if((G.qual==0))
1361                                         special_editmenu();
1362                                 
1363                                 break;
1364                         case XKEY:
1365                         case DELKEY:
1366                                 if(G.qual==0)
1367                                         delete_context_selected();
1368                                 break;
1369                         case YKEY:
1370                                 if((G.qual==0) && (G.obedit)) {
1371                                         if(G.obedit->type==OB_MESH) split_mesh();
1372                                 }
1373                                 break;
1374                         case ZKEY:
1375                                 toggle_shading();
1376                                 
1377                                 scrarea_queue_headredraw(curarea);
1378                                 scrarea_queue_winredraw(curarea);
1379                                 break;
1380                                 
1381                         
1382                         case HOMEKEY:
1383                                 if(G.qual==0)
1384                                         view3d_home(0);
1385                                 break;
1386                         case COMMAKEY:
1387                                 if(G.qual==0) {
1388                                         G.vd->around= V3D_CENTRE;
1389                                         scrarea_queue_headredraw(curarea);
1390                                 }
1391                                 break;
1392                                 
1393                         case PERIODKEY:
1394                                 if(G.qual==0) {
1395                                         G.vd->around= V3D_CURSOR;
1396                                         scrarea_queue_headredraw(curarea);
1397                                 }
1398                                 break;
1399                         
1400                         case PADSLASHKEY:
1401                                 if(G.qual==0) {
1402                                         if(G.vd->localview) {
1403                                                 G.vd->localview= 0;
1404                                                 endlocalview(curarea);
1405                                         }
1406                                         else {
1407                                                 G.vd->localview= 1;
1408                                                 initlocalview();
1409                                         }
1410                                         scrarea_queue_headredraw(curarea);
1411                                 }
1412                                 break;
1413                         case PADASTERKEY:       /* '*' */
1414                                 if(G.qual==0) {
1415                                         ob= OBACT;
1416                                         if(ob) {
1417                                                 obmat_to_viewmat(ob);
1418                                                 if(G.vd->persp==2) G.vd->persp= 1;
1419                                                 scrarea_queue_winredraw(curarea);
1420                                         }
1421                                 }
1422                                 break;
1423                         case PADPERIOD: /* '.' */
1424                                 if(G.qual==0)
1425                                         centreview();
1426                                 break;
1427                         
1428                         case PAGEUPKEY:
1429                                 if(G.qual==LR_CTRLKEY)
1430                                         movekey_obipo(1);
1431                                 else if((G.qual==0))
1432                                         nextkey_obipo(1);       /* in editipo.c */
1433                                 break;
1434
1435                         case PAGEDOWNKEY:
1436                                 if(G.qual==LR_CTRLKEY)
1437                                         movekey_obipo(-1);
1438                                 else if((G.qual==0))
1439                                         nextkey_obipo(-1);
1440                                 break;
1441                                 
1442                         case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
1443                         case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
1444                         case PADMINUS: case PADPLUSKEY: case PADENTER:
1445                                 persptoetsen(event);
1446                                 doredraw= 1;
1447                                 break;
1448                         
1449                         case ESCKEY:
1450                                 if(G.qual==0) {
1451                                         if (G.vd->flag & V3D_DISPIMAGE) {
1452                                                 G.vd->flag &= ~V3D_DISPIMAGE;
1453                                                 doredraw= 1;
1454                                         }
1455                                 }
1456                                 break;
1457                         }
1458                 }
1459         }
1460         
1461         if(doredraw) {
1462                 scrarea_queue_winredraw(curarea);
1463                 scrarea_queue_headredraw(curarea);
1464         }
1465 }
1466
1467 void initview3d(ScrArea *sa)
1468 {
1469         View3D *vd;
1470         
1471         vd= MEM_callocN(sizeof(View3D), "initview3d");
1472         BLI_addhead(&sa->spacedata, vd);        /* addhead! not addtail */
1473
1474         vd->spacetype= SPACE_VIEW3D;
1475         vd->viewquat[0]= 1.0;
1476         vd->viewquat[1]= vd->viewquat[2]= vd->viewquat[3]= 0.0;
1477         vd->persp= 1;
1478         vd->drawtype= OB_WIRE;
1479         vd->view= 7;
1480         vd->dist= 10.0;
1481         vd->lens= 35.0f;
1482         vd->near= 0.01f;
1483         vd->far= 500.0f;
1484         vd->grid= 1.0f;
1485         vd->gridlines= 16;
1486         vd->lay= vd->layact= 1;
1487         if(G.scene) {
1488                 vd->lay= vd->layact= G.scene->lay;
1489                 vd->camera= G.scene->camera;
1490         }
1491         vd->scenelock= 1;
1492 }
1493
1494
1495 /* ******************** SPACE: IPO ********************** */
1496
1497 static void changeview2dspace(ScrArea *sa, void *spacedata)
1498 {
1499         if(G.v2d==0) return;
1500
1501         test_view2d(G.v2d, curarea->winx, curarea->winy);
1502         myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
1503 }
1504
1505 void winqreadipospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
1506 {
1507         extern void do_ipobuts(unsigned short event);   // drawipo.c
1508         unsigned short event= evt->event;
1509         short val= evt->val;
1510         SpaceIpo *sipo= curarea->spacedata.first;
1511         View2D *v2d= &sipo->v2d;
1512         float dx, dy;
1513         int cfra, doredraw= 0;
1514         short mval[2];
1515         
1516
1517         if(sa->win==0) return;
1518
1519         if(val) {
1520                 if( uiDoBlocks(&sa->uiblocks, event)!=UI_NOTHING ) event= 0;
1521
1522                 switch(event) {
1523                 case UI_BUT_EVENT:
1524                         /* note: bad bad code, will be cleaned! is because event queues are all shattered */
1525                         if(val>0 && val < 32) do_ipowin_buts(val-1);
1526                         else do_ipobuts(val);
1527                         break;
1528                         
1529                 case LEFTMOUSE:
1530                         if( in_ipo_buttons() ) {
1531                                 do_ipo_selectbuttons();
1532                                 doredraw= 1;
1533                         }                       
1534                         else if(G.qual & LR_CTRLKEY) add_vert_ipo();
1535                         else {
1536                                 do {
1537                                         getmouseco_areawin(mval);
1538                                         areamouseco_to_ipoco(v2d, mval, &dx, &dy);
1539                                         
1540                                         cfra= (int)dx;
1541                                         if(cfra< 1) cfra= 1;
1542                                         
1543                                         if( cfra!=CFRA ) {
1544                                                 CFRA= cfra;
1545                                                 update_for_newframe();
1546                                                 force_draw_plus(SPACE_VIEW3D);
1547                                                 force_draw_plus(SPACE_ACTION);
1548                                                 force_draw_plus(SPACE_BUTS);    /* To make constraint sliders redraw */
1549                                         }
1550                                 
1551                                 } while(get_mbut()&L_MOUSE);
1552                         }
1553                         
1554                         break;
1555                 case MIDDLEMOUSE:
1556                         if(in_ipo_buttons()) {
1557                                 scroll_ipobuts();
1558                         }
1559                         else view2dmove(event); /* in drawipo.c */
1560                         break;
1561
1562                 case WHEELUPMOUSE:
1563                 case WHEELDOWNMOUSE:
1564                         view2dmove(event);      /* in drawipo.c */
1565                         break;
1566
1567                 case RIGHTMOUSE:
1568                         mouse_select_ipo();
1569                         allqueue (REDRAWACTION, 0);
1570                         allqueue(REDRAWNLA, 0);
1571                         break;
1572                 case PADPLUSKEY:
1573                         view2d_zoom(v2d, 0.1154, sa->winx, sa->winy);
1574                         doredraw= 1;
1575                         break;
1576                 case PADMINUS:
1577                         view2d_zoom(v2d, -0.15, sa->winx, sa->winy);
1578                         doredraw= 1;
1579                         break;
1580                 case PAGEUPKEY:
1581                         if(G.qual==LR_CTRLKEY)
1582                                 movekey_ipo(1);
1583                         else if((G.qual==0))
1584                                 nextkey_ipo(1);
1585                         break;
1586                 case PAGEDOWNKEY:
1587                         if(G.qual==LR_CTRLKEY)
1588                                 movekey_ipo(-1);
1589                         else if((G.qual==0))
1590                                 nextkey_ipo(-1);
1591                         break;
1592                 case HOMEKEY:
1593                         if((G.qual==0))
1594                                 do_ipo_buttons(B_IPOHOME);
1595                         break;
1596                         
1597                 case AKEY:
1598                         if((G.qual==0)) {
1599                                 if(in_ipo_buttons()) {
1600                                         swap_visible_editipo();
1601                                 }
1602                                 else swap_selectall_editipo();
1603                                 allspace (REMAKEIPO, 0);
1604                                 allqueue (REDRAWNLA, 0);
1605                                 allqueue (REDRAWACTION, 0);
1606                         }
1607                         break;
1608                 case BKEY:
1609                         if((G.qual==0))
1610                                 borderselect_ipo();
1611                         break;
1612                 case CKEY:
1613                         if((G.qual==0))
1614                                 move_to_frame();
1615                         break;
1616                 case DKEY:
1617                         if((G.qual==LR_SHIFTKEY))
1618                                 add_duplicate_editipo();
1619                         break;
1620                 case GKEY:
1621                         if((G.qual==0))
1622                                 transform_ipo('g');
1623                         break;
1624                 case HKEY:
1625                         if((G.qual==LR_SHIFTKEY))
1626                                 sethandles_ipo(HD_AUTO);
1627                         else if((G.qual==0))
1628                                 sethandles_ipo(HD_ALIGN);
1629                         break;
1630                 case JKEY:
1631                         if((G.qual==0))
1632                                 join_ipo();
1633                         break;
1634                 case KKEY:
1635                         if((G.qual==0)) {
1636                                 ipo_toggle_showkey();
1637                                 scrarea_queue_headredraw(curarea);
1638                                 allqueue(REDRAWVIEW3D, 0);
1639                                 doredraw= 1;
1640                         }
1641                         break;
1642                 case NKEY:
1643                         add_blockhandler(sa, IPO_HANDLER_PROPERTIES, UI_PNL_TO_MOUSE);
1644                         doredraw= 1;
1645                         break;
1646                 case RKEY:
1647                         if((G.qual==0))
1648                                 ipo_record();
1649                         break;
1650                 case SKEY:
1651                         if((G.qual==LR_SHIFTKEY))
1652                                 ipo_snapmenu();
1653                         else if((G.qual==0))
1654                                 transform_ipo('s');
1655                         break;
1656                 case TKEY:
1657                         if((G.qual==0))
1658                                 set_ipotype();
1659                         break;
1660                 case VKEY:
1661                         if((G.qual==0))
1662                                 sethandles_ipo(HD_VECT);
1663                         break;
1664                 case XKEY:
1665                 case DELKEY:
1666                         if((G.qual==LR_SHIFTKEY))
1667                                 delete_key();
1668                         else if((G.qual==0))
1669                                 del_ipo();
1670                         break;
1671                 }
1672         }
1673
1674         if(doredraw) scrarea_queue_winredraw(sa);
1675 }
1676
1677 void initipo(ScrArea *sa)
1678 {
1679         SpaceIpo *sipo;
1680         
1681         sipo= MEM_callocN(sizeof(SpaceIpo), "initipo");
1682         BLI_addhead(&sa->spacedata, sipo);
1683
1684         sipo->spacetype= SPACE_IPO;
1685         /* sipo space loopt van (0,-?) tot (??,?) */
1686         sipo->v2d.tot.xmin= 0.0;
1687         sipo->v2d.tot.ymin= -10.0;
1688         sipo->v2d.tot.xmax= G.scene->r.efra;
1689         sipo->v2d.tot.ymax= 10.0;
1690
1691         sipo->v2d.cur= sipo->v2d.tot;
1692
1693         sipo->v2d.min[0]= 0.01f;
1694         sipo->v2d.min[1]= 0.01f;
1695
1696         sipo->v2d.max[0]= 15000.0f;
1697         sipo->v2d.max[1]= 10000.0f;
1698         
1699         sipo->v2d.scroll= L_SCROLL+B_SCROLL;
1700         sipo->v2d.keeptot= 0;
1701
1702         sipo->blocktype= ID_OB;
1703 }
1704
1705 /* ******************** SPACE: INFO ********************** */
1706
1707 void space_mipmap_button_function(int event) {
1708         set_mipmap(!(U.gameflags & USERDEF_DISABLE_MIPMAP));
1709
1710         allqueue(REDRAWVIEW3D, 0);
1711 }
1712
1713 void space_sound_button_function(int event)
1714 {
1715         int a;
1716         SYS_SystemHandle syshandle;
1717
1718         if ((syshandle = SYS_GetSystem()))
1719         {
1720                 a = (U.gameflags & USERDEF_DISABLE_SOUND);
1721                 SYS_WriteCommandLineInt(syshandle, "noaudio", a);
1722         }
1723 }
1724
1725 #define B_ADD_THEME     3301
1726 #define B_DEL_THEME     3302
1727 #define B_NAME_THEME    3303
1728 #define B_THEMECOL              3304
1729 #define B_UPDATE_THEME  3305
1730 #define B_CHANGE_THEME  3306
1731 #define B_THEME_COPY    3307
1732 #define B_THEME_PASTE   3308
1733
1734 #define B_RECALCLIGHT   3310
1735
1736 // needed for event; choose new 'curmain' resets it...
1737 static short th_curcol= TH_BACK;
1738 static char *th_curcol_ptr= NULL;
1739 static char th_curcol_arr[4]={0, 0, 0, 255};
1740
1741 void info_user_themebuts(uiBlock *block, short y1, short y2, short y3)
1742 {
1743         bTheme *btheme, *bt;
1744         int spacetype= 0;
1745         static short cur=1, curmain=2;
1746         short a, tot=0, isbuiltin= 0;
1747         char string[20*32], *strp, *col;
1748         
1749         y3= y2+23;      // exception!
1750         
1751         /* count total, max 16! */
1752         for(bt= U.themes.first; bt; bt= bt->next) tot++;
1753         
1754         /* if cur not is 1; move that to front of list */
1755         if(cur!=1) {
1756                 a= 1;
1757                 for(bt= U.themes.first; bt; bt= bt->next, a++) {
1758                         if(a==cur) {
1759                                 BLI_remlink(&U.themes, bt);
1760                                 BLI_addhead(&U.themes, bt);
1761                                 cur= 1;
1762                                 break;
1763                         }
1764                 }
1765         }
1766         
1767         /* the current theme */
1768         btheme= U.themes.first;
1769         if(strcmp(btheme->name, "Default")==0) isbuiltin= 1;
1770
1771         /* construct popup script */
1772         string[0]= 0;
1773         for(bt= U.themes.first; bt; bt= bt->next) {
1774                 strcat(string, bt->name);
1775                 if(btheme->next) strcat(string, "   |");
1776         }
1777         uiDefButS(block, MENU, B_UPDATE_THEME, string,                  45,y3,200,20, &cur, 0, 0, 0, 0, "Current theme");
1778         
1779         /* add / delete / name */
1780
1781         if(tot<16)
1782                 uiDefBut(block, BUT, B_ADD_THEME, "Add",        45,y2,200,20, NULL, 0, 0, 0, 0, "Makes new copy of this theme");
1783         if(tot>1 && isbuiltin==0)
1784                 uiDefBut(block, BUT, B_DEL_THEME, "Delete", 45,y1,200,20, NULL, 0, 0, 0, 0, "Delete theme");
1785
1786         if(isbuiltin) return;
1787         
1788         /* name */
1789         uiDefBut(block, TEX, B_NAME_THEME, "",                  255,y3,200,20, btheme->name, 1.0, 30.0, 0, 0, "Rename theme");
1790
1791         /* main choices pup */
1792         uiDefButS(block, MENU, B_CHANGE_THEME, "UI and Buttons %x1|3D View %x2|Ipo Curve Editor %x3|Action Editor %x4|"
1793                 "NLA Editor %x5|UV/Image Editor %x6|Sequence Editor %x7|Sound Editor %x8|Text Editor %x9|User Preferences %x10|"
1794                 "OOPS Schematic %x11|Buttons Window %x12|File Window %x13|Image Browser %x14",
1795                                                                                                         255,y2,200,20, &curmain, 0, 0, 0, 0, "Specify theme for...");
1796         if(curmain==1) spacetype= 0;
1797         else if(curmain==2) spacetype= SPACE_VIEW3D;
1798         else if(curmain==3) spacetype= SPACE_IPO;
1799         else if(curmain==4) spacetype= SPACE_ACTION;
1800         else if(curmain==5) spacetype= SPACE_NLA;
1801         else if(curmain==6) spacetype= SPACE_IMAGE;
1802         else if(curmain==7) spacetype= SPACE_SEQ;
1803         else if(curmain==8) spacetype= SPACE_SOUND;
1804         else if(curmain==9) spacetype= SPACE_TEXT;
1805         else if(curmain==10) spacetype= SPACE_INFO;
1806         else if(curmain==11) spacetype= SPACE_OOPS;
1807         else if(curmain==12) spacetype= SPACE_BUTS;
1808         else if(curmain==13) spacetype= SPACE_FILE;
1809         else if(curmain==14) spacetype= SPACE_IMASEL;
1810         else return; // only needed while coding... when adding themes for more windows
1811         
1812         /* color choices pup */
1813         if(curmain==1) {
1814                 strp= BIF_ThemeColorsPup(0);
1815                 if(th_curcol==TH_BACK) th_curcol= TH_BUT_NEUTRAL;  // switching main choices...
1816         }
1817         else strp= BIF_ThemeColorsPup(spacetype);
1818         
1819         uiDefButS(block, MENU, B_REDR, strp,                    255,y1,200,20, &th_curcol, 0, 0, 0, 0, "Current color");
1820         MEM_freeN(strp);
1821         
1822         th_curcol_ptr= col= BIF_ThemeGetColorPtr(btheme, spacetype, th_curcol);
1823         if(col==NULL) return;
1824         
1825         /* first handle exceptions, special single values, row selection, etc */
1826         if(th_curcol==TH_VERTEX_SIZE) {
1827                 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"Vertex size ", 465,y3,200,20,  col, 1.0, 10.0, 0, 0, "");
1828         }
1829         else if(th_curcol==TH_BUT_DRAWTYPE) {
1830                 uiDefButC(block, ROW, B_UPDATE_THEME, "Minimal",        465,y3,200,20,  col, 2.0, 0.0, 0, 0, "");
1831                 uiDefButC(block, ROW, B_UPDATE_THEME, "Default",        465,y2,200,20,  col, 2.0, 1.0, 0, 0, "");
1832         
1833         }
1834         else {
1835                 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"R ",   465,y3,200,20,  col, 0.0, 255.0, B_THEMECOL, 0, "");
1836                 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"G ",   465,y2,200,20,  col+1, 0.0, 255.0, B_THEMECOL, 0, "");
1837                 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"B ",   465,y1,200,20,  col+2, 0.0, 255.0, B_THEMECOL, 0, "");
1838
1839                 uiDefButC(block, COL, B_THEMECOL, "",           675,y1,50,y3-y1+20, col, 0, 0, 0, 0, "");
1840                 if ELEM3(th_curcol, TH_PANEL, TH_FACE, TH_FACE_SELECT) {
1841                         uiDefButC(block, NUMSLI, B_UPDATE_THEME,"A ",   465,y3+25,200,20,  col+3, 0.0, 255.0, B_THEMECOL, 0, "");
1842                 }
1843                 
1844                 /* copy paste */
1845                 uiDefBut(block, BUT, B_THEME_COPY, "Copy Color",        755,y2,120,20, NULL, 0, 0, 0, 0, "Stores current color in buffer");
1846                 uiDefBut(block, BUT, B_THEME_PASTE, "Paste Color",      755,y1,120,20, NULL, 0, 0, 0, 0, "Pastes buffer color");
1847
1848                 uiDefButC(block, COL, 0, "",                            885,y1,50,y2-y1+20, th_curcol_arr, 0, 0, 0, 0, "");
1849                 
1850         }
1851 }
1852
1853
1854 void drawinfospace(ScrArea *sa, void *spacedata)
1855 {
1856         uiBlock *block;
1857         static short cur_light=0, cur_light_var=0;
1858         float fac, col[3];
1859         short xpos, ypos, ypostab,  buth, rspace, dx, y1, y2, y3, y4, y2label, y3label, y4label;
1860         short smallprefbut, medprefbut, largeprefbut, smfileselbut;
1861         short edgespace, midspace;
1862         char naam[32];
1863
1864         if(curarea->win==0) return;
1865
1866         BIF_GetThemeColor3fv(TH_BACK, col);
1867         glClearColor(col[0], col[1], col[2], 0.0);
1868         glClear(GL_COLOR_BUFFER_BIT);
1869
1870         fac= ((float)curarea->winx)/1280.0f;
1871         myortho2(0.0, 1280.0, 0.0, curarea->winy/fac);
1872         
1873         sprintf(naam, "infowin %d", curarea->win);
1874         block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSS, UI_HELV, curarea->win);
1875
1876
1877         dx= (1280-90)/7;        /* spacing for use in equally dividing 'tab' row */
1878
1879         xpos = 45;              /* left padding */
1880         ypos = 50;              /* bottom padding for buttons */
1881         ypostab = 10;           /* bottom padding for 'tab' row */
1882
1883
1884         buth = 20;              /* standard button height */
1885
1886         smallprefbut = 94;      /* standard size for small preferences button */
1887         medprefbut = 193;       /* standard size for medium preferences button */
1888         largeprefbut = 292;     /* standard size for large preferences button */
1889         smfileselbut = buth;    /* standard size for fileselect button (square) */
1890         
1891         edgespace = 3;          /* space from edge of end 'tab' to edge of end button */
1892         midspace = 5;           /* horizontal space between buttons */
1893
1894         rspace = 3;             /* default space between rows */
1895
1896         y1 = ypos;              /* bottom padding of 1st (bottom) button row */
1897         y2 = ypos+buth+rspace;  /* bottom padding of 2nd button row */
1898         y3 = ypos+2*(buth+rspace)+(3*rspace);   /* bottom padding of 3rd button row */
1899         y4 = ypos+3*(buth+rspace)+(3*rspace);   /* bottom padding of 4th button row */
1900
1901         y2label = y2-2;         /* adjustments to offset the labels down to align better */
1902         y3label = y3-(3*rspace)-2;      /* again for 3rd row */
1903         y4label = y4-2;         /* again for 4th row */
1904
1905
1906         /* set the colour to blue and draw the main 'tab' controls */
1907
1908         uiBlockSetCol(block, TH_BUT_SETTING1);
1909
1910         uiDefButI(block, ROW,B_USERPREF,"View & Controls",
1911                 xpos,ypostab,(short)dx,buth,
1912                 &U.userpref,1.0,0.0, 0, 0,"");
1913                 
1914         uiDefButI(block, ROW,B_USERPREF,"Edit Methods",
1915                 (short)(xpos+dx),ypostab,(short)dx,buth,
1916                 &U.userpref,1.0,1.0, 0, 0,"");
1917
1918         uiDefButI(block, ROW,B_USERPREF,"Language & Font",
1919                 (short)(xpos+2*dx),ypostab,(short)dx,buth,
1920                 &U.userpref,1.0,2.0, 0, 0,"");
1921
1922         uiDefButI(block, ROW,B_USERPREF,"Themes",
1923                 (short)(xpos+3*dx),ypostab,(short)dx,buth,
1924                 &U.userpref,1.0,6.0, 0, 0,"");
1925
1926         uiDefButI(block, ROW,B_USERPREF,"Auto Save",
1927                 (short)(xpos+4*dx),ypostab,(short)dx,buth,
1928                 &U.userpref,1.0,3.0, 0, 0,"");
1929
1930         uiDefButI(block, ROW,B_USERPREF,"System & OpenGL",
1931                 (short)(xpos+5*dx),ypostab,(short)dx,buth,
1932                 &U.userpref,1.0,4.0, 0, 0,"");
1933                 
1934         uiDefButI(block, ROW,B_USERPREF,"File Paths",
1935                 (short)(xpos+6*dx),ypostab,(short)dx,buth,
1936                 &U.userpref,1.0,5.0, 0, 0,"");
1937
1938         uiBlockSetCol(block, TH_AUTO);
1939
1940         /* end 'tab' controls */
1941
1942         /* line 2: left x co-ord, top y co-ord, width, height */
1943
1944         if(U.userpref == 6) {
1945                 info_user_themebuts(block, y1, y2, y3);
1946         }
1947         else if (U.userpref == 0) { /* view & controls */
1948
1949                 uiDefBut(block, LABEL,0,"Display:",
1950                         xpos,y3label,medprefbut,buth,
1951                         0, 0, 0, 0, 0, "");
1952
1953                 uiDefButS(block, TOG|BIT|11, 0, "ToolTips",
1954                         (xpos+edgespace),y2,smallprefbut,buth,
1955                         &(U.flag), 0, 0, 0, 0,
1956                         "Displays tooltips (help tags) over buttons");
1957
1958                 uiDefButS(block, TOG|BIT|4, B_DRAWINFO, "Object Info",
1959                         (xpos+edgespace+midspace+smallprefbut),y2,smallprefbut,buth,
1960                         &(U.uiflag), 0, 0, 0, 0,
1961                         "Displays current object name and frame number in the 3D viewport");
1962
1963                 uiDefButS(block, TOG|BIT|4, 0, "Global Scene",
1964                         (xpos+edgespace),y1,medprefbut,buth,
1965                         &(U.flag), 0, 0, 0, 0,
1966                         "Forces the current Scene to be displayed in all Screens");
1967
1968
1969                 uiDefBut(block, LABEL,0,"Snap to grid:",
1970                         (xpos+edgespace+medprefbut),y3label,medprefbut,buth,
1971                         0, 0, 0, 0, 0, "");
1972
1973                 uiDefButS(block, TOG|BIT|1, 0, "Grab",
1974                         (xpos+edgespace+medprefbut+midspace),y2,smallprefbut,buth,
1975                         &(U.flag), 0, 0, 0, 0,
1976                         "Move objects to grid units");
1977
1978                 uiDefButS(block, TOG|BIT|3, 0, "Size",
1979                         (xpos+edgespace+medprefbut+midspace),y1,smallprefbut,buth,
1980                         &(U.flag), 0, 0, 0, 0,
1981                         "Scale objects to grid units");
1982
1983                 uiDefButS(block, TOG|BIT|2, 0, "Rotate",
1984                         (xpos+edgespace+medprefbut+(2*midspace)+smallprefbut),y2,smallprefbut,buth,
1985                         &(U.flag), 0, 0, 0, 0,
1986                         "Rotate objects to grid units");
1987
1988
1989
1990                 uiDefBut(block, LABEL,0,"Menu Buttons:",
1991                         (xpos+edgespace+medprefbut+(3*midspace)+(2*smallprefbut)),y3label,medprefbut,buth,
1992                         0, 0, 0, 0, 0, "");
1993
1994                 uiDefButS(block, TOG|BIT|9, 0, "Auto Open",
1995                         (xpos+edgespace+medprefbut+(3*midspace)+(2*smallprefbut)),y2,smallprefbut,buth,
1996                         &(U.uiflag), 0, 0, 0, 0,
1997                         "Automatic opening of menu buttons");
1998
1999                 uiDefButS(block, NUM, 0, "ThresA:",
2000                         (xpos+edgespace+medprefbut+(3*midspace)+(2*smallprefbut)),y1,smallprefbut,buth,
2001                         &(U.menuthreshold1), 1, 40, 0, 0,
2002                         "Time in 1/10 seconds for auto open");
2003
2004                 uiDefButS(block, NUM, 0, "ThresB:",
2005                         (xpos+edgespace+medprefbut+(4*midspace)+(3*smallprefbut)),y1,smallprefbut,buth,
2006                         &(U.menuthreshold2), 1, 40, 0, 0,
2007                         "Time in 1/10 seconds for auto open sublevels");
2008
2009
2010                 uiDefBut(block, LABEL,0,"Toolbox Thresh.:",
2011                         (xpos+edgespace+(3*midspace)+(3*medprefbut)),y3label,medprefbut,buth,
2012                         0, 0, 0, 0, 0, "");
2013
2014                 uiDefButS(block, NUM, 0, "LMB:",
2015                         (xpos+edgespace+(3*midspace)+(3*medprefbut)),y2,smallprefbut,buth,
2016                         &(U.tb_leftmouse), 2, 40, 0, 0,
2017                         "Time in 1/10 seconds leftmouse hold to open toolbox");
2018
2019                 uiDefButS(block, NUM, 0, "RMB:",
2020                         (xpos+edgespace+(3*midspace)+(3*medprefbut)),y1,smallprefbut,buth,
2021                         &(U.tb_rightmouse), 2, 40, 0, 0,
2022                         "Time in 1/10 seconds for rightmouse to open toolbox");
2023
2024                         
2025                 uiDefBut(block, LABEL,0,"View rotation:",
2026                         (xpos+edgespace+(3*midspace)+(3*medprefbut)+smallprefbut+2),y3label,medprefbut,buth,
2027                         0, 0, 0, 0, 0, "");
2028
2029                 uiDefButS(block, TOG|BIT|5, B_DRAWINFO, "Trackball",
2030                         (xpos+edgespace+(3*midspace)+(3*medprefbut)+smallprefbut+2),y2,(smallprefbut+2),buth,
2031                         &(U.flag), 0, 0, 0, 0,
2032                         "Use trackball style rotation with middle mouse button");
2033
2034                 uiDefButS(block, TOGN|BIT|5, B_DRAWINFO, "Turntable",
2035                         (xpos+edgespace+(3*midspace)+(3*medprefbut)+smallprefbut+2),y1,(smallprefbut+2),buth,
2036                         &(U.flag), 0, 0, 0, 0,
2037                         "Use turntable style rotation with middle mouse button");
2038
2039
2040
2041                 uiDefButS(block, TOGN|BIT|10, B_DRAWINFO, "Rotate View",
2042                         (xpos+edgespace+(4*midspace)+(4*medprefbut)),y2,(smallprefbut+2),buth,
2043                         &(U.flag), 0, 0, 0, 0, "Default action for the middle mouse button");
2044
2045                 uiDefButS(block, TOG|BIT|10, B_DRAWINFO, "Pan View",
2046                         (xpos+edgespace+(4*midspace)+(4*medprefbut)+smallprefbut+2),y2,(smallprefbut+2),buth,
2047                         &(U.flag), 0, 0, 0, 0, "Default action for the middle mouse button");
2048
2049                 uiDefBut(block, LABEL,0,"Middle mouse button:",
2050                         (xpos+edgespace+(3*midspace)+(4*medprefbut)),y3label,medprefbut,buth,
2051                         0, 0, 0, 0, 0, "");
2052                 uiDefButS(block, TOG|BIT|12, 0, "Emulate 3 Buttons",
2053                         (xpos+edgespace+(4*midspace)+(4*medprefbut)),y1,medprefbut,buth,
2054                         &(U.flag), 0, 0, 0, 0,
2055                         "Emulates a middle mouse button with ALT+LeftMouse");
2056
2057
2058
2059
2060                 uiDefBut(block, LABEL,0,"Mousewheel:",
2061                         (xpos+edgespace+(4*midspace)+(5*medprefbut)),y3label,medprefbut,buth,
2062                         0, 0, 0, 0, 0, "");
2063                 uiDefButS(block, TOG|BIT|2, 0, "Invert Wheel Zoom",
2064                         (xpos+edgespace+(5*midspace)+(5*medprefbut)),y1,medprefbut,buth,
2065                         &(U.uiflag), 0, 0, 0, 0,
2066                         "Swaps mouse wheel zoom direction");
2067
2068
2069                 uiDefButI(block, NUM, 0, "Scroll Lines:",
2070                         (xpos+edgespace+(5*midspace)+(5*medprefbut)),y2,medprefbut,buth,
2071                         &U.wheellinescroll, 0.0, 32.0, 0, 0,
2072                         "The number of lines scrolled at a time with the mouse wheel");
2073
2074
2075         } else if (U.userpref == 1) { /* edit methods */
2076
2077
2078                 uiDefBut(block, LABEL,0,"Material linked to:",
2079                         xpos,y3label,medprefbut,buth,
2080                         0, 0, 0, 0, 0, "");
2081
2082                 uiDefButS(block, TOGN|BIT|8, B_DRAWINFO, "ObData",
2083                         (xpos+edgespace),y2,(smallprefbut),buth,
2084                         &(U.flag), 0, 0, 0, 0, "Link new objects' material to the obData block");
2085
2086                 uiDefButS(block, TOG|BIT|8, B_DRAWINFO, "Object",
2087                         (xpos+edgespace+midspace+smallprefbut),y2,(smallprefbut),buth,
2088                         &(U.flag), 0, 0, 0, 0, "Link new objects' material to the object block");
2089
2090
2091
2092                 uiDefBut(block, LABEL,0,"Mesh Undo",
2093                         (xpos+edgespace+medprefbut),y3label, medprefbut,buth,
2094                         0, 0, 0, 0, 0, "");
2095
2096                 uiDefButS(block, NUMSLI, B_DRAWINFO, "Steps:",
2097                         (xpos+edgespace+medprefbut+midspace),y2,(medprefbut),buth,
2098                                 &(U.undosteps), 1, 64, 0, 0, "Number of undo steps avail. in Editmode.  Smaller conserves memory.");
2099
2100
2101                 uiDefBut(block, LABEL,0,"Auto keyframe on:",
2102                         (xpos+edgespace+(2*medprefbut)+midspace),y3label,medprefbut,buth,
2103                         0, 0, 0, 0, 0, "");
2104
2105                 uiDefButS(block, TOG|BIT|0, 0, "Action",
2106                         (xpos+edgespace+(2*medprefbut)+(2*midspace)),y2,smallprefbut,buth,
2107                         &(U.uiflag), 0, 0, 0, 0, "Automatic keyframe insertion in action ipo curve");
2108
2109                 uiDefButS(block, TOG|BIT|1, 0, "Object",
2110                         (xpos+edgespace+(2*medprefbut)+(3*midspace)+smallprefbut),y2,smallprefbut,buth,
2111                         &(U.uiflag), 0, 0, 0, 0, "Automatic keyframe insertion in object ipo curve");
2112
2113
2114
2115                 uiDefBut(block, LABEL,0,"Duplicate with object:",
2116                         (xpos+edgespace+(3*midspace)+(3*medprefbut)+smallprefbut),y3label,medprefbut,buth,
2117                         0, 0, 0, 0, 0, "");
2118
2119                 uiDefButS(block, TOG|BIT|0, 0, "Mesh",
2120                         (xpos+edgespace+(4*midspace)+(3*medprefbut)+smallprefbut),y2,smallprefbut,buth,
2121                         &(U.dupflag), 0, 0, 0, 0, "Causes mesh data to be duplicated with Shift+D");
2122                 uiDefButS(block, TOG|BIT|9, 0, "Armature",
2123                         (xpos+edgespace+(4*midspace)+(3*medprefbut)+smallprefbut),y1,smallprefbut,buth,
2124                         &(U.dupflag), 0, 0, 0, 0, "Causes armature data to be duplicated with Shift+D");
2125
2126                 uiDefButS(block, TOG|BIT|2, 0, "Surface",
2127                         (xpos+edgespace+(5*midspace)+(3*medprefbut)+(2*smallprefbut)),y2,smallprefbut,buth,
2128                         &(U.dupflag), 0, 0, 0, 0, "Causes surface data to be duplicated with Shift+D");
2129                 uiDefButS(block, TOG|BIT|5, 0, "Lamp",
2130                         (xpos+edgespace+(5*midspace)+(3*medprefbut)+(2*smallprefbut)),y1,smallprefbut,buth,
2131                         &(U.dupflag), 0, 0, 0, 0, "Causes lamp data to be duplicated with Shift+D");
2132
2133                 uiDefButS(block, TOG|BIT|1, 0, "Curve",
2134                         (xpos+edgespace+(6*midspace)+(3*medprefbut)+(3*smallprefbut)),y2,smallprefbut,buth,
2135                         &(U.dupflag), 0, 0, 0, 0, "Causes curve data to be duplicated with Shift+D");
2136                 uiDefButS(block, TOG|BIT|7, 0, "Material",
2137                         (xpos+edgespace+(6*midspace)+(3*medprefbut)+(3*smallprefbut)),y1,smallprefbut,buth,
2138                         &(U.dupflag), 0, 0, 0, 0, "Causes material data to be duplicated with Shift+D");
2139
2140                 uiDefButS(block, TOG|BIT|3, 0, "Text",
2141                         (xpos+edgespace+(7*midspace)+(3*medprefbut)+(4*smallprefbut)),y2,smallprefbut,buth,
2142                         &(U.dupflag), 0, 0, 0, 0, "Causes text data to be duplicated with Shift+D");
2143                 uiDefButS(block, TOG|BIT|8, 0, "Texture",
2144                         (xpos+edgespace+(7*midspace)+(3*medprefbut)+(4*smallprefbut)),y1,smallprefbut,buth,
2145                         &(U.dupflag), 0, 0, 0, 0, "Causes texture data to be duplicated with Shift+D");
2146
2147                 uiDefButS(block, TOG|BIT|4, 0, "Metaball",
2148                         (xpos+edgespace+(8*midspace)+(3*medprefbut)+(5*smallprefbut)),y2,smallprefbut,buth,
2149                         &(U.dupflag), 0, 0, 0, 0, "Causes metaball data to be duplicated with Shift+D");
2150                 uiDefButS(block, TOG|BIT|6, 0, "Ipo",
2151                         (xpos+edgespace+(8*midspace)+(3*medprefbut)+(5*smallprefbut)),y1,smallprefbut,buth,
2152                         &(U.dupflag), 0, 0, 0, 0, "Causes ipo data to be duplicated with Shift+D");
2153         
2154         } else if(U.userpref == 2) { /* language & colors */
2155
2156 #ifdef INTERNATIONAL
2157                 char curfont[64];
2158
2159                 sprintf(curfont, "Interface Font: ");
2160                 strcat(curfont,U.fontname);
2161
2162                 uiDefButS(block, TOG|BIT|5, B_DOLANGUIFONT, "International Fonts",
2163                         xpos,y2,medprefbut,buth,
2164                         &(U.transopts), 0, 0, 0, 0, "Activate international interface");
2165
2166                 if(U.transopts & TR_ALL) {
2167                         uiDefBut(block, LABEL,0,curfont,
2168                                 (xpos+edgespace+medprefbut+midspace),y2,medprefbut,buth,
2169                                 0, 0, 0, 0, 0, "");
2170
2171                         uiDefBut(block, BUT, B_LOADUIFONT, "Select Font",
2172                                 xpos,y1,medprefbut,buth,
2173                                 0, 0, 0, 0, 0, "Select a new font for the interface");
2174
2175
2176                         uiDefButI(block, MENU|INT, B_SETFONTSIZE, fontsize_pup(),
2177                                 (xpos+edgespace+medprefbut+midspace),y1,medprefbut,buth,
2178                                 &U.fontsize, 0, 0, 0, 0, "Current interface font size (points)");
2179
2180 /*
2181                         uiDefButS(block, MENU|SHO, B_SETENCODING, encoding_pup(),
2182                                 (xpos+edgespace+medprefbut+midspace),y1,medprefbut,buth,
2183                                 &U.encoding, 0, 0, 0, 0, "Current interface font encoding");
2184
2185
2186                         uiDefBut(block, LABEL,0,"Translate:",
2187                                 (xpos+edgespace+(2.1*medprefbut)+(2*midspace)),y3label,medprefbut,buth,
2188                                 0, 0, 0, 0, 0, "");
2189 */
2190
2191                         uiDefButS(block, TOG|BIT|0, B_SETTRANSBUTS, "Tooltips",
2192                                 (xpos+edgespace+(2.2*medprefbut)+(3*midspace)),y1,smallprefbut,buth,
2193                                 &(U.transopts), 0, 0, 0, 0, "Translate tooltips");
2194
2195                         uiDefButS(block, TOG|BIT|1, B_SETTRANSBUTS, "Buttons",
2196                                 (xpos+edgespace+(2.2*medprefbut)+(4*midspace)+smallprefbut),y1,smallprefbut,buth,
2197                                 &(U.transopts), 0, 0, 0, 0, "Translate button labels");
2198
2199                         uiDefButS(block, TOG|BIT|2, B_SETTRANSBUTS, "Toolbox",
2200                                 (xpos+edgespace+(2.2*medprefbut)+(5*midspace)+(2*smallprefbut)),y1,smallprefbut,buth,
2201                                 &(U.transopts), 0, 0, 0, 0, "Translate toolbox menu");
2202
2203                         uiDefButS(block, MENU|SHO, B_SETLANGUAGE, language_pup(),
2204                                 (xpos+edgespace+(2.2*medprefbut)+(3*midspace)),y2,medprefbut+(0.5*medprefbut)+3,buth,
2205                                 &U.language, 0, 0, 0, 0, "Select interface language");
2206                                 
2207                         /* uiDefButS(block, TOG|BIT|3, B_SETTRANSBUTS, "FTF All windows",
2208                                 (xpos+edgespace+(4*medprefbut)+(4*midspace)),y1,medprefbut,buth,
2209                                 &(U.transopts), 0, 0, 0, 0,
2210                                 "Use FTF drawing for fileselect and textwindow "
2211                                 "(under construction)");
2212                         */
2213                 }
2214
2215 /* end of INTERNATIONAL */
2216 #endif
2217
2218         } else if(U.userpref == 3) { /* auto save */
2219
2220
2221                 uiDefButS(block, TOG|BIT|0, B_RESETAUTOSAVE, "Auto Save Temp Files",
2222                         (xpos+edgespace),y2,medprefbut,buth,
2223                         &(U.flag), 0, 0, 0, 0,
2224                         "Enables automatic saving of temporary files");
2225
2226                 if(U.flag & AUTOSAVE) {
2227
2228                         uiDefBut(block, BUT, B_LOADTEMP, "Open Recent",
2229                                 (xpos+edgespace),y1,medprefbut,buth,
2230                                 0, 0, 0, 0, 0,"Opens the most recently saved temporary file");
2231
2232                         uiDefButI(block, NUM, B_RESETAUTOSAVE, "Minutes:",
2233                                 (xpos+edgespace+medprefbut+midspace),y2,medprefbut,buth,
2234                                 &(U.savetime), 1.0, 60.0, 0, 0,
2235                                 "The time (in minutes) to wait between automatic temporary saves");
2236
2237                         uiDefButS(block, NUM, 0, "Versions:",
2238                                 (xpos+edgespace+medprefbut+midspace),y1,medprefbut,buth,
2239                                 &U.versions, 0.0, 32.0, 0, 0,
2240                                 "The number of old versions to maintain when saving");
2241                 }
2242
2243         } else if (U.userpref == 4) { /* system & opengl */
2244                 uiDefBut(block, LABEL,0,"Solid OpenGL light:",
2245                         xpos+edgespace, y3label, medprefbut, buth,
2246                         0, 0, 0, 0, 0, "");
2247                 
2248                 uiDefButS(block, MENU, B_REDR, "Light1 %x0|Light2 %x1|Light3 %x2",
2249                         xpos+edgespace, y2, 2*medprefbut/6, buth, &cur_light, 0.0, 0.0, 0, 0, "");
2250                 uiBlockSetCol(block, TH_BUT_SETTING1);
2251                 uiDefButI(block, TOG|BIT|0, B_RECALCLIGHT, "On",
2252                         xpos+edgespace+2*medprefbut/6, y2, medprefbut/6, buth, 
2253                         &U.light[cur_light].flag, 0.0, 0.0, 0, 0, "");
2254                         
2255                 uiBlockSetCol(block, TH_AUTO);
2256                 uiDefButS(block, ROW, B_REDR, "Vec",
2257                         xpos+edgespace+3*medprefbut/6, y2, medprefbut/6, buth, 
2258                         &cur_light_var, 123.0, 0.0, 0, 0, "");
2259                 uiDefButS(block, ROW, B_REDR, "Col",
2260                         xpos+edgespace+4*medprefbut/6, y2, medprefbut/6, buth, 
2261                         &cur_light_var, 123.0, 1.0, 0, 0, "");
2262                 uiDefButS(block, ROW, B_REDR, "Spec",
2263                         xpos+edgespace+5*medprefbut/6, y2, medprefbut/6, buth, 
2264                         &cur_light_var, 123.0, 2.0, 0, 0, "");
2265
2266                 if(cur_light_var==1) {
2267                         uiDefButF(block, NUM, B_RECALCLIGHT, "R ",
2268                                 xpos+edgespace, y1, medprefbut/3, buth, 
2269                                 U.light[cur_light].col, 0.0, 1.0, 100, 2, "");
2270                         uiDefButF(block, NUM, B_RECALCLIGHT, "G ",
2271                                 xpos+edgespace+medprefbut/3, y1, medprefbut/3, buth, 
2272                                 U.light[cur_light].col+1, 0.0, 1.0, 100, 2, "");
2273                         uiDefButF(block, NUM, B_RECALCLIGHT, "B ",
2274                                 xpos+edgespace+2*medprefbut/3, y1, medprefbut/3, buth, 
2275                                 U.light[cur_light].col+2, 0.0, 1.0, 100, 2, "");
2276                 }
2277                 else if(cur_light_var==2) {
2278                         uiDefButF(block, NUM, B_RECALCLIGHT, "sR ",
2279                                 xpos+edgespace, y1, medprefbut/3, buth, 
2280                                 U.light[cur_light].spec, 0.0, 1.0, 100, 2, "");
2281                         uiDefButF(block, NUM, B_RECALCLIGHT, "sG ",
2282                                 xpos+edgespace+medprefbut/3, y1, medprefbut/3, buth, 
2283                                 U.light[cur_light].spec+1, 0.0, 1.0, 100, 2, "");
2284                         uiDefButF(block, NUM, B_RECALCLIGHT, "sB ",
2285                                 xpos+edgespace+2*medprefbut/3, y1, medprefbut/3, buth, 
2286                                 U.light[cur_light].spec+2, 0.0, 1.0, 100, 2, "");
2287                 }
2288                 else if(cur_light_var==0) {
2289                         uiDefButF(block, NUM, B_RECALCLIGHT, "X ",
2290                                 xpos+edgespace, y1, medprefbut/3, buth, 
2291                                 U.light[cur_light].vec, -1.0, 1.0, 100, 2, "");
2292                         uiDefButF(block, NUM, B_RECALCLIGHT, "Y ",
2293                                 xpos+edgespace+medprefbut/3, y1, medprefbut/3, buth, 
2294                                 U.light[cur_light].vec+1, -1.0, 1.0, 100, 2, "");
2295                         uiDefButF(block, NUM, B_RECALCLIGHT, "Z ",
2296                                 xpos+edgespace+2*medprefbut/3, y1, medprefbut/3, buth, 
2297                                 U.light[cur_light].vec+2, -1.0, 1.0, 100, 2, "");
2298                 }
2299
2300 /*
2301                 uiDefButS(block, TOG|BIT|5, 0, "Log Events to Console",
2302                         (xpos+edgespace),y2,largeprefbut,buth,
2303                         &(U.uiflag), 0, 0, 0, 0, "Display a list of input events in the console");
2304
2305                 uiDefButS(block, MENU|SHO, B_CONSOLEOUT, consolemethod_pup(),
2306                         (xpos+edgespace), y1, largeprefbut,buth,
2307                         &U.console_out, 0, 0, 0, 0, "Select console output method");
2308
2309                 uiDefButS(block, NUM, B_CONSOLENUMLINES, "Lines:",
2310                         (xpos+edgespace+largeprefbut+midspace),y1,smallprefbut,buth,
2311                         &U.console_buffer, 1.0, 4000.0, 0, 0, "Maximum number of internal console lines");
2312 */
2313
2314 #ifdef _WIN32
2315                 uiDefBut(block, LABEL,0,"Win Codecs:",
2316                         (xpos+edgespace+(1*midspace)+(1*medprefbut)),y3label,medprefbut,buth,
2317                         0, 0, 0, 0, 0, "");
2318
2319                 uiDefButS(block, TOG|BIT|8, 0, "Enable all codecs",
2320                         (xpos+edgespace+(1*medprefbut)+(1*midspace)),y2,medprefbut,buth,
2321                         &(U.uiflag), 0, 0, 0, 0, "Allows all codecs for rendering (not guaranteed)");
2322 #endif
2323
2324                 uiDefBut(block, LABEL,0,"Keyboard:",
2325                         (xpos+edgespace+(3*midspace)+(3*medprefbut)),y3label,medprefbut,buth,
2326                         0, 0, 0, 0, 0, "");
2327
2328                 uiDefButS(block, TOG|BIT|9, B_U_CAPSLOCK, "Disable Caps Lock",
2329                         (xpos+edgespace+(3*midspace)+(3*medprefbut)),y1,medprefbut,buth,
2330                         &(U.flag), 0, 0, 0, 0,
2331                         "Disables the Caps Lock key when entering text");
2332
2333                 uiDefButS(block, TOG|BIT|13, 0, "Emulate Numpad",
2334                         (xpos+edgespace+(3*midspace)+(3*medprefbut)),y2,medprefbut,buth,
2335                         &(U.flag), 0, 0, 0, 0,
2336                         "Causes the 1 to 0 keys to act as the numpad (useful for laptops)");
2337
2338
2339                 uiDefBut(block, LABEL,0,"System:",
2340                         (xpos+edgespace+(4*midspace)+(4*medprefbut)),y3label,medprefbut,buth,
2341                         0, 0, 0, 0, 0, "");
2342
2343                 uiDefButI(block, TOG|BIT|USERDEF_DISABLE_SOUND_BIT, B_SOUNDTOGGLE, "Disable Sound",
2344                         (xpos+edgespace+(4*medprefbut)+(4*midspace)),y2,medprefbut,buth,
2345                         &(U.gameflags), 0, 0, 0, 0, "Disables sounds from being played");
2346
2347                 uiDefButS(block, TOG|BIT|3, 0, "Filter File Extensions",
2348                         (xpos+edgespace+(4*medprefbut)+(4*midspace)),y1,medprefbut,buth,
2349                         &(U.uiflag), 0, 0, 0, 0, "Display only files with extensions in the image select window");
2350
2351
2352                 uiDefBut(block, LABEL,0,"OpenGL:",
2353                         (xpos+edgespace+(5*midspace)+(5*medprefbut)),y3label,medprefbut,buth,
2354                         0, 0, 0, 0, 0, "");
2355
2356                 uiDefButI(block, TOGN|BIT|USERDEF_DISABLE_MIPMAP_BIT, B_MIPMAPCHANGED, "Mipmaps",
2357                         (xpos+edgespace+(5*medprefbut)+(5*midspace)),y2,medprefbut,buth,
2358                         &(U.gameflags), 0, 0, 0, 0, "Toggles between mipmap textures on (beautiful) and off (fast)");
2359
2360                 uiDefButI(block, TOG|BIT|USERDEF_VERTEX_ARRAYS_BIT, 0, "Vertex Arrays",
2361                         (xpos+edgespace+(5*medprefbut)+(5*midspace)),y1,medprefbut,buth,
2362                         &(U.gameflags), 0, 0, 0, 0, "Toggles between vertex arrays on (less reliable) and off (more reliable)");
2363
2364                 uiDefBut(block, LABEL,0,"Audio:",
2365                         (xpos+edgespace+(2*midspace)+(2*medprefbut)),y3label,medprefbut,buth,
2366                         0, 0, 0, 0, 0, "");
2367
2368                 uiDefButI(block, ROW, 0, "Mixing buffer 256", (xpos+edgespace+(2*midspace)+(2*medprefbut)),y2,medprefbut,buth, &U.mixbufsize, 2.0, 256.0, 0, 0, "Set audio buffer size to 256 samples");
2369                 uiDefButI(block, ROW, 0, "512", (xpos+edgespace+(2*midspace)+(2*medprefbut)),y1,61,buth, &U.mixbufsize, 2.0, 512.0, 0, 0, "Set audio buffer size to 512 samples");      
2370                 uiDefButI(block, ROW, 0, "1024", (xpos+edgespace+(2*midspace)+(2*medprefbut))+61+midspace,y1,61,buth, &U.mixbufsize, 2.0, 1024.0, 0, 0, "Set audio buffer size to 1024 samples");               
2371                 uiDefButI(block, ROW, 0, "2048", (xpos+edgespace+(2*midspace)+(2*medprefbut))+2*(61+midspace),y1,61,buth, &U.mixbufsize, 2.0, 2048.0, 0, 0, "Set audio buffer size to 2048 samples");                   
2372
2373         } else if(U.userpref == 5) { /* file paths */
2374
2375
2376                 uiDefBut(block, TEX, 0, "Fonts: ",
2377                         (xpos+edgespace),y2,(largeprefbut-smfileselbut),buth,
2378                         U.fontdir, 1.0, 63.0, 0, 0,
2379                         "The default directory to search for loading fonts");
2380                 uiDefIconBut(block, BUT, B_FONTDIRFILESEL, ICON_FILESEL,
2381                         (xpos+edgespace+largeprefbut-smfileselbut),y2,smfileselbut,buth,
2382                         0, 0, 0, 0, 0, "Select the default font directory");
2383
2384                 uiDefBut(block, TEX, 0, "Textures: ",
2385                         (xpos+edgespace+largeprefbut+midspace),y2,(largeprefbut-smfileselbut),buth,
2386                         U.textudir, 1.0, 63.0, 0, 0, "The default directory to search for textures");
2387                 uiDefIconBut(block, BUT, B_TEXTUDIRFILESEL, ICON_FILESEL,
2388                         (xpos+edgespace+(2*largeprefbut)+midspace-smfileselbut),y2,smfileselbut,buth,
2389                         0, 0, 0, 0, 0, "Select the default texture location");
2390
2391
2392                 uiDefBut(block, TEX, 0, "Tex Plugins: ",
2393                         (xpos+edgespace+(2*largeprefbut)+(2*midspace)),y2,(largeprefbut-smfileselbut),buth,
2394                         U.plugtexdir, 1.0, 63.0, 0, 0, "The default directory to search for texture plugins");
2395                 uiDefIconBut(block, BUT, B_PLUGTEXDIRFILESEL, ICON_FILESEL,
2396                         (xpos+edgespace+(3*largeprefbut)+(2*midspace)-smfileselbut),y2,smfileselbut,buth,
2397                         0, 0, 0, 0, 0, "Select the default texture plugin location");
2398
2399                 uiDefBut(block, TEX, 0, "Seq Plugins: ",
2400                         (xpos+edgespace+(3*largeprefbut)+(3*midspace)),y2,(largeprefbut-smfileselbut),buth,
2401                         U.plugseqdir, 1.0, 63.0, 0, 0, "The default directory to search for sequence plugins");
2402                 uiDefIconBut(block, BUT, B_PLUGSEQDIRFILESEL, ICON_FILESEL,
2403                         (xpos+edgespace+(4*largeprefbut)+(3*midspace)-smfileselbut),y2,smfileselbut,buth,
2404                         0, 0, 0, 0, 0, "Select the default sequence plugin location");
2405
2406
2407                 uiDefBut(block, TEX, 0, "Render: ",
2408                         (xpos+edgespace),y1,(largeprefbut-smfileselbut),buth,
2409                         U.renderdir, 1.0, 63.0, 0, 0, "The default directory for rendering output");
2410                 uiDefIconBut(block, BUT, B_RENDERDIRFILESEL, ICON_FILESEL,
2411                         (xpos+edgespace+largeprefbut-smfileselbut),y1,smfileselbut,buth,
2412                         0, 0, 0, 0, 0, "Select the default render output location");
2413
2414                 uiDefBut(block, TEX, 0, "Python: ",
2415                         (xpos+edgespace+largeprefbut+midspace),y1,(largeprefbut-smfileselbut),buth,
2416                         U.pythondir, 1.0, 63.0, 0, 0, "The default directory to search for Python scripts");
2417                 uiDefIconBut(block, BUT, B_PYTHONDIRFILESEL, ICON_FILESEL,
2418                         (xpos+edgespace+(2*largeprefbut)+midspace-smfileselbut),y1,smfileselbut,buth,
2419                         0, 0, 0, 0, 0, "Select the default Python script location");
2420
2421
2422                 uiDefBut(block, TEX, 0, "Sounds: ",
2423                         (xpos+edgespace+(2*largeprefbut)+(2*midspace)),y1,(largeprefbut-smfileselbut),buth,
2424                         U.sounddir, 1.0, 63.0, 0, 0, "The default directory to search for sounds");
2425                 uiDefIconBut(block, BUT, B_SOUNDDIRFILESEL, ICON_FILESEL,
2426                         (xpos+edgespace+(3*largeprefbut)+(2*midspace)-smfileselbut),y1,smfileselbut,buth,
2427                         0, 0, 0, 0, 0, "Select the default sound location");
2428
2429                 uiDefBut(block, TEX, 0, "Temp: ",
2430                          (xpos+edgespace+(3*largeprefbut)+(3*midspace)),y1,(largeprefbut-smfileselbut),buth,
2431                          U.tempdir, 1.0, 63.0, 0, 0, "The directory for storing temporary save files");
2432                 uiDefIconBut(block, BUT, B_TEMPDIRFILESEL, ICON_FILESEL,
2433                         (xpos+edgespace+(4*largeprefbut)+(3*midspace)-smfileselbut),y1,smfileselbut,buth,
2434                         0, 0, 0, 0, 0, "Select the default temporary save file location");
2435
2436         }
2437
2438         uiDrawBlock(block);
2439         
2440         myortho2(-0.5, (float)(sa->winx)-.05, -0.5, (float)(sa->winy)-0.5);
2441         draw_area_emboss(sa);
2442         myortho2(0.0, 1280.0, 0.0, curarea->winy/fac);
2443         sa->win_swap= WIN_BACK_OK;
2444         
2445 }
2446
2447
2448 void winqreadinfospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
2449 {
2450         unsigned short event= evt->event;
2451         short val= evt->val;
2452         
2453         if(val) {
2454                 if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
2455
2456                 switch(event) {
2457                 case UI_BUT_EVENT:
2458                         if(val==B_ADD_THEME) {
2459                                 bTheme *btheme, *new;
2460                                 
2461                                 btheme= U.themes.first;
2462                                 new= MEM_callocN(sizeof(bTheme), "theme");
2463                                 memcpy(new, btheme, sizeof(bTheme));
2464                                 BLI_addhead(&U.themes, new);
2465                                 strcpy(new->name, "New User Theme");
2466                                 addqueue(sa->win, REDRAW, 1);
2467                         }
2468                         else if(val==B_DEL_THEME) {
2469                                 bTheme *btheme= U.themes.first;
2470                                 BLI_remlink(&U.themes, btheme);
2471                                 MEM_freeN(btheme);
2472                                 BIF_SetTheme(curarea); // prevent usage of old theme in calls   
2473                                 addqueue(sa->win, REDRAW, 1);
2474                         }
2475                         else if(val==B_NAME_THEME) {
2476                                 bTheme *btheme= U.themes.first;
2477                                 if(strcmp(btheme->name, "Default")==0) {
2478                                         strcpy(btheme->name, "New User Theme");
2479                                         addqueue(sa->win, REDRAW, 1);
2480                                 }
2481                         }
2482                         else if(val==B_UPDATE_THEME) {
2483                                 allqueue(REDRAWALL, 0);
2484                         }
2485                         else if(val==B_CHANGE_THEME) {
2486                                 th_curcol= TH_BACK;     // backdrop color is always there...
2487                                 addqueue(sa->win, REDRAW, 1);
2488                         }
2489                         else if(val==B_THEME_COPY) {
2490                                 if(th_curcol_ptr) {
2491                                         th_curcol_arr[0]= th_curcol_ptr[0];
2492                                         th_curcol_arr[1]= th_curcol_ptr[1];
2493                                         th_curcol_arr[2]= th_curcol_ptr[2];
2494                                         th_curcol_arr[3]= th_curcol_ptr[3];
2495                                         addqueue(sa->win, REDRAW, 1);
2496                                 }
2497                         }
2498                         else if(val==B_THEME_PASTE) {
2499                                 if(th_curcol_ptr) {
2500                                         th_curcol_ptr[0]= th_curcol_arr[0];
2501                                         th_curcol_ptr[1]= th_curcol_arr[1];
2502                                         th_curcol_ptr[2]= th_curcol_arr[2];
2503                                         th_curcol_ptr[3]= th_curcol_arr[3];
2504                                         allqueue(REDRAWALL, 0);
2505                                 }
2506                         }
2507                         else if(val==B_RECALCLIGHT) {
2508                                 if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0)
2509                                         U.light[0].flag= 1;
2510                                 
2511                                 default_gl_light();
2512                                 addqueue(sa->win, REDRAW, 1);
2513                                 allqueue(REDRAWVIEW3D, 0);
2514                         }
2515                         else do_global_buttons(val);
2516                         
2517                         break;  
2518                 }
2519         }
2520 }
2521
2522 void init_infospace(ScrArea *sa)
2523 {
2524         SpaceInfo *sinfo;
2525         
2526         sinfo= MEM_callocN(sizeof(SpaceInfo), "initinfo");
2527         BLI_addhead(&sa->spacedata, sinfo);
2528
2529         sinfo->spacetype=SPACE_INFO;
2530 }
2531
2532 /* ******************** SPACE: BUTS ********************** */
2533
2534 extern void drawbutspace(ScrArea *sa, void *spacedata); /* buttons.c */
2535
2536 static void changebutspace(ScrArea *sa, void *spacedata)
2537 {
2538         if(G.v2d==0) return;
2539         
2540         test_view2d(G.v2d, curarea->winx, curarea->winy);
2541         myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin-0.6, G.v2d->cur.ymax+0.6);
2542 }
2543
2544 void winqreadbutspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
2545 {
2546         unsigned short event= evt->event;
2547         short val= evt->val;
2548         SpaceButs *sbuts= curarea->spacedata.first;
2549         ScrArea *sa2, *sa3d;
2550         int nr, doredraw= 0;
2551
2552         if(val) {
2553                 
2554                 if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
2555
2556                 switch(event) {
2557                 case UI_BUT_EVENT:
2558                         do_butspace(val);
2559                         break;
2560                         
2561                 case MIDDLEMOUSE:
2562                 case WHEELUPMOUSE:
2563                 case WHEELDOWNMOUSE:
2564                         view2dmove(event);      /* in drawipo.c */
2565                         break;
2566                 case PAGEUPKEY:
2567                         event= WHEELUPMOUSE;
2568                         view2dmove(event);      /* in drawipo.c */
2569                         break;
2570                 case PAGEDOWNKEY:
2571                         event= WHEELDOWNMOUSE;
2572                         view2dmove(event);      /* in drawipo.c */
2573                         break;
2574                         
2575                 case RIGHTMOUSE:
2576                         nr= pupmenu("Align buttons%t|Free %x0|Horizontal%x1|Vertical%x2");
2577                         if (nr>=0) {
2578                                 sbuts->align= nr;
2579                                 if(nr) {
2580                                         uiAlignPanelStep(sa, 1.0);
2581                                         do_buts_buttons(B_BUTSHOME);
2582                                 }
2583                         }
2584
2585                         break;
2586                 case PADPLUSKEY:
2587                         view2d_zoom(&sbuts->v2d, 0.06f, curarea->winx, curarea->winy);
2588                         scrarea_queue_winredraw(curarea);
2589                         break;
2590                 case PADMINUS:
2591                         view2d_zoom(&sbuts->v2d, -0.075f, curarea->winx, curarea->winy);
2592                         scrarea_queue_winredraw(curarea);
2593                         break;
2594                 case RENDERPREVIEW:
2595                         BIF_previewrender(sbuts);
2596                         break;
2597                 
2598                 case HOMEKEY:
2599                         do_buts_buttons(B_BUTSHOME);
2600                         break;
2601
2602
2603                 /* if only 1 view, also de persp, excluding arrowkeys */
2604                 case PAD0: case PAD1: case PAD3:
2605                 case PAD5: case PAD7: case PAD9:
2606                 case PADENTER: case ZKEY: case PKEY:
2607                         sa3d= 0;
2608                         sa2= G.curscreen->areabase.first;
2609                         while(sa2) {
2610                                 if(sa2->spacetype==SPACE_VIEW3D) {
2611                                         if(sa3d) return;
2612                                         sa3d= sa2;
2613                                 }
2614                                 sa2= sa2->next;
2615                         }
2616                         if(sa3d) {
2617                                 sa= curarea;
2618                                 areawinset(sa3d->win);
2619                                 
2620                                 if(event==PKEY) start_game();
2621                                 else if(event==ZKEY) toggle_shading();
2622                                 else persptoetsen(event);
2623                                 
2624                                 scrarea_queue_winredraw(sa3d);
2625                                 scrarea_queue_headredraw(sa3d);
2626                                 areawinset(sa->win);
2627                         }
2628                 }
2629         }
2630
2631         if(doredraw) scrarea_queue_winredraw(curarea);
2632 }
2633
2634 void set_rects_butspace(SpaceButs *buts)
2635 {
2636         /* buts space goes from (0,0) to (1280, 228) */
2637
2638         buts->v2d.tot.xmin= 0.0f;
2639         buts->v2d.tot.ymin= 0.0f;
2640         buts->v2d.tot.xmax= 1279.0f;
2641         buts->v2d.tot.ymax= 228.0f;
2642         
2643         buts->v2d.min[0]= 256.0f;
2644         buts->v2d.min[1]= 42.0f;
2645
2646         buts->v2d.max[0]= 2048.0f;
2647         buts->v2d.max[1]= 450.0f;
2648         
2649         buts->v2d.minzoom= 0.5f;
2650         buts->v2d.maxzoom= 1.21f;
2651         
2652         buts->v2d.scroll= 0;
2653         buts->v2d.keepaspect= 1;
2654         buts->v2d.keepzoom= 1;
2655         buts->v2d.keeptot= 1;
2656         
2657 }
2658
2659 void test_butspace(void)
2660 {
2661         ScrArea *area= curarea;
2662         int blocksmin= uiBlocksGetYMin(&area->uiblocks)-10.0;
2663         
2664         G.buts->v2d.tot.ymin= MIN2(0.0, blocksmin-10.0);
2665 }
2666
2667 void init_butspace(ScrArea *sa)
2668 {
2669         SpaceButs *buts;
2670         
2671         buts= MEM_callocN(sizeof(SpaceButs), "initbuts");
2672         BLI_addhead(&sa->spacedata, buts);
2673
2674         buts->spacetype= SPACE_BUTS;
2675         buts->scaflag= BUTS_SENS_LINK|BUTS_SENS_ACT|BUTS_CONT_ACT|BUTS_ACT_ACT|BUTS_ACT_LINK;
2676
2677         /* set_rects only does defaults, so after reading a file the cur has not changed */
2678         set_rects_butspace(buts);
2679         buts->v2d.cur= buts->v2d.tot;
2680 }
2681
2682 void extern_set_butspace(int fkey)
2683 {
2684         ScrArea *sa;
2685         SpaceButs *sbuts;
2686         
2687         /* when a f-key pressed: closest button window is initialized */
2688         if(curarea->spacetype==SPACE_BUTS) sa= curarea;
2689         else {
2690                 /* find area */
2691                 sa= G.curscreen->areabase.first;
2692                 while(sa) {
2693                         if(sa->spacetype==SPACE_BUTS) break;
2694                         sa= sa->next;
2695                 }
2696         }
2697         
2698         if(sa==0) return;
2699         
2700         if(sa!=curarea) areawinset(sa->win);
2701         
2702         sbuts= sa->spacedata.first;
2703         
2704         if(fkey==F4KEY) {
2705                 sbuts->mainb= CONTEXT_LOGIC;
2706         }
2707         else if(fkey==F5KEY) {
2708                 sbuts->mainb= CONTEXT_SHADING;
2709                 if(OBACT) {
2710                         if(OBACT->type==OB_CAMERA) 
2711                                 sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_WORLD;
2712                         else if(OBACT->type==OB_LAMP) 
2713                                 sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP;
2714                         else  
2715                                 sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
2716                 }
2717                 else sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT;
2718         }
2719         else if(fkey==F6KEY) {
2720                 sbuts->mainb= CONTEXT_SHADING;
2721                 sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX;
2722         }
2723         else if(fkey==F7KEY) sbuts->mainb= CONTEXT_OBJECT;
2724         else if(fkey==F8KEY) {
2725                 sbuts->mainb= CONTEXT_SHADING;
2726                 sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_WORLD;
2727         }
2728         else if(fkey==F9KEY) sbuts->mainb= CONTEXT_EDITING;
2729         else if(fkey==F10KEY) sbuts->mainb= CONTEXT_SCENE;
2730
2731         scrarea_queue_headredraw(sa);
2732         scrarea_queue_winredraw(sa);
2733         BIF_preview_changed(sbuts);
2734 }
2735
2736 /* ******************** SPACE: SEQUENCE ********************** */
2737
2738 /*  extern void drawseqspace(ScrArea *sa, void *spacedata); BIF_drawseq.h */
2739
2740 void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
2741 {
2742         unsigned short event= evt->event;
2743         short val= evt->val;
2744         SpaceSeq *sseq= curarea->spacedata.first;
2745         View2D *v2d= &sseq->v2d;
2746         extern Sequence *last_seq;
2747         float dx, dy;
2748         int doredraw= 0, cfra, first;
2749         short mval[2];
2750         
2751         if(curarea->win==0) return;
2752
2753         if(val) {
2754                 
2755                 if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
2756
2757                 switch(event) {
2758                 case LEFTMOUSE:
2759                         if(sseq->mainb || view2dmove(event)==0) {
2760                                 
2761                                 first= 1;               
2762                                 set_special_seq_update(1);
2763
2764                                 do {
2765                                         getmouseco_areawin(mval);
2766                                         areamouseco_to_ipoco(v2d, mval, &dx, &dy);
2767                                         
2768                                         cfra= (int)dx;
2769                                         if(cfra< 1) cfra= 1;
2770                                         /* else if(cfra> EFRA) cfra= EFRA; */
2771                                         
2772                                         if( cfra!=CFRA || first ) {
2773                                                 first= 0;
2774                                 
2775                                                 CFRA= cfra;
2776                                                 force_draw();
2777                                                 update_for_newframe();  /* for audio scrubbing */                                               
2778                                         }
2779                                 
2780                                 } while(get_mbut()&L_MOUSE);
2781                                 
2782                                 set_special_seq_update(0);
2783                                 
2784                                 update_for_newframe();
2785                         }
2786                         break;
2787                 case MIDDLEMOUSE:
2788                 case WHEELUPMOUSE:
2789                 case WHEELDOWNMOUSE:
2790                         if(sseq->mainb) break;
2791                         view2dmove(event);      /* in drawipo.c */
2792                         break;
2793                 case RIGHTMOUSE:
2794                         if(sseq->mainb) break;
2795                         mouse_select_seq();
2796                         break;
2797                 case PADPLUSKEY:
2798                         if(sseq->mainb) {
2799                                 sseq->zoom++;
2800                                 if(sseq->zoom>8) sseq->zoom= 8;
2801                         }
2802                         else {
2803                                 if((G.qual==0)) {
2804                                         dx= 0.1154*(v2d->cur.xmax-v2d->cur.xmin);
2805                                         v2d->cur.xmin+= dx;
2806                                         v2d->cur.xmax-= dx;
2807                                         test_view2d(G.v2d, curarea->winx, curarea->winy);
2808                                 }
2809                                 else if((G.qual==LR_SHIFTKEY)) {
2810                                         insert_gap(25, CFRA);
2811                                         allqueue(REDRAWSEQ, 0);
2812                                 }
2813                                 else if(G.qual==LR_ALTKEY) {
2814                                         insert_gap(250, CFRA);
2815                                         allqueue(REDRAWSEQ, 0);
2816                                 }
2817                         }
2818                         doredraw= 1;
2819                         break;
2820                 case PADMINUS:
2821                         if(sseq->mainb) {
2822                                 sseq->zoom--;
2823                                 if(sseq->zoom<1) sseq->zoom= 1;
2824                         }
2825                         else {
2826                                 if((G.qual==LR_SHIFTKEY))
2827                                         no_gaps();
2828                                 else if((G.qual==0)) {
2829                                         dx= 0.15*(v2d->cur.xmax-v2d->cur.xmin);
2830                                         v2d->cur.xmin-= dx;
2831                                         v2d->cur.xmax+= dx;
2832                                         test_view2d(G.v2d, curarea->winx, curarea->winy);
2833                                 }
2834                         }
2835                         doredraw= 1;
2836                         break;
2837                 case HOMEKEY:
2838                         if((G.qual==0))
2839                                 do_seq_buttons(B_SEQHOME);
2840