Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_edit.c
| Show First 20 Lines • Show All 1,396 Lines • ▼ Show 20 Lines | void GPENCIL_OT_paste(wmOperatorType *ot) | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* properties */ | /* properties */ | ||||
| ot->prop = RNA_def_enum(ot->srna, "type", copy_type, GP_COPY_TO_ACTIVE, "Type", ""); | ot->prop = RNA_def_enum(ot->srna, "type", copy_type, GP_COPY_TO_ACTIVE, "Type", ""); | ||||
| } | } | ||||
| /* ******************* Move To Layer ****************************** */ | /* ******************* Move To Layer ****************************** */ | ||||
| static int gp_move_to_layer_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(evt)) | |||||
| { | |||||
| uiPopupMenu *pup; | |||||
| uiLayout *layout; | |||||
| /* call the menu, which will call this operator again, hence the canceled */ | |||||
| pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE); | |||||
| layout = UI_popup_menu_layout(pup); | |||||
| uiItemsEnumO(layout, "GPENCIL_OT_move_to_layer", "layer"); | |||||
| UI_popup_menu_end(C, pup); | |||||
| return OPERATOR_INTERFACE; | |||||
| } | |||||
| // FIXME: allow moving partial strokes | |||||
| static int gp_move_to_layer_exec(bContext *C, wmOperator *op) | static int gp_move_to_layer_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bGPdata *gpd = CTX_data_gpencil_data(C); | bGPdata *gpd = CTX_data_gpencil_data(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| bGPDlayer *target_layer = NULL; | bGPDlayer *target_layer = NULL; | ||||
| ListBase strokes = {NULL, NULL}; | ListBase strokes = {NULL, NULL}; | ||||
| int layer_num = RNA_enum_get(op->ptr, "layer"); | int layer_num = RNA_int_get(op->ptr, "layer"); | ||||
| const bool use_autolock = (bool)(gpd->flag & GP_DATA_AUTOLOCK_LAYERS); | const bool use_autolock = (bool)(gpd->flag & GP_DATA_AUTOLOCK_LAYERS); | ||||
| if (GPENCIL_MULTIEDIT_SESSIONS_ON(gpd)) { | if (GPENCIL_MULTIEDIT_SESSIONS_ON(gpd)) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Operator not supported in multiframe edition"); | BKE_report(op->reports, RPT_ERROR, "Operator not supported in multiframe edition"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* if autolock enabled, disabled now */ | /* if autolock enabled, disabled now */ | ||||
| if (use_autolock) { | if (use_autolock) { | ||||
| gpd->flag &= ~GP_DATA_AUTOLOCK_LAYERS; | gpd->flag &= ~GP_DATA_AUTOLOCK_LAYERS; | ||||
| } | } | ||||
| /* Get layer or create new one */ | |||||
| if (layer_num == -1) { | |||||
| /* Create layer */ | |||||
| target_layer = BKE_gpencil_layer_addnew(gpd, DATA_("GP_Layer"), true); | |||||
| } | |||||
| else { | |||||
| /* Try to get layer */ | /* Try to get layer */ | ||||
| target_layer = BLI_findlink(&gpd->layers, layer_num); | target_layer = BLI_findlink(&gpd->layers, layer_num); | ||||
| if (target_layer == NULL) { | if (target_layer == NULL) { | ||||
| /* back autolock status */ | /* back autolock status */ | ||||
| if (use_autolock) { | if (use_autolock) { | ||||
| gpd->flag |= GP_DATA_AUTOLOCK_LAYERS; | gpd->flag |= GP_DATA_AUTOLOCK_LAYERS; | ||||
| } | } | ||||
| BKE_reportf(op->reports, RPT_ERROR, "There is no layer number %d", layer_num); | BKE_reportf(op->reports, RPT_ERROR, "There is no layer number %d", layer_num); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | |||||
| /* Extract all strokes to move to this layer | /* Extract all strokes to move to this layer | ||||
| * NOTE: We need to do this in a two-pass system to avoid conflicts with strokes | * NOTE: We need to do this in a two-pass system to avoid conflicts with strokes | ||||
| * getting repeatedly moved | * getting repeatedly moved | ||||
| */ | */ | ||||
| CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { | CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { | ||||
| bGPDframe *gpf = gpl->actframe; | bGPDframe *gpf = gpl->actframe; | ||||
| bGPDstroke *gps, *gpsn; | bGPDstroke *gps, *gpsn; | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Move Strokes to Layer"; | ot->name = "Move Strokes to Layer"; | ||||
| ot->idname = "GPENCIL_OT_move_to_layer"; | ot->idname = "GPENCIL_OT_move_to_layer"; | ||||
| ot->description = | ot->description = | ||||
| "Move selected strokes to another layer"; // XXX: allow moving individual points too? | "Move selected strokes to another layer"; // XXX: allow moving individual points too? | ||||
| /* callbacks */ | /* callbacks */ | ||||
| ot->invoke = gp_move_to_layer_invoke; | |||||
| ot->exec = gp_move_to_layer_exec; | ot->exec = gp_move_to_layer_exec; | ||||
| ot->poll = gp_stroke_edit_poll; // XXX? | ot->poll = gp_stroke_edit_poll; // XXX? | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* gp layer to use (dynamic enum) */ | /* GPencil layer to use. */ | ||||
| ot->prop = RNA_def_enum(ot->srna, "layer", DummyRNA_DEFAULT_items, 0, "Grease Pencil Layer", ""); | ot->prop = RNA_def_int(ot->srna, "layer", 0, 0, INT_MAX, "Grease Pencil Layer", "", 0, INT_MAX); | ||||
| RNA_def_enum_funcs(ot->prop, ED_gpencil_layers_with_new_enum_itemf); | |||||
| } | } | ||||
| /* ********************* Add Blank Frame *************************** */ | /* ********************* Add Blank Frame *************************** */ | ||||
| /* Basically the same as the drawing op */ | /* Basically the same as the drawing op */ | ||||
| static bool UNUSED_FUNCTION(gp_blank_frame_add_poll)(bContext *C) | static bool UNUSED_FUNCTION(gp_blank_frame_add_poll)(bContext *C) | ||||
| { | { | ||||
| if (ED_operator_regionactive(C)) { | if (ED_operator_regionactive(C)) { | ||||
| ▲ Show 20 Lines • Show All 3,142 Lines • Show Last 20 Lines | |||||