From c6eaa9c552eb5e505075dda4c7c4e59dc7497738 Mon Sep 17 00:00:00 2001 From: Simon Lenz Date: Fri, 26 Nov 2021 11:01:04 +0100 Subject: MaskEditor: draw active layer on top Instead of drawing the mask layers in the sequence of their occurence, draw the active mask *always* on top. Implementation: - move drawing loop for splines to separate static function - draw active mask last Example: lowest layer is active, yet still drawn on top. {F12140355} This is part of an effort to make mask editing more intuitive & easy to use: https://developer.blender.org/T93097 Reviewed By: sergey Differential Revision: https://developer.blender.org/D13372 --- source/blender/editors/mask/mask_draw.c | 56 ++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 22232e9c87e..92e774bfe86 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -587,6 +587,35 @@ static void draw_spline_curve(const bContext *C, } } +static void draw_layer_splines(const bContext *C, + MaskLayer *layer, + const char draw_flag, + const char draw_type, + const int width, + const int height, + const bool is_active) +{ + LISTBASE_FOREACH (MaskSpline *, spline, &layer->splines) { + /* draw curve itself first... */ + draw_spline_curve(C, layer, spline, draw_flag, draw_type, is_active, width, height); + + if (!(layer->visibility_flag & MASK_HIDE_SELECT)) { + /* ...and then handles over the curve so they're nicely visible */ + draw_spline_points(C, layer, spline, draw_flag, draw_type); + } + + /* show undeform for testing */ + if (0) { + void *back = spline->points_deform; + + spline->points_deform = NULL; + draw_spline_curve(C, layer, spline, draw_flag, draw_type, is_active, width, height); + draw_spline_points(C, layer, spline, draw_flag, draw_type); + spline->points_deform = back; + } + } +} + static void draw_mask_layers(const bContext *C, Mask *mask, const char draw_flag, @@ -600,6 +629,7 @@ static void draw_mask_layers(const bContext *C, MaskLayer *mask_layer; int i; + MaskLayer *active = NULL; for (mask_layer = mask->masklayers.first, i = 0; mask_layer != NULL; mask_layer = mask_layer->next, i++) { const bool is_active = (i == mask->masklay_act); @@ -608,26 +638,16 @@ static void draw_mask_layers(const bContext *C, continue; } - LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { - - /* draw curve itself first... */ - draw_spline_curve(C, mask_layer, spline, draw_flag, draw_type, is_active, width, height); - - if (!(mask_layer->visibility_flag & MASK_HIDE_SELECT)) { - /* ...and then handles over the curve so they're nicely visible */ - draw_spline_points(C, mask_layer, spline, draw_flag, draw_type); - } + if (is_active) { + active = mask_layer; + continue; + } - /* show undeform for testing */ - if (0) { - void *back = spline->points_deform; + draw_layer_splines(C, mask_layer, draw_flag, draw_type, width, height, is_active); + } - spline->points_deform = NULL; - draw_spline_curve(C, mask_layer, spline, draw_flag, draw_type, is_active, width, height); - draw_spline_points(C, mask_layer, spline, draw_flag, draw_type); - spline->points_deform = back; - } - } + if (active != NULL) { + draw_layer_splines(C, active, draw_flag, draw_type, width, height, true); } GPU_program_point_size(false); -- cgit v1.2.3