Pie menus:

* Only use last key for pies if it hasn't been released already
* Confirm threshold is now measured as distance after regular threshold.
zero disables.
* Only display the confirm threshold if there's a valid direction (mouse
is after threshold).
* Calculate confirm threshold taking recentering into account
This commit is contained in:
2014-10-14 11:57:50 +02:00
parent 20c233f3af
commit f23cf22125
5 changed files with 29 additions and 15 deletions

View File

@@ -7995,7 +7995,7 @@ static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlock
return retval;
}
void ui_block_calculate_pie_segment(uiBlock *block, const float event_xy[2])
float ui_block_calculate_pie_segment(uiBlock *block, const float event_xy[2])
{
float seg1[2];
float seg2[2];
@@ -8017,6 +8017,8 @@ void ui_block_calculate_pie_segment(uiBlock *block, const float event_xy[2])
block->pie_data.flags |= UI_PIE_INVALID_DIR;
else
block->pie_data.flags &= ~UI_PIE_INVALID_DIR;
return len;
}
static int ui_handle_menu_event(
@@ -8609,6 +8611,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
float event_xy[2];
double duration;
bool is_click_style;
float dist;
/* we block all events, this is modal interaction, except for drop events which is described below */
int retval = WM_UI_HANDLER_BREAK;
@@ -8637,7 +8640,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
ui_window_to_block_fl(ar, block, &event_xy[0], &event_xy[1]);
ui_block_calculate_pie_segment(block, event_xy);
dist = ui_block_calculate_pie_segment(block, event_xy);
if (event->type == TIMER) {
if (event->customdata == menu->scrolltimer) {
@@ -8723,11 +8726,10 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
block->pie_data.flags |= UI_PIE_CLICK_STYLE;
}
else {
float len_sq = len_squared_v2v2(event_xy, block->pie_data.pie_center_init);
uiBut *but = ui_but_find_activated(menu->region);
if (but && (U.pie_menu_confirm >= U.pie_menu_threshold) &&
(sqrtf(len_sq) >= U.pie_menu_confirm))
if (but && (U.pie_menu_confirm > 0) &&
(dist >= U.pie_menu_threshold + U.pie_menu_confirm))
{
if (but)
return ui_but_pie_menu_apply(C, menu, but, true);
@@ -8747,12 +8749,14 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
if (!is_click_style) {
float len_sq = len_squared_v2v2(event_xy, block->pie_data.pie_center_init);
/* here we use the initial position explicitly */
if (len_sq > PIE_CLICK_THRESHOLD_SQ) {
block->pie_data.flags |= UI_PIE_DRAG_STYLE;
}
if ((U.pie_menu_confirm >= U.pie_menu_threshold) &&
(len_sq >= SQUARE(U.pie_menu_confirm)))
/* here instead, we use the offset location to account for the initial direction timeout */
if ((U.pie_menu_confirm > 0) &&
(dist >= U.pie_menu_threshold + U.pie_menu_confirm))
{
block->pie_data.flags |= UI_PIE_GESTURE_END_WAIT;
copy_v2_v2(block->pie_data.last_pos, event_xy);

View File

@@ -608,7 +608,7 @@ extern uiBut *ui_but_find_activated(struct ARegion *ar);
bool ui_but_is_editable(const uiBut *but);
void ui_but_pie_dir_visual(RadialDirection dir, float vec[2]);
void ui_but_pie_dir(RadialDirection dir, float vec[2]);
void ui_block_calculate_pie_segment(struct uiBlock *block, const float event_xy[2]);
float ui_block_calculate_pie_segment(struct uiBlock *block, const float event_xy[2]);
void ui_button_clipboard_free(void);
void ui_panel_menu(struct bContext *C, ARegion *ar, Panel *pa);

View File

@@ -2732,10 +2732,18 @@ uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const
win->lock_pie_event = EVENT_NONE;
}
else {
if (win->last_pie_event != EVENT_NONE)
event_type = win->last_pie_event;
else
if (win->last_pie_event != EVENT_NONE) {
/* original pie key has been released, so don't propagate the event */
if (win->lock_pie_event == EVENT_NONE) {
event_type = EVENT_NONE;
pie->block_radial->pie_data.flags |= UI_PIE_CLICK_STYLE;
}
else
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;

View File

@@ -3838,8 +3838,6 @@ void ui_draw_pie_center(uiBlock *block)
float pie_radius_internal = U.pixelsize * U.pie_menu_threshold;
float pie_radius_external = U.pixelsize * (U.pie_menu_threshold + 7.0f);
float pie_confirm_radius = U.pixelsize * (U.pie_menu_confirm);
float pie_confirm_external = U.pixelsize * (U.pie_menu_confirm + 2.0f);
int subd = 40;
@@ -3876,10 +3874,14 @@ void ui_draw_pie_center(uiBlock *block)
glutil_draw_lined_arc(0.0f, (float)M_PI * 2.0f, pie_radius_internal, subd);
glutil_draw_lined_arc(0.0f, (float)M_PI * 2.0f, pie_radius_external, subd);
if (pie_confirm_radius > pie_radius_external) {
if (U.pie_menu_confirm > 0 && !(block->pie_data.flags & (UI_PIE_INVALID_DIR | UI_PIE_CLICK_STYLE))) {
float pie_confirm_radius = U.pixelsize * (pie_radius_internal + U.pie_menu_confirm);
float pie_confirm_external = U.pixelsize * (pie_radius_internal + U.pie_menu_confirm + 7.0f);
glColor4ub(btheme->tui.wcol_pie_menu.text_sel[0], btheme->tui.wcol_pie_menu.text_sel[1], btheme->tui.wcol_pie_menu.text_sel[2], 64);
draw_disk_shaded(angle - range / 2.0f, range, pie_confirm_radius, pie_confirm_external, subd, NULL, NULL, false);
}
glDisable(GL_BLEND);
glPopMatrix();
}

View File

@@ -3253,7 +3253,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
prop = RNA_def_property(srna, "pie_menu_confirm", PROP_INT, PROP_PIXEL);
RNA_def_property_range(prop, 0, 1000);
RNA_def_property_ui_text(prop, "Confirm Threshold", "Distance from center after which selection is made");
RNA_def_property_ui_text(prop, "Confirm Threshold", "Distance after threshold after which selection is made (zero disables)");
prop = RNA_def_property(srna, "use_quit_dialog", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_QUIT_PROMPT);