diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-20 11:40:05 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-20 11:40:05 +0400 |
commit | 9f766c71b0a98801600c775dfc46faee84ddf49e (patch) | |
tree | e8d933e20df512eb836062e0f8cf9191f32c1141 /source/blender/editors/space_node | |
parent | 2338765726a5aa6b8870d573d685218720864583 (diff) |
use event->mval rather then subtracting ar->winrct.x / y from event->x / y
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_select.c | 22 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_state.c | 10 |
3 files changed, 13 insertions, 36 deletions
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 19a9bfb224b..d967e2240e6 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1166,7 +1166,6 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) Image *ima; ImBuf *ibuf; float fx, fy, bufx, bufy; - int mx, my; ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); @@ -1181,13 +1180,11 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) IMB_rect_from_float(ibuf); } - mx= event->x - ar->winrct.xmin; - my= event->y - ar->winrct.ymin; /* map the mouse coords to the backdrop image space */ bufx = ibuf->x * snode->zoom; bufy = ibuf->y * snode->zoom; - fx = (bufx > 0.0f ? ((float)mx - 0.5f*ar->winx - snode->xof) / bufx + 0.5f : 0.0f); - fy = (bufy > 0.0f ? ((float)my - 0.5f*ar->winy - snode->yof) / bufy + 0.5f : 0.0f); + fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f*ar->winx - snode->xof) / bufx + 0.5f : 0.0f); + fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f*ar->winy - snode->yof) / bufy + 0.5f : 0.0f); if(fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { float *fp; @@ -1317,7 +1314,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) switch (event->type) { case MOUSEMOVE: - UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my); if (node) { @@ -1358,7 +1355,7 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event) rctf totr; /* convert mouse coordinates to v2d space */ - UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my); /* rect we're interested in is just the bottom right corner */ @@ -2094,7 +2091,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) sock= nldrag->sock; link= nldrag->link; - UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my); switch (event->type) { @@ -2244,7 +2241,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event) bNodeLinkDrag *nldrag= MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); - UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my); ED_preview_kill_jobs(C); @@ -2928,7 +2925,7 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, wmEvent *event) SpaceNode *snode= CTX_wm_space_node(C); /* convert mouse coordinates to v2d space */ - UI_view2d_region_to_view(&ar->v2d, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin, + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my); if (RNA_property_is_set(op->ptr, "filepath") || RNA_property_is_set(op->ptr, "name")) diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 6bda47e5c8f..a1ef75f3976 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -124,14 +124,8 @@ static int node_select_exec(bContext *C, wmOperator *op) static int node_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - int mval[2]; - - mval[0]= event->x - ar->winrct.xmin; - mval[1]= event->y - ar->winrct.ymin; - - RNA_int_set(op->ptr, "mouse_x", mval[0]); - RNA_int_set(op->ptr, "mouse_y", mval[1]); + RNA_int_set(op->ptr, "mouse_x", event->mval[0]); + RNA_int_set(op->ptr, "mouse_y", event->mval[1]); return node_select_exec(C,op); } @@ -199,17 +193,9 @@ static int node_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event /* this allows border select on empty space, but drag-translate on nodes */ SpaceNode *snode= CTX_wm_space_node(C); ARegion *ar= CTX_wm_region(C); - int mval[2]; float mx, my; - - mval[0]= event->x - ar->winrct.xmin; - mval[1]= event->y - ar->winrct.ymin; - - /* get mouse coordinates in view2d space */ - mx= (float)mval[0]; - my= (float)mval[1]; - - UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &mx, &my); + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my); if (node_under_mouse(snode->edittree, mx, my)) return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c index 9665a152970..601ffbd313d 100644 --- a/source/blender/editors/space_node/node_state.c +++ b/source/blender/editors/space_node/node_state.c @@ -201,14 +201,8 @@ static int node_toggle_visibility_exec(bContext *C, wmOperator *op) static int node_toggle_visibility_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - int mval[2]; - - mval[0]= event->x - ar->winrct.xmin; - mval[1]= event->y - ar->winrct.ymin; - - RNA_int_set(op->ptr, "mouse_x", mval[0]); - RNA_int_set(op->ptr, "mouse_y", mval[1]); + RNA_int_set(op->ptr, "mouse_x", event->mval[0]); + RNA_int_set(op->ptr, "mouse_y", event->mval[1]); return node_toggle_visibility_exec(C,op); } |