Merge branch 'blender-v2.90-release'
This commit is contained in:
@@ -3092,8 +3092,38 @@ static double soft_range_round_down(double value, double max)
|
|||||||
return newmax;
|
return newmax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ui_but_range_set_hard(uiBut *but)
|
||||||
|
{
|
||||||
|
if (but->rnaprop) {
|
||||||
|
const PropertyType type = RNA_property_type(but->rnaprop);
|
||||||
|
double hardmin, hardmax;
|
||||||
|
|
||||||
|
/* clamp button range to something reasonable in case
|
||||||
|
* we get -inf/inf from RNA properties */
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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_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
|
||||||
@@ -3497,7 +3527,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
|
|||||||
/* 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_range_set_soft(but);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8900,6 +8900,11 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
|
|||||||
|
|
||||||
/* for jumping to the next button with tab while text editing */
|
/* for jumping to the next button with tab while text editing */
|
||||||
if (post_but) {
|
if (post_but) {
|
||||||
|
/* The post_but still has previous ranges (without the changes in active button considered),
|
||||||
|
* needs refreshing the ranges. */
|
||||||
|
ui_but_range_set_soft(post_but);
|
||||||
|
ui_but_range_set_hard(post_but);
|
||||||
|
|
||||||
button_activate_init(C, region, post_but, post_type);
|
button_activate_init(C, region, post_but, post_type);
|
||||||
}
|
}
|
||||||
else if (!((event->type == EVT_BUT_CANCEL) && (event->val == 1))) {
|
else if (!((event->type == EVT_BUT_CANCEL) && (event->val == 1))) {
|
||||||
|
@@ -537,6 +537,9 @@ extern void ui_but_rna_menu_convert_to_panel_type(struct uiBut *but, const char
|
|||||||
extern void ui_but_rna_menu_convert_to_menu_type(struct uiBut *but, const char *menu_type);
|
extern void ui_but_rna_menu_convert_to_menu_type(struct uiBut *but, const char *menu_type);
|
||||||
extern bool ui_but_menu_draw_as_popover(const uiBut *but);
|
extern bool ui_but_menu_draw_as_popover(const uiBut *but);
|
||||||
|
|
||||||
|
void ui_but_range_set_hard(uiBut *but);
|
||||||
|
void ui_but_range_set_soft(uiBut *but);
|
||||||
|
|
||||||
extern void ui_but_update(uiBut *but);
|
extern void ui_but_update(uiBut *but);
|
||||||
extern void ui_but_update_edited(uiBut *but);
|
extern void ui_but_update_edited(uiBut *but);
|
||||||
extern bool ui_but_is_float(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
extern bool ui_but_is_float(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
Reference in New Issue
Block a user