[Bf-blender-cvs] [ebca6f5f208] blender2.8: Fix grease pencil line toggle

Campbell Barton noreply at git.blender.org
Tue Jul 31 15:39:30 CEST 2018


Commit: ebca6f5f2087b545a196422f3c1e4e988a7cd93f
Author: Campbell Barton
Date:   Tue Jul 31 23:36:01 2018 +1000
Branches: blender2.8
https://developer.blender.org/rBebca6f5f2087b545a196422f3c1e4e988a7cd93f

Fix grease pencil line toggle

Replace with generic context toggle operator.

===================================================================

M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/gpencil/gpencil_intern.h
M	source/blender/editors/gpencil/gpencil_ops.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index fdeadcc648a..56d1d53ea40 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -486,44 +486,6 @@ void GPENCIL_OT_selection_opacity_toggle(wmOperatorType *ot)
 	ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER;
 }
 
-/* toggle multi edit strokes support */
-static int gpencil_multiedit_toggle_exec(bContext *C, wmOperator *op)
-{
-	View3D *v3d = CTX_wm_view3d(C);
-	const bool lines = RNA_boolean_get(op->ptr, "lines");
-
-	/* Just toggle value */
-	if (lines == 0) {
-		v3d->flag3 ^= V3D_GP_SHOW_EDIT_LINES;
-	}
-	else {
-		v3d->flag3 ^= V3D_GP_SHOW_MULTIEDIT_LINES;
-	}
-
-	WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, NULL);
-	WM_event_add_notifier(C, NC_SCENE | ND_MODE, NULL);
-
-	return OPERATOR_FINISHED;
-}
-
-void GPENCIL_OT_multiedit_toggle(wmOperatorType *ot)
-{
-	/* identifiers */
-	ot->name = "Edit Lines Toggle";
-	ot->idname = "GPENCIL_OT_multiedit_toggle";
-	ot->description = "Enable/disable edit lines support";
-
-	/* callbacks */
-	ot->exec = gpencil_multiedit_toggle_exec;
-	ot->poll = gp_stroke_edit_poll;
-
-	/* flags */
-	ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER;
-
-	/* properties */
-	RNA_def_boolean(ot->srna, "toggle_visibility", 0, "Toggle Visibility Only", "Toggle visibility of edit lines only");
-}
-
 /* ************** Duplicate Selected Strokes **************** */
 
 /* Make copies of selected point segments in a selected stroke */
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index a51f9e7a065..52e7d1e1f30 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -291,7 +291,6 @@ void GPENCIL_OT_paintmode_toggle(struct wmOperatorType *ot);
 void GPENCIL_OT_sculptmode_toggle(struct wmOperatorType *ot);
 void GPENCIL_OT_weightmode_toggle(struct wmOperatorType *ot);
 void GPENCIL_OT_selection_opacity_toggle(struct wmOperatorType *ot);
-void GPENCIL_OT_multiedit_toggle(struct wmOperatorType *ot);
 
 void GPENCIL_OT_select(struct wmOperatorType *ot);
 void GPENCIL_OT_select_all(struct wmOperatorType *ot);
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index e5ebfcecdf8..43ccc77e921 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -404,11 +404,10 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
 	WM_keymap_add_item(keymap, "GPENCIL_OT_selection_opacity_toggle", HKEY, KM_PRESS, KM_CTRL, 0);
 
 	/* toogle multiedit support */
-	kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_multiedit_toggle", QKEY, KM_PRESS, 0, 0);
-	RNA_boolean_set(kmi->ptr, "toggle_visibility", 0);
-
-	kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_multiedit_toggle", QKEY, KM_PRESS, KM_SHIFT, 0);
-	RNA_boolean_set(kmi->ptr, "toggle_visibility", 1);
+	kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, 0, 0);
+	RNA_string_set(kmi->ptr, "data_path", "space_data.overlay.use_gpencil_edit_lines");
+	kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, KM_SHIFT, 0);
+	RNA_string_set(kmi->ptr, "data_path", "space_data.overlay.use_gpencil_multiedit_line_only");
 
 	/* Isolate Layer */
 	WM_keymap_add_item(keymap, "GPENCIL_OT_layer_isolate", PADASTERKEY, KM_PRESS, 0, 0);
@@ -605,12 +604,10 @@ static void ed_keymap_gpencil_sculpting(wmKeyConfig *keyconf)
 	ed_keymap_gpencil_sculpt(keymap);
 
 	/* toogle multiedit support */
-	kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_multiedit_toggle", QKEY, KM_PRESS, 0, 0);
-	RNA_boolean_set(kmi->ptr, "toggle_visibility", 0);
-
-	kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_multiedit_toggle", QKEY, KM_PRESS, KM_SHIFT, 0);
-	RNA_boolean_set(kmi->ptr, "toggle_visibility", 1);
-
+	kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, 0, 0);
+	RNA_string_set(kmi->ptr, "data_path", "space_data.overlay.use_gpencil_edit_lines");
+	kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, KM_SHIFT, 0);
+	RNA_string_set(kmi->ptr, "data_path", "space_data.overlay.use_gpencil_multiedit_line_only");
 }
 
 /* Stroke Weight Paint Keymap - Only when weight is enabled */
@@ -637,12 +634,10 @@ static void ed_keymap_gpencil_weightpainting(wmKeyConfig *keyconf)
 	RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.gpencil_sculpt.weight_brush.size");
 
 	/* toogle multiedit support */
-	kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_multiedit_toggle", QKEY, KM_PRESS, 0, 0);
-	RNA_boolean_set(kmi->ptr, "toggle_visibility", 0);
-
-	kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_multiedit_toggle", QKEY, KM_PRESS, KM_SHIFT, 0);
-	RNA_boolean_set(kmi->ptr, "toggle_visibility", 1);
-
+	kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, 0, 0);
+	RNA_string_set(kmi->ptr, "data_path", "space_data.overlay.use_gpencil_edit_lines");
+	kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, KM_SHIFT, 0);
+	RNA_string_set(kmi->ptr, "data_path", "space_data.overlay.use_gpencil_multiedit_line_only");
 }
 /* ==================== */
 
@@ -678,7 +673,6 @@ void ED_operatortypes_gpencil(void)
 	WM_operatortype_append(GPENCIL_OT_sculptmode_toggle);
 	WM_operatortype_append(GPENCIL_OT_weightmode_toggle);
 	WM_operatortype_append(GPENCIL_OT_selection_opacity_toggle);
-	WM_operatortype_append(GPENCIL_OT_multiedit_toggle);
 
 	WM_operatortype_append(GPENCIL_OT_select);
 	WM_operatortype_append(GPENCIL_OT_select_all);



More information about the Bf-blender-cvs mailing list