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:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-09-04 22:09:57 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-09-04 22:38:33 +0300
commit36e23c95e8f341883fdb5e0933e9430b9f7bdb41 (patch)
treedcc711f6108f5db67121f8ae9be3f7f4e22a706f /source/blender/blenlib/intern/listbase.c
parente52ad1835a6aaefab389b173728b9bb7ef2e754a (diff)
Python API: add methods for reordering constraints.
Order matters for constraints, but there was no way to change it. The API follows other collections like idprops and node sockets.
Diffstat (limited to 'source/blender/blenlib/intern/listbase.c')
-rw-r--r--source/blender/blenlib/intern/listbase.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index 31d372945c6..631978f60fe 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -504,6 +504,27 @@ bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step)
}
/**
+ * Move the link at the index \a from to the position at index \a to.
+ *
+ * @return If the move was successful.
+ */
+bool BLI_listbase_move_index(ListBase *listbase, int from, int to)
+{
+ if (from == to) {
+ return false;
+ }
+
+ /* Find the link to move. */
+ void *link = BLI_findlink(listbase, from);
+
+ if (!link) {
+ return false;
+ }
+
+ return BLI_listbase_link_move(listbase, link, to - from);
+}
+
+/**
* Removes and disposes of the entire contents of listbase using direct free(3).
*/
void BLI_freelist(ListBase *listbase)