Two in one:
[blender.git] / source / blender / src / toets.c
index 9b46d9c5f437377fc5fcaee96faadb817a909bff..355a1535f42dac2242a6241bf76e74cf9f431199 100644 (file)
@@ -79,6 +79,7 @@
 #include "BIF_poseobject.h"
 #include "BIF_previewrender.h"
 #include "BIF_renderwin.h"
+#include "BIF_retopo.h"
 #include "BIF_screen.h"
 #include "BIF_space.h"
 #include "BIF_toets.h"
@@ -86,6 +87,7 @@
 #include "BIF_usiblender.h"
 #include "BIF_writeimage.h"
 
+#include "BDR_sculptmode.h"
 #include "BDR_vpaint.h"
 #include "BDR_editobject.h"
 #include "BDR_editface.h"
@@ -139,8 +141,10 @@ void persptoetsen(unsigned short event)
        }
        else if((G.qual & (LR_SHIFTKEY | LR_CTRLKEY)) && (event != PAD0)) {
                
-               /* indicate that this view is inverted */
-               G.vd->flag2 |= V3D_OPP_DIRECTION_NAME;
+               /* Indicate that this view is inverted,
+                * but only if it actually _was_ inverted (jobbe) */
+               if (event==PAD7 || event == PAD1 || event == PAD3)
+                       G.vd->flag2 |= V3D_OPP_DIRECTION_NAME;
                
                if(event==PAD0) {
                        /* G.vd->persp= 3; */
@@ -201,8 +205,11 @@ void persptoetsen(unsigned short event)
                }
        }
        else {
-               /* indicate that this view is not inverted */
-               G.vd->flag2 &= ~V3D_OPP_DIRECTION_NAME;
+               /* Indicate that this view is not inverted.
+                * Don't do this for PADMINUS/PADPLUSKEY, though. (jobbe)*/
+               if (event != PADMINUS && event != PADPLUSKEY)
+                       G.vd->flag2 &= ~V3D_OPP_DIRECTION_NAME;
+               
 
                if(event==PAD7) {
                        G.vd->viewquat[0]= 1.0;
@@ -259,8 +266,9 @@ void persptoetsen(unsigned short event)
                                handle_view3d_lock();
                        }
                        else if(BASACT) {
+                               /* check both G.vd as G.scene cameras */
                                if(G.qual==LR_CTRLKEY) {
-                                       if(G.vd->camera != OBACT) {
+                                       if(G.vd->camera != OBACT || G.scene->camera != OBACT) {
                                                if(G.vd->camera && G.vd->camera->type==OB_CAMERA)
                                                        oldcamera= G.vd->camera;
                                                
@@ -268,7 +276,7 @@ void persptoetsen(unsigned short event)
                                                handle_view3d_lock();
                                        }
                                }
-                               else if(G.vd->camera==0 && OBACT->type==OB_CAMERA) {
+                               else if((G.vd->camera==NULL || G.scene->camera==NULL) && OBACT->type==OB_CAMERA) {
                                        G.vd->camera= OBACT;
                                        handle_view3d_lock();
                                }
@@ -285,6 +293,7 @@ void persptoetsen(unsigned short event)
                                        void setcameratoview3d(void);   // view.c
                                        setcameratoview3d();
                                        DAG_object_flush_update(G.scene, G.scene->camera, OB_RECALC_OB);
+                                       BIF_undo_push("View to Camera position");
                                        allqueue(REDRAWVIEW3D, 0);
                                }                               
                        }
@@ -298,7 +307,7 @@ void persptoetsen(unsigned short event)
                else if(G.vd->persp<2) {
                        if(event==PAD4 || event==PAD6) {
                                /* z-axis */
-                               phi= (float)(M_PI/24.0);
+                               phi= (float)(M_PI/360.0)*U.pad_rot_angle;
                                if(event==PAD6) phi= -phi;
                                si= (float)sin(phi);
                                q1[0]= (float)cos(phi);
@@ -313,7 +322,7 @@ void persptoetsen(unsigned short event)
                                VECCOPY(q1+1, G.vd->viewinv[0]);
                                
                                Normalise(q1+1);
-                               phi= (float)(M_PI/24.0);
+                               phi= (float)(M_PI/360.0)*U.pad_rot_angle;
                                if(event==PAD2) phi= -phi;
                                si= (float)sin(phi);
                                q1[0]= (float)cos(phi);
@@ -327,6 +336,8 @@ void persptoetsen(unsigned short event)
 
                if(G.vd->persp<2) perspo= G.vd->persp;
        }
+
+       retopo_force_update();
        
        if(preview3d_event) 
                BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
@@ -378,8 +389,8 @@ char *recent_filelist(void)
                        recent = BLI_findlink(&(G.recent_files), event-1-ofs);
                        if(recent) return(recent->filename);
        }
-       else
-               return(NULL);
+       
+       return(NULL);
 }
 
 int blenderqread(unsigned short event, short val)
@@ -439,15 +450,16 @@ int blenderqread(unsigned short event, short val)
                break;
        case F3KEY:
                if(G.qual==0) {
-                       BIF_save_rendered_image_fs(0);
+                       BIF_save_rendered_image_fs();
+                       return 0;
+               }
+               else if(G.qual==LR_SHIFTKEY) {
+                       newspace(curarea, SPACE_NODE);
                        return 0;
                }
                else if(G.qual & LR_CTRLKEY) {
                        BIF_screendump(0);
                }
-               else if(G.qual & LR_SHIFTKEY) {
-                       BIF_save_rendered_image_fs(1);
-               }
                break;
        case F4KEY:
                if(G.qual==LR_SHIFTKEY) {
@@ -456,11 +468,11 @@ int blenderqread(unsigned short event, short val)
                        ob= OBACT;
                        if(ob) strcpy(str, ob->id.name);
 
-                       activate_fileselect(FILE_MAIN, "Data Select", str, 0);
+                       activate_fileselect(FILE_MAIN, "Data Select", str, NULL);
                        return 0;
                }
                else if(G.qual==0) {
-                       extern_set_butspace(event);
+                       extern_set_butspace(event, 1);
                }
                break;
        case F5KEY:
@@ -469,7 +481,7 @@ int blenderqread(unsigned short event, short val)
                        return 0;
                }
                else if(G.qual==0) {
-                       extern_set_butspace(event);
+                       extern_set_butspace(event, 1);
                }
                break;
        case F6KEY:
