2.5
authorTon Roosendaal <ton@blender.org>
Sun, 8 Feb 2009 12:16:35 +0000 (12:16 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 8 Feb 2009 12:16:35 +0000 (12:16 +0000)
Scene browse button now works.
Note that animsys currently executes animation for the entire
database, so multiple scenes in multiple windows don't work yet.

Various fixes:

- crash on invoking filewindow when mouse outside (active) window
- removed obsolete error prints (set screen error, copy data error)
- displist fix for loading files with curve/nurbs, the select-outline
  then didnt draw immediately.
- outliner allows scene activating

source/blender/editors/include/ED_screen.h
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_info/info_header.c
source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c

index ce53ac78d20715d1fa9a45749179df4d0a073a86..b5e2558c893b541cf8d2d328d215c86a3769051c 100644 (file)
@@ -39,12 +39,14 @@ struct wmNotifier;
 struct wmEvent;
 struct bContext;
 struct SpaceType;
-struct AreagionType;
+struct Scene;
+struct bScreen;
+struct ARegion;
 struct uiBlock;
 struct rcti;
 
 /* regions */
-void   ED_region_do_listen(ARegion *ar, struct wmNotifier *note);
+void   ED_region_do_listen(struct ARegion *ar, struct wmNotifier *note);
 void   ED_region_do_draw(struct bContext *C, struct ARegion *ar);
 void   ED_region_exit(struct bContext *C, struct ARegion *ar);
 void   ED_region_pixelspace(struct ARegion *ar);
@@ -79,10 +81,11 @@ void        ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
 void   ED_screen_do_listen(struct wmWindow *win, struct wmNotifier *note);
 bScreen *ED_screen_duplicate(struct wmWindow *win, struct bScreen *sc);
 void   ED_screen_set(struct bContext *C, struct bScreen *sc);
+void   ED_screen_set_scene(struct bContext *C, struct Scene *scene);
 void   ED_screen_set_subwinactive(struct wmWindow *win, struct wmEvent *event);
 void   ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen);
 void   ED_screen_animation_timer(struct bContext *C, int enable);
-void   ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type);
+int            ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type);
 void   ED_screen_full_prevspace(struct bContext *C);
 
 /* anim */
index 01ae32e78f6c3484459a13094edf1ce04418a901..bc90728f23e222c574052e5d4ceaa84bd3839c8c 100644 (file)
@@ -642,12 +642,10 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space)
        else {
                BKE_spacedata_freelist(&sa1->spacedata);
                BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata);
-               
-               if(sa1->spacedata.first==NULL) {
-                       printf("copy data error\n");
-               }
        }
        
+       /* Note; SPACE_EMPTY is possible on new screens */
+       
        /* regions */
        st= BKE_spacetype_from_id(sa1->spacetype);
        for(ar= sa1->regionbase.first; ar; ar= ar->next)
index 800a618e89e7c69d06038249127953562e3a30dd..3f047add6d550c1784cb6ecff2f240ada1655292 100644 (file)
@@ -32,6 +32,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_texture_types.h"
+#include "DNA_userdef_types.h"
 
 #include "BLI_blenlib.h"
 
@@ -1234,7 +1235,6 @@ void ED_screen_set(bContext *C, bScreen *sc)
                                break;
                        }
                }
-               if(sc1==NULL) printf("set screen error\n");
        }
        
        if (oldscreen != sc) {
@@ -1259,6 +1259,65 @@ void ED_screen_set(bContext *C, bScreen *sc)
        }
 }
 
