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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-09-10 14:50:08 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-10 14:50:08 +0400
commitc276ef6a268bab16972021a3aaffe81b8689be84 (patch)
treea425b30371e679e324a9ad35fa73b5abccd33fe8 /source
parentf7a5569a97d7c732c4e4d105761eb7cab35c822a (diff)
change to auto-opening menus so the first menu item in popup menu wont auto open.
This way we can do predictable key-shortcut-chaining. Eg. Shift+A, M, O --- adds a metaball cone. In editmode Ctrl+V, X, A --- Assign new vertex group.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_handlers.c9
-rw-r--r--source/blender/editors/interface/interface_intern.h12
-rw-r--r--source/blender/editors/interface/interface_regions.c1
3 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 53cd7f3fb58..17486edd07f 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -5227,7 +5227,12 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
/* automatic open pulldown block timer */
if (ELEM3(but->type, BLOCK, PULLDOWN, ICONTEXTROW)) {
- if (data->used_mouse && !data->autoopentimer) {
+ if ((data->used_mouse == TRUE) &&
+ (data->autoopentimer == FALSE) &&
+ /* don't popup the first time,
+ * see description on this member for info */
+ (but->block->auto_is_first_event == FALSE))
+ {
int time;
if (but->block->auto_open == TRUE) { /* test for toolbox */
@@ -5247,6 +5252,8 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
data->autoopentimer = WM_event_add_timer(data->wm, data->window, TIMER, 0.02 * (double)time);
}
}
+
+ but->block->auto_is_first_event = FALSE;
}
}
else {
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index d308f7d852e..a5e4fa5890f 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -305,7 +305,17 @@ struct uiBlock {
char direction;
char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied to buttons */
char auto_open;
- char _pad[7];
+
+ /* this setting is used so newly opened menu's dont popout the first item under the mouse,
+ * the reasoning behind this is because of muscle memory for opening menus.
+ *
+ * Without this, the first time opening a Submenu and activating an item in it will be 2 steps,
+ * but the second time the same item is accessed the menu memory would auto activate the
+ * last used menu and the key intended to select that submenu ends up being passed into the submenu.
+ * - Campbell
+ */
+ char auto_is_first_event;
+ char _pad[6];
double auto_open_last;
const char *lockstr;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 9c22b06fc1c..bebc80cbfc3 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2502,6 +2502,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
pup->block->puphash = ui_popup_menu_hash(title);
+ pup->block->auto_is_first_event = TRUE;
pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN);