Fix #23629: Layers doesn't sign there are objects on them, only if the object is selected
Also fixed layer buttons update when changing scene/screen
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user