[Bf-blender-cvs] [26e8798] master: FModifiers: Various tweaks for consistency + improved behaviour

Joshua Leung noreply at git.blender.org
Fri Apr 15 10:19:29 CEST 2016


Commit: 26e8798561a7b9180ab1c6f220a3d85baec30012
Author: Joshua Leung
Date:   Sat Apr 9 18:05:22 2016 +1200
Branches: master
https://developer.blender.org/rB26e8798561a7b9180ab1c6f220a3d85baec30012

FModifiers: Various tweaks for consistency + improved behaviour

* Use an RNA enum callback for NLA FModifier types too
* Cleaned up tooltips for these operators in Graph and NLA editors
* Fix update notifiers after adding FModifiers in the Graph Editor

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

M	source/blender/editors/space_graph/graph_edit.c
M	source/blender/editors/space_nla/nla_edit.c

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

diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 4ebb9ce..5854cb5 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2374,27 +2374,27 @@ static EnumPropertyItem *graph_fmodifier_itemf(bContext *C, PointerRNA *UNUSED(p
 	EnumPropertyItem *item = NULL;
 	int totitem = 0;
 	int i = 0;
-
+	
 	if (C == NULL) {
 		return rna_enum_fmodifier_type_items;
 	}
-
+	
 	/* start from 1 to skip the 'Invalid' modifier type */
 	for (i = 1; i < FMODIFIER_NUM_TYPES; i++) {
 		const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i);
 		int index;
-
+		
 		/* check if modifier is valid for this context */
 		if (fmi == NULL)
 			continue;
-
+		
 		index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type);
 		RNA_enum_item_add(&item, &totitem, &rna_enum_fmodifier_type_items[index]);
 	}
-
+	
 	RNA_enum_item_end(&item, &totitem);
 	*r_free = true;
-
+	
 	return item;
 }
 
@@ -2435,16 +2435,15 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
 			BKE_report(op->reports, RPT_ERROR, "Modifier could not be added (see console for details)");
 			break;
 		}
-
+		
 		ale->update |= ANIM_UPDATE_DEPS;
 	}
-
+	
 	ANIM_animdata_update(&ac, &anim_data);
 	ANIM_animdata_freelist(&anim_data);
 	
 	/* set notifier that things have changed */
-	// FIXME: this really isn't the best description for it...
-	WM_event_add_notifier(C, NC_ANIMATION, NULL);
+	WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
 	
 	return OPERATOR_FINISHED;
 }
@@ -2452,11 +2451,11 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
 void GRAPH_OT_fmodifier_add(wmOperatorType *ot)
 {
 	PropertyRNA *prop;
-
+	
 	/* identifiers */
 	ot->name = "Add F-Curve Modifier";
 	ot->idname = "GRAPH_OT_fmodifier_add";
-	ot->description = "Add F-Modifiers to the selected F-Curves";
+	ot->description = "Add F-Modifier to the active/selected F-Curves";
 	
 	/* api callbacks */
 	ot->invoke = WM_menu_invoke;
@@ -2470,7 +2469,7 @@ void GRAPH_OT_fmodifier_add(wmOperatorType *ot)
 	prop = RNA_def_enum(ot->srna, "type", rna_enum_fmodifier_type_items, 0, "Type", "");
 	RNA_def_enum_funcs(prop, graph_fmodifier_itemf);
 	ot->prop = prop;
-
+	
 	RNA_def_boolean(ot->srna, "only_active", 1, "Only Active", "Only add F-Modifier to active F-Curve");
 }
 
@@ -2495,10 +2494,10 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op)
 	/* if this exists, call the copy F-Modifiers API function */
 	if (ale && ale->data) {
 		FCurve *fcu = (FCurve *)ale->data;
-
+		
 		/* TODO: when 'active' vs 'all' boolean is added, change last param! */
 		ok = ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0);
-
+		
 		/* free temp data now */
 		MEM_freeN(ale);
 	}
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index fd772aa..2892e8d 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -2213,19 +2213,20 @@ void NLA_OT_snap(wmOperatorType *ot)
 
 /* ******************** Add F-Modifier Operator *********************** */
 
-/* present a special customised popup menu for this, with some filtering */
-static int nla_fmodifier_add_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
+static EnumPropertyItem *nla_fmodifier_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
 {
-	uiPopupMenu *pup;
-	uiLayout *layout;
-	int i;
+	EnumPropertyItem *item = NULL;
+	int totitem = 0;
+	int i = 0;
 	
-	pup = UI_popup_menu_begin(C, IFACE_("Add F-Modifier"), ICON_NONE);
-	layout = UI_popup_menu_layout(pup);
+	if (C == NULL) {
+		return rna_enum_fmodifier_type_items;
+	}
 	
 	/* start from 1 to skip the 'Invalid' modifier type */
 	for (i = 1; i < FMODIFIER_NUM_TYPES; i++) {
 		const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i);
+		int index;
 		
 		/* check if modifier is valid for this context */
 		if (fmi == NULL)
@@ -2233,16 +2234,17 @@ static int nla_fmodifier_add_invoke(bContext *C, wmOperator *UNUSED(op), const w
 		if (i == FMODIFIER_TYPE_CYCLES) /* we already have repeat... */
 			continue;
 		
-		/* add entry to add this type of modifier */
-		uiItemEnumO(layout, "NLA_OT_fmodifier_add", fmi->name, 0, "type", i);
+		index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type);
+		RNA_enum_item_add(&item, &totitem, &rna_enum_fmodifier_type_items[index]);
 	}
-	uiItemS(layout);
 	
-	UI_popup_menu_end(C, pup);
+	RNA_enum_item_end(&item, &totitem);
+	*r_free = true;
 	
-	return OPERATOR_INTERFACE;
+	return item;
 }
 
+
 static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
 {
 	bAnimContext ac;
@@ -2316,10 +2318,10 @@ void NLA_OT_fmodifier_add(wmOperatorType *ot)
 	/* identifiers */
 	ot->name = "Add F-Modifier";
 	ot->idname = "NLA_OT_fmodifier_add";
-	ot->description = "Add a F-Modifier of the specified type to the selected NLA-Strips";
+	ot->description = "Add F-Modifier to the active/selected NLA-Strips";
 	
 	/* api callbacks */
-	ot->invoke = nla_fmodifier_add_invoke;
+	ot->invoke = WM_menu_invoke;
 	ot->exec = nla_fmodifier_add_exec;
 	ot->poll = nlaop_poll_tweakmode_off; 
 	
@@ -2328,7 +2330,9 @@ void NLA_OT_fmodifier_add(wmOperatorType *ot)
 	
 	/* id-props */
 	ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_fmodifier_type_items, 0, "Type", "");
-	RNA_def_boolean(ot->srna, "only_active", 0, "Only Active", "Only add a F-Modifier of the specified type to the active strip");
+	RNA_def_enum_funcs(ot->prop, nla_fmodifier_itemf);
+	
+	RNA_def_boolean(ot->srna, "only_active", true, "Only Active", "Only add a F-Modifier of the specified type to the active strip");
 }
 
 /* ******************** Copy F-Modifiers Operator *********************** */




More information about the Bf-blender-cvs mailing list