From 0be88c7d15d2ad1af284c6283370173647ae74eb Mon Sep 17 00:00:00 2001 From: Falk David Date: Fri, 13 Nov 2020 21:43:00 +0100 Subject: GPencil: Merge GSoC curve edit mode Differential Revision: https://developer.blender.org/D8660 This patch is the result of the GSoC 2020 "Editing Grease Pencil Strokes Using Curves" project. It adds a submode to greasepencil edit mode that allows for the transformation of greasepencil strokes using bezier curves. More information about the project can be found here: https://wiki.blender.org/wiki/User:Filedescriptor/GSoC_2020. --- source/blender/editors/gpencil/gpencil_ops.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source/blender/editors/gpencil/gpencil_ops.c') diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index 9f7725e01f5..33ac0c5bbbf 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -69,6 +69,13 @@ static bool gpencil_stroke_editmode_poll(bContext *C) return (gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE)); } +/* Poll callback for stroke curve editing mode */ +static bool gpencil_stroke_editmode_curve_poll(bContext *C) +{ + bGPdata *gpd = CTX_data_gpencil_data(C); + return (GPENCIL_EDIT_MODE(gpd) && GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)); +} + /* Poll callback for stroke painting mode */ static bool gpencil_stroke_paintmode_poll(bContext *C) { @@ -315,6 +322,15 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf) keymap->poll = gpencil_stroke_editmode_poll; } +/* Stroke Curve Editing Keymap - Only when editmode is enabled and in curve edit mode */ +static void ed_keymap_gpencil_curve_editing(wmKeyConfig *keyconf) +{ + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Curve Edit Mode", 0, 0); + + /* set poll callback - so that this keymap only gets enabled when curve editmode is enabled */ + keymap->poll = gpencil_stroke_editmode_curve_poll; +} + /* keys for draw with a drawing brush (no fill) */ static void ed_keymap_gpencil_painting_draw(wmKeyConfig *keyconf) { @@ -471,6 +487,7 @@ static void ed_keymap_gpencil_weightpainting_draw(wmKeyConfig *keyconf) void ED_keymap_gpencil(wmKeyConfig *keyconf) { ed_keymap_gpencil_general(keyconf); + ed_keymap_gpencil_curve_editing(keyconf); ed_keymap_gpencil_editing(keyconf); ed_keymap_gpencil_painting(keyconf); ed_keymap_gpencil_painting_draw(keyconf); @@ -568,6 +585,11 @@ void ED_operatortypes_gpencil(void) WM_operatortype_append(GPENCIL_OT_sculpt_paint); WM_operatortype_append(GPENCIL_OT_weight_paint); + /* Edit stroke editcurve */ + + WM_operatortype_append(GPENCIL_OT_stroke_enter_editcurve_mode); + WM_operatortype_append(GPENCIL_OT_stroke_editcurve_set_handle_type); + /* Editing (Buttons) ------------ */ WM_operatortype_append(GPENCIL_OT_annotation_add); -- cgit v1.2.3