Fix T62120: number button editing outside of soft max range jumps.

This commit is contained in:
Brecht Van Lommel 2019-03-14 18:27:17 +01:00
parent 7b38ad7286
commit 57b5852bc8
Notes: blender-bot 2023-02-14 08:25:14 +01:00
Referenced by issue #62120, broken slider widget
3 changed files with 9 additions and 3 deletions

View File

@ -2888,7 +2888,7 @@ void UI_block_theme_style_set(uiBlock *block, char theme_style)
* \param validate: When set, this function may change the button value.
* Otherwise treat the button value as read-only.
*/
void ui_but_update_ex(uiBut *but, const bool validate)
static void ui_but_update_ex(uiBut *but, const bool validate)
{
/* if something changed in the button */
double value = UI_BUT_VALUE_UNSET;
@ -2897,7 +2897,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
ui_but_update_select_flag(but, &value);
/* only update soft range while not editing */
if (!(but->editval || but->editstr || but->editvec)) {
if (!ui_but_is_editing(but)) {
if ((but->rnaprop != NULL) ||
(but->poin && (but->pointype & UI_BUT_POIN_TYPES)))
{

View File

@ -6934,6 +6934,12 @@ bool ui_but_is_active(ARegion *ar)
return (ui_but_find_active_in_region(ar) != NULL);
}
bool ui_but_is_editing(uiBut *but)
{
uiHandleButtonData *data = but->active;
return (data && ELEM(data->state, BUTTON_STATE_TEXT_EDITING, BUTTON_STATE_NUM_EDITING));
}
/* is called by notifier */
void UI_screen_free_active_but(const bContext *C, bScreen *screen)
{

View File

@ -508,7 +508,6 @@ extern uiButExtraIconType ui_but_icon_extra_get(uiBut *but);
extern void ui_but_default_set(struct bContext *C, const bool all, const bool use_afterfunc);
extern void ui_but_update_ex(uiBut *but, const bool validate);
extern void ui_but_update(uiBut *but);
extern void ui_but_update_edited(uiBut *but);
extern bool ui_but_is_float(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
@ -687,6 +686,7 @@ extern void ui_but_execute_begin(struct bContext *C, struct ARegion *ar, uiBut *
extern void ui_but_execute_end(struct bContext *C, struct ARegion *ar, uiBut *but, void *active_back);
extern void ui_but_active_free(const struct bContext *C, uiBut *but);
extern bool ui_but_is_active(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT;
extern bool ui_but_is_editing(uiBut *but);
extern int ui_but_menu_direction(uiBut *but);
extern void ui_but_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, const bool restore);
extern uiBut *ui_but_find_select_in_enum(uiBut *but, int direction);