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.
This commit is contained in:
Campbell Barton 2012-09-10 10:50:08 +00:00
parent f7a5569a97
commit c276ef6a26
3 changed files with 20 additions and 2 deletions

@ -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 {

@ -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;

@ -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);