soc-2008-mxcurioni: merged changes to revision 15705
[blender.git] / source / blender / src / space.c
index 3b8bb4c3929be8f152e2019288b34666d77fc701..92efb477095fe300202eafe4f6b3f0209e73c4a8 100644 (file)
@@ -56,6 +56,7 @@
 #include "DNA_armature_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_group_types.h" /* used for select_same_group */
+#include "DNA_gpencil_types.h"
 #include "DNA_image_types.h"
 #include "DNA_ipo_types.h"
 #include "DNA_mesh_types.h"
 #include "BDR_imagepaint.h"
 #include "BDR_sculptmode.h"
 #include "BDR_unwrapper.h"
+#include "BDR_gpencil.h"
 
 #include "BLO_readfile.h" /* for BLO_blendhandle_close */
 
@@ -1193,13 +1195,17 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                
                if(event==UI_BUT_EVENT) do_butspace(val); /* temporal, view3d deserves own queue? */
                
-               /* we consider manipulator a button, defaulting to leftmouse */
+               /* - we consider manipulator a button, defaulting to leftmouse 
+                * - grease-pencil also defaults to leftmouse
+                */
                if(event==LEFTMOUSE) {
                        /* run any view3d event handler script links */
-                       if (event && sa->scriptlink.totscript)
+                       if (event && sa->scriptlink.totscript) {
                                if (BPY_do_spacehandlers(sa, event, SPACEHANDLER_VIEW3D_EVENT))
                                        return; /* return if event was processed (swallowed) by handler(s) */
-
+                       }
+                       
+                       if(gpencil_do_paint(sa)) return;
                        if(BIF_do_manipulator(sa)) return;
                }
                
@@ -1207,7 +1213,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                if (U.flag & USER_LMOUSESELECT) {
                        /* only swap mouse button for selection, in modes where it is relevant.
                         * painting/sculpting stays on LEFTMOUSE */
-                       if (   !((G.f & G_SCULPTMODE) || (G.f & G_WEIGHTPAINT) ||
+                       if (   !((G.f & G_SCULPTMODE) || (G.f & G_WEIGHTPAINT) || (G.f & G_GREASEPENCIL) ||
                                (G.f & G_VERTEXPAINT) || (G.f & G_TEXTUREPAINT) || (G.f & G_PARTICLEEDIT)) ||
                                (G.obedit) )
                        {                       
@@ -1945,7 +1951,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                adduplicate(0, 0);
                                }
                                else if(G.qual==LR_CTRLKEY) {
-                                       imagestodisplist();
+                                       imagestodisplist(); // removed
                                }
                                else if((G.qual==0)){
                                        pupval= pupmenu("Draw mode%t|BoundBox %x1|Wire %x2|OpenGL Solid %x3|Shaded Solid %x4|Textured Solid %x5");
@@ -4816,6 +4822,11 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
        if(val) {
                if( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
                
+               /* grease-pencil defaults to leftmouse */
+               if(event==LEFTMOUSE) {
+                       if(gpencil_do_paint(sa)) return;
+               }
+               
                /* swap mouse buttons based on user preference */
                if (U.flag & USER_LMOUSESELECT) {
                        if (event == LEFTMOUSE) {
@@ -4829,11 +4840,11 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                
                switch(event) {
                case LEFTMOUSE:
-                       if(sseq->mainb || view2dmove(event)==0) {
+                       if(sseq->mainb==0 && view2dmove(event)==0) {
                                
                                first= 1;               
                                set_special_seq_update(1);
-
+                               
                                do {
                                        getmouseco_areawin(mval);
                                        areamouseco_to_ipoco(v2d, mval, &dx, &dy);
@@ -4844,9 +4855,9 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        
                                        if( cfra!=CFRA || first ) {
                                                first= 0;
-                               
+                                               
                                                CFRA= cfra;
-                                               force_draw(0);
+                                               force_draw_all(0);
                                                update_for_newframe();  /* for audio scrubbing */                                               
                                        }
                                        else PIL_sleep_ms(30);
@@ -6241,6 +6252,7 @@ void freespacelist(ScrArea *sa)
                                if(vd->bgpic->ima) vd->bgpic->ima->id.us--;
                                MEM_freeN(vd->bgpic);
                        }
+                       if(vd->gpd) free_gpencil_data(vd->gpd);
                        if(vd->localvd) MEM_freeN(vd->localvd);
                        if(vd->clipbb) MEM_freeN(vd->clipbb);
                        if(vd->depths) {
@@ -6284,7 +6296,12 @@ void freespacelist(ScrArea *sa)
                                curvemapping_free(sima->cumap);
                }
                else if(sl->spacetype==SPACE_NODE) {
-/*                     SpaceNode *snode= (SpaceNode *)sl; */
+                       SpaceNode *snode= (SpaceNode *)sl;
+                       if(snode->gpd) free_gpencil_data(snode->gpd);
+               }
+               else if(sl->spacetype==SPACE_SEQ) {
+                       SpaceSeq *sseq= (SpaceSeq *)sl;
+                       if(sseq->gpd) free_gpencil_data(sseq->gpd);
                }
        }
 
@@ -6314,6 +6331,7 @@ void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2)
                        BIF_view3d_previewrender_free(v3d);
                        v3d->depths= NULL;
                        v3d->retopo_view_data= NULL;
+                       v3d->gpd= gpencil_data_duplicate(v3d->gpd);
                }
                else if(sl->spacetype==SPACE_OOPS) {
                        SpaceOops *so= (SpaceOops *)sl;
@@ -6333,11 +6351,16 @@ void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2)
                else if(sl->spacetype==SPACE_NODE) {
                        SpaceNode *snode= (SpaceNode *)sl;
                        snode->nodetree= NULL;
+                       snode->gpd= gpencil_data_duplicate(snode->gpd);
                }
                else if(sl->spacetype==SPACE_SCRIPT) {
                        SpaceScript *sc = ( SpaceScript * ) sl;
                        sc->but_refs = NULL;
                }
+               else if(sl->spacetype==SPACE_SEQ) {
+                       SpaceSeq *sseq= (SpaceSeq *)sl;
+                       sseq->gpd= gpencil_data_duplicate(sseq->gpd);
+               }
                sl= sl->next;
        }