+/* only call outside of area/region loops */
+void ED_screen_set_scene(bContext *C, Scene *scene)
+{
+       bScreen *sc;
+       bScreen *curscreen= CTX_wm_screen(C);
+       
+       for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) {
+               if((U.flag & USER_SCENEGLOBAL) || sc==curscreen) {
+                       
+                       if(scene != sc->scene) {
+                               /* all areas endlocalview */
+                       // XXX  ScrArea *sa= sc->areabase.first;
+                       //      while(sa) {
+                       //              endlocalview(sa);
+                       //              sa= sa->next;
+                       //      }               
+                               sc->scene= scene;
+                       }
+                       
+               }
+       }
+       
+       //  copy_view3d_lock(0);        /* space.c */
+       
+       /* are there cameras in the views that are not in the scene? */
+       for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) {
+               if( (U.flag & USER_SCENEGLOBAL) || sc==curscreen) {
+                       ScrArea *sa= sc->areabase.first;
+                       while(sa) {
+                               SpaceLink *sl= sa->spacedata.first;
+                               while(sl) {
+                                       if(sl->spacetype==SPACE_VIEW3D) {
+                                               View3D *v3d= (View3D*) sl;
+                                               if (!v3d->camera || !object_in_scene(v3d->camera, scene)) {
+                                                       v3d->camera= scene_find_camera(sc->scene);
+                                                       // XXX if (sc==curscreen) handle_view3d_lock();
+                                                       if (!v3d->camera && v3d->persp==V3D_CAMOB) 
+                                                               v3d->persp= V3D_PERSP;
+                                               }
+                                       }
+                                       sl= sl->next;
+                               }
+                               sa= sa->next;
+                       }
+               }
+       }
+       
+       CTX_data_scene_set(C, scene);
+       set_scene_bg(scene);
+       
+       ED_update_for_newframe(C, 1);
+       
+//     set_radglobal();
+       
+       /* complete redraw */
+       WM_event_add_notifier(C, NC_WINDOW, NULL);
+       
+}
+
 /* this function toggles: if area is full then the parent will be restored */
 void ed_screen_fullarea(bContext *C, ScrArea *sa)
 {
@@ -1305,7 +1364,7 @@ void ed_screen_fullarea(bContext *C, ScrArea *sa)
                        ED_screen_set(C, sc);
                        
                        free_screen(oldscreen);
-                       free_libblock(&G.main->screen, oldscreen);
+                       free_libblock(&CTX_data_main(C)->screen, oldscreen);
                }
        }
        else {
@@ -1348,13 +1407,18 @@ void ed_screen_fullarea(bContext *C, ScrArea *sa)
 
 }
 
-void ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
+int ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
 {
+       if(sa==NULL)
+               return 0;
+       
        if(sa->full==0)
                ed_screen_fullarea(C, sa);
 
        /* CTX_wm_area(C) is new area */
        ED_area_newspace(C, CTX_wm_area(C), type);
+       
+       return 1;
 }
 
 void ED_screen_full_prevspace(bContext *C)
