diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-04-16 17:10:08 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-04-16 17:10:08 +0400 |
commit | f47ab4f0aedf2445bffab2094986884a418a976f (patch) | |
tree | feb0de1eb8f9d32d3ffebd14f03b0a1a64424fc0 | |
parent | 23af7214d3721862eae9f4601791ee0602740f50 (diff) |
2.5:
* Added extra parameter to generic unique name finding function BLI_uniquename() for specifying the delimeter between non-unique parts of the name and digits.
* Driver target variables now get unique names by default.
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/ipo.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_util.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/util.c | 7 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 2 | ||||
-rw-r--r-- | source/blender/editors/armature/poselib.c | 4 | ||||
-rw-r--r-- | source/blender/editors/armature/poseobject.c | 2 | ||||
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 2 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_buttons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner.c | 2 |
13 files changed, 20 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index c8b2ff71612..1d819b7de8b 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -240,7 +240,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho BLI_addtail(list, ks); /* make sure KeyingSet has a unique name (this helps with identification) */ - BLI_uniquename(list, ks, "Keying Set", offsetof(KeyingSet, name), 64); + BLI_uniquename(list, ks, "Keying Set", ' ', offsetof(KeyingSet, name), 64); /* return new KeyingSet for further editing */ return ks; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 9fc907a3931..dd8fd88f76c 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -93,7 +93,7 @@ /* Find the first available, non-duplicate name for a given constraint */ void unique_constraint_name (bConstraint *con, ListBase *list) { - BLI_uniquename(list, con, "Const", offsetof(bConstraint, name), 32); + BLI_uniquename(list, con, "Const", '.', offsetof(bConstraint, name), 32); } /* ----------------- Evaluation Loop Preparation --------------- */ diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 5d475767369..d7b1bdaeff3 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -5,6 +5,7 @@ #include <math.h> #include <stdio.h> +#include <stddef.h> #include <string.h> #include <float.h> @@ -589,8 +590,9 @@ DriverTarget *driver_add_new_target (ChannelDriver *driver) dtar= MEM_callocN(sizeof(DriverTarget), "DriverTarget"); BLI_addtail(&driver->targets, dtar); - /* give the target a name */ - strcpy(dtar->name, "a"); // XXX fimxe... this needs more work to get unique names without dots... + /* give the target a 'unique' name */ + strcpy(dtar->name, "var"); + BLI_uniquename(&driver->targets, dtar, "var", '_', offsetof(DriverTarget, name), 64); /* return the target */ return dtar; diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 48ffdca3a83..43791e32b38 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1082,7 +1082,7 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c BLI_snprintf(agrp->name, 64, grpname); BLI_addtail(&tmp_act.groups, agrp); - BLI_uniquename(&tmp_act.groups, agrp, "Group", offsetof(bActionGroup, name), 64); + BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), 64); } } diff --git a/source/blender/blenlib/BLI_util.h b/source/blender/blenlib/BLI_util.h index 9f0c3504ef8..30c9fc353b3 100644 --- a/source/blender/blenlib/BLI_util.h +++ b/source/blender/blenlib/BLI_util.h @@ -51,7 +51,7 @@ void BLI_split_dirfile(char *string, char *dir, char *file); void BLI_split_dirfile_basic(const char *string, char *dir, char *file); void BLI_join_dirfile(char *string, const char *dir, const char *file); int BLI_testextensie(const char *str, const char *ext); -void BLI_uniquename(struct ListBase *list, void *vlink, char defname[], short name_offs, short len); +void BLI_uniquename(struct ListBase *list, void *vlink, char defname[], char delim, short name_offs, short len); void BLI_newname(char * name, int add); int BLI_stringdec(char *string, char *kop, char *start, unsigned short *numlen); void BLI_stringenc(char *string, char *kop, char *start, unsigned short numlen, int pic); diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index 040b2d4027c..88f5038e19f 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -224,8 +224,9 @@ void BLI_newname(char *name, int add) * name_offs: should be calculated using offsetof(structname, membername) macro from stddef.h * len: maximum length of string (to prevent overflows, etc.) * defname: the name that should be used by default if none is specified already + * delim: the character which acts as a delimeter between parts of the name */ -void BLI_uniquename(ListBase *list, void *vlink, char defname[], short name_offs, short len) +void BLI_uniquename(ListBase *list, void *vlink, char defname[], char delim, short name_offs, short len) { Link *link; char tempname[128]; @@ -261,12 +262,12 @@ void BLI_uniquename(ListBase *list, void *vlink, char defname[], short name_offs return; /* Strip off the suffix */ - dot = strchr(GIVE_STRADDR(vlink, name_offs), '.'); + dot = strchr(GIVE_STRADDR(vlink, name_offs), delim); if (dot) *dot=0; for (number = 1; number <= 999; number++) { - BLI_snprintf(tempname, 128, "%s.%03d", GIVE_STRADDR(vlink, name_offs), number); + BLI_snprintf(tempname, 128, "%s%c%03d", GIVE_STRADDR(vlink, name_offs), delim, number); exists = 0; for (link= list->first; link; link= link->next) { diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index c09ac20f91b..0a911f2281a 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -127,7 +127,7 @@ FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[], BLI_snprintf(grp->name, 64, group); BLI_addtail(&act->groups, grp); - BLI_uniquename(&act->groups, grp, "Group", offsetof(bActionGroup, name), 64); + BLI_uniquename(&act->groups, grp, "Group", '.', offsetof(bActionGroup, name), 64); } /* add F-Curve to group */ diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index f4391ca95c8..fc5b98b1690 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -388,7 +388,7 @@ static int poselib_add_exec (bContext *C, wmOperator *op) } /* validate name */ - BLI_uniquename(&act->markers, marker, "Pose", offsetof(TimeMarker, name), 64); + BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), 64); /* make sure we've got KeyingSets to use */ poselib_get_builtin_keyingsets(); @@ -562,7 +562,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op) /* copy name and validate it */ BLI_strncpy(marker->name, newname, sizeof(marker->name)); - BLI_uniquename(&act->markers, marker, "Pose", offsetof(TimeMarker, name), 64); + BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), 64); /* done */ return OPERATOR_FINISHED; diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index ae82c063435..09edc5549c1 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -970,7 +970,7 @@ void pose_add_posegroup (Scene *scene) grp= MEM_callocN(sizeof(bActionGroup), "PoseGroup"); strcpy(grp->name, "Group"); BLI_addtail(&pose->agroups, grp); - BLI_uniquename(&pose->agroups, grp, "Group", offsetof(bActionGroup, name), 32); + BLI_uniquename(&pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), 32); pose->active_group= BLI_countlist(&pose->agroups); diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index b467450673d..9c24cd8b1e8 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -102,7 +102,7 @@ void gp_ui_renamelayer_cb (void *gpd_arg, void *gpl_arg) bGPdata *gpd= (bGPdata *)gpd_arg; bGPDlayer *gpl= (bGPDlayer *)gpl_arg; - BLI_uniquename(&gpd->layers, gpl, "GP_Layer", offsetof(bGPDlayer, info[0]), 128); + BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), 128); gpencil_layer_setactive(gpd, gpl); scrarea_queue_winredraw(curarea); diff --git a/source/blender/editors/gpencil/gpencil.c b/source/blender/editors/gpencil/gpencil.c index 7a251f2c252..f842cde72d9 100644 --- a/source/blender/editors/gpencil/gpencil.c +++ b/source/blender/editors/gpencil/gpencil.c @@ -226,7 +226,7 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd) /* auto-name */ sprintf(gpl->info, "GP_Layer"); - BLI_uniquename(&gpd->layers, gpl, "GP_Layer", offsetof(bGPDlayer, info[0]), 128); + BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), 128); /* make this one the active one */ gpencil_layer_setactive(gpd, gpl); diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 4bdc12f33c9..cfb5d61f90b 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -275,7 +275,7 @@ static void graph_panel_drivers(const bContext *C, ARegion *ar, short cntrl, bAn short height = 60; /* variable name */ - uiDefButC(block, TEX, B_REDR, "Name: ", 10,yco,280,20, dtar->name, 0, 63, 0, 0, "Name of target variable."); + uiDefButC(block, TEX, B_REDR, "Name: ", 10,yco,280,20, dtar->name, 0, 63, 0, 0, "Name of target variable (No spaces or dots are allowed. Also, must not start with a symbol or digit)."); /* remove button */ but= uiDefIconBut(block, BUT, B_REDR, ICON_X, 290, yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Delete target variable."); diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 6bd1e915b2b..46f8bc77149 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -4060,7 +4060,7 @@ static void namebutton_cb(bContext *C, void *tep, void *oldnamep) Object *ob= (Object *)tselem->id; // id = object bActionGroup *grp= te->directdata; - BLI_uniquename(&ob->pose->agroups, grp, "Group", offsetof(bActionGroup, name), 32); + BLI_uniquename(&ob->pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), 32); } break; case TSE_R_LAYER: |