~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/src/toets.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: toets.c,v 1.27 2004/04/20 22:00:33 ton Exp $
 
2
 * $Id: toets.c,v 1.54 2005/06/10 13:12:59 jesterking Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
38
38
#include <string.h>
39
39
#include <math.h>
40
40
 
41
 
#ifdef HAVE_CONFIG_H
42
 
#include <config.h>
43
 
#endif
44
 
 
45
41
#ifdef WIN32
46
42
#include "BLI_winstuff.h"
47
43
#endif
59
55
#include "DNA_screen_types.h"
60
56
#include "DNA_space_types.h"
61
57
#include "DNA_view3d_types.h"
 
58
#include "DNA_userdef_types.h"
62
59
 
63
 
#include "BKE_utildefines.h"
 
60
#include "BKE_action.h"
 
61
#include "BKE_anim.h"
 
62
#include "BKE_blender.h"
 
63
#include "BKE_displist.h"
64
64
#include "BKE_global.h"
65
 
#include "BKE_anim.h"
66
 
#include "BKE_scene.h"
67
65
#include "BKE_ipo.h"
68
 
#include "BKE_action.h"
69
66
#include "BKE_ika.h"
70
67
#include "BKE_key.h"
71
 
#include "BKE_displist.h"
 
68
#include "BKE_scene.h"
 
69
#include "BKE_utildefines.h"
72
70
 
 
71
#include "BIF_butspace.h"
 
72
#include "BIF_editseq.h"
 
73
#include "BIF_editsound.h"
 
74
#include "BIF_editmesh.h"
73
75
#include "BIF_interface.h"
 
76
#include "BIF_poseobject.h"
 
77
#include "BIF_renderwin.h"
74
78
#include "BIF_screen.h"
75
79
#include "BIF_space.h"
76
 
#include "BIF_butspace.h"
77
 
#include "BIF_renderwin.h"
 
80
#include "BIF_toets.h"
78
81
#include "BIF_toolbox.h"
79
 
#include "BIF_toets.h"
80
 
#include "BIF_editseq.h"
81
 
#include "BIF_editsound.h"
82
 
#include "BIF_poseobject.h"
83
82
#include "BIF_usiblender.h"
84
83
 
85
84
#include "BDR_vpaint.h"
92
91
#include "BSE_edit.h"
93
92
#include "BSE_editipo.h"
94
93
#include "BSE_headerbuttons.h"
 
94
#include "BSE_seqaudio.h"
95
95
 
96
96
#include "blendef.h"
97
 
#include "render.h"
 
97
#include "render.h"             // darn schrijfplaatje() (ton)
98
98
 
99
99
#include "IMB_imbuf.h"
100
100
#include "IMB_imbuf_types.h"
103
103
 
104
104
#include "BIF_poseobject.h"
105
105
 
106
 
/* only used in toets.c */
 
106
/* only used in toets.c and initrender.c */
107
107
/* this function doesn't really belong here */
108
108
/* ripped from render module */
109
109
void schrijfplaatje(char *name);
110
110
 
111
111
 
112
 
void write_imag(char *name)
 
