4 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
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
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.
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.
23 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24 * All rights reserved.
26 * The Original Code is: all of this file.
28 * Contributor(s): none yet.
30 * ***** END GPL/BL DUAL LICENSE BLOCK *****
33 * - here initialize and free and handling SPACE data
44 #include "BLI_winstuff.h"
47 #include "MEM_guardedalloc.h"
50 #include "BIF_language.h"
53 #include "IMB_imbuf_types.h"
54 #include "IMB_imbuf.h"
56 #include "BLI_blenlib.h"
57 #include "BLI_arithb.h"
58 #include "BLI_linklist.h"
60 #include "DNA_action_types.h"
61 #include "DNA_curve_types.h"
62 #include "DNA_image_types.h"
63 #include "DNA_ipo_types.h"
64 #include "DNA_mesh_types.h"
65 #include "DNA_object_types.h"
66 #include "DNA_scene_types.h"
67 #include "DNA_screen_types.h"
68 #include "DNA_sequence_types.h"
69 #include "DNA_sound_types.h"
70 #include "DNA_space_types.h"
71 #include "DNA_userdef_types.h"
72 #include "DNA_view2d_types.h"
73 #include "DNA_view3d_types.h"
75 #include "BKE_blender.h"
76 #include "BKE_curve.h"
77 #include "BKE_displist.h"
78 #include "BKE_global.h"
81 #include "BKE_scene.h"
82 #include "BKE_utildefines.h"
84 #include "BIF_butspace.h"
85 #include "BIF_drawimage.h"
86 #include "BIF_drawseq.h"
87 #include "BIF_drawtext.h"
88 #include "BIF_drawscript.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"
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"
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"
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 #include "BDR_unwrapper.h"
133 #include "BLO_readfile.h" /* for BLO_blendhandle_close */
135 #include "BPY_extern.h"
137 #include "mydevice.h"
141 #include "TPT_DependKludge.h"
143 #include "BSE_trans_types.h"
147 #include "SYS_System.h" /* for the user def menu ... should move elsewhere. */
149 extern void StartKetsjiShell(ScrArea *area, char* startscenename, struct Main* maggie, int always_use_expand_framing);
152 * When the mipmap setting changes, we want to redraw the view right
153 * away to reflect this setting.
155 void space_mipmap_button_function(int event);
157 unsigned short convert_for_nonumpad(unsigned short event);
158 void free_soundspace(SpaceSound *ssound);
160 /* *************************************** */
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!
165 void add_blockhandler(ScrArea *sa, short eventcode, short val)
167 SpaceLink *sl= sa->spacedata.first;
171 for(a=0; a<SPACE_MAXHANDLER; a+=2) {
172 if( sl->blockhandler[a]==eventcode ) {
173 sl->blockhandler[a+1]= val;
176 else if( sl->blockhandler[a]==0) {
177 sl->blockhandler[a]= eventcode;
178 sl->blockhandler[a+1]= val;
182 if(a==SPACE_MAXHANDLER) printf("error; max (4) blockhandlers reached!\n");
185 void rem_blockhandler(ScrArea *sa, short eventcode)
187 SpaceLink *sl= sa->spacedata.first;
190 for(a=0; a<SPACE_MAXHANDLER; a+=2) {
191 if( sl->blockhandler[a]==eventcode) {
192 sl->blockhandler[a]= 0;
198 void toggle_blockhandler(ScrArea *sa, short eventcode, short val)
200 SpaceLink *sl= sa->spacedata.first;
204 for(a=0; a<SPACE_MAXHANDLER; a+=2) {
205 if( sl->blockhandler[a]==eventcode ) {
206 sl->blockhandler[a]= 0;
210 if(addnew) add_blockhandler(sa, eventcode, val);
215 /* ************* SPACE: VIEW3D ************* */
217 /* extern void drawview3dspace(ScrArea *sa, void *spacedata); BSE_drawview.h */
220 void copy_view3d_lock(short val)
225 /* from G.scene copy to the other views */
226 sc= G.main->screen.first;
229 if(sc->scene==G.scene) {
230 ScrArea *sa= sc->areabase.first;
232 SpaceLink *sl= sa->spacedata.first;
234 if(sl->spacetype==SPACE_OOPS && val==REDRAW) {
235 if(sa->win) scrarea_queue_winredraw(sa);
237 else if(sl->spacetype==SPACE_VIEW3D) {
238 View3D *vd= (View3D*) sl;
239 if(vd->scenelock && vd->localview==0) {
240 vd->lay= G.scene->lay;
241 vd->camera= G.scene->camera;
243 if(vd->camera==0 && vd->persp>1) vd->persp= 1;
245 if( (vd->lay & vd->layact) == 0) {
248 if(vd->lay & (1<<bit)) {
256 if(val==REDRAW && vd==sa->spacedata.first) {
257 if(sa->win) scrarea_queue_redraw(sa);
270 void handle_view3d_around()
274 if ((U.uiflag & USER_LOCKAROUND)==0) return;
276 /* copies from G.vd->around to other view3ds */
278 sc= G.main->screen.first;
281 if(sc->scene==G.scene) {
282 ScrArea *sa= sc->areabase.first;
284 SpaceLink *sl= sa->spacedata.first;
286 if(sl->spacetype==SPACE_VIEW3D) {
287 View3D *vd= (View3D*) sl;
289 vd->around= G.vd->around;
290 if (G.vd->flag & V3D_ALIGN)
291 vd->flag |= V3D_ALIGN;
293 vd->flag &= ~V3D_ALIGN;
294 scrarea_queue_headredraw(sa);
306 void handle_view3d_lock()
309 if(G.vd->localview==0 && G.vd->scenelock && curarea->spacetype==SPACE_VIEW3D) {
312 G.scene->lay= G.vd->lay;
313 G.scene->camera= G.vd->camera;
315 copy_view3d_lock(REDRAW);
320 void space_set_commmandline_options(void) {
321 SYS_SystemHandle syshandle;
324 if ( (syshandle = SYS_GetSystem()) ) {
325 /* User defined settings */
326 a= (U.gameflags & USER_VERTEX_ARRAYS);
327 SYS_WriteCommandLineInt(syshandle, "vertexarrays", a);
329 a= (U.gameflags & USER_DISABLE_SOUND);
330 SYS_WriteCommandLineInt(syshandle, "noaudio", a);
332 a= (U.gameflags & USER_DISABLE_MIPMAP);
334 SYS_WriteCommandLineInt(syshandle, "nomipmap", a);
336 /* File specific settings: */
337 /* Only test the first one. These two are switched
339 a= (G.fileflags & G_FILE_SHOW_FRAMERATE);
340 SYS_WriteCommandLineInt(syshandle, "show_framerate", a);
341 SYS_WriteCommandLineInt(syshandle, "show_profile", a);
343 /* When in wireframe mode, always draw debug props. */
345 a = ( (G.fileflags & G_FILE_SHOW_DEBUG_PROPS)
346 || (G.vd->drawtype == OB_WIRE)
347 || (G.vd->drawtype == OB_SOLID) );
348 SYS_WriteCommandLineInt(syshandle, "show_properties", a);
351 a= (G.fileflags & G_FILE_ENABLE_ALL_FRAMES);
352 SYS_WriteCommandLineInt(syshandle, "fixedtime", a);
358 * These two routines imported from the gameengine,
359 * I suspect a lot of the resetting stuff is cruft
360 * and can be removed, but it should be checked.
362 static void SaveState(void)
364 glPushAttrib(GL_ALL_ATTRIB_BITS);
369 if(G.scene->camera==0 || G.scene->camera->type!=OB_CAMERA)
370 error("no (correct) camera");
375 static void RestoreState(void)
377 curarea->win_swap = 0;
378 curarea->head_swap=0;
379 allqueue(REDRAWVIEW3D, 0);
380 allqueue(REDRAWBUTSALL, 0);
387 static LinkNode *save_and_reset_all_scene_cfra(void)
389 LinkNode *storelist= NULL;
392 for (sc= G.main->scene.first; sc; sc= sc->id.next) {
393 BLI_linklist_prepend(&storelist, (void*) (long) sc->r.cfra);
399 BLI_linklist_reverse(&storelist);
404 static void restore_all_scene_cfra(LinkNode *storelist) {
405 LinkNode *sc_store= storelist;
408 for (sc= G.main->scene.first; sc; sc= sc->id.next) {
409 int stored_cfra= (int) sc_store->link;
411 sc->r.cfra= stored_cfra;
414 sc_store= sc_store->next;
417 BLI_linklist_free(storelist, NULL);
421 void start_game(void)
425 Scene *sc, *startscene = G.scene;
426 LinkNode *scene_cfra_store;
428 /* XXX, silly code - the game engine can
429 * access any scene through logic, so we try
430 * to make sure each scene has a valid camera,
431 * just in case the game engine tries to use it.
433 * Better would be to make a better routine
434 * in the game engine for finding the camera.
437 for (sc= G.main->scene.first; sc; sc= sc->id.next) {
441 for (base= sc->base.first; base; base= base->next)
442 if (base->object->type==OB_CAMERA)
445 sc->camera= base?base->object:NULL;
449 /* these two lines make sure front and backbuffer are equal. for swapbuffers */
451 screen_swapbuffers();
453 /* can start from header */
454 mywinset(curarea->win);
456 scene_cfra_store= save_and_reset_all_scene_cfra();
459 /* sound init is save, only handles once */
461 sound_stop_all_sounds();
463 /* Before jumping into Ketsji, we configure some settings. */
464 space_set_commmandline_options();
467 StartKetsjiShell(curarea, startscene->id.name+2, G.main, 1);
470 /* Restart BPY - unload the game engine modules. */
474 restore_all_scene_cfra(scene_cfra_store);
475 set_scene_bg(startscene);
477 if (G.flags & G_FLAGS_AUTOPLAY)
480 /* groups could have changed ipo */
481 allqueue(REDRAWNLA, 0);
482 allqueue(REDRAWACTION, 0);
483 allspace(REMAKEIPO, 0);
484 allqueue(REDRAWIPO, 0);
487 notice("Game engine is disabled in this release!");
491 static void changeview3dspace(ScrArea *sa, void *spacedata)
493 setwinmatrixview3d(0); /* 0= no pick rect */
496 /* Callable from editmode and faceselect mode from the
497 * moment, would be nice (and is easy) to generalize
500 static void align_view_to_selected(View3D *v3d)
502 int nr= pupmenu("Align View%t|To Selected (top)%x2|To Selected (front)%x1|To Selected (side)%x0");
507 if ((G.obedit) && (G.obedit->type == OB_MESH)) {
508 editmesh_align_view_to_selected(v3d, axis);
509 addqueue(v3d->area->win, REDRAW, 1);
510 } else if (G.f & G_FACESELECT) {
511 Object *obact= OBACT;
512 if (obact && obact->type==OB_MESH) {
513 Mesh *me= obact->data;
516 faceselect_align_view_to_selected(v3d, me, axis);
517 addqueue(v3d->area->win, REDRAW, 1);
524 void select_children(Object *ob, int recursive)
528 for (base= FIRSTBASE; base; base= base->next)
529 if (ob == base->object->parent) {
530 base->flag |= SELECT;
531 base->object->flag |= SELECT;
532 if (recursive) select_children(base->object, 1);
536 void select_parent(void) /* Makes parent active and de-selected OBACT */
538 Base *base, *startbase, *basact=NULL, *oldbasact;
540 if (!(OBACT->parent)) return;
541 BASACT->flag &= (~SELECT);
542 BASACT->object->flag &= (~SELECT);
543 startbase= FIRSTBASE;
544 if(BASACT && BASACT->next) startbase= BASACT->next;
547 if(base->object==BASACT->object->parent) { basact=base; break; }
549 if(base==0) base= FIRSTBASE;
550 if(base==startbase) break;
554 basact->flag |= SELECT;
556 basact->object->flag= basact->flag;
558 set_active_base(basact);
562 void select_group_menu(void)
567 /* make menu string */
569 str= MEM_mallocN(160, "groupmenu");
570 strcpy(str, "Select Grouped%t|Children%x1|"
571 "Immediate Children%x2|Parent%x3|"
572 "Objects on Shared Layers%x4");
582 void select_group(short nr)
589 if (base->lay & OBACT->lay) {
590 base->flag |= SELECT;
591 base->object->flag |= SELECT;
596 else if(nr==2) select_children(OBACT, 0);
597 else if(nr==1) select_children(OBACT, 1);
598 else if(nr==3) select_parent();
600 allqueue(REDRAWVIEW3D, 0);
601 allqueue(REDRAWBUTSOBJECT, 0);
602 allspace(REMAKEIPO, 0);
603 allqueue(REDRAWIPO, 0);
606 static unsigned short convert_for_nonumpad(unsigned short event)
608 if (event>=ZEROKEY && event<=NINEKEY) {
609 return event - ZEROKEY + PAD0;
610 } else if (event==MINUSKEY) {
612 } else if (event==EQUALKEY) {
614 } else if (event==BACKSLASHKEY) {
621 void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
623 unsigned short event= evt->event;
625 char ascii= evt->ascii;
626 View3D *v3d= curarea->spacedata.first;
629 int doredraw= 0, pupval;
631 if(curarea->win==0) return; /* when it comes from sa->headqread() */
635 if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
636 if(event==MOUSEY) return;
638 if(event==UI_BUT_EVENT) do_butspace(val); // temporal, view3d deserves own queue?
640 /* swap mouse buttons based on user preference */
641 if (U.flag & USER_LMOUSESELECT) {
642 if (evt->event == LEFTMOUSE) {
644 } else if (evt->event == RIGHTMOUSE) {
650 if((G.obedit) && G.obedit->type==OB_FONT) {
657 /* use '&' here, because of alt+leftmouse which emulates middlemouse */
658 if(U.flag & USER_VIEWMOVE) {
659 if((G.qual==LR_SHIFTKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_SHIFTKEY))))
661 else if((G.qual==LR_CTRLKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_CTRLKEY))))
663 else if((G.qual==0) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==LR_ALTKEY)))
667 if((G.qual==LR_SHIFTKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_SHIFTKEY))))
669 else if((G.qual==LR_CTRLKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_CTRLKEY))))
677 /* Regular: Zoom in */
678 /* Shift: Scroll up */
679 /* Ctrl: Scroll right */
680 /* Alt-Shift: Rotate up */
681 /* Alt-Ctrl: Rotate right */
683 if( G.qual & LR_SHIFTKEY ) {
684 if( G.qual & LR_ALTKEY ) {
685 G.qual &= ~LR_SHIFTKEY;
687 G.qual |= LR_SHIFTKEY;
691 } else if( G.qual & LR_CTRLKEY ) {
692 if( G.qual & LR_ALTKEY ) {
693 G.qual &= ~LR_CTRLKEY;
695 G.qual |= LR_CTRLKEY;
699 } else if(U.uiflag & USER_WHEELZOOMDIR)
700 persptoetsen(PADMINUS);
702 persptoetsen(PADPLUSKEY);
708 /* Regular: Zoom out */
709 /* Shift: Scroll down */
710 /* Ctrl: Scroll left */
711 /* Alt-Shift: Rotate down */
712 /* Alt-Ctrl: Rotate left */
714 if( G.qual & LR_SHIFTKEY ) {
715 if( G.qual & LR_ALTKEY ) {
716 G.qual &= ~LR_SHIFTKEY;
718 G.qual |= LR_SHIFTKEY;
722 } else if( G.qual & LR_CTRLKEY ) {
723 if( G.qual & LR_ALTKEY ) {
724 G.qual &= ~LR_CTRLKEY;
726 G.qual |= LR_CTRLKEY;
730 } else if(U.uiflag & USER_WHEELZOOMDIR)
731 persptoetsen(PADPLUSKEY);
733 persptoetsen(PADMINUS);
739 if(G.qual==LR_ALTKEY) {
744 do_textedit(event, val, ascii);
748 if(G.qual==LR_ALTKEY) {
753 do_textedit(event, val, ascii);
756 case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
757 case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
764 do_textedit(event, val, ascii);
770 if (U.flag & USER_NONUMPAD) {
771 event= convert_for_nonumpad(event);
780 /* LEFTMOUSE and RIGHTMOUSE event codes can be swapped above,
781 * based on user preference USER_LMOUSESELECT
784 if ((G.obedit) || !(G.f&(G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) {
786 } else if (G.f & G_VERTEXPAINT) {
789 else if (G.f & G_WEIGHTPAINT){
792 else if (G.f & G_TEXTUREPAINT) {
797 /* use '&' here, because of alt+leftmouse which emulates middlemouse */
798 if(U.flag & USER_VIEWMOVE) {
799 if((G.qual==LR_SHIFTKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_SHIFTKEY))))
801 else if((G.qual==LR_CTRLKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_CTRLKEY))))
803 else if((G.qual==0) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==LR_ALTKEY)))
807 if((G.qual==LR_SHIFTKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_SHIFTKEY))))
809 else if((G.qual==LR_CTRLKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_CTRLKEY))))
811 else if((G.qual==0) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==LR_ALTKEY)))
816 if((G.obedit) && (G.qual & LR_CTRLKEY)==0) {
817 if(G.obedit->type==OB_MESH)
819 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
821 else if(G.obedit->type==OB_MBALL)
823 else if(G.obedit->type==OB_LATTICE)
825 else if(G.obedit->type==OB_ARMATURE)
828 else if((G.obedit) && (G.qual == (LR_CTRLKEY|LR_ALTKEY)))
829 mouse_mesh(); // edge select
830 else if((G.obedit) && (G.qual == (LR_CTRLKEY|LR_ALTKEY|LR_SHIFTKEY)))
831 mouse_mesh(); // edge select
833 if (G.obpose->type==OB_ARMATURE)
834 mousepose_armature();
836 else if(G.qual==LR_CTRLKEY)
837 mouse_select(); // also allow in editmode, for vertex parenting
838 else if(G.f & G_FACESELECT)
840 else if( G.f & (G_VERTEXPAINT|G_TEXTUREPAINT))
846 /* Regular: Zoom in */
847 /* Shift: Scroll up */
848 /* Ctrl: Scroll right */
849 /* Alt-Shift: Rotate up */
850 /* Alt-Ctrl: Rotate right */
852 if( G.qual & LR_SHIFTKEY ) {
853 if( G.qual & LR_ALTKEY ) {
854 G.qual &= ~LR_SHIFTKEY;
856 G.qual |= LR_SHIFTKEY;
860 } else if( G.qual & LR_CTRLKEY ) {
861 if( G.qual & LR_ALTKEY ) {
862 G.qual &= ~LR_CTRLKEY;
864 G.qual |= LR_CTRLKEY;
868 } else if(U.uiflag & USER_WHEELZOOMDIR)
869 persptoetsen(PADMINUS);
871 persptoetsen(PADPLUSKEY);
876 /* Regular: Zoom out */
877 /* Shift: Scroll down */
878 /* Ctrl: Scroll left */
879 /* Alt-Shift: Rotate down */
880 /* Alt-Ctrl: Rotate left */
882 if( G.qual & LR_SHIFTKEY ) {
883 if( G.qual & LR_ALTKEY ) {
884 G.qual &= ~LR_SHIFTKEY;
886 G.qual |= LR_SHIFTKEY;
890 } else if( G.qual & LR_CTRLKEY ) {
891 if( G.qual & LR_ALTKEY ) {
892 G.qual &= ~LR_CTRLKEY;
894 G.qual |= LR_CTRLKEY;
898 } else if(U.uiflag & USER_WHEELZOOMDIR)
899 persptoetsen(PADPLUSKEY);
901 persptoetsen(PADMINUS);
908 if(G.qual==LR_CTRLKEY) {
909 if(ob && ob->type == OB_MESH) {
910 flip_subdivison(ob, 1);
913 else do_layer_buttons(0);
918 if(G.qual==LR_CTRLKEY) {
919 if(ob && ob->type == OB_MESH) {
920 flip_subdivison(ob, 2);
923 else do_layer_buttons(1);
928 if(G.qual==LR_CTRLKEY) {
929 if(ob && ob->type == OB_MESH) {
930 flip_subdivison(ob, 3);
933 else do_layer_buttons(2);
938 if(G.qual==LR_CTRLKEY) {
939 if(ob && ob->type == OB_MESH) {
940 flip_subdivison(ob, 4);
943 else do_layer_buttons(3);
947 do_layer_buttons(4); break;
949 do_layer_buttons(5); break;
951 do_layer_buttons(6); break;
953 do_layer_buttons(7); break;
955 do_layer_buttons(8); break;
957 do_layer_buttons(9); break;
959 do_layer_buttons(10); break;
961 do_layer_buttons(11); break;
963 do_layer_buttons(-1); break;
966 if(G.qual & LR_CTRLKEY) apply_object(); // also with shift!
967 else if((G.qual==LR_SHIFTKEY)) {
972 if(G.obedit->type==OB_MESH)
974 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
976 else if(G.obedit->type==OB_MBALL)
978 else if(G.obedit->type==OB_LATTICE)
980 else if(G.obedit->type==OB_ARMATURE)
981 deselectall_armature();
984 switch (G.obpose->type){
986 deselectall_posearmature(1);
991 if(G.f & G_FACESELECT) deselectall_tface();
993 /* by design, the center of the active object
994 * (which need not necessarily by selected) will
995 * still be drawn as if it were selected.
1003 if((G.qual==LR_SHIFTKEY))
1004 set_render_border();
1005 else if((G.qual==LR_ALTKEY)){
1006 if(G.obedit && G.obedit->type==OB_MESH) {
1007 /* Loop Select Operations */
1010 vertex_loop_select();
1013 else if((G.qual==0))
1017 if(G.qual==LR_CTRLKEY) {
1020 else if(G.qual==LR_ALTKEY) {
1021 convertmenu(); /* editobject.c */
1023 else if((G.qual==LR_SHIFTKEY)) {
1025 curs= give_cursor();
1026 curs[0]=curs[1]=curs[2]= 0.0;
1027 allqueue(REDRAWVIEW3D, 0);
1029 else if((G.obedit) && ELEM(G.obedit->type, OB_CURVE, OB_SURF) ) {
1031 makeDispList(G.obedit);
1032 allqueue(REDRAWVIEW3D, 0);
1034 else if((G.qual==0)){
1035 curs= give_cursor();
1036 G.vd->ofs[0]= -curs[0];
1037 G.vd->ofs[1]= -curs[1];
1038 G.vd->ofs[2]= -curs[2];
1039 scrarea_queue_winredraw(curarea);
1044 if((G.qual==LR_SHIFTKEY)) {
1045 duplicate_context_selected();
1047 else if(G.qual==LR_ALTKEY) {
1049 error ("Duplicate not possible in posemode.");
1050 else if((G.obedit==0))
1053 else if(G.qual==LR_CTRLKEY) {
1056 else if((G.qual==0)){
1057 pupval= pupmenu("Draw mode%t|BoundBox %x1|Wire %x2|OpenGL Solid %x3|Shaded Solid %x4|Textured Solid %x5");
1059 G.vd->drawtype= pupval;
1069 if(G.obedit->type==OB_MESH)
1071 else if(G.obedit->type==OB_CURVE)
1073 else if(G.obedit->type==OB_SURF)
1075 else if(G.obedit->type==OB_ARMATURE)
1080 if(ob && ob->type==OB_IKA) if(okee("extrude IKA"))
1084 else if (G.qual==LR_CTRLKEY) {
1085 if(G.obedit && G.obedit->type==OB_MESH)
1088 else if (G.qual==LR_SHIFTKEY) {
1089 if (G.obedit && G.obedit->type==OB_MESH) {
1096 if(G.obedit->type==OB_MESH) {
1097 if((G.qual==LR_SHIFTKEY))
1099 else if(G.qual==LR_ALTKEY)
1101 else if(G.qual==LR_CTRLKEY)
1106 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) addsegment_nurb();
1108 else if(G.qual==LR_CTRLKEY)
1110 else if((G.qual==LR_SHIFTKEY))
1118 /* RMGRP if(G.qual & LR_CTRLKEY) add_selected_to_group();
1119 else if(G.qual & LR_ALTKEY) rem_selected_from_group(); */
1121 if((G.qual==LR_SHIFTKEY))
1122 select_group_menu();
1123 else if(G.qual==LR_ALTKEY)
1125 else if((G.qual==0))
1130 if(G.obedit->type==OB_MESH) {
1131 if(G.qual==LR_ALTKEY)
1133 else if((G.qual==LR_SHIFTKEY))
1135 else if((G.qual==0))
1138 else if(G.obedit->type== OB_SURF) {
1139 if(G.qual==LR_ALTKEY)
1141 else if((G.qual==LR_SHIFTKEY))
1143 else if((G.qual==0))
1146 else if(G.obedit->type==OB_CURVE) {
1147 if(G.qual==LR_CTRLKEY)
1148 autocalchandlesNurb_all(1); /* flag=1, selected */
1149 else if((G.qual==LR_SHIFTKEY))
1151 else if((G.qual==0))
1154 makeDispList(G.obedit);
1156 allqueue(REDRAWVIEW3D, 0);
1159 else if(G.f & G_FACESELECT)
1163 hide_selected_pose_bones();
1164 else if (G.qual==LR_SHIFTKEY)
1165 hide_unselected_pose_bones();
1166 else if (G.qual==LR_ALTKEY)
1167 show_all_pose_bones();
1174 if(G.qual==LR_CTRLKEY) {
1176 if(ob->type == OB_MESH)
1178 else if(ob->type == OB_CURVE)
1179 join_curve(OB_CURVE);
1180 else if(ob->type == OB_SURF)
1181 join_curve(OB_SURF);
1182 else if(ob->type == OB_ARMATURE)
1185 else if ((G.obedit) && ELEM(G.obedit->type, OB_CURVE, OB_SURF))
1189 if(G.obedit->type==OB_MESH) {
1197 if (G.obedit->type==OB_MESH) {
1198 if (G.qual==LR_SHIFTKEY)
1199 KnifeSubdivide(KNIFE_PROMPT);
1203 else if(G.obedit->type==OB_SURF)
1207 if((G.qual==LR_SHIFTKEY)) {
1208 if(G.f & G_FACESELECT)
1209 clear_vpaint_selectedfaces();
1210 else if(G.f & G_VERTEXPAINT)
1213 select_select_keys();
1215 else if(G.qual==LR_CTRLKEY)
1217 /* else if(G.qual & LR_ALTKEY) delete_skeleton(); */
1225 if(G.obedit->type==OB_MESH)
1226 selectconnected_mesh(G.qual);
1227 if(G.obedit->type==OB_ARMATURE)
1228 selectconnected_armature();
1229 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
1230 selectconnected_nurb();
1233 if(G.obpose->type==OB_ARMATURE)
1234 selectconnected_posearmature();
1237 if((G.qual==LR_SHIFTKEY))
1239 else if(G.qual==LR_CTRLKEY)
1241 else if(G.f & G_FACESELECT)
1242 select_linked_tfaces();
1243 else if((G.qual==0))
1249 if(G.qual==LR_ALTKEY) {
1250 if(G.obedit->type==OB_MESH) {
1252 makeDispList(G.obedit);
1255 else if((G.qual==0) || (G.qual==LR_CTRLKEY)) {
1258 if(G.qual & (LR_SHIFTKEY | LR_ALTKEY | LR_CTRLKEY)) {
1259 if(G.obedit->type==OB_MESH) select_non_manifold();
1262 else if(G.qual & LR_CTRLKEY) {
1265 else if(G.qual==0) {
1271 toggle_blockhandler(curarea, VIEW3D_HANDLER_OBJECT, UI_PNL_TO_MOUSE);
1272 allqueue(REDRAWVIEW3D, 0);
1275 switch (G.obedit->type){
1277 if(G.qual==LR_CTRLKEY){
1278 if (okee("Recalculate bone roll angles")) {
1279 auto_align_armature();
1280 allqueue(REDRAWVIEW3D, 0);
1285 if(G.qual==(LR_SHIFTKEY|LR_CTRLKEY)) {
1286 if(okee("Recalculate normals inside")) {
1287 undo_push_mesh("Recalculate normals inside");
1289 allqueue(REDRAWVIEW3D, 0);
1292 else if(G.qual==LR_CTRLKEY){
1293 if(okee("Recalculate normals outside")) {
1294 undo_push_mesh("Recalculate normals outside");
1296 allqueue(REDRAWVIEW3D, 0);
1307 extern int prop_mode;
1309 if (G.qual==LR_SHIFTKEY) {
1310 prop_mode= !prop_mode;
1311 allqueue(REDRAWHEADERS, 0);
1313 else if((G.qual==0)) {
1314 G.f ^= G_PROPORTIONAL;
1315 allqueue(REDRAWHEADERS, 0);
1318 else if((G.qual==LR_SHIFTKEY)) {
1319 if(ob && ob->type == OB_MESH) {
1320 flip_subdivison(ob, -1);
1323 else if(G.qual==LR_ALTKEY) clear_object('o');
1329 if(G.qual==LR_CTRLKEY || G.qual==(LR_SHIFTKEY|LR_CTRLKEY))
1331 else if((G.qual==0) && G.obedit->type==OB_MESH)
1333 else if ((G.qual==0) && ELEM(G.obedit->type, OB_CURVE, OB_SURF))
1336 else if(G.qual==LR_CTRLKEY || G.qual==(LR_SHIFTKEY|LR_CTRLKEY))
1338 else if(G.qual==LR_ALTKEY)
1340 else if((G.qual==0)) {
1345 if((G.obedit==0) && (G.f & G_FACESELECT) && (G.qual==0))
1347 else if(G.qual==LR_ALTKEY)
1349 else if (G.obedit) {
1350 if((G.qual==LR_SHIFTKEY)) {
1351 if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
1353 else if (G.obedit->type==OB_MESH)
1354 loopoperations(LOOP_SELECT);
1356 else if(G.qual==LR_CTRLKEY) {
1357 if (G.obedit->type==OB_MESH)
1358 loopoperations(LOOP_CUT);
1360 else if((G.qual==0))
1363 else if((G.qual==0))
1368 if(G.qual==LR_ALTKEY)
1369 transform('N'); /* scale along normal */
1370 else if(G.qual==LR_CTRLKEY)
1372 else if(G.qual==LR_SHIFTKEY)
1374 else if((G.qual==0))
1377 else if(G.qual==LR_ALTKEY) {
1380 else if((G.qual==LR_SHIFTKEY))
1382 else if((G.qual==0))
1387 if((G.qual==LR_CTRLKEY) && G.obedit->type==OB_MESH) {
1388 convert_to_triface(0);
1389 allqueue(REDRAWVIEW3D, 0);
1391 makeDispList(G.obedit);
1393 else if((G.qual==LR_ALTKEY) && G.obedit->type==OB_CURVE)
1395 else if((G.qual==0))
1398 else if(G.qual==LR_CTRLKEY) {
1401 else if(G.qual==LR_ALTKEY) {
1404 else if((G.qual==0)){
1411 if(G.obedit->type==OB_MESH){
1412 if (G.qual==LR_ALTKEY)
1414 else if (G.qual==LR_SHIFTKEY)
1416 else if((G.qual==0))
1419 else if(G.obedit->type==OB_ARMATURE)
1420 remake_editArmature();
1421 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
1423 else if(G.obedit->type==OB_LATTICE)
1426 else if((G.qual==0)){
1427 if (G.f & G_FACESELECT)
1428 uv_autocalc_tface();
1429 else if(G.f & G_WEIGHTPAINT)
1431 else if(G.f & G_VERTEXPAINT)
1440 if((G.qual==LR_SHIFTKEY)) {
1441 if ((G.obedit) && G.obedit->type==OB_MESH) {
1442 align_view_to_selected(v3d);
1444 else if (G.f & G_FACESELECT) {
1445 align_view_to_selected(v3d);
1448 else if(G.qual==LR_ALTKEY)
1450 else if (G.qual==0){
1452 if(G.obedit->type==OB_CURVE) {
1454 makeDispList(G.obedit);
1455 allqueue(REDRAWVIEW3D, 0);
1458 else if(ob && ob->type == OB_MESH)
1463 if((G.qual==LR_SHIFTKEY)) {
1466 else if(G.qual==LR_ALTKEY) {
1467 /* if(G.obedit && G.obedit->type==OB_MESH) write_videoscape(); */
1469 else if(G.qual==LR_CTRLKEY) {
1471 if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
1472 switchdirectionNurb2();
1476 else if((G.qual==0))
1483 delete_context_selected();
1486 if((G.qual==0) && (G.obedit)) {
1487 if(G.obedit->type==OB_MESH) split_mesh();
1493 scrarea_queue_headredraw(curarea);
1494 scrarea_queue_winredraw(curarea);
1503 if(G.qual==LR_CTRLKEY) {
1504 G.vd->around= V3D_CENTROID;
1505 } else if(G.qual==LR_SHIFTKEY) {
1506 G.vd->around= V3D_CENTROID;
1507 } else if(G.qual==0) {
1508 G.vd->around= V3D_CENTRE;
1510 scrarea_queue_headredraw(curarea);
1514 if(G.qual==LR_CTRLKEY) {
1515 G.vd->around= V3D_LOCAL;
1516 } else if(G.qual==0) {
1517 G.vd->around= V3D_CURSOR;
1519 scrarea_queue_headredraw(curarea);
1524 if(G.vd->localview) {
1526 endlocalview(curarea);
1532 scrarea_queue_headredraw(curarea);
1535 case PADASTERKEY: /* '*' */
1539 obmat_to_viewmat(ob);
1540 if(G.vd->persp==2) G.vd->persp= 1;
1541 scrarea_queue_winredraw(curarea);
1545 case PADPERIOD: /* '.' */
1551 if(G.qual==LR_CTRLKEY)
1553 else if((G.qual==0))
1554 nextkey_obipo(1); /* in editipo.c */
1558 if(G.qual==LR_CTRLKEY)
1560 else if((G.qual==0))
1564 case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
1565 case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
1567 persptoetsen(event);
1571 if ( (G.qual==LR_CTRLKEY)
1572 && (G.obedit) && (G.obedit->type==OB_MESH) )
1575 persptoetsen(event);
1581 if ( (G.qual==LR_CTRLKEY)
1582 && (G.obedit) && (G.obedit->type==OB_MESH) )
1585 persptoetsen(event);
1592 if (G.vd->flag & V3D_DISPIMAGE) {
1593 G.vd->flag &= ~V3D_DISPIMAGE;
1603 scrarea_queue_winredraw(curarea);
1604 scrarea_queue_headredraw(curarea);
1608 void initview3d(ScrArea *sa)
1612 vd= MEM_callocN(sizeof(View3D), "initview3d");
1613 BLI_addhead(&sa->spacedata, vd); /* addhead! not addtail */
1615 vd->spacetype= SPACE_VIEW3D;
1616 vd->blockscale= 0.7;
1617 vd->viewquat[0]= 1.0;
1618 vd->viewquat[1]= vd->viewquat[2]= vd->viewquat[3]= 0.0;
1620 vd->drawtype= OB_WIRE;
1628 vd->lay= vd->layact= 1;
1630 vd->lay= vd->layact= G.scene->lay;
1631 vd->camera= G.scene->camera;
1634 vd->gridflag |= V3D_SHOW_X;
1635 vd->gridflag |= V3D_SHOW_Y;
1636 vd->gridflag |= V3D_SHOW_FLOOR;
1637 vd->gridflag &= ~V3D_SHOW_Z;
1641 /* ******************** SPACE: IPO ********************** */
1643 static void changeview2dspace(ScrArea *sa, void *spacedata)
1645 if(G.v2d==0) return;
1647 test_view2d(G.v2d, curarea->winx, curarea->winy);
1648 myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
1651 void winqreadipospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
1653 extern void do_ipobuts(unsigned short event); // drawipo.c
1654 unsigned short event= evt->event;
1655 short val= evt->val;
1656 SpaceIpo *sipo= curarea->spacedata.first;
1657 View2D *v2d= &sipo->v2d;
1659 int cfra, doredraw= 0;
1661 short mousebut = L_MOUSE;
1663 if(sa->win==0) return;
1666 if( uiDoBlocks(&sa->uiblocks, event)!=UI_NOTHING ) event= 0;
1668 /* swap mouse buttons based on user preference */
1669 if (U.flag & USER_LMOUSESELECT) {
1670 if (evt->event == LEFTMOUSE) {
1673 } else if (evt->event == RIGHTMOUSE) {
1681 /* note: bad bad code, will be cleaned! is because event queues are all shattered */
1682 if(val>0 && val < 51) do_ipowin_buts(val-1);
1683 else do_ipobuts(val);
1687 if( in_ipo_buttons() ) {
1688 do_ipo_selectbuttons();
1691 else if(G.qual & LR_CTRLKEY) add_vert_ipo();
1694 getmouseco_areawin(mval);
1695 areamouseco_to_ipoco(v2d, mval, &dx, &dy);
1698 if(cfra< 1) cfra= 1;
1702 update_for_newframe();
1703 force_draw_plus(SPACE_VIEW3D);
1704 force_draw_plus(SPACE_ACTION);
1705 force_draw_plus(SPACE_BUTS); /* To make constraint sliders redraw */
1708 } while(get_mbut() & mousebut);
1713 allqueue (REDRAWACTION, 0);
1714 allqueue(REDRAWNLA, 0);
1717 if(in_ipo_buttons()) {
1720 else view2dmove(event); /* in drawipo.c */
1723 case WHEELDOWNMOUSE:
1724 view2dmove(event); /* in drawipo.c */
1727 view2d_zoom(v2d, 0.1154, sa->winx, sa->winy);
1731 view2d_zoom(v2d, -0.15, sa->winx, sa->winy);
1735 if(G.qual==LR_CTRLKEY)
1737 else if((G.qual==0))
1741 if(G.qual==LR_CTRLKEY)
1743 else if((G.qual==0))
1748 do_ipo_buttons(B_IPOHOME);
1753 if(in_ipo_buttons()) {
1754 swap_visible_editipo();
1756 else swap_selectall_editipo();
1757 allspace (REMAKEIPO, 0);
1758 allqueue (REDRAWNLA, 0);
1759 allqueue (REDRAWACTION, 0);
1771 if((G.qual==LR_SHIFTKEY))
1772 add_duplicate_editipo();
1779 if((G.qual==LR_SHIFTKEY))
1780 sethandles_ipo(HD_AUTO);
1781 else if((G.qual==0))
1782 sethandles_ipo(HD_ALIGN);
1790 ipo_toggle_showkey();
1791 scrarea_queue_headredraw(curarea);
1792 allqueue(REDRAWVIEW3D, 0);
1797 toggle_blockhandler(sa, IPO_HANDLER_PROPERTIES, UI_PNL_TO_MOUSE);
1805 if((G.qual==LR_SHIFTKEY)) {
1807 } else if((G.qual==0))
1816 sethandles_ipo(HD_VECT);
1820 if((G.qual==LR_SHIFTKEY))
1822 else if((G.qual==0))
1828 if(doredraw) scrarea_queue_winredraw(sa);
1831 void initipo(ScrArea *sa)
1835 sipo= MEM_callocN(sizeof(SpaceIpo), "initipo");
1836 BLI_addhead(&sa->spacedata, sipo);
1838 sipo->spacetype= SPACE_IPO;
1839 sipo->blockscale= 0.7;
1841 /* sipo space loopt van (0,-?) tot (??,?) */
1842 sipo->v2d.tot.xmin= 0.0;
1843 sipo->v2d.tot.ymin= -10.0;
1844 sipo->v2d.tot.xmax= G.scene->r.efra;
1845 sipo->v2d.tot.ymax= 10.0;
1847 sipo->v2d.cur= sipo->v2d.tot;
1849 sipo->v2d.min[0]= 0.01f;
1850 sipo->v2d.min[1]= 0.01f;
1852 sipo->v2d.max[0]= 15000.0f;
1853 sipo->v2d.max[1]= 10000.0f;
1855 sipo->v2d.scroll= L_SCROLL+B_SCROLL;
1856 sipo->v2d.keeptot= 0;
1858 sipo->blocktype= ID_OB;
1861 /* ******************** SPACE: INFO ********************** */
1863 void space_mipmap_button_function(int event) {
1864 set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
1866 allqueue(REDRAWVIEW3D, 0);
1869 void space_sound_button_function(int event)
1872 SYS_SystemHandle syshandle;
1874 if ((syshandle = SYS_GetSystem()))
1876 a = (U.gameflags & USER_DISABLE_SOUND);
1877 SYS_WriteCommandLineInt(syshandle, "noaudio", a);
1881 #define B_ADD_THEME 3301
1882 #define B_DEL_THEME 3302
1883 #define B_NAME_THEME 3303
1884 #define B_THEMECOL 3304
1885 #define B_UPDATE_THEME 3305
1886 #define B_CHANGE_THEME 3306
1887 #define B_THEME_COPY 3307
1888 #define B_THEME_PASTE 3308
1890 #define B_RECALCLIGHT 3310
1892 // needed for event; choose new 'curmain' resets it...
1893 static short th_curcol= TH_BACK;
1894 static char *th_curcol_ptr= NULL;
1895 static char th_curcol_arr[4]={0, 0, 0, 255};
1897 void info_user_themebuts(uiBlock *block, short y1, short y2, short y3)
1899 bTheme *btheme, *bt;
1901 static short cur=1, curmain=2;
1902 short a, tot=0, isbuiltin= 0;
1903 char string[20*32], *strp, *col;
1905 y3= y2+23; // exception!
1907 /* count total, max 16! */
1908 for(bt= U.themes.first; bt; bt= bt->next) tot++;
1910 /* if cur not is 1; move that to front of list */
1913 for(bt= U.themes.first; bt; bt= bt->next, a++) {
1915 BLI_remlink(&U.themes, bt);
1916 BLI_addhead(&U.themes, bt);
1917 allqueue(REDRAWALL, 0);
1924 /* the current theme */
1925 btheme= U.themes.first;
1926 if(strcmp(btheme->name, "Default")==0) isbuiltin= 1;
1928 /* construct popup script */
1930 for(bt= U.themes.first; bt; bt= bt->next) {
1931 strcat(string, bt->name);
1932 if(btheme->next) strcat(string, " |");
1934 uiDefButS(block, MENU, B_UPDATE_THEME, string, 45,y3,200,20, &cur, 0, 0, 0, 0, "Current theme");
1936 /* add / delete / name */
1939 uiDefBut(block, BUT, B_ADD_THEME, "Add", 45,y2,200,20, NULL, 0, 0, 0, 0, "Makes new copy of this theme");
1940 if(tot>1 && isbuiltin==0)
1941 uiDefBut(block, BUT, B_DEL_THEME, "Delete", 45,y1,200,20, NULL, 0, 0, 0, 0, "Delete theme");
1943 if(isbuiltin) return;
1946 uiDefBut(block, TEX, B_NAME_THEME, "", 255,y3,200,20, btheme->name, 1.0, 30.0, 0, 0, "Rename theme");
1948 /* main choices pup */
1949 uiDefButS(block, MENU, B_CHANGE_THEME, "UI and Buttons %x1|%l|3D View %x2|%l|Ipo Curve Editor %x3|Action Editor %x4|"
1950 "NLA Editor %x5|%l|UV/Image Editor %x6|Video Sequence Editor %x7|Audio Timeline %x8|Text Editor %x9|%l|User Preferences %x10|"
1951 "OOPS Schematic %x11|Buttons Window %x12|%l|File Browser %x13|Image Browser %x14",
1952 255,y2,200,20, &curmain, 0, 0, 0, 0, "Specify theme for...");
1953 if(curmain==1) spacetype= 0;
1954 else if(curmain==2) spacetype= SPACE_VIEW3D;
1955 else if(curmain==3) spacetype= SPACE_IPO;
1956 else if(curmain==4) spacetype= SPACE_ACTION;
1957 else if(curmain==5) spacetype= SPACE_NLA;
1958 else if(curmain==6) spacetype= SPACE_IMAGE;
1959 else if(curmain==7) spacetype= SPACE_SEQ;
1960 else if(curmain==8) spacetype= SPACE_SOUND;
1961 else if(curmain==9) spacetype= SPACE_TEXT;
1962 else if(curmain==10) spacetype= SPACE_INFO;
1963 else if(curmain==11) spacetype= SPACE_OOPS;
1964 else if(curmain==12) spacetype= SPACE_BUTS;
1965 else if(curmain==13) spacetype= SPACE_FILE;
1966 else if(curmain==14) spacetype= SPACE_IMASEL;
1967 else return; // only needed while coding... when adding themes for more windows
1969 /* color choices pup */
1971 strp= BIF_ThemeColorsPup(0);
1972 if(th_curcol==TH_BACK) th_curcol= TH_BUT_OUTLINE; // switching main choices...
1974 else strp= BIF_ThemeColorsPup(spacetype);
1976 uiDefButS(block, MENU, B_REDR, strp, 255,y1,200,20, &th_curcol, 0, 0, 0, 0, "Current color");
1979 th_curcol_ptr= col= BIF_ThemeGetColorPtr(btheme, spacetype, th_curcol);
1980 if(col==NULL) return;
1982 /* first handle exceptions, special single values, row selection, etc */
1983 if(th_curcol==TH_VERTEX_SIZE) {
1984 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"Vertex size ", 465,y3,200,20, col, 1.0, 10.0, 0, 0, "");
1986 else if(th_curcol==TH_BUT_DRAWTYPE) {
1987 uiBlockBeginAlign(block);
1988 uiDefButC(block, ROW, B_UPDATE_THEME, "Minimal", 465,y3,100,20, col, 2.0, 0.0, 0, 0, "");
1989 uiDefButC(block, ROW, B_UPDATE_THEME, "Shaded", 565,y3,100,20, col, 2.0, 1.0, 0, 0, "");
1990 uiDefButC(block, ROW, B_UPDATE_THEME, "Rounded", 465,y2,100,20, col, 2.0, 2.0, 0, 0, "");
1991 uiDefButC(block, ROW, B_UPDATE_THEME, "OldSkool", 565,y2,100,20, col, 2.0, 3.0, 0, 0, "");
1992 uiBlockEndAlign(block);
1995 uiBlockBeginAlign(block);
1996 if ELEM3(th_curcol, TH_PANEL, TH_FACE, TH_FACE_SELECT) {
1997 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"A ", 465,y3+25,200,20, col+3, 0.0, 255.0, B_THEMECOL, 0, "");
1999 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"R ", 465,y3,200,20, col, 0.0, 255.0, B_THEMECOL, 0, "");
2000 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"G ", 465,y2,200,20, col+1, 0.0, 255.0, B_THEMECOL, 0, "");
2001 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"B ", 465,y1,200,20, col+2, 0.0, 255.0, B_THEMECOL, 0, "");
2002 uiBlockEndAlign(block);
2004 uiDefButC(block, COL, B_UPDATE_THEME, "", 675,y1,50,y3-y1+20, col, 0, 0, 0, 0, "");
2007 uiBlockBeginAlign(block);
2008 uiDefBut(block, BUT, B_THEME_COPY, "Copy Color", 755,y2,120,20, NULL, 0, 0, 0, 0, "Stores current color in buffer");
2009 uiDefBut(block, BUT, B_THEME_PASTE, "Paste Color", 755,y1,120,20, NULL, 0, 0, 0, 0, "Pastes buffer color");
2010 uiBlockEndAlign(block);
2012 uiDefButC(block, COL, 0, "", 885,y1,50,y2-y1+20, th_curcol_arr, 0, 0, 0, 0, "");
2018 void drawinfospace(ScrArea *sa, void *spacedata)
2021 static short cur_light=0, cur_light_var=0;
2023 short xpos, ypos, ypostab, buth, rspace, dx, y1, y2, y3, y4, y5, y6;
2024 short y2label, y3label, y4label, y5label, y6label;
2025 short spref, mpref, lpref, smfileselbut;
2029 if(curarea->win==0) return;
2031 BIF_GetThemeColor3fv(TH_BACK, col);
2032 glClearColor(col[0], col[1], col[2], 0.0);
2033 glClear(GL_COLOR_BUFFER_BIT);
2035 fac= ((float)curarea->winx)/1280.0f;
2036 myortho2(0.0, 1280.0, 0.0, curarea->winy/fac);
2038 sprintf(naam, "infowin %d", curarea->win);
2039 block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSS, UI_HELV, curarea->win);
2042 /* Vars for nice grid alignment */
2043 dx= (1280-90)/7; /* spacing for use in equally dividing 'tab' row */
2045 xpos = 45; /* left padding */
2046 ypos = 50; /* bottom padding for buttons */
2047 ypostab = 10; /* bottom padding for 'tab' row */
2049 buth = 20; /* standard button height */
2051 spref = 90; /* standard size for small preferences button */
2052 mpref = 189; /* standard size for medium preferences button */
2053 lpref = 288; /* standard size for large preferences button */
2054 smfileselbut = buth; /* standard size for fileselect button (square) */
2056 edgsp = 3; /* space from edge of end 'tab' to edge of end button */
2057 midsp = 9; /* horizontal space between buttons */
2059 rspace = 3; /* default space between rows */
2061 y1 = ypos; /* grid alignment for each row of buttons */
2062 y2 = ypos+buth+rspace;
2063 y3 = ypos+2*(buth+rspace);
2064 y4 = ypos+3*(buth+rspace);
2065 y5 = ypos+4*(buth+rspace);
2066 y6 = ypos+5*(buth+rspace);
2069 y2label = y2-2; /* adjustments to offset the labels down to align better */
2076 /* set the colour to blue and draw the main 'tab' controls */
2078 uiBlockSetCol(block, TH_BUT_SETTING1);
2079 uiBlockBeginAlign(block);
2081 uiDefButS(block, ROW,B_USERPREF,"View & Controls",
2082 xpos,ypostab,(short)dx,buth,
2083 &U.userpref,1.0,0.0, 0, 0,"");
2085 uiDefButS(block, ROW,B_USERPREF,"Edit Methods",
2086 (short)(xpos+dx),ypostab,(short)dx,buth,
2087 &U.userpref,1.0,1.0, 0, 0,"");
2089 uiDefButS(block, ROW,B_USERPREF,"Language & Font",
2090 (short)(xpos+2*dx),ypostab,(short)dx,buth,
2091 &U.userpref,1.0,2.0, 0, 0,"");
2093 uiDefButS(block, ROW,B_USERPREF,"Themes",
2094 (short)(xpos+3*dx),ypostab,(short)dx,buth,
2095 &U.userpref,1.0,6.0, 0, 0,"");
2097 uiDefButS(block, ROW,B_USERPREF,"Auto Save",
2098 (short)(xpos+4*dx),ypostab,(short)dx,buth,
2099 &U.userpref,1.0,3.0, 0, 0,"");
2101 uiDefButS(block, ROW,B_USERPREF,"System & OpenGL",
2102 (short)(xpos+5*dx),ypostab,(short)dx,buth,
2103 &U.userpref,1.0,4.0, 0, 0,"");
2105 uiDefButS(block, ROW,B_USERPREF,"File Paths",
2106 (short)(xpos+6*dx),ypostab,(short)dx,buth,
2107 &U.userpref,1.0,5.0, 0, 0,"");
2109 uiBlockSetCol(block, TH_AUTO);
2110 uiBlockEndAlign(block);
2111 /* end 'tab' controls */
2113 /* line 2: left x co-ord, top y co-ord, width, height */
2115 if(U.userpref == 6) {
2116 info_user_themebuts(block, y1, y2, y3);
2118 else if (U.userpref == 0) { /* view & controls */
2120 uiDefBut(block, LABEL,0,"Display:",
2121 xpos,y6label,spref,buth,
2123 uiDefButBitS(block, TOG, USER_TOOLTIPS, 0, "ToolTips",
2124 (xpos+edgsp),y5,spref,buth,
2125 &(U.flag), 0, 0, 0, 0,
2126 "Display tooltips (help tags) over buttons");
2127 uiDefButBitS(block, TOG, USER_DRAWVIEWINFO, B_DRAWINFO, "Object Info",
2128 (xpos+edgsp),y4,spref,buth,
2129 &(U.uiflag), 0, 0, 0, 0,
2130 "Display active object name and frame number in the 3D View");
2131 uiDefButBitS(block, TOG, USER_SCENEGLOBAL, 0, "Global Scene",
2132 (xpos+edgsp),y3,spref,buth,
2133 &(U.flag), 0, 0, 0, 0,
2134 "Forces the current Scene to be displayed in all Screens");
2136 uiDefButS(block, TOG|BIT|0, 0, "Large Cursors",
2137 (xpos+edgsp),y2,spref,buth,
2138 &(U.curssize), 0, 0, 0, 0,
2139 "Use large mouse cursors when available");
2141 U.curssize=0; /*Small Cursor always for OS X for now */
2144 uiDefBut(block, LABEL,0,"Menus:",
2145 (xpos+(2*edgsp)+spref),y6label,spref,buth,
2147 uiDefButBitS(block, TOG, USER_MENUOPENAUTO, 0, "Open on Mouse Over",
2148 (xpos+edgsp+spref+midsp),y5,mpref,buth,
2149 &(U.uiflag), 0, 0, 0, 0,
2150 "Open menu buttons and pulldowns automatically when the mouse is hovering");
2151 uiDefButS(block, NUM, 0, "Top Level:",
2152 (xpos+edgsp+spref+midsp),y4,spref+edgsp,buth,
2153 &(U.menuthreshold1), 1, 40, 0, 0,
2154 "Time delay in 1/10 seconds before automatically opening top level menus");
2155 uiDefButS(block, NUM, 0, "Sublevels:",
2156 (xpos+edgsp+(2*spref)+(2*midsp)-edgsp),y4,spref+edgsp,buth,
2157 &(U.menuthreshold2), 1, 40, 0, 0,
2158 "Time delay in 1/10 seconds before automatically opening menu sublevels");
2160 uiDefBut(block, LABEL,0,"Toolbox click-hold delay:",
2161 (xpos+(2*edgsp)+spref),y3label,mpref,buth,
2163 uiDefButS(block, NUM, 0, "LMB:",
2164 (xpos+edgsp+spref+midsp),y2,spref+edgsp,buth,
2165 &(U.tb_leftmouse), 2, 40, 0, 0,
2166 "Time in 1/10 seconds to hold the Left Mouse Button before opening the toolbox");
2167 uiDefButS(block, NUM, 0, "RMB:",
2168 (xpos+edgsp+(2*spref)+(2*midsp)-edgsp),y2,spref+edgsp,buth,
2169 &(U.tb_rightmouse), 2, 40, 0, 0,
2170 "Time in 1/10 seconds to hold the Right Mouse Button before opening the toolbox");
2171 uiDefButBitS(block, TOG, USER_PANELPINNED, 0, "Pin Floating Panels",
2172 (xpos+edgsp+spref+midsp),y1,mpref,buth,
2173 &(U.uiflag), 0, 0, 0, 0,
2174 "Make floating panels invoked by a hotkey (eg. N Key) open at the previous location");
2177 uiDefBut(block, LABEL,0,"Snap to grid:",
2178 (xpos+(2*edgsp)+spref+midsp+mpref),y6label,mpref,buth,
2180 uiDefButBitS(block, TOG, USER_AUTOGRABGRID, 0, "Grab/Move",
2181 (xpos+edgsp+mpref+spref+(2*midsp)),y5,spref,buth,
2182 &(U.flag), 0, 0, 0, 0,
2183 "Snap objects and sub-objects to grid units when moving");
2184 uiDefButBitS(block, TOG, USER_AUTOROTGRID, 0, "Rotate",
2185 (xpos+edgsp+mpref+spref+(2*midsp)),y4,spref,buth,
2186 &(U.flag), 0, 0, 0, 0,
2187 "Snap objects and sub-objects to grid units when rotating");
2188 uiDefButBitS(block, TOG, USER_AUTOSIZEGRID, 0, "Scale",
2189 (xpos+edgsp+mpref+spref+(2*midsp)),y3,spref,buth,
2190 &(U.flag), 0, 0, 0, 0,
2191 "Snap objects and sub-objects to grid units when scaling");
2193 uiDefButBitS(block, TOG, USER_LOCKAROUND, B_DRAWINFO, "Global Pivot",
2194 (xpos+edgsp+mpref+spref+(2*midsp)),y1,spref,buth,
2195 &(U.uiflag), 0, 0, 0, 0,
2196 "Lock the same rotation/scaling pivot in all 3D Views");
2198 uiDefBut(block, LABEL,0,"View zoom:",
2199 (xpos+(2*edgsp)+mpref+(2*spref)+(2*midsp)),y6label,mpref,buth,
2201 uiBlockBeginAlign(block);
2202 uiDefButS(block, ROW, 0, "Continue",
2203 (xpos+edgsp+mpref+(2*spref)+(3*midsp)),y5,(mpref/3),buth,
2204 &(U.viewzoom), 40, USER_ZOOM_CONT, 0, 0,
2205 "Old style zoom, continues while moving mouse up or down");
2206 uiDefButS(block, ROW, 0, "Dolly",
2207 (xpos+edgsp+mpref+(2*spref)+(3*midsp)+(mpref/3)),y5,(mpref/3),buth,
2208 &(U.viewzoom), 40, USER_ZOOM_DOLLY, 0, 0,
2209 "Zooms in and out based on vertical mouse movement.");
2210 uiDefButS(block, ROW, 0, "Scale",
2211 (xpos+edgsp+mpref+(2*spref)+(3*midsp)+(2*mpref/3)),y5,(mpref/3),buth,
2212 &(U.viewzoom), 40, USER_ZOOM_SCALE, 0, 0,
2213 "Zooms in and out like scaling the view, mouse movements relative to center.");
2214 uiBlockEndAlign(block);
2216 uiDefBut(block, LABEL,0,"View rotation:",
2217 (xpos+(2*edgsp)+mpref+(2*spref)+(2*midsp)),y4label,mpref,buth,
2219 uiBlockBeginAlign(block);
2220 uiDefButBitS(block, TOG, USER_TRACKBALL, B_DRAWINFO, "Trackball",
2221 (xpos+edgsp+mpref+(2*spref)+(3*midsp)),y3,(mpref/2),buth,
2222 &(U.flag), 0, 0, 0, 0,
2223 "Allow the view to tumble freely when orbiting with the Middle Mouse Button");
2224 uiDefButBitS(block, TOGN, USER_TRACKBALL, B_DRAWINFO, "Turntable",
2225 (xpos+edgsp+mpref+(2*spref)+(3*midsp)+(mpref/2)),y3,(mpref/2),buth,
2226 &(U.flag), 0, 0, 0, 0,
2227 "Keep the Global Z axis pointing upwards when orbiting the view with the Middle Mouse Button");
2228 uiBlockEndAlign(block);
2230 uiDefButBitS(block, TOG, USER_AUTOPERSP, B_DRAWINFO, "Auto Perspective",
2231 (xpos+edgsp+mpref+(2*spref)+(3*midsp)),y1,spref,buth,
2232 &(U.uiflag), 0, 0, 0, 0,
2233 "Automatically switch between orthographic and perspective when changing from top/front/side views");
2235 uiDefBut(block, LABEL,0,"Left Mouse Button:",
2236 (xpos+(2*edgsp)+(3*mpref)+(3*midsp)),y6label,mpref,buth,
2238 uiBlockBeginAlign(block);
2239 uiDefButBitS(block, TOGN, USER_LMOUSESELECT, B_DRAWINFO, "Cursor",
2240 (xpos+edgsp+(3*mpref)+(4*midsp)),y5,(mpref/2),buth,
2241 &(U.flag), 0, 0, 0, 0, "Action for the left mouse button");
2242 uiDefButBitS(block, TOG, USER_LMOUSESELECT, B_DRAWINFO, "Select",
2243 (xpos+edgsp+(3*mpref)+(4*midsp)+(mpref/2)),y5,(mpref/2),buth,
2244 &(U.flag), 0, 0, 0, 0, "Action for the left mouse button");
2245 uiBlockEndAlign(block);
2248 uiDefBut(block, LABEL,0,"Right Mouse Button:",
2249 (xpos+(2*edgsp)+(3*mpref)+(3*midsp)),y4label,mpref,buth,
2251 uiBlockBeginAlign(block);
2252 uiDefButBitS(block, TOGN, USER_LMOUSESELECT, B_DRAWINFO, "Select",
2253 (xpos+edgsp+(3*mpref)+(4*midsp)),y3,(mpref/2),buth,
2254 &(U.flag), 0, 0, 0, 0, "Action for the right mouse button");
2255 uiDefButBitS(block, TOG, USER_LMOUSESELECT, B_DRAWINFO, "Cursor",
2256 (xpos+edgsp+(3*mpref)+(4*midsp)+(mpref/2)),y3,(mpref/2),buth,
2257 &(U.flag), 0, 0, 0, 0, "Action for the right mouse button");
2258 uiBlockEndAlign(block);
2260 uiDefButBitS(block, TOG, USER_TWOBUTTONMOUSE, 0, "Emulate 3 Button Mouse",
2261 (xpos+edgsp+(3*mpref)+(4*midsp)),y1,mpref,buth,
2262 &(U.flag), 0, 0, 0, 0,
2263 "Emulates a middle mouse button with Alt LeftMouse");
2266 uiDefBut(block, LABEL,0,"Middle Mouse Button:",
2267 (xpos+(2*edgsp)+(4*mpref)+(4*midsp)),y6label,mpref,buth,
2269 uiBlockBeginAlign(block);
2270 uiDefButBitS(block, TOGN, USER_VIEWMOVE, B_DRAWINFO, "Rotate View",
2271 (xpos+edgsp+(4*mpref)+(5*midsp)),y5,(mpref/2),buth,
2272 &(U.flag), 0, 0, 0, 0, "Default action for the Middle Mouse Button");
2273 uiDefButBitS(block, TOG, USER_VIEWMOVE, B_DRAWINFO, "Pan View",
2274 (xpos+edgsp+(4*mpref)+(5*midsp)+(mpref/2)),y5,(mpref/2),buth,
2275 &(U.flag), 0, 0, 0, 0, "Default action for the Middle Mouse Button");
2276 uiBlockEndAlign(block);
2278 uiDefBut(block, LABEL,0,"Mouse Wheel:",
2279 (xpos+(2*edgsp)+(4*mpref)+(4*midsp)),y4label,mpref,buth,
2281 uiDefButBitS(block, TOG, USER_WHEELZOOMDIR, 0, "Invert Zoom",
2282 (xpos+edgsp+(4*mpref)+(5*midsp)),y3,spref,buth,
2283 &(U.uiflag), 0, 0, 0, 0,
2284 "Swap the Mouse Wheel zoom direction");
2285 uiDefButI(block, NUM, 0, "Scroll Lines:",
2286 (xpos+edgsp+(4*mpref)+(6*midsp)+spref-edgsp),y3,spref+edgsp,buth,
2287 &U.wheellinescroll, 0.0, 32.0, 0, 0,
2288 "The number of lines scrolled at a time with the mouse wheel");
2291 } else if (U.userpref == 1) { /* edit methods */
2294 uiDefBut(block, LABEL,0,"Material linked to:",
2295 xpos,y3label,mpref,buth,
2297 uiBlockBeginAlign(block);
2298 uiDefButBitS(block, TOGN, USER_MAT_ON_OB, B_DRAWINFO, "ObData",
2299 (xpos+edgsp),y2,(mpref/2),buth,
2300 &(U.flag), 0, 0, 0, 0, "Link new objects' material to the obData block");
2301 uiDefButBitS(block, TOG, USER_MAT_ON_OB, B_DRAWINFO, "Object",
2302 (xpos+edgsp+(mpref/2)),y2,(mpref/2),buth,
2303 &(U.flag), 0, 0, 0, 0, "Link new objects' material to the object block");
2304 uiBlockEndAlign(block);
2307 uiDefBut(block, LABEL,0,"Mesh undo:",
2308 (xpos+(2*edgsp)+mpref),y3label, mpref,buth,
2310 uiDefButS(block, NUMSLI, B_DRAWINFO, "Steps:",
2311 (xpos+edgsp+mpref+midsp),y2,mpref,buth,
2312 &(U.undosteps), 2, 64, 0, 0, "Number of undo steps available in Edit Mode (smaller values conserve memory)");
2315 uiDefBut(block, LABEL,0,"Auto keyframe on:",
2316 (xpos+(2*edgsp)+(2*mpref)+midsp),y3label,mpref,buth,
2318 uiDefButBitS(block, TOG, USER_KEYINSERTACT, 0, "Action",
2319 (xpos+edgsp+(2*mpref)+(2*midsp)),y2,(spref+edgsp),buth,
2320 &(U.uiflag), 0, 0, 0, 0, "Automatic keyframe insertion in Action Ipo curve");
2321 uiDefButBitS(block, TOG, USER_KEYINSERTOBJ, 0, "Object",
2322 (xpos+edgsp+(2*mpref)+(3*midsp)+spref-edgsp),y2,(spref+edgsp),buth,
2323 &(U.uiflag), 0, 0, 0, 0, "Automatic keyframe insertion in Object Ipo curve");
2326 uiDefBut(block, LABEL,0,"Duplicate with object:",
2327 (xpos+(2*edgsp)+(3*midsp)+(3*mpref)+spref),y3label,mpref,buth,
2330 uiDefButBitS(block, TOG, USER_DUP_MESH, 0, "Mesh",
2331 (xpos+edgsp+(4*midsp)+(3*mpref)+spref),y2,(spref+edgsp),buth,
2332 &(U.dupflag), 0, 0, 0, 0, "Causes mesh data to be duplicated with Shift+D");
2333 uiDefButBitS(block, TOG, USER_DUP_ARM, 0, "Armature",
2334 (xpos+edgsp+(4*midsp)+(3*mpref)+spref),y1,(spref+edgsp),buth,
2335 &(U.dupflag), 0, 0, 0, 0, "Causes armature data to be duplicated with Shift+D");
2337 uiDefButBitS(block, TOG, USER_DUP_SURF, 0, "Surface",
2338 (xpos+edgsp+(5*midsp)+(3*mpref)+(2*spref)),y2,(spref+edgsp),buth,
2339 &(U.dupflag), 0, 0, 0, 0, "Causes surface data to be duplicated with Shift+D");
2340 uiDefButBitS(block, TOG, USER_DUP_LAMP, 0, "Lamp",
2341 (xpos+edgsp+(5*midsp)+(3*mpref)+(2*spref)),y1,(spref+edgsp),buth,
2342 &(U.dupflag), 0, 0, 0, 0, "Causes lamp data to be duplicated with Shift+D");
2344 uiDefButBitS(block, TOG, USER_DUP_CURVE, 0, "Curve",
2345 (xpos+edgsp+(6*midsp)+(3*mpref)+(3*spref)),y2,(spref+edgsp),buth,
2346 &(U.dupflag), 0, 0, 0, 0, "Causes curve data to be duplicated with Shift+D");
2347 uiDefButBitS(block, TOG, USER_DUP_MAT, 0, "Material",
2348 (xpos+edgsp+(6*midsp)+(3*mpref)+(3*spref)),y1,(spref+edgsp),buth,
2349 &(U.dupflag), 0, 0, 0, 0, "Causes material data to be duplicated with Shift+D");
2351 uiDefButBitS(block, TOG, USER_DUP_FONT, 0, "Text",
2352 (xpos+edgsp+(7*midsp)+(3*mpref)+(4*spref)),y2,(spref+edgsp),buth,
2353 &(U.dupflag), 0, 0, 0, 0, "Causes text data to be duplicated with Shift+D");
2354 uiDefButBitS(block, TOG, USER_DUP_TEX, 0, "Texture",
2355 (xpos+edgsp+(7*midsp)+(3*mpref)+(4*spref)),y1,(spref+edgsp),buth,
2356 &(U.dupflag), 0, 0, 0, 0, "Causes texture data to be duplicated with Shift+D");
2358 uiDefButBitS(block, TOG, USER_DUP_MBALL, 0, "Metaball",
2359 (xpos+edgsp+(8*midsp)+(3*mpref)+(5*spref)),y2,(spref+edgsp),buth,
2360 &(U.dupflag), 0, 0, 0, 0, "Causes metaball data to be duplicated with Shift+D");
2361 uiDefButBitS(block, TOG, USER_DUP_IPO, 0, "Ipo",
2362 (xpos+edgsp+(8*midsp)+(3*mpref)+(5*spref)),y1,(spref+edgsp),buth,
2363 &(U.dupflag), 0, 0, 0, 0, "Causes ipo data to be duplicated with Shift+D");
2365 } else if(U.userpref == 2) { /* language & colors */
2367 #ifdef INTERNATIONAL
2370 sprintf(curfont, "Interface Font: ");
2371 strcat(curfont,U.fontname);
2373 uiDefButBitS(block, TOG, USER_DOTRANSLATE, B_DOLANGUIFONT, "International Fonts",
2375 &(U.transopts), 0, 0, 0, 0, "Activate international interface");
2377 if(U.transopts & USER_DOTRANSLATE) {
2378 uiDefBut(block, LABEL,0,curfont,
2379 (xpos+edgsp+mpref+midsp),y2,mpref,buth,
2382 uiDefBut(block, BUT, B_LOADUIFONT, "Select Font",
2384 0, 0, 0, 0, 0, "Select a new font for the interface");
2387 uiDefButI(block, MENU|INT, B_SETFONTSIZE, fontsize_pup(),
2388 (xpos+edgsp+mpref+midsp),y1,mpref,buth,
2389 &U.fontsize, 0, 0, 0, 0, "Current interface font size (points)");
2392 uiDefButS(block, MENU|SHO, B_SETENCODING, encoding_pup(),
2393 (xpos+edgsp+mpref+midsp),y1,mpref,buth,
2394 &U.encoding, 0, 0, 0, 0, "Current interface font encoding");
2397 uiDefBut(block, LABEL,0,"Translate:",
2398 (xpos+edgsp+(2.1*mpref)+(2*midsp)),y3label,mpref,buth,
2402 uiDefButBitS(block, TOG, USER_TR_TOOLTIPS, B_SETTRANSBUTS, "Tooltips",
2403 (xpos+edgsp+(2.2*mpref)+(3*midsp)),y1,spref,buth,
2404 &(U.transopts), 0, 0, 0, 0, "Translate tooltips");
2406 uiDefButBitS(block, TOG, USER_TR_BUTTONS, B_SETTRANSBUTS, "Buttons",
2407 (xpos+edgsp+(2.2*mpref)+(4*midsp)+spref),y1,spref,buth,
2408 &(U.transopts), 0, 0, 0, 0, "Translate button labels");
2410 uiDefButBitS(block, TOG, USER_TR_MENUS, B_SETTRANSBUTS, "Toolbox",
2411 (xpos+edgsp+(2.2*mpref)+(5*midsp)+(2*spref)),y1,spref,buth,
2412 &(U.transopts), 0, 0, 0, 0, "Translate toolbox menu");
2414 uiDefButS(block, MENU|SHO, B_SETLANGUAGE, language_pup(),
2415 (xpos+edgsp+(2.2*mpref)+(3*midsp)),y2,mpref+(0.5*mpref)+3,buth,
2416 &U.language, 0, 0, 0, 0, "Select interface language");
2418 /* uiDefButBitS(block, TOG, USER_TR_TEXTEDIT, B_SETTRANSBUTS, "FTF All windows",
2419 (xpos+edgsp+(4*mpref)+(4*midsp)),y1,mpref,buth,
2420 &(U.transopts), 0, 0, 0, 0,
2421 "Use FTF drawing for fileselect and textwindow "
2422 "(under construction)");
2426 /* end of INTERNATIONAL */
2429 } else if(U.userpref == 3) { /* auto save */
2432 uiDefButS(block, NUM, 0, "Save Versions:",
2433 (xpos+edgsp),y3,mpref,buth,
2434 &U.versions, 0.0, 32.0, 0, 0,
2435 "The number of old versions to maintain in the current directory, when manually saving");
2437 uiDefButBitS(block, TOG, USER_AUTOSAVE, B_RESETAUTOSAVE, "Auto Save Temp Files",
2438 (xpos+edgsp+mpref+midsp),y3,mpref,buth,
2439 &(U.flag), 0, 0, 0, 0,
2440 "Enables automatic saving of temporary files");
2442 if(U.flag & USER_AUTOSAVE) {
2444 uiDefButI(block, NUM, B_RESETAUTOSAVE, "Minutes:",
2445 (xpos+edgsp+mpref+midsp),y2,mpref,buth,
2446 &(U.savetime), 1.0, 60.0, 0, 0,
2447 "The time (in minutes) to wait between automatic temporary saves");
2449 uiDefBut(block, BUT, B_LOADTEMP, "Open Recent",
2450 (xpos+edgsp+mpref+midsp),y1,mpref,buth,
2451 0, 0, 0, 0, 0,"Open the most recently saved temporary file");
2454 } else if (U.userpref == 4) { /* system & opengl */
2455 uiDefBut(block, LABEL,0,"Solid OpenGL light:",
2456 xpos+edgsp, y3label, mpref, buth,
2459 uiDefButS(block, MENU, B_REDR, "Light1 %x0|Light2 %x1|Light3 %x2",
2460 xpos+edgsp, y2, 2*mpref/6, buth, &cur_light, 0.0, 0.0, 0, 0, "");
2461 uiBlockSetCol(block, TH_BUT_SETTING1);
2462 uiDefButI(block, TOG|BIT|0, B_RECALCLIGHT, "On",
2463 xpos+edgsp+2*mpref/6, y2, mpref/6, buth,
2464 &U.light[cur_light].flag, 0.0, 0.0, 0, 0, "");
2466 uiBlockSetCol(block, TH_AUTO);
2467 uiDefButS(block, ROW, B_REDR, "Vec",
2468 xpos+edgsp+3*mpref/6, y2, mpref/6, buth,
2469 &cur_light_var, 123.0, 0.0, 0, 0, "");
2470 uiDefButS(block, ROW, B_REDR, "Col",
2471 xpos+edgsp+4*mpref/6, y2, mpref/6, buth,
2472 &cur_light_var, 123.0, 1.0, 0, 0, "");
2473 uiDefButS(block, ROW, B_REDR, "Spec",
2474 xpos+edgsp+5*mpref/6, y2, mpref/6, buth,
2475 &cur_light_var, 123.0, 2.0, 0, 0, "");
2477 if(cur_light_var==1) {
2478 uiDefButF(block, NUM, B_RECALCLIGHT, "R ",
2479 xpos+edgsp, y1, mpref/3, buth,
2480 U.light[cur_light].col, 0.0, 1.0, 100, 2, "");
2481 uiDefButF(block, NUM, B_RECALCLIGHT, "G ",
2482 xpos+edgsp+mpref/3, y1, mpref/3, buth,
2483 U.light[cur_light].col+1, 0.0, 1.0, 100, 2, "");
2484 uiDefButF(block, NUM, B_RECALCLIGHT, "B ",
2485 xpos+edgsp+2*mpref/3, y1, mpref/3, buth,
2486 U.light[cur_light].col+2, 0.0, 1.0, 100, 2, "");
2488 else if(cur_light_var==2) {
2489 uiDefButF(block, NUM, B_RECALCLIGHT, "sR ",
2490 xpos+edgsp, y1, mpref/3, buth,
2491 U.light[cur_light].spec, 0.0, 1.0, 100, 2, "");
2492 uiDefButF(block, NUM, B_RECALCLIGHT, "sG ",
2493 xpos+edgsp+mpref/3, y1, mpref/3, buth,
2494 U.light[cur_light].spec+1, 0.0, 1.0, 100, 2, "");
2495 uiDefButF(block, NUM, B_RECALCLIGHT, "sB ",
2496 xpos+edgsp+2*mpref/3, y1, mpref/3, buth,
2497 U.light[cur_light].spec+2, 0.0, 1.0, 100, 2, "");
2499 else if(cur_light_var==0) {
2500 uiDefButF(block, NUM, B_RECALCLIGHT, "X ",
2501 xpos+edgsp, y1, mpref/3, buth,
2502 U.light[cur_light].vec, -1.0, 1.0, 100, 2, "");
2503 uiDefButF(block, NUM, B_RECALCLIGHT, "Y ",
2504 xpos+edgsp+mpref/3, y1, mpref/3, buth,
2505 U.light[cur_light].vec+1, -1.0, 1.0, 100, 2, "");
2506 uiDefButF(block, NUM, B_RECALCLIGHT, "Z ",
2507 xpos+edgsp+2*mpref/3, y1, mpref/3, buth,
2508 U.light[cur_light].vec+2, -1.0, 1.0, 100, 2, "");
2512 uiDefButS(block, TOG|BIT|5, 0, "Log Events to Console",
2513 (xpos+edgsp),y2,lpref,buth,
2514 &(U.uiflag), 0, 0, 0, 0, "Display a list of input events in the console");
2516 uiDefButS(block, MENU|SHO, B_CONSOLEOUT, consolemethod_pup(),
2517 (xpos+edgsp), y1, lpref,buth,
2518 &U.console_out, 0, 0, 0, 0, "Select console output method");
2520 uiDefButS(block, NUM, B_CONSOLENUMLINES, "Lines:",
2521 (xpos+edgsp+lpref+midsp),y1,spref,buth,
2522 &U.console_buffer, 1.0, 4000.0, 0, 0, "Maximum number of internal console lines");
2526 uiDefBut(block, LABEL,0,"Win Codecs:",
2527 (xpos+edgsp+(1*midsp)+(1*mpref)),y3label,mpref,buth,
2530 uiDefButBitS(block, TOG, USER_ALLWINCODECS, 0, "Enable all codecs",
2531 (xpos+edgsp+(1*mpref)+(1*midsp)),y2,mpref,buth,
2532 &(U.uiflag), 0, 0, 0, 0, "Allows all codecs for rendering (not guaranteed)");
2535 uiDefBut(block, LABEL,0,"Keyboard:",
2536 (xpos+edgsp+(3*midsp)+(3*mpref)),y3label,mpref,buth,
2539 uiDefButBitS(block, TOG, USER_NO_CAPSLOCK, B_U_CAPSLOCK, "Disable Caps Lock",
2540 (xpos+edgsp+(3*midsp)+(3*mpref)),y1,mpref,buth,
2541 &(U.flag), 0, 0, 0, 0,
2542 "Disables the Caps Lock key when entering text");
2544 uiDefButBitS(block, TOG, USER_NONUMPAD, 0, "Emulate Numpad",
2545 (xpos+edgsp+(3*midsp)+(3*mpref)),y2,mpref,buth,
2546 &(U.flag), 0, 0, 0, 0,
2547 "Causes the 1 to 0 keys to act as the numpad (useful for laptops)");
2550 uiDefBut(block, LABEL,0,"System:",
2551 (xpos+edgsp+(4*midsp)+(4*mpref)),y3label,mpref,buth,
2554 uiDefButBitI(block, TOG, USER_DISABLE_SOUND, B_SOUNDTOGGLE, "Disable Sound",
2555 (xpos+edgsp+(4*mpref)+(4*midsp)),y2,mpref,buth,
2556 &(U.gameflags), 0, 0, 0, 0, "Disables sounds from being played");
2558 uiDefButBitS(block, TOG, USER_FILTERFILEEXTS, 0, "Filter File Extensions",
2559 (xpos+edgsp+(4*mpref)+(4*midsp)),y1,mpref,buth,
2560 &(U.uiflag), 0, 0, 0, 0, "Display only files with extensions in the image select window");
2563 uiDefBut(block, LABEL,0,"OpenGL:",
2564 (xpos+edgsp+(5*midsp)+(5*mpref)),y3label,mpref,buth,
2567 uiDefButBitI(block, TOGN, USER_DISABLE_MIPMAP, B_MIPMAPCHANGED, "Mipmaps",
2568 (xpos+edgsp+(5*mpref)+(5*midsp)),y2,mpref,buth,
2569 &(U.gameflags), 0, 0, 0, 0, "Toggles between mipmap textures on (beautiful) and off (fast)");
2571 uiDefButBitI(block, TOG, USER_VERTEX_ARRAYS, 0, "Vertex Arrays",
2572 (xpos+edgsp+(5*mpref)+(5*midsp)),y1,mpref,buth,
2573 &(U.gameflags), 0, 0, 0, 0, "Toggles between vertex arrays on (less reliable) and off (more reliable)");
2575 uiDefBut(block, LABEL,0,"Audio mixing buffer:",
2576 (xpos+edgsp+(2*midsp)+(2*mpref)),y3label,mpref,buth,
2578 uiBlockBeginAlign(block);
2579 uiDefButI(block, ROW, 0, "256",
2580 (xpos+edgsp+(2*midsp)+(2*mpref)),y2,(mpref/4),buth,
2581 &U.mixbufsize, 2.0, 256.0, 0, 0, "Set audio mixing buffer size to 256 samples");
2582 uiDefButI(block, ROW, 0, "512",
2583 (xpos+edgsp+(2*midsp)+(2*mpref)+(mpref/4)),y2,(mpref/4),buth,
2584 &U.mixbufsize, 2.0, 512.0, 0, 0, "Set audio mixing buffer size to 512 samples");
2585 uiDefButI(block, ROW, 0, "1024",
2586 (xpos+edgsp+(2*midsp)+(2*mpref)+(2*mpref/4)),y2,(mpref/4),buth,
2587 &U.mixbufsize, 2.0, 1024.0, 0, 0, "Set audio mixing buffer size to 1024 samples");
2588 uiDefButI(block, ROW, 0, "2048",
2589 (xpos+edgsp+(2*midsp)+(2*mpref)+(3*mpref/4)),y2,(mpref/4),buth,
2590 &U.mixbufsize, 2.0, 2048.0, 0, 0, "Set audio mixing buffer size to 2048 samples");
2591 uiBlockEndAlign(block);
2593 } else if(U.userpref == 5) { /* file paths */
2595 /* yafray: (temporary) path button for yafray xml export, now with fileselect */
2596 uiDefBut(block, TEX, 0, "YFexport: ",
2597 (xpos+edgsp), y2+buth+rspace, lpref-smfileselbut, buth,
2598 U.yfexportdir, 1.0, 63.0, 0, 0,
2599 "The default directory for yafray xml export (must exist!)");
2600 uiDefIconBut(block, BUT, B_YAFRAYDIRFILESEL, ICON_FILESEL,
2601 (xpos+edgsp+lpref-smfileselbut), y2+buth+rspace, smfileselbut, buth,
2602 0, 0, 0, 0, 0, "Select the default yafray export directory");
2604 uiDefBut(block, TEX, 0, "Fonts: ",
2605 (xpos+edgsp),y2,(lpref-smfileselbut),buth,
2606 U.fontdir, 1.0, 63.0, 0, 0,
2607 "The default directory to search for loading fonts");
2608 uiDefIconBut(block, BUT, B_FONTDIRFILESEL, ICON_FILESEL,
2609 (xpos+edgsp+lpref-smfileselbut),y2,smfileselbut,buth,
2610 0, 0, 0, 0, 0, "Select the default font directory");
2612 uiDefBut(block, TEX, 0, "Textures: ",
2613 (xpos+edgsp+lpref+midsp),y2,(lpref-smfileselbut),buth,
2614 U.textudir, 1.0, 63.0, 0, 0, "The default directory to search for textures");
2615 uiDefIconBut(block, BUT, B_TEXTUDIRFILESEL, ICON_FILESEL,
2616 (xpos+edgsp+(2*lpref)+midsp-smfileselbut),y2,smfileselbut,buth,
2617 0, 0, 0, 0, 0, "Select the default texture location");
2620 uiDefBut(block, TEX, 0, "Tex Plugins: ",
2621 (xpos+edgsp+(2*lpref)+(2*midsp)),y2,(lpref-smfileselbut),buth,
2622 U.plugtexdir, 1.0, 63.0, 0, 0, "The default directory to search for texture plugins");
2623 uiDefIconBut(block, BUT, B_PLUGTEXDIRFILESEL, ICON_FILESEL,
2624 (xpos+edgsp+(3*lpref)+(2*midsp)-smfileselbut),y2,smfileselbut,buth,
2625 0, 0, 0, 0, 0, "Select the default texture plugin location");
2627 uiDefBut(block, TEX, 0, "Seq Plugins: ",
2628 (xpos+edgsp+(3*lpref)+(3*midsp)),y2,(lpref-smfileselbut),buth,
2629 U.plugseqdir, 1.0, 63.0, 0, 0, "The default directory to search for sequence plugins");
2630 uiDefIconBut(block, BUT, B_PLUGSEQDIRFILESEL, ICON_FILESEL,
2631 (xpos+edgsp+(4*lpref)+(3*midsp)-smfileselbut),y2,smfileselbut,buth,
2632 0, 0, 0, 0, 0, "Select the default sequence plugin location");
2635 uiDefBut(block, TEX, 0, "Render: ",
2636 (xpos+edgsp),y1,(lpref-smfileselbut),buth,
2637 U.renderdir, 1.0, 63.0, 0, 0, "The default directory for rendering output");
2638 uiDefIconBut(block, BUT, B_RENDERDIRFILESEL, ICON_FILESEL,
2639 (xpos+edgsp+lpref-smfileselbut),y1,smfileselbut,buth,
2640 0, 0, 0, 0, 0, "Select the default render output location");
2642 uiDefBut(block, TEX, 0, "Python: ",
2643 (xpos+edgsp+lpref+midsp),y1,(lpref-2*smfileselbut),buth,
2644 U.pythondir, 1.0, 63.0, 0, 0, "The default directory to search for Python scripts");
2645 uiDefIconBut(block, BUT, B_PYMENUEVAL, ICON_SCRIPT,
2646 (xpos+edgsp+(2*lpref)+midsp-2*smfileselbut),y1,smfileselbut,buth,
2647 0, 0, 0, 0, 0, "Re-evaluate scripts registration in menus");
2648 uiDefIconBut(block, BUT, B_PYTHONDIRFILESEL, ICON_FILESEL,
2649 (xpos+edgsp+(2*lpref)+midsp-smfileselbut),y1,smfileselbut,buth,
2650 0, 0, 0, 0, 0, "Select the default Python script location");
2653 uiDefBut(block, TEX, 0, "Sounds: ",
2654 (xpos+edgsp+(2*lpref)+(2*midsp)),y1,(lpref-smfileselbut),buth,
2655 U.sounddir, 1.0, 63.0, 0, 0, "The default directory to search for sounds");
2656 uiDefIconBut(block, BUT, B_SOUNDDIRFILESEL, ICON_FILESEL,
2657 (xpos+edgsp+(3*lpref)+(2*midsp)-smfileselbut),y1,smfileselbut,buth,
2658 0, 0, 0, 0, 0, "Select the default sound location");
2660 uiDefBut(block, TEX, 0, "Temp: ",
2661 (xpos+edgsp+(3*lpref)+(3*midsp)),y1,(lpref-smfileselbut),buth,
2662 U.tempdir, 1.0, 63.0, 0, 0, "The directory for storing temporary save files");
2663 uiDefIconBut(block, BUT, B_TEMPDIRFILESEL, ICON_FILESEL,
2664 (xpos+edgsp+(4*lpref)+(3*midsp)-smfileselbut),y1,smfileselbut,buth,
2665 0, 0, 0, 0, 0, "Select the default temporary save file location");
2671 myortho2(-0.375, (float)(sa->winx)-0.375, -0.375, (float)(sa->winy)-0.375);
2672 draw_area_emboss(sa);
2673 myortho2(0.0, 1280.0, 0.0, curarea->winy/fac);
2674 sa->win_swap= WIN_BACK_OK;
2679 void winqreadinfospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
2681 unsigned short event= evt->event;
2682 short val= evt->val;
2685 if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
2689 if(val==B_ADD_THEME) {
2690 bTheme *btheme, *new;
2692 btheme= U.themes.first;
2693 new= MEM_callocN(sizeof(bTheme), "theme");
2694 memcpy(new, btheme, sizeof(bTheme));
2695 BLI_addhead(&U.themes, new);
2696 strcpy(new->name, "New User Theme");
2697 addqueue(sa->win, REDRAW, 1);
2699 else if(val==B_DEL_THEME) {
2700 bTheme *btheme= U.themes.first;
2701 BLI_remlink(&U.themes, btheme);
2703 BIF_SetTheme(sa); // prevent usage of old theme in calls
2704 addqueue(sa->win, REDRAW, 1);
2706 else if(val==B_NAME_THEME) {
2707 bTheme *btheme= U.themes.first;
2708 if(strcmp(btheme->name, "Default")==0) {
2709 strcpy(btheme->name, "New User Theme");
2710 addqueue(sa->win, REDRAW, 1);
2713 else if(val==B_UPDATE_THEME) {
2714 allqueue(REDRAWALL, 0);
2716 else if(val==B_CHANGE_THEME) {
2717 th_curcol= TH_BACK; // backdrop color is always there...
2718 addqueue(sa->win, REDRAW, 1);
2720 else if(val==B_THEME_COPY) {
2722 th_curcol_arr[0]= th_curcol_ptr[0];
2723 th_curcol_arr[1]= th_curcol_ptr[1];
2724 th_curcol_arr[2]= th_curcol_ptr[2];
2725 th_curcol_arr[3]= th_curcol_ptr[3];
2726 addqueue(sa->win, REDRAW, 1);
2729 else if(val==B_THEME_PASTE) {
2731 th_curcol_ptr[0]= th_curcol_arr[0];
2732 th_curcol_ptr[1]= th_curcol_arr[1];
2733 th_curcol_ptr[2]= th_curcol_arr[2];
2734 th_curcol_ptr[3]= th_curcol_arr[3];
2735 allqueue(REDRAWALL, 0);
2738 else if(val==B_RECALCLIGHT) {
2739 if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0)
2743 addqueue(sa->win, REDRAW, 1);
2744 allqueue(REDRAWVIEW3D, 0);
2746 else do_global_buttons(val);
2753 void init_infospace(ScrArea *sa)
2757 sinfo= MEM_callocN(sizeof(SpaceInfo), "initinfo");
2758 BLI_addhead(&sa->spacedata, sinfo);
2760 sinfo->spacetype=SPACE_INFO;
2763 /* ******************** SPACE: BUTS ********************** */
2765 extern void drawbutspace(ScrArea *sa, void *spacedata); /* buttons.c */
2767 static void changebutspace(ScrArea *sa, void *spacedata)
2769 if(G.v2d==0) return;
2771 test_view2d(G.v2d, curarea->winx, curarea->winy);
2772 myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
2775 void winqreadbutspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
2777 unsigned short event= evt->event;
2778 short val= evt->val;
2779 SpaceButs *sbuts= curarea->spacedata.first;
2780 ScrArea *sa2, *sa3d;
2781 int nr, doredraw= 0;
2785 if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
2794 case WHEELDOWNMOUSE: