Pie menus:

If user drags away from initial position, menu changes to drag style and
returning to that position won't remake the menu click-style. Allows to
use the threshold indicator to cancel the pie.
This commit is contained in:
Antony Riakiotakis 2014-08-14 14:17:39 +02:00
parent 8e30db0f67
commit b42b0554ea
3 changed files with 10 additions and 6 deletions

@ -8704,13 +8704,16 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
if (event->val != KM_RELEASE) {
ui_handle_menu_button(C, event, menu);
if (len_squared_v2v2(event_xy, block->pie_data.pie_center_init) > PIE_CLICK_THRESHOLD_SQ) {
block->pie_data.flags |= UI_PIE_DRAG_STYLE;
}
/* why redraw here? It's simple, we are getting many double click events here.
* Those operate like mouse move events almost */
ED_region_tag_redraw(ar);
}
else {
/* distance from initial point */
if (len_squared_v2v2(event_xy, block->pie_data.pie_center_init) < PIE_CLICK_THRESHOLD_SQ) {
if (!(block->pie_data.flags & UI_PIE_DRAG_STYLE)) {
block->pie_data.flags |= UI_PIE_CLICK_STYLE;
}
else if (!is_click_style) {
@ -8726,8 +8729,12 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
switch (event->type) {
case MOUSEMOVE:
/* mouse move should always refresh the area for pie menus */
if (len_squared_v2v2(event_xy, block->pie_data.pie_center_init) > PIE_CLICK_THRESHOLD_SQ) {
block->pie_data.flags |= UI_PIE_DRAG_STYLE;
}
ui_handle_menu_button(C, event, menu);
/* mouse move should always refresh the area for pie menus */
ED_region_tag_redraw(ar);
break;

@ -166,7 +166,7 @@ extern const short ui_radial_dir_to_angle[8];
enum {
UI_PIE_DEGREES_RANGE_LARGE = (1 << 0), /* pie menu item collision is detected at 90 degrees */
UI_PIE_INITIAL_DIRECTION = (1 << 1), /* use initial center of pie menu to calculate direction */
UI_PIE_3_ITEMS = (1 << 2), /* pie menu has only 3 items, careful when centering */
UI_PIE_DRAG_STYLE = (1 << 2), /* pie menu is drag style */
UI_PIE_INVALID_DIR = (1 << 3), /* mouse not far enough from center position */
UI_PIE_FINISHED = (1 << 4), /* pie menu finished but we still wait for a release event */
UI_PIE_CLICK_STYLE = (1 << 5), /* pie menu changed to click style, click to confirm */

@ -2171,9 +2171,6 @@ static void ui_litem_layout_radial(uiLayout *litem)
if (totitems < 5)
litem->root->block->pie_data.flags |= UI_PIE_DEGREES_RANGE_LARGE;
if (totitems == 3)
litem->root->block->pie_data.flags |= UI_PIE_3_ITEMS;
for (item = litem->items.first; item; item = item->next) {
/* not all button types are drawn in a radial menu, do filtering here */
if (ui_item_is_radial_displayable(item)) {