diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-04 22:09:57 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-04 22:38:33 +0300 |
commit | 36e23c95e8f341883fdb5e0933e9430b9f7bdb41 (patch) | |
tree | dcc711f6108f5db67121f8ae9be3f7f4e22a706f /source/blender/blenlib/intern/listbase.c | |
parent | e52ad1835a6aaefab389b173728b9bb7ef2e754a (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.c | 21 |
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) |