[Bf-blender-cvs] [c7e5493b15f] soc-2020-outliner: Outliner: Properties sync with pinned data

Nathan Craddock noreply at git.blender.org
Sat Jun 20 22:43:01 CEST 2020


Commit: c7e5493b15f34d32f904b5d007ebee3d0870b4b2
Author: Nathan Craddock
Date:   Sat Jun 20 14:40:42 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rBc7e5493b15f34d32f904b5d007ebee3d0870b4b2

Outliner: Properties sync with pinned data

Previously only the type of tab/context was passed to the properties
editor from the outliner. This caused some issues. If Object A was
pinned, and Object B's mesh data was clicked, it would switch to Object
A's mesh data.

Now pass an RNA pointer along to verify if the outliner data is in the
valid path when the properties editor is pinned.

Also support Hair and PointCloud new object types.

===================================================================

M	source/blender/editors/include/ED_buttons.h
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_outliner/outliner_select.c

===================================================================

diff --git a/source/blender/editors/include/ED_buttons.h b/source/blender/editors/include/ED_buttons.h
index 18e137603da..268c05fe29e 100644
--- a/source/blender/editors/include/ED_buttons.h
+++ b/source/blender/editors/include/ED_buttons.h
@@ -29,7 +29,7 @@ extern "C" {
 
 struct bContext;
 
-void ED_buttons_set_context(const struct bContext *C, const short context);
+void ED_buttons_set_context(const struct bContext *C, PointerRNA *ptr, const short context);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index a29c28382d4..1be10f27f3f 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -760,14 +760,19 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts)
   sbuts->pathflag = flag;
 }
 
-void ED_buttons_set_context(const bContext *C, const short context)
+static bool is_pointer_in_path(ButsContextPath *path, PointerRNA *ptr)
 {
-  bScreen *screen = CTX_wm_screen(C);
-  Object *obact = CTX_data_active_object(C);
-  ID *active_id;
-  if (obact) {
-    active_id = &obact->id;
+  for (int i = 0; i < path->len; ++i) {
+    if (ptr->owner_id == path->ptr[i].owner_id) {
+      return true;
+    }
   }
+  return false;
+}
+
+void ED_buttons_set_context(const bContext *C, PointerRNA *ptr, const short context)
+{
+  bScreen *screen = CTX_wm_screen(C);
 
   LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
     /* Only update for properties editors that are visible */
@@ -778,8 +783,10 @@ void ED_buttons_set_context(const bContext *C, const short context)
 
       ButsContextPath path;
       if (buttons_context_path(C, sbuts, &path, context, 0)) {
-        sbuts->mainbuser = context;
-        sbuts->mainb = sbuts->mainbuser;
+        if (is_pointer_in_path(&path, ptr)) {
+          sbuts->mainbuser = context;
+          sbuts->mainb = sbuts->mainbuser;
+        }
       }
     }
   }
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index df61f87f271..a9a65989c19 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -46,6 +46,7 @@
 #include "BKE_main.h"
 #include "BKE_object.h"
 #include "BKE_paint.h"
+#include "BKE_particle.h"
 #include "BKE_scene.h"
 #include "BKE_sequencer.h"
 #include "BKE_workspace.h"
@@ -1137,14 +1138,18 @@ eOLDrawState tree_element_type_active(bContext *C,
 
 static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreElem *tselem)
 {
+  PointerRNA ptr;
+
   /* ID Types */
   if (tselem->type == 0) {
+    RNA_id_pointer_create(tselem->id, &ptr);
+
     switch (te->idcode) {
       case ID_SCE:
-        ED_buttons_set_context(C, BCONTEXT_SCENE);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_SCENE);
         break;
       case ID_OB:
-        ED_buttons_set_context(C, BCONTEXT_OBJECT);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_OBJECT);
         break;
       case ID_ME:
       case ID_CU:
@@ -1158,14 +1163,16 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE
       case ID_AR:
       case ID_GD:
       case ID_LP:
+      case ID_HA:
+      case ID_PT:
       case ID_VO:
-        ED_buttons_set_context(C, BCONTEXT_DATA);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_DATA);
         break;
       case ID_MA:
-        ED_buttons_set_context(C, BCONTEXT_MATERIAL);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_MATERIAL);
         break;
       case ID_WO:
-        ED_buttons_set_context(C, BCONTEXT_WORLD);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_WORLD);
         break;
     }
   }
