diff options
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_data.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 65 |
1 files changed, 54 insertions, 11 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 6980ad46241..9d183222c2d 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -53,7 +53,6 @@ #include "DNA_gpencil_types.h" #include "BKE_context.h" -#include "BKE_global.h" #include "BKE_gpencil.h" #include "BKE_library.h" #include "BKE_object.h" @@ -302,7 +301,7 @@ static int gp_layer_move_exec(bContext *C, wmOperator *op) void GPENCIL_OT_layer_move(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {GP_LAYER_MOVE_UP, "UP", 0, "Up", ""}, {GP_LAYER_MOVE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} @@ -423,18 +422,59 @@ static int gp_reveal_poll(bContext *C) return ED_gpencil_data_get_active(C) != NULL; } -static int gp_reveal_exec(bContext *C, wmOperator *UNUSED(op)) +static void gp_reveal_select_frame(bContext *C, bGPDframe *frame, bool select) +{ + bGPDstroke *gps; + for (gps = frame->strokes.first; gps; gps = gps->next) { + + /* only deselect strokes that are valid in this view */ + if (ED_gpencil_stroke_can_use(C, gps)) { + + /* (de)select points */ + int i; + bGPDspoint *pt; + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { + SET_FLAG_FROM_TEST(pt->flag, select, GP_SPOINT_SELECT); + } + + /* (de)select stroke */ + SET_FLAG_FROM_TEST(gps->flag, select, GP_STROKE_SELECT); + } + } +} + +static int gp_reveal_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl; - + const bool select = RNA_boolean_get(op->ptr, "select"); + /* sanity checks */ if (gpd == NULL) return OPERATOR_CANCELLED; - /* make all layers visible */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { - gpl->flag &= ~GP_LAYER_HIDE; + + if (gpl->flag & GP_LAYER_HIDE) { + gpl->flag &= ~GP_LAYER_HIDE; + + /* select or deselect if requested, only on hidden layers */ + if (gpd->flag & GP_DATA_STROKE_EDITMODE) { + if (select) { + /* select all strokes on active frame only (same as select all operator) */ + if (gpl->actframe) { + gp_reveal_select_frame(C, gpl->actframe, true); + } + } + else { + /* deselect strokes on all frames (same as deselect all operator) */ + bGPDframe *gpf; + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { + gp_reveal_select_frame(C, gpf, false); + } + } + } + } } /* notifiers */ @@ -456,6 +496,9 @@ void GPENCIL_OT_reveal(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* props */ + RNA_def_boolean(ot->srna, "select", true, "Select", ""); } /* ***************** Lock/Unlock All Layers ************************ */ @@ -831,7 +874,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op) void GPENCIL_OT_stroke_arrange(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {GP_STROKE_MOVE_UP, "UP", 0, "Bring Forward", ""}, {GP_STROKE_MOVE_DOWN, "DOWN", 0, "Send Backward", ""}, {GP_STROKE_MOVE_TOP, "TOP", 0, "Bring to Front", ""}, @@ -1019,7 +1062,7 @@ static int gp_brush_remove_exec(bContext *C, wmOperator *op) if (ELEM(NULL, ts, brush)) return OPERATOR_CANCELLED; - if (BLI_listbase_count_ex(&ts->gp_brushes, 2) < 2) { + if (BLI_listbase_count_at_most(&ts->gp_brushes, 2) < 2) { BKE_report(op->reports, RPT_ERROR, "Grease Pencil needs a brush, unable to delete the last one"); return OPERATOR_CANCELLED; } @@ -1165,7 +1208,7 @@ static int gp_brush_move_exec(bContext *C, wmOperator *op) void GPENCIL_OT_brush_move(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {GP_BRUSH_MOVE_UP, "UP", 0, "Up", ""}, {GP_BRUSH_MOVE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL } @@ -1377,7 +1420,7 @@ static int gp_palette_remove_exec(bContext *C, wmOperator *op) if (ELEM(NULL, gpd, palette)) return OPERATOR_CANCELLED; - if (BLI_listbase_count_ex(&gpd->palettes, 2) < 2) { + if (BLI_listbase_count_at_most(&gpd->palettes, 2) < 2) { BKE_report(op->reports, RPT_ERROR, "Grease Pencil needs a palette, unable to delete the last one"); return OPERATOR_CANCELLED; } @@ -1922,7 +1965,7 @@ static int gp_palettecolor_move_exec(bContext *C, wmOperator *op) void GPENCIL_OT_palettecolor_move(wmOperatorType *ot) { - static EnumPropertyItem slot_move[] = { + static const EnumPropertyItem slot_move[] = { {GP_COLOR_MOVE_UP, "UP", 0, "Up", ""}, {GP_COLOR_MOVE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} |