Fix T43111: Node Editor (Slider) Draw Glitch

* don't allow Node Editor input max value to be less then min value
* avoid the num slider drawing glitch if softmin equals softmax
* assert if softmax/hardmax is smaller than softmin/hardmin

With this, we sort of allow softmin/hardmin and softmax/hardmax being the same.
This commit is contained in:
julianeisel 2015-01-05 21:05:17 +01:00
parent 22ce525bcd
commit e7a9bf88d2
Notes: blender-bot 2023-02-14 09:40:08 +01:00
Referenced by issue #43111, node editor (slider) draw glitch
3 changed files with 20 additions and 2 deletions

View File

@ -2603,6 +2603,10 @@ void ui_but_update(uiBut *but)
}
}
/* max must never be smaller than min! Both being equal is allowed though */
BLI_assert(but->softmin <= but->softmax &&
but->hardmin <= but->hardmax);
/* test for min and max, icon sliders, etc */
switch (but->type) {
case UI_BTYPE_NUM:

View File

@ -2874,7 +2874,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
uiWidgetBase wtb, wtb1;
rcti rect1;
double value;
float offs, toffs, fac;
float offs, toffs, fac = 0;
char outline[3];
widget_init(&wtb);
@ -2905,7 +2905,9 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
rect1 = *rect;
value = ui_but_value_get(but);
fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin);
if ((but->softmax - but->softmin) > 0) {
fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin);
}
/* left part of slider, always rounded */
rect1.xmax = rect1.xmin + ceil(offs + U.pixelsize);

View File

@ -2199,6 +2199,10 @@ static void rna_NodeSocketStandard_float_range(PointerRNA *ptr, float *min, floa
bNodeSocketValueFloat *dval = sock->default_value;
int subtype = sock->typeinfo->subtype;
if (dval->max < dval->min) {
dval->max = dval->min;
}
*min = (subtype == PROP_UNSIGNED ? 0.0f : -FLT_MAX);
*max = FLT_MAX;
*softmin = dval->min;
@ -2211,6 +2215,10 @@ static void rna_NodeSocketStandard_int_range(PointerRNA *ptr, int *min, int *max
bNodeSocketValueInt *dval = sock->default_value;
int subtype = sock->typeinfo->subtype;
if (dval->max < dval->min) {
dval->max = dval->min;
}
*min = (subtype == PROP_UNSIGNED ? 0 : INT_MIN);
*max = INT_MAX;
*softmin = dval->min;
@ -2222,6 +2230,10 @@ static void rna_NodeSocketStandard_vector_range(PointerRNA *ptr, float *min, flo
bNodeSocket *sock = ptr->data;
bNodeSocketValueVector *dval = sock->default_value;
if (dval->max < dval->min) {
dval->max = dval->min;
}
*min = -FLT_MAX;
*max = FLT_MAX;
*softmin = dval->min;