2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2010-03-21 01:14:04 +00:00
|
|
|
* $Id$
|
2007-12-24 18:27:28 +00:00
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-12-24 18:27:28 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2007 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-25 14:04:21 +00:00
|
|
|
/** \file blender/windowmanager/intern/wm_keymap.c
|
|
|
|
* \ingroup wm
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2007-12-24 18:27:28 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2009-12-24 09:26:06 +00:00
|
|
|
#include "DNA_object_types.h"
|
2008-12-16 07:44:21 +00:00
|
|
|
#include "DNA_screen_types.h"
|
2009-12-24 09:26:06 +00:00
|
|
|
#include "DNA_space_types.h"
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
2007-12-24 18:27:28 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2007-12-24 18:27:28 +00:00
|
|
|
|
|
|
|
#include "BKE_blender.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2009-01-28 23:29:27 +00:00
|
|
|
#include "BKE_idprop.h"
|
2007-12-24 18:27:28 +00:00
|
|
|
#include "BKE_library.h"
|
|
|
|
#include "BKE_main.h"
|
2010-02-07 23:39:44 +00:00
|
|
|
#include "BKE_screen.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2.5: added support for setting RNA properties in keymap item,
which will then be set when the operator is called, example:
kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "dir", 'h');
kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "dir", 'v');
There is a hack I had to do here, since properties are defined
as member of wmOperator, will try to fix later, committing now
so it can be used already.
2008-12-15 13:10:29 +00:00
|
|
|
#include "RNA_access.h"
|
2009-06-21 14:30:59 +00:00
|
|
|
#include "RNA_enum_types.h"
|
2.5: added support for setting RNA properties in keymap item,
which will then be set when the operator is called, example:
kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "dir", 'h');
kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "dir", 'v');
There is a hack I had to do here, since properties are defined
as member of wmOperator, will try to fix later, committing now
so it can be used already.
2008-12-15 13:10:29 +00:00
|
|
|
|
2007-12-24 18:27:28 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
#include "wm_window.h"
|
|
|
|
#include "wm_event_system.h"
|
|
|
|
#include "wm_event_types.h"
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
/* ********************* key config ***********************/
|
|
|
|
|
2010-01-27 21:19:39 +00:00
|
|
|
static void keymap_properties_set(wmKeyMapItem *kmi)
|
|
|
|
{
|
|
|
|
WM_operator_properties_alloc(&(kmi->ptr), &(kmi->properties), kmi->idname);
|
2010-02-01 18:26:45 +00:00
|
|
|
WM_operator_properties_sanitize(kmi->ptr, 1);
|
2010-01-27 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
2010-11-10 11:19:52 +00:00
|
|
|
/* properties can be NULL, otherwise the arg passed is used and ownership is given to the kmi */
|
|
|
|
void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties)
|
2009-12-02 04:12:16 +00:00
|
|
|
{
|
|
|
|
WM_operator_properties_free(kmi->ptr);
|
|
|
|
MEM_freeN(kmi->ptr);
|
|
|
|
|
|
|
|
kmi->ptr = NULL;
|
2010-11-10 11:19:52 +00:00
|
|
|
kmi->properties = properties;
|
2009-12-02 04:12:16 +00:00
|
|
|
|
2010-01-27 21:19:39 +00:00
|
|
|
keymap_properties_set(kmi);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname)
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
{
|
|
|
|
wmKeyConfig *keyconf;
|
|
|
|
|
|
|
|
keyconf= MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig");
|
|
|
|
BLI_strncpy(keyconf->idname, idname, sizeof(keyconf->idname));
|
|
|
|
BLI_addtail(&wm->keyconfigs, keyconf);
|
|
|
|
|
|
|
|
return keyconf;
|
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
wmKeyConfig *WM_keyconfig_new_user(wmWindowManager *wm, const char *idname)
|
2010-01-28 19:54:06 +00:00
|
|
|
{
|
2010-08-30 13:50:59 +00:00
|
|
|
wmKeyConfig *keyconf = WM_keyconfig_new(wm, idname);
|
2010-01-28 19:54:06 +00:00
|
|
|
|
|
|
|
keyconf->flag |= KEYCONF_USER;
|
|
|
|
|
|
|
|
return keyconf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
|
|
|
|
{
|
|
|
|
if (keyconf) {
|
|
|
|
if (BLI_streq(U.keyconfigstr, keyconf->idname)) {
|
|
|
|
BLI_strncpy(U.keyconfigstr, wm->defaultconf->idname, sizeof(U.keyconfigstr));
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_remlink(&wm->keyconfigs, keyconf);
|
|
|
|
WM_keyconfig_free(keyconf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
void WM_keyconfig_free(wmKeyConfig *keyconf)
|
|
|
|
{
|
|
|
|
wmKeyMap *km;
|
|
|
|
|
|
|
|
while((km= keyconf->keymaps.first)) {
|
|
|
|
WM_keymap_free(km);
|
|
|
|
BLI_freelinkN(&keyconf->keymaps, km);
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(keyconf);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
void WM_keyconfig_userdef(void)
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
{
|
|
|
|
wmKeyMap *km;
|
|
|
|
wmKeyMapItem *kmi;
|
|
|
|
|
2009-11-15 19:25:34 +00:00
|
|
|
for(km=U.keymaps.first; km; km=km->next) {
|
|
|
|
/* modal keymaps don't have operator properties */
|
|
|
|
if ((km->flag & KEYMAP_MODAL) == 0) {
|
|
|
|
for(kmi=km->items.first; kmi; kmi=kmi->next) {
|
|
|
|
keymap_properties_set(kmi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static wmKeyConfig *wm_keyconfig_list_find(ListBase *lb, char *idname)
|
|
|
|
{
|
|
|
|
wmKeyConfig *kc;
|
|
|
|
|
|
|
|
for(kc= lb->first; kc; kc= kc->next)
|
|
|
|
if(0==strncmp(idname, kc->idname, KMAP_MAX_NAME))
|
|
|
|
return kc;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************ free ************************* */
|
|
|
|
|
|
|
|
void WM_keymap_free(wmKeyMap *keymap)
|
|
|
|
{
|
|
|
|
wmKeyMapItem *kmi;
|
|
|
|
|
|
|
|
for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
|
|
|
|
if(kmi->ptr) {
|
|
|
|
WM_operator_properties_free(kmi->ptr);
|
|
|
|
MEM_freeN(kmi->ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelistN(&keymap->items);
|
|
|
|
}
|
|
|
|
|
2007-12-24 18:27:28 +00:00
|
|
|
/* ***************** generic call, exported **************** */
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modifier, short keymodifier)
|
2007-12-24 18:27:28 +00:00
|
|
|
{
|
2008-12-08 15:02:57 +00:00
|
|
|
kmi->type= type;
|
|
|
|
kmi->val= val;
|
|
|
|
kmi->keymodifier= keymodifier;
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2008-12-22 12:57:53 +00:00
|
|
|
if(modifier == KM_ANY) {
|
|
|
|
kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= KM_ANY;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
2009-07-28 16:48:02 +00:00
|
|
|
kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= 0;
|
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* defines? */
|
2008-12-22 12:57:53 +00:00
|
|
|
if(modifier & KM_SHIFT)
|
|
|
|
kmi->shift= 1;
|
|
|
|
else if(modifier & KM_SHIFT2)
|
|
|
|
kmi->shift= 2;
|
|
|
|
if(modifier & KM_CTRL)
|
|
|
|
kmi->ctrl= 1;
|
|
|
|
else if(modifier & KM_CTRL2)
|
|
|
|
kmi->ctrl= 2;
|
|
|
|
if(modifier & KM_ALT)
|
|
|
|
kmi->alt= 1;
|
|
|
|
else if(modifier & KM_ALT2)
|
|
|
|
kmi->alt= 2;
|
|
|
|
if(modifier & KM_OSKEY)
|
|
|
|
kmi->oskey= 1;
|
|
|
|
else if(modifier & KM_OSKEY2)
|
|
|
|
kmi->oskey= 2;
|
|
|
|
}
|
2007-12-24 18:27:28 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 02:42:59 +00:00
|
|
|
static void keymap_item_set_id(wmKeyMap *keymap, wmKeyMapItem *kmi)
|
|
|
|
{
|
|
|
|
keymap->kmi_id++;
|
|
|
|
if ((keymap->flag & KEYMAP_USER) == 0) {
|
|
|
|
kmi->id = keymap->kmi_id;
|
|
|
|
} else {
|
|
|
|
kmi->id = -keymap->kmi_id; // User defined keymap entries have negative ids
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-24 10:45:36 +00:00
|
|
|
/* if item was added, then bail out */
|
2010-12-03 17:05:21 +00:00
|
|
|
wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
|
2007-12-24 18:27:28 +00:00
|
|
|
{
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMapItem *kmi;
|
2007-12-24 18:27:28 +00:00
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
for(kmi= keymap->items.first; kmi; kmi= kmi->next)
|
2008-12-08 15:02:57 +00:00
|
|
|
if(strncmp(kmi->idname, idname, OP_MAX_TYPENAME)==0)
|
2007-12-24 18:27:28 +00:00
|
|
|
break;
|
2008-12-08 15:02:57 +00:00
|
|
|
if(kmi==NULL) {
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
kmi= MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
|
2007-12-24 18:27:28 +00:00
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
BLI_addtail(&keymap->items, kmi);
|
2008-12-08 15:02:57 +00:00
|
|
|
BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
|
2007-12-24 18:27:28 +00:00
|
|
|
|
2010-12-06 02:42:59 +00:00
|
|
|
keymap_item_set_id(keymap, kmi);
|
2009-12-21 01:44:33 +00:00
|
|
|
|
2.5: added support for setting RNA properties in keymap item,
which will then be set when the operator is called, example:
kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "dir", 'h');
kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "dir", 'v');
There is a hack I had to do here, since properties are defined
as member of wmOperator, will try to fix later, committing now
so it can be used already.
2008-12-15 13:10:29 +00:00
|
|
|
keymap_event_set(kmi, type, val, modifier, keymodifier);
|
|
|
|
keymap_properties_set(kmi);
|
2007-12-24 18:27:28 +00:00
|
|
|
}
|
2008-12-15 11:45:17 +00:00
|
|
|
return kmi;
|
2007-12-24 18:27:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-10 17:38:17 +00:00
|
|
|
/* always add item */
|
2010-11-17 09:45:45 +00:00
|
|
|
wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
|
2008-01-10 17:38:17 +00:00
|
|
|
{
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMapItem *kmi= MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
|
2008-01-10 17:38:17 +00:00
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
BLI_addtail(&keymap->items, kmi);
|
2008-12-08 15:02:57 +00:00
|
|
|
BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
|
2008-01-10 17:38:17 +00:00
|
|
|
|
2.5: added support for setting RNA properties in keymap item,
which will then be set when the operator is called, example:
kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "dir", 'h');
kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "dir", 'v');
There is a hack I had to do here, since properties are defined
as member of wmOperator, will try to fix later, committing now
so it can be used already.
2008-12-15 13:10:29 +00:00
|
|
|
keymap_event_set(kmi, type, val, modifier, keymodifier);
|
|
|
|
keymap_properties_set(kmi);
|
2009-12-17 03:32:33 +00:00
|
|
|
|
2010-12-06 02:42:59 +00:00
|
|
|
keymap_item_set_id(keymap, kmi);
|
2009-12-17 03:32:33 +00:00
|
|
|
|
2008-12-15 11:45:17 +00:00
|
|
|
return kmi;
|
|
|
|
}
|
|
|
|
|
2009-11-17 15:29:55 +00:00
|
|
|
/* menu wrapper for WM_keymap_add_item */
|
2010-12-03 17:05:21 +00:00
|
|
|
wmKeyMapItem *WM_keymap_add_menu(wmKeyMap *keymap, const char *idname, int type, int val, int modifier, int keymodifier)
|
2009-11-17 15:29:55 +00:00
|
|
|
{
|
|
|
|
wmKeyMapItem *kmi= WM_keymap_add_item(keymap, "WM_OT_call_menu", type, val, modifier, keymodifier);
|
|
|
|
RNA_string_set(kmi->ptr, "name", idname);
|
|
|
|
return kmi;
|
|
|
|
}
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
|
|
|
|
{
|
|
|
|
if(BLI_findindex(&keymap->items, kmi) != -1) {
|
|
|
|
if(kmi->ptr) {
|
|
|
|
WM_operator_properties_free(kmi->ptr);
|
|
|
|
MEM_freeN(kmi->ptr);
|
|
|
|
}
|
|
|
|
BLI_freelinkN(&keymap->items, kmi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
/* ****************** storage in WM ************ */
|
|
|
|
|
|
|
|
/* name id's are for storing general or multiple keymaps,
|
|
|
|
space/region ids are same as DNA_space_types.h */
|
|
|
|
/* gets free'd in wm.c */
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid)
|
2008-12-08 15:02:57 +00:00
|
|
|
{
|
|
|
|
wmKeyMap *km;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
|
|
|
for(km= lb->first; km; km= km->next)
|
2008-12-08 15:02:57 +00:00
|
|
|
if(km->spaceid==spaceid && km->regionid==regionid)
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
if(0==strncmp(idname, km->idname, KMAP_MAX_NAME))
|
2009-09-17 21:36:02 +00:00
|
|
|
return km;
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
{
|
2009-12-08 18:02:50 +00:00
|
|
|
wmKeyMap *km= WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
2008-12-08 15:02:57 +00:00
|
|
|
if(km==NULL) {
|
|
|
|
km= MEM_callocN(sizeof(struct wmKeyMap), "keymap list");
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
BLI_strncpy(km->idname, idname, KMAP_MAX_NAME);
|
2008-12-08 15:02:57 +00:00
|
|
|
km->spaceid= spaceid;
|
|
|
|
km->regionid= regionid;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
BLI_addtail(&keyconf->keymaps, km);
|
2008-12-08 15:02:57 +00:00
|
|
|
}
|
|
|
|
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
return km;
|
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid, int regionid)
|
2009-12-24 09:26:06 +00:00
|
|
|
{
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
wmKeyConfig *keyconf;
|
|
|
|
wmKeyMap *km;
|
|
|
|
|
|
|
|
/* first user defined keymaps */
|
|
|
|
km= WM_keymap_list_find(&U.keymaps, idname, spaceid, regionid);
|
|
|
|
if (km)
|
|
|
|
return km;
|
|
|
|
|
|
|
|
/* then user key config */
|
|
|
|
keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
|
|
|
|
if(keyconf) {
|
|
|
|
km= WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
|
|
|
|
if (km)
|
|
|
|
return km;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then use default */
|
|
|
|
km= WM_keymap_list_find(&wm->defaultconf->keymaps, idname, spaceid, regionid);
|
|
|
|
if (km)
|
|
|
|
return km;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
/* ****************** modal keymaps ************ */
|
|
|
|
|
|
|
|
/* modal maps get linked to a running operator, and filter the keys before sending to modal() callback */
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, EnumPropertyItem *items)
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
{
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMap *km= WM_keymap_find(keyconf, idname, 0, 0);
|
|
|
|
km->flag |= KEYMAP_MODAL;
|
|
|
|
km->modal_items= items;
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
|
|
|
|
return km;
|
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname)
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
{
|
|
|
|
wmKeyMap *km;
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
for(km= keyconf->keymaps.first; km; km= km->next)
|
|
|
|
if(km->flag & KEYMAP_MODAL)
|
|
|
|
if(0==strncmp(idname, km->idname, KMAP_MAX_NAME))
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
return km;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-16 20:50:02 +00:00
|
|
|
wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value)
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
{
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMapItem *kmi= MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
BLI_addtail(&km->items, kmi);
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
kmi->propvalue= value;
|
|
|
|
|
|
|
|
keymap_event_set(kmi, type, val, modifier, keymodifier);
|
2009-11-16 20:50:02 +00:00
|
|
|
|
2010-12-06 02:42:59 +00:00
|
|
|
keymap_item_set_id(km, kmi);
|
2009-12-17 03:32:33 +00:00
|
|
|
|
2009-11-16 20:50:02 +00:00
|
|
|
return kmi;
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
|
2.5
Modal keymaps.
I've tried to make it as simple as possible, yet still using sufficient facilities to enable self-documenting UIs, saving/reading in files, and proper Python support.
The simplicity is: the 'modal keymap' just checks an event, uses event matching similarly to other keymap matching, and if there's a match it changes the event type, and sets the event value to what the modal keymap has defined. The event values are being defined using EnumPropertyItem structs, so the UI will be able to show all options in self-documenting way.
This system also allows to still handle hardcoded own events.
Tech doc:
1) define keymap
- Create map with unique name, WM_modalkeymap_add()
- Give map property definitions (EnumPropertyItem *)
This only for UI, so user can get information on available options
2) items
- WM_modalkeymap_add_item(): give it an enum value for events
3) activate
- In keymap definition code, assign the modal keymap to operatortype
WM_modalkeymap_assign()
4) event manager
- The event handler will check for modal keymap, if so:
- If the modal map has a match:
- Sets event->type to EVT_MODAL_MAP
- Sets event->val to the enum value
5) modal handler
- If event type is EVT_MODAL_MAP:
- Check event->val, handle it
- Other events can just be handled still
Two examples added in the code:
editors/transform/transform.c: transform_modal_keymap()
editors/screen/screen_ops.c: keymap_modal_set()
Also: to support 'key release' the define KM_RELEASE now is officially
used in event manager, this is not '0', so don't check key events with
the old convention if(event->val) but use if(event->val==KM_PRESS)
2009-07-21 11:03:07 +00:00
|
|
|
{
|
|
|
|
wmOperatorType *ot= WM_operatortype_find(opname, 0);
|
|
|
|
|
|
|
|
if(ot)
|
|
|
|
ot->modalkeymap= km;
|
|
|
|
else
|
|
|
|
printf("error: modalkeymap_assign, unknown operator %s\n", opname);
|
|
|
|
}
|
|
|
|
|
2008-12-16 07:32:12 +00:00
|
|
|
/* ***************** get string from key events **************** */
|
|
|
|
|
2009-06-29 12:06:46 +00:00
|
|
|
const char *WM_key_event_string(short type)
|
2008-12-16 07:32:12 +00:00
|
|
|
{
|
2009-06-21 14:30:59 +00:00
|
|
|
const char *name= NULL;
|
|
|
|
if(RNA_enum_name(event_type_items, (int)type, &name))
|
|
|
|
return name;
|
2008-12-16 07:32:12 +00:00
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
|
2008-12-16 07:44:21 +00:00
|
|
|
{
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
char buf[128];
|
2008-12-16 07:44:21 +00:00
|
|
|
|
|
|
|
buf[0]= 0;
|
|
|
|
|
2009-11-15 19:25:34 +00:00
|
|
|
if (kmi->shift == KM_ANY &&
|
|
|
|
kmi->ctrl == KM_ANY &&
|
|
|
|
kmi->alt == KM_ANY &&
|
|
|
|
kmi->oskey == KM_ANY) {
|
2008-12-16 07:44:21 +00:00
|
|
|
|
2009-11-15 19:25:34 +00:00
|
|
|
strcat(buf, "Any ");
|
|
|
|
} else {
|
|
|
|
if(kmi->shift)
|
|
|
|
strcat(buf, "Shift ");
|
2008-12-16 07:44:21 +00:00
|
|
|
|
2009-11-15 19:25:34 +00:00
|
|
|
if(kmi->ctrl)
|
|
|
|
strcat(buf, "Ctrl ");
|
2008-12-16 17:36:51 +00:00
|
|
|
|
2009-11-15 19:25:34 +00:00
|
|
|
if(kmi->alt)
|
|
|
|
strcat(buf, "Alt ");
|
|
|
|
|
|
|
|
if(kmi->oskey)
|
|
|
|
strcat(buf, "Cmd ");
|
|
|
|
}
|
2009-10-25 03:47:14 +00:00
|
|
|
|
|
|
|
if(kmi->keymodifier) {
|
|
|
|
strcat(buf, WM_key_event_string(kmi->keymodifier));
|
|
|
|
strcat(buf, " ");
|
|
|
|
}
|
2008-12-16 07:44:21 +00:00
|
|
|
|
|
|
|
strcat(buf, WM_key_event_string(kmi->type));
|
|
|
|
BLI_strncpy(str, buf, len);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext), IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
|
2008-12-16 07:44:21 +00:00
|
|
|
{
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmWindowManager *wm= CTX_wm_manager(C);
|
2008-12-16 07:44:21 +00:00
|
|
|
wmEventHandler *handler;
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMapItem *kmi;
|
2008-12-16 07:44:21 +00:00
|
|
|
|
2009-01-28 23:29:27 +00:00
|
|
|
/* find keymap item in handlers */
|
2009-09-10 14:20:21 +00:00
|
|
|
for(handler=handlers->first; handler; handler=handler->next) {
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
keymap= WM_keymap_active(wm, handler->keymap);
|
2009-09-17 21:36:02 +00:00
|
|
|
|
|
|
|
if(keymap && (!keymap->poll || keymap->poll((bContext*)C))) {
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
|
2011-02-25 16:32:03 +00:00
|
|
|
|
2009-09-10 14:20:21 +00:00
|
|
|
if(strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) {
|
2010-01-26 01:02:10 +00:00
|
|
|
if (hotkey)
|
|
|
|
if (!ISHOTKEY(kmi->type))
|
|
|
|
continue;
|
|
|
|
|
2009-09-10 14:20:21 +00:00
|
|
|
if(compare_props) {
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
if(kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) {
|
|
|
|
if(keymap_r) *keymap_r= keymap;
|
2009-09-10 14:20:21 +00:00
|
|
|
return kmi;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
2009-09-10 14:20:21 +00:00
|
|
|
}
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
else {
|
|
|
|
if(keymap_r) *keymap_r= keymap;
|
2009-07-28 16:48:02 +00:00
|
|
|
return kmi;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
2009-09-10 14:20:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-28 23:29:27 +00:00
|
|
|
|
2010-01-26 10:14:39 +00:00
|
|
|
/* ensure un-initialized keymap is never used */
|
|
|
|
if(keymap_r) *keymap_r= NULL;
|
2009-01-28 23:29:27 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-01-26 01:02:10 +00:00
|
|
|
static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r)
|
2009-01-28 23:29:27 +00:00
|
|
|
{
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmWindow *win= CTX_wm_window(C);
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
wmKeyMapItem *found= NULL;
|
2009-01-28 23:29:27 +00:00
|
|
|
|
|
|
|
/* look into multiple handler lists to find the item */
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
if(win)
|
2010-01-26 01:02:10 +00:00
|
|
|
found= wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
2009-07-28 16:48:02 +00:00
|
|
|
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
if(sa && found==NULL)
|
2010-01-26 01:02:10 +00:00
|
|
|
found= wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
2009-07-28 16:48:02 +00:00
|
|
|
|
|
|
|
if(found==NULL) {
|
|
|
|
if(ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) {
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
if(sa) {
|
2010-02-07 23:39:44 +00:00
|
|
|
if (!(ar && ar->regiontype == RGN_TYPE_WINDOW))
|
|
|
|
ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
|
|
|
|
2009-07-28 16:48:02 +00:00
|
|
|
if(ar)
|
2010-02-15 14:15:34 +00:00
|
|
|
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
2009-07-28 16:48:02 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-07 23:39:44 +00:00
|
|
|
else if(ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) {
|
|
|
|
if (!(ar && ar->regiontype == RGN_TYPE_CHANNELS))
|
|
|
|
ar= BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
|
|
|
|
|
|
|
|
if(ar)
|
2010-02-15 14:15:34 +00:00
|
|
|
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
2010-02-07 23:39:44 +00:00
|
|
|
}
|
|
|
|
else if(ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) {
|
|
|
|
if (!(ar && ar->regiontype == RGN_TYPE_PREVIEW))
|
|
|
|
ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
|
|
|
|
|
|
|
|
if(ar)
|
2010-02-15 14:15:34 +00:00
|
|
|
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
2010-02-07 23:39:44 +00:00
|
|
|
}
|
2009-07-28 16:48:02 +00:00
|
|
|
else {
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
if(ar)
|
2010-02-15 14:15:34 +00:00
|
|
|
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
2008-12-16 07:44:21 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-28 16:48:02 +00:00
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2010-01-26 01:02:10 +00:00
|
|
|
static wmKeyMapItem *wm_keymap_item_find(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int hotkey, wmKeyMap **keymap_r)
|
2009-07-28 16:48:02 +00:00
|
|
|
{
|
2010-01-26 01:02:10 +00:00
|
|
|
wmKeyMapItem *found= wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r);
|
2009-09-10 14:20:21 +00:00
|
|
|
|
|
|
|
if(!found)
|
2010-02-15 14:15:34 +00:00
|
|
|
found= wm_keymap_item_find_props(C, opname, opcontext, NULL, 0, hotkey, keymap_r);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *WM_key_event_operator_string(const bContext *C, const char *opname, int opcontext, IDProperty *properties, char *str, int len)
|
|
|
|
{
|
2010-01-26 01:02:10 +00:00
|
|
|
wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, 0, NULL);
|
2009-07-28 16:48:02 +00:00
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
if(kmi) {
|
|
|
|
WM_keymap_item_to_string(kmi, str, len);
|
2009-07-28 16:48:02 +00:00
|
|
|
return str;
|
2008-12-16 07:44:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-01-26 01:02:10 +00:00
|
|
|
int WM_key_event_operator_id(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int hotkey, wmKeyMap **keymap_r)
|
2009-12-24 09:26:06 +00:00
|
|
|
{
|
2010-01-26 01:02:10 +00:00
|
|
|
wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, hotkey, keymap_r);
|
2009-12-24 09:26:06 +00:00
|
|
|
|
|
|
|
if(kmi)
|
|
|
|
return kmi->id;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Keymap conflict detection operator.
Takes into account the hierarchical structures of keymaps as well as wildcards (KM_ANY) in event definitions, user remaps (emulate numpad, action/select mouse buttons, ...) and event values that overlap (click, press and release)
For now, doesn't do anything other than print conflicts in the console.
As a result, I cleaned up a lot of keymaps that had double definitions, moved some keymap items in more appropriate places, fixed wrong definitions and removed kmi that were added for testing a long long time ago.
Out of all the remaining conflicts, after removing obvious non-issues, here's what remains: http://www.pasteall.org/9898
2009-12-17 22:14:43 +00:00
|
|
|
int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
|
|
|
|
{
|
|
|
|
int k1type, k2type;
|
|
|
|
|
|
|
|
if (k1->flag & KMI_INACTIVE || k2->flag & KMI_INACTIVE)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* take event mapping into account */
|
|
|
|
k1type = WM_userdef_event_map(k1->type);
|
|
|
|
k2type = WM_userdef_event_map(k2->type);
|
|
|
|
|
|
|
|
if(k1type != KM_ANY && k2type != KM_ANY && k1type != k2type)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(k1->val != KM_ANY && k2->val != KM_ANY) {
|
|
|
|
/* take click, press, release conflict into account */
|
|
|
|
if (k1->val == KM_CLICK && ELEM3(k2->val, KM_PRESS, KM_RELEASE, KM_CLICK) == 0)
|
|
|
|
return 0;
|
|
|
|
if (k2->val == KM_CLICK && ELEM3(k1->val, KM_PRESS, KM_RELEASE, KM_CLICK) == 0)
|
|
|
|
return 0;
|
|
|
|
if (k1->val != k2->val)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(k1->shift != KM_ANY && k2->shift != KM_ANY && k1->shift != k2->shift)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(k1->ctrl != KM_ANY && k2->ctrl != KM_ANY && k1->ctrl != k2->ctrl)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(k1->alt != KM_ANY && k2->alt != KM_ANY && k1->alt != k2->alt)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(k1->oskey != KM_ANY && k2->oskey != KM_ANY && k1->oskey != k2->oskey)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(k1->keymodifier != k2->keymodifier)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
/* ***************** user preferences ******************* */
|
2009-09-10 14:20:21 +00:00
|
|
|
|
2009-11-15 19:25:34 +00:00
|
|
|
int WM_keymap_user_init(wmWindowManager *wm, wmKeyMap *keymap)
|
|
|
|
{
|
|
|
|
wmKeyConfig *keyconf;
|
|
|
|
wmKeyMap *km;
|
|
|
|
|
|
|
|
if(!keymap)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* init from user key config */
|
|
|
|
keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
|
|
|
|
if(keyconf) {
|
2009-12-08 18:02:50 +00:00
|
|
|
km= WM_keymap_list_find(&keyconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
2009-11-15 19:25:34 +00:00
|
|
|
if(km) {
|
|
|
|
keymap->poll= km->poll; /* lazy init */
|
|
|
|
keymap->modal_items= km->modal_items;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* or from default */
|
2009-12-08 18:02:50 +00:00
|
|
|
km= WM_keymap_list_find(&wm->defaultconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
2009-11-15 19:25:34 +00:00
|
|
|
if(km) {
|
|
|
|
keymap->poll= km->poll; /* lazy init */
|
|
|
|
keymap->modal_items= km->modal_items;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
|
|
|
|
{
|
|
|
|
wmKeyConfig *keyconf;
|
|
|
|
wmKeyMap *km;
|
2009-07-28 16:48:02 +00:00
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
if(!keymap)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* first user defined keymaps */
|
2009-12-08 18:02:50 +00:00
|
|
|
km= WM_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
2009-10-19 11:11:35 +00:00
|
|
|
if(km) {
|
|
|
|
km->poll= keymap->poll; /* lazy init */
|
2009-11-15 19:25:34 +00:00
|
|
|
km->modal_items= keymap->modal_items;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
return km;
|
2009-10-19 11:11:35 +00:00
|
|
|
}
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
|
|
|
/* then user key config */
|
|
|
|
keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
|
|
|
|
if(keyconf) {
|
2009-12-08 18:02:50 +00:00
|
|
|
km= WM_keymap_list_find(&keyconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
2009-10-19 11:11:35 +00:00
|
|
|
if(km) {
|
|
|
|
km->poll= keymap->poll; /* lazy init */
|
2009-11-15 19:25:34 +00:00
|
|
|
km->modal_items= keymap->modal_items;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
return km;
|
2009-10-19 11:11:35 +00:00
|
|
|
}
|
2009-07-28 16:48:02 +00:00
|
|
|
}
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
|
|
|
/* then use default */
|
2009-12-08 18:02:50 +00:00
|
|
|
km= WM_keymap_list_find(&wm->defaultconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
return km;
|
2009-07-28 16:48:02 +00:00
|
|
|
}
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMap *WM_keymap_copy_to_user(wmKeyMap *keymap)
|
|
|
|
{
|
|
|
|
wmKeyMap *usermap;
|
|
|
|
wmKeyMapItem *kmi;
|
|
|
|
|
2009-12-08 18:02:50 +00:00
|
|
|
usermap= WM_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
2010-12-15 18:09:25 +00:00
|
|
|
/* XXX this function is only used by RMB setting hotkeys, and it clears maps on 2nd try this way */
|
|
|
|
if(keymap==usermap)
|
|
|
|
return keymap;
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
if(!usermap) {
|
|
|
|
/* not saved yet, duplicate existing */
|
|
|
|
usermap= MEM_dupallocN(keymap);
|
|
|
|
usermap->modal_items= NULL;
|
|
|
|
usermap->poll= NULL;
|
|
|
|
usermap->flag |= KEYMAP_USER;
|
|
|
|
|
|
|
|
BLI_addtail(&U.keymaps, usermap);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* already saved, free items for re-copy */
|
|
|
|
WM_keymap_free(usermap);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_duplicatelist(&usermap->items, &keymap->items);
|
|
|
|
|
|
|
|
for(kmi=usermap->items.first; kmi; kmi=kmi->next) {
|
|
|
|
if(kmi->properties) {
|
|
|
|
kmi->ptr= MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr");
|
|
|
|
WM_operator_properties_create(kmi->ptr, kmi->idname);
|
|
|
|
|
|
|
|
kmi->properties= IDP_CopyProperty(kmi->properties);
|
|
|
|
kmi->ptr->data= kmi->properties;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(kmi=keymap->items.first; kmi; kmi=kmi->next)
|
|
|
|
kmi->flag &= ~KMI_EXPANDED;
|
|
|
|
|
|
|
|
return usermap;
|
|
|
|
}
|
2009-12-17 03:32:33 +00:00
|
|
|
|
|
|
|
void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapItem *kmi)
|
|
|
|
{
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
wmKeyConfig *keyconf;
|
|
|
|
wmKeyMap *km = NULL;
|
|
|
|
|
|
|
|
/* look in user key config */
|
|
|
|
keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
|
|
|
|
if(keyconf) {
|
|
|
|
km= WM_keymap_list_find(&keyconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!km) {
|
|
|
|
/* or from default */
|
|
|
|
km= WM_keymap_list_find(&wm->defaultconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (km) {
|
2010-01-29 02:01:02 +00:00
|
|
|
wmKeyMapItem *orig = WM_keymap_item_find_id(km, kmi->id);
|
2009-12-17 03:32:33 +00:00
|
|
|
|
|
|
|
if (orig) {
|
|
|
|
if(strcmp(orig->idname, kmi->idname) != 0) {
|
|
|
|
BLI_strncpy(kmi->idname, orig->idname, sizeof(kmi->idname));
|
|
|
|
|
2010-11-10 11:19:52 +00:00
|
|
|
WM_keymap_properties_reset(kmi, NULL);
|
2009-12-17 03:32:33 +00:00
|
|
|
}
|
2010-06-27 23:57:58 +00:00
|
|
|
|
|
|
|
if (orig->properties) {
|
|
|
|
kmi->properties= IDP_CopyProperty(orig->properties);
|
|
|
|
kmi->ptr->data= kmi->properties;
|
|
|
|
}
|
2009-12-17 03:32:33 +00:00
|
|
|
|
|
|
|
kmi->propvalue = orig->propvalue;
|
|
|
|
kmi->type = orig->type;
|
|
|
|
kmi->val = orig->val;
|
|
|
|
kmi->shift = orig->shift;
|
|
|
|
kmi->ctrl = orig->ctrl;
|
|
|
|
kmi->alt = orig->alt;
|
|
|
|
kmi->oskey = orig->oskey;
|
|
|
|
kmi->keymodifier = orig->keymodifier;
|
|
|
|
kmi->maptype = orig->maptype;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2009-07-26 12:52:39 +00:00
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
void WM_keymap_restore_to_default(wmKeyMap *keymap)
|
2009-07-26 12:52:39 +00:00
|
|
|
{
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMap *usermap;
|
|
|
|
|
2009-12-08 18:02:50 +00:00
|
|
|
usermap= WM_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
|
|
|
if(usermap) {
|
|
|
|
WM_keymap_free(usermap);
|
|
|
|
BLI_freelinkN(&U.keymaps, usermap);
|
|
|
|
}
|
2009-07-26 12:52:39 +00:00
|
|
|
}
|
|
|
|
|
2009-12-24 09:26:06 +00:00
|
|
|
wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id)
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
{
|
|
|
|
wmKeyMapItem *kmi;
|
|
|
|
|
2009-12-24 09:26:06 +00:00
|
|
|
for (kmi=keymap->items.first; kmi; kmi=kmi->next) {
|
2010-01-26 01:02:10 +00:00
|
|
|
if (kmi->id == id) {
|
2009-12-24 09:26:06 +00:00
|
|
|
return kmi;
|
2010-01-26 01:02:10 +00:00
|
|
|
}
|
2009-12-24 09:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
2009-12-24 09:26:06 +00:00
|
|
|
/* Guess an appropriate keymap from the operator name */
|
|
|
|
/* Needs to be kept up to date with Keymap and Operator naming */
|
2010-11-17 09:45:45 +00:00
|
|
|
wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
2009-12-24 09:26:06 +00:00
|
|
|
{
|
|
|
|
wmKeyMap *km=NULL;
|
|
|
|
SpaceLink *sl = CTX_wm_space_data(C);
|
|
|
|
|
|
|
|
/* Window */
|
|
|
|
if (strstr(opname, "WM_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Window", 0, 0);
|
|
|
|
}
|
|
|
|
/* Screen */
|
|
|
|
else if (strstr(opname, "SCREEN_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Screen", 0, 0);
|
|
|
|
}
|
|
|
|
/* Grease Pencil */
|
|
|
|
else if (strstr(opname, "GPENCIL_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Grease Pencil", 0, 0);
|
|
|
|
}
|
|
|
|
/* Markers */
|
|
|
|
else if (strstr(opname, "MARKER_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Markers", 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 3D View */
|
|
|
|
else if (strstr(opname, "VIEW3D_OT")) {
|
2010-09-06 05:40:52 +00:00
|
|
|
km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0);
|
2009-12-24 09:26:06 +00:00
|
|
|
}
|
|
|
|
else if (strstr(opname, "OBJECT_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
|
|
|
|
}
|
2010-01-26 01:02:10 +00:00
|
|
|
|
2009-12-24 09:26:06 +00:00
|
|
|
|
|
|
|
/* Editing Modes */
|
|
|
|
else if (strstr(opname, "MESH_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Mesh", 0, 0);
|
2011-02-25 16:32:03 +00:00
|
|
|
|
|
|
|
/* some mesh operators are active in object mode too, like add-prim */
|
|
|
|
if(km && km->poll && km->poll((bContext *)C)==0) {
|
|
|
|
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
|
|
|
|
}
|
2009-12-24 09:26:06 +00:00
|
|
|
}
|
|
|
|
else if (strstr(opname, "CURVE_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Curve", 0, 0);
|
2011-02-25 16:32:03 +00:00
|
|
|
|
|
|
|
/* some curve operators are active in object mode too, like add-prim */
|
|
|
|
if(km && km->poll && km->poll((bContext *)C)==0) {
|
|
|
|
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
|
|
|
|
}
|
2009-12-24 09:26:06 +00:00
|
|
|
}
|
|
|
|
else if (strstr(opname, "ARMATURE_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Armature", 0, 0);
|
|
|
|
}
|
|
|
|
else if (strstr(opname, "POSE_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Pose", 0, 0);
|
|
|
|
}
|
|
|
|
else if (strstr(opname, "SCULPT_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Sculpt", 0, 0);
|
|
|
|
}
|
|
|
|
else if (strstr(opname, "MBALL_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Metaball", 0, 0);
|
2011-02-25 16:32:03 +00:00
|
|
|
|
|
|
|
/* some mball operators are active in object mode too, like add-prim */
|
|
|
|
if(km && km->poll && km->poll((bContext *)C)==0) {
|
|
|
|
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
|
|
|
|
}
|
2009-12-24 09:26:06 +00:00
|
|
|
}
|
|
|
|
else if (strstr(opname, "LATTICE_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Lattice", 0, 0);
|
|
|
|
}
|
|
|
|
else if (strstr(opname, "PARTICLE_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Particle", 0, 0);
|
|
|
|
}
|
|
|
|
else if (strstr(opname, "FONT_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Font", 0, 0);
|
|
|
|
}
|
|
|
|
else if (strstr(opname, "PAINT_OT")) {
|
|
|
|
|
|
|
|
/* check for relevant mode */
|
|
|
|
switch(CTX_data_mode_enum(C)) {
|
|
|
|
case OB_MODE_WEIGHT_PAINT:
|
|
|
|
km = WM_keymap_find_all(C, "Weight Paint", 0, 0);
|
|
|
|
break;
|
|
|
|
case OB_MODE_VERTEX_PAINT:
|
|
|
|
km = WM_keymap_find_all(C, "Vertex Paint", 0, 0);
|
|
|
|
break;
|
|
|
|
case OB_MODE_TEXTURE_PAINT:
|
|
|
|
km = WM_keymap_find_all(C, "Image Paint", 0, 0);
|
|
|
|
break;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-24 09:26:06 +00:00
|
|
|
/* Paint Face Mask */
|
|
|
|
else if (strstr(opname, "PAINT_OT_face_select")) {
|
|
|
|
km = WM_keymap_find_all(C, "Face Mask", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* Timeline */
|
|
|
|
else if (strstr(opname, "TIME_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Timeline", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* Image Editor */
|
|
|
|
else if (strstr(opname, "IMAGE_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Image", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* UV Editor */
|
|
|
|
else if (strstr(opname, "UV_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "UV Editor", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* Node Editor */
|
|
|
|
else if (strstr(opname, "NODE_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Node Editor", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* Animation Editor Channels */
|
|
|
|
else if (strstr(opname, "ANIM_OT_channels")) {
|
|
|
|
km = WM_keymap_find_all(C, "Animation Channels", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* Animation Generic - after channels */
|
|
|
|
else if (strstr(opname, "ANIM_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Animation", 0, 0);
|
|
|
|
}
|
|
|
|
/* Graph Editor */
|
|
|
|
else if (strstr(opname, "GRAPH_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Graph Editor", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* Dopesheet Editor */
|
|
|
|
else if (strstr(opname, "ACTION_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Dopesheet", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* NLA Editor */
|
|
|
|
else if (strstr(opname, "NLA_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "NLA Editor", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* Script */
|
|
|
|
else if (strstr(opname, "SCRIPT_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Script", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* Text */
|
|
|
|
else if (strstr(opname, "TEXT_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Text", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* Sequencer */
|
|
|
|
else if (strstr(opname, "SEQUENCER_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Sequencer", sl->spacetype, 0);
|
|
|
|
}
|
|
|
|
/* Console */
|
|
|
|
else if (strstr(opname, "CONSOLE_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Console", sl->spacetype, 0);
|
|
|
|
}
|
2010-11-11 13:36:57 +00:00
|
|
|
/* Console */
|
|
|
|
else if (strstr(opname, "INFO_OT")) {
|
|
|
|
km = WM_keymap_find_all(C, "Info", sl->spacetype, 0);
|
|
|
|
}
|
2009-12-24 09:26:06 +00:00
|
|
|
|
2010-01-26 01:02:10 +00:00
|
|
|
/* Transform */
|
|
|
|
else if (strstr(opname, "TRANSFORM_OT")) {
|
|
|
|
|
|
|
|
/* check for relevant editor */
|
|
|
|
switch(sl->spacetype) {
|
|
|
|
case SPACE_VIEW3D:
|
2010-09-06 05:40:52 +00:00
|
|
|
km = WM_keymap_find_all(C, "3D View", sl->spacetype, 0);
|
2010-01-26 01:02:10 +00:00
|
|
|
break;
|
|
|
|
case SPACE_IPO:
|
|
|
|
km = WM_keymap_find_all(C, "Graph Editor", sl->spacetype, 0);
|
|
|
|
break;
|
|
|
|
case SPACE_ACTION:
|
|
|
|
km = WM_keymap_find_all(C, "Dopesheet", sl->spacetype, 0);
|
|
|
|
break;
|
|
|
|
case SPACE_NLA:
|
|
|
|
km = WM_keymap_find_all(C, "NLA Editor", sl->spacetype, 0);
|
|
|
|
break;
|
|
|
|
case SPACE_IMAGE:
|
|
|
|
km = WM_keymap_find_all(C, "UV Editor", sl->spacetype, 0);
|
|
|
|
break;
|
|
|
|
case SPACE_NODE:
|
|
|
|
km = WM_keymap_find_all(C, "Node Editor", sl->spacetype, 0);
|
|
|
|
break;
|
|
|
|
case SPACE_SEQ:
|
|
|
|
km = WM_keymap_find_all(C, "Sequencer", sl->spacetype, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-24 09:26:06 +00:00
|
|
|
return km;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|