Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-05-24 08:46:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-24 08:48:08 +0300
commit7dd888c0cf4039d3224863a7f2d235674d321614 (patch)
treeaade5973ede02058207b2fb401427f1b5351fff7 /source
parent911116e1ba5d5cb63e74c32ba257bc665831c853 (diff)
Keymap: share 3D view transform keymaps
While internally these are separate gizmos, there is no reason to have a keymaps for each. Also prefix the gizmo with "3D View" since there are other kinds of transform gizmos.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c14
-rw-r--r--source/blender/windowmanager/gizmo/WM_gizmo_api.h4
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c17
3 files changed, 28 insertions, 7 deletions
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 16dcd053f9d..ead90b6a67a 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -1976,12 +1976,18 @@ static bool WIDGETGROUP_gizmo_poll_tool(const struct bContext *C, struct wmGizmo
return true;
}
-/* Expose as multiple gizmos so tools use one, persistant context another.
+static wmKeyMap *WIDGETGROUP_gizmo_setup_keymap(const struct wmGizmoGroupType *gzgt,
+ struct wmKeyConfig *config)
+{
+ return WM_gizmogroup_keymap_common_with_name(gzgt, config, "3D View: Transform Gizmo");
+}
+
+/* Expose as multiple gizmos so tools use one, persistent context another.
* Needed because they use different options which isn't so simple to dynamically update. */
void VIEW3D_GGT_xform_gizmo(wmGizmoGroupType *gzgt)
{
- gzgt->name = "Transform Gizmo";
+ gzgt->name = "3D View: Transform Gizmo";
gzgt->idname = "VIEW3D_GGT_xform_gizmo";
gzgt->flag = WM_GIZMOGROUPTYPE_3D;
@@ -1995,6 +2001,7 @@ void VIEW3D_GGT_xform_gizmo(wmGizmoGroupType *gzgt)
gzgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe;
gzgt->draw_prepare = WIDGETGROUP_gizmo_draw_prepare;
gzgt->invoke_prepare = WIDGETGROUP_gizmo_invoke_prepare;
+ gzgt->setup_keymap = WIDGETGROUP_gizmo_setup_keymap;
static const EnumPropertyItem rna_enum_gizmo_items[] = {
{V3D_GIZMO_SHOW_OBJECT_TRANSLATE, "TRANSLATE", 0, "Move", ""},
@@ -2014,7 +2021,7 @@ void VIEW3D_GGT_xform_gizmo(wmGizmoGroupType *gzgt)
/** Only poll, flag & gzmap_params differ. */
void VIEW3D_GGT_xform_gizmo_context(wmGizmoGroupType *gzgt)
{
- gzgt->name = "Transform Gizmo Context";
+ gzgt->name = "3D View: Transform Gizmo Context";
gzgt->idname = "VIEW3D_GGT_xform_gizmo_context";
gzgt->flag = WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_PERSISTENT;
@@ -2025,6 +2032,7 @@ void VIEW3D_GGT_xform_gizmo_context(wmGizmoGroupType *gzgt)
gzgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe;
gzgt->draw_prepare = WIDGETGROUP_gizmo_draw_prepare;
gzgt->invoke_prepare = WIDGETGROUP_gizmo_invoke_prepare;
+ gzgt->setup_keymap = WIDGETGROUP_gizmo_setup_keymap;
}
/** \} */
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h
index 9a272b27f87..4c24762416e 100644
--- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h
+++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h
@@ -235,8 +235,12 @@ void WM_gizmo_target_property_subscribe_all(struct wmGizmo *gz,
/* wmGizmoGroup */
/* Callbacks for 'wmGizmoGroupType.setup_keymap' */
+struct wmKeyMap *WM_gizmogroup_keymap_common_with_name(const struct wmGizmoGroupType *gzgt,
+ struct wmKeyConfig *config,
+ const char *idname);
struct wmKeyMap *WM_gizmogroup_keymap_common(const struct wmGizmoGroupType *gzgt,
struct wmKeyConfig *config);
+
struct wmKeyMap *WM_gizmogroup_keymap_common_select(const struct wmGizmoGroupType *gzgt,
struct wmKeyConfig *config);
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index 85ebd2baefa..68020c736d8 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -680,21 +680,30 @@ static wmKeyMap *gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char
}
/**
- * Common default keymap for gizmo groups
+ * Common default keymap for gizmo groups.
+ *
+ * \param name: Typically #wmGizmoGroupType.name.
*/
-wmKeyMap *WM_gizmogroup_keymap_common(const wmGizmoGroupType *gzgt, wmKeyConfig *config)
+wmKeyMap *WM_gizmogroup_keymap_common_with_name(const wmGizmoGroupType *gzgt,
+ wmKeyConfig *config,
+ const char *name)
{
/* Use area and region id since we might have multiple gizmos
* with the same name in different areas/regions. */
wmKeyMap *km = WM_keymap_ensure(
- config, gzgt->name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid);
+ config, name, gzgt->gzmap_params.spaceid, gzgt->gzmap_params.regionid);
WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
- gizmogroup_tweak_modal_keymap(config, gzgt->name);
+ gizmogroup_tweak_modal_keymap(config, name);
return km;
}
+wmKeyMap *WM_gizmogroup_keymap_common(const wmGizmoGroupType *gzgt, wmKeyConfig *config)
+{
+ return WM_gizmogroup_keymap_common_with_name(gzgt, config, gzgt->name);
+}
+
/**
* Variation of #WM_gizmogroup_keymap_common but with keymap items for selection
*/