Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2011-06-29 08:34:20 +0400
committerJoshua Leung <aligorith@gmail.com>2011-06-29 08:34:20 +0400
commit2f60a5030f6c90c2278d3938460809de43012f85 (patch)
treefcf2b78b7a0c1e50cb613ad3219b94d06dc7f406 /source/blender/editors/space_outliner
parentb85e0c3e850b8995577aee9b066e15e66c60bad3 (diff)
Actions can now be made single-user from the Outliner
* Use the same method as from unlinking actions to do this. * Split off the make single-user code used for the ID-browser into a function in blenkernel which can be used elsewhere. Getting materials to also work using this method proved to be a bit too tricky (due to the whole messy ob vs obdata situation), so I haven't done that.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner.c115
1 files changed, 86 insertions, 29 deletions
diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c
index 20be507f5a0..3e4641bc0b9 100644
--- a/source/blender/editors/space_outliner/outliner.c
+++ b/source/blender/editors/space_outliner/outliner.c
@@ -3340,6 +3340,23 @@ static void id_local_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *
}
}
+
+static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem)
+{
+ ID *id = tselem->id;
+
+ if (id) {
+ IdAdtTemplate *iat = (IdAdtTemplate *)tsep->id;
+ PointerRNA ptr = {{0}};
+ PropertyRNA *prop;
+
+ RNA_pointer_create(&iat->id, &RNA_AnimData, iat->adt, &ptr);
+ prop = RNA_struct_find_property(&ptr, "action");
+
+ id_single_user(C, id, &ptr, prop);
+ }
+}
+
static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
{
Group *group= (Group *)tselem->id;
@@ -3634,10 +3651,18 @@ void OUTLINER_OT_group_operation(wmOperatorType *ot)
/* **************************************** */
+typedef enum eOutlinerIdOpTypes {
+ OUTLINER_IDOP_INVALID = 0,
+ OUTLINER_IDOP_UNLINK,
+ OUTLINER_IDOP_LOCAL,
+ OUTLINER_IDOP_SINGLE
+} eOutlinerIdOpTypes;
+
// TODO: implement support for changing the ID-block used
static EnumPropertyItem prop_id_op_types[] = {
- {1, "UNLINK", 0, "Unlink", ""},
- {2, "LOCAL", 0, "Make Local", ""},
+ {OUTLINER_IDOP_UNLINK, "UNLINK", 0, "Unlink", ""},
+ {OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""},
+ {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -3646,7 +3671,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
SpaceOops *soops= CTX_wm_space_outliner(C);
int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0;
- int event;
+ eOutlinerIdOpTypes event;
/* check for invalid states */
if (soops == NULL)
@@ -3656,33 +3681,65 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
event= RNA_enum_get(op->ptr, "type");
- if(event==1) {
- switch(idlevel) {
- case ID_AC:
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_action_cb);
-
- WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL);
- ED_undo_push(C, "Unlink action");
- break;
- case ID_MA:
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_material_cb);
-
- WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL);
- ED_undo_push(C, "Unlink material");
- break;
- case ID_TE:
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_texture_cb);
-
- WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL);
- ED_undo_push(C, "Unlink texture");
- break;
- default:
- BKE_report(op->reports, RPT_WARNING, "Not Yet");
+ switch (event) {
+ case OUTLINER_IDOP_UNLINK:
+ {
+ /* unlink datablock from its parent */
+ switch (idlevel) {
+ case ID_AC:
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_action_cb);
+
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL);
+ ED_undo_push(C, "Unlink action");
+ break;
+ case ID_MA:
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_material_cb);
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL);
+ ED_undo_push(C, "Unlink material");
+ break;
+ case ID_TE:
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_texture_cb);
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL);
+ ED_undo_push(C, "Unlink texture");
+ break;
+ default:
+ BKE_report(op->reports, RPT_WARNING, "Not Yet");
+ break;
+ }
}
- }
- else if(event==2) {
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb);
- ED_undo_push(C, "Localized Data");
+ break;
+
+ case OUTLINER_IDOP_LOCAL:
+ {
+ /* make local */
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb);
+ ED_undo_push(C, "Localized Data");
+ }
+ break;
+
+ case OUTLINER_IDOP_SINGLE:
+ {
+ /* make single user */
+ switch (idlevel) {
+ case ID_AC:
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_action_cb);
+
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL);
+ ED_undo_push(C, "Single-User Action");
+ break;
+
+ default:
+ BKE_report(op->reports, RPT_WARNING, "Not Yet");
+ break;
+ }
+ }
+ break;
+
+ default:
+ // invalid - unhandled
+ break;
}
/* wrong notifier still... */