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/freestyle
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/freestyle')
-rw-r--r--source/blender/freestyle/FRS_freestyle.h3
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp22
2 files changed, 7 insertions, 18 deletions
diff --git a/source/blender/freestyle/FRS_freestyle.h b/source/blender/freestyle/FRS_freestyle.h
index 039a75a2f0f..a6382010ca7 100644
--- a/source/blender/freestyle/FRS_freestyle.h
+++ b/source/blender/freestyle/FRS_freestyle.h
@@ -63,8 +63,7 @@ void FRS_exit(void);
void FRS_copy_active_lineset(struct FreestyleConfig *config);
void FRS_paste_active_lineset(struct FreestyleConfig *config);
void FRS_delete_active_lineset(struct FreestyleConfig *config);
-void FRS_move_active_lineset_up(struct FreestyleConfig *config);
-void FRS_move_active_lineset_down(struct FreestyleConfig *config);
+bool FRS_move_active_lineset(struct FreestyleConfig *config, int direction);
/* Testing */
struct Material *FRS_create_stroke_material(struct Main *bmain, struct FreestyleLineStyle *linestyle);
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