diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2016-09-18 22:36:34 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2016-09-18 22:44:42 +0300 |
commit | 572bc1364ca9d978edf5aee991849dd4f8e56a52 (patch) | |
tree | 61e965068f2d6bc835ecb8bd0ffe29709c9f5c1d /source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp | |
parent | 6c28d3bac26b22049768824bef6ae9d0e82bb71f (diff) |
BLI_listbase: Add/use utility to move link (BLI_listbase_link_move)
We were calling BLI_remlink and then BLI_insertlinkbefore/after quite often. BLI_listbase_link_move simplifies code a bit and makes it easier to follow. It also returns if link position has changed which can be used to avoid unnecessary updates.
Added it to a number of list reorder operators for now and made use of return value. Behavior shouldn't be changed.
Also some minor cleanup.
Diffstat (limited to 'source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp')
-rw-r--r-- | source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 4d8c6a66d42..2af4447e4dc 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -730,24 +730,14 @@ void FRS_delete_active_lineset(FreestyleConfig *config) } } -void FRS_move_active_lineset_up(FreestyleConfig *config) -{ - FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config); - - if (lineset) { - BLI_remlink(&config->linesets, lineset); - BLI_insertlinkbefore(&config->linesets, lineset->prev, lineset); - } -} - -void FRS_move_active_lineset_down(FreestyleConfig *config) +/** + * Reinsert the active lineset at an offset \a direction from current position. + * \return if position of active lineset has changed. + */ +bool FRS_move_active_lineset(FreestyleConfig *config, int direction) { FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config); - - if (lineset) { - BLI_remlink(&config->linesets, lineset); - BLI_insertlinkafter(&config->linesets, lineset->next, lineset); - } + return (lineset != NULL) && BLI_listbase_link_move(&config->linesets, lineset, direction); } // Testing |