Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show First 20 Lines • Show All 3,201 Lines • ▼ Show 20 Lines | |||||
| void ui_but_range_set_hard(uiBut *but) | void ui_but_range_set_hard(uiBut *but) | ||||
| { | { | ||||
| if (but->rnaprop == NULL) { | if (but->rnaprop == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| const PropertyType type = RNA_property_type(but->rnaprop); | const PropertyType type = RNA_property_type(but->rnaprop); | ||||
| /* clamp button range to something reasonable in case | |||||
| * we get -inf/inf from RNA properties */ | |||||
| if (type == PROP_INT) { | if (type == PROP_INT) { | ||||
| int imin, imax; | int imin, imax; | ||||
| RNA_property_int_range(&but->rnapoin, but->rnaprop, &imin, &imax); | RNA_property_int_range(&but->rnapoin, but->rnaprop, &imin, &imax); | ||||
| but->hardmin = (imin == INT_MIN) ? -1e4 : imin; | but->hardmin = imin; | ||||
| but->hardmax = (imin == INT_MAX) ? 1e4 : imax; | but->hardmax = imax; | ||||
| } | } | ||||
| else if (type == PROP_FLOAT) { | else if (type == PROP_FLOAT) { | ||||
| float fmin, fmax; | float fmin, fmax; | ||||
| RNA_property_float_range(&but->rnapoin, but->rnaprop, &fmin, &fmax); | RNA_property_float_range(&but->rnapoin, but->rnaprop, &fmin, &fmax); | ||||
| but->hardmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin; | but->hardmin = fmin; | ||||
| but->hardmax = (fmax == FLT_MAX) ? (float)1e4 : fmax; | but->hardmax = fmax; | ||||
| } | } | ||||
| } | } | ||||
| /* note: this could be split up into functions which handle arrays and not */ | /* note: this could be split up into functions which handle arrays and not */ | ||||
| void ui_but_range_set_soft(uiBut *but) | void ui_but_range_set_soft(uiBut *but) | ||||
| { | { | ||||
| /* ideally we would not limit this but practically, its more than | /* ideally we would not limit this but practically, its more than | ||||
| * enough worst case is very long vectors wont use a smart soft-range | * enough worst case is very long vectors wont use a smart soft-range | ||||
| ▲ Show 20 Lines • Show All 3,915 Lines • Show Last 20 Lines | |||||