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-07-20 05:12:57 +0400
committerJoshua Leung <aligorith@gmail.com>2011-07-20 05:12:57 +0400
commit69614a972f1e7ad68f1c27dea4b56c41889e63d2 (patch)
treedb4d8d11286b8914b538c0e3c6c80b861a8f4fe6 /source/blender/editors/space_outliner
parent57fe73b3ac6ba6d7a0c3903318d9f0675e18338a (diff)
Add/Clear Fake Users from Outliner by RMB on ID blocks
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 891c18bcd8a..57ee2fe00ef 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -300,13 +300,32 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
static void id_local_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
{
- if(tselem->id->lib && (tselem->id->flag & LIB_EXTERN)) {
+ if (tselem->id->lib && (tselem->id->flag & LIB_EXTERN)) {
tselem->id->lib= NULL;
tselem->id->flag= LIB_LOCAL;
new_id(NULL, tselem->id, NULL);
}
}
+static void id_fake_user_set_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+{
+ ID *id = tselem->id;
+
+ if ((id) && ((id->flag & LIB_FAKEUSER) == 0)) {
+ id->flag |= LIB_FAKEUSER;
+ id_us_plus(id);
+ }
+}
+
+static void id_fake_user_clear_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+{
+ ID *id = tselem->id;
+
+ if ((id) && (id->flag & LIB_FAKEUSER)) {
+ id->flag &= ~LIB_FAKEUSER;
+ id_us_min(id);
+ }
+}
static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem)
{
@@ -637,9 +656,13 @@ void OUTLINER_OT_group_operation(wmOperatorType *ot)
typedef enum eOutlinerIdOpTypes {
OUTLINER_IDOP_INVALID = 0,
+
OUTLINER_IDOP_UNLINK,
OUTLINER_IDOP_LOCAL,
- OUTLINER_IDOP_SINGLE
+ OUTLINER_IDOP_SINGLE,
+
+ OUTLINER_IDOP_FAKE_ADD,
+ OUTLINER_IDOP_FAKE_CLEAR
} eOutlinerIdOpTypes;
// TODO: implement support for changing the ID-block used
@@ -647,6 +670,8 @@ static EnumPropertyItem prop_id_op_types[] = {
{OUTLINER_IDOP_UNLINK, "UNLINK", 0, "Unlink", ""},
{OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""},
{OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
+ {OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User", "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
+ {OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -721,6 +746,26 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
}
break;
+ case OUTLINER_IDOP_FAKE_ADD:
+ {
+ /* set fake user */
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_set_cb);
+
+ WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL);
+ ED_undo_push(C, "Add Fake User");
+ }
+ break;
+
+ case OUTLINER_IDOP_FAKE_CLEAR:
+ {
+ /* clear fake user */
+ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_clear_cb);
+
+ WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL);
+ ED_undo_push(C, "Clear Fake User");
+ }
+ break;
+
default:
// invalid - unhandled
break;