Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_edit.c
| Show First 20 Lines • Show All 1,231 Lines • ▼ Show 20 Lines | typedef enum eGP_PasteMode { | ||||
| GP_COPY_MERGE = 1, | GP_COPY_MERGE = 1, | ||||
| } eGP_PasteMode; | } eGP_PasteMode; | ||||
| static int gp_strokes_paste_exec(bContext *C, wmOperator *op) | static int gp_strokes_paste_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | bGPdata *gpd = ED_gpencil_data_get_active(C); | ||||
| bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); /* only use active for copy merge */ | bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); /* only use active for copy merge */ | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Scene *scene = CTX_data_scene(C); | ||||
| int cfra_eval = (int)DEG_get_ctime(depsgraph); | int cfra_eval = CFRA; | ||||
| bGPDframe *gpf; | bGPDframe *gpf; | ||||
| eGP_PasteMode type = RNA_enum_get(op->ptr, "type"); | eGP_PasteMode type = RNA_enum_get(op->ptr, "type"); | ||||
| GHash *new_colors; | GHash *new_colors; | ||||
| /* check for various error conditions */ | /* check for various error conditions */ | ||||
| if (gpd == NULL) { | if (gpd == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); | BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); | ||||
| ▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | static int gp_move_to_layer_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(evt)) | ||||
| return OPERATOR_INTERFACE; | return OPERATOR_INTERFACE; | ||||
| } | } | ||||
| // FIXME: allow moving partial strokes | // 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); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Scene *scene = CTX_data_scene(C); | ||||
| int cfra_eval = (int)DEG_get_ctime(depsgraph); | int cfra_eval = CFRA; | ||||
| 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_enum_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; | ||||
| ▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | static bool UNUSED_FUNCTION(gp_blank_frame_add_poll)(bContext *C) | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static int gp_blank_frame_add_exec(bContext *C, wmOperator *op) | static int gp_blank_frame_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | bGPdata *gpd = ED_gpencil_data_get_active(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Scene *scene = CTX_data_scene(C); | ||||
| int cfra_eval = (int)DEG_get_ctime(depsgraph); | int cfra_eval = CFRA; | ||||
| bGPDlayer *active_gpl = BKE_gpencil_layer_getactive(gpd); | bGPDlayer *active_gpl = BKE_gpencil_layer_getactive(gpd); | ||||
| const bool all_layers = RNA_boolean_get(op->ptr, "all_layers"); | const bool all_layers = RNA_boolean_get(op->ptr, "all_layers"); | ||||
| /* Initialise datablock and an active layer if nothing exists yet */ | /* Initialise datablock and an active layer if nothing exists yet */ | ||||
| if (ELEM(NULL, gpd, active_gpl)) { | if (ELEM(NULL, gpd, active_gpl)) { | ||||
| /* Let's just be lazy, and call the "Add New Layer" operator, | /* Let's just be lazy, and call the "Add New Layer" operator, | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* delete active frame - wrapper around API calls */ | /* delete active frame - wrapper around API calls */ | ||||
| static int gp_actframe_delete_exec(bContext *C, wmOperator *op) | static int gp_actframe_delete_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | bGPdata *gpd = ED_gpencil_data_get_active(C); | ||||
| bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); | bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Scene *scene = CTX_data_scene(C); | ||||
| int cfra_eval = (int)DEG_get_ctime(depsgraph); | int cfra_eval = CFRA; | ||||
| bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV); | bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV); | ||||
| /* if there's no existing Grease-Pencil data there, add some */ | /* if there's no existing Grease-Pencil data there, add some */ | ||||
| if (gpd == NULL) { | if (gpd == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "No grease pencil data"); | BKE_report(op->reports, RPT_ERROR, "No grease pencil data"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| Show All 36 Lines | static bool gp_actframe_delete_all_poll(bContext *C) | ||||
| * 2) Hopefully some of the layers have stuff we can use | * 2) Hopefully some of the layers have stuff we can use | ||||
| */ | */ | ||||
| return (gpd && gpd->layers.first); | return (gpd && gpd->layers.first); | ||||
| } | } | ||||
| static int gp_actframe_delete_all_exec(bContext *C, wmOperator *op) | static int gp_actframe_delete_all_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | bGPdata *gpd = ED_gpencil_data_get_active(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Scene *scene = CTX_data_scene(C); | ||||
| int cfra_eval = (int)DEG_get_ctime(depsgraph); | int cfra_eval = CFRA; | ||||
| bool success = false; | bool success = false; | ||||
| CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { | CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { | ||||
| /* try to get the "active" frame - but only if it actually occurs on this frame */ | /* try to get the "active" frame - but only if it actually occurs on this frame */ | ||||
| bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV); | bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV); | ||||
| if (gpf == NULL) { | if (gpf == NULL) { | ||||
| ▲ Show 20 Lines • Show All 2,868 Lines • Show Last 20 Lines | |||||