diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2021-12-16 15:03:39 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2021-12-16 15:18:19 +0300 |
commit | 6da23db5e0def6909797374a0689afa2b3f8d96f (patch) | |
tree | 6fba8876b40e8e8bee47286ebae6d173b5df0b01 /source/blender/editors/interface/interface_handlers.c | |
parent | 3e04d37529437255764610b52a9dfe4666ddec15 (diff) |
UI: deduplicate code for Copy To Selected and Alt-button tweaking
This resolves an old TODO to deduplicate code in copy_to_selected_button
& ui_selectcontext_begin.
This is also in hindsight of adding id-property support [incl. Geometry
Nodes modifier properties] for this in the next commit.
No behavior change expected here.
ref T93983 & D13573
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 88 |
1 files changed, 34 insertions, 54 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index f947572f41b..d720b52a59e 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1787,7 +1787,7 @@ static bool ui_but_is_drag_toggle(const uiBut *but) static bool ui_selectcontext_begin(bContext *C, uiBut *but, uiSelectContextStore *selctx_data) { - PointerRNA lptr, idptr; + PointerRNA lptr; PropertyRNA *lprop; bool success = false; @@ -1821,68 +1821,48 @@ static bool ui_selectcontext_begin(bContext *C, uiBut *but, uiSelectContextStore if (i >= selctx_data->elems_len) { break; } + + if (!UI_context_copy_to_selected_check( + &ptr, &link->ptr, prop, path, use_path_from_id, &lptr, &lprop)) { + selctx_data->elems_len -= 1; + i -= 1; + continue; + } + uiSelectContextElem *other = &selctx_data->elems[i]; - /* TODO: de-duplicate copy_to_selected_button. */ - if (link->ptr.data != ptr.data) { - if (use_path_from_id) { - /* Path relative to ID. */ - lprop = NULL; - RNA_id_pointer_create(link->ptr.owner_id, &idptr); - RNA_path_resolve_property(&idptr, path, &lptr, &lprop); - } - else if (path) { - /* Path relative to elements from list. */ - lprop = NULL; - RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop); + other->ptr = lptr; + if (is_array) { + if (rna_type == PROP_FLOAT) { + other->val_f = RNA_property_float_get_index(&lptr, lprop, index); } - else { - lptr = link->ptr; - lprop = prop; + else if (rna_type == PROP_INT) { + other->val_i = RNA_property_int_get_index(&lptr, lprop, index); } - - /* lptr might not be the same as link->ptr! */ - if ((lptr.data != ptr.data) && (lprop == prop) && RNA_property_editable(&lptr, lprop)) { - other->ptr = lptr; - if (is_array) { - if (rna_type == PROP_FLOAT) { - other->val_f = RNA_property_float_get_index(&lptr, lprop, index); - } - else if (rna_type == PROP_INT) { - other->val_i = RNA_property_int_get_index(&lptr, lprop, index); - } - /* ignored for now */ + /* ignored for now */ # if 0 - else if (rna_type == PROP_BOOLEAN) { - other->val_b = RNA_property_boolean_get_index(&lptr, lprop, index); - } -# endif + else if (rna_type == PROP_BOOLEAN) { + other->val_b = RNA_property_boolean_get_index(&lptr, lprop, index); } - else { - if (rna_type == PROP_FLOAT) { - other->val_f = RNA_property_float_get(&lptr, lprop); - } - else if (rna_type == PROP_INT) { - other->val_i = RNA_property_int_get(&lptr, lprop); - } - /* ignored for now */ -# if 0 - else if (rna_type == PROP_BOOLEAN) { - other->val_b = RNA_property_boolean_get(&lptr, lprop); - } - else if (rna_type == PROP_ENUM) { - other->val_i = RNA_property_enum_get(&lptr, lprop); - } # endif - } - - continue; + } + else { + if (rna_type == PROP_FLOAT) { + other->val_f = RNA_property_float_get(&lptr, lprop); } + else if (rna_type == PROP_INT) { + other->val_i = RNA_property_int_get(&lptr, lprop); + } + /* ignored for now */ +# if 0 + else if (rna_type == PROP_BOOLEAN) { + other->val_b = RNA_property_boolean_get(&lptr, lprop); + } + else if (rna_type == PROP_ENUM) { + other->val_i = RNA_property_enum_get(&lptr, lprop); + } +# endif } - - selctx_data->elems_len -= 1; - i -= 1; } - success = (selctx_data->elems_len != 0); } } |