Tag depsgraph update when hide and hide_select are changed
We were not updating depsgraph when collection just "became" selectable, but although this doesn't change object selection, it change its selectability.
This commit is contained in:
@@ -245,10 +245,9 @@ static void restrictbutton_gp_layer_flag_cb(bContext *C, void *UNUSED(poin), voi
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
|
||||
}
|
||||
|
||||
static void restrictbutton_collection_hide_cb(bContext *C, void *poin, void *UNUSED(poin2))
|
||||
static void restrictbutton_collection_flag_cb(bContext *C, void *poin, void *UNUSED(poin2))
|
||||
{
|
||||
Scene *scene = poin;
|
||||
|
||||
/* hide and deselect bases that are directly influenced by this LayerCollection */
|
||||
/* TODO(sergey): Use proper flag for tagging here. */
|
||||
DAG_id_tag_update(&scene->id, 0);
|
||||
@@ -256,20 +255,6 @@ static void restrictbutton_collection_hide_cb(bContext *C, void *poin, void *UNU
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL);
|
||||
}
|
||||
|
||||
static void restrictbutton_collection_hide_select_cb(bContext *C, void *poin, void *poin2)
|
||||
{
|
||||
Scene *scene = poin;
|
||||
LayerCollection *collection = poin2;
|
||||
|
||||
if ((collection->flag & COLLECTION_SELECTABLE) == 0) {
|
||||
/* deselect bases that are directly influenced by this LayerCollection */
|
||||
/* TODO(sergey): Use proper flag for tagging here. */
|
||||
DAG_id_tag_update(&scene->id, 0);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
|
||||
}
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, NULL);
|
||||
}
|
||||
|
||||
static void restrictbutton_id_user_toggle(bContext *UNUSED(C), void *poin, void *UNUSED(poin2))
|
||||
{
|
||||
ID *id = (ID *)poin;
|
||||
@@ -579,14 +564,14 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
|
||||
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
|
||||
UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
|
||||
TIP_("Restrict/Allow 3D View visibility of objects in the collection"));
|
||||
UI_but_func_set(bt, restrictbutton_collection_hide_cb, scene, collection);
|
||||
UI_but_func_set(bt, restrictbutton_collection_flag_cb, scene, collection);
|
||||
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
|
||||
|
||||
bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE_N, COLLECTION_SELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
|
||||
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
|
||||
UI_UNIT_Y, &collection->flag, 0, 0, 0, 0,
|
||||
TIP_("Restrict/Allow 3D View selection of objects in the collection"));
|
||||
UI_but_func_set(bt, restrictbutton_collection_hide_select_cb, scene, collection);
|
||||
UI_but_func_set(bt, restrictbutton_collection_flag_cb, scene, collection);
|
||||
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
|
||||
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
|
@@ -2634,30 +2634,14 @@ static int rna_LayerCollection_move_into(ID *id, LayerCollection *lc_src, Main *
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void rna_LayerCollection_hide_update(bContext *C, PointerRNA *UNUSED(ptr))
|
||||
static void rna_LayerCollection_flag_update(bContext *C, PointerRNA *UNUSED(ptr))
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
/* hide and deselect bases that are directly influenced by this LayerCollection */
|
||||
/* TODO(sergey): Use proper flag for tagging here. */
|
||||
DAG_id_tag_update(&scene->id, 0);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
||||
}
|
||||
|
||||
static void rna_LayerCollection_hide_select_update(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
LayerCollection *lc = ptr->data;
|
||||
|
||||
if ((lc->flag & COLLECTION_SELECTABLE) == 0) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
/* deselect bases that are directly influenced by this LayerCollection */
|
||||
/* TODO(sergey): Use proper flag for tagging here. */
|
||||
DAG_id_tag_update(&scene->id, 0);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C));
|
||||
}
|
||||
}
|
||||
|
||||
static int rna_LayerCollections_active_collection_index_get(PointerRNA *ptr)
|
||||
{
|
||||
SceneLayer *sl = (SceneLayer *)ptr->data;
|
||||
@@ -6248,14 +6232,14 @@ static void rna_def_layer_collection(BlenderRNA *brna)
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1);
|
||||
RNA_def_property_ui_text(prop, "Hide", "Restrict visiblity");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_hide_update");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
|
||||
|
||||
prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_SELECTABLE);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 1);
|
||||
RNA_def_property_ui_text(prop, "Hide Selectable", "Restrict selection");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_hide_select_update");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_LayerCollection_flag_update");
|
||||
|
||||
/* TODO_LAYER_OVERRIDE */
|
||||
}
|
||||
|
Reference in New Issue
Block a user