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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2008-12-08 18:02:57 +0300
committerTon Roosendaal <ton@blender.org>2008-12-08 18:02:57 +0300
commit02e23c16dd9e403deb1694829c11d16dc47392ee (patch)
treef5ec9e3f68bad13137bdeafa326281c74387327e /source/blender/windowmanager/intern/wm_keymap.c
parent11e15bf68979670b2257814aa296886222b3ee40 (diff)
2.5
Part one of wrapping up area/region management. Read design doc here: http://wiki.blender.org/index.php/BlenderDev/Blender2.5/AreaManager This commit: - brings keymap storage to WM, based on names/types. This structure allows rna-ifying it too, so you can browse keymaps etc. - creating areas and regions works slightly different now, wich regiontypes stored in areatype. Todo: - better callbacks and structure for defining which handlers need to be added. - using region types to validate regions - proper implementation of local region data - code method for customizing keymaps. Current idea is that you have to indicate an entire keymap to be custom, to prevent too complicated merging problems of default and custom maps (like order, multiple keys for same operator, disabling options, etc).
Diffstat (limited to 'source/blender/windowmanager/intern/wm_keymap.c')
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c89
1 files changed, 57 insertions, 32 deletions
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 610222b4372..439f5c304d1 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -47,45 +47,45 @@
/* ***************** generic call, exported **************** */
-static void keymap_set(wmKeymapItem *km, short type, short val, int modifier, short keymodifier)
+static void keymap_set(wmKeymapItem *kmi, short type, short val, int modifier, short keymodifier)
{
- km->type= type;
- km->val= val;
- km->keymodifier= keymodifier;
+ kmi->type= type;
+ kmi->val= val;
+ kmi->keymodifier= keymodifier;
if(modifier & KM_SHIFT)
- km->shift= 1;
+ kmi->shift= 1;
else if(modifier & KM_SHIFT2)
- km->shift= 2;
+ kmi->shift= 2;
if(modifier & KM_CTRL)
- km->ctrl= 1;
+ kmi->ctrl= 1;
else if(modifier & KM_CTRL2)
- km->ctrl= 2;
+ kmi->ctrl= 2;
if(modifier & KM_ALT)
- km->alt= 1;
+ kmi->alt= 1;
else if(modifier & KM_ALT2)
- km->alt= 2;
+ kmi->alt= 2;
if(modifier & KM_OSKEY)
- km->oskey= 1;
+ kmi->oskey= 1;
else if(modifier & KM_OSKEY2)
- km->oskey= 2;
+ kmi->oskey= 2;
}
/* if item was added, then bail out */
void WM_keymap_verify_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier)
{
- wmKeymapItem *km;
+ wmKeymapItem *kmi;
- for(km= lb->first; km; km= km->next)
- if(strncmp(km->idname, idname, OP_MAX_TYPENAME)==0)
+ for(kmi= lb->first; kmi; kmi= kmi->next)
+ if(strncmp(kmi->idname, idname, OP_MAX_TYPENAME)==0)
break;
- if(km==NULL) {
- km= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
+ if(kmi==NULL) {
+ kmi= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
- BLI_addtail(lb, km);
- BLI_strncpy(km->idname, idname, OP_MAX_TYPENAME);
+ BLI_addtail(lb, kmi);
+ BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
- keymap_set(km, type, val, modifier, keymodifier);
+ keymap_set(kmi, type, val, modifier, keymodifier);
}
}
@@ -93,30 +93,55 @@ void WM_keymap_verify_item(ListBase *lb, char *idname, short type, short val, in
/* if item was added, then replace */
void WM_keymap_set_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier)
{
- wmKeymapItem *km;
+ wmKeymapItem *kmi;
- for(km= lb->first; km; km= km->next)
- if(strncmp(km->idname, idname, OP_MAX_TYPENAME)==0)
+ for(kmi= lb->first; kmi; kmi= kmi->next)
+ if(strncmp(kmi->idname, idname, OP_MAX_TYPENAME)==0)
break;
- if(km==NULL) {
- km= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
+ if(kmi==NULL) {
+ kmi= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
- BLI_addtail(lb, km);
- BLI_strncpy(km->idname, idname, OP_MAX_TYPENAME);
+ BLI_addtail(lb, kmi);
+ BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
}
- keymap_set(km, type, val, modifier, keymodifier);
+ keymap_set(kmi, type, val, modifier, keymodifier);
}
/* always add item */
void WM_keymap_add_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier)
{
- wmKeymapItem *km= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
+ wmKeymapItem *kmi= MEM_callocN(sizeof(wmKeymapItem), "keymap entry");
- BLI_addtail(lb, km);
- BLI_strncpy(km->idname, idname, OP_MAX_TYPENAME);
+ BLI_addtail(lb, kmi);
+ BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME);
- keymap_set(km, type, val, modifier, keymodifier);
+ keymap_set(kmi, type, val, modifier, keymodifier);
}
+/* ****************** 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 */
+
+ListBase *WM_keymap_listbase(wmWindowManager *wm, const char *nameid, int spaceid, int regionid)
+{
+ wmKeyMap *km;
+
+ for(km= wm->keymaps.first; km; km= km->next)
+ if(km->spaceid==spaceid && km->regionid==regionid)
+ if(0==strncmp(nameid, km->nameid, KMAP_MAX_NAME))
+ break;
+ if(km==NULL) {
+ km= MEM_callocN(sizeof(struct wmKeyMap), "keymap list");
+ BLI_strncpy(km->nameid, nameid, KMAP_MAX_NAME);
+ km->spaceid= spaceid;
+ km->regionid= regionid;
+ printf("added keymap %s %d %d\n", nameid, spaceid, regionid);
+ BLI_addtail(&wm->keymaps, km);
+ }
+
+ return &km->keymap;
+}