Some code cleanups:
* editaction.c - merged the functions for channel properties (renaming, slider limits, protect/mute, etc.) * blenlib - added a new function BLI_findindex which finds the index position of a given item in a list. It will return -1 if it can't find the item - tidied up code formatting so that (the bits I have checked) have a single formatting style instead of a few different ones - added a few paranoia checks for NULL in one of the listbase-related functions - removed some half-dutch variable names still lurking around - culled a few compiler warnings... there are still two in util.c related to (const char *) and (char *) type things
This commit is contained in:
@@ -102,13 +102,14 @@ void BLI_join_dirfile(char *string, const char *dir, const char *file);
|
||||
int BLI_testextensie(const char *str, const char *ext);
|
||||
void addlisttolist(ListBase *list1, ListBase *list2);
|
||||
void BLI_insertlink(struct ListBase *listbase, void *vprevlink, void *vnewlink);
|
||||
void * BLI_findlink(struct ListBase *listbase, int number);
|
||||
void *BLI_findlink(struct ListBase *listbase, int number);
|
||||
int BLI_findindex(struct ListBase *listbase, void *vlink);
|
||||
void BLI_freelistN(struct ListBase *listbase);
|
||||
void BLI_addtail(struct ListBase *listbase, void *vlink);
|
||||
void BLI_remlink(struct ListBase *listbase, void *vlink);
|
||||
void BLI_newname(char * name, int add);
|
||||
int BLI_stringdec(char *string, char *kop, char *staart, unsigned short *numlen);
|
||||
void BLI_stringenc(char *string, char *kop, char *staart, unsigned short numlen, int pic);
|
||||
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);
|
||||
void BLI_addhead(struct ListBase *listbase, void *vlink);
|
||||
void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink);
|
||||
void BLI_freelist(struct ListBase *listbase);
|
||||
@@ -173,7 +174,7 @@ void BLI_clean(char *path);
|
||||
* @param str The string to be duplicated
|
||||
* @retval Returns the duplicated string
|
||||
*/
|
||||
char* BLI_strdup(const char *str);
|
||||
char *BLI_strdup(const char *str);
|
||||
|
||||
/**
|
||||
* Duplicates the first @a len bytes of cstring @a str
|
||||
@@ -184,7 +185,7 @@ char* BLI_strdup(const char *str);
|
||||
* @param len The number of bytes to duplicate
|
||||
* @retval Returns the duplicated string
|
||||
*/
|
||||
char* BLI_strdupn(const char *str, int len);
|
||||
char *BLI_strdupn(const char *str, int len);
|
||||
|
||||
/**
|
||||
* Like strncpy but ensures dst is always
|
||||
@@ -196,7 +197,7 @@ char* BLI_strdupn(const char *str, int len);
|
||||
* the size of dst)
|
||||
* @retval Returns dst
|
||||
*/
|
||||
char* BLI_strncpy(char *dst, const char *src, int maxncpy);
|
||||
char *BLI_strncpy(char *dst, const char *src, int maxncpy);
|
||||
|
||||
/*
|
||||
* Replacement for snprintf
|
||||
@@ -262,15 +263,15 @@ char* BLI_getbundle(void);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
int BLI_getInstallationDir( char * str );
|
||||
int BLI_getInstallationDir(char *str);
|
||||
#endif
|
||||
|
||||
/* BLI_storage.h */
|
||||
int BLI_filesize(int file);
|
||||
double BLI_diskfree(char *dir);
|
||||
char * BLI_getwdN(char * dir);
|
||||
char *BLI_getwdN(char *dir);
|
||||
void BLI_hide_dot_files(int set);
|
||||
unsigned int BLI_getdir(char *dirname, struct direntry **filelist);
|
||||
unsigned int BLI_getdir(char *dirname, struct direntry **filelist);
|
||||
|
||||
/**
|
||||
* @attention Do not confuse with BLI_exists
|
||||
@@ -303,12 +304,12 @@ char *BLI_last_slash(char *string);
|
||||
*
|
||||
* @return True if @a rect is empty.
|
||||
*/
|
||||
int BLI_rcti_is_empty(struct rcti * rect);
|
||||
int BLI_rcti_is_empty(struct rcti *rect);
|
||||
void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, float ymax);
|
||||
void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
|
||||
void BLI_translate_rctf(struct rctf *rect, float x, float y);
|
||||
void BLI_translate_rcti(struct rcti *rect, int x, int y);
|
||||
int BLI_in_rcti(struct rcti * rect, int x, int y);
|
||||
int BLI_in_rcti(struct rcti *rect, int x, int y);
|
||||
int BLI_in_rctf(struct rctf *rect, float x, float y);
|
||||
int BLI_isect_rctf(struct rctf *src1, struct rctf *src2, struct rctf *dest);
|
||||
int BLI_isect_rcti(struct rcti *src1, struct rcti *src2, struct rcti *dest);
|
||||
|
||||
@@ -90,31 +90,29 @@ static int add_win32_extension(char *name);
|
||||
|
||||
/* implementation */
|
||||
|
||||
/* Ripped this from blender.c
|
||||
*/
|
||||
/* Ripped this from blender.c */
|
||||
void addlisttolist(ListBase *list1, ListBase *list2)
|
||||
{
|
||||
if (list2->first==0) return;
|
||||
|
||||
if(list2->first==0) return;
|
||||
|
||||
if(list1->first==0) {
|
||||
if (list1->first==0) {
|
||||
list1->first= list2->first;
|
||||
list1->last= list2->last;
|
||||
}
|
||||
else {
|
||||
((struct Link *)list1->last)->next= list2->first;
|
||||
((struct Link *)list2->first)->prev= list1->last;
|
||||
((Link *)list1->last)->next= list2->first;
|
||||
((Link *)list2->first)->prev= list1->last;
|
||||
list1->last= list2->last;
|
||||
}
|
||||
list2->first= list2->last= 0;
|
||||
}
|
||||
|
||||
int BLI_stringdec(char *string, char *kop, char *staart, unsigned short *numlen)
|
||||
int BLI_stringdec(char *string, char *kop, char *start, unsigned short *numlen)
|
||||
{
|
||||
unsigned short len, len2, nums = 0, nume = 0;
|
||||
short i, found = 0;
|
||||
|
||||
len2 = len = strlen( string);
|
||||
len2 = len = strlen(string);
|
||||
|
||||
if (len > 6) {
|
||||
if (BLI_strncasecmp(string + len - 6, ".blend", 6) == 0) len -= 6;
|
||||
@@ -125,7 +123,6 @@ int BLI_stringdec(char *string, char *kop, char *staart, unsigned short *numlen)
|
||||
if (BLI_strncasecmp(string + len - 9, ".blend.gz", 9) == 0) len -= 9;
|
||||
}
|
||||
|
||||
|
||||
if (len == len2) {
|
||||
if (len > 4) {
|
||||
/* handle .jf0 en .jf1 for jstreams */
|
||||
@@ -143,7 +140,7 @@ int BLI_stringdec(char *string, char *kop, char *staart, unsigned short *numlen)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = len - 1; i >= 0; i--){
|
||||
for (i = len - 1; i >= 0; i--) {
|
||||
if (string[i] == '/') break;
|
||||
if (isdigit(string[i])) {
|
||||
if (found){
|
||||
@@ -155,12 +152,12 @@ int BLI_stringdec(char *string, char *kop, char *staart, unsigned short *numlen)
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
if (found) break;
|
||||
}
|
||||
}
|
||||
if (found){
|
||||
if (staart) strcpy(staart,&string[nume+1]);
|
||||
if (start) strcpy(start,&string[nume+1]);
|
||||
if (kop) {
|
||||
strcpy(kop,string);
|
||||
kop[nums]=0;
|
||||
@@ -168,7 +165,7 @@ int BLI_stringdec(char *string, char *kop, char *staart, unsigned short *numlen)
|
||||
if (numlen) *numlen = nume-nums+1;
|
||||
return ((int)atoi(&(string[nums])));
|
||||
}
|
||||
if (staart) strcpy(staart, string + len);
|
||||
if (start) strcpy(start, string + len);
|
||||
if (kop) {
|
||||
strncpy(kop, string, len);
|
||||
kop[len] = 0;
|
||||
@@ -178,7 +175,7 @@ int BLI_stringdec(char *string, char *kop, char *staart, unsigned short *numlen)
|
||||
}
|
||||
|
||||
|
||||
void BLI_stringenc(char *string, char *kop, char *staart, unsigned short numlen, int pic)
|
||||
void BLI_stringenc(char *string, char *kop, char *start, unsigned short numlen, int pic)
|
||||
{
|
||||
char numstr[10]="";
|
||||
unsigned short len,i;
|
||||
@@ -187,17 +184,17 @@ void BLI_stringenc(char *string, char *kop, char *staart, unsigned short numlen,
|
||||
|
||||
if (pic>0 || numlen==4) {
|
||||
len= sprintf(numstr,"%d",pic);
|
||||
|
||||
|
||||
for(i=len;i<numlen;i++){
|
||||
strcat(string,"0");
|
||||
}
|
||||
strcat(string,numstr);
|
||||
}
|
||||
strcat(string,staart);
|
||||
strcat(string, start);
|
||||
}
|
||||
|
||||
|
||||
void BLI_newname(char * name, int add)
|
||||
void BLI_newname(char *name, int add)
|
||||
{
|
||||
char head[128], tail[128];
|
||||
int pic;
|
||||
@@ -215,38 +212,38 @@ void BLI_newname(char * name, int add)
|
||||
|
||||
pic += add;
|
||||
|
||||
if(digits==4 && pic<0) pic= 0;
|
||||
if (digits==4 && pic<0) pic= 0;
|
||||
BLI_stringenc(name, head, tail, digits, pic);
|
||||
}
|
||||
|
||||
|
||||
void BLI_addhead(ListBase *listbase, void *vlink)
|
||||
{
|
||||
struct Link *link= vlink;
|
||||
Link *link= vlink;
|
||||
|
||||
if (link == 0) return;
|
||||
if (listbase == 0) return;
|
||||
if (link == NULL) return;
|
||||
if (listbase == NULL) return;
|
||||
|
||||
link->next = listbase->first;
|
||||
link->prev = 0;
|
||||
link->prev = NULL;
|
||||
|
||||
if (listbase->first) ((struct Link *)listbase->first)->prev = link;
|
||||
if (listbase->last == 0) listbase->last = link;
|
||||
if (listbase->first) ((Link *)listbase->first)->prev = link;
|
||||
if (listbase->last == NULL) listbase->last = link;
|
||||
listbase->first = link;
|
||||
}
|
||||
|
||||
|
||||
void BLI_addtail(ListBase *listbase, void *vlink)
|
||||
{
|
||||
struct Link *link= vlink;
|
||||
Link *link= vlink;
|
||||
|
||||
if (link == 0) return;
|
||||
if (listbase == 0) return;
|
||||
if (link == NULL) return;
|
||||
if (listbase == NULL) return;
|
||||
|
||||
link->next = 0;
|
||||
link->next = NULL;
|
||||
link->prev = listbase->last;
|
||||
|
||||
if (listbase->last) ((struct Link *)listbase->last)->next = link;
|
||||
if (listbase->last) ((Link *)listbase->last)->next = link;
|
||||
if (listbase->first == 0) listbase->first = link;
|
||||
listbase->last = link;
|
||||
}
|
||||
@@ -254,10 +251,10 @@ void BLI_addtail(ListBase *listbase, void *vlink)
|
||||
|
||||
void BLI_remlink(ListBase *listbase, void *vlink)
|
||||
{
|
||||
struct Link *link= vlink;
|
||||
Link *link= vlink;
|
||||
|
||||
if (link == 0) return;
|
||||
if (listbase == 0) return;
|
||||
if (link == NULL) return;
|
||||
if (listbase == NULL) return;
|
||||
|
||||
if (link->next) link->next->prev = link->prev;
|
||||
if (link->prev) link->prev->next = link->next;
|
||||
@@ -269,10 +266,10 @@ void BLI_remlink(ListBase *listbase, void *vlink)
|
||||
|
||||
void BLI_freelinkN(ListBase *listbase, void *vlink)
|
||||
{
|
||||
struct Link *link= vlink;
|
||||
Link *link= vlink;
|
||||
|
||||
if (link == 0) return;
|
||||
if (listbase == 0) return;
|
||||
if (link == NULL) return;
|
||||
if (listbase == NULL) return;
|
||||
|
||||
BLI_remlink(listbase,link);
|
||||
MEM_freeN(link);
|
||||
@@ -281,19 +278,23 @@ void BLI_freelinkN(ListBase *listbase, void *vlink)
|
||||
|
||||
void BLI_insertlink(ListBase *listbase, void *vprevlink, void *vnewlink)
|
||||
{
|
||||
struct Link *prevlink= vprevlink, *newlink= vnewlink;
|
||||
Link *prevlink= vprevlink;
|
||||
Link *newlink= vnewlink;
|
||||
|
||||
/* newlink comes after prevlink */
|
||||
|
||||
if (newlink == 0) return;
|
||||
if (listbase == 0) return;
|
||||
|
||||
if(listbase->first==0) { /* empty list */
|
||||
if (newlink == NULL) return;
|
||||
if (listbase == NULL) return;
|
||||
|
||||
/* empty list */
|
||||
if (listbase->first == NULL) {
|
||||
|
||||
listbase->first= newlink;
|
||||
listbase->last= newlink;
|
||||
return;
|
||||
}
|
||||
if (prevlink== 0) { /* insert before first element */
|
||||
|
||||
/* insert before first element */
|
||||
if (prevlink == NULL) {
|
||||
newlink->next= listbase->first;
|
||||
newlink->prev= 0;
|
||||
newlink->next->prev= newlink;
|
||||
@@ -301,96 +302,106 @@ void BLI_insertlink(ListBase *listbase, void *vprevlink, void *vnewlink)
|
||||
return;
|
||||
}
|
||||
|
||||
if (listbase->last== prevlink) /* at end of list */
|
||||
/* at end of list */
|
||||
if (listbase->last== prevlink)
|
||||
listbase->last = newlink;
|
||||
|
||||
newlink->next= prevlink->next;
|
||||
prevlink->next= newlink;
|
||||
if(newlink->next) newlink->next->prev= newlink;
|
||||
if (newlink->next) newlink->next->prev= newlink;
|
||||
newlink->prev= prevlink;
|
||||
}
|
||||
|
||||
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink)
|
||||
{
|
||||
struct Link *nextlink= vnextlink, *newlink= vnewlink;
|
||||
Link *nextlink= vnextlink;
|
||||
Link *newlink= vnewlink;
|
||||
|
||||
/* newlink before nextlink */
|
||||
if (newlink == NULL) return;
|
||||
if (listbase == NULL) return;
|
||||
|
||||
if (newlink == 0) return;
|
||||
if (listbase == 0) return;
|
||||
|
||||
if(listbase->first==0) { /* empty list */
|
||||
/* empty list */
|
||||
if (listbase->first == NULL) {
|
||||
listbase->first= newlink;
|
||||
listbase->last= newlink;
|
||||
return;
|
||||
}
|
||||
if (nextlink== 0) { /* insert at end of list */
|
||||
|
||||
/* insert at end of list */
|
||||
if (nextlink == NULL) {
|
||||
newlink->prev= listbase->last;
|
||||
newlink->next= 0;
|
||||
((struct Link *)listbase->last)->next= newlink;
|
||||
((Link *)listbase->last)->next= newlink;
|
||||
listbase->last= newlink;
|
||||
return;
|
||||
}
|
||||
|
||||
if (listbase->first== nextlink) /* at beginning of list */
|
||||
/* at beginning of list */
|
||||
if (listbase->first== nextlink)
|
||||
listbase->first = newlink;
|
||||
|
||||
newlink->next= nextlink;
|
||||
newlink->prev= nextlink->prev;
|
||||
nextlink->prev= newlink;
|
||||
if(newlink->prev) newlink->prev->next= newlink;
|
||||
if (newlink->prev) newlink->prev->next= newlink;
|
||||
}
|
||||
|
||||
|
||||
void BLI_freelist(ListBase *listbase)
|
||||
{
|
||||
struct Link *link,*next;
|
||||
Link *link, *next;
|
||||
|
||||
if (listbase == 0) return;
|
||||
if (listbase == NULL)
|
||||
return;
|
||||
|
||||
link= listbase->first;
|
||||
while(link) {
|
||||
while (link) {
|
||||
next= link->next;
|
||||
free(link);
|
||||
link= next;
|
||||
}
|
||||
listbase->first=0;
|
||||
listbase->last=0;
|
||||
|
||||
listbase->first= NULL;
|
||||
listbase->last= NULL;
|
||||
}
|
||||
|
||||
void BLI_freelistN(ListBase *listbase)
|
||||
{
|
||||
struct Link *link,*next;
|
||||
Link *link, *next;
|
||||
|
||||
if (listbase == 0) return;
|
||||
if (listbase == NULL) return;
|
||||
|
||||
link= listbase->first;
|
||||
while(link) {
|
||||
while (link) {
|
||||
next= link->next;
|
||||
MEM_freeN(link);
|
||||
link= next;
|
||||
}
|
||||
listbase->first=0;
|
||||
listbase->last=0;
|
||||
|
||||
listbase->first= NULL;
|
||||
listbase->last= NULL;
|
||||
}
|
||||
|
||||
|
||||
int BLI_countlist(ListBase *listbase)
|
||||
{
|
||||
Link * link;
|
||||
Link *link;
|
||||
int count = 0;
|
||||
|
||||
if (listbase){
|
||||
if (listbase) {
|
||||
link = listbase->first;
|
||||
while(link) {
|
||||
while (link) {
|
||||
count++;
|
||||
link= link->next;
|
||||
}
|
||||
}
|
||||
return(count);
|
||||
return count;
|
||||
}
|
||||
|
||||
void * BLI_findlink(ListBase *listbase, int number)
|
||||
void *BLI_findlink(ListBase *listbase, int number)
|
||||
{
|
||||
Link * link = NULL;
|
||||
Link *link = NULL;
|
||||
|
||||
if (number >= 0) {
|
||||
link = listbase->first;
|
||||
@@ -400,7 +411,27 @@ void * BLI_findlink(ListBase *listbase, int number)
|
||||
}
|
||||
}
|
||||
|
||||
return (link);
|
||||
return link;
|
||||
}
|
||||
|
||||
int BLI_findindex(ListBase *listbase, void *vlink)
|
||||
{
|
||||
Link *link= NULL;
|
||||
int number= 0;
|
||||
|
||||
if (listbase == NULL) return -1;
|
||||
if (vlink == NULL) return -1;
|
||||
|
||||
link= listbase->first;
|
||||
while (link) {
|
||||
if (link == vlink)
|
||||
return number;
|
||||
|
||||
number++;
|
||||
link= link->next;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*=====================================================================================*/
|
||||
@@ -1195,7 +1226,7 @@ void BLI_split_dirfile(const char *string, char *dir, char *file)
|
||||
strcat(dir,string);
|
||||
BLI_strncpy(string,dir,FILE_MAXDIR+FILE_MAXFILE);
|
||||
}
|
||||
|
||||
|
||||
// BLI_exist doesn't recognize a slashed dirname as a dir
|
||||
// check if a trailing slash exists, and remove it. Do not do this
|
||||
// when we are already at root. -jesterKing
|
||||
@@ -1221,11 +1252,11 @@ void BLI_split_dirfile(const char *string, char *dir, char *file)
|
||||
else
|
||||
BLI_strncpy(file,string,FILE_MAXFILE);
|
||||
|
||||
if (strrchr(string,'\\')){
|
||||
if (strrchr(string,'\\')) {
|
||||
BLI_strncpy(file,strrchr(string,'\\')+1,FILE_MAXFILE);
|
||||
}
|
||||
|
||||
if (a = strlen(dir)) {
|
||||
|
||||
if ( (a = strlen(dir)) ) {
|
||||
if (dir[a-1] != '\\') strcat(dir,"\\");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,17 +464,17 @@ Key *get_action_mesh_key(void)
|
||||
Key *key;
|
||||
|
||||
ob = OBACT;
|
||||
if (!ob) return NULL;
|
||||
if (ob == NULL)
|
||||
return NULL;
|
||||
|
||||
if (G.saction->pin) return NULL;
|
||||
|
||||
if (ob->type==OB_MESH ) {
|
||||
if (ob->type==OB_MESH)
|
||||
key = ((Mesh *)ob->data)->key;
|
||||
}
|
||||
else if (ob->type==OB_LATTICE ) {
|
||||
else if (ob->type==OB_LATTICE)
|
||||
key = ((Lattice *)ob->data)->key;
|
||||
}
|
||||
else return NULL;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
if (key) {
|
||||
if (key->type == KEY_RELATIVE)
|
||||
@@ -533,7 +533,7 @@ void *get_nearest_act_channel (short mval[], short *ret_type)
|
||||
}
|
||||
|
||||
/* filter data */
|
||||
filter= (ACTFILTER_VISIBLE | ACTFILTER_CHANNELS);
|
||||
filter= (ACTFILTER_FORDRAWING | ACTFILTER_VISIBLE | ACTFILTER_CHANNELS);
|
||||
actdata_filter(&act_data, filter, data, datatype);
|
||||
|
||||
for (ale= act_data.first; ale; ale= ale->next) {
|
||||
@@ -1399,83 +1399,55 @@ void sethandles_action_keys (int code)
|
||||
|
||||
/* ----------------------------------------- */
|
||||
|
||||
static void clever_keyblock_names (Key *key, short *mval)
|
||||
/* this gets called when nkey is pressed (no Transform Properties panel yet) */
|
||||
static void numbuts_action ()
|
||||
{
|
||||
KeyBlock *kb;
|
||||
int but=0, keynum;
|
||||
char str[64];
|
||||
float x;
|
||||
void *data;
|
||||
short datatype;
|
||||
|
||||
/* get the keynum cooresponding to the y value
|
||||
* of the mouse pointer, return if this is
|
||||
* 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_get_keyblock(key, keynum);
|
||||
if (kb == NULL)
|
||||
return;
|
||||
|
||||
if (kb->name[0] == '\0')
|
||||
sprintf(str, "Key %d", keynum);
|
||||
else
|
||||
strcpy(str, kb->name);
|
||||
|
||||
if ( (kb->slidermin >= kb->slidermax) ) {
|
||||
kb->slidermin = 0.0;
|
||||
kb->slidermax = 1.0;
|
||||
}
|
||||
|
||||
add_numbut(but++, TEX, "KB: ", 0, 24, str,
|
||||
"Does this really need a tool tip?");
|
||||
add_numbut(but++, NUM|FLO, "Slider Min:",
|
||||
-10000, kb->slidermax, &kb->slidermin, 0);
|
||||
add_numbut(but++, NUM|FLO, "Slider Max:",
|
||||
kb->slidermin, 10000, &kb->slidermax, 0);
|
||||
|
||||
if (do_clever_numbuts(str, but, REDRAW)) {
|
||||
strcpy(kb->name, str);
|
||||
allqueue (REDRAWACTION, 0);
|
||||
allspace(REMAKEIPO, 0);
|
||||
allqueue (REDRAWIPO, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void clever_achannel_names (short *mval)
|
||||
{
|
||||
void *act_channel;
|
||||
short chantype;
|
||||
|
||||
bActionChannel *achan= NULL;
|
||||
bConstraintChannel *conchan= NULL;
|
||||
IpoCurve *icu= NULL;
|
||||
KeyBlock *kb= NULL;
|
||||
|
||||
short mval[2];
|
||||
|
||||
int but=0;
|
||||
char str[64];
|
||||
short chantype;
|
||||
short expand, protect, mute;
|
||||
float slidermin, slidermax;
|
||||
|
||||
|
||||
/* determine what type of data we are operating on */
|
||||
data = get_action_context(&datatype);
|
||||
if (data == NULL) return;
|
||||
|
||||
/* figure out what is under cursor */
|
||||
getmouseco_areawin(mval);
|
||||
if (mval[0] < NAMEWIDTH)
|
||||
return;
|
||||
act_channel= get_nearest_act_channel(mval, &chantype);
|
||||
|
||||
/* create items for clever-numbut */
|
||||
if (chantype == ACTTYPE_ACHAN) {
|
||||
/* Action Channel */
|
||||
achan= (bActionChannel *)act_channel;
|
||||
|
||||
strcpy(str, achan->name);
|
||||
protect= (achan->flag & ACHAN_PROTECTED);
|
||||
expand = (achan->flag & ACHAN_EXPANDED);
|
||||
mute = (achan->ipo)? (achan->ipo->muteipo): 0;
|
||||
|
||||
|
||||
add_numbut(but++, TEX, "ActChan: ", 0, 31, str, "Name of Action Channel");
|
||||
add_numbut(but++, TOG|SHO, "Expanded", 0, 24, &expand, "Action Channel is Expanded");
|
||||
add_numbut(but++, TOG|SHO, "Muted", 0, 24, &mute, "Channel is Muted");
|
||||
add_numbut(but++, TOG|SHO, "Protected", 0, 24, &protect, "Channel is Protected");
|
||||
}
|
||||
else if (chantype == ACTTYPE_CONCHAN) {
|
||||
/* Constraint Channel */
|
||||
conchan= (bConstraintChannel *)act_channel;
|
||||
|
||||
strcpy(str, conchan->name);
|
||||
@@ -1487,6 +1459,7 @@ static void clever_achannel_names (short *mval)
|
||||
add_numbut(but++, TOG|SHO, "Protected", 0, 24, &protect, "Channel is Protected");
|
||||
}
|
||||
else if (chantype == ACTTYPE_ICU) {
|
||||
/* IPO Curve */
|
||||
icu= (IpoCurve *)act_channel;
|
||||
|
||||
if (G.saction->pin)
|
||||
@@ -1515,6 +1488,31 @@ static void clever_achannel_names (short *mval)
|
||||
add_numbut(but++, TOG|SHO, "Muted", 0, 24, &mute, "Channel is Muted");
|
||||
//add_numbut(but++, TOG|SHO, "Protected", 0, 24, &protect, "Channel is Protected");
|
||||
}
|
||||
else if (chantype == ACTTYPE_SHAPEKEY) {
|
||||
/* Shape Key */
|
||||
kb= (KeyBlock *)act_channel;
|
||||
|
||||
if (kb->name[0] == '\0') {
|
||||
Key *key= (Key *)data;
|
||||
int keynum= BLI_findindex(&key->block, kb);
|
||||
|
||||
sprintf(str, "Key %d", keynum);
|
||||
}
|
||||
else
|
||||
strcpy(str, kb->name);
|
||||
|
||||
if (kb->slidermin >= kb->slidermax) {
|
||||
kb->slidermin = 0.0;
|
||||
kb->slidermax = 1.0;
|
||||
}
|
||||
|
||||
add_numbut(but++, TEX, "KB: ", 0, 24, str,
|
||||
"Does this really need a tool tip?");
|
||||
add_numbut(but++, NUM|FLO, "Slider Min:",
|
||||
-10000, kb->slidermax, &kb->slidermin, 0);
|
||||
add_numbut(but++, NUM|FLO, "Slider Max:",
|
||||
kb->slidermin, 10000, &kb->slidermax, 0);
|
||||
}
|
||||
else {
|
||||
/* nothing under-cursor */
|
||||
return;
|
||||
@@ -1554,35 +1552,13 @@ static void clever_achannel_names (short *mval)
|
||||
achan->ipo->muteipo = mute;
|
||||
}
|
||||
|
||||
allqueue (REDRAWACTION, 0);
|
||||
allqueue (REDRAWVIEW3D, 0);
|
||||
allqueue(REDRAWACTION, 0);
|
||||
allspace(REMAKEIPO, 0);
|
||||
allqueue(REDRAWIPO, 0);
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* this gets called when nkey is pressed (no Transform Properties panel yet) */
|
||||
static void numbuts_action (void)
|
||||
{
|
||||
/* now called from action window event loop, plus reacts on mouseclick */
|
||||
/* removed Hos grunts for that reason! :) (ton) */
|
||||
void *data;
|
||||
short datatype;
|
||||
short mval[2];
|
||||
|
||||
/* determine what type of data we are operating on */
|
||||
data = get_action_context(&datatype);
|
||||
getmouseco_areawin(mval);
|
||||
|
||||
if (mval[0] < NAMEWIDTH) {
|
||||
switch (datatype) {
|
||||
case ACTCONT_ACTION:
|
||||
clever_achannel_names(mval);
|
||||
break;
|
||||
case ACTCONT_SHAPEKEY:
|
||||
clever_keyblock_names(data, mval);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* **************************************************** */
|
||||
@@ -2885,7 +2861,7 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
if (datatype == ACTCONT_ACTION) {
|
||||
/* mouse is over action channels */
|
||||
if (G.qual & LR_CTRLKEY)
|
||||
clever_achannel_names(mval);
|
||||
numbuts_action();
|
||||
else
|
||||
mouse_actionchannels(mval);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user