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
path: root/source
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2021-04-17 16:34:01 +0300
committerAntonio Vazquez <blendergit@gmail.com>2021-04-17 16:38:36 +0300
commitd9224f64a1b9f745531a0de408c3b778abff8881 (patch)
tree55c6598ad23c27cb27f316d4e64c8a918d32b5ac /source
parentb2a0f6927508359be65af96936f53d5eab6162ae (diff)
Fix T87321: GPencil Arrange strokes not consistent with industry standards
Now if one stroke in the extremes of the stack is selected, other strokes are moved. Reviewed By: pepeland, Dantti Maniphest Tasks: T87321 Differential Revision: https://developer.blender.org/D10997
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c102
1 files changed, 65 insertions, 37 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index fd2758c8a08..b269fd84d5f 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -1555,6 +1555,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
const int direction = RNA_enum_get(op->ptr, "direction");
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ bGPDstroke *gps_target = NULL;
bool changed = false;
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
@@ -1569,7 +1570,6 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
if (gpf == NULL) {
continue;
}
- bool gpf_lock = false;
/* verify if any selected stroke is in the extreme of the stack and select to move */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
/* only if selected */
@@ -1582,18 +1582,19 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
if (ED_gpencil_stroke_material_editable(ob, gpl, gps) == false) {
continue;
}
+ bool gpf_lock = false;
/* some stroke is already at front*/
if (ELEM(direction, GP_STROKE_MOVE_TOP, GP_STROKE_MOVE_UP)) {
if (gps == gpf->strokes.last) {
gpf_lock = true;
- continue;
+ gps_target = gps;
}
}
/* Some stroke is already at bottom. */
if (ELEM(direction, GP_STROKE_MOVE_BOTTOM, GP_STROKE_MOVE_DOWN)) {
if (gps == gpf->strokes.first) {
gpf_lock = true;
- continue;
+ gps_target = gps;
}
}
/* add to list (if not locked) */
@@ -1602,47 +1603,74 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op)
}
}
}
+
+ const int target_index = (gps_target) ? BLI_findindex(&gpf->strokes, gps_target) : -1;
+ int prev_index = target_index;
/* Now do the movement of the stroke */
- if (!gpf_lock) {
- switch (direction) {
- /* Bring to Front */
- case GP_STROKE_MOVE_TOP:
- LISTBASE_FOREACH (LinkData *, link, &selected) {
- gps = link->data;
- BLI_remlink(&gpf->strokes, gps);
+ switch (direction) {
+ /* Bring to Front */
+ case GP_STROKE_MOVE_TOP:
+ LISTBASE_FOREACH (LinkData *, link, &selected) {
+ gps = link->data;
+ BLI_remlink(&gpf->strokes, gps);
+ if (gps_target) {
+ BLI_insertlinkbefore(&gpf->strokes, gps_target, gps);
+ }
+ else {
BLI_addtail(&gpf->strokes, gps);
- changed = true;
}
- break;
- /* Bring Forward */
- case GP_STROKE_MOVE_UP:
- LISTBASE_FOREACH_BACKWARD (LinkData *, link, &selected) {
- gps = link->data;
- BLI_listbase_link_move(&gpf->strokes, gps, 1);
- changed = true;
+ changed = true;
+ }
+ break;
+ /* Bring Forward */
+ case GP_STROKE_MOVE_UP:
+ LISTBASE_FOREACH_BACKWARD (LinkData *, link, &selected) {
+ gps = link->data;
+ if (gps_target) {
+ int gps_index = BLI_findindex(&gpf->strokes, gps);
+ if (gps_index + 1 >= prev_index) {
+ prev_index = gps_index;
+ continue;
+ }
+ prev_index = gps_index;
+ }
+ BLI_listbase_link_move(&gpf->strokes, gps, 1);
+ changed = true;
+ }
+ break;
+ /* Send Backward */
+ case GP_STROKE_MOVE_DOWN:
+ LISTBASE_FOREACH (LinkData *, link, &selected) {
+ gps = link->data;
+ if (gps_target) {
+ int gps_index = BLI_findindex(&gpf->strokes, gps);
+ if (gps_index - 1 <= prev_index) {
+ prev_index = gps_index;
+ continue;
+ }
+ prev_index = gps_index;
}
- break;
- /* Send Backward */
- case GP_STROKE_MOVE_DOWN:
- LISTBASE_FOREACH (LinkData *, link, &selected) {
- gps = link->data;
- BLI_listbase_link_move(&gpf->strokes, gps, -1);
- changed = true;
+ BLI_listbase_link_move(&gpf->strokes, gps, -1);
+ changed = true;
+ }
+ break;
+ /* Send to Back */
+ case GP_STROKE_MOVE_BOTTOM:
+ LISTBASE_FOREACH_BACKWARD (LinkData *, link, &selected) {
+ gps = link->data;
+ BLI_remlink(&gpf->strokes, gps);
+ if (gps_target) {
+ BLI_insertlinkafter(&gpf->strokes, gps_target, gps);
}
- break;
- /* Send to Back */
- case GP_STROKE_MOVE_BOTTOM:
- LISTBASE_FOREACH_BACKWARD (LinkData *, link, &selected) {
- gps = link->data;
- BLI_remlink(&gpf->strokes, gps);
+ else {
BLI_addhead(&gpf->strokes, gps);
- changed = true;
}
- break;
- default:
- BLI_assert(0);
- break;
- }
+ changed = true;
+ }
+ break;
+ default:
+ BLI_assert(0);
+ break;
}
BLI_freelistN(&selected);
}