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;
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to