Freestyle: Added handling of a user-specified name for creating a new line set.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 11 May 2014 08:50:16 +0000 (17:50 +0900)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sun, 11 May 2014 08:57:43 +0000 (17:57 +0900)
source/blender/blenkernel/BKE_freestyle.h
source/blender/blenkernel/intern/freestyle.c
source/blender/editors/render/render_shading.c
source/blender/makesrna/intern/rna_scene.c

index e3e73cddbc0695ad5584c213a1d0cfeb23529d18..195c15fd837c04dbf865b516d4a8e2682fab30a3 100644 (file)
@@ -50,7 +50,7 @@ void BKE_freestyle_module_move_up(FreestyleConfig *config, FreestyleModuleConfig
 void BKE_freestyle_module_move_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
 
 /* FreestyleConfig.linesets */
-FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config);
+FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config, const char *name);
 bool BKE_freestyle_lineset_delete(FreestyleConfig *config, FreestyleLineSet *lineset);
 FreestyleLineSet *BKE_freestyle_lineset_get_active(FreestyleConfig *config);
 short BKE_freestyle_lineset_get_active_index(FreestyleConfig *config);
index 4bf68af8b65951aee082e0927711f9dd00b63121..495e99d61af240ecb73bb7ed08fa429139e192ac 100644 (file)
@@ -169,7 +169,7 @@ static FreestyleLineSet *alloc_lineset(void)
        return (FreestyleLineSet *)MEM_callocN(sizeof(FreestyleLineSet), "Freestyle line set");
 }
 
-FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config)
+FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config, const char *name)
 {
        int lineset_index = BLI_countlist(&config->linesets);
 
@@ -186,10 +186,15 @@ FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config)
        lineset->edge_types = FREESTYLE_FE_SILHOUETTE | FREESTYLE_FE_BORDER | FREESTYLE_FE_CREASE;
        lineset->exclude_edge_types = 0;
        lineset->group = NULL;
-       if (lineset_index > 0)
+       if (name) {
+               BLI_strncpy(lineset->name, name, sizeof(lineset->name));
+       }
+       else if (lineset_index > 0) {
                sprintf(lineset->name, "LineSet %i", lineset_index + 1);
-       else
+       }
+       else {
                strcpy(lineset->name, "LineSet");
+       }
        BKE_freestyle_lineset_unique_name(config, lineset);
 
        return lineset;
index 73659db891097017834d1d9ca439440465f4a350..97f6b3466662eb1c9efa18b560887d02f3524fac 100644 (file)
@@ -712,7 +712,7 @@ static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op))
        Scene *scene = CTX_data_scene(C);
        SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
 
-       BKE_freestyle_lineset_add(&srl->freestyleConfig);
+       BKE_freestyle_lineset_add(&srl->freestyleConfig, NULL);
 
        WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
 
index a97c0cf5da3d6f94ed243b7aa4dc21117602d7bd..bf2858c44e66ff3754a45b21e0eee94bc648e22a 100644 (file)
@@ -1586,7 +1586,7 @@ static void rna_FreestyleLineSet_linestyle_set(PointerRNA *ptr, PointerRNA value
 static FreestyleLineSet *FreestyleSettings_lineset_add(ID *id, struct FreestyleSettings *config, const char *name)
 {
        Scene *scene = (Scene *)id;
-       FreestyleLineSet *lineset = BKE_freestyle_lineset_add((FreestyleConfig *)config);
+       FreestyleLineSet *lineset = BKE_freestyle_lineset_add((FreestyleConfig *)config, name);
 
        DAG_id_tag_update(&scene->id, 0);
        WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);