[Bf-blender-cvs] [01bdb0c76ed] master: Support Copy To Selected and Alt-Click for F-Curves in the curve editor.

Alexander Gavrilov noreply at git.blender.org
Tue Aug 29 13:37:41 CEST 2017


Commit: 01bdb0c76edf8315e597cbb2ee82c30c1e35229f
Author: Alexander Gavrilov
Date:   Sat Aug 19 19:58:39 2017 +0300
Branches: master
https://developer.blender.org/rB01bdb0c76edf8315e597cbb2ee82c30c1e35229f

Support Copy To Selected and Alt-Click for F-Curves in the curve editor.

This affects the curve display color setting, but is really intended
for future per-curve options.

The id_data reference in the created rna pointers refers to the object
even if the curve is actually owned by its action, which is somewhat
inconsistent, but the same problem can be found in existing code.
Fixing it requires changes in animdata filter API.

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

M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/screen/screen_context.c

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

diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index fb95cdf389b..580ad025086 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -360,6 +360,9 @@ bool UI_context_copy_to_selected_list(
 	else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) {
 		*r_lb = CTX_data_collection_get(C, "selected_editable_sequences");
 	}
+	else if (RNA_struct_is_a(ptr->type, &RNA_FCurve)) {
+		*r_lb = CTX_data_collection_get(C, "selected_editable_fcurves");
+	}
 	else if (RNA_struct_is_a(ptr->type, &RNA_Node) ||
 	         RNA_struct_is_a(ptr->type, &RNA_NodeSocket))
 	{
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index c165bbfd301..293e507c2b3 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -54,6 +54,7 @@
 
 #include "ED_armature.h"
 #include "ED_gpencil.h"
+#include "ED_anim_api.h"
 
 #include "WM_api.h"
 #include "UI_interface.h"
@@ -87,7 +88,7 @@ const char *screen_context_dir[] = {
 	"visible_gpencil_layers", "editable_gpencil_layers", "editable_gpencil_strokes",
 	"active_gpencil_layer", "active_gpencil_frame", "active_gpencil_palette", 
 	"active_gpencil_palettecolor", "active_gpencil_brush",
-	"active_operator",
+	"active_operator", "selected_editable_fcurves",
 	NULL};
 
 int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
@@ -608,6 +609,30 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
 			return 1;
 		}
 	}
+	else if (CTX_data_equals(member, "selected_editable_fcurves"))
+	{
+		bAnimContext ac;
+
+		if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_IPO)) {
+			bAnimListElem *ale;
+			ListBase anim_data = {NULL, NULL};
+
+			int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS | ANIMFILTER_SEL) |
+			             (ac.spacetype == SPACE_IPO ? ANIMFILTER_CURVE_VISIBLE : ANIMFILTER_LIST_VISIBLE);
+
+			ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+			for (ale = anim_data.first; ale; ale = ale->next) {
+				if (ale->type == ANIMTYPE_FCURVE)
+					CTX_data_list_add(result, ale->id, &RNA_FCurve, ale->data);
+			}
+
+			ANIM_animdata_freelist(&anim_data);
+
+			CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+			return 1;
+		}
+	}
 	else {
 		return 0; /* not found */
 	}



More information about the Bf-blender-cvs mailing list