@@ -1427,7 +1491,7 @@ void ED_update_for_newframe(const bContext *C, int mute)
        /* update animated texture nodes */
        {
                Tex *tex;
-               for(tex= G.main->tex.first; tex; tex= tex->id.next)
+               for(tex= CTX_data_main(C)->tex.first; tex; tex= tex->id.next)
                        if( tex->use_nodes && tex->nodetree ) {
                                ntreeTexTagAnimated( tex->nodetree );
                        }
index 130d5d6ca76a31bfc6e255ddd97e62498a09b600..160d5ccd9d8627f3aa7a0215a9c5f8b3275432eb 100644 (file)
@@ -1025,11 +1025,12 @@ void SCREEN_OT_frame_offset(wmOperatorType *ot)
 static int screen_set_exec(bContext *C, wmOperator *op)
 {
        bScreen *screen= CTX_wm_screen(C);
+       ScrArea *sa= CTX_wm_area(C);
        int tot= BLI_countlist(&CTX_data_main(C)->screen);
        int delta= RNA_int_get(op->ptr, "delta");
        
        /* this screen is 'fake', solve later XXX */
-       if(CTX_wm_area(C)->full)
+       if(sa && sa->full)
                return OPERATOR_CANCELLED;
        
        if(delta==1) {
@@ -1088,7 +1089,7 @@ void SCREEN_OT_screen_full_area(wmOperatorType *ot)
        ot->idname = "SCREEN_OT_screen_full_area";
        
        ot->exec= screen_full_area_exec;
-       ot->poll= ED_operator_screenactive;
+       ot->poll= ED_operator_areaactive;
        ot->flag= OPTYPE_REGISTER;
 
 }
@@ -1361,7 +1362,7 @@ void SCREEN_OT_area_join(wmOperatorType *ot)
        ot->invoke= area_join_invoke;
        ot->modal= area_join_modal;
 
-       ot->poll= ED_operator_screenactive;
+       ot->poll= ED_operator_areaactive;
 
        /* rna */
        RNA_def_int(ot->srna, "x1", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX);
index 096374a82c485b4cd4fb6b3e05713eed3bf040b7..4b750600583c81c4f6e3032a3e19b550f04eac3e 100644 (file)
@@ -135,7 +135,8 @@ static void scene_idpoin_handle(bContext *C, ID *id, int event)
        
        switch(event) {
                case UI_ID_BROWSE:
-                       WM_event_add_notifier(C, NC_SCREEN|ND_SCENEBROWSE, CTX_wm_screen(C));
+                       /* exception: can't set screens inside of area/region handers */
+                       WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, id);
                        break;
                case UI_ID_DELETE:
                        ED_undo_push(C, "");
index 5e54a57f48dc339a4651b4e8a0a72da15cba8169..dce23eb103f1624daf1d8948af34732c61da5b64 100644 (file)
 
 #include "ED_armature.h"
 #include "ED_object.h"
+#include "ED_screen.h"
 
 #include "outliner_intern.h"
 
 static void allqueue() {}
 static void BIF_undo_push() {}
 static void BIF_preview_changed() {}
-static void set_scene() {}
 static void error() {}
 static int pupmenu() {return 0;}
 
@@ -1665,8 +1665,7 @@ static void tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops
        
        sce= (Scene *)outliner_search_back(soops, te, ID_SCE);
        if(sce && scene != sce) {
-// XXX         if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
-               set_scene(sce);
+               ED_screen_set_scene(C, sce);
        }
        
        /* find associated base in current scene */
@@ -1845,8 +1844,7 @@ static int tree_element_active_world(Scene *scene, SpaceOops *soops, TreeElement
        
        if(set) {       // make new scene active
                if(sce && scene != sce) {
-// XXX                 if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
-                       set_scene(sce);
+                       // XXX ED_screen_set_scene(C, sce);
                }
        }
        
@@ -2188,8 +2186,7 @@ static int do_outliner_mouse_event(bContext *C, Scene *scene, ARegion *ar, Space
                                                /* editmode? */
                                                if(te->idcode==ID_SCE) {
                                                        if(scene!=(Scene *)tselem->id) {
-// XXX                                                         if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
-                                                               set_scene((Scene *)tselem->id);
+                                                               ED_screen_set_scene(C, (Scene *)tselem->id);
                                                        }
                                                }
                                                else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) {
@@ -2853,7 +2850,7 @@ static void outliner_do_object_operation(Scene *scene, SpaceOops *soops, ListBas
                                // when objects selected in other scenes... dunno if that should be allowed
                                Scene *sce= (Scene *)outliner_search_back(soops, te, ID_SCE);
                                if(sce && scene != sce) {
-                                       set_scene(sce);
+// XXX                                 ED_screen_set_scene(C, sce);
                                }
                                
                                operation_cb(te, NULL, tselem);
@@ -2974,7 +2971,7 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
                                Scene *sce= scene;      // to be able to delete, scenes are set...
                                outliner_do_object_operation(scene, soops, &soops->tree, object_select_cb);
                                if(scene != sce) {
-                                       set_scene(sce);
+// XXX                                 ED_screen_set_scene(C, sce);
                                }
                                
                                str= "Select Objects";
index dd101231b4989f21f64d855e8ccb37bbccc0ce40..85edf6cf5fb45197dfa220e68f1b82411a9a5f16 100644 (file)
@@ -4906,10 +4906,18 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
 
        }
 
+       /* bad exception, solve this! otherwise outline shows too late */
+       if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
+               cu= ob->data;
+               /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
+               if (cu->disp.first==NULL) makeDispListCurveTypes(scene, ob, 0);
+       }
+       
        /* draw outline for selected solid objects, mesh does itself */
        if((v3d->flag & V3D_SELECT_OUTLINE) && ob->type!=OB_MESH) {
                if(dt>OB_WIRE && dt<OB_TEXTURE && ob!=scene->obedit && (flag && DRAW_SCENESET)==0) {
                        if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT) && !(flag&DRAW_PICKING)) {
+                               
                                drawSolidSelect(scene, v3d, rv3d, base);
                        }
                }
@@ -4925,7 +4933,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                        break;
                case OB_FONT:
                        cu= ob->data;
-                       if (cu->disp.first==NULL) makeDispListCurveTypes(scene, ob, 0);
                        if(cu->editfont) {
                                draw_textcurs(cu->editfont->textcurs);
 
@@ -5017,8 +5024,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                case OB_CURVE:
                case OB_SURF:
                        cu= ob->data;
-                       /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
-                       if (cu->disp.first==NULL) makeDispListCurveTypes(scene, ob, 0);
 
                        if(cu->editnurb) {
                                drawnurb(scene, v3d, rv3d, base, cu->editnurb->first, dt);
index 7e209bc8693dc2e6a36a0795c83ecc986ac85181..30ef1be1dbfe72e1f0c2f20d8a69bf5fca8b4b9a 100644 (file)
@@ -542,7 +542,6 @@ static int view3d_context(const bContext *C, bContextDataMember member, bContext
        }
        else if(member == CTX_DATA_ACTIVE_PCHAN) {
                Object *obact= OBACT;
-               bArmature *arm= (obact) ? obact->data : NULL;
                bPoseChannel *pchan;
                
                pchan= get_active_posechannel(obact);
index b982c3e1f0e81db63b5e3634177367df18da38ea..780bb46ece4dd081aedd8b6bd2401c033e86927f 100644 (file)
@@ -580,10 +580,7 @@ static void view3d_view_alignviewmenu(bContext *C, uiMenuItem *head, void *arg_u
 {
        
 }
-static void view3d_view_camerasmenu(bContext *C, uiMenuItem *head, void *arg_unused)
-{
-       
-}
+
 static void view3d_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
 {
        ScrArea *sa= CTX_wm_area(C);
index def9d7351acda14581348a3f9c088d3b091ea159..dcca2fa60c992f36f85be776b3ce480dcbcc36bc 100644 (file)
@@ -32,7 +32,7 @@
 #include "DNA_listBase.h"
 #include "DNA_screen_types.h"
 #include "DNA_windowmanager_types.h"
-#include "DNA_userdef_types.h" /* U.flag & TWOBUTTONMOUSE */
+#include "DNA_userdef_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -131,7 +131,6 @@ void wm_event_do_notifiers(bContext *C)
                return;
        
        /* cache & catch WM level notifiers, such as frame change, scene/screen set */
-       /* XXX todo, multiwindow scenes */
        for(win= wm->windows.first; win; win= win->next) {
                int do_anim= 0;
                
@@ -144,7 +143,10 @@ void wm_event_do_notifiers(bContext *C)
                                                ED_screen_set(C, note->reference);      // XXX hrms, think this over!
                                }
                                else if(note->category==NC_SCENE) {
-                                       if(note->data==ND_FRAME)
+                                       if(note->data==ND_SCENEBROWSE) {
+                                               ED_screen_set_scene(C, note->reference);        // XXX hrms, think this over!
+                                       }
+                                       else if(note->data==ND_FRAME)
                                                do_anim= 1;
                                }
                        }
index b9bdabcdbfdde3b576a90bbc86942abc2fe3a8a8..c54d738822f6af3c643d951969b36dbcf3ba576a 100644 (file)
@@ -357,7 +357,8 @@ static int wm_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        SpaceFile *sfile;
        
-       ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_FILE);
+       if(0==ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_FILE))
+               return OPERATOR_CANCELLED;
 
        /* settings for filebrowser */
        sfile= (SpaceFile*)CTX_wm_space_data(C);