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:
authorCampbell Barton <ideasman42@gmail.com>2011-11-14 18:42:47 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-14 18:42:47 +0400
commit9e6860d864d0f630f92f2fb7130412e9387aea26 (patch)
tree766bbe23db54fea7829a1b2b5c297ae68469c5c8
parent1ace39c86bf54271cdc2ce7ae5bb4166715cd02a (diff)
fix [#29242] menus have no keyboard shortcuts
-rw-r--r--release/scripts/startup/bl_ui/properties_object_constraint.py1
-rw-r--r--source/blender/blenkernel/intern/tracking.c1
-rw-r--r--source/blender/editors/include/UI_interface.h1
-rw-r--r--source/blender/editors/interface/interface.c55
-rw-r--r--source/blender/editors/interface/interface_handlers.c2
-rw-r--r--source/blender/editors/interface/interface_layout.c11
-rw-r--r--source/blender/editors/interface/interface_regions.c6
-rw-r--r--source/blender/editors/interface/interface_templates.c2
-rw-r--r--source/blender/editors/interface/interface_widgets.c11
-rw-r--r--source/blender/windowmanager/WM_api.h1
-rw-r--r--source/blender/windowmanager/WM_keymap.h2
-rw-r--r--source/blender/windowmanager/intern/wm.c20
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c10
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c2
14 files changed, 79 insertions, 46 deletions
diff --git a/release/scripts/startup/bl_ui/properties_object_constraint.py b/release/scripts/startup/bl_ui/properties_object_constraint.py
index 8cdb07461bb..1ff9a8a0449 100644
--- a/release/scripts/startup/bl_ui/properties_object_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_object_constraint.py
@@ -763,7 +763,6 @@ class ConstraintButtonsPanel():
layout.prop(con, "track")
-
layout.operator("clip.constraint_to_fcurve")
def CAMERA_SOLVER(self, context, layout, con):
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index d236c053058..d582ad7c4d8 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -1449,6 +1449,7 @@ int BKE_tracking_can_solve(MovieTracking *tracking, char *error_msg, int error_s
return 1;
#else
BLI_strncpy(error_msg, "Blender is compiled without motion tracking library", error_size);
+ (void)tracking;
return 0;
#endif
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 35fabb3b80e..01273b291a2 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -688,6 +688,7 @@ void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr);
const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing
void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, int (*check_prop)(struct PropertyRNA *), const char label_align, const short flag);
+struct MenuType *uiButGetMenuType(uiBut *but);
void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
void uiLayoutSetActive(uiLayout *layout, int active);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 81b42277055..ce4e052bd53 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -48,6 +48,8 @@
#include "BKE_context.h"
#include "BKE_library.h"
#include "BKE_unit.h"
+#include "BKE_screen.h"
+#include "BKE_idprop.h"
#include "BKE_utildefines.h" /* FILE_MAX */
#include "BIF_gl.h"
@@ -793,26 +795,61 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
{
uiBut *but;
- IDProperty *prop;
char buf[512];
+ /* for menu's */
+ MenuType *mt;
+ IDProperty *prop_menu= NULL;
+ IDProperty *prop_menu_name= NULL;
+
/* only do it before bounding */
if(block->minx != block->maxx)
return;
+
+#define UI_MENU_KEY_STR_CAT \
+ char *butstr_orig= BLI_strdup(but->str); \
+ BLI_snprintf(but->strdata, \
+ sizeof(but->strdata), \
+ "%s|%s", \
+ butstr_orig, buf); \
+ MEM_freeN(butstr_orig); \
+ but->str= but->strdata; \
+ ui_check_but(but); \
+
+
for(but=block->buttons.first; but; but=but->next) {
if(but->optype) {
- prop= (but->opptr)? but->opptr->data: NULL;
-
- if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
- char *butstr_orig= BLI_strdup(but->str);
- BLI_snprintf(but->strdata, sizeof(but->strdata), "%s|%s", butstr_orig, buf);
- MEM_freeN(butstr_orig);
- but->str= but->strdata;
- ui_check_but(but);
+ IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+
+ if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) {
+ UI_MENU_KEY_STR_CAT
+ }
+ }
+ else if ((mt= uiButGetMenuType(but))) {
+ /* only allocate menu property once */
+ if (prop_menu == NULL) {
+ /* annoying, create a property */
+ IDPropertyTemplate val = {0};
+ prop_menu= IDP_New(IDP_GROUP, val, __func__); /* dummy, name is unimportant */
+ IDP_AddToGroup(prop_menu, (prop_menu_name= IDP_NewString("", "name", sizeof(mt->idname))));
+ }
+
+ IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname));
+
+ if(WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE, buf, sizeof(buf))) {
+ UI_MENU_KEY_STR_CAT
}
}
}
+
+ if (prop_menu) {
+ IDP_FreeProperty(prop_menu);
+ MEM_freeN(prop_menu);
+ }
+
+#undef UI_MENU_KEY_STR_CAT
+
}
void uiEndBlock(const bContext *C, uiBlock *block)
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 7338aa1983f..ee1f9617813 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4357,7 +4357,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
/* complex code to change name of button */
- if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
+ if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) {
char *butstr_orig;
// XXX but->str changed... should not, remove the hotkey from it
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 32bcfe51afc..a6f93101fdc 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2821,3 +2821,14 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in
}
}
}
+
+/* this is a bit of a hack but best keep it in one place at least */
+MenuType *uiButGetMenuType(uiBut *but)
+{
+ if(but->menu_create_func == ui_item_menutype_func) {
+ return (MenuType *)but->poin;
+ }
+ else {
+ return NULL;
+ }
+}
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 34b62155314..837a9d12af1 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -408,7 +408,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
/* operator keymap (not menus, they already have it) */
prop= (but->opptr)? but->opptr->data: NULL;
- if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
+ if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) {
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), buf);
data->color[data->totline]= 0x888888;
data->totline++;
@@ -493,8 +493,8 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
}
else if (ELEM(but->type, MENU, PULLDOWN)) {
if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
- if(but->menu_create_func && WM_menutype_contains((MenuType *)but->poin)) {
- MenuType *mt= (MenuType *)but->poin;
+ MenuType *mt= uiButGetMenuType(but);
+ if (mt) {
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s"), mt->idname);
data->color[data->totline]= 0x888888;
data->totline++;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 795446e76ef..eb7e06623f7 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -2458,7 +2458,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
/* check for hotkey */
if(len < 256-6) {
- if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, &name[len+1], 256-len-1))
+ if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, &name[len+1], 256-len-1))
name[len]= '|';
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index aa407bbf6d4..c9fcb7f1d24 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -810,6 +810,11 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect)
}
+static int ui_but_draw_menu_icon(uiBut *but)
+{
+ return (but->flag & UI_ICON_SUBMENU) && (but->dt == UI_EMBOSSP);
+}
+
/* icons have been standardized... and this call draws in untransformed coordinates */
static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect)
@@ -888,8 +893,8 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect
else
UI_icon_draw_aspect(xs, ys, icon, aspect, alpha);
}
-
- if((but->flag & UI_ICON_SUBMENU) && (but->dt == UI_EMBOSSP)) {
+
+ if (ui_but_draw_menu_icon(but)) {
xs= rect->xmax-17;
ys= (rect->ymin+rect->ymax- height)/2;
@@ -1139,7 +1144,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* part text right aligned */
if(cpoin) {
fstyle->align= UI_STYLE_TEXT_RIGHT;
- rect->xmax-=5;
+ rect->xmax -= ui_but_draw_menu_icon(but) ? UI_DPI_ICON_SIZE : 5;
uiStyleFontDraw(fstyle, rect, cpoin+1);
*cpoin= '|';
}
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 8b55db27761..fcdb6d25083 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -233,7 +233,6 @@ void WM_operator_py_idname(char *to, const char *from);
void WM_menutype_init(void);
struct MenuType *WM_menutype_find(const char *idname, int quiet);
int WM_menutype_add(struct MenuType* mt);
-int WM_menutype_contains(struct MenuType* mt);
void WM_menutype_freelink(struct MenuType* mt);
void WM_menutype_free(void);
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 250752e661a..f254358e3cf 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -92,7 +92,7 @@ void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *key
const char *WM_key_event_string(short type);
int WM_key_event_operator_id(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, int hotkey, struct wmKeyMap **keymap_r);
-char *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, char *str, int len);
+char *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, const short sloppy, char *str, int len);
#ifdef __cplusplus
}
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 10c3735685c..c6c67e22bfd 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -175,26 +175,6 @@ int WM_menutype_add(MenuType* mt)
return 1;
}
-/* inefficient but only used for tooltip code */
-int WM_menutype_contains(MenuType* mt)
-{
- int found= FALSE;
-
- if(mt) {
- GHashIterator *iter= BLI_ghashIterator_new(menutypes_hash);
-
- for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
- if(mt == BLI_ghashIterator_getValue(iter)) {
- found= TRUE;
- break;
- }
- }
- BLI_ghashIterator_free(iter);
- }
-
- return found;
-}
-
void WM_menutype_freelink(MenuType* mt)
{
BLI_ghash_remove(menutypes_hash, mt->idname, NULL, (GHashValFreeFP)MEM_freeN);
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 9957d24c7ab..2e191a5ab6d 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -852,19 +852,19 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *op
return found;
}
-static wmKeyMapItem *wm_keymap_item_find(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int hotkey, wmKeyMap **keymap_r)
+static wmKeyMapItem *wm_keymap_item_find(const bContext *C, const char *opname, int opcontext, IDProperty *properties, const short hotkey, const short sloppy, wmKeyMap **keymap_r)
{
wmKeyMapItem *found= wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r);
- if(!found)
+ if(!found && sloppy)
found= wm_keymap_item_find_props(C, opname, opcontext, NULL, 0, hotkey, keymap_r);
return found;
}
-char *WM_key_event_operator_string(const bContext *C, const char *opname, int opcontext, IDProperty *properties, char *str, int len)
+char *WM_key_event_operator_string(const bContext *C, const char *opname, int opcontext, IDProperty *properties, const short sloppy, char *str, int len)
{
- wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, 0, NULL);
+ wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, 0, sloppy, NULL);
if(kmi) {
WM_keymap_item_to_string(kmi, str, len);
@@ -876,7 +876,7 @@ char *WM_key_event_operator_string(const bContext *C, const char *opname, int op
int WM_key_event_operator_id(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int hotkey, wmKeyMap **keymap_r)
{
- wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, hotkey, keymap_r);
+ wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, hotkey, TRUE, keymap_r);
if(kmi)
return kmi->id;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 4367a8b03ef..7fb6ba6e26b 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1362,7 +1362,7 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons
/* check for hotkey */
if(len < 256-6) {
- if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, &name[len+1], 256-len-1))
+ if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, &name[len+1], 256-len-1))
name[len]= '|';
}