From 91ec8d8d1ebbcfb00fa6eb711513a98238903d70 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 May 2015 09:43:06 +1000 Subject: UI: multi-value-editing, copy value when typed in --- .../blender/editors/interface/interface_handlers.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/interface/interface_handlers.c') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index cfa31c8ef35..8e3cc08feee 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -176,6 +176,11 @@ typedef struct uiSelectContextStore { int elems_len; bool do_free; bool is_enabled; + /* When set, simply copy values (don't apply difference). + * Rules are: + * - dragging numbers uses delta. + * - typing in values will assign to all. */ + bool is_copy; } uiSelectContextStore; static bool ui_selectcontext_begin( @@ -1433,6 +1438,7 @@ static void ui_selectcontext_apply( PropertyRNA *lprop = but->rnaprop; int index = but->rnaindex; int i; + const bool use_delta = (selctx_data->is_copy == false); union { bool b; @@ -1444,10 +1450,10 @@ static void ui_selectcontext_apply( const int rna_type = RNA_property_type(prop); if (rna_type == PROP_FLOAT) { - delta.f = value - value_orig; + delta.f = use_delta ? (value - value_orig) : value; } else if (rna_type == PROP_INT) { - delta.i = (int)value - (int)value_orig; + delta.i = use_delta ? ((int)value - (int)value_orig) : (int)value; } else if (rna_type == PROP_ENUM) { delta.i = RNA_property_enum_get(&but->rnapoin, prop); /* not a delta infact */ @@ -1466,10 +1472,10 @@ static void ui_selectcontext_apply( PointerRNA lptr = other->ptr; if (is_array) { if (rna_type == PROP_FLOAT) { - RNA_property_float_set_index(&lptr, lprop, index, other->val_f + delta.f); + RNA_property_float_set_index(&lptr, lprop, index, use_delta ? (other->val_f + delta.f) : delta.f); } else if (rna_type == PROP_INT) { - RNA_property_int_set_index(&lptr, lprop, index, other->val_i + delta.i); + RNA_property_int_set_index(&lptr, lprop, index, use_delta ? (other->val_i + delta.i) : delta.i); } else if (rna_type == PROP_BOOLEAN) { RNA_property_boolean_set_index(&lptr, lprop, index, delta.b); @@ -1477,10 +1483,10 @@ static void ui_selectcontext_apply( } else { if (rna_type == PROP_FLOAT) { - RNA_property_float_set(&lptr, lprop, other->val_f + delta.f); + RNA_property_float_set(&lptr, lprop, use_delta ? (other->val_f + delta.f) : delta.f); } else if (rna_type == PROP_INT) { - RNA_property_int_set(&lptr, lprop, other->val_i + delta.i); + RNA_property_int_set(&lptr, lprop, use_delta ? (other->val_i + delta.i) : delta.i); } else if (rna_type == PROP_BOOLEAN) { RNA_property_boolean_set(&lptr, lprop, delta.b); @@ -2820,6 +2826,8 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) if (is_num_but) { if (IS_ALLSELECT_EVENT(win->eventstate)) { data->select_others.is_enabled = true; + data->select_others.is_copy = true; + } } #endif -- cgit v1.2.3