@@ -478,7 +490,7 @@ int blenderqread(unsigned short event, short val)
                        return 0;
                }
                else if(G.qual==0) {
-                       extern_set_butspace(event);
+                       extern_set_butspace(event, 1);
                }
                break;
        case F7KEY:
@@ -487,7 +499,7 @@ int blenderqread(unsigned short event, short val)
                        return 0;
                }
                else if(G.qual==0) {
-                       extern_set_butspace(event);
+                       extern_set_butspace(event, 1);
                }
                break;
        case F8KEY:
@@ -496,7 +508,7 @@ int blenderqread(unsigned short event, short val)
                        return 0;
                }
                else if(G.qual==0) {
-                       extern_set_butspace(event);
+                       extern_set_butspace(event, 1);
                }
                break;
        case F9KEY:
@@ -509,7 +521,7 @@ int blenderqread(unsigned short event, short val)
                        return 0;
                }
                else if(G.qual==0) {
-                       extern_set_butspace(event);
+                       extern_set_butspace(event, 1);
                }
                break;
        case F10KEY:
@@ -518,7 +530,7 @@ int blenderqread(unsigned short event, short val)
                        return 0;
                }
                else if(G.qual==0) {
-                       extern_set_butspace(event);
+                       extern_set_butspace(event, 1);
                }
                break;
        case F11KEY:
@@ -645,11 +657,11 @@ int blenderqread(unsigned short event, short val)
                                else if(G.vd) {
                                        /* also when Alt-E */
                                        if(G.obedit==NULL) {
-                                               enter_editmode();
+                                               enter_editmode(EM_WAITCURSOR);
                                                if(G.obedit) BIF_undo_push("Original"); // here, because all over code enter_editmode is abused
                                        }
                                        else
-                                               exit_editmode(2); // freedata, and undo
+                                               exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); // freedata, and undo
                                }
                                return 0;
                        }
@@ -663,25 +675,12 @@ int blenderqread(unsigned short event, short val)
                                }
                                else if(ob->type==OB_MESH) {
                                        if(ob==G.obedit) EM_selectmode_menu();
+                                       else if(G.f & G_SCULPTMODE)
+                                               sculptmode_selectbrush_menu();
                                        else set_wpaint();
                                }
                        }
                }
-               else if(G.qual==LR_SHIFTKEY) {  // ??
-                       if(G.obedit)
-                               exit_editmode(2); // freedata, and undo
-                       if(G.f & G_FACESELECT)
-                               set_faceselect();
-                       if(G.f & G_VERTEXPAINT)
-                               set_vpaint();
-                       if(G.f & G_TEXTUREPAINT) {
-                               G.f &= ~G_TEXTUREPAINT;
-                               allqueue(REDRAWVIEW3D, 0);
-                               allqueue(REDRAWBUTSEDIT, 0);
-                       }
-                       if(G.f & G_WEIGHTPAINT)
-                               set_wpaint();
-               }
                break;
 
        case BACKSPACEKEY:
@@ -703,18 +702,19 @@ int blenderqread(unsigned short event, short val)
                if(G.qual==LR_ALTKEY) {
                        if(G.vd && textspace==0) {
                                if(G.obedit==0) {
-                                       enter_editmode();
+                                       enter_editmode(EM_WAITCURSOR);
                                        BIF_undo_push("Original");
                                }
                                else
-                                       exit_editmode(2); // freedata, and undo
+                                       exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); // freedata, and undo
                                return 0;
                        }                       
                }
                break;
        case IKEY:
-               if(textediting==0 && textspace==0 && curarea->spacetype!=SPACE_FILE && curarea->spacetype!=SPACE_IMASEL) {
-                       if(G.qual==0) {
+               if(textediting==0 && textspace==0 && !ELEM3(curarea->spacetype, SPACE_FILE, SPACE_IMASEL, SPACE_NODE)) {
+                       if(G.f & G_SCULPTMODE) return 1;
+                       else if(G.qual==0) {
                                common_insertkey();
                                return 0;
                        }
@@ -781,6 +781,8 @@ int blenderqread(unsigned short event, short val)
                        int a;
                        double delta, stime;
 
+                       if (event < 0) return 0; /* cancelled by user */
+
                        waitcursor(1);
                        
                        stime= PIL_check_seconds_timer();
@@ -871,6 +873,7 @@ int blenderqread(unsigned short event, short val)
                        }
                        else if(G.qual==LR_ALTKEY) {
                                write_videoscape_fs();
+                               return 0;
                        }
                }
                break;