Fix #23629: Layers doesn't sign there are objects on them, only if the object is...
authorSergey Sharybin <sergey.vfx@gmail.com>
Sat, 2 Oct 2010 09:28:41 +0000 (09:28 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sat, 2 Oct 2010 09:28:41 +0000 (09:28 +0000)
Also fixed layer buttons update when changing scene/screen

source/blender/editors/screen/screen_edit.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/windowmanager/WM_types.h

index 05b6e072eacae24626a7e8afe06678206bd4fac8..32e82571609051d0200825ee89405176665c6563 100644 (file)
@@ -1312,6 +1312,7 @@ void ED_screen_set(bContext *C, bScreen *sc)
                
                ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C));
                WM_event_add_notifier(C, NC_WINDOW, NULL);
+               WM_event_add_notifier(C, NC_SCREEN|ND_SCREENSET, sc);
                
                /* makes button hilites work */
                WM_event_add_mousemove(C);
index a49ada8a4c9b853fc232ac74b3aa7d3109d7faed..4c9d8f88dd190da1dcd4d6ace6a9216bedd1ebd6 100644 (file)
@@ -529,30 +529,30 @@ static void *view3d_main_area_duplicate(void *poin)
        return NULL;
 }
 
-static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn)
+static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn, Scene *scene)
 {
        wmWindow *win= wmn->wm->winactive;
        ScrArea *sa;
+       int lay_used= 0;
+       Base *base;
 
        if (!win) return;
 
-       sa= win->screen->areabase.first;
+       base= scene->base.first;
+       while(base) {
+               lay_used|= base->lay;
+
+               if (lay_used & (1<<20-1)) break;
+
+               base= base->next;
+       }
 
+       sa= win->screen->areabase.first;
        while(sa) {
                if(sa->spacetype == SPACE_VIEW3D)
                        if(BLI_findindex(&sa->regionbase, ar) >= 0) {
                                View3D *v3d= sa->spacedata.first;
-                               Scene *scene= wmn->reference;
-                               Base *base;
-
-                               v3d->lay_used= 0;
-                               base= scene->base.first;
-                               while(base) {
-                                       v3d->lay_used|= base->lay;
-
-                                       base= base->next;
-                               }
-
+                               v3d->lay_used= lay_used;
                                break;
                        }
 
@@ -562,6 +562,8 @@ static void view3d_recalc_used_layers(ARegion *ar, wmNotifier *wmn)
 
 static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
 {
+       bScreen *sc;
+
        /* context changes */
        switch(wmn->category) {
                case NC_ANIMATION:
@@ -584,7 +586,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                case NC_SCENE:
                        switch(wmn->data) {
                                case ND_LAYER_CONTENT:
-                                       view3d_recalc_used_layers(ar, wmn);
+                                       view3d_recalc_used_layers(ar, wmn, wmn->reference);
                                        ED_region_tag_redraw(ar);
                                        break;
                                case ND_FRAME:
@@ -681,10 +683,22 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                                ED_region_tag_redraw(ar);
                        break;
                case NC_SCREEN:
-                       if(wmn->data == ND_GPENCIL)     
-                               ED_region_tag_redraw(ar);
-                       else if(wmn->data==ND_ANIMPLAY)
-                               ED_region_tag_redraw(ar);
+                       switch(wmn->data) {
+                               case ND_GPENCIL:
+                               case ND_ANIMPLAY:
+                                       ED_region_tag_redraw(ar);
+                                       break;
+                               case ND_SCREENBROWSE:
+                               case ND_SCREENDELETE:
+                               case ND_SCREENSET:
+                                       /* screen was changed, need to update used layers due to NC_SCENE|ND_LAYER_CONTENT */
+                                       /* updates used layers only for View3D in active screen */
+                                       sc= wmn->reference;
+                                       view3d_recalc_used_layers(ar, wmn, sc->scene);
+                                       ED_region_tag_redraw(ar);
+                                       break;
+                       }
+
                        break;
        }
 }
index 2054761bd43cbd793645fed09f0787f150166bc5..871057801f80f8cc777a15ed5bce955d9450b780 100644 (file)
@@ -2260,7 +2260,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
        Base *base;
        Object *ob;
        float backcol[3];
-       int retopo= 0, sculptparticle= 0;
+       int retopo= 0, sculptparticle= 0, lay_used= 0;
        Object *obact = OBACT;
        char *grid_unit= NULL;
 
@@ -2363,8 +2363,12 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
                /* Transp and X-ray afterdraw stuff for sets is done later */
        }
 
+       lay_used= 0;
+
        /* then draw not selected and the duplis, but skip editmode object */
        for(base= scene->base.first; base; base= base->next) {
+               lay_used |= base->lay;
+
                if(v3d->lay & base->lay) {
                        
                        /* dupli drawing */
@@ -2378,6 +2382,20 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
                }
        }
 
+       if(v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */
+               ARegion *ar;
+               ScrArea *sa= CTX_wm_area(C);
+
+               /* find header and force tag redraw */
+               for(ar= sa->regionbase.first; ar; ar= ar->next)
+                       if(ar->regiontype==RGN_TYPE_HEADER) {
+                               ED_region_tag_redraw(ar);
+                               break;
+                       }
+
+               v3d->lay_used= lay_used;
+       }
+
 //     retopo= retopo_mesh_check() || retopo_curve_check();
        sculptparticle= (obact && obact->mode & (OB_MODE_PARTICLE_EDIT)) && !scene->obedit;
        if(retopo)
index 9b18a2cd9babd67f6d76cbdff51ddc9e93ac3eeb..73f1fe8cbd39a99ad45051fe8d4fe959601038d9 100644 (file)
@@ -167,6 +167,7 @@ typedef struct wmNotifier {
 #define ND_ANIMPLAY                    (4<<16)
 #define ND_GPENCIL                     (5<<16)
 #define ND_EDITOR_CHANGED      (6<<16) /*sent to new editors after switching to them*/
+#define ND_SCREENSET           (7<<16)
 
        /* NC_SCENE Scene */
 #define ND_SCENEBROWSE         (1<<16)