@@ -1173,10 +1180,12 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE
     switch (tselem->type) {
       case TSE_DEFGROUP_BASE:
       case TSE_DEFGROUP:
-        ED_buttons_set_context(C, BCONTEXT_DATA);
+        RNA_id_pointer_create(tselem->id, &ptr);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_DATA);
         break;
       case TSE_CONSTRAINT_BASE:
       case TSE_CONSTRAINT: {
+        RNA_id_pointer_create(tselem->id, &ptr);
         bool is_bone_constraint = false;
 
         /* Check if parent is a bone */
@@ -1184,44 +1193,88 @@ static void outliner_set_properties_tab(bContext *C, TreeElement *te, TreeStoreE
         while (te) {
           tselem = TREESTORE(te);
           if (tselem->type == TSE_POSE_CHANNEL) {
+            bPoseChannel *pchan = (bPoseChannel *)te->directdata;
+            RNA_pointer_create(tselem->id, &RNA_PoseBone, pchan, &ptr);
+
             is_bone_constraint = true;
             break;
           }
           te = te->parent;
         }
         if (is_bone_constraint) {
-          ED_buttons_set_context(C, BCONTEXT_BONE_CONSTRAINT);
+          ED_buttons_set_context(C, &ptr, BCONTEXT_BONE_CONSTRAINT);
         }
         else {
-          ED_buttons_set_context(C, BCONTEXT_CONSTRAINT);
+          ED_buttons_set_context(C, &ptr, BCONTEXT_CONSTRAINT);
         }
         break;
       }
       case TSE_MODIFIER_BASE:
       case TSE_MODIFIER:
-        ED_buttons_set_context(C, BCONTEXT_MODIFIER);
+        RNA_id_pointer_create(tselem->id, &ptr);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_MODIFIER);
+        break;
+      case TSE_BONE: {
+        bArmature *arm = (bArmature *)tselem->id;
+        Bone *bone = te->directdata;
+
+        RNA_pointer_create(&arm->id, &RNA_Bone, bone, &ptr);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_BONE);
         break;
-      case TSE_BONE:
-      case TSE_EBONE:
-      case TSE_POSE_CHANNEL:
-        ED_buttons_set_context(C, BCONTEXT_BONE);
+      }
+      case TSE_EBONE: {
+        bArmature *arm = (bArmature *)tselem->id;
+        EditBone *ebone = te->directdata;
+
+        RNA_pointer_create(&arm->id, &RNA_EditBone, ebone, &ptr);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_BONE);
         break;
-      case TSE_POSE_BASE:
-        ED_buttons_set_context(C, BCONTEXT_DATA);
+      }
+      case TSE_POSE_CHANNEL: {
+        Object *ob = (Object *)tselem->id;
+        bArmature *arm = ob->data;
+        bPoseChannel *pchan = te->directdata;
+
+        RNA_pointer_create(&arm->id, &RNA_PoseBone, pchan, &ptr);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_BONE);
         break;
+      }
+      case TSE_POSE_BASE: {
+        Object *ob = (Object *)tselem->id;
+        bArmature *arm = ob->data;
+
+        RNA_pointer_create(&arm->id, &RNA_Armature, arm, &ptr);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_DATA);
+        break;
+      }
       case TSE_R_LAYER_BASE:
-      case TSE_R_LAYER:
-        ED_buttons_set_context(C, BCONTEXT_VIEW_LAYER);
+      case TSE_R_LAYER: {
+        ViewLayer *view_layer = te->directdata;
+
+        RNA_pointer_create(tselem->id, &RNA_ViewLayer, view_layer, &ptr);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_VIEW_LAYER);
         break;
+      }
       case TSE_POSEGRP_BASE:
-      case TSE_POSEGRP:
-        ED_buttons_set_context(C, BCONTEXT_DATA);
+      case TSE_POSEGRP: {
+        Object *ob = (Object *)tselem->id;
+        bArmature *arm = ob->data;
+
+        RNA_pointer_create(&arm->id, &RNA_Armature, arm, &ptr);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_DATA);
         break;
-      case TSE_LINKED_PSYS:
-        ED_buttons_set_context(C, BCONTEXT_PARTICLE);
+      }
+      case TSE_LINKED_PSYS: {
+        Object *ob = (Object *)tselem->id;
+        ParticleSystem *psys = psys_get_current(ob);
+
+        RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &ptr);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_PARTICLE);
         break;
+      }
       case TSE_GP_LAYER:
-        ED_buttons_set_context(C, BCONTEXT_DATA);
+        RNA_id_pointer_create(tselem->id, &ptr);
+        ED_buttons_set_context(C, &ptr, BCONTEXT_DATA);
         break;
     }
   }



More information about the Bf-blender-cvs mailing list