diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_animsys.h | 19 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_layer.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 29 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 17 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_layer.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 24 |
6 files changed, 59 insertions, 34 deletions
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 71c63df7bf3..8b71d97c0e5 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -31,23 +31,22 @@ * \author Joshua Leung */ -struct ID; -struct ListBase; -struct Main; struct AnimData; +struct AnimMapper; struct FCurve; -struct KeyingSet; +struct ID; struct KS_Path; +struct KeyingSet; +struct ListBase; +struct Main; struct PathResolvedRNA; -struct bContext; - struct PointerRNA; struct PropertyRNA; struct ReportList; +struct Scene; struct bAction; struct bActionGroup; -struct AnimMapper; -struct FCurve; +struct bContext; /* ************************************* */ /* AnimData API */ @@ -119,7 +118,7 @@ void BKE_keyingsets_free(struct ListBase *list); /* Path Fixing API */ /* Get a "fixed" version of the given path (oldPath) */ -char *BKE_animsys_fix_rna_path_rename(ID *owner_id, char *old_path, const char *prefix, const char *oldName, +char *BKE_animsys_fix_rna_path_rename(struct ID *owner_id, char *old_path, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths); /* Fix all the paths for the given ID + Action */ @@ -132,7 +131,7 @@ void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, st bool verify_paths); /* Fix all the paths for the entire database... */ -void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const char *oldName, const char *newName); +void BKE_animdata_fix_paths_rename_all(struct ID *ref_id, const char *prefix, const char *oldName, const char *newName); /* Fix the path after removing elements that are not ID (e.g., node) */ void BKE_animdata_fix_paths_remove(struct ID *id, const char *path); diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index 9daf33baf10..626a1cd09e3 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -80,6 +80,8 @@ void BKE_view_layer_copy_data( struct ViewLayer *view_layer_dst, const struct ViewLayer *view_layer_src, const int flag); +void BKE_view_layer_rename(struct Scene *scene, struct ViewLayer *view_layer, const char *name); + struct LayerCollection *BKE_layer_collection_get_active(struct ViewLayer *view_layer); bool BKE_layer_collection_activate(struct ViewLayer *view_layer, struct LayerCollection *lc); struct LayerCollection *BKE_layer_collection_activate_parent(struct ViewLayer *view_layer, struct LayerCollection *lc); diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 6d875ecb516..648d5f02d4d 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -34,6 +34,7 @@ #include "BLI_threads.h" #include "BLT_translation.h" +#include "BKE_animsys.h" #include "BKE_collection.h" #include "BKE_freestyle.h" #include "BKE_global.h" @@ -387,6 +388,34 @@ void BKE_view_layer_copy_data( // TODO: not always safe to free BKE_layer_collection_sync(scene_dst, view_layer_dst); } +void BKE_view_layer_rename(Scene *scene, ViewLayer *view_layer, const char *newname) +{ + char oldname[sizeof(view_layer->name)]; + + BLI_strncpy(oldname, view_layer->name, sizeof(view_layer->name)); + + BLI_strncpy_utf8(view_layer->name, newname, sizeof(view_layer->name)); + BLI_uniquename(&scene->view_layers, view_layer, DATA_("ViewLayer"), '.', offsetof(ViewLayer, name), sizeof(view_layer->name)); + + if (scene->nodetree) { + bNode *node; + int index = BLI_findindex(&scene->view_layers, view_layer); + + for (node = scene->nodetree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_R_LAYERS && node->id == NULL) { + if (node->custom1 == index) + BLI_strncpy(node->name, view_layer->name, NODE_MAXSTR); + } + } + } + + /* fix all the animation data which may link to this */ + BKE_animdata_fix_paths_rename_all(NULL, "view_layers", oldname, view_layer->name); + + /* Dependency graph uses view layer name based lookups. */ + DEG_id_tag_update(&scene->id, 0); +} + /* LayerCollection */ /** diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 90b137bcd7d..dd9eee1f5fb 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -391,10 +391,25 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, gpd); break; } + case TSE_R_LAYER: + { + Scene *scene = (Scene *)tselem->id; + ViewLayer *view_layer = te->directdata; + + /* Restore old name. */ + char newname[sizeof(view_layer->name)]; + BLI_strncpy(newname, view_layer->name, sizeof(view_layer->name)); + BLI_strncpy(view_layer->name, oldname, sizeof(view_layer->name)); + + /* Rename, preserving animation and compositing data. */ + BKE_view_layer_rename(scene, view_layer, newname); + WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); + break; + } case TSE_LAYER_COLLECTION: { BLI_libblock_ensure_unique_name(bmain, tselem->id->name); - WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break; + WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break; } } diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index 10739150a40..8dc4f8c5e7b 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -305,7 +305,7 @@ void RNA_def_view_layer(BlenderRNA *brna) PropertyRNA *prop; srna = RNA_def_struct(brna, "ViewLayer", NULL); - RNA_def_struct_ui_text(srna, "Render Layer", "Render layer"); + RNA_def_struct_ui_text(srna, "View Layer", "View layer"); RNA_def_struct_ui_icon(srna, ICON_RENDER_RESULT); RNA_def_struct_path_func(srna, "rna_ViewLayer_path"); RNA_def_struct_idprops_func(srna, "rna_ViewLayer_idprops"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 32b2f9504ca..a86492fc462 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1486,27 +1486,7 @@ void rna_ViewLayer_name_set(PointerRNA *ptr, const char *value) { Scene *scene = (Scene *)ptr->id.data; ViewLayer *view_layer = (ViewLayer *)ptr->data; - char oldname[sizeof(view_layer->name)]; - - BLI_strncpy(oldname, view_layer->name, sizeof(view_layer->name)); - - BLI_strncpy_utf8(view_layer->name, value, sizeof(view_layer->name)); - BLI_uniquename(&scene->view_layers, view_layer, DATA_("ViewLayer"), '.', offsetof(ViewLayer, name), sizeof(view_layer->name)); - - if (scene->nodetree) { - bNode *node; - int index = BLI_findindex(&scene->view_layers, view_layer); - - for (node = scene->nodetree->nodes.first; node; node = node->next) { - if (node->type == CMP_NODE_R_LAYERS && node->id == NULL) { - if (node->custom1 == index) - BLI_strncpy(node->name, view_layer->name, NODE_MAXSTR); - } - } - } - - /* fix all the animation data which may link to this */ - BKE_animdata_fix_paths_rename_all(NULL, "view_layers", oldname, view_layer->name); + BKE_view_layer_rename(scene, view_layer, value); } static void rna_SceneRenderView_name_set(PointerRNA *ptr, const char *value) @@ -3224,7 +3204,7 @@ void rna_def_view_layer_common(StructRNA *srna, int scene) prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); if (scene) RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ViewLayer_name_set"); else RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Name", "Render layer name"); + RNA_def_property_ui_text(prop, "Name", "View layer name"); RNA_def_struct_name_property(srna, prop); if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); |