112
static void write_imag(char *name)
113
113
{
114
114
        /* from file select */
115
115
        char str[256];
174
174
 
175
175
        if(ibuf) {
176
176
                ibuf->rect= (unsigned int *) R.rectot;
 
177
//              ibuf->rect_float = R.rectftot;
177
178
 
178
179
                if(R.r.planes == 8) IMB_cspace(ibuf, rgb_to_bw);
179
180
 
273
274
                        G.vd->viewquat[2]= 0.0;
274
275
                        G.vd->viewquat[3]= 0.0;
275
276
                        G.vd->view= 7;
276
 
                        if(G.vd->persp>=2) G.vd->persp= perspo;
 
277
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0; 
 
278
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
277
279
                }
278
280
                else if(event==PAD1) {
279
281
                        G.vd->viewquat[0]= 0.0;
281
283
                        G.vd->viewquat[2]= (float)-cos(M_PI/4.0);
282
284
                        G.vd->viewquat[3]= (float)-cos(M_PI/4.0);
283
285
                        G.vd->view=1;
284
 
                        if(G.vd->persp>=2) G.vd->persp= perspo;
 
286
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
 
287
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
285
288
                }
286
289
                else if(event==PAD3) {
287
290
                        G.vd->viewquat[0]= 0.5;
289
292
                        G.vd->viewquat[2]= 0.5;
290
293
                        G.vd->viewquat[3]= 0.5;
291
294
                        G.vd->view=3;
292
 
                        if(G.vd->persp>=2) G.vd->persp= perspo;
 
295
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
 
296
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
293
297
                }
294
298
                else if(event==PADMINUS) {
295
299
                        /* this min and max is also in viewmove() */
327
331
                        G.vd->viewquat[2]= 0.0;
328
332
                        G.vd->viewquat[3]= 0.0;
329
333
                        G.vd->view=7;
330
 
                        if(G.vd->persp>=2) G.vd->persp= perspo;
 
334
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
 
335
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
331
336
                }
332
337
                else if(event==PAD1) {
333
338
                        G.vd->viewquat[0]= (float)cos(M_PI/4.0);
335
340
                        G.vd->viewquat[2]= 0.0;
336
341
                        G.vd->viewquat[3]= 0.0;
337
342
                        G.vd->view=1;
338
 
                        if(G.vd->persp>=2) G.vd->persp= perspo;
 
343
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
 
344
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
339
345
                }
340
346
                else if(event==PAD3) {
341
347
                        G.vd->viewquat[0]= 0.5;
343
349
                        G.vd->viewquat[2]= -0.5;
344
350
                        G.vd->viewquat[3]= -0.5;
345
351
                        G.vd->view=3;
346
 
                        if(G.vd->persp>=2) G.vd->persp= perspo;
 
352
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
 
353
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
347
354
                }
348
355
                else if(event==PADMINUS) {
349
356
                        /* this min and max is also in viewmove() */
393
400
                        if(G.vd->camera) {
394
401
                                G.vd->persp= 2;
395
402
                                G.vd->view= 0;
396
 
                                if(G.qual & LR_SHIFTKEY) {
 
403
                                if(((G.qual & LR_CTRLKEY) && (G.qual & LR_ALTKEY)) || (G.qual & LR_SHIFTKEY)) {
397
404
                                        void setcameratoview3d(void);   // view.c
398
405
                                        setcameratoview3d();
399
406
                                }                               
403
410
                        countall();
404
411
                        do_all_ipos();
405
412
                        do_all_keys();
406
 
                        do_all_actions();
 
413
                        do_all_actions(NULL);
407
414
                        do_all_ikas();
408
415
                        test_all_displists();
409
416
                        
464
471
{
465
472
        switch(G.scene->r.imtype) {
466
473
        case R_PNG:
467
 
                strcpy(str, "SAVE PNG"); return 1;
 
474
                strcpy(str, "Save PNG"); return 1;
468
475
        case R_BMP:
469
 
                strcpy(str, "SAVE BMP"); return 1;
 
476
                strcpy(str, "Save BMP"); return 1;
470
477
        case R_TARGA:
471
 
                strcpy(str, "SAVE TARGA"); return 1;
 
478
                strcpy(str, "Save Targa"); return 1;
472
479
        case R_RAWTGA:
473
 
                strcpy(str, "SAVE RAW TARGA"); return 1;
 
480
                strcpy(str, "Save Raw Targa"); return 1;
474
481
        case R_IRIS:
475
 
                strcpy(str, "SAVE IRIS"); return 1;
 
482
                strcpy(str, "Save IRIS"); return 1;
476
483
        case R_IRIZ:
477
 
                strcpy(str, "SAVE IRIS"); return 1;
 
484
                strcpy(str, "Save IRIS"); return 1;
478
485
        case R_HAMX:
479
 
                strcpy(str, "SAVE HAMX"); return 1;
 
486
                strcpy(str, "Save HAMX"); return 1;
480
487
        case R_FTYPE:
481
 
                strcpy(str, "SAVE FTYPE"); return 1;
 
488
                strcpy(str, "Save Ftype"); return 1;
482
489
        case R_JPEG90:
483
 
                strcpy(str, "SAVE JPEG"); return 1;
 
490
                strcpy(str, "Save JPEG"); return 1;
484
491
        default:
485
 
                strcpy(str, "SAVE IMAGE"); return 0;
 
492
                strcpy(str, "Save Image"); return 0;
486
493
        }       
487
494
}
488
495
 
540
547
                                areawinset(sa->win);
541
548
                        }
542
549
                        
543
 
                        activate_fileselect(FILE_BLENDER, "LOAD FILE", G.sce, BIF_read_file);
 
550
                        activate_fileselect(FILE_BLENDER, "Open File", G.sce, BIF_read_file);
544
551
                        return 0;
545
552
                }
546
553
                else if(G.qual==LR_SHIFTKEY) {
547
 
                        activate_fileselect(FILE_LOADLIB, "LOAD LIBRARY", G.lib, 0);
 
554
                        activate_fileselect(FILE_LOADLIB, "Load Library", G.lib, 0);
548
555
                        return 0;
549
556
                }
550
557
                break;
552
559
                if(G.qual==0) {
553
560
                        strcpy(dir, G.sce);
554
561
                        untitled(dir);
555
 
                        activate_fileselect(FILE_BLENDER, "SAVE FILE", dir, BIF_write_file);
 
562
                        activate_fileselect(FILE_BLENDER, "Save File", dir, BIF_write_file);
556
563
                        return 0;
557
564
                }
558
565
                else if(G.qual==LR_CTRLKEY) {
571
578
                }
572
579
                else if(G.qual & LR_CTRLKEY) {
573
580
                        /* all alt+ctrl+shift combos are needed here... */
574
 
                        BIF_screendump();
 
581
                        BIF_screendump(0);
575
582
                }
576
583
                break;
577
584
        case F4KEY:
581
588
                        ob= OBACT;
582
589
                        if(ob) strcpy(str, ob->id.name);
583
590
 
584
 
                        activate_fileselect(FILE_MAIN, "DATA SELECT", str, 0);
 
591
                        activate_fileselect(FILE_MAIN, "Data Select", str, 0);
585
592
                        return 0;
586
593
                }
587
594
                else if(G.qual==0) {
629
636
                        newspace(curarea, SPACE_OOPS);
630
637
                        return 0;
631
638
                }
 
639
                else if(G.qual==(LR_SHIFTKEY|LR_ALTKEY)) {
 
640
                        newspace(curarea, SPACE_OOPS+256);
 
641
                        return 0;
 
642
                }
632
643
                else if(G.qual==0) {
633
644
                        extern_set_butspace(event);
634
645
                }
672
683
        case DOWNARROWKEY:
673
684
                if(textediting==0 && textspace==0) {
674
685
 
675
 
#ifdef _WIN32   // FULLSCREEN
 
686
#if 0
 
687
//#ifdef _WIN32 // FULLSCREEN
676
688
                        if(event==DOWNARROWKEY){
677
689
                                if (G.qual==LR_ALTKEY)
678
690
                                        mainwindow_toggle_fullscreen(0);
699
711
        case UPARROWKEY:
700
712
                if(textediting==0 && textspace==0) {
701
713
 
702
 
#ifdef _WIN32   // FULLSCREEN
 
714
#if 0
 
715
//#ifdef _WIN32 // FULLSCREEN
703
716
                        if(event==UPARROWKEY){ 
704
717
                                if(G.qual==LR_ALTKEY)
705
718
                                        mainwindow_toggle_fullscreen(1);
721
734
                break;
722
735
 
723
736
        case ESCKEY:
724
 
                sound_stop_all_sounds();
 
737
                sound_stop_all_sounds();        // whats this?
 
738
                
 
739
                /* stop playback on ESC always */
 
740
                rem_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM);
 
741
                audiostream_stop();
 
742
                allqueue(REDRAWALL, 0);
 
743
                
725
744
                break;
726
745
        case TABKEY:
727
746
                if(G.qual==0) {
732
751
                                        enter_meta();
733
752
                                else if(G.vd) {
734
753
                                        /* also when Alt-E */
735
 
                                        if(G.obedit==0)
 
754
                                        if(G.obedit==NULL) {
736
755
                                                enter_editmode();
 
756
                                                if(G.obedit) BIF_undo_push("Original"); // here, because all over code enter_editmode is abused
 
757
                                        }
737
758
                                        else
738
 
                                                exit_editmode(1);
 
759
                                                exit_editmode(2); // freedata, and undo
739
760
                                }
740
761
                                return 0;
741
762
                        }
742
763
                }
743
764
                else if(G.qual==LR_CTRLKEY){
744
 
                        if(G.obpose)
745
 
                                exit_posemode(1);
746
 
                        else
747
 
                                enter_posemode();
748
 
                        allqueue(REDRAWHEADERS, 0);     
749
 
                        allqueue(REDRAWBUTSALL, 0);     
 
765
                        Object *ob= OBACT;
 
766
                        if(ob) {
 
767
                                if(ob->type==OB_ARMATURE) {
 
768
                                        if(G.obpose) exit_posemode(1);
 
769
                                        else enter_posemode();
 
770
                                }
 
771
                                else if(ob->type==OB_MESH) {
 
772
                                        if(ob==G.obedit) EM_selectmode_menu();
 
773
                                }
 
774
                        }
750
775
                }
751
776
                else if(G.qual==LR_SHIFTKEY) {
752
777
                        if(G.obedit)
753
 
                                exit_editmode(1);
 
778
                                exit_editmode(2); // freedata, and undo
754
779
                        if(G.f & G_FACESELECT)
755
780
                                set_faceselect();
756
781
                        if(G.f & G_VERTEXPAINT)
757
782
                                set_vpaint();
 
783
                        if(G.f & G_TEXTUREPAINT) {
 
784
                                G.f &= ~G_TEXTUREPAINT;
 
785
                                allqueue(REDRAWVIEW3D, 0);
 
786
                                allqueue(REDRAWBUTSEDIT, 0);
 
787
                        }
758
788
                        if(G.f & G_WEIGHTPAINT)
759
789
                                set_wpaint();
760
790
                        if(G.obpose)
780
810
        case EKEY:
781
811
                if(G.qual==LR_ALTKEY) {
782
812
                        if(G.vd && textspace==0) {
783
 
                                if(G.obedit==0)
 
813
                                if(G.obedit==0) {
784
814
                                        enter_editmode();
 
815
                                        BIF_undo_push("Original");
 
816
                                }
785
817
                                else
786
 
                                        exit_editmode(1);
 
818
                                        exit_editmode(2); // freedata, and undo
787
819
                                return 0;
788
820
                        }                       
789
821
                }
814
846
                                else if(curarea->spacetype==SPACE_IMAGE);                       // is new panel, in ipo queue
815
847
                                else if(curarea->spacetype==SPACE_ACTION);                      // is own queue
816
848
                                else if(curarea->spacetype==SPACE_NLA);                 // is new panel
 
849
                                else if(curarea->spacetype==SPACE_SEQ);                 // is new panel
817
850
                                else {
818
851
                                        clever_numbuts();
819
852
                                        return 0;
844
877
                        if(G.qual==LR_CTRLKEY) {
845
878
                                strcpy(dir, G.sce);
846
879
                                if (untitled(dir)) {
847
 
                                        activate_fileselect(FILE_BLENDER, "SAVE FILE", dir, BIF_write_file);
 
880
                                        activate_fileselect(FILE_BLENDER, "Save File", dir, BIF_write_file);
848
881
                                } else {
849
882
                                        BIF_write_file(dir);
850
883
                                        free_filesel_spec(dir);
875
908
                }
876
909
                else if(G.qual==(LR_ALTKEY|LR_CTRLKEY)) {
877
910
                        int a;
878
 
                        int event= pupmenu("10 Timer%t|draw|draw+swap|displist");
 
911
                        int event= pupmenu("10 Timer%t|draw|draw+swap|displist|undo");
879
912
                        if(event>0) {
880
913
                                double stime= PIL_check_seconds_timer();
881
914
                                char tmpstr[128];
894
927
                                                        makeDispList(OBACT);
895
928
                                                }
896
929
                                        }
 
930
                                        else if(event==4) {
 
931
                                                BKE_write_undo("10 timer");
 
932
                                        }
897
933
                                }
898
934
                        
899
935
                                time= (PIL_check_seconds_timer()-stime)*1000;
901
937
                                if(event==1) sprintf(tmpstr, "draw %%t|%d ms", time);
902
938
                                if(event==2) sprintf(tmpstr, "d+sw %%t|%d ms", time);
903
939
                                if(event==3) sprintf(tmpstr, "displist %%t|%d ms", time);
 
940
                                if(event==4) sprintf(tmpstr, "undo %%t|%d ms", time);
904
941
                        
905
942
                                waitcursor(0);
906
943
                                pupmenu(tmpstr);
913
950
        case UKEY:
914
951
                if(textediting==0) {
915
952
                        if(G.qual==LR_CTRLKEY) {
916
 
                                if(okee("SAVE USER DEFAULTS")) {
 
953
                                if(okee("Save user defaults")) {
917
954
                                        BIF_write_homefile();
918
955
                                }
919
956
                                return 0;
920
957
                        }
 
958
                        else if(G.qual==LR_ALTKEY) {
 
959
                                if(curarea->spacetype!=SPACE_TEXT) {
 
960
                                        BIF_undo_menu();
 
961
                                        return 0;
 
962
                                }
 
963
                        }
921
964
                }
922
965
                break;
923
966
                
926
969
                        if(G.qual==LR_CTRLKEY) {
927
970
                                strcpy(dir, G.sce);
928
971
                                if (untitled(dir)) {
929
 
                                        activate_fileselect(FILE_BLENDER, "SAVE FILE", dir, BIF_write_file);
 
972
                                        activate_fileselect(FILE_BLENDER, "Save File", dir, BIF_write_file);
930
973
                                } else {
931
974
                                        BIF_write_file(dir);
932
975
                                        free_filesel_spec(dir);
942
985
        case XKEY:
943
986
                if(textspace==0) {
944
987
                        if(G.qual==LR_CTRLKEY) {
945
 
                                if(okee("ERASE ALL")) {
 
988
                                if(okee("Erase all")) {
 
989
                                        strcpy(G.sce, BLI_gethome());
 
990
                                        strcat(G.sce, "/untitled.blend");
 
991
                                        BLI_clean(G.sce);
946
992
                                        if( BIF_read_homefile()==0) error("No file ~/.B.blend");
947
993
                                }
948
994
                                return 0;
949
995
                        }
950
996
                }
951
997
                break;
 
998
        case YKEY:      // redo alternative
 
999
                if(textspace==0) {
 
1000
                        if(G.qual==LR_CTRLKEY) {
 
1001
                                BIF_redo(); 
 
1002
                                return 0;
 
1003
                        }
 
1004
                }
 
1005
                break;
 
1006
        case ZKEY:      // undo
 
1007
                if(textspace==0) {
 
1008
                        if(G.qual & (LR_CTRLKEY|LR_COMMANDKEY)) { // all combos with ctrl/commandkey are accepted
 
1009
                                if ELEM(G.qual, LR_CTRLKEY, LR_COMMANDKEY) BIF_undo();
 
1010
                                else BIF_redo(); // all combos with ctrl is redo
 
1011
                                return 0;
 
1012
                        }
 
1013
                }
 
1014
                break; 
952
1015
        }
953
1016
        
954
1017
        return 1;