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:
authorJulian Eisel <eiseljulian@gmail.com>2016-09-18 22:36:34 +0300
committerJulian Eisel <eiseljulian@gmail.com>2016-09-18 22:44:42 +0300
commit572bc1364ca9d978edf5aee991849dd4f8e56a52 (patch)
tree61e965068f2d6bc835ecb8bd0ffe29709c9f5c1d /source/blender/blenkernel/intern/freestyle.c
parent6c28d3bac26b22049768824bef6ae9d0e82bb71f (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/blenkernel/intern/freestyle.c')
-rw-r--r--source/blender/blenkernel/intern/freestyle.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c
index 3a15be5a09d..21fc1674dc5 100644
--- a/source/blender/blenkernel/intern/freestyle.c
+++ b/source/blender/blenkernel/intern/freestyle.c
@@ -151,22 +151,14 @@ bool BKE_freestyle_module_delete(FreestyleConfig *config, FreestyleModuleConfig
return true;
}
-bool BKE_freestyle_module_move_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
-{
- if (BLI_findindex(&config->modules, module_conf) == -1)
- return false;
- BLI_remlink(&config->modules, module_conf);
- BLI_insertlinkbefore(&config->modules, module_conf->prev, module_conf);
- return true;
-}
-
-bool BKE_freestyle_module_move_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
+/**
+ * Reinsert \a module_conf offset by \a direction from current position.
+ * \return if position of \a module_conf changed.
+ */
+bool BKE_freestyle_module_move(FreestyleConfig *config, FreestyleModuleConfig *module_conf, int direction)
{
- if (BLI_findindex(&config->modules, module_conf) == -1)
- return false;
- BLI_remlink(&config->modules, module_conf);
- BLI_insertlinkafter(&config->modules, module_conf->next, module_conf);
- return true;
+ return ((BLI_findindex(&config->modules, module_conf) > -1) &&
+ (BLI_listbase_link_move(&config->modules, module_conf, direction) == true));
}
void BKE_freestyle_lineset_unique_name(FreestyleConfig *config, FreestyleLineSet *lineset)