Fix grease pencil line toggle

Replace with generic context toggle operator.
This commit is contained in:
Campbell Barton
2018-07-31 23:36:01 +10:00
parent 475e9003c0
commit ebca6f5f20
3 changed files with 12 additions and 57 deletions

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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);