Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Craddock <nzcraddock@gmail.com>2020-09-15 23:56:13 +0300
committerNathan Craddock <nzcraddock@gmail.com>2020-09-16 00:29:19 +0300
commita6434ff4170b8a45228de688894b5b12185dc617 (patch)
tree31f25c17a221815bd53bbe99b3f8aa91ff318009 /source/blender
parent18701c19fa91572cb44643de31853335a6737925 (diff)
Cleanup: Extract editor function from constraint_move_to_index_exec
No functional changes. Move the constraint reordering logic into an ED_ level function to be used by outliner constraint drag and drop. Differential Revision: https://developer.blender.org/D8642
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/include/ED_object.h3
-rw-r--r--source/blender/editors/object/object_constraint.c23
2 files changed, 19 insertions, 7 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 8762ac6d0bb..282df25172f 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -343,6 +343,9 @@ void ED_object_constraint_dependency_tag_update(struct Main *bmain,
struct Object *ob,
struct bConstraint *con);
+bool ED_object_constraint_move_to_index(struct Object *ob,
+ struct bConstraint *con,
+ const int index);
/* object_modes.c */
bool ED_object_mode_compat_test(const struct Object *ob, eObjectMode mode);
bool ED_object_mode_compat_set(struct bContext *C,
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 85522209e29..f0a320e42cf 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1421,6 +1421,21 @@ void ED_object_constraint_dependency_tag_update(Main *bmain, Object *ob, bConstr
DEG_relations_tag_update(bmain);
}
+bool ED_object_constraint_move_to_index(Object *ob, bConstraint *con, const int index)
+{
+ BLI_assert(con != NULL);
+ BLI_assert(index >= 0);
+
+ ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL);
+ int current_index = BLI_findindex(conlist, con);
+ BLI_assert(current_index >= 0);
+
+ BLI_listbase_link_move(conlist, con, index - current_index);
+
+ WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT, ob);
+
+ return true;
+}
/** \} */
/* ------------------------------------------------------------------- */
@@ -1613,13 +1628,7 @@ static int constraint_move_to_index_exec(bContext *C, wmOperator *op)
}
if (con) {
- ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL);
- int current_index = BLI_findindex(conlist, con);
- BLI_assert(current_index >= 0);
-
- BLI_listbase_link_move(conlist, con, new_index - current_index);
-
- WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
+ ED_object_constraint_move_to_index(ob, con, new_index);
return OPERATOR_FINISHED;
}