[Bf-blender-cvs] [9ca6fc41ae7] master: Bevel: Make modal keymap instead of hardcoded.

Howard Trickey noreply at git.blender.org
Sun Feb 10 22:10:03 CET 2019


Commit: 9ca6fc41ae7cc9d8e5ce89b10d1237c035ce5d63
Author: Howard Trickey
Date:   Sun Feb 10 16:08:25 2019 -0500
Branches: master
https://developer.blender.org/rB9ca6fc41ae7cc9d8e5ce89b10d1237c035ce5d63

Bevel: Make modal keymap instead of hardcoded.

Also added keys for toggling harden normals,
and cycling through miter types.
Still to do: add some shortcuts for affecting the
spread value for arc miters.

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

M	release/scripts/addons
M	release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	source/blender/editors/mesh/editmesh_bevel.c
M	source/blender/editors/mesh/mesh_intern.h
M	source/blender/editors/mesh/mesh_ops.c

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

diff --git a/release/scripts/addons b/release/scripts/addons
index be0e825355c..f999cc09083 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit be0e825355c92d38d5fa55e43591a950fc517a7f
+Subproject commit f999cc0908333ac0d4b2b203706f3eb640ba54c9
diff --git a/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py b/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
index a769bb34d1e..05404ef203c 100644
--- a/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
+++ b/release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
@@ -111,6 +111,7 @@ _km_hierarchy = [
 
         ('Knife Tool Modal Map', 'EMPTY', 'WINDOW', []),
         ('Custom Normals Modal Map', 'EMPTY', 'WINDOW', []),
+        ('Bevel Modal Map', 'EMPTY', 'WINDOW', []),
         ('Paint Stroke Modal', 'EMPTY', 'WINDOW', []),
         ('Paint Curve', 'EMPTY', 'WINDOW', []),
 
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 9b79823b272..09ffecd3c57 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -4754,6 +4754,40 @@ def km_custom_normals_modal_map(_params):
     return keymap
 
 
+def km_bevel_modal_map(_params):
+    items = []
+    keymap = (
+        "Bevel Modal Map",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW', "modal": True},
+        {"items": items},
+    )
+
+    items.extend([
+        ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None),
+        ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, None),
+        ("CONFIRM", {"type": 'RET', "value": 'PRESS', "any": True}, None),
+        ("CONFIRM", {"type": 'NUMPAD_ENTER', "value": 'PRESS', "any": True}, None),
+        ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+        ("VALUE_OFFSET", {"type": 'A', "value": 'PRESS', "any": True}, None),
+        ("VALUE_PROFILE", {"type": 'P', "value": 'PRESS', "any": True}, None),
+        ("VALUE_SEGMENTS", {"type": 'S', "value": 'PRESS', "any": True}, None),
+        ("SEGMENTS_UP", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "any": True}, None),
+        ("SEGMENTS_UP", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "any": True}, None),
+        ("SEGMENTS_DOWN", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "any": True}, None),
+        ("SEGMENTS_DOWN", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "any": True}, None),
+        ("OFFSET_MODE_CHANGE", {"type": 'M', "value": 'PRESS', "any": True}, None),
+        ("CLAMP_OVERLAP_TOGGLE", {"type": 'C', "value": 'PRESS', "any": True}, None),
+        ("VERTEX_ONLY_TOGGLE", {"type": 'V', "value": 'PRESS', "any": True}, None),
+        ("HARDEN_NORMALS_TOGGLE", {"type": 'H', "value": 'PRESS', "any": True}, None),
+        ("MARK_SEAM_TOGGLE", {"type": 'U', "value": 'PRESS', "any": True}, None),
+        ("MARK_SHARP_TOGGLE", {"type": 'K', "value": 'PRESS', "any": True}, None),
+        ("OUTER_MITER_CHANGE", {"type": 'O', "value": 'PRESS', "any": True}, None),
+        ("INNER_MITER_CHANGE", {"type": 'I', "value": 'PRESS', "any": True}, None),
+    ])
+
+    return keymap
+
+
 def km_view3d_fly_modal(_params):
     items = []
     keymap = (
@@ -5973,6 +6007,7 @@ def generate_keymaps(params=None):
         km_standard_modal_map(params),
         km_knife_tool_modal_map(params),
         km_custom_normals_modal_map(params),
+        km_bevel_modal_map(params),
         km_view3d_fly_modal(params),
         km_view3d_walk_modal(params),
         km_view3d_rotate_modal(params),
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index eb787a69d4e..29dde0e5200 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -50,6 +50,9 @@
 #include "ED_transform.h"
 #include "ED_view3d.h"
 
+#include "WM_api.h"
+#include "WM_types.h"
+
 #include "mesh_intern.h"  /* own include */
 
 
@@ -97,38 +100,97 @@ typedef struct {
 	float segments;     /* Segments as float so smooth mouse pan works in small increments */
 } BevelData;
 
+enum {
+	BEV_MODAL_CANCEL = 1,
+	BEV_MODAL_CONFIRM,
+	BEV_MODAL_VALUE_OFFSET,
+	BEV_MODAL_VALUE_PROFILE,
+	BEV_MODAL_VALUE_SEGMENTS,
+	BEV_MODAL_SEGMENTS_UP,
+	BEV_MODAL_SEGMENTS_DOWN,
+	BEV_MODAL_OFFSET_MODE_CHANGE,
+	BEV_MODAL_CLAMP_OVERLAP_TOGGLE,
+	BEV_MODAL_VERTEX_ONLY_TOGGLE,
+	BEV_MODAL_HARDEN_NORMALS_TOGGLE,
+	BEV_MODAL_MARK_SEAM_TOGGLE,
+	BEV_MODAL_MARK_SHARP_TOGGLE,
+	BEV_MODAL_OUTER_MITER_CHANGE,
+	BEV_MODAL_INNER_MITER_CHANGE,
+};
+
 static void edbm_bevel_update_header(bContext *C, wmOperator *op)
 {
-	const char *str = IFACE_("Confirm: (Enter/LMB), Cancel: (Esc/RMB), Mode: %s (M), Clamp Overlap: %s (C), "
-	                         "Vertex Only: %s (V), Profile Control: %s (P), Offset: %s, Segments: %d, Profile: %.3f");
-
-	char msg[UI_MAX_DRAW_STR];
-	ScrArea *sa = CTX_wm_area(C);
+	char header[UI_MAX_DRAW_STR];
+	char buf[UI_MAX_DRAW_STR];
+	char *p = buf;
+	int available_len = sizeof(buf);
 	Scene *sce = CTX_data_scene(C);
+	BevelData *opdata = op->customdata;
+	char offset_str[NUM_STR_REP_LEN];
+	const char *mode_str, *omiter_str, *imiter_str;
+	PropertyRNA *prop;
 
-	if (sa) {
-		BevelData *opdata = op->customdata;
-		char offset_str[NUM_STR_REP_LEN];
-		const char *type_str;
-		PropertyRNA *prop = RNA_struct_find_property(op->ptr, "offset_type");
-
-		if (hasNumInput(&opdata->num_input[OFFSET_VALUE])) {
-			outputNumInput(&opdata->num_input[OFFSET_VALUE], offset_str, &sce->unit);
-		}
-		else {
-			BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "offset"));
-		}
-
-		RNA_property_enum_name_gettexted(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &type_str);
-
-		BLI_snprintf(msg, sizeof(msg), str, type_str,
-		             WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")),
-		             WM_bool_as_string(RNA_boolean_get(op->ptr, "vertex_only")),
-		             WM_bool_as_string(opdata->value_mode == PROFILE_VALUE),
-		             offset_str, RNA_int_get(op->ptr, "segments"), RNA_float_get(op->ptr, "profile"));
+#define WM_MODALKEY(_id) \
+	WM_modalkeymap_operator_items_to_string_buf(op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p)
 
-		ED_area_status_text(sa, msg);
+	if (hasNumInput(&opdata->num_input[OFFSET_VALUE])) {
+		outputNumInput(&opdata->num_input[OFFSET_VALUE], offset_str, &sce->unit);
+	}
+	else {
+		BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "offset"));
 	}
+
+	prop = RNA_struct_find_property(op->ptr, "offset_type");
+	RNA_property_enum_name_gettexted(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &mode_str);
+	prop = RNA_struct_find_property(op->ptr, "miter_outer");
+	RNA_property_enum_name_gettexted(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &omiter_str);
+	prop = RNA_struct_find_property(op->ptr, "miter_inner");
+	RNA_property_enum_name_gettexted(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &imiter_str);
+
+	BLI_snprintf(header, sizeof(header),
+		IFACE_("%s: confirm, "
+			"%s: cancel, "
+			"%s: mode (%s), "
+			"%s: offset (%s), "
+			"%s: segments (%d), "
+			"%s: profile (%.3f), "
+			"%s: clamp overlap (%s), "
+			"%s: vertex only (%s), "
+			"%s: outer miter (%s), "
+			"%s: inner imter (%s), "
+			"%s: harden normals (%s), "
+			"%s: mark seam (%s), "
+			"%s: mark sharp (%s)"
+		),
+		WM_MODALKEY(BEV_MODAL_CONFIRM),
+		WM_MODALKEY(BEV_MODAL_CANCEL),
+		WM_MODALKEY(BEV_MODAL_OFFSET_MODE_CHANGE),
+		mode_str,
+		WM_MODALKEY(BEV_MODAL_VALUE_OFFSET),
+		offset_str,
+		WM_MODALKEY(BEV_MODAL_VALUE_SEGMENTS),
+		RNA_int_get(op->ptr, "segments"),
+		WM_MODALKEY(BEV_MODAL_VALUE_PROFILE),
+		RNA_float_get(op->ptr, "profile"),
+		WM_MODALKEY(BEV_MODAL_CLAMP_OVERLAP_TOGGLE),
+		WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")),
+		WM_MODALKEY(BEV_MODAL_VERTEX_ONLY_TOGGLE),
+		WM_bool_as_string(RNA_boolean_get(op->ptr, "vertex_only")),
+		WM_MODALKEY(BEV_MODAL_OUTER_MITER_CHANGE),
+		omiter_str,
+		WM_MODALKEY(BEV_MODAL_INNER_MITER_CHANGE),
+		imiter_str,
+		WM_MODALKEY(BEV_MODAL_HARDEN_NORMALS_TOGGLE),
+		WM_bool_as_string(RNA_boolean_get(op->ptr, "harden_normals")),
+		WM_MODALKEY(BEV_MODAL_MARK_SEAM_TOGGLE),
+		WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_seam")),
+		WM_MODALKEY(BEV_MODAL_MARK_SHARP_TOGGLE),
+		WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_sharp"))
+		);
+
+#undef WM_MODALKEY
+
+	ED_workspace_status_text(C, header);
 }
 
 static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
@@ -463,40 +525,96 @@ static void edbm_bevel_numinput_set_value(wmOperator *op)
 	}
 }
 
+wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf)
+{
+	static const EnumPropertyItem modal_items[] = {
+		{BEV_MODAL_CANCEL, "CANCEL", 0, "Cancel", "Cancel bevel"},
+		{BEV_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", "Confirm bevel"},
+		{BEV_MODAL_VALUE_OFFSET, "VALUE_OFFSET", 0, "Value is offset",
+			"Value changes offset"},
+		{BEV_MODAL_VALUE_PROFILE, "VALUE_PROFILE", 0, "Value is profile",
+			"Value changes profile"},
+		{BEV_MODAL_VALUE_SEGMENTS, "VALUE_SEGMENTS", 0, "Value is segments",
+			"Value changes segments"},
+		{BEV_MODAL_SEGMENTS_UP, "SEGMENTS_UP", 0, "Increase segments",
+			"Increase segments"},
+		{BEV_MODAL_SEGMENTS_DOWN, "SEGMENTS_DOWN", 0, "Decrease segments",
+			"Decrease segments"},
+		{BEV_MODAL_OFFSET_MODE_CHANGE, "OFFSET_MODE_CHANGE", 0, "Change offset mode",
+			"Cycle through offset modes"},
+		{BEV_MODAL_CLAMP_OVERLAP_TOGGLE, "CLAMP_OVERLAP_TOGGLE", 0, "Toggle clamp overlap",
+			"Toggle clamp overlap flag"},
+		{BEV_MODAL_VERTEX_ONLY_TOGGLE, "VERTEX_ONLY_TOGGLE", 0, "Toggle vertex only",
+			"Toggle vertex only flag"},
+		{BEV_MODAL_HARDEN_NORMALS_TOGGLE, "HARDEN_NORMALS_TOGGLE", 0, "Toggle harden normals",
+			"Toggle harden normals flag"},
+		{BEV_MODAL_MARK_SEAM_TOGGLE, "MARK_SEAM_TOGGLE", 0, "Toggle mark seam",
+			"Toggle mark seam flag"},
+		{BEV_MODAL_MARK_SHARP_TOGGLE, "MARK_SHARP_TOGGLE", 0, "Toggle mark sharp",
+			"Toggle mark sharp flag"},
+		{BEV_MODAL_OUTER_MITER_CHANGE, "OUTER_MI

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list