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
This commit is contained in:
Simon Lenz 2021-11-26 11:01:04 +01:00 committed by Sergey Sharybin
parent 658fd8df0b
commit c6eaa9c552
1 changed files with 39 additions and 19 deletions

View File

@ -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);
}
/* show undeform for testing */
if (0) {
void *back = spline->points_deform;
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 (is_active) {
active = mask_layer;
continue;
}
draw_layer_splines(C, mask_layer, draw_flag, draw_type, width, height, is_active);
}
if (active != NULL) {
draw_layer_splines(C, active, draw_flag, draw_type, width, height, true);
}
GPU_program_point_size(false);