From e71a6bd79ea1982dbed05468cc98def7093e9228 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 8 May 2008 08:59:36 +0000 Subject: [PATCH] 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) --- source/blender/include/BIF_interface.h | 1 + source/blender/src/drawnla.c | 6 ++--- source/blender/src/interface.c | 35 +++++++++++++++++--------- source/blender/src/interface_draw.c | 8 +++++- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/source/blender/include/BIF_interface.h b/source/blender/include/BIF_interface.h index 24747b9f220..fbd4e4ecd91 100644 --- a/source/blender/include/BIF_interface.h +++ b/source/blender/include/BIF_interface.h @@ -164,6 +164,7 @@ struct AutoComplete; #define BUT_TOGDUAL (33<<9) #define ICONTOGN (34<<9) #define FTPREVIEW (35<<9) +#define NUMABS (36<<9) #define BUTTYPE (63<<9) diff --git a/source/blender/src/drawnla.c b/source/blender/src/drawnla.c index c0cd11d27a1..083d10fd484 100644 --- a/source/blender/src/drawnla.c +++ b/source/blender/src/drawnla.c @@ -638,14 +638,14 @@ static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES 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"); diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index f324bf3b053..7af6b67bfa3 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -472,7 +472,7 @@ static int ui_but_copy_paste(uiBut *but, char mode) 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 @@ static int ui_act_as_text_but(uiBut *but) } if(but->pointype!=FLO) value= (int)value; - + + if(but->type==NUMABS) value= fabs(value); if(valuemax) value= max; @@ -3934,6 +3935,7 @@ static int ui_do_button(uiBlock *block, uiBut *but, uiEvent *uevent) break; case NUM: + case NUMABS: if(uevent->val) retval= ui_do_but_NUM(but); break; @@ -4253,13 +4255,13 @@ static void ui_but_next_edittext(uiBlock *block) 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 @@ static void ui_but_prev_edittext(uiBlock *block) 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 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent, int movemouse_quit) //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 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent, int movemouse_quit) 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,8 +5444,15 @@ void ui_check_but(uiBut *but) 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: @@ -5485,6 +5494,7 @@ void ui_check_but(uiBut *but) case NUM: case NUMSLI: case HSVSLI: + case NUMABS: value= ui_get_but_val(but); @@ -5574,7 +5584,7 @@ void ui_check_but(uiBut *but) 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 @@ static int ui_auto_themecol(uiBut *but) case SLI: case NUM: case NUMSLI: + case NUMABS: case HSVSLI: return TH_BUT_NUM; case TEX: @@ -5894,7 +5905,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short 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 && slenstr[slen-1]!=' ') { diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c index 83a3c12bae7..83f1221b1fb 100644 --- a/source/blender/src/interface_draw.c +++ b/source/blender/src/interface_draw.c @@ -846,6 +846,7 @@ static void ui_default_flat(int type, int colorid, float asp, float x1, float y1 /* *** EXTRA DRAWING FOR SPECIFIC CONTROL TYPES *** */ switch(type) { case NUM: + case NUMABS: /* SIDE ARROWS */ /* left */ if(flag & UI_SELECT) { @@ -872,11 +873,12 @@ static void ui_default_slider(int colorid, float fac, float aspect, float x1, fl 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 @@ static void ui_draw_default(int type, int colorid, float aspect, float x1, float 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 @@ static void ui_draw_oldskool(int type, int colorid, float asp, float x1, float y /* 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 @@ static void ui_draw_round(int type, int colorid, float asp, float x1, float y1, /* 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 @@ static void ui_draw_minimal(int type, int colorid, float asp, float x1, float y1 /* 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);