Commit: 4fe223ab0eb7b2d4d6d7135fb73495bc84f51d43
Author: Campbell Barton
Date:   Sat Aug 2 04:28:02 2014 +1000
Branches: pie-menus
https://developer.blender.org/rB4fe223ab0eb7b2d4d6d7135fb73495bc84f51d43

Simplify some 2d vector use

===================================================================

M       source/blender/editors/interface/interface_handlers.c
M       source/blender/editors/interface/interface_intern.h
M       source/blender/editors/interface/interface_regions.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index 125c07c..c35ed75 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 71219c8..65f533c 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 5f60acc..956cc9e 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));
                                }
                        }
                }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to