Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_merge.c
| Show First 20 Lines • Show All 429 Lines • ▼ Show 20 Lines | if (last >= totpoints) { | ||||
| loop = false; | loop = false; | ||||
| } | } | ||||
| } | } | ||||
| BLI_ghash_free(all_strokes, NULL, NULL); | BLI_ghash_free(all_strokes, NULL, NULL); | ||||
| return last; | return last; | ||||
| } | } | ||||
| static bool gpencil_strokes_merge_poll(bContext *C) | static bool gpencil_strokes_separate_merge_poll(bContext *C) | ||||
| { | { | ||||
| /* only supported with grease pencil objects */ | /* only supported with grease pencil objects */ | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| if ((ob == NULL) || (ob->type != OB_GPENCIL)) { | if ((ob == NULL) || (ob->type != OB_GPENCIL)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* check material */ | /* check material */ | ||||
| Show All 14 Lines | static bool gpencil_strokes_separate_merge_poll(bContext *C) | ||||
| if ((gpl == NULL) || (gpl->flag & GP_LAYER_LOCKED) || (gpl->flag & GP_LAYER_HIDE)) { | if ((gpl == NULL) || (gpl->flag & GP_LAYER_LOCKED) || (gpl->flag & GP_LAYER_HIDE)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* NOTE: this is a bit slower, but is the most accurate... */ | /* NOTE: this is a bit slower, but is the most accurate... */ | ||||
| return (CTX_DATA_COUNT(C, editable_gpencil_strokes) != 0) && ED_operator_view3d_active(C); | return (CTX_DATA_COUNT(C, editable_gpencil_strokes) != 0) && ED_operator_view3d_active(C); | ||||
| } | } | ||||
| static int gpencil_stroke_merge_exec(bContext *C, wmOperator *op) | static int gpencil_stroke_separate_merge_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| const int mode = RNA_enum_get(op->ptr, "mode"); | const int mode = RNA_enum_get(op->ptr, "mode"); | ||||
| const bool clear_point = RNA_boolean_get(op->ptr, "clear_point"); | const bool clear_point = RNA_boolean_get(op->ptr, "clear_point"); | ||||
| const bool clear_stroke = RNA_boolean_get(op->ptr, "clear_stroke"); | const bool clear_stroke = RNA_boolean_get(op->ptr, "clear_stroke"); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| /* sanity checks */ | /* sanity checks */ | ||||
| if (!ob || ob->type != OB_GPENCIL) { | if (!ob || ob->type != OB_GPENCIL) { | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | static int gpencil_stroke_separate_merge_exec(bContext *C, wmOperator *op) | ||||
| /* notifiers */ | /* notifiers */ | ||||
| DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); | DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); | ||||
| WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void GPENCIL_OT_stroke_merge(wmOperatorType *ot) | void GPENCIL_OT_stroke_separate_merge(wmOperatorType *ot) | ||||
| { | { | ||||
| static const EnumPropertyItem mode_type[] = { | static const EnumPropertyItem mode_type[] = { | ||||
| {GP_MERGE_STROKE, "STROKE", 0, "Stroke", ""}, | {GP_MERGE_STROKE, "STROKE", 0, "Stroke", ""}, | ||||
| {GP_MERGE_POINT, "POINT", 0, "Point", ""}, | {GP_MERGE_POINT, "POINT", 0, "Point", ""}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Merge Strokes"; | ot->name = "Merge Strokes"; | ||||
| ot->idname = "GPENCIL_OT_stroke_merge"; | ot->idname = "GPENCIL_OT_stroke_separate_merge"; | ||||
| ot->description = "Create a new stroke with the selected stroke points"; | ot->description = "Create a new stroke with the selected stroke points"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = gpencil_stroke_merge_exec; | ot->exec = gpencil_stroke_separate_merge_exec; | ||||
| ot->poll = gpencil_strokes_merge_poll; | ot->poll = gpencil_strokes_separate_merge_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* properties */ | /* properties */ | ||||
| ot->prop = RNA_def_enum(ot->srna, "mode", mode_type, GP_MERGE_STROKE, "Mode", ""); | ot->prop = RNA_def_enum(ot->srna, "mode", mode_type, GP_MERGE_STROKE, "Mode", ""); | ||||
| RNA_def_boolean( | RNA_def_boolean( | ||||
| ot->srna, "back", 0, "Draw on Back", "Draw new stroke below all previous strokes"); | ot->srna, "back", 0, "Draw on Back", "Draw new stroke below all previous strokes"); | ||||
| ▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines | |||||