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 void free_soundspace(SpaceSound *ssound);
159 /* *************************************** */
161 /* don't know yet how the handlers will evolve, for simplicity
162 i choose for an array with eventcodes, this saves in a file!
164 void add_blockhandler(ScrArea *sa, short eventcode, short val)
166 SpaceLink *sl= sa->spacedata.first;
170 for(a=0; a<SPACE_MAXHANDLER; a+=2) {
171 if( sl->blockhandler[a]==eventcode ) {
172 sl->blockhandler[a+1]= val;
175 else if( sl->blockhandler[a]==0) {
176 sl->blockhandler[a]= eventcode;
177 sl->blockhandler[a+1]= val;
181 if(a==SPACE_MAXHANDLER) printf("error; max (4) blockhandlers reached!\n");
184 void rem_blockhandler(ScrArea *sa, short eventcode)
186 SpaceLink *sl= sa->spacedata.first;
189 for(a=0; a<SPACE_MAXHANDLER; a+=2) {
190 if( sl->blockhandler[a]==eventcode) {
191 sl->blockhandler[a]= 0;
197 void toggle_blockhandler(ScrArea *sa, short eventcode, short val)
199 SpaceLink *sl= sa->spacedata.first;
203 for(a=0; a<SPACE_MAXHANDLER; a+=2) {
204 if( sl->blockhandler[a]==eventcode ) {
205 sl->blockhandler[a]= 0;
209 if(addnew) add_blockhandler(sa, eventcode, val);
214 /* ************* SPACE: VIEW3D ************* */
216 /* extern void drawview3dspace(ScrArea *sa, void *spacedata); BSE_drawview.h */
219 void copy_view3d_lock(short val)
224 /* from G.scene copy to the other views */
225 sc= G.main->screen.first;
228 if(sc->scene==G.scene) {
229 ScrArea *sa= sc->areabase.first;
231 SpaceLink *sl= sa->spacedata.first;
233 if(sl->spacetype==SPACE_OOPS && val==REDRAW) {
234 if(sa->win) scrarea_queue_winredraw(sa);
236 else if(sl->spacetype==SPACE_VIEW3D) {
237 View3D *vd= (View3D*) sl;
238 if(vd->scenelock && vd->localview==0) {
239 vd->lay= G.scene->lay;
240 vd->camera= G.scene->camera;
242 if(vd->camera==0 && vd->persp>1) vd->persp= 1;
244 if( (vd->lay & vd->layact) == 0) {
247 if(vd->lay & (1<<bit)) {
255 if(val==REDRAW && vd==sa->spacedata.first) {
256 if(sa->win) scrarea_queue_redraw(sa);
269 void handle_view3d_around()
273 if ((U.uiflag & USER_LOCKAROUND)==0) return;
275 /* copies from G.vd->around to other view3ds */
277 sc= G.main->screen.first;
280 if(sc->scene==G.scene) {
281 ScrArea *sa= sc->areabase.first;
283 SpaceLink *sl= sa->spacedata.first;
285 if(sl->spacetype==SPACE_VIEW3D) {
286 View3D *vd= (View3D*) sl;
288 vd->around= G.vd->around;
289 if (G.vd->flag & V3D_ALIGN)
290 vd->flag |= V3D_ALIGN;
292 vd->flag &= ~V3D_ALIGN;
293 scrarea_queue_headredraw(sa);
305 void handle_view3d_lock()
308 if(G.vd->localview==0 && G.vd->scenelock && curarea->spacetype==SPACE_VIEW3D) {
311 G.scene->lay= G.vd->lay;
312 G.scene->camera= G.vd->camera;
314 copy_view3d_lock(REDRAW);
319 void space_set_commmandline_options(void) {
320 SYS_SystemHandle syshandle;
323 if ( (syshandle = SYS_GetSystem()) ) {
324 /* User defined settings */
325 a= (U.gameflags & USER_VERTEX_ARRAYS);
326 SYS_WriteCommandLineInt(syshandle, "vertexarrays", a);
328 a= (U.gameflags & USER_DISABLE_SOUND);
329 SYS_WriteCommandLineInt(syshandle, "noaudio", a);
331 a= (U.gameflags & USER_DISABLE_MIPMAP);
333 SYS_WriteCommandLineInt(syshandle, "nomipmap", a);
335 /* File specific settings: */
336 /* Only test the first one. These two are switched
338 a= (G.fileflags & G_FILE_SHOW_FRAMERATE);
339 SYS_WriteCommandLineInt(syshandle, "show_framerate", a);
340 SYS_WriteCommandLineInt(syshandle, "show_profile", a);
342 /* When in wireframe mode, always draw debug props. */
344 a = ( (G.fileflags & G_FILE_SHOW_DEBUG_PROPS)
345 || (G.vd->drawtype == OB_WIRE)
346 || (G.vd->drawtype == OB_SOLID) );
347 SYS_WriteCommandLineInt(syshandle, "show_properties", a);
350 a= (G.fileflags & G_FILE_ENABLE_ALL_FRAMES);
351 SYS_WriteCommandLineInt(syshandle, "fixedtime", a);
357 * These two routines imported from the gameengine,
358 * I suspect a lot of the resetting stuff is cruft
359 * and can be removed, but it should be checked.
361 static void SaveState(void)
363 glPushAttrib(GL_ALL_ATTRIB_BITS);
368 if(G.scene->camera==0 || G.scene->camera->type!=OB_CAMERA)
369 error("no (correct) camera");
374 static void RestoreState(void)
376 curarea->win_swap = 0;
377 curarea->head_swap=0;
378 allqueue(REDRAWVIEW3D, 0);
379 allqueue(REDRAWBUTSALL, 0);
386 static LinkNode *save_and_reset_all_scene_cfra(void)
388 LinkNode *storelist= NULL;
391 for (sc= G.main->scene.first; sc; sc= sc->id.next) {
392 BLI_linklist_prepend(&storelist, (void*) (long) sc->r.cfra);
398 BLI_linklist_reverse(&storelist);
403 static void restore_all_scene_cfra(LinkNode *storelist) {
404 LinkNode *sc_store= storelist;
407 for (sc= G.main->scene.first; sc; sc= sc->id.next) {
408 int stored_cfra= (int) sc_store->link;
410 sc->r.cfra= stored_cfra;
413 sc_store= sc_store->next;
416 BLI_linklist_free(storelist, NULL);
420 void start_game(void)
424 Scene *sc, *startscene = G.scene;
425 LinkNode *scene_cfra_store;
427 /* XXX, silly code - the game engine can
428 * access any scene through logic, so we try
429 * to make sure each scene has a valid camera,
430 * just in case the game engine tries to use it.
432 * Better would be to make a better routine
433 * in the game engine for finding the camera.
436 for (sc= G.main->scene.first; sc; sc= sc->id.next) {
440 for (base= sc->base.first; base; base= base->next)
441 if (base->object->type==OB_CAMERA)
444 sc->camera= base?base->object:NULL;
448 /* these two lines make sure front and backbuffer are equal. for swapbuffers */
450 screen_swapbuffers();
452 /* can start from header */
453 mywinset(curarea->win);
455 scene_cfra_store= save_and_reset_all_scene_cfra();
458 /* game engine will do its own sounds. */
459 sound_stop_all_sounds();
462 /* Before jumping into Ketsji, we configure some settings. */
463 space_set_commmandline_options();
466 StartKetsjiShell(curarea, startscene->id.name+2, G.main, 1);
469 /* Restart BPY - unload the game engine modules. */
472 BPY_post_start_python(); /* userpref path and menus init */
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) || !(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 /* *************** */
623 void BIF_undo_push(char *str)
626 if(G.obedit->type==OB_MESH)
628 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
629 undo_push_curve(str);
632 if(U.uiflag & USER_GLOBALUNDO)
639 extern void undo_curve_step(int step); // editcurve.c
642 if(G.obedit->type==OB_MESH)
644 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
649 if (G.f & G_FACESELECT)
651 else if(G.f & G_WEIGHTPAINT)
653 else if(G.f & G_VERTEXPAINT)
656 if(U.uiflag & USER_GLOBALUNDO) BKE_undo_step(1);
663 extern void undo_curve_step(int step); // editcurve.c
666 if(G.obedit->type==OB_MESH)
668 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
673 if (G.f & G_FACESELECT)
675 else if(G.f & G_WEIGHTPAINT)
677 else if(G.f & G_VERTEXPAINT)
680 if(U.uiflag & USER_GLOBALUNDO) BKE_undo_step(-1);
685 void BIF_undo_menu(void)
688 if(G.obedit->type==OB_MESH)
690 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
691 ;//undo_menu_curve();
694 if (G.f & G_FACESELECT)
696 else if(G.f & G_WEIGHTPAINT)
698 else if(G.f & G_VERTEXPAINT)
701 if(U.uiflag & USER_GLOBALUNDO) BKE_undo_menu();
707 /* *************** */
709 void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
711 unsigned short event= evt->event;
713 char ascii= evt->ascii;
714 View3D *v3d= curarea->spacedata.first;
717 int doredraw= 0, pupval;
719 if(curarea->win==0) return; /* when it comes from sa->headqread() */
723 if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
724 if(event==MOUSEY || event==MOUSEX) return;
726 if(event==UI_BUT_EVENT) do_butspace(val); // temporal, view3d deserves own queue?
728 /* swap mouse buttons based on user preference */
729 if (U.flag & USER_LMOUSESELECT) {
730 if (evt->event == LEFTMOUSE) {
732 } else if (evt->event == RIGHTMOUSE) {
738 if((G.obedit) && G.obedit->type==OB_FONT) {
745 /* use '&' here, because of alt+leftmouse which emulates middlemouse */
746 if(U.flag & USER_VIEWMOVE) {
747 if((G.qual==LR_SHIFTKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_SHIFTKEY))))
749 else if((G.qual==LR_CTRLKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_CTRLKEY))))
751 else if((G.qual==0) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==LR_ALTKEY)))
755 if((G.qual==LR_SHIFTKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_SHIFTKEY))))
757 else if((G.qual==LR_CTRLKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_CTRLKEY))))
765 /* Regular: Zoom in */
766 /* Shift: Scroll up */
767 /* Ctrl: Scroll right */
768 /* Alt-Shift: Rotate up */
769 /* Alt-Ctrl: Rotate right */
771 if( G.qual & LR_SHIFTKEY ) {
772 if( G.qual & LR_ALTKEY ) {
773 G.qual &= ~LR_SHIFTKEY;
775 G.qual |= LR_SHIFTKEY;
779 } else if( G.qual & LR_CTRLKEY ) {
780 if( G.qual & LR_ALTKEY ) {
781 G.qual &= ~LR_CTRLKEY;
783 G.qual |= LR_CTRLKEY;
787 } else if(U.uiflag & USER_WHEELZOOMDIR)
788 persptoetsen(PADMINUS);
790 persptoetsen(PADPLUSKEY);
796 /* Regular: Zoom out */
797 /* Shift: Scroll down */
798 /* Ctrl: Scroll left */
799 /* Alt-Shift: Rotate down */
800 /* Alt-Ctrl: Rotate left */
802 if( G.qual & LR_SHIFTKEY ) {
803 if( G.qual & LR_ALTKEY ) {
804 G.qual &= ~LR_SHIFTKEY;
806 G.qual |= LR_SHIFTKEY;
810 } else if( G.qual & LR_CTRLKEY ) {
811 if( G.qual & LR_ALTKEY ) {
812 G.qual &= ~LR_CTRLKEY;
814 G.qual |= LR_CTRLKEY;
818 } else if(U.uiflag & USER_WHEELZOOMDIR)
819 persptoetsen(PADPLUSKEY);
821 persptoetsen(PADMINUS);
827 if(G.qual==LR_ALTKEY) {
832 do_textedit(event, val, ascii);
836 if(G.qual==LR_ALTKEY) {
841 do_textedit(event, val, ascii);
844 case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
845 case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
852 do_textedit(event, val, ascii);
858 if (U.flag & USER_NONUMPAD) {
859 event= convert_for_nonumpad(event);
868 /* LEFTMOUSE and RIGHTMOUSE event codes can be swapped above,
869 * based on user preference USER_LMOUSESELECT
872 if ((G.obedit) || !(G.f&(G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) {
874 } else if (G.f & G_VERTEXPAINT) {
877 else if (G.f & G_WEIGHTPAINT){
880 else if (G.f & G_TEXTUREPAINT) {
885 /* use '&' here, because of alt+leftmouse which emulates middlemouse */
886 if(U.flag & USER_VIEWMOVE) {
887 if((G.qual==LR_SHIFTKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_SHIFTKEY))))
889 else if((G.qual==LR_CTRLKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_CTRLKEY))))
891 else if((G.qual==0) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==LR_ALTKEY)))
895 if((G.qual==LR_SHIFTKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_SHIFTKEY))))
897 else if((G.qual==LR_CTRLKEY) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==(LR_ALTKEY|LR_CTRLKEY))))
899 else if((G.qual==0) || ((U.flag & USER_TWOBUTTONMOUSE) && (G.qual==LR_ALTKEY)))
904 if((G.obedit) && (G.qual & LR_CTRLKEY)==0) {
905 if(G.obedit->type==OB_MESH)
907 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
909 else if(G.obedit->type==OB_MBALL)
911 else if(G.obedit->type==OB_LATTICE)
913 else if(G.obedit->type==OB_ARMATURE)
916 else if((G.obedit) && (G.qual == (LR_CTRLKEY|LR_ALTKEY)))
917 mouse_mesh(); // edge select
918 else if((G.obedit) && (G.qual == (LR_CTRLKEY|LR_ALTKEY|LR_SHIFTKEY)))
919 mouse_mesh(); // edge select
921 if (G.obpose->type==OB_ARMATURE)
922 mousepose_armature();
924 else if(G.qual==LR_CTRLKEY)
925 mouse_select(); // also allow in editmode, for vertex parenting
926 else if(G.f & G_FACESELECT)
928 else if( G.f & (G_VERTEXPAINT|G_TEXTUREPAINT))
934 /* Regular: Zoom in */
935 /* Shift: Scroll up */
936 /* Ctrl: Scroll right */
937 /* Alt-Shift: Rotate up */
938 /* Alt-Ctrl: Rotate right */
940 if( G.qual & LR_SHIFTKEY ) {
941 if( G.qual & LR_ALTKEY ) {
942 G.qual &= ~LR_SHIFTKEY;
944 G.qual |= LR_SHIFTKEY;
948 } else if( G.qual & LR_CTRLKEY ) {
949 if( G.qual & LR_ALTKEY ) {
950 G.qual &= ~LR_CTRLKEY;
952 G.qual |= LR_CTRLKEY;
956 } else if(U.uiflag & USER_WHEELZOOMDIR)
957 persptoetsen(PADMINUS);
959 persptoetsen(PADPLUSKEY);
964 /* Regular: Zoom out */
965 /* Shift: Scroll down */
966 /* Ctrl: Scroll left */
967 /* Alt-Shift: Rotate down */
968 /* Alt-Ctrl: Rotate left */
970 if( G.qual & LR_SHIFTKEY ) {
971 if( G.qual & LR_ALTKEY ) {
972 G.qual &= ~LR_SHIFTKEY;
974 G.qual |= LR_SHIFTKEY;
978 } else if( G.qual & LR_CTRLKEY ) {
979 if( G.qual & LR_ALTKEY ) {
980 G.qual &= ~LR_CTRLKEY;
982 G.qual |= LR_CTRLKEY;
986 } else if(U.uiflag & USER_WHEELZOOMDIR)
987 persptoetsen(PADPLUSKEY);
989 persptoetsen(PADMINUS);
996 if(G.qual==LR_CTRLKEY) {
997 if(ob && ob->type == OB_MESH) {
998 flip_subdivison(ob, 1);
1001 else do_layer_buttons(0);
1006 if(G.qual==LR_CTRLKEY) {
1007 if(ob && ob->type == OB_MESH) {
1008 flip_subdivison(ob, 2);
1011 else do_layer_buttons(1);
1016 if(G.qual==LR_CTRLKEY) {
1017 if(ob && ob->type == OB_MESH) {
1018 flip_subdivison(ob, 3);
1021 else do_layer_buttons(2);
1026 if(G.qual==LR_CTRLKEY) {
1027 if(ob && ob->type == OB_MESH) {
1028 flip_subdivison(ob, 4);
1031 else do_layer_buttons(3);
1035 do_layer_buttons(4); break;
1037 do_layer_buttons(5); break;
1039 do_layer_buttons(6); break;
1041 do_layer_buttons(7); break;
1043 do_layer_buttons(8); break;
1045 do_layer_buttons(9); break;
1047 do_layer_buttons(10); break;
1049 do_layer_buttons(11); break;
1050 case ACCENTGRAVEKEY:
1051 do_layer_buttons(-1); break;
1054 if(G.qual & LR_CTRLKEY) apply_object(); // also with shift!
1055 else if((G.qual==LR_SHIFTKEY)) {
1060 if(G.obedit->type==OB_MESH)
1062 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
1064 else if(G.obedit->type==OB_MBALL)
1065 deselectall_mball();
1066 else if(G.obedit->type==OB_LATTICE)
1068 else if(G.obedit->type==OB_ARMATURE)
1069 deselectall_armature();
1072 switch (G.obpose->type){
1074 deselectall_posearmature(1);
1079 if(G.f & G_FACESELECT) deselectall_tface();
1081 /* by design, the center of the active object
1082 * (which need not necessarily by selected) will
1083 * still be drawn as if it were selected.
1091 if((G.qual==LR_SHIFTKEY))
1092 set_render_border();
1093 else if((G.qual==LR_ALTKEY)){
1094 if(G.obedit && G.obedit->type==OB_MESH) {
1095 /* Loop Select Operations */
1098 vertex_loop_select();
1101 else if((G.qual==0))
1105 if(G.qual==LR_CTRLKEY) {
1108 else if(G.qual==LR_ALTKEY) {
1109 convertmenu(); /* editobject.c */
1111 else if((G.qual==LR_SHIFTKEY)) {
1113 curs= give_cursor();
1114 curs[0]=curs[1]=curs[2]= 0.0;
1115 allqueue(REDRAWVIEW3D, 0);
1117 else if((G.obedit) && ELEM(G.obedit->type, OB_CURVE, OB_SURF) ) {
1119 makeDispList(G.obedit);
1120 allqueue(REDRAWVIEW3D, 0);
1122 else if((G.qual==0)){
1123 curs= give_cursor();
1124 G.vd->ofs[0]= -curs[0];
1125 G.vd->ofs[1]= -curs[1];
1126 G.vd->ofs[2]= -curs[2];
1127 scrarea_queue_winredraw(curarea);
1132 if((G.qual==LR_SHIFTKEY)) {
1133 duplicate_context_selected();
1135 else if(G.qual==LR_ALTKEY) {
1137 error ("Duplicate not possible in posemode.");
1138 else if((G.obedit==0))
1141 else if(G.qual==LR_CTRLKEY) {
1144 else if((G.qual==0)){
1145 pupval= pupmenu("Draw mode%t|BoundBox %x1|Wire %x2|OpenGL Solid %x3|Shaded Solid %x4|Textured Solid %x5");
1147 G.vd->drawtype= pupval;
1157 if(G.obedit->type==OB_MESH)
1159 else if(G.obedit->type==OB_CURVE)
1161 else if(G.obedit->type==OB_SURF)
1163 else if(G.obedit->type==OB_ARMATURE)
1168 if(ob && ob->type==OB_IKA) if(okee("extrude IKA"))
1172 else if (G.qual==LR_CTRLKEY) {
1173 if(G.obedit && G.obedit->type==OB_MESH)
1176 else if (G.qual==LR_SHIFTKEY) {
1177 if (G.obedit && G.obedit->type==OB_MESH) {
1184 if(G.obedit->type==OB_MESH) {
1185 if((G.qual==LR_SHIFTKEY))
1187 else if(G.qual==LR_ALTKEY)
1189 else if(G.qual==LR_CTRLKEY)
1194 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) addsegment_nurb();
1196 else if(G.qual==LR_CTRLKEY)
1198 else if((G.qual==LR_SHIFTKEY))
1206 /* RMGRP if(G.qual & LR_CTRLKEY) add_selected_to_group();
1207 else if(G.qual & LR_ALTKEY) rem_selected_from_group(); */
1208 if((G.qual==LR_SHIFTKEY))
1209 select_group_menu();
1210 else if(G.qual==LR_ALTKEY)
1212 else if((G.qual==0))
1217 if(G.obedit->type==OB_MESH) {
1218 if(G.qual==LR_CTRLKEY)
1220 else if(G.qual==LR_ALTKEY)
1222 else if((G.qual==LR_SHIFTKEY))
1224 else if((G.qual==0))
1227 else if(G.obedit->type== OB_SURF) {
1228 if(G.qual==LR_CTRLKEY)
1230 else if(G.qual==LR_ALTKEY)
1232 else if((G.qual==LR_SHIFTKEY))
1234 else if((G.qual==0))
1237 else if(G.obedit->type==OB_CURVE) {
1238 if(G.qual==LR_CTRLKEY)
1241 undo_push_curve("Handle change");
1242 if(G.qual==LR_CTRLKEY)
1243 autocalchandlesNurb_all(1); /* flag=1, selected */
1244 else if((G.qual==LR_SHIFTKEY))
1246 else if((G.qual==0))
1249 makeDispList(G.obedit);
1251 allqueue(REDRAWVIEW3D, 0);
1254 else if(G.obedit->type==OB_LATTICE) {
1255 if(G.qual==LR_CTRLKEY) add_hook();
1258 else if(G.f & G_FACESELECT)
1262 hide_selected_pose_bones();
1263 else if (G.qual==LR_SHIFTKEY)
1264 hide_unselected_pose_bones();
1265 else if (G.qual==LR_ALTKEY)
1266 show_all_pose_bones();
1273 if(G.qual==LR_CTRLKEY) {
1275 if(ob->type == OB_MESH)
1277 else if(ob->type == OB_CURVE)
1278 join_curve(OB_CURVE);
1279 else if(ob->type == OB_SURF)
1280 join_curve(OB_SURF);
1281 else if(ob->type == OB_ARMATURE)
1284 else if ((G.obedit) && ELEM(G.obedit->type, OB_CURVE, OB_SURF))
1288 if(G.obedit->type==OB_MESH) {
1296 if (G.obedit->type==OB_MESH) {
1297 if (G.qual==LR_SHIFTKEY)
1298 KnifeSubdivide(KNIFE_PROMPT);
1302 else if(G.obedit->type==OB_SURF)
1306 if((G.qual==LR_SHIFTKEY)) {
1307 if(G.f & G_FACESELECT)
1308 clear_vpaint_selectedfaces();
1309 else if(G.f & G_VERTEXPAINT)
1312 select_select_keys();
1314 else if(G.qual==LR_CTRLKEY)
1316 /* else if(G.qual & LR_ALTKEY) delete_skeleton(); */
1324 if(G.obedit->type==OB_MESH)
1325 selectconnected_mesh(G.qual);
1326 if(G.obedit->type==OB_ARMATURE)
1327 selectconnected_armature();
1328 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
1329 selectconnected_nurb();
1332 if(G.obpose->type==OB_ARMATURE)
1333 selectconnected_posearmature();
1336 if((G.qual==LR_SHIFTKEY))
1338 else if(G.qual==LR_CTRLKEY)
1340 else if(G.f & G_FACESELECT)
1341 select_linked_tfaces();
1342 else if((G.qual==0))
1348 if(G.qual==LR_ALTKEY) {
1349 if(G.obedit->type==OB_MESH) {
1351 makeDispList(G.obedit);
1354 else if((G.qual==0) || (G.qual==LR_CTRLKEY)) {
1357 if(G.qual & (LR_SHIFTKEY | LR_ALTKEY | LR_CTRLKEY)) {
1358 if(G.obedit->type==OB_MESH) select_non_manifold();
1361 else if(G.qual & LR_CTRLKEY) {
1364 else if(G.qual==0) {
1370 toggle_blockhandler(curarea, VIEW3D_HANDLER_OBJECT, UI_PNL_TO_MOUSE);
1371 allqueue(REDRAWVIEW3D, 0);
1374 switch (G.obedit->type){
1376 if(G.qual==LR_CTRLKEY){
1377 if (okee("Recalculate bone roll angles")) {
1378 auto_align_armature();
1379 allqueue(REDRAWVIEW3D, 0);
1384 if(G.qual==(LR_SHIFTKEY|LR_CTRLKEY)) {
1385 if(okee("Recalculate normals inside")) {
1386 undo_push_mesh("Recalculate normals inside");
1388 allqueue(REDRAWVIEW3D, 0);
1391 else if(G.qual==LR_CTRLKEY){
1392 if(okee("Recalculate normals outside")) {
1393 undo_push_mesh("Recalculate normals outside");
1395 allqueue(REDRAWVIEW3D, 0);
1406 extern int prop_mode;
1408 if (G.qual==LR_SHIFTKEY) {
1409 prop_mode= !prop_mode;
1410 allqueue(REDRAWHEADERS, 0);
1412 else if((G.qual==0)) {
1413 G.f ^= G_PROPORTIONAL;
1414 allqueue(REDRAWHEADERS, 0);
1417 else if((G.qual==LR_SHIFTKEY)) {
1418 if(ob && ob->type == OB_MESH) {
1419 flip_subdivison(ob, -1);
1422 else if(G.qual==LR_ALTKEY) clear_object('o');
1428 if(G.qual==LR_CTRLKEY || G.qual==(LR_SHIFTKEY|LR_CTRLKEY))
1430 else if((G.qual==0) && G.obedit->type==OB_MESH)
1432 else if ((G.qual==0) && ELEM(G.obedit->type, OB_CURVE, OB_SURF))
1435 else if(G.qual==LR_CTRLKEY || G.qual==(LR_SHIFTKEY|LR_CTRLKEY))
1437 else if(G.qual==LR_ALTKEY)
1439 else if((G.qual==0)) {
1444 if((G.obedit==0) && (G.f & G_FACESELECT) && (G.qual==0))
1446 else if(G.qual==LR_ALTKEY)
1448 else if (G.obedit) {
1449 if((G.qual==LR_SHIFTKEY)) {
1450 if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
1452 else if (G.obedit->type==OB_MESH)
1453 loopoperations(LOOP_SELECT);
1455 else if(G.qual==LR_CTRLKEY) {
1456 if (G.obedit->type==OB_MESH)
1457 loopoperations(LOOP_CUT);
1459 else if((G.qual==0))
1462 else if((G.qual==0))
1467 if(G.qual==LR_ALTKEY)
1468 transform('N'); /* scale along normal */
1469 else if(G.qual==LR_CTRLKEY)
1471 else if(G.qual==LR_SHIFTKEY)
1473 else if((G.qual==0))
1476 else if(G.qual==LR_ALTKEY) {
1479 else if((G.qual==LR_SHIFTKEY))
1481 else if((G.qual==0))
1486 if((G.qual==LR_CTRLKEY) && G.obedit->type==OB_MESH) {
1487 convert_to_triface(0);
1488 allqueue(REDRAWVIEW3D, 0);
1490 makeDispList(G.obedit);
1492 else if((G.qual==LR_ALTKEY) && G.obedit->type==OB_CURVE)
1494 else if((G.qual==0))
1497 else if(G.qual==LR_CTRLKEY) {
1500 else if(G.qual==LR_ALTKEY) {
1503 else if((G.qual==0)){
1510 if(G.obedit->type==OB_MESH){
1511 if (G.qual==LR_ALTKEY)
1513 else if (G.qual==LR_SHIFTKEY)
1515 else if((G.qual==0))
1518 else if(G.obedit->type==OB_ARMATURE)
1519 remake_editArmature();
1520 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
1521 extern void undo_curve_step(int step);
1522 if (G.qual==LR_ALTKEY)
1523 //undo_menu_curve();
1525 else if (G.qual==LR_SHIFTKEY)
1526 undo_curve_step(-1);
1527 else if((G.qual==0))
1530 else if(G.obedit->type==OB_LATTICE)
1533 else if((G.qual==0)){
1534 if (G.f & G_FACESELECT)
1535 uv_autocalc_tface();
1536 else if(G.f & G_WEIGHTPAINT)
1538 else if(G.f & G_VERTEXPAINT)
1541 if(U.uiflag & USER_GLOBALUNDO) BIF_undo();
1545 else if(G.qual==LR_SHIFTKEY)
1546 if(U.uiflag & USER_GLOBALUNDO) BIF_redo();
1551 if((G.qual==LR_SHIFTKEY)) {
1552 if ((G.obedit) && G.obedit->type==OB_MESH) {
1553 align_view_to_selected(v3d);
1555 else if (G.f & G_FACESELECT) {
1556 align_view_to_selected(v3d);
1559 else if(G.qual==LR_ALTKEY)
1561 else if (G.qual==0){
1563 if(G.obedit->type==OB_CURVE) {
1564 undo_push_curve("Handle change");
1566 makeDispList(G.obedit);
1567 allqueue(REDRAWVIEW3D, 0);
1570 else if(ob && ob->type == OB_MESH)
1575 if((G.qual==LR_SHIFTKEY)) {
1578 else if(G.qual==LR_ALTKEY) {
1579 /* if(G.obedit && G.obedit->type==OB_MESH) write_videoscape(); */
1581 else if(G.qual==LR_CTRLKEY) {
1583 if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
1584 switchdirectionNurb2();
1588 else if((G.qual==0))
1595 delete_context_selected();
1598 if((G.qual==0) && (G.obedit)) {
1599 if(G.obedit->type==OB_MESH) split_mesh();
1605 scrarea_queue_headredraw(curarea);
1606 scrarea_queue_winredraw(curarea);
1614 if(G.qual==LR_CTRLKEY) {
1615 G.vd->around= V3D_CENTROID;
1616 } else if(G.qual==LR_SHIFTKEY) {
1617 G.vd->around= V3D_CENTROID;
1618 } else if(G.qual==0) {
1619 G.vd->around= V3D_CENTRE;
1621 scrarea_queue_headredraw(curarea);
1625 if(G.qual==LR_CTRLKEY) {
1626 G.vd->around= V3D_LOCAL;
1627 } else if(G.qual==0) {
1628 G.vd->around= V3D_CURSOR;
1630 scrarea_queue_headredraw(curarea);
1635 if(G.vd->localview) {
1637 endlocalview(curarea);
1643 scrarea_queue_headredraw(curarea);
1646 case PADASTERKEY: /* '*' */
1650 obmat_to_viewmat(ob);
1651 if(G.vd->persp==2) G.vd->persp= 1;
1652 scrarea_queue_winredraw(curarea);
1656 case PADPERIOD: /* '.' */
1662 if(G.qual==LR_CTRLKEY)
1664 else if((G.qual==0))
1665 nextkey_obipo(1); /* in editipo.c */
1669 if(G.qual==LR_CTRLKEY)
1671 else if((G.qual==0))
1675 case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
1676 case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
1678 persptoetsen(event);
1682 if ( (G.qual==LR_CTRLKEY)
1683 && (G.obedit) && (G.obedit->type==OB_MESH) )
1686 persptoetsen(event);
1692 if ( (G.qual==LR_CTRLKEY)
1693 && (G.obedit) && (G.obedit->type==OB_MESH) )
1696 persptoetsen(event);
1703 if (G.vd->flag & V3D_DISPIMAGE) {
1704 G.vd->flag &= ~V3D_DISPIMAGE;
1714 scrarea_queue_winredraw(curarea);
1715 scrarea_queue_headredraw(curarea);
1719 void initview3d(ScrArea *sa)
1723 vd= MEM_callocN(sizeof(View3D), "initview3d");
1724 BLI_addhead(&sa->spacedata, vd); /* addhead! not addtail */
1726 vd->spacetype= SPACE_VIEW3D;
1727 vd->blockscale= 0.7;
1728 vd->viewquat[0]= 1.0;
1729 vd->viewquat[1]= vd->viewquat[2]= vd->viewquat[3]= 0.0;
1731 vd->drawtype= OB_WIRE;
1739 vd->lay= vd->layact= 1;
1741 vd->lay= vd->layact= G.scene->lay;
1742 vd->camera= G.scene->camera;
1745 vd->gridflag |= V3D_SHOW_X;
1746 vd->gridflag |= V3D_SHOW_Y;
1747 vd->gridflag |= V3D_SHOW_FLOOR;
1748 vd->gridflag &= ~V3D_SHOW_Z;
1752 /* ******************** SPACE: IPO ********************** */
1754 static void changeview2dspace(ScrArea *sa, void *spacedata)
1756 if(G.v2d==0) return;
1758 test_view2d(G.v2d, curarea->winx, curarea->winy);
1759 myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
1762 void winqreadipospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
1764 extern void do_ipobuts(unsigned short event); // drawipo.c
1765 unsigned short event= evt->event;
1766 short val= evt->val;
1767 SpaceIpo *sipo= curarea->spacedata.first;
1768 View2D *v2d= &sipo->v2d;
1770 int cfra, doredraw= 0;
1772 short mousebut = L_MOUSE;
1774 if(sa->win==0) return;
1777 if( uiDoBlocks(&sa->uiblocks, event)!=UI_NOTHING ) event= 0;
1779 /* swap mouse buttons based on user preference */
1780 if (U.flag & USER_LMOUSESELECT) {
1781 if (evt->event == LEFTMOUSE) {
1784 } else if (evt->event == RIGHTMOUSE) {
1792 /* note: bad bad code, will be cleaned! is because event queues are all shattered */
1793 if(val>0 && val < 65) do_ipowin_buts(val-1);
1794 else do_ipobuts(val);
1798 if( in_ipo_buttons() ) {
1799 do_ipo_selectbuttons();
1802 else if(G.qual & LR_CTRLKEY) add_vert_ipo();
1805 getmouseco_areawin(mval);
1806 areamouseco_to_ipoco(v2d, mval, &dx, &dy);
1809 if(cfra< 1) cfra= 1;
1813 update_for_newframe();
1814 force_draw_plus(SPACE_VIEW3D);
1815 force_draw_plus(SPACE_ACTION);
1816 force_draw_plus(SPACE_BUTS); /* To make constraint sliders redraw */
1819 } while(get_mbut() & mousebut);
1824 allqueue (REDRAWACTION, 0);
1825 allqueue(REDRAWNLA, 0);
1828 if(in_ipo_buttons()) {
1831 else view2dmove(event); /* in drawipo.c */
1834 case WHEELDOWNMOUSE:
1835 view2dmove(event); /* in drawipo.c */
1838 view2d_zoom(v2d, 0.1154, sa->winx, sa->winy);
1842 view2d_zoom(v2d, -0.15, sa->winx, sa->winy);
1846 if(G.qual==LR_CTRLKEY)
1848 else if((G.qual==0))
1852 if(G.qual==LR_CTRLKEY)
1854 else if((G.qual==0))
1859 do_ipo_buttons(B_IPOHOME);
1864 if(in_ipo_buttons()) {
1865 swap_visible_editipo();
1867 else swap_selectall_editipo();
1868 allspace (REMAKEIPO, 0);
1869 allqueue (REDRAWNLA, 0);
1870 allqueue (REDRAWACTION, 0);
1882 if((G.qual==LR_SHIFTKEY))
1883 add_duplicate_editipo();
1890 if((G.qual==LR_SHIFTKEY))
1891 sethandles_ipo(HD_AUTO);
1892 else if((G.qual==0))
1893 sethandles_ipo(HD_ALIGN);
1901 ipo_toggle_showkey();
1902 scrarea_queue_headredraw(curarea);
1903 allqueue(REDRAWVIEW3D, 0);
1908 toggle_blockhandler(sa, IPO_HANDLER_PROPERTIES, UI_PNL_TO_MOUSE);
1916 if((G.qual==LR_SHIFTKEY)) {
1918 } else if((G.qual==0))
1927 sethandles_ipo(HD_VECT);
1931 if((G.qual==LR_SHIFTKEY))
1933 else if((G.qual==0))
1939 if(doredraw) scrarea_queue_winredraw(sa);
1942 void initipo(ScrArea *sa)
1946 sipo= MEM_callocN(sizeof(SpaceIpo), "initipo");
1947 BLI_addhead(&sa->spacedata, sipo);
1949 sipo->spacetype= SPACE_IPO;
1950 sipo->blockscale= 0.7;
1952 /* sipo space loopt van (0,-?) tot (??,?) */
1953 sipo->v2d.tot.xmin= 0.0;
1954 sipo->v2d.tot.ymin= -10.0;
1955 sipo->v2d.tot.xmax= G.scene->r.efra;
1956 sipo->v2d.tot.ymax= 10.0;
1958 sipo->v2d.cur= sipo->v2d.tot;
1960 sipo->v2d.min[0]= 0.01f;
1961 sipo->v2d.min[1]= 0.01f;
1963 sipo->v2d.max[0]= 15000.0f;
1964 sipo->v2d.max[1]= 10000.0f;
1966 sipo->v2d.scroll= L_SCROLL+B_SCROLL;
1967 sipo->v2d.keeptot= 0;
1969 sipo->blocktype= ID_OB;
1972 /* ******************** SPACE: INFO ********************** */
1974 void space_mipmap_button_function(int event) {
1975 set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
1977 allqueue(REDRAWVIEW3D, 0);
1980 void space_sound_button_function(int event)
1983 SYS_SystemHandle syshandle;
1985 if ((syshandle = SYS_GetSystem()))
1987 a = (U.gameflags & USER_DISABLE_SOUND);
1988 SYS_WriteCommandLineInt(syshandle, "noaudio", a);
1992 #define B_ADD_THEME 3301
1993 #define B_DEL_THEME 3302
1994 #define B_NAME_THEME 3303
1995 #define B_THEMECOL 3304
1996 #define B_UPDATE_THEME 3305
1997 #define B_CHANGE_THEME 3306
1998 #define B_THEME_COPY 3307
1999 #define B_THEME_PASTE 3308
2001 #define B_RECALCLIGHT 3310
2003 // needed for event; choose new 'curmain' resets it...
2004 static short th_curcol= TH_BACK;
2005 static char *th_curcol_ptr= NULL;
2006 static char th_curcol_arr[4]={0, 0, 0, 255};
2008 void info_user_themebuts(uiBlock *block, short y1, short y2, short y3)
2010 bTheme *btheme, *bt;
2012 static short cur=1, curmain=2;
2013 short a, tot=0, isbuiltin= 0;
2014 char string[21*32], *strp, *col;
2016 y3= y2+23; // exception!
2018 /* count total, max 16! */
2019 for(bt= U.themes.first; bt; bt= bt->next) tot++;
2021 /* if cur not is 1; move that to front of list */
2024 for(bt= U.themes.first; bt; bt= bt->next, a++) {
2026 BLI_remlink(&U.themes, bt);
2027 BLI_addhead(&U.themes, bt);
2028 allqueue(REDRAWALL, 0);
2035 /* the current theme */
2036 btheme= U.themes.first;
2037 if(strcmp(btheme->name, "Default")==0) isbuiltin= 1;
2039 /* construct popup script */
2041 for(bt= U.themes.first; bt; bt= bt->next) {
2042 strcat(string, bt->name);
2043 if(btheme->next) strcat(string, " |");
2045 uiDefButS(block, MENU, B_UPDATE_THEME, string, 45,y3,200,20, &cur, 0, 0, 0, 0, "Current theme");
2047 /* add / delete / name */
2050 uiDefBut(block, BUT, B_ADD_THEME, "Add", 45,y2,200,20, NULL, 0, 0, 0, 0, "Makes new copy of this theme");
2051 if(tot>1 && isbuiltin==0)
2052 uiDefBut(block, BUT, B_DEL_THEME, "Delete", 45,y1,200,20, NULL, 0, 0, 0, 0, "Delete theme");
2054 if(isbuiltin) return;
2057 uiDefBut(block, TEX, B_NAME_THEME, "", 255,y3,200,20, btheme->name, 1.0, 30.0, 0, 0, "Rename theme");
2059 /* main choices pup */
2060 uiDefButS(block, MENU, B_CHANGE_THEME, "UI and Buttons %x1|%l|3D View %x2|%l|Ipo Curve Editor %x3|Action Editor %x4|"
2061 "NLA Editor %x5|%l|UV/Image Editor %x6|Video Sequence Editor %x7|Audio Timeline %x8|Text Editor %x9|%l|User Preferences %x10|"
2062 "OOPS Schematic %x11|Buttons Window %x12|%l|File Browser %x13|Image Browser %x14",
2063 255,y2,200,20, &curmain, 0, 0, 0, 0, "Specify theme for...");
2064 if(curmain==1) spacetype= 0;
2065 else if(curmain==2) spacetype= SPACE_VIEW3D;
2066 else if(curmain==3) spacetype= SPACE_IPO;
2067 else if(curmain==4) spacetype= SPACE_ACTION;
2068 else if(curmain==5) spacetype= SPACE_NLA;
2069 else if(curmain==6) spacetype= SPACE_IMAGE;
2070 else if(curmain==7) spacetype= SPACE_SEQ;
2071 else if(curmain==8) spacetype= SPACE_SOUND;
2072 else if(curmain==9) spacetype= SPACE_TEXT;
2073 else if(curmain==10) spacetype= SPACE_INFO;
2074 else if(curmain==11) spacetype= SPACE_OOPS;
2075 else if(curmain==12) spacetype= SPACE_BUTS;
2076 else if(curmain==13) spacetype= SPACE_FILE;
2077 else if(curmain==14) spacetype= SPACE_IMASEL;
2078 else return; // only needed while coding... when adding themes for more windows
2080 /* color choices pup */
2082 strp= BIF_ThemeColorsPup(0);
2083 if(th_curcol==TH_BACK) th_curcol= TH_BUT_OUTLINE; // switching main choices...
2085 else strp= BIF_ThemeColorsPup(spacetype);
2087 uiDefButS(block, MENU, B_REDR, strp, 255,y1,200,20, &th_curcol, 0, 0, 0, 0, "Current color");
2090 th_curcol_ptr= col= BIF_ThemeGetColorPtr(btheme, spacetype, th_curcol);
2091 if(col==NULL) return;
2093 /* first handle exceptions, special single values, row selection, etc */
2094 if(th_curcol==TH_VERTEX_SIZE) {
2095 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"Vertex size ", 465,y3,200,20, col, 1.0, 10.0, 0, 0, "");
2097 else if(th_curcol==TH_BUT_DRAWTYPE) {
2098 uiBlockBeginAlign(block);
2099 uiDefButC(block, ROW, B_UPDATE_THEME, "Minimal", 465,y3,100,20, col, 2.0, 0.0, 0, 0, "");
2100 uiDefButC(block, ROW, B_UPDATE_THEME, "Shaded", 565,y3,100,20, col, 2.0, 1.0, 0, 0, "");
2101 uiDefButC(block, ROW, B_UPDATE_THEME, "Rounded", 465,y2,100,20, col, 2.0, 2.0, 0, 0, "");
2102 uiDefButC(block, ROW, B_UPDATE_THEME, "OldSkool", 565,y2,100,20, col, 2.0, 3.0, 0, 0, "");
2103 uiBlockEndAlign(block);
2106 uiBlockBeginAlign(block);
2107 if ELEM3(th_curcol, TH_PANEL, TH_FACE, TH_FACE_SELECT) {
2108 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"A ", 465,y3+25,200,20, col+3, 0.0, 255.0, B_THEMECOL, 0, "");
2110 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"R ", 465,y3,200,20, col, 0.0, 255.0, B_THEMECOL, 0, "");
2111 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"G ", 465,y2,200,20, col+1, 0.0, 255.0, B_THEMECOL, 0, "");
2112 uiDefButC(block, NUMSLI, B_UPDATE_THEME,"B ", 465,y1,200,20, col+2, 0.0, 255.0, B_THEMECOL, 0, "");
2113 uiBlockEndAlign(block);
2115 uiDefButC(block, COL, B_UPDATE_THEME, "", 675,y1,50,y3-y1+20, col, 0, 0, 0, 0, "");
2118 uiBlockBeginAlign(block);
2119 uiDefBut(block, BUT, B_THEME_COPY, "Copy Color", 755,y2,120,20, NULL, 0, 0, 0, 0, "Stores current color in buffer");
2120 uiDefBut(block, BUT, B_THEME_PASTE, "Paste Color", 755,y1,120,20, NULL, 0, 0, 0, 0, "Pastes buffer color");
2121 uiBlockEndAlign(block);
2123 uiDefButC(block, COL, 0, "", 885,y1,50,y2-y1+20, th_curcol_arr, 0, 0, 0, 0, "");
2129 void drawinfospace(ScrArea *sa, void *spacedata)
2132 static short cur_light=0, cur_light_var=0;
2134 short xpos, ypos, ypostab, buth, rspace, dx, y1, y2, y3, y4, y5, y6;
2135 short y2label, y3label, y4label, y5label, y6label;
2136 short spref, mpref, lpref, smfileselbut;
2140 if(curarea->win==0) return;
2142 BIF_GetThemeColor3fv(TH_BACK, col);
2143 glClearColor(col[0], col[1], col[2], 0.0);
2144 glClear(GL_COLOR_BUFFER_BIT);
2146 fac= ((float)curarea->winx)/1280.0f;
2147 myortho2(0.0, 1280.0, 0.0, curarea->winy/fac);
2149 sprintf(naam, "infowin %d", curarea->win);
2150 block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSS, UI_HELV, curarea->win);
2153 /* Vars for nice grid alignment */
2154 dx= (1280-90)/7; /* spacing for use in equally dividing 'tab' row */
2156 xpos = 45; /* left padding */
2157 ypos = 50; /* bottom padding for buttons */
2158 ypostab = 10; /* bottom padding for 'tab' row */
2160 buth = 20; /* standard button height */
2162 spref = 90; /* standard size for small preferences button */
2163 mpref = 189; /* standard size for medium preferences button */
2164 lpref = 288; /* standard size for large preferences button */
2165 smfileselbut = buth; /* standard size for fileselect button (square) */
2167 edgsp = 3; /* space from edge of end 'tab' to edge of end button */
2168 midsp = 9; /* horizontal space between buttons */
2170 rspace = 3; /* default space between rows */
2172 y1 = ypos; /* grid alignment for each row of buttons */
2173 y2 = ypos+buth+rspace;
2174 y3 = ypos+2*(buth+rspace);
2175 y4 = ypos+3*(buth+rspace);
2176 y5 = ypos+4*(buth+rspace);
2177 y6 = ypos+5*(buth+rspace);
2180 y2label = y2-2; /* adjustments to offset the labels down to align better */
2187 /* set the colour to blue and draw the main 'tab' controls */
2189 uiBlockSetCol(block, TH_BUT_SETTING1);
2190 uiBlockBeginAlign(block);
2192 uiDefButS(block, ROW,B_USERPREF,"View & Controls",
2193 xpos,ypostab,(short)dx,buth,
2194 &U.userpref,1.0,0.0, 0, 0,"");
2196 uiDefButS(block, ROW,B_USERPREF,"Edit Methods",
2197 (short)(xpos+dx),ypostab,(short)dx,buth,
2198 &U.userpref,1.0,1.0, 0, 0,"");
2200 uiDefButS(block, ROW,B_USERPREF,"Language & Font",
2201 (short)(xpos+2*dx),ypostab,(short)dx,buth,
2202 &U.userpref,1.0,2.0, 0, 0,"");
2204 uiDefButS(block, ROW,B_USERPREF,"Themes",
2205 (short)(xpos+3*dx),ypostab,(short)dx,buth,
2206 &U.userpref,1.0,6.0, 0, 0,"");
2208 uiDefButS(block, ROW,B_USERPREF,"Auto Save",
2209 (short)(xpos+4*dx),ypostab,(short)dx,buth,
2210 &U.userpref,1.0,3.0, 0, 0,"");
2212 uiDefButS(block, ROW,B_USERPREF,"System & OpenGL",
2213 (short)(xpos+5*dx),ypostab,(short)dx,buth,
2214 &U.userpref,1.0,4.0, 0, 0,"");
2216 uiDefButS(block, ROW,B_USERPREF,"File Paths",
2217 (short)(xpos+6*dx),ypostab,(short)dx,buth,
2218 &U.userpref,1.0,5.0, 0, 0,"");
2220 uiBlockSetCol(block, TH_AUTO);
2221 uiBlockEndAlign(block);
2222 /* end 'tab' controls */
2224 /* line 2: left x co-ord, top y co-ord, width, height */
2226 if(U.userpref == 6) {
2227 info_user_themebuts(block, y1, y2, y3);
2229 else if (U.userpref == 0) { /* view & controls */
2231 uiDefBut(block, LABEL,0,"Display:",
2232 xpos,y6label,spref,buth,
2234 uiDefButBitS(block, TOG, USER_TOOLTIPS, 0, "ToolTips",
2235 (xpos+edgsp),y5,spref,buth,
2236 &(U.flag), 0, 0, 0, 0,
2237 "Display tooltips (help tags) over buttons");
2238 uiDefButBitS(block, TOG, USER_DRAWVIEWINFO, B_DRAWINFO, "Object Info",
2239 (xpos+edgsp),y4,spref,buth,
2240 &(U.uiflag), 0, 0, 0, 0,
2241 "Display active object name and frame number in the 3D View");
2242 uiDefButBitS(block, TOG, USER_SCENEGLOBAL, 0, "Global Scene",
2243 (xpos+edgsp),y3,spref,buth,
2244 &(U.flag), 0, 0, 0, 0,
2245 "Forces the current Scene to be displayed in all Screens");
2247 uiDefButS(block, TOG|BIT|0, 0, "Large Cursors",
2248 (xpos+edgsp),y2,spref,buth,
2249 &(U.curssize), 0, 0, 0, 0,
2250 "Use large mouse cursors when available");
2252 U.curssize=0; /*Small Cursor always for OS X for now */
2255 uiDefBut(block, LABEL,0,"Menus:",
2256 (xpos+(2*edgsp)+spref),y6label,spref,buth,
2258 uiDefButBitS(block, TOG, USER_MENUOPENAUTO, 0, "Open on Mouse Over",
2259 (xpos+edgsp+spref+midsp),y5,mpref,buth,
2260 &(U.uiflag), 0, 0, 0, 0,
2261 "Open menu buttons and pulldowns automatically when the mouse is hovering");
2262 uiDefButS(block, NUM, 0, "Top Level:",
2263 (xpos+edgsp+spref+midsp),y4,spref+edgsp,buth,
2264 &(U.menuthreshold1), 1, 40, 0, 0,
2265 "Time delay in 1/10 seconds before automatically opening top level menus");
2266 uiDefButS(block, NUM, 0, "Sublevels:",
2267 (xpos+edgsp+(2*spref)+(2*midsp)-edgsp),y4,spref+edgsp,buth,
2268 &(U.menuthreshold2), 1, 40, 0, 0,
2269 "Time delay in 1/10 seconds before automatically opening menu sublevels");
2271 uiDefBut(block, LABEL,0,"Toolbox click-hold delay:",
2272 (xpos+(2*edgsp)+spref),y3label,mpref,buth,
2274 uiDefButS(block, NUM, 0, "LMB:",
2275 (xpos+edgsp+spref+midsp),y2,spref+edgsp,buth,
2276 &(U.tb_leftmouse), 2, 40, 0, 0,
2277 "Time in 1/10 seconds to hold the Left Mouse Button before opening the toolbox");
2278 uiDefButS(block, NUM, 0, "RMB:",
2279 (xpos+edgsp+(2*spref)+(2*midsp)-edgsp),y2,spref+edgsp,buth,
2280 &(U.tb_rightmouse), 2, 40, 0, 0,
2281 "Time in 1/10 seconds to hold the Right Mouse Button before opening the toolbox");
2282 uiDefButBitS(block, TOG, USER_PANELPINNED, 0, "Pin Floating Panels",
2283 (xpos+edgsp+spref+midsp),y1,mpref,buth,
2284 &(U.uiflag), 0, 0, 0, 0,
2285 "Make floating panels invoked by a hotkey (eg. N Key) open at the previous location");
2288 uiDefBut(block, LABEL,0,"Snap to grid:",
2289 (xpos+(2*edgsp)+spref+midsp+mpref),y6label,mpref,buth,
2291 uiDefButBitS(block, TOG, USER_AUTOGRABGRID, 0, "Grab/Move",
2292 (xpos+edgsp+mpref+spref+(2*midsp)),y5,spref,buth,
2293 &(U.flag), 0, 0, 0, 0,
2294 "Snap objects and sub-objects to grid units when moving");
2295 uiDefButBitS(block, TOG, USER_AUTOROTGRID, 0, "Rotate",
2296 (xpos+edgsp+mpref+spref+(2*midsp)),y4,spref,buth,
2297 &(U.flag), 0, 0, 0, 0,
2298 "Snap objects and sub-objects to grid units when rotating");
2299 uiDefButBitS(block, TOG, USER_AUTOSIZEGRID, 0, "Scale",
2300 (xpos+edgsp+mpref+spref+(2*midsp)),y3,spref,buth,
2301 &(U.flag), 0, 0, 0, 0,
2302 "Snap objects and sub-objects to grid units when scaling");
2304 uiDefButBitS(block, TOG, USER_LOCKAROUND, B_DRAWINFO, "Global Pivot",
2305 (xpos+edgsp+mpref+spref+(2*midsp)),y1,spref,buth,
2306 &(U.uiflag), 0, 0, 0, 0,
2307 "Lock the same rotation/scaling pivot in all 3D Views");
2309 uiDefBut(block, LABEL,0,"View zoom:",
2310 (xpos+(2*edgsp)+mpref+(2*spref)+(2*midsp)),y6label,mpref,buth,
2312 uiBlockBeginAlign(block);
2313 uiDefButS(block, ROW, 0, "Continue",
2314 (xpos+edgsp+mpref+(2*spref)+(3*midsp)),y5,(mpref/3),buth,
2315 &(U.viewzoom), 40, USER_ZOOM_CONT, 0, 0,
2316 "Old style zoom, continues while moving mouse up or down");
2317 uiDefButS(block, ROW, 0, "Dolly",
2318 (xpos+edgsp+mpref+(2*spref)+(3*midsp)+(mpref/3)),y5,(mpref/3),buth,
2319 &(U.viewzoom), 40, USER_ZOOM_DOLLY, 0, 0,
2320 "Zooms in and out based on vertical mouse movement.");
2321 uiDefButS(block, ROW, 0, "Scale",
2322 (xpos+edgsp+mpref+(2*spref)+(3*midsp)+(2*mpref/3)),y5,(mpref/3),buth,
2323 &(U.viewzoom), 40, USER_ZOOM_SCALE, 0, 0,
2324 "Zooms in and out like scaling the view, mouse movements relative to center.");
2325 uiBlockEndAlign(block);
2327 uiDefBut(block, LABEL,0,"View rotation:",
2328 (xpos+(2*edgsp)+mpref+(2*spref)+(2*midsp)),y4label,mpref,buth,
2330 uiBlockBeginAlign(block);
2331 uiDefButBitS(block, TOG, USER_TRACKBALL, B_DRAWINFO, "Trackball",
2332 (xpos+edgsp+mpref+(2*spref)+(3*midsp)),y3,(mpref/2),buth,
2333 &(U.flag), 0, 0, 0, 0,
2334 "Allow the view to tumble freely when orbiting with the Middle Mouse Button");
2335 uiDefButBitS(block, TOGN, USER_TRACKBALL, B_DRAWINFO, "Turntable",
2336 (xpos+edgsp+mpref+(2*spref)+(3*midsp)+(mpref/2)),y3,(mpref/2),buth,
2337 &(U.flag), 0, 0, 0, 0,
2338 "Keep the Global Z axis pointing upwards when orbiting the view with the Middle Mouse Button");
2339 uiBlockEndAlign(block);
2341 uiDefButBitS(block, TOG, USER_AUTOPERSP, B_DRAWINFO, "Auto Perspective",
2342 (xpos+edgsp+mpref+(2*spref)+(3*midsp)),y1,spref,buth,
2343 &(U.uiflag), 0, 0, 0, 0,
2344 "Automatically switch between orthographic and perspective when changing from top/front/side views");
2346 uiDefBut(block, LABEL,0,"Select with:",
2347 (xpos+(2*edgsp)+(3*mpref)+(3*midsp)),y6label,mpref,buth,
2349 uiBlockBeginAlign(block);
2350 uiDefButBitS(block, TOG, USER_LMOUSESELECT, B_DRAWINFO, "Left Mouse",
2351 (xpos+edgsp+(3*mpref)+(4*midsp)),y5,(mpref/2),buth,
2352 &(U.flag), 0, 0, 0, 0, "Use the Left Mouse Button for selection");
2353 uiDefButBitS(block, TOGN, USER_LMOUSESELECT, B_DRAWINFO, "Right Mouse",
2354 (xpos+edgsp+(3*mpref)+(4*midsp)+(mpref/2)),y5,(mpref/2),buth,
2355 &(U.flag), 0, 0, 0, 0, "Use the Right Mouse Button for selection");
2356 uiBlockEndAlign(block);
2359 if(U.flag & USER_LMOUSESELECT) {
2360 uiDefBut(block, LABEL,0,"Cursor with: Right Mouse",
2361 (xpos+(2*edgsp)+(3*mpref)+(3*midsp)),y4label+5,mpref,buth,
2364 uiDefBut(block, LABEL,0,"Cursor with: Left Mouse",
2365 (xpos+(2*edgsp)+(3*mpref)+(3*midsp)),y4label+5,mpref,buth,
2369 uiDefButBitS(block, TOG, USER_TWOBUTTONMOUSE, 0, "Emulate 3 Button Mouse",
2370 (xpos+edgsp+(3*mpref)+(4*midsp)),y3,mpref,buth,
2371 &(U.flag), 0, 0, 0, 0,
2372 "Emulates a middle mouse button with Alt LeftMouse");
2375 uiDefBut(block, LABEL,0,"Middle Mouse Button:",
2376 (xpos+(2*edgsp)+(4*mpref)+(4*midsp)),y6label,mpref,buth,
2378 uiBlockBeginAlign(block);
2379 uiDefButBitS(block, TOGN, USER_VIEWMOVE, B_DRAWINFO, "Rotate View",
2380 (xpos+edgsp+(4*mpref)+(5*midsp)),y5,(mpref/2),buth,
2381 &(U.flag), 0, 0, 0, 0, "Default action for the Middle Mouse Button");
2382 uiDefButBitS(block, TOG, USER_VIEWMOVE, B_DRAWINFO, "Pan View",
2383 (xpos+edgsp+(4*mpref)+(5*midsp)+(mpref/2)),y5,(mpref/2),buth,
2384 &(U.flag), 0, 0, 0, 0, "Default action for the Middle Mouse Button");
2385 uiBlockEndAlign(block);
2387 uiDefBut(block, LABEL,0,"Mouse Wheel:",
2388 (xpos+(2*edgsp)+(4*mpref)+(4*midsp)),y4label,mpref,buth,
2390 uiDefButBitS(block, TOG, USER_WHEELZOOMDIR, 0, "Invert Zoom",
2391 (xpos+edgsp+(4*mpref)+(5*midsp)),y3,spref,buth,
2392 &(U.uiflag), 0, 0, 0, 0,
2393 "Swap the Mouse Wheel zoom direction");
2394 uiDefButI(block, NUM, 0, "Scroll Lines:",
2395 (xpos+edgsp+(4*mpref)+(6*midsp)+spref-edgsp),y3,spref+edgsp,buth,
2396 &U.wheellinescroll, 0.0, 32.0, 0, 0,
2397 "The number of lines scrolled at a time with the mouse wheel");
2400 } else if (U.userpref == 1) { /* edit methods */
2403 uiDefBut(block, LABEL,0,"Material linked to:",
2404 xpos,y3label,mpref,buth,
2406 uiBlockBeginAlign(block);
2407 uiDefButBitS(block, TOGN, USER_MAT_ON_OB, B_DRAWINFO, "ObData",
2408 (xpos+edgsp),y2,(mpref/2),buth,
2409 &(U.flag), 0, 0, 0, 0, "Link new objects' material to the obData block");
2410 uiDefButBitS(block, TOG, USER_MAT_ON_OB, B_DRAWINFO, "Object",
2411 (xpos+edgsp+(mpref/2)),y2,(mpref/2),buth,
2412 &(U.flag), 0, 0, 0, 0, "Link new objects' material to the object block");
2413 uiBlockEndAlign(block);
2416 uiDefBut(block, LABEL,0,"Editmode undo:",
2417 (xpos+(2*edgsp)+mpref),y3label, mpref,buth,
2419 uiDefButS(block, NUMSLI, B_DRAWINFO, "Steps:",
2420 (xpos+edgsp+mpref+midsp),y2,mpref,buth,
2421 &(U.undosteps), 2, 64, 0, 0, "Number of undo steps available in Edit Mode (smaller values conserve memory)");
2423 uiDefButBitS(block, TOG, USER_GLOBALUNDO, B_DRAWINFO, "Global undo",
2424 (xpos+edgsp+mpref+midsp),y1,mpref,buth,
2425 &(U.uiflag), 2, 64, 0, 0, "");
2428 uiDefBut(block, LABEL,0,"Auto keyframe on:",
2429 (xpos+(2*edgsp)+(2*mpref)+midsp),y3label,mpref,buth,
2431 uiDefButBitS(block, TOG, USER_KEYINSERTACT, 0, "Action",
2432 (xpos+edgsp+(2*mpref)+(2*midsp)),y2,(spref+edgsp),buth,
2433 &(U.uiflag), 0, 0, 0, 0, "Automatic keyframe insertion in Action Ipo curve");
2434 uiDefButBitS(block, TOG, USER_KEYINSERTOBJ, 0, "Object",
2435 (xpos+edgsp+(2*mpref)+(3*midsp)+spref-edgsp),y2,(spref+edgsp),buth,
2436 &(U.uiflag), 0, 0, 0, 0, "Automatic keyframe insertion in Object Ipo curve");
2439 uiDefBut(block, LABEL,0,"Duplicate with object:",
2440 (xpos+(2*edgsp)+(3*midsp)+(3*mpref)+spref),y3label,mpref,buth,
2443 uiDefButBitS(block, TOG, USER_DUP_MESH, 0, "Mesh",
2444 (xpos+edgsp+(4*midsp)+(3*mpref)+spref),y2,(spref+edgsp),buth,
2445 &(U.dupflag), 0, 0, 0, 0, "Causes mesh data to be duplicated with Shift+D");
2446 uiDefButBitS(block, TOG, USER_DUP_ARM, 0, "Armature",
2447 (xpos+edgsp+(4*midsp)+(3*mpref)+spref),y1,(spref+edgsp),buth,
2448 &(U.dupflag), 0, 0, 0, 0, "Causes armature data to be duplicated with Shift+D");
2450 uiDefButBitS(block, TOG, USER_DUP_SURF, 0, "Surface",
2451 (xpos+edgsp+(5*midsp)+(3*mpref)+(2*spref)),y2,(spref+edgsp),buth,
2452 &(U.dupflag), 0, 0, 0, 0, "Causes surface data to be duplicated with Shift+D");
2453 uiDefButBitS(block, TOG, USER_DUP_LAMP, 0, "Lamp",
2454 (xpos+edgsp+(5*midsp)+(3*mpref)+(2*spref)),y1,(spref+edgsp),buth,
2455 &(U.dupflag), 0, 0, 0, 0, "Causes lamp data to be duplicated with Shift+D");
2457 uiDefButBitS(block, TOG, USER_DUP_CURVE, 0, "Curve",
2458 (xpos+edgsp+(6*midsp)+(3*mpref)+(3*spref)),y2,(spref+edgsp),buth,
2459 &(U.dupflag), 0, 0, 0, 0, "Causes curve data to be duplicated with Shift+D");
2460 uiDefButBitS(block, TOG, USER_DUP_MAT, 0, "Material",
2461 (xpos+edgsp+(6*midsp)+(3*mpref)+(3*spref)),y1,(spref+edgsp),buth,
2462 &(U.dupflag), 0, 0, 0, 0, "Causes material data to be duplicated with Shift+D");
2464 uiDefButBitS(block, TOG, USER_DUP_FONT, 0, "Text",
2465 (xpos+edgsp+(7*midsp)+(3*mpref)+(4*spref)),y2,(spref+edgsp),buth,
2466 &(U.dupflag), 0, 0, 0, 0, "Causes text data to be duplicated with Shift+D");
2467 uiDefButBitS(block, TOG, USER_DUP_TEX, 0, "Texture",
2468 (xpos+edgsp+(7*midsp)+(3*mpref)+(4*spref)),y1,(spref+edgsp),buth,
2469 &(U.dupflag), 0, 0, 0, 0, "Causes texture data to be duplicated with Shift+D");
2471 uiDefButBitS(block, TOG, USER_DUP_MBALL, 0, "Metaball",
2472 (xpos+edgsp+(8*midsp)+(3*mpref)+(5*spref)),y2,(spref+edgsp),buth,
2473 &(U.dupflag), 0, 0, 0, 0, "Causes metaball data to be duplicated with Shift+D");
2474 uiDefButBitS(block, TOG, USER_DUP_IPO, 0, "Ipo",
2475 (xpos+edgsp+(8*midsp)+(3*mpref)+(5*spref)),y1,(spref+edgsp),buth,
2476 &(U.dupflag), 0, 0, 0, 0, "Causes ipo data to be duplicated with Shift+D");
2478 } else if(U.userpref == 2) { /* language & colors */
2480 #ifdef INTERNATIONAL
2483 sprintf(curfont, "Interface Font: ");
2484 strcat(curfont,U.fontname);
2486 uiDefButBitS(block, TOG, USER_DOTRANSLATE, B_DOLANGUIFONT, "International Fonts",
2488 &(U.transopts), 0, 0, 0, 0, "Activate international interface");
2490 if(U.transopts & USER_DOTRANSLATE) {
2491 uiDefBut(block, LABEL,0,curfont,
2492 (xpos+edgsp+mpref+midsp),y2,mpref,buth,
2495 uiDefBut(block, BUT, B_LOADUIFONT, "Select Font",
2497 0, 0, 0, 0, 0, "Select a new font for the interface");
2500 uiDefButI(block, MENU|INT, B_SETFONTSIZE, fontsize_pup(),
2501 (xpos+edgsp+mpref+midsp),y1,mpref,buth,
2502 &U.fontsize, 0, 0, 0, 0, "Current interface font size (points)");
2505 uiDefButS(block, MENU|SHO, B_SETENCODING, encoding_pup(),
2506 (xpos+edgsp+mpref+midsp),y1,mpref,buth,
2507 &U.encoding, 0, 0, 0, 0, "Current interface font encoding");
2510 uiDefBut(block, LABEL,0,"Translate:",
2511 (xpos+edgsp+(2.1*mpref)+(2*midsp)),y3label,mpref,buth,
2515 uiDefButBitS(block, TOG, USER_TR_TOOLTIPS, B_SETTRANSBUTS, "Tooltips",
2516 (xpos+edgsp+(2.2*mpref)+(3*midsp)),y1,spref,buth,
2517 &(U.transopts), 0, 0, 0, 0, "Translate tooltips");
2519 uiDefButBitS(block, TOG, USER_TR_BUTTONS, B_SETTRANSBUTS, "Buttons",
2520 (xpos+edgsp+(2.2*mpref)+(4*midsp)+spref),y1,spref,buth,
2521 &(U.transopts), 0, 0, 0, 0, "Translate button labels");
2523 uiDefButBitS(block, TOG, USER_TR_MENUS, B_SETTRANSBUTS, "Toolbox",
2524 (xpos+edgsp+(2.2*mpref)+(5*midsp)+(2*spref)),y1,spref,buth,
2525 &(U.transopts), 0, 0, 0, 0, "Translate toolbox menu");
2527 uiDefButS(block, MENU|SHO, B_SETLANGUAGE, language_pup(),
2528 (xpos+edgsp+(2.2*mpref)+(3*midsp)),y2,mpref+(0.5*mpref)+3,buth,
2529 &U.language, 0, 0, 0, 0, "Select interface language");
2531 /* uiDefButBitS(block, TOG, USER_TR_TEXTEDIT, B_SETTRANSBUTS, "FTF All windows",
2532 (xpos+edgsp+(4*mpref)+(4*midsp)),y1,mpref,buth,
2533 &(U.transopts), 0, 0, 0, 0,
2534 "Use FTF drawing for fileselect and textwindow "
2535 "(under construction)");
2539 /* end of INTERNATIONAL */
2542 } else if(U.userpref == 3) { /* auto save */
2545 uiDefButS(block, NUM, 0, "Save Versions:",
2546 (xpos+edgsp),y3,mpref,buth,
2547 &U.versions, 0.0, 32.0, 0, 0,
2548 "The number of old versions to maintain in the current directory, when manually saving");
2550 uiDefButBitS(block, TOG, USER_AUTOSAVE, B_RESETAUTOSAVE, "Auto Save Temp Files",
2551 (xpos+edgsp+mpref+midsp),y3,mpref,buth,
2552 &(U.flag), 0, 0, 0, 0,
2553 "Enables automatic saving of temporary files");
2555 if(U.flag & USER_AUTOSAVE) {
2557 uiDefButI(block, NUM, B_RESETAUTOSAVE, "Minutes:",
2558 (xpos+edgsp+mpref+midsp),y2,mpref,buth,
2559 &(U.savetime), 1.0, 60.0, 0, 0,
2560 "The time (in minutes) to wait between automatic temporary saves");
2562 uiDefBut(block, BUT, B_LOADTEMP, "Open Recent",
2563 (xpos+edgsp+mpref+midsp),y1,mpref,buth,
2564 0, 0, 0, 0, 0,"Open the most recently saved temporary file");
2567 } else if (U.userpref == 4) { /* system & opengl */
2568 uiDefBut(block, LABEL,0,"Solid OpenGL light:",
2569 xpos+edgsp, y3label, mpref, buth,
2572 uiDefButS(block, MENU, B_REDR, "Light1 %x0|Light2 %x1|Light3 %x2",
2573 xpos+edgsp, y2, 2*mpref/6, buth, &cur_light, 0.0, 0.0, 0, 0, "");
2574 uiBlockSetCol(block, TH_BUT_SETTING1);
2575 uiDefButI(block, TOG|BIT|0, B_RECALCLIGHT, "On",
2576 xpos+edgsp+2*mpref/6, y2, mpref/6, buth,
2577 &U.light[cur_light].flag, 0.0, 0.0, 0, 0, "");
2579 uiBlockSetCol(block, TH_AUTO);
2580 uiDefButS(block, ROW, B_REDR, "Vec",
2581 xpos+edgsp+3*mpref/6, y2, mpref/6, buth,
2582 &cur_light_var, 123.0, 0.0, 0, 0, "");
2583 uiDefButS(block, ROW, B_REDR, "Col",
2584 xpos+edgsp+4*mpref/6, y2, mpref/6, buth,
2585 &cur_light_var, 123.0, 1.0, 0, 0, "");
2586 uiDefButS(block, ROW, B_REDR, "Spec",
2587 xpos+edgsp+5*mpref/6, y2, mpref/6, buth,
2588 &cur_light_var, 123.0, 2.0, 0, 0, "");
2590 if(cur_light_var==1) {
2591 uiDefButF(block, NUM, B_RECALCLIGHT, "R ",
2592 xpos+edgsp, y1, mpref/3, buth,
2593 U.light[cur_light].col, 0.0, 1.0, 100, 2, "");
2594 uiDefButF(block, NUM, B_RECALCLIGHT, "G ",
2595 xpos+edgsp+mpref/3, y1, mpref/3, buth,
2596 U.light[cur_light].col+1, 0.0, 1.0, 100, 2, "");
2597 uiDefButF(block, NUM, B_RECALCLIGHT, "B ",
2598 xpos+edgsp+2*mpref/3, y1, mpref/3, buth,
2599 U.light[cur_light].col+2, 0.0, 1.0, 100, 2, "");
2601 else if(cur_light_var==2) {
2602 uiDefButF(block, NUM, B_RECALCLIGHT, "sR ",
2603 xpos+edgsp, y1, mpref/3, buth,
2604 U.light[cur_light].spec, 0.0, 1.0, 100, 2, "");
2605 uiDefButF(block, NUM, B_RECALCLIGHT, "sG ",
2606 xpos+edgsp+mpref/3, y1, mpref/3, buth,
2607 U.light[cur_light].spec+1, 0.0, 1.0, 100, 2, "");
2608 uiDefButF(block, NUM, B_RECALCLIGHT, "sB ",
2609 xpos+edgsp+2*mpref/3, y1, mpref/3, buth,
2610 U.light[cur_light].spec+2, 0.0, 1.0, 100, 2, "");
2612 else if(cur_light_var==0) {
2613 uiDefButF(block, NUM, B_RECALCLIGHT, "X ",
2614 xpos+edgsp, y1, mpref/3, buth,
2615 U.light[cur_light].vec, -1.0, 1.0, 100, 2, "");
2616 uiDefButF(block, NUM, B_RECALCLIGHT, "Y ",
2617 xpos+edgsp+mpref/3, y1, mpref/3, buth,
2618 U.light[cur_light].vec+1, -1.0, 1.0, 100, 2, "");
2619 uiDefButF(block, NUM, B_RECALCLIGHT, "Z ",
2620 xpos+edgsp+2*mpref/3, y1, mpref/3, buth,
2621 U.light[cur_light].vec+2, -1.0, 1.0, 100, 2, "");
2625 uiDefButS(block, TOG|BIT|5, 0, "Log Events to Console",
2626 (xpos+edgsp),y2,lpref,buth,
2627 &(U.uiflag), 0, 0, 0, 0, "Display a list of input events in the console");
2629 uiDefButS(block, MENU|SHO, B_CONSOLEOUT, consolemethod_pup(),
2630 (xpos+edgsp), y1, lpref,buth,
2631 &U.console_out, 0, 0, 0, 0, "Select console output method");
2633 uiDefButS(block, NUM, B_CONSOLENUMLINES, "Lines:",
2634 (xpos+edgsp+lpref+midsp),y1,spref,buth,
2635 &U.console_buffer, 1.0, 4000.0, 0, 0, "Maximum number of internal console lines");
2639 uiDefBut(block, LABEL,0,"Win Codecs:",
2640 (xpos+edgsp+(1*midsp)+(1*mpref)),y3label,mpref,buth,
2643 uiDefButBitS(block, TOG, USER_ALLWINCODECS, 0, "Enable all codecs",
2644 (xpos+edgsp+(1*mpref)+(1*midsp)),y2,mpref,buth,
2645 &(U.uiflag), 0, 0, 0, 0, "Allows all codecs for rendering (not guaranteed)");
2648 uiDefBut(block, LABEL,0,"Keyboard:",
2649 (xpos+edgsp+(3*midsp)+(3*mpref)),y3label,mpref,buth,
2652 uiDefButBitS(block, TOG, USER_NO_CAPSLOCK, B_U_CAPSLOCK, "Disable Caps Lock",
2653 (xpos+edgsp+(3*midsp)+(3*mpref)),y1,mpref,buth,
2654 &(U.flag), 0, 0, 0, 0,
2655 "Disables the Caps Lock key when entering text");
2657 uiDefButBitS(block, TOG, USER_NONUMPAD, 0, "Emulate Numpad",
2658 (xpos+edgsp+(3*midsp)+(3*mpref)),y2,mpref,buth,
2659 &(U.flag), 0, 0, 0, 0,
2660 "Causes the 1 to 0 keys to act as the numpad (useful for laptops)");
2663 uiDefBut(block, LABEL,0,"System:",
2664 (xpos+edgsp+(4*midsp)+(4*mpref)),y3label,mpref,buth,
2667 uiDefButBitI(block, TOG, USER_DISABLE_SOUND, B_SOUNDTOGGLE, "Disable Sound",
2668 (xpos+edgsp+(4*mpref)+(4*midsp)),y2,mpref,buth,
2669 &(U.gameflags), 0, 0, 0, 0, "Disables sounds from being played");
2671 uiDefButBitS(block, TOG, USER_FILTERFILEEXTS, 0, "Filter File Extensions",
2672 (xpos+edgsp+(4*mpref)+(4*midsp)),y1,mpref,buth,
2673 &(U.uiflag), 0, 0, 0, 0, "Display only files with extensions in the image select window");
2676 uiDefBut(block, LABEL,0,"OpenGL:",
2677 (xpos+edgsp+(5*midsp)+(5*mpref)),y3label,mpref,buth,
2680 uiDefButBitI(block, TOGN, USER_DISABLE_MIPMAP, B_MIPMAPCHANGED, "Mipmaps",
2681 (xpos+edgsp+(5*mpref)+(5*midsp)),y2,mpref,buth,
2682 &(U.gameflags), 0, 0, 0, 0, "Toggles between mipmap textures on (beautiful) and off (fast)");
2684 uiDefButBitI(block, TOG, USER_VERTEX_ARRAYS, 0, "Vertex Arrays",
2685 (xpos+edgsp+(5*mpref)+(5*midsp)),y1,mpref,buth,
2686 &(U.gameflags), 0, 0, 0, 0, "Toggles between vertex arrays on (less reliable) and off (more reliable)");
2688 uiDefBut(block, LABEL,0,"Audio mixing buffer:",
2689 (xpos+edgsp+(2*midsp)+(2*mpref)),y3label,mpref,buth,
2691 uiBlockBeginAlign(block);
2692 uiDefButI(block, ROW, 0, "256",
2693 (xpos+edgsp+(2*midsp)+(2*mpref)),y2,(mpref/4),buth,
2694 &U.mixbufsize, 2.0, 256.0, 0, 0, "Set audio mixing buffer size to 256 samples");
2695 uiDefButI(block, ROW, 0, "512",
2696 (xpos+edgsp+(2*midsp)+(2*mpref)+(mpref/4)),y2,(mpref/4),buth,
2697 &U.mixbufsize, 2.0, 512.0, 0, 0, "Set audio mixing buffer size to 512 samples");
2698 uiDefButI(block, ROW, 0, "1024",
2699 (xpos+edgsp+(2*midsp)+(2*mpref)+(2*mpref/4)),y2,(mpref/4),buth,
2700 &U.mixbufsize, 2.0, 1024.0, 0, 0, "Set audio mixing buffer size to 1024 samples");
2701 uiDefButI(block, ROW, 0, "2048",
2702 (xpos+edgsp+(2*midsp)+(2*mpref)+(3*mpref/4)),y2,(mpref/4),buth,
2703 &U.mixbufsize, 2.0, 2048.0, 0, 0, "Set audio mixing buffer size to 2048 samples");
2704 uiBlockEndAlign(block);
2706 } else if(U.userpref == 5) { /* file paths */
2708 /* yafray: (temporary) path button for yafray xml export, now with fileselect */
2709 uiDefBut(block, TEX, 0, "YFexport: ",
2710 (xpos+edgsp), y2+buth+rspace, lpref-smfileselbut, buth,
2711 U.yfexportdir, 1.0, 63.0, 0, 0,
2712 "The default directory for yafray xml export (must exist!)");
2713 uiDefIconBut(block, BUT, B_YAFRAYDIRFILESEL, ICON_FILESEL,
2714 (xpos+edgsp+lpref-smfileselbut), y2+buth+rspace, smfileselbut, buth,
2715 0, 0, 0, 0, 0, "Select the default yafray export directory");
2717 uiDefBut(block, TEX, 0, "Fonts: ",
2718 (xpos+edgsp),y2,(lpref-smfileselbut),buth,
2719 U.fontdir, 1.0, 63.0, 0, 0,
2720 "The default directory to search for loading fonts");
2721 uiDefIconBut(block, BUT, B_FONTDIRFILESEL, ICON_FILESEL,
2722 (xpos+edgsp+lpref-smfileselbut),y2,smfileselbut,buth,
2723 0, 0, 0, 0, 0, "Select the default font directory");
2725 uiDefBut(block, TEX, 0, "Textures: ",
2726 (xpos+edgsp+lpref+midsp),y2,(lpref-smfileselbut),buth,
2727 U.textudir, 1.0, 63.0, 0, 0, "The default directory to search for textures");
2728 uiDefIconBut(block, BUT, B_TEXTUDIRFILESEL, ICON_FILESEL,
2729 (xpos+edgsp+(2*lpref)+midsp-smfileselbut),y2,smfileselbut,buth,
2730 0, 0, 0, 0, 0, "Select the default texture location");
2733 uiDefBut(block, TEX, 0, "Tex Plugins: ",
2734 (xpos+edgsp+(2*lpref)+(2*midsp)),y2,(lpref-smfileselbut),buth,
2735 U.plugtexdir, 1.0, 63.0, 0, 0, "The default directory to search for texture plugins");
2736 uiDefIconBut(block, BUT, B_PLUGTEXDIRFILESEL, ICON_FILESEL,
2737 (xpos+edgsp+(3*lpref)+(2*midsp)-smfileselbut),y2,smfileselbut,buth,
2738 0, 0, 0, 0, 0, "Select the default texture plugin location");
2740 uiDefBut(block, TEX, 0, "Seq Plugins: ",
2741 (xpos+edgsp+(3*lpref)+(3*midsp)),y2,(lpref-smfileselbut),buth,
2742 U.plugseqdir, 1.0, 63.0, 0, 0, "The default directory to search for sequence plugins");
2743 uiDefIconBut(block, BUT, B_PLUGSEQDIRFILESEL, ICON_FILESEL,
2744 (xpos+edgsp+(4*lpref)+(3*midsp)-smfileselbut),y2,smfileselbut,buth,
2745 0, 0, 0, 0, 0, "Select the default sequence plugin location");
2748 uiDefBut(block, TEX, 0, "Render: ",
2749 (xpos+edgsp),y1,(lpref-smfileselbut),buth,
2750 U.renderdir, 1.0, 63.0, 0, 0, "The default directory for rendering output");
2751 uiDefIconBut(block, BUT, B_RENDERDIRFILESEL, ICON_FILESEL,
2752 (xpos+edgsp+lpref-smfileselbut),y1,smfileselbut,buth,
2753 0, 0, 0, 0, 0, "Select the default render output location");
2755 uiDefBut(block, TEX, 0, "Python: ",
2756 (xpos+edgsp+lpref+midsp),y1,(lpref-2*smfileselbut),buth,
2757 U.pythondir, 1.0, 63.0, 0, 0, "The default directory to search for Python scripts");
2758 uiDefIconBut(block, BUT, B_PYMENUEVAL, ICON_SCRIPT,
2759 (xpos+edgsp+(2*lpref)+midsp-2*smfileselbut),y1,smfileselbut,buth,
2760 0, 0, 0, 0, 0, "Re-evaluate scripts registration in menus");
2761 uiDefIconBut(block, BUT, B_PYTHONDIRFILESEL, ICON_FILESEL,
2762 (xpos+edgsp+(2*lpref)+midsp-smfileselbut),y1,smfileselbut,buth,
2763 0, 0, 0, 0, 0, "Select the default Python script location");
2766 uiDefBut(block, TEX, 0, "Sounds: ",
2767 (xpos+edgsp+(2*lpref)+(2*midsp)),y1,(lpref-smfileselbut),buth,
2768 U.sounddir, 1.0, 63.0, 0, 0, "The default directory to search for sounds");
2769 uiDefIconBut(block, BUT, B_SOUNDDIRFILESEL, ICON_FILESEL,
2770 (xpos+edgsp+(3*lpref)+(2*midsp)-smfileselbut),y1,smfileselbut,buth,
2771 0, 0, 0, 0, 0, "Select the default sound location");
2773 uiDefBut(block, TEX, 0, "Temp: ",
2774 (xpos+edgsp+(3*lpref)+(3*midsp)),y1,(lpref-smfileselbut),buth,
2775 U.tempdir, 1.0, 63.0, 0, 0, "The directory for storing temporary save files");
2776 uiDefIconBut(block, BUT, B_TEMPDIRFILESEL, ICON_FILESEL,
2777 (xpos+edgsp+(4*lpref)+(3*midsp)-smfileselbut),y1,smfileselbut,buth,
2778 0, 0, 0, 0, 0, "Select the default temporary save file location");
2784 myortho2(-0.375, (float)(sa->winx)-0.375, -0.375, (float)(sa->winy)-0.375);
2785 draw_area_emboss(sa);
2786 myortho2(0.0, 1280.0, 0.0, curarea->winy/fac);
2787 sa->win_swap= WIN_BACK_OK;
2792 void winqreadinfospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
2794 unsigned short event= evt->event;
2795 short val= evt->val;
2798 if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;