[Bf-blender-cvs] [8a41de0f8c9] blender2.8: Cleanup: de-duplicate keymap items

Campbell Barton noreply at git.blender.org
Fri Nov 9 02:46:10 CET 2018


Commit: 8a41de0f8c9db41d17d7f6c844ca2cedf573d969
Author: Campbell Barton
Date:   Fri Nov 9 12:13:59 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB8a41de0f8c9db41d17d7f6c844ca2cedf573d969

Cleanup: de-duplicate keymap items

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 2ae68c54290..a00b2467c83 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -36,6 +36,15 @@ class KeymapParams:
         self.action_mouse = 'ACTIONMOUSE'
 
 
+# ------------------------------------------------------------------------------
+# Constants
+
+# Physical layout.
+NUMBERS_1 = ('ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE', 'ZERO')
+# Numeric order.
+NUMBERS_0 = ('ZERO', 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE')
+
+
 # ------------------------------------------------------------------------------
 # Keymap Item Wrappers
 
@@ -63,6 +72,15 @@ def _template_items_select_actions(operator):
     ]
 
 
+def _template_items_object_subdivision_set():
+    return [
+        ("object.subdivision_set",
+         {"type": NUMBERS_0[i], "value": 'PRESS', "ctrl": True},
+         {"properties": [("level", i)]})
+        for i in range(6)
+    ]
+
+
 def _template_items_gizmo_tweak_value():
     return [
         ("gizmogroup.gizmo_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
@@ -86,6 +104,19 @@ def _template_items_gizmo_tweak_modal():
     ]
 
 
+def _template_items_editmode_mesh_select_mode():
+    return [
+        (
+            "mesh.select_mode",
+            {"type": k, "value": 'PRESS', **key_expand, **key_extend},
+            {"properties": [*prop_extend, *prop_expand, ("type", e)]}
+        )
+        for key_expand, prop_expand in (({}, ()), ({"ctrl": True}, (("use_expand", True),)))
+        for key_extend, prop_extend in (({}, ()), ({"shift": True}, (("use_extend", True),)))
+        for k, e in (('ONE', 'VERT'), ('TWO', 'EDGE'), ('THREE', 'FACE'))
+    ]
+
+
 # ------------------------------------------------------------------------------
 # Window, Screen, Areas, Regions
 
@@ -123,24 +154,22 @@ def km_window(params):
         ("wm.toolbar", {"type": 'SPACE', "value": 'PRESS'}, None),
 
         # Fast editor switching
-        ("wm.context_set_enum", {"type": 'F4', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path", 'area.type'), ("value", 'CONSOLE')]}),
-        ("wm.context_set_enum", {"type": 'F5', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path", 'area.type'), ("value", 'VIEW_3D')]}),
-        ("wm.context_set_enum", {"type": 'F6', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path", 'area.type'), ("value", 'GRAPH_EDITOR')]}),
-        ("wm.context_set_enum", {"type": 'F7', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path", 'area.type'), ("value", 'PROPERTIES')]}),
-        ("wm.context_set_enum", {"type": 'F8', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path", 'area.type'), ("value", 'SEQUENCE_EDITOR')]}),
-        ("wm.context_set_enum", {"type": 'F9', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path", 'area.type'), ("value", 'OUTLINER')]}),
-        ("wm.context_set_enum", {"type": 'F10', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path", 'area.type'), ("value", 'IMAGE_EDITOR')]}),
-        ("wm.context_set_enum", {"type": 'F11', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path", 'area.type'), ("value", 'TEXT_EDITOR')]}),
-        ("wm.context_set_enum", {"type": 'F12', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path", 'area.type'), ("value", 'DOPESHEET_EDITOR')]}),
+        *(
+            ("wm.context_set_enum",
+             {"type": k, "value": 'PRESS', "shift": True},
+             {"properties": [("data_path", 'area.type'), ("value", t)]})
+            for k, t in (
+                ('F4', 'CONSOLE'),
+                ('F5', 'VIEW_3D'),
+                ('F6', 'GRAPH_EDITOR'),
+                ('F7', 'PROPERTIES'),
+                ('F8', 'SEQUENCE_EDITOR'),
+                ('F9', 'OUTLINER'),
+                ('F10', 'IMAGE_EDITOR'),
+                ('F11', 'TEXT_EDITOR'),
+                ('F12', 'DOPESHEET_EDITOR'),
+            )
+        ),
 
         # NDOF settings
         op_menu("USERPREF_MT_ndof_settings", {"type": 'NDOF_BUTTON_MENU', "value": 'PRESS'}),
@@ -511,31 +540,8 @@ def km_uv_editor(params):
     )
 
     items.extend([
-        # TODO: expand into loop.
-        ("mesh.select_mode", {"type": 'ONE', "value": 'PRESS'},
-         {"properties": [("type", 'VERT')]}),
-        ("mesh.select_mode", {"type": 'TWO', "value": 'PRESS'},
-         {"properties": [("type", 'EDGE')]}),
-        ("mesh.select_mode", {"type": 'THREE', "value": 'PRESS'},
-         {"properties": [("type", 'FACE')]}),
-        ("mesh.select_mode", {"type": 'ONE', "value": 'PRESS', "shift": True},
-         {"properties": [("use_extend", True), ("type", 'VERT')]}),
-        ("mesh.select_mode", {"type": 'TWO', "value": 'PRESS', "shift": True},
-         {"properties": [("use_extend", True), ("type", 'EDGE')]}),
-        ("mesh.select_mode", {"type": 'THREE', "value": 'PRESS', "shift": True},
-         {"properties": [("use_extend", True), ("type", 'FACE')]}),
-        ("mesh.select_mode", {"type": 'ONE', "value": 'PRESS', "ctrl": True},
-         {"properties": [("use_expand", True), ("type", 'VERT')]}),
-        ("mesh.select_mode", {"type": 'TWO', "value": 'PRESS', "ctrl": True},
-         {"properties": [("use_expand", True), ("type", 'EDGE')]}),
-        ("mesh.select_mode", {"type": 'THREE', "value": 'PRESS', "ctrl": True},
-         {"properties": [("use_expand", True), ("type", 'FACE')]}),
-        ("mesh.select_mode", {"type": 'ONE', "value": 'PRESS', "shift": True, "ctrl": True},
-         {"properties": [("use_extend", True), ("use_expand", True), ("type", 'VERT')]}),
-        ("mesh.select_mode", {"type": 'TWO', "value": 'PRESS', "shift": True, "ctrl": True},
-         {"properties": [("use_extend", True), ("use_expand", True), ("type", 'EDGE')]}),
-        ("mesh.select_mode", {"type": 'THREE', "value": 'PRESS', "shift": True, "ctrl": True},
-         {"properties": [("use_extend", True), ("use_expand", True), ("type", 'FACE')]}),
+        # Selection modes.
+        *_template_items_editmode_mesh_select_mode(),
         ("mesh.select_mode", {"type": 'FOUR', "value": 'PRESS'}, None),
         ("wm.context_set_enum", {"type": 'ONE', "value": 'PRESS'},
          {"properties": [("data_path", 'tool_settings.uv_select_mode'), ("value", 'VERTEX')]}),
@@ -1313,25 +1319,13 @@ def km_image(params):
          {"properties": [("point", 'WHITE_POINT')]}),
         ("object.mode_set", {"type": 'TAB', "value": 'PRESS'},
          {"properties": [("mode", 'EDIT'), ("toggle", True)]}),
-        # TODO: expand into loop.
-        ("wm.context_set_int", {"type": 'ONE', "value": 'PRESS'},
-         {"properties": [("data_path", 'space_data.image.render_slots.active_index'), ("value", 0)]}),
-        ("wm.context_set_int", {"type": 'TWO', "value": 'PRESS'},
-         {"properties": [("data_path", 'space_data.image.render_slots.active_index'), ("value", 1)]}),
-        ("wm.context_set_int", {"type": 'THREE', "value": 'PRESS'},
-         {"properties": [("data_path", 'space_data.image.render_slots.active_index'), ("value", 2)]}),
-        ("wm.context_set_int", {"type": 'FOUR', "value": 'PRESS'},
-         {"properties": [("data_path", 'space_data.image.render_slots.active_index'), ("value", 3)]}),
-        ("wm.context_set_int", {"type": 'FIVE', "value": 'PRESS'},
-         {"properties": [("data_path", 'space_data.image.render_slots.active_index'), ("value", 4)]}),
-        ("wm.context_set_int", {"type": 'SIX', "value": 'PRESS'},
-         {"properties": [("data_path", 'space_data.image.render_slots.active_index'), ("value", 5)]}),
-        ("wm.context_set_int", {"type": 'SEVEN', "value": 'PRESS'},
-         {"properties": [("data_path", 'space_data.image.render_slots.active_index'), ("value", 6)]}),
-        ("wm.context_set_int", {"type": 'EIGHT', "value": 'PRESS'},
-         {"properties": [("data_path", 'space_data.image.render_slots.active_index'), ("value", 7)]}),
-        ("wm.context_set_int", {"type": 'NINE', "value": 'PRESS'},
-         {"properties": [("data_path", 'space_data.image.render_slots.active_index'), ("value", 8)]}),
+        *(
+            (("wm.context_set_int",
+              {"type": NUMBERS_1[i], "value": 'PRESS'},
+              {"properties": [("data_path", 'space_data.image.render_slots.active_index'), ("value", i)]})
+             for i in range(9)
+             )
+        ),
         op_menu_pie("IMAGE_MT_pivot_pie", {"type": 'PERIOD', "value": 'PRESS'}),
         ("image.render_border", {"type": 'B', "value": 'PRESS', "ctrl": True}, None),
         ("image.clear_render_border", {"type": 'B', "value": 'PRESS', "ctrl": True, "alt": True}, None),
@@ -2157,27 +2151,13 @@ def km_sequencer(params):
         ("sequencer.gap_insert", {"type": 'EQUAL', "value": 'PRESS', "shift": True}, None),
         ("sequencer.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None),
         ("sequencer.swap_inputs", {"type": 'S', "value": 'PRESS', "alt": True}, None),
-        # TODO: expand into loop.
-        ("sequencer.cut_multicam", {"type": 'ONE', "value": 'PRESS'},
-         {"properties": [("camera", 1)]}),
-        ("sequencer.cut_multicam", {"type": 'TWO', "value": 'PRESS'},
-         {"properties": [("camera", 2)]}),
-        ("sequencer.cut_multicam", {"type": 'THREE', "value": 'PRESS'},
-         {"properties": [("camera", 3)]}),
-        ("sequencer.cut_multicam", {"type": 'FOUR', "value": 'PRESS'},
-         {"properties": [("camera", 4)]}),
-        ("sequencer.cut_multicam", {"type": 'FIVE', "value": 'PRESS'},
-         {"properties": [("camera", 5)]}),
-        ("sequencer.cut_multicam", {"type": 'SIX', "value": 'PRESS'},
-         {"properties": [("camera", 6)]}),
-        ("sequencer.cut_multicam", {"type": 'SEVEN', "value": 'PRESS'},
-         {"properties": [("camera", 7)]}),
-        ("sequencer.cut_multicam", {"type": 'EIGHT', "value": 'PRESS'},
-         {"properties

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list