diff options
-rw-r--r-- | source/blender/blenkernel/BKE_key.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/key.c | 20 | ||||
-rw-r--r-- | source/blender/src/drawaction.c | 4 | ||||
-rw-r--r-- | source/blender/src/editaction.c | 18 | ||||
-rw-r--r-- | source/blender/src/editipo_lib.c | 26 |
5 files changed, 41 insertions, 28 deletions
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 94ba1cbd69d..5325b3a8bc1 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -59,6 +59,7 @@ int do_ob_key(struct Object *ob); struct Key *ob_get_key(struct Object *ob); struct KeyBlock *ob_get_keyblock(struct Object *ob); +struct KeyBlock *key_get_keyblock(struct Key *key, int index); #endif diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 0b5650ece44..8da3ea0b994 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1386,3 +1386,23 @@ KeyBlock *ob_get_keyblock(Object *ob) return NULL; } + +/* get the appropriate KeyBlock given an index */ +KeyBlock *key_get_keyblock(Key *key, int index) +{ + KeyBlock *kb; + int i; + + if (key) { + kb= key->block.first; + + for (i= 1; i < key->totkey; i++) { + kb= kb->next; + + if (index==i) + return kb; + } + } + + return NULL; +} diff --git a/source/blender/src/drawaction.c b/source/blender/src/drawaction.c index 8d525b88472..5b65295d212 100644 --- a/source/blender/src/drawaction.c +++ b/source/blender/src/drawaction.c @@ -160,14 +160,14 @@ static void meshactionbuts(SpaceAction *saction, Object *ob, Key *key) glRects(NAMEWIDTH, 0, NAMEWIDTH+SLIDERWIDTH, curarea->winy); uiBlockSetEmboss(block, UI_EMBOSS); - for (i=1 ; i < key->totkey ; ++ i) { + for (i=1; i < key->totkey; i++) { make_rvk_slider(block, ob, i, x, y, SLIDERWIDTH-2, CHANNELHEIGHT-1, "Slider to control Shape Keys"); y-=CHANNELHEIGHT+CHANNELSKIP; /* see sliderval array in editkey.c */ - if(i>=255) break; + if(i >= 255) break; } } uiDrawBlock(block); diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index 9ecb958b567..f7a5d5f40d3 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -1652,20 +1652,20 @@ static void clever_keyblock_names (Key *key, short *mval) * an invalid key number (and we don't deal * with the speed ipo). */ - + keynum = get_nearest_key_num(key, mval, &x); if ( (keynum < 1) || (keynum >= key->totkey) ) return; - - kb= key->block.first; - for (i=0; i<keynum; ++i) kb = kb->next; - - if (kb->name[0] == '\0') { + + kb= key_get_keyblock(key, keynum); + if (kb == NULL) + return; + + + if (kb->name[0] == '\0') sprintf(str, "Key %d", keynum); - } - else { + else strcpy(str, kb->name); - } if ( (kb->slidermin >= kb->slidermax) ) { kb->slidermin = 0.0; diff --git a/source/blender/src/editipo_lib.c b/source/blender/src/editipo_lib.c index 15840614d2a..47bd06664c2 100644 --- a/source/blender/src/editipo_lib.c +++ b/source/blender/src/editipo_lib.c @@ -148,24 +148,16 @@ char *getname_ipocurve(IpoCurve *icu, Object *ob) { static char name[32]; Key *key= ob_get_key(ob); + KeyBlock *kb= key_get_keyblock(key, icu->adrcode); - if (key) { - KeyBlock *kb= key->block.first; - int i; - - for (i= 1; i < key->totkey; i++) { - kb= kb->next; - - if (icu->adrcode == i) { - /* only return name if it has been set, otherwise use - * default method using static string (Key #) - */ - if (kb->name[0] == '\0') - break; /* stop looping through keyblocks */ - else - return kb->name; /* return keyblock's name */ - } - } + if (kb) { + /* only return name if it has been set, otherwise use + * default method using static string (Key #) + */ + if (kb->name[0] == '\0') + break; /* stop looping through keyblocks */ + else + return kb->name; /* return keyblock's name */ } /* in case keyblock is not named or no key/keyblock was found */ |