From 9d65214d5b9f72899553456201d2e345eeaf91bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 8 Sep 2023 15:15:34 +0200 Subject: [PATCH] Anim: add notifier `ND_BONE_COLLECTION` for bone collection changes Send nodifier `NC_OBJECT | ND_BONE_COLLECTION` on bone collection changes. --- source/blender/editors/armature/bone_collections.cc | 9 ++------- source/blender/editors/space_action/space_action.cc | 1 + source/blender/editors/space_buttons/space_buttons.cc | 1 + source/blender/editors/space_outliner/space_outliner.cc | 1 + source/blender/editors/space_view3d/space_view3d.cc | 2 ++ source/blender/makesrna/intern/rna_armature.cc | 6 +++--- source/blender/windowmanager/WM_types.hh | 1 + 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/armature/bone_collections.cc b/source/blender/editors/armature/bone_collections.cc index 763bdf510a9..4ccbd0275d1 100644 --- a/source/blender/editors/armature/bone_collections.cc +++ b/source/blender/editors/armature/bone_collections.cc @@ -272,7 +272,7 @@ static void bone_collection_assign_editbones(bContext *C, } ED_armature_edit_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_COLLECTION, ob); DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); } @@ -489,12 +489,7 @@ static void bone_collection_select(bContext *C, } DEG_id_tag_update(&armature->id, ID_RECALC_SELECT); - if (is_editmode) { - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - } - else { - WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - } + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_COLLECTION, ob); if (is_editmode) { ED_outliner_select_sync_from_edit_bone_tag(C); diff --git a/source/blender/editors/space_action/space_action.cc b/source/blender/editors/space_action/space_action.cc index f48d597f524..1b554ba081d 100644 --- a/source/blender/editors/space_action/space_action.cc +++ b/source/blender/editors/space_action/space_action.cc @@ -428,6 +428,7 @@ static void action_main_region_listener(const wmRegionListenerParams *params) break; case ND_BONE_ACTIVE: case ND_BONE_SELECT: + case ND_BONE_COLLECTION: case ND_KEYS: ED_region_tag_redraw(region); break; diff --git a/source/blender/editors/space_buttons/space_buttons.cc b/source/blender/editors/space_buttons/space_buttons.cc index bbf7de3b968..f28f29cf7c1 100644 --- a/source/blender/editors/space_buttons/space_buttons.cc +++ b/source/blender/editors/space_buttons/space_buttons.cc @@ -694,6 +694,7 @@ static void buttons_area_listener(const wmSpaceTypeListenerParams *params) case ND_POSE: case ND_BONE_ACTIVE: case ND_BONE_SELECT: + case ND_BONE_COLLECTION: buttons_area_redraw(area, BCONTEXT_BONE); buttons_area_redraw(area, BCONTEXT_BONE_CONSTRAINT); buttons_area_redraw(area, BCONTEXT_DATA); diff --git a/source/blender/editors/space_outliner/space_outliner.cc b/source/blender/editors/space_outliner/space_outliner.cc index 52cbcba093a..5a4acd66ba3 100644 --- a/source/blender/editors/space_outliner/space_outliner.cc +++ b/source/blender/editors/space_outliner/space_outliner.cc @@ -156,6 +156,7 @@ static void outliner_main_region_listener(const wmRegionListenerParams *params) break; case ND_BONE_ACTIVE: case ND_BONE_SELECT: + case ND_BONE_COLLECTION: case ND_DRAW: case ND_PARENT: case ND_OB_SHADING: diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index 15822ac0361..fbe70beded6 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -1227,6 +1227,7 @@ static void view3d_main_region_listener(const wmRegionListenerParams *params) switch (wmn->data) { case ND_BONE_ACTIVE: case ND_BONE_SELECT: + case ND_BONE_COLLECTION: case ND_TRANSFORM: case ND_POSE: case ND_DRAW: @@ -1847,6 +1848,7 @@ static void view3d_buttons_region_listener(const wmRegionListenerParams *params) switch (wmn->data) { case ND_BONE_ACTIVE: case ND_BONE_SELECT: + case ND_BONE_COLLECTION: case ND_TRANSFORM: case ND_POSE: case ND_DRAW: diff --git a/source/blender/makesrna/intern/rna_armature.cc b/source/blender/makesrna/intern/rna_armature.cc index 2920e5fd515..70ad058e595 100644 --- a/source/blender/makesrna/intern/rna_armature.cc +++ b/source/blender/makesrna/intern/rna_armature.cc @@ -196,7 +196,7 @@ static void rna_BoneCollections_active_index_set(PointerRNA *ptr, const int bone bArmature *arm = (bArmature *)ptr->data; ANIM_armature_bonecoll_active_index_set(arm, bone_collection_index); - // TODO: send notifiers? + WM_main_add_notifier(NC_OBJECT | ND_BONE_COLLECTION, ptr->data); } static void rna_BoneCollections_active_index_range( @@ -219,7 +219,7 @@ static void rna_BoneCollections_move(bArmature *arm, ReportList *reports, int fr BKE_reportf(reports, RPT_ERROR, "Cannot move collection from index '%d' to '%d'", from, to); } - // TODO: notifiers. + WM_main_add_notifier(NC_OBJECT | ND_BONE_COLLECTION, &arm->id); } static void rna_BoneCollection_name_set(PointerRNA *ptr, const char *name) @@ -228,7 +228,7 @@ static void rna_BoneCollection_name_set(PointerRNA *ptr, const char *name) BoneCollection *bcoll = (BoneCollection *)ptr->data; ANIM_armature_bonecoll_name_set(arm, bcoll, name); - // TODO: notifiers. + WM_main_add_notifier(NC_OBJECT | ND_BONE_COLLECTION, &arm->id); } static char *rna_BoneCollection_path(const PointerRNA *ptr) diff --git a/source/blender/windowmanager/WM_types.hh b/source/blender/windowmanager/WM_types.hh index 623f6ddc165..d693d88ce26 100644 --- a/source/blender/windowmanager/WM_types.hh +++ b/source/blender/windowmanager/WM_types.hh @@ -429,6 +429,7 @@ struct wmNotifier { #define ND_SHADERFX (32 << 16) /* For updating motion paths in 3dview. */ #define ND_DRAW_ANIMVIZ (33 << 16) +#define ND_BONE_COLLECTION (34 << 16) /* NC_MATERIAL Material */ #define ND_SHADING (30 << 16)