diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-08-01 22:28:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-08-01 22:29:37 +0400 |
commit | 4fe223ab0eb7b2d4d6d7135fb73495bc84f51d43 (patch) | |
tree | 82a206fbec673959150bbc8bbe18c6740dc4d0ad | |
parent | b7ad6b4437c3978ab354e34c0763051914f5493e (diff) |
Simplify some 2d vector use
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 22 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 4 |
3 files changed, 12 insertions, 16 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 125c07cff49..c35ed753193 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -7983,7 +7983,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 mx, const float my) +void ui_block_calculate_pie_segment(uiBlock *block, const float event_xy[2]) { float seg1[2]; float seg2[2]; @@ -7996,8 +7996,7 @@ void ui_block_calculate_pie_segment(uiBlock *block, const float mx, const float copy_v2_v2(seg1, block->pie_data.pie_center_spawned); } - seg2[0] = mx - seg1[0]; - seg2[1] = my - seg1[1]; + sub_v2_v2v2(seg2, event_xy, seg1); len = normalize_v2_v2(block->pie_data.pie_dir, seg2); @@ -8611,7 +8610,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle ARegion *ar; uiBlock *block; uiBut *but; - int mx, my; + float event_xy[2]; double duration; bool is_click_style; @@ -8676,12 +8675,12 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle } } - mx = event->x; - my = event->y; + event_xy[0] = event->x; + event_xy[1] = event->y; - ui_window_to_block(ar, block, &mx, &my); + ui_window_to_block_fl(ar, block, &event_xy[0], &event_xy[1]); - ui_block_calculate_pie_segment(block, mx, my); + ui_block_calculate_pie_segment(block, event_xy); if (block->pie_data.flags & UI_PIE_FINISHED) { if ((event->type == block->pie_data.event && event->val == KM_RELEASE) || @@ -8703,11 +8702,8 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle ED_region_tag_redraw(ar); } else { - /* calculate distance from initial poit */ - float seg[2] = {(float)mx, (float)my}; - sub_v2_v2(seg, block->pie_data.pie_center_init); - - if (len_squared_v2(seg) < PIE_CLICK_THRESHOLD) { + /* distance from initial point */ + if (len_squared_v2v2(event_xy, block->pie_data.pie_center_init) < PIE_CLICK_THRESHOLD) { block->pie_data.flags |= UI_PIE_CLICK_STYLE; } else if (!is_click_style) { diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 71219c8033e..65f533c0cfc 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -599,7 +599,7 @@ extern bool ui_button_is_active(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT; extern int ui_button_open_menu_direction(uiBut *but); extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, const bool restore); extern uiBut *ui_but_find_activated(struct ARegion *ar); -void ui_block_calculate_pie_segment(struct uiBlock *block, const float mx, const float my); +void ui_block_calculate_pie_segment(struct uiBlock *block, const float event_xy[2]); void ui_button_clipboard_free(void); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 5f60acc630c..956cc9ea613 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1745,13 +1745,13 @@ uiBlock *ui_popup_block_refresh( ar->winrct.ymin = 0; ar->winrct.ymax = winy; - ui_block_calculate_pie_segment(block, block->pie_data.pie_center_init[0], block->pie_data.pie_center_init[1]); + ui_block_calculate_pie_segment(block, block->pie_data.pie_center_init); /* lastly set the buttons at the center of the pie menu, ready for animation */ if (U.pie_animation_timeout > 0) { for (but = block->buttons.first; but; but = but->next) { if (but->pie_dir) { - BLI_rctf_recenter(&but->rect, block->pie_data.pie_center_spawned[0], block->pie_data.pie_center_spawned[1]); + BLI_rctf_recenter(&but->rect, UNPACK2(block->pie_data.pie_center_spawned)); } } } |