Page MenuHome

outliner-poselib.patch

Authored By
Torsten Rupp (rupp)
Nov 13 2013, 2:45 PM
Size
7 KB
Subscribers
None

outliner-poselib.patch

Index: source/blender/editors/space_outliner/outliner.c
===================================================================
--- source/blender/editors/space_outliner/outliner.c (revision 30136)
+++ source/blender/editors/space_outliner/outliner.c (working copy)
@@ -80,6 +80,7 @@
#include "BKE_utildefines.h"
#include "ED_armature.h"
+#include "ED_keyframes_edit.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_util.h"
@@ -536,6 +537,20 @@
}
}
+/* add pose library pose names to outliner */
+static void outliner_add_poselib_contents(SpaceOops *soops, ListBase *lb, bAction *act, TreeElement *te)
+{
+ TreeElement *ten;
+ int a;
+ TimeMarker *marker;
+
+ for (a=0, marker= act->markers.first; marker; marker= marker->next, a++) {
+ ten= outliner_add_element(soops, &te->subtree, act, te, TSE_POSELIB, a);
+ ten->name= marker->name;
+ ten->directdata= marker;
+ }
+}
+
static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te)
{
SceneRenderLayer *srl;
@@ -857,6 +872,7 @@
{
// XXX do we want to be exposing the F-Curves here?
//bAction *act= (bAction *)id;
+ outliner_add_poselib_contents(soops, &te->subtree, (bAction *)id, te);
}
break;
case ID_AR:
@@ -2249,6 +2265,20 @@
return 0;
}
+static int tree_element_active_poselib(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set)
+{
+ bAction *act= (bAction *)tselem->id;
+
+ if(set) {
+ act->active_marker= te->index+1;
+ WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, act);
+ }
+ else {
+ if (act->active_marker== te->index+1) return 1;
+ }
+ return 0;
+}
+
/* generic call for ID data check or make/check active in UI */
static int tree_element_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set)
{
@@ -2367,6 +2397,8 @@
return tree_element_active_pose(C, scene, te, tselem, set);
case TSE_POSE_CHANNEL:
return tree_element_active_posechannel(C, scene, te, tselem, set);
+ case TSE_POSELIB:
+ return tree_element_active_poselib(C, scene, te, tselem, set);
case TSE_CONSTRAINT:
return tree_element_active_constraint(C, te, tselem, set);
case TSE_R_LAYER:
@@ -2379,7 +2411,6 @@
return tree_element_active_sequence_dup(C, scene, te, tselem, set);
case TSE_KEYMAP_ITEM:
return tree_element_active_keymap_item(C, te, tselem, set);
-
}
return 0;
}
@@ -3557,6 +3588,96 @@
/* **************************************** */
+static EnumPropertyItem prop_poselib_op_types[] = {
+ {1, "UNLINK", 0, "Unlink", ""},
+//XXX {2, "APPLY", 0, "Apply", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+static void poselib_cb(int event, TreeElement *te, TreeStoreElem *tselem)
+{
+ bAction *act= (bAction *)tselem->id;
+ TimeMarker *marker= (TimeMarker*)te->directdata;
+ FCurve *fcu;
+
+ if(marker) {
+ if(event==1) {
+ /* remove relevant keyframes */
+ for (fcu= act->curves.first; fcu; fcu= fcu->next) {
+ BezTriple *bezt;
+ int i;
+
+ if (fcu->bezt) {
+ for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+ /* check if remove */
+ if (IS_EQ(bezt->vec[1][0], marker->frame)) {
+ delete_fcurve_key(fcu, i, 1);
+ break;
+ }
+ }
+ }
+ }
+
+ /* remove poselib from list */
+ BLI_freelinkN(&act->markers, marker);
+
+ /* fix active pose number */
+ act->active_marker= 0;
+ }
+ else if(event==2) {
+// XXX apply still not implemented - how to do this here?
+ }
+ }
+}
+
+static int outliner_poselib_operation_exec(bContext *C, wmOperator *op)
+{
+ SpaceOops *soops= CTX_wm_space_outliner(C);
+ int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0;
+ int event;
+
+ /* check for invalid states */
+ if (soops == NULL)
+ return OPERATOR_CANCELLED;
+
+ set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
+
+ event= RNA_enum_get(op->ptr, "type");
+
+ if(event==1) {
+ outliner_do_data_operation(soops, datalevel, event, &soops->tree, poselib_cb);
+ ED_undo_push(C, "Unlink PoseLib");
+ }
+ else if(event==2) {
+ outliner_do_data_operation(soops, datalevel, event, &soops->tree, poselib_cb);
+ ED_undo_push(C, "Apply PoseLib to Scene");
+ }
+
+ WM_event_add_notifier(C, NC_GROUP, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+
+void OUTLINER_OT_poselib_operation(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Outliner PoseLib Operation";
+ ot->idname= "OUTLINER_OT_poselib_operation";
+ ot->description= "";
+
+ /* callbacks */
+ ot->invoke= WM_menu_invoke;
+ ot->exec= outliner_poselib_operation_exec;
+ ot->poll= ED_operator_outliner_active;
+
+ ot->flag= 0;
+
+ ot->prop= RNA_def_enum(ot->srna, "type", prop_poselib_op_types, 0, "PoseLib Operation", "");
+}
+
+/* **************************************** */
+
static EnumPropertyItem prop_data_op_types[] = {
{1, "SELECT", 0, "Select", ""},
{2, "DESELECT", 0, "Deselect", ""},
@@ -3670,7 +3791,10 @@
else if(datalevel) {
if(datalevel==-1) error("Mixed selection");
else {
- WM_operator_name_call(C, "OUTLINER_OT_data_operation", WM_OP_INVOKE_REGION_WIN, NULL);
+ if (datalevel==TSE_POSELIB)
+ WM_operator_name_call(C, "OUTLINER_OT_poselib_operation", WM_OP_INVOKE_REGION_WIN, NULL);
+ else
+ WM_operator_name_call(C, "OUTLINER_OT_data_operation", WM_OP_INVOKE_REGION_WIN, NULL);
}
}
Index: source/blender/editors/space_outliner/outliner_ops.c
===================================================================
--- source/blender/editors/space_outliner/outliner_ops.c (revision 30136)
+++ source/blender/editors/space_outliner/outliner_ops.c (working copy)
@@ -51,6 +51,7 @@
WM_operatortype_append(OUTLINER_OT_object_operation);
WM_operatortype_append(OUTLINER_OT_group_operation);
WM_operatortype_append(OUTLINER_OT_id_operation);
+ WM_operatortype_append(OUTLINER_OT_poselib_operation);
WM_operatortype_append(OUTLINER_OT_data_operation);
WM_operatortype_append(OUTLINER_OT_show_one_level);
Index: source/blender/editors/space_outliner/outliner_intern.h
===================================================================
--- source/blender/editors/space_outliner/outliner_intern.h (revision 30136)
+++ source/blender/editors/space_outliner/outliner_intern.h (working copy)
@@ -99,6 +99,8 @@
#define TSE_KEYMAP 34
#define TSE_KEYMAP_ITEM 35
+#define TSE_POSELIB 36
+
/* button events */
#define OL_NAMEBUTTON 1
@@ -122,6 +124,7 @@
void OUTLINER_OT_object_operation(struct wmOperatorType *ot);
void OUTLINER_OT_group_operation(struct wmOperatorType *ot);
void OUTLINER_OT_id_operation(struct wmOperatorType *ot);
+void OUTLINER_OT_poselib_operation(struct wmOperatorType *ot);
void OUTLINER_OT_data_operation(struct wmOperatorType *ot);
void OUTLINER_OT_show_one_level(struct wmOperatorType *ot);
Index: source/blender/editors/armature/poselib.c
===================================================================
--- source/blender/editors/armature/poselib.c (revision 30136)
+++ source/blender/editors/armature/poselib.c (working copy)
@@ -372,6 +372,9 @@
/* store new 'active' pose number */
act->active_marker= BLI_countlist(&act->markers);
+ /* send notifiers for this */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, marker);
+
/* done */
return OPERATOR_FINISHED;
}
@@ -472,6 +475,9 @@
/* fix active pose number */
act->active_marker= 0;
+ /* send notifiers for this */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, marker);
+
/* done */
return OPERATOR_FINISHED;
}
@@ -554,6 +560,9 @@
BLI_strncpy(marker->name, newname, sizeof(marker->name));
BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), sizeof(marker->name));
+ /* send notifiers for this */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, marker);
+
/* done */
return OPERATOR_FINISHED;
}

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e8/bc/06f804b0c2464c90a4a2fc67cb60

Event Timeline