Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show First 20 Lines • Show All 3,069 Lines • ▼ Show 20 Lines | if (newmax * 5.0 <= max && newmax * 5.0 <= value) { | ||||
| return newmax * 5.0; | return newmax * 5.0; | ||||
| } | } | ||||
| if (newmax * 2.0 <= max && newmax * 2.0 <= value) { | if (newmax * 2.0 <= max && newmax * 2.0 <= value) { | ||||
| return newmax * 2.0; | return newmax * 2.0; | ||||
| } | } | ||||
| return newmax; | return newmax; | ||||
| } | } | ||||
| void UI_but_set_hard_range(uiBut *but) | |||||
| { | |||||
| if (but->rnaprop) { | |||||
| const PropertyType type = RNA_property_type(but->rnaprop); | |||||
| double hardmin, hardmax; | |||||
| if (type == PROP_INT) { | |||||
| int imin, imax; | |||||
| RNA_property_int_range(&but->rnapoin, but->rnaprop, &imin, &imax); | |||||
| hardmin = (imin == INT_MIN) ? -1e4 : imin; | |||||
| hardmax = (imin == INT_MAX) ? 1e4 : imax; | |||||
HooglyBoogly: I see this clamping comes from the soft range setting below, but I'm not sure it makes sense… | |||||
lichtwerkAuthorUnsubmitted Not Done Inline ActionsAlso not sure when -inf/inf from RNA properties can happen (but in that case seems to make sense, no?) lichtwerk: Also not sure when -inf/inf from RNA properties can happen (but in that case seems to make… | |||||
HooglyBooglyUnsubmitted Not Done Inline ActionsHmm, to me it looked like this would reset the hard max to 10 000 if it was set to INT_MAX. But I tested with the taa_samples property then tabbing to taa_render_samples, and that didn't happen, so I guess I'm missing something. HooglyBoogly: Hmm, to me it looked like this would reset the hard max to `10 000` if it was set to `INT_MAX`. | |||||
| } | |||||
| else if (type == PROP_FLOAT) { | |||||
| float fmin, fmax; | |||||
| RNA_property_float_range(&but->rnapoin, but->rnaprop, &fmin, &fmax); | |||||
| hardmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin; | |||||
| hardmax = (fmax == FLT_MAX) ? (float)1e4 : fmax; | |||||
| } | |||||
| else { | |||||
| return; | |||||
| } | |||||
| but->hardmin = hardmin; | |||||
| but->hardmax = hardmax; | |||||
| } | |||||
| } | |||||
| /* 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 */ | ||||
| static void ui_set_but_soft_range(uiBut *but) | void UI_but_set_soft_range(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 | ||||
| * which isn't so bad. */ | * which isn't so bad. */ | ||||
| if (but->rnaprop) { | if (but->rnaprop) { | ||||
| const PropertyType type = RNA_property_type(but->rnaprop); | const PropertyType type = RNA_property_type(but->rnaprop); | ||||
| double softmin, softmax /*, step, precision*/; | double softmin, softmax /*, step, precision*/; | ||||
| ▲ Show 20 Lines • Show All 387 Lines • ▼ Show 20 Lines | static void ui_but_update_ex(uiBut *but, const bool validate) | ||||
| /* if something changed in the button */ | /* if something changed in the button */ | ||||
| double value = UI_BUT_VALUE_UNSET; | double value = UI_BUT_VALUE_UNSET; | ||||
| ui_but_update_select_flag(but, &value); | ui_but_update_select_flag(but, &value); | ||||
| /* only update soft range while not editing */ | /* only update soft range while not editing */ | ||||
| if (!ui_but_is_editing(but)) { | if (!ui_but_is_editing(but)) { | ||||
| if ((but->rnaprop != NULL) || (but->poin && (but->pointype & UI_BUT_POIN_TYPES))) { | if ((but->rnaprop != NULL) || (but->poin && (but->pointype & UI_BUT_POIN_TYPES))) { | ||||
| ui_set_but_soft_range(but); | UI_but_set_soft_range(but); | ||||
| } | } | ||||
| } | } | ||||
| /* test for min and max, icon sliders, etc */ | /* test for min and max, icon sliders, etc */ | ||||
| switch (but->type) { | switch (but->type) { | ||||
| case UI_BTYPE_NUM: | case UI_BTYPE_NUM: | ||||
| case UI_BTYPE_SCROLL: | case UI_BTYPE_SCROLL: | ||||
| case UI_BTYPE_NUM_SLIDER: | case UI_BTYPE_NUM_SLIDER: | ||||
| ▲ Show 20 Lines • Show All 3,305 Lines • Show Last 20 Lines | |||||
I see this clamping comes from the soft range setting below, but I'm not sure it makes sense for the hard range.