diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-10-10 21:13:40 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-10-13 16:35:41 +0400 |
commit | 9fcc1a32df1377d22b950854fabc7af53a67b813 (patch) | |
tree | fb11bec4ed32bf7703fefad1551390f4c62ca280 /source/blender/editors/interface/interface_regions.c | |
parent | 116439ed91dd313fdc30c93b5d76807b7473ad39 (diff) |
Pie menus: Confirm threshold
This commit adds a confirm threshold property to pie menus.
Basically, this will confirm the pie menu automatically when
the distance from the center of the pie exceeds that threshold without
a need to release the pie button.
The confirm threshold will only work if it is larger than the pie
threshold.
The confirmation actually occur when the mouse stops moving, to
allow multiple pie menus to be better linked together, (see below)
This functionality also facilitates the ability for chained pie menus by
dragging. Basically, a pie menu item can be a call_menu_pie operator and
the new pie menu will still use the original pie menu release event for
confirmation. This should allow for quick, gesture based navigation in
pie menu hierarchies (going back in the hierarchy is still not supported
though)
There will be a demonstration pie in the official add-on soon
Diffstat (limited to 'source/blender/editors/interface/interface_regions.c')
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 5739ebebe64..49823d4e472 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2709,8 +2709,18 @@ static float uiPieTitleWidth(const char *name, int icon) uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const wmEvent *event) { - uiStyle *style = UI_GetStyleDraw(); - uiPieMenu *pie = MEM_callocN(sizeof(uiPopupMenu), "pie menu"); + uiStyle *style; + uiPieMenu *pie; + short event_type; + + wmWindow *win = CTX_wm_window(C); + + /* allow respawning a pie from the last pie event */ + if (event->type == win->lock_pie_event && event->type != win->last_pie_event) + return NULL; + + style = UI_GetStyleDraw(); + pie = MEM_callocN(sizeof(uiPopupMenu), "pie menu"); pie->block_radial = uiBeginBlock(C, NULL, __func__, UI_EMBOSS); /* may be useful later to allow spawning pies @@ -2718,10 +2728,17 @@ uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const /* pie->block_radial->flag |= UI_BLOCK_POPUP_MEMORY; */ pie->block_radial->puphash = ui_popup_menu_hash(title); pie->block_radial->flag |= UI_BLOCK_RADIAL; - pie->block_radial->pie_data.event = event->type; + + if (win->last_pie_event != EVENT_NONE) + event_type = win->last_pie_event; + else + event_type = event->type; + + pie->block_radial->pie_data.event = event_type; + win->lock_pie_event = event_type; /* if pie is spawned by a left click, it is always assumed to be click style */ - if (event->type == LEFTMOUSE) { + if (event_type == LEFTMOUSE) { pie->block_radial->flag |= UI_PIE_CLICK_STYLE; } @@ -2785,7 +2802,8 @@ void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *even if (mt->poll && mt->poll(C, mt) == 0) return; - pie = uiPieMenuBegin(C, IFACE_(mt->label), ICON_NONE, event); + if (!(pie = uiPieMenuBegin(C, IFACE_(mt->label), ICON_NONE, event))) + return; layout = uiPieMenuLayout(pie); menu.layout = layout; @@ -2806,7 +2824,9 @@ void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char * uiPieMenu *pie; uiLayout *layout; - pie = uiPieMenuBegin(C, IFACE_(title), ICON_NONE, event); + if (!(pie = uiPieMenuBegin(C, IFACE_(title), ICON_NONE, event))) + return; + layout = uiPieMenuLayout(pie); layout = uiLayoutRadial(layout); @@ -2836,7 +2856,9 @@ void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, return; } - pie = uiPieMenuBegin(C, IFACE_(title), ICON_NONE, event); + if (!(pie = uiPieMenuBegin(C, IFACE_(title), ICON_NONE, event))) + return; + layout = uiPieMenuLayout(pie); layout = uiLayoutRadial(layout); |