[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14742] trunk/blender/source/blender: NLA - Bugfix:

Joshua Leung aligorith at gmail.com
Thu May 8 10:59:36 CEST 2008


Revision: 14742
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14742
Author:   aligorith
Date:     2008-05-08 10:59:36 +0200 (Thu, 08 May 2008)

Log Message:
-----------
NLA - Bugfix:

Scale and Repeat fields in NLA Transform Properties panel will now ignore negative values instead of clamping them to a near-zero value, which can easily be confused with the strip being 'destroyed'. This shouldn't affect other interface elements, as this change has only been used here. 

(Note: negative scaling should be avoided)

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_interface.h
    trunk/blender/source/blender/src/drawnla.c
    trunk/blender/source/blender/src/interface.c
    trunk/blender/source/blender/src/interface_draw.c

Modified: trunk/blender/source/blender/include/BIF_interface.h
===================================================================
--- trunk/blender/source/blender/include/BIF_interface.h	2008-05-08 08:41:56 UTC (rev 14741)
+++ trunk/blender/source/blender/include/BIF_interface.h	2008-05-08 08:59:36 UTC (rev 14742)
@@ -164,6 +164,7 @@
 #define BUT_TOGDUAL (33<<9)
 #define ICONTOGN (34<<9)
 #define FTPREVIEW (35<<9)
+#define NUMABS	(36<<9)
 #define BUTTYPE	(63<<9)
 
 

Modified: trunk/blender/source/blender/src/drawnla.c
===================================================================
--- trunk/blender/source/blender/src/drawnla.c	2008-05-08 08:41:56 UTC (rev 14741)
+++ trunk/blender/source/blender/src/drawnla.c	2008-05-08 08:59:36 UTC (rev 14742)
@@ -638,14 +638,14 @@
 	
 	uiBlockBeginAlign(block);
 		// FIXME: repeat and scale are too cramped!
-	uiDefButF(block, NUM, B_NLA_SCALE, "Repeat:", 	160,100,75,19, &strip->repeat, 0.001, 1000.0f, 100, 0, "Number of times the action should repeat");
+	uiDefButF(block, NUMABS, B_NLA_SCALE, "Repeat:", 	160,100,75,19, &strip->repeat, 0.001, 1000.0f, 100, 0, "Number of times the action should repeat");
 	if ((strip->actend - strip->actstart) < 1.0f) {
 		uiBlockSetCol(block, TH_REDALERT);
-		uiDefButF(block, NUM, B_NLA_SCALE, "Scale:", 	235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Please run Alt-S to fix up this error");
+		uiDefButF(block, NUMABS, B_NLA_SCALE, "Scale:", 	235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Please run Alt-S to fix up this error");
 		uiBlockSetCol(block, TH_AUTO);
 	}
 	else
-		uiDefButF(block, NUM, B_NLA_SCALE, "Scale:", 	235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Amount the action should be scaled by");
+		uiDefButF(block, NUMABS, B_NLA_SCALE, "Scale:", 	235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Amount the action should be scaled by");
 	but= uiDefButC(block, TEX, B_NLA_PANEL, "OffsBone:", 160,80,150,19, strip->offs_bone, 0, 31.0f, 0, 0, "Name of Bone that defines offset for repeat");
 	uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob);
 	uiDefButBitS(block, TOG, ACTSTRIP_HOLDLASTFRAME, B_NLA_PANEL, "Hold",	160,60,75,19, &strip->flag, 0, 0, 0, 0, "Toggles whether to continue displaying the last frame past the end of the strip");

Modified: trunk/blender/source/blender/src/interface.c
===================================================================
--- trunk/blender/source/blender/src/interface.c	2008-05-08 08:41:56 UTC (rev 14741)
+++ trunk/blender/source/blender/src/interface.c	2008-05-08 08:59:36 UTC (rev 14742)
@@ -472,7 +472,7 @@
 	if(mode=='v' && but->lock) return 0;
 	poin= but->poin;
 		
-	if ELEM3(but->type, NUM, NUMSLI, HSVSLI) {
+	if ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI) {
 		
 		if(poin==NULL);
 		else if(mode=='c') {
@@ -2100,7 +2100,8 @@
 	}
 	
 	if(but->pointype!=FLO) value= (int)value;
-
+	
+	if(but->type==NUMABS) value= fabs(value);
 	if(value<min) value= min;
 	if(value>max) value= max;
 
@@ -3934,6 +3935,7 @@
 		break;
 
 	case NUM:
+	case NUMABS:
 		if(uevent->val) retval= ui_do_but_NUM(but);
 		break;
 		
@@ -4253,13 +4255,13 @@
 			but->flag &= ~(UI_ACTIVE|UI_SELECT);
 		
 		for(but= actbut->next; but; but= but->next) {
-			if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) {
+			if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) {
 				but->flag |= UI_ACTIVE;
 				return;
 			}
 		}
 		for(but= block->buttons.first; but!=actbut; but= but->next) {
-			if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) {
+			if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) {
 				but->flag |= UI_ACTIVE;
 				return;
 			}
@@ -4282,13 +4284,13 @@
 			but->flag &= ~(UI_ACTIVE|UI_SELECT);
 		
 		for(but= actbut->prev; but; but= but->prev) {
-			if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) {
+			if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) {
 				but->flag |= UI_ACTIVE;
 				return;
 			}
 		}
 		for(but= block->buttons.last; but!=actbut; but= but->prev) {
-			if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) {
+			if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) {
 				but->flag |= UI_ACTIVE;
 				return;
 			}
@@ -4643,7 +4645,7 @@
 				//Really nasty... to update the num button from the same butblock
 				for(bt= block->buttons.first; bt; bt= bt->next)
 				{
-					if(bt->type == NUM) {
+					if(ELEM(bt->type, NUM, NUMABS)) {
 						ui_check_but(bt);
 						ui_draw_but(bt);
 					}
@@ -4669,7 +4671,7 @@
 
 				for(bt= block->buttons.first; bt; bt= bt->next)
 				{
-					if(bt->type == NUM) {
+					if(ELEM(bt->type, NUM, NUMABS)) {
 						ui_check_but(bt);
 						ui_draw_but(bt);
 					}
@@ -5442,10 +5444,17 @@
 		case HSVSLI:
 			value= ui_get_but_val(but);
 			if(value < but->min) value= but->min;
-				if(value > but->max) value= but->max;
-					ui_set_but_val(but, value);
+			if(value > but->max) value= but->max;
+			ui_set_but_val(but, value);
 			break;
 			
+		case NUMABS:
+			value= fabs( ui_get_but_val(but) );
+			if(value < but->min) value= but->min;
+			if(value > but->max) value= but->max;
+			ui_set_but_val(but, value);
+			break;
+			
 		case ICONTOG: 
 		case ICONTOGN:
 			if(but->flag & UI_SELECT) but->iconadd= 1;
@@ -5485,6 +5494,7 @@
 	case NUM:
 	case NUMSLI:
 	case HSVSLI:
+	case NUMABS:
 
 		value= ui_get_but_val(but);
 
@@ -5574,7 +5584,7 @@
 		but->ofs= 0;
 		while(but->strwidth > (int)okwidth ) {
 	
-			if ELEM(but->type, NUM, TEX) {	// only these cut off left
+			if ELEM3(but->type, NUM, NUMABS, TEX) {	// only these cut off left
 				but->ofs++;
 				but->strwidth= but->aspect*BIF_GetStringWidth(but->font, but->drawstr+but->ofs, transopts);
 				
@@ -5618,6 +5628,7 @@
 	case SLI:
 	case NUM:
 	case NUMSLI:
+	case NUMABS:
 	case HSVSLI:
 		return TH_BUT_NUM;
 	case TEX:
@@ -5894,7 +5905,7 @@
 	
 	but->pos= -1;	/* cursor invisible */
 
-	if(but->type==NUM) {	/* add a space to name */
+	if(ELEM(but->type, NUM, NUMABS)) {	/* add a space to name */
 		slen= strlen(but->str);
 		if(slen>0 && slen<UI_MAX_NAME_STR-2) {
 			if(but->str[slen-1]!=' ') {

Modified: trunk/blender/source/blender/src/interface_draw.c
===================================================================
--- trunk/blender/source/blender/src/interface_draw.c	2008-05-08 08:41:56 UTC (rev 14741)
+++ trunk/blender/source/blender/src/interface_draw.c	2008-05-08 08:59:36 UTC (rev 14742)
@@ -846,6 +846,7 @@
 	/* *** EXTRA DRAWING FOR SPECIFIC CONTROL TYPES *** */
 	switch(type) {
 	case NUM:
+	case NUMABS:
 		/* SIDE ARROWS */
 		/* left */
 		if(flag & UI_SELECT) {
@@ -872,11 +873,12 @@
 	
 	if(flag & UI_SELECT) 
 			BIF_ThemeColorShade(TH_BUT_NUM, -5);
-	else
+	else {
 		if(flag & UI_ACTIVE) 
 			BIF_ThemeColorShade(TH_BUT_NUM, +35); 
 		else
 			BIF_ThemeColorShade(TH_BUT_NUM, +25); 
+	}
 
 	glRectf(x1, ymid-yc, x2, ymid+yc);
 	
@@ -943,6 +945,7 @@
 	case TEX:
 	case IDPOIN:
 	case NUM:
+	case NUMABS:
 		ui_default_flat(type, colorid, aspect, x1, y1, x2, y2, flag);
 		break;
 	case ICONROW: 
@@ -1026,6 +1029,7 @@
 	/* special type decorations */
 	switch(type) {
 	case NUM:
+	case NUMABS:
 		if(flag & UI_SELECT) BIF_ThemeColorShade(colorid, -60);
 		else BIF_ThemeColorShade(colorid, -30);
 		ui_default_num_arrows(x1, y1, x2, y2);
@@ -1176,6 +1180,7 @@
 	/* special type decorations */
 	switch(type) {
 	case NUM:
+	case NUMABS:
 		BIF_ThemeColorShade(colorid, curshade-60);
 		ui_default_num_arrows(x1, y1, x2, y2);
 		break;
@@ -1285,6 +1290,7 @@
 	/* special type decorations */
 	switch(type) {
 	case NUM:
+	case NUMABS:
 		if(flag & UI_SELECT) BIF_ThemeColorShade(colorid, -60);
 		else BIF_ThemeColorShade(colorid, -30);
 		ui_default_num_arrows(x1, y1, x2, y2);





More information about the Bf-blender-cvs mailing list