diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-10-15 17:55:06 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-10-15 17:55:06 +0400 |
commit | ef765b3606754bd639b48995900d01258c71f002 (patch) | |
tree | cbd26f1bccd41cf41c1788c81b715cf1283944f7 /source/blender/editors | |
parent | 23612a8598bc4cb3ed3a21be6a9c181b8866112b (diff) |
Fix [#37077] User prefs > Input and Outliner Keymaps mismatch in representation.
Remove KeyMap mode from outliner, was an old half-finished features redondant with user preferences settings...
Also moved key map item's "event type to map type" and map type defines at WM level, this is too much generic to be at RNA level.
Also added a check in versionning code to convert all outdated outliner modes to a valid one (seems old 'verse' ones were not handled as well).
Thanks to Brecht for reviews and advices!
Diffstat (limited to 'source/blender/editors')
4 files changed, 4 insertions, 299 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 6b9200afb75..513085e9a64 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1225,7 +1225,7 @@ static int modify_key_op_poll(bContext *C) /* if Outliner, don't allow in some views */ if (so) { - if (ELEM5(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_USERDEF, SO_KEYMAP)) { + if (ELEM4(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_USERDEF)) { return 0; } } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index fe706ce2365..fda8c19d21b 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -765,286 +765,6 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa uiBlockSetEmboss(block, UI_EMBOSS); } -static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2) -{ - wmOperatorType *ot = arg2; - wmKeyMapItem *kmi = arg_kmi; - - if (ot) - BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME); -} - -static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), - const char *str, uiSearchItems *items) -{ - GHashIterator *iter = WM_operatortype_iter(); - - for (; !BLI_ghashIterator_done(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot = BLI_ghashIterator_getValue(iter); - - if (BLI_strcasestr(ot->idname, str)) { - char name[OP_MAX_TYPENAME]; - - /* display name for menu */ - WM_operator_py_idname(name, ot->idname); - - if (false == uiSearchItemAdd(items, name, ot, 0)) - break; - } - } - BLI_ghashIterator_free(iter); -} - -/* operator Search browse menu, open */ -static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) -{ - static char search[OP_MAX_TYPENAME]; - wmEvent event; - wmWindow *win = CTX_wm_window(C); - wmKeyMapItem *kmi = arg_kmi; - wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); - uiBlock *block; - uiBut *but; - - /* clear initial search string, then all items show */ - search[0] = 0; - - block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); - - /* fake button, it holds space for search items */ - uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL); - - but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, UI_UNIT_Y, 0, 0, ""); - uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot); - - uiBoundsBlock(block, 6); - uiBlockSetDirection(block, UI_DOWN); - uiEndBlock(C, block); - - wm_event_init_from_window(win, &event); - event.type = EVT_BUT_OPEN; - event.val = KM_PRESS; - event.customdata = but; - event.customdatafree = FALSE; - wm_event_add(win, &event); - - return block; -} - -#define OL_KM_KEYBOARD 0 -#define OL_KM_MOUSE 1 -#define OL_KM_TWEAK 2 -#define OL_KM_SPECIALS 3 - -static short keymap_menu_type(short type) -{ - if (ISKEYBOARD(type)) return OL_KM_KEYBOARD; - if (ISTWEAK(type)) return OL_KM_TWEAK; - if (ISMOUSE(type)) return OL_KM_MOUSE; -// return OL_KM_SPECIALS; - return 0; -} - -static const char *keymap_type_menu(void) -{ - static const char string[] = - "Event Type%t" - "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) - "|Mouse%x" STRINGIFY(OL_KM_MOUSE) - "|Tweak%x" STRINGIFY(OL_KM_TWEAK) -// "|Specials%x" STRINGIFY(OL_KM_SPECIALS) - ; - - return string; -} - -static const char *keymap_mouse_menu(void) -{ - static const char string[] = - "Mouse Event%t" - "|Left Mouse%x" STRINGIFY(LEFTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) - "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) - "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) - "|Select Mouse%x" STRINGIFY(SELECTMOUSE) - "|Mouse Move%x" STRINGIFY(MOUSEMOVE) - "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) - "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) - "|Wheel In%x" STRINGIFY(WHEELINMOUSE) - "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) - "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) - "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) - "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) - ; - - return string; -} - -static const char *keymap_tweak_menu(void) -{ - static const char string[] = - "Tweak Event%t" - "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) - "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) - "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) - "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) - "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) - ; - - return string; -} - -static const char *keymap_tweak_dir_menu(void) -{ - static const char string[] = - "Tweak Direction%t" - "|Any%x" STRINGIFY(KM_ANY) - "|North%x" STRINGIFY(EVT_GESTURE_N) - "|North-East%x" STRINGIFY(EVT_GESTURE_NE) - "|East%x" STRINGIFY(EVT_GESTURE_E) - "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) - "|South%x" STRINGIFY(EVT_GESTURE_S) - "|South-West%x" STRINGIFY(EVT_GESTURE_SW) - "|West%x" STRINGIFY(EVT_GESTURE_W) - "|North-West%x" STRINGIFY(EVT_GESTURE_NW) - ; - - return string; -} - - -static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v)) -{ - wmKeyMapItem *kmi = kmi_v; - short maptype = keymap_menu_type(kmi->type); - - if (maptype != kmi->maptype) { - switch (kmi->maptype) { - case OL_KM_KEYBOARD: - kmi->type = AKEY; - kmi->val = KM_PRESS; - break; - case OL_KM_MOUSE: - kmi->type = LEFTMOUSE; - kmi->val = KM_PRESS; - break; - case OL_KM_TWEAK: - kmi->type = EVT_TWEAK_L; - kmi->val = KM_ANY; - break; - case OL_KM_SPECIALS: - kmi->type = AKEY; - kmi->val = KM_PRESS; - break; - } - ED_region_tag_redraw(CTX_wm_region(C)); - } -} - -static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soops, ListBase *lb) -{ - TreeElement *te; - TreeStoreElem *tselem; - - uiBlockSetEmboss(block, UI_EMBOSST); - - for (te = lb->first; te; te = te->next) { - tselem = TREESTORE(te); - if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { - uiBut *but; - const char *str; - int xstart = 240; - int butw1 = UI_UNIT_X; /* operator */ - int butw2 = 90; /* event type, menus */ - int butw3 = 43; /* modifiers */ - - if (tselem->type == TSE_KEYMAP_ITEM) { - wmKeyMapItem *kmi = te->directdata; - - /* modal map? */ - if (kmi->propvalue) { - /* pass */ - } - else { - uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, te->ys + 1, butw1, UI_UNIT_Y - 1, - TIP_("Assign new Operator")); - } - xstart += butw1 + 10; - - /* map type button */ - kmi->maptype = keymap_menu_type(kmi->type); - - str = keymap_type_menu(); - but = uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->maptype, - 0, 0, 0, 0, TIP_("Event type")); - uiButSetFunc(but, keymap_type_cb, kmi, NULL); - xstart += butw2 + 5; - - /* edit actual event */ - switch (kmi->maptype) { - case OL_KM_KEYBOARD: - uiDefKeyevtButS(block, 0, "", xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, - TIP_("Key code")); - xstart += butw2 + 5; - break; - case OL_KM_MOUSE: - str = keymap_mouse_menu(); - uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, - 0, 0, 0, 0, TIP_("Mouse button")); - xstart += butw2 + 5; - break; - case OL_KM_TWEAK: - str = keymap_tweak_menu(); - uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, - 0, 0, 0, 0, TIP_("Tweak gesture")); - xstart += butw2 + 5; - str = keymap_tweak_dir_menu(); - uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->val, - 0, 0, 0, 0, TIP_("Tweak gesture direction")); - xstart += butw2 + 5; - break; - } - - /* modifiers */ - uiDefButS(block, OPTION, 0, IFACE_("Shift"), xstart, te->ys + 1, butw3 + 5, UI_UNIT_Y - 1, - &kmi->shift, 0, 0, 0, 0, TIP_("Modifier")); - xstart += butw3 + 5; - uiDefButS(block, OPTION, 0, IFACE_("Ctrl"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->ctrl, - 0, 0, 0, 0, TIP_("Modifier")); - xstart += butw3; - uiDefButS(block, OPTION, 0, IFACE_("Alt"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->alt, - 0, 0, 0, 0, TIP_("Modifier")); - xstart += butw3; - uiDefButS(block, OPTION, 0, IFACE_("OS"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->oskey, - 0, 0, 0, 0, TIP_("Modifier")); - xstart += butw3 + 5; - uiDefKeyevtButS(block, 0, "", xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->keymodifier, - TIP_("Key Modifier code")); - xstart += butw3 + 5; - - /* rna property */ - if (kmi->ptr && kmi->ptr->data) { - uiDefBut(block, LABEL, 0, IFACE_("(RNA property)"), xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, - NULL, 0, 0, 0, 0, ""); - xstart += butw2; - } - - (void)xstart; - } - } - - if (TSELEM_OPEN(tselem, soops)) outliner_draw_keymapbuts(block, ar, soops, &te->subtree); - } - - uiBlockSetEmboss(block, UI_EMBOSS); -} - - static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, TreeElement *te) { uiBut *bt; @@ -1864,7 +1584,7 @@ void draw_outliner(const bContext *C) /* get extents of data */ outliner_height(soops, &soops->tree, &sizey); - if (ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP)) { + if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { /* RNA has two columns: * - column 1 is (max_width + OL_RNA_COL_SPACEX) or * (OL_RNA_COL_X), whichever is wider... @@ -1878,11 +1598,7 @@ void draw_outliner(const bContext *C) sizex_rna = max_ii(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX); /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ - if (soops->outlinevis == SO_KEYMAP) - // XXX this is only really a quick hack to make this wide enough... - sizex = sizex_rna + OL_RNA_COL_SIZEX * 3 + 50; - else - sizex = sizex_rna + OL_RNA_COL_SIZEX + 50; + sizex = sizex_rna + OL_RNA_COL_SIZEX + 50; } else { /* width must take into account restriction columns (if visible) so that entries will still be visible */ @@ -1918,9 +1634,6 @@ void draw_outliner(const bContext *C) outliner_draw_rnacols(ar, sizex_rna); outliner_draw_rnabuts(block, scene, ar, soops, sizex_rna, &soops->tree); } - else if (soops->outlinevis == SO_KEYMAP) { - outliner_draw_keymapbuts(block, ar, soops, &soops->tree); - } else if (!(soops->flag & SO_HIDE_RESTRICTCOLS)) { /* draw restriction columns */ outliner_draw_restrictcols(ar); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 41ad75bb14f..d1d512409ee 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -902,7 +902,7 @@ int outliner_item_do_activate(bContext *C, int x, int y, bool extend, bool recur UI_view2d_region_to_view(&ar->v2d, x, y, fmval, fmval + 1); - if (!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && + if (!ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF) && !(soops->flag & SO_HIDE_RESTRICTCOLS) && (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)) { diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index a93ed2dc6b0..036db3bae91 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1676,14 +1676,6 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) tselem->flag &= ~TSE_CLOSED; } } - else if (soops->outlinevis == SO_KEYMAP) { - wmWindowManager *wm = mainvar->wm.first; - wmKeyMap *km; - - for (km = wm->defaultconf->keymaps.first; km; km = km->next) { - /* ten = */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0); - } - } else { ten = outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); if (ten) ten->directdata = BASACT; |