* Added support for soft/hard range in the buttons code. Currently
  it works by only allowing to drag or click increment in the soft
  range, but typing a number value allows to go outside it.

  If the number is outside the soft range, the range will be extended,
  rounded to values like:
  .., 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, ..
This commit is contained in:
Brecht Van Lommel
2009-03-29 18:44:49 +00:00
parent 64f2dd52cb
commit 9b7f44ceb5
7 changed files with 199 additions and 97 deletions

View File

@@ -538,6 +538,8 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
but->editcumap= oldbut->editcumap;
but->selsta= oldbut->selsta;
but->selend= oldbut->selend;
but->softmin= oldbut->softmin;
but->softmax= oldbut->softmax;
found= 1;
oldbut->active= NULL;
@@ -605,6 +607,10 @@ void uiEndBlock(const bContext *C, uiBlock *block)
but->lock = 1;
}
}
/* only update soft range while not editing */
if(but->rnaprop && !(but->editval || but->editstr || but->editvec))
ui_set_but_soft_range(but, ui_get_but_val(but));
}
if(block->oldblock) {
@@ -691,14 +697,14 @@ static void ui_is_but_sel(uiBut *but)
case TOG3:
case BUT_TOGDUAL:
case ICONTOG:
if(value!=but->min) push= 1;
if(value!=but->hardmin) push= 1;
break;
case ICONTOGN:
case TOGN:
if(value==0.0) push= 1;
break;
case ROW:
if(value == but->max) push= 1;
if(value == but->hardmax) push= 1;
break;
case COL:
push= 1;
@@ -733,7 +739,7 @@ static uiBut *ui_get_valid_link_button(uiBlock *block, uiBut *but, short *mval)
}
}
else if(but->type==INLINK && bt->type==LINK) {
if( bt->link->tocode == (int)but->min ) {
if( bt->link->tocode == (int)but->hardmin ) {
return bt;
}
}
@@ -1420,7 +1426,92 @@ void ui_set_but_string(uiBut *but, const char *str)
RNA_property_string_set(&but->rnapoin, but->rnaprop, str);
}
else
BLI_strncpy(but->poin, str, but->max);
BLI_strncpy(but->poin, str, but->hardmax);
}
static double soft_range_round_up(double value, double max)
{
/* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */
double newmax= pow(10.0, ceil(log(value)/log(10.0)));
if(newmax*0.2 >= max && newmax*0.2 >= value)
return newmax*0.2;
else if(newmax*0.5 >= max && newmax*0.5 >= value)
return newmax*0.5;
else
return newmax;
}
static double soft_range_round_down(double value, double max)
{
/* round down to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */
double newmax= pow(10.0, floor(log(value)/log(10.0)));
if(newmax*5.0 <= max && newmax*5.0 <= value)
return newmax*5.0;
else if(newmax*2.0 <= max && newmax*2.0 <= value)
return newmax*2.0;
else
return newmax;
}
void ui_set_but_soft_range(uiBut *but, double value)
{
PropertyType type;
double softmin, softmax, step, precision;
if(but->rnaprop) {
type= RNA_property_type(&but->rnapoin, but->rnaprop);
if(type == PROP_INT) {
int imin, imax, istep;
RNA_property_int_ui_range(&but->rnapoin, but->rnaprop, &imin, &imax, &istep);
softmin= imin;
softmax= imax;
step= istep;
precision= 1;
}
else if(type == PROP_FLOAT) {
float fmin, fmax, fstep, fprecision;
RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision);
softmin= fmin;
softmax= fmax;
step= fstep;
precision= fprecision;
}
else
return;
/* clamp button range to something reasonable in case
* we get -inf/inf from RNA properties */
softmin= MAX2(softmin, -1e4);
softmax= MIN2(softmax, 1e4);
/* if the value goes out of the soft/max range, adapt the range */
if(value+1e-10 < softmin) {
if(value < 0.0)
softmin= -soft_range_round_up(-value, -softmin);
else
softmin= soft_range_round_down(value, softmin);
if(softmin < but->hardmin)
softmin= but->hardmin;
}
else if(value-1e-10 > softmax) {
if(value < 0.0)
softmax= -soft_range_round_down(-value, -softmax);
else
softmax= soft_range_round_up(value, softmax);
if(softmax > but->hardmax)
softmax= but->hardmax;
}
but->softmin= softmin;
but->softmax= softmax;
}
}
/* ******************* Font ********************/
@@ -1681,14 +1772,14 @@ void ui_check_but(uiBut *but)
case NUMSLI:
case HSVSLI:
value= ui_get_but_val(but);
if(value < but->min) ui_set_but_val(but, but->min);
else if(value > but->max) ui_set_but_val(but, but->max);
if(value < but->hardmin) ui_set_but_val(but, but->hardmin);
else if(value > but->hardmax) ui_set_but_val(but, but->hardmax);
break;
case NUMABS:
value= fabs( ui_get_but_val(but) );
if(value < but->min) ui_set_but_val(but, but->min);
else if(value > but->max) ui_set_but_val(but, but->max);
if(value < but->hardmin) ui_set_but_val(but, but->hardmin);
else if(value > but->hardmax) ui_set_but_val(but, but->hardmax);
break;
case ICONTOG:
@@ -1699,12 +1790,12 @@ void ui_check_but(uiBut *but)
case ICONROW:
value= ui_get_but_val(but);
but->iconadd= (int)value- (int)(but->min);
but->iconadd= (int)value- (int)(but->hardmin);
break;
case ICONTEXTROW:
value= ui_get_but_val(but);
but->iconadd= (int)value- (int)(but->min);
but->iconadd= (int)value- (int)(but->hardmin);
break;
}
@@ -1741,7 +1832,7 @@ void ui_check_but(uiBut *but)
else sprintf(but->drawstr, "%s%.4f", but->str, value);
}
else {
if(but->max<10.001) sprintf(but->drawstr, "%s%.3f", but->str, value);
if(but->hardmax<10.001) sprintf(but->drawstr, "%s%.3f", but->str, value);
else sprintf(but->drawstr, "%s%.2f", but->str, value);
}
}
@@ -2133,8 +2224,8 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
but->y2= (y1+y2);
}
but->poin= poin;
but->min= min;
but->max= max;
but->hardmin= but->softmin= min;
but->hardmax= but->softmax= max;
but->a1= a1;
but->a2= a2;
but->tip= tip;
@@ -2267,13 +2358,14 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
if(min == max || a1 == -1 || a2 == -1) {
if(proptype == PROP_INT) {
int softmin, softmax, step;
int hardmin, hardmax, softmin, softmax, step;
RNA_property_int_range(ptr, prop, &hardmin, &hardmax);
RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step);
if(min == max) {
min= softmin;
max= softmax;
min= hardmin;
max= hardmax;
}
if(a1 == -1)
a1= step;
@@ -2281,13 +2373,14 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
a2= 0;
}
else if(proptype == PROP_FLOAT) {
float softmin, softmax, step, precision;
float hardmin, hardmax, softmin, softmax, step, precision;
RNA_property_float_range(ptr, prop, &hardmin, &hardmax);
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
if(min == max) {
min= softmin;
max= softmax;
min= hardmin;
max= hardmax;
}
if(a1 == -1)
a1= step;

View File

@@ -2213,7 +2213,7 @@ void ui_draw_text(uiBut *but, float x, float y, int sunken)
float ypos = (sunken==BUT_TEXT_SUNKEN) ? (y-1) : y;
char *cpoin;
if(but->type==LABEL && but->min!=0.0) {
if(but->type==LABEL && but->hardmin!=0.0) {
UI_ThemeColor(TH_BUT_TEXT_HI);
}
else if(but->dt==UI_EMBOSSP) {
@@ -3122,7 +3122,7 @@ static void ui_draw_roundbox(uiBut *but)
UI_ThemeColorShadeAlpha(but->themecol, but->a2, but->a2);
uiSetRoundBox(but->a1);
gl_round_box(GL_POLYGON, but->x1, but->y1, but->x2, but->y2, but->min);
gl_round_box(GL_POLYGON, but->x1, but->y1, but->x2, but->y2, but->hardmin);
glDisable(GL_BLEND);
}
@@ -3263,7 +3263,7 @@ void ui_draw_but(ARegion *ar, uiBut *but)
y2= but->y2;
value= ui_get_but_val(but);
fac= (value-but->min)*(x2-x1)/(but->max - but->min);
fac= (value-but->softmin)*(x2-x1)/(but->softmax - but->softmin);
but->sliderfunc(but->themecol, fac, but->aspect, x1, y1, x2, y2, but->flag);
ui_draw_text_icon(but);

View File

@@ -101,7 +101,7 @@ typedef struct uiHandleButtonData {
/* edited value */
char *str, *origstr;
double value, origvalue;
double value, origvalue, startvalue;
float vec[3], origvec[3];
int togdual, togonly;
ColorBand *coba;
@@ -300,7 +300,7 @@ static void ui_apply_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data)
static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_set_but_val(but, but->min);
ui_set_but_val(but, but->hardmin);
ui_apply_but_func(C, but);
data->retval= but->retval;
@@ -381,7 +381,7 @@ static void ui_apply_but_TOG(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data)
{
ui_set_but_val(but, but->max);
ui_set_but_val(but, but->hardmax);
ui_apply_but_func(C, but);
data->retval= but->retval;
@@ -426,8 +426,10 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
if(!ui_is_but_float(but)) data->value= (int)data->value;
if(but->type==NUMABS) data->value= fabs(data->value);
if(data->value<but->min) data->value= but->min;
if(data->value>but->max) data->value= but->max;
/* not that we use hard limits here */
if(data->value<but->hardmin) data->value= but->hardmin;
if(data->value>but->hardmax) data->value= but->hardmax;
}
ui_set_but_val(but, data->value);
@@ -1138,7 +1140,7 @@ static void ui_textedit_begin(uiBut *but, uiHandleButtonData *data)
/* retrieve string */
if(but->type == TEX) {
data->maxlen= but->max;
data->maxlen= but->hardmax;
data->str= MEM_callocN(sizeof(char)*(data->maxlen+1), "textedit str");
ui_get_but_string(but, data->str, data->maxlen+1);
@@ -1389,18 +1391,9 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u
/* ************* number editing for various types ************* */
static void but_clamped_range(uiBut *but, float *butmin, float *butmax, float *butrange)
{
/* clamp button range to something reasonable in case
* we get -inf/inf from RNA properties */
*butmin= MAX2(but->min, -1e4f);
*butmax= MIN2(but->max, 1e4f);
*butrange= *butmax - *butmin;
}
static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
{
float butrange, butmin, butmax;
float softrange, softmin, softmax;
if(but->type == BUT_CURVE) {
data->cumap= (CurveMapping*)but->poin;
@@ -1416,13 +1409,16 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
but->editvec= data->vec;
}
else {
data->origvalue= ui_get_but_val(but);
data->startvalue= ui_get_but_val(but);
data->origvalue= data->startvalue;
data->value= data->origvalue;
but->editval= &data->value;
but_clamped_range(but, &butmin, &butmax, &butrange);
softmin= but->softmin;
softmax= but->softmax;
softrange= softmax - softmin;
data->dragfstart= (butrange == 0.0)? 0.0f: (data->value - butmin)/butrange;
data->dragfstart= (softrange == 0.0)? 0.0: (data->value - softmin)/softrange;
data->dragf= data->dragfstart;
}
@@ -1629,7 +1625,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, int snap, int mx)
{
float deler, tempf, butmin, butmax, butrange;
float deler, tempf, softmin, softmax, softrange;
int lvalue, temp, changed= 0;
if(mx == data->draglastx)
@@ -1645,19 +1641,21 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
data->dragstartx= mx; /* ignore mouse movement within drag-lock */
}
but_clamped_range(but, &butmin, &butmax, &butrange);
softmin= but->softmin;
softmax= but->softmax;
softrange= softmax - softmin;
deler= 500;
if(!ui_is_but_float(but)) {
if((butrange)<100) deler= 200.0;
if((butrange)<25) deler= 50.0;
if((softrange)<100) deler= 200.0;
if((softrange)<25) deler= 50.0;
}
deler /= fac;
if(ui_is_but_float(but) && butrange > 11) {
if(ui_is_but_float(but) && softrange > 11) {
/* non linear change in mouse input- good for high precicsion */
data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.002);
} else if (!ui_is_but_float(but) && butrange > 129) { /* only scale large int buttons */
} else if (!ui_is_but_float(but) && softrange > 129) { /* only scale large int buttons */
/* non linear change in mouse input- good for high precicsionm ints need less fine tuning */
data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.004);
} else {
@@ -1668,51 +1666,50 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
if(data->dragf>1.0) data->dragf= 1.0;
if(data->dragf<0.0) data->dragf= 0.0;
data->draglastx= mx;
tempf= (butmin + data->dragf*butrange);
tempf= (softmin + data->dragf*softrange);
if(!ui_is_but_float(but)) {
temp= floor(tempf+.5);
if(tempf==but->min || tempf==but->max);
if(tempf==softmin || tempf==softmax);
else if(snap) {
if(snap == 2) temp= 100*(temp/100);
else temp= 10*(temp/10);
}
if( temp>=but->min && temp<=but->max) {
lvalue= (int)data->value;
if(temp != lvalue ) {
data->dragchange= 1;
data->value= (double)temp;
changed= 1;
}
}
CLAMP(temp, softmin, softmax);
lvalue= (int)data->value;
if(temp != lvalue) {
data->dragchange= 1;
data->value= (double)temp;
changed= 1;
}
}
else {
temp= 0;
if(snap) {
if(snap == 2) {
if(tempf==but->min || tempf==but->max);
else if(butrange < 2.10) tempf= 0.01*floor(100.0*tempf);
else if(butrange < 21.0) tempf= 0.1*floor(10.0*tempf);
if(tempf==softmin || tempf==softmax);
else if(softrange < 2.10) tempf= 0.01*floor(100.0*tempf);
else if(softrange < 21.0) tempf= 0.1*floor(10.0*tempf);
else tempf= floor(tempf);
}
else {
if(tempf==but->min || tempf==but->max);
else if(butrange < 2.10) tempf= 0.1*floor(10*tempf);
else if(butrange < 21.0) tempf= floor(tempf);
if(tempf==softmin || tempf==softmax);
else if(softrange < 2.10) tempf= 0.1*floor(10*tempf);
else if(softrange < 21.0) tempf= floor(tempf);
else tempf= 10.0*floor(tempf/10.0);
}
}
if( tempf>=but->min && tempf<=but->max) {
if(tempf != data->value) {
data->dragchange= 1;
data->value= tempf;
changed= 1;
}
CLAMP(tempf, softmin, softmax);
if(tempf != data->value) {
data->dragchange= 1;
data->value= tempf;
changed= 1;
}
}
@@ -1786,15 +1783,18 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
if(click) {
/* we can click on the side arrows to increment/decrement,
* or click inside to edit the value directly */
float tempf;
float tempf, softmin, softmax;
int temp;
softmin= but->softmin;
softmax= but->softmax;
if(!ui_is_but_float(but)) {
if(mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp= (int)data->value - 1;
if(temp>=but->min && temp<=but->max)
if(temp>=softmin && temp<=softmax)
data->value= (double)temp;
else
data->cancel= 1;
@@ -1805,7 +1805,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp= (int)data->value + 1;
if(temp>=but->min && temp<=but->max)
if(temp>=softmin && temp<=softmax)
data->value= (double)temp;
else
data->cancel= 1;
@@ -1820,7 +1820,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf= data->value - 0.01*but->a1;
if (tempf < but->min) tempf = but->min;
if (tempf < softmin) tempf = softmin;
data->value= tempf;
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -1829,7 +1829,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf= data->value + 0.01*but->a1;
if (tempf < but->min) tempf = but->min;
if (tempf > softmax) tempf = softmax;
data->value= tempf;
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -1846,10 +1846,12 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, int ctrl, int mx)
{
float deler, f, tempf, butmin, butmax, butrange;
float deler, f, tempf, softmin, softmax, softrange;
int temp, lvalue, changed= 0;
but_clamped_range(but, &butmin, &butmax, &butrange);
softmin= but->softmin;
softmax= but->softmax;
softrange= softmax - softmin;
if(but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0*but->aspect);
else if(but->type==HSVSLI) deler= ((but->x2-but->x1)/2 - 5.0*but->aspect);
@@ -1861,22 +1863,22 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
f= (f-data->dragfstart)/10.0 + data->dragfstart;
CLAMP(f, 0.0, 1.0);
tempf= butmin + f*butrange;
tempf= softmin + f*softrange;
temp= floor(tempf+.5);
if(ctrl) {
if(tempf==but->min || tempf==but->max);
if(tempf==softmin || tempf==softmax);
else if(ui_is_but_float(but)) {
if(shift) {
if(tempf==but->min || tempf==but->max);
else if(but->max-but->min < 2.10) tempf= 0.01*floor(100.0*tempf);
else if(but->max-but->min < 21.0) tempf= 0.1*floor(10.0*tempf);
if(tempf==softmin || tempf==softmax);
else if(softmax-softmin < 2.10) tempf= 0.01*floor(100.0*tempf);
else if(softmax-softmin < 21.0) tempf= 0.1*floor(10.0*tempf);
else tempf= floor(tempf);
}
else {
if(but->max-but->min < 2.10) tempf= 0.1*floor(10*tempf);
else if(but->max-but->min < 21.0) tempf= floor(tempf);
if(softmax-softmin < 2.10) tempf= 0.1*floor(10*tempf);
else if(softmax-softmin < 21.0) tempf= floor(tempf);
else tempf= 10.0*floor(tempf/10.0);
}
}
@@ -1889,6 +1891,8 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
if(!ui_is_but_float(but)) {
lvalue= floor(data->value+0.5);
CLAMP(temp, softmin, softmax);
if(temp != lvalue) {
data->value= temp;
data->dragchange= 1;
@@ -1896,6 +1900,8 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
}
}
else {
CLAMP(tempf, softmin, softmax);
if(tempf != data->value) {
data->value= tempf;
data->dragchange= 1;
@@ -1956,13 +1962,14 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
if(click) {
if (event->ctrl) {
/* nudge slider to the left or right */
float f;
float tempf, butmin, butmax, butrange;
float f, tempf, softmin, softmax, softrange;
int temp;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
but_clamped_range(but, &butmin, &butmax, &butrange);
softmin= but->softmin;
softmax= but->softmax;
softrange= softmax - softmin;
tempf= data->value;
temp= (int)data->value;
@@ -1970,13 +1977,13 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
if(but->type==SLI) f= (float)(mx-but->x1)/(but->x2-but->x1);
else f= (float)(mx- but->x1)/(but->x2-but->x1);
f= butmin + f*butrange;
f= softmin + f*softrange;
if(!ui_is_but_float(but)) {
if(f<temp) temp--;
else temp++;
if(temp>=but->min && temp<=but->max)
if(temp>=softmin && temp<=softmax)
data->value= temp;
else
data->cancel= 1;
@@ -1985,7 +1992,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
if(f<tempf) tempf-=.01;
else tempf+=.01;
if(tempf>=but->min && tempf<=but->max)
if(tempf>=softmin && tempf<=softmax)
data->value= tempf;
else
data->cancel= 1;

View File

@@ -117,7 +117,7 @@ struct uiBut {
float x1, y1, x2, y2;
char *poin;
float min, max;
float hardmin, hardmax, softmin, softmax;
float a1, a2, hsv[3]; // hsv is temp memory for hsv buttons
float aspect;
@@ -261,6 +261,8 @@ extern void ui_set_but_vectorf(uiBut *but, float *vec);
extern void ui_get_but_string(uiBut *but, char *str, int maxlen);
extern void ui_set_but_string(uiBut *but, const char *str);
extern void ui_set_but_soft_range(uiBut *but, double value);
extern void ui_check_but(uiBut *but);
extern void ui_autofill(uiBlock *block);
extern int ui_is_but_float(uiBut *but);

View File

@@ -843,8 +843,8 @@ uiBlock *ui_block_func_ICONROW(bContext *C, uiPopupBlockHandle *handle, void *ar
block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT;
block->themecol= TH_MENU_ITEM;
for(a=(int)but->min; a<=(int)but->max; a++) {
uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->min), 0, (short)(18*a), (short)(but->x2-but->x1-4), 18, &handle->retvalue, (float)a, 0.0, 0, 0, "");
for(a=(int)but->hardmin; a<=(int)but->hardmax; a++) {
uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->hardmin), 0, (short)(18*a), (short)(but->x2-but->x1-4), 18, &handle->retvalue, (float)a, 0.0, 0, 0, "");
}
block->direction= UI_TOP;
@@ -892,7 +892,7 @@ uiBlock *ui_block_func_ICONTEXTROW(bContext *C, uiPopupBlockHandle *handle, void
ypos +=3;
}
else {
uiDefIconTextButF(block, BUTM|FLO, B_NOP, (short)((but->icon)+(md->items[a].retval-but->min)), md->items[a].str, 0, ypos,(short)width, 19, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, "");
uiDefIconTextButF(block, BUTM|FLO, B_NOP, (short)((but->icon)+(md->items[a].retval-but->hardmin)), md->items[a].str, 0, ypos,(short)width, 19, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, "");
ypos += 20;
}
}

View File

@@ -1148,7 +1148,7 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const
iprop->softmax= 10000;
}
if(prop->subtype == PROP_UNSIGNED)
if(prop->subtype == PROP_UNSIGNED || prop->subtype == PROP_PERCENTAGE)
iprop->hardmin= iprop->softmin= 0;
}
}

View File

@@ -224,7 +224,7 @@ void rna_def_scene_render_data(BlenderRNA *brna)
prop= RNA_def_property(srna, "resolution_percentage", PROP_INT, PROP_PERCENTAGE);
RNA_def_property_int_sdna(prop, NULL, "size");
RNA_def_property_range(prop, 1, 400);
RNA_def_property_ui_range(prop, 1, 100, 10, 1);
RNA_def_property_ui_text(prop, "Resolution %", "Preview scale for render resolution");
prop= RNA_def_property(srna, "parts_x", PROP_INT, PROP_NONE);