[Bf-blender-cvs] [fe393bd2a97] greasepencil-object: Keep color selected when move

Antonio Vazquez noreply at git.blender.org
Tue Aug 8 11:19:30 CEST 2017


Commit: fe393bd2a9776c098b46d2087c7530ec60cc6ce6
Author: Antonio Vazquez
Date:   Mon Aug 7 16:21:16 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBfe393bd2a9776c098b46d2087c7530ec60cc6ce6

Keep color selected when move

When move up or down in the color list, the color must keep selected.

The code has been cleanup too.

===================================================================

M	source/blender/editors/sculpt_paint/paint_ops.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index eb6bee2d038..f1925818695 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -634,23 +634,11 @@ static int palettecolor_move_exec(bContext *C, wmOperator *op)
 	if (ELEM(NULL, palette, palcolor))
 		return OPERATOR_CANCELLED;
 
-	/* up or down? */
-	if (direction == PALETTE_COLOR_MOVE_UP) {
-		/* up */
-		BLI_remlink(&palette->colors, palcolor);
-		BLI_insertlinkbefore(&palette->colors, palcolor->prev, palcolor);
+	BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */
+	if (BLI_listbase_link_move(&palette->colors, palcolor, direction)) {
+		palette->active_color = BLI_findindex(&palette->colors, palcolor);
+		WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 	}
-	else if (direction == PALETTE_COLOR_MOVE_DOWN) {
-		/* down */
-		BLI_remlink(&palette->colors, palcolor);
-		BLI_insertlinkafter(&palette->colors, palcolor->next, palcolor);
-	}
-	else {
-		BLI_assert(0);
-	}
-
-	/* notifiers */
-	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 
 	return OPERATOR_FINISHED;
 }




More information about the Bf-blender-cvs mailing list