diff options
author | Ton Roosendaal <ton@blender.org> | 2013-03-18 17:57:47 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2013-03-18 17:57:47 +0400 |
commit | ee692508d916edb31b321dc119f80c2fbe887dea (patch) | |
tree | 7a4c1c2e1be797f159f47ae3a1e8c5eece8176f4 /source | |
parent | 0ee5a2b9562bf63144b36253420c48b6e5680b9e (diff) |
Bug fix, irc:
Curves widget error: after deleting a point, and click to add a new point, on dragging
it the point flipped up 20 pixels. Was caused by changed layout and region view matrix.
Solved by storing actual mousecoords instead of mapped ones.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 12a6343c7e7..39aef38fadb 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4158,20 +4158,27 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle return WM_UI_HANDLER_CONTINUE; } -static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, - float mx, float my, const short shift) +static int ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data, int snap, + int evtx, int evty, const short shift) { CurveMapping *cumap = (CurveMapping *)but->poin; CurveMap *cuma = cumap->cm + cumap->cur; CurveMapPoint *cmp = cuma->curve; - float fx, fy, zoomx, zoomy /*, offsx, offsy */ /* UNUSED */; + float fx, fy, zoomx, zoomy; + int mx, my, dragx, dragy; int a, changed = 0; + /* evtx evty and drag coords are absolute mousecoords, prevents errors when editing when layout changes */ + mx = evtx; + my = evty; + ui_window_to_block(data->region, block, &mx, &my); + dragx = data->draglastx; + dragy = data->draglasty; + ui_window_to_block(data->region, block, &dragx, &dragy); + zoomx = BLI_rctf_size_x(&but->rect) / BLI_rctf_size_x(&cumap->curr); zoomy = BLI_rctf_size_y(&but->rect) / BLI_rctf_size_y(&cumap->curr); - /* offsx = cumap->curr.xmin; */ - /* offsy = cumap->curr.ymin; */ - + if (snap) { float d[2]; @@ -4187,8 +4194,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, const float mval_factor = ui_mouse_scale_warp_factor(shift); int moved_point = 0; /* for ctrl grid, can't use orig coords because of sorting */ - fx = (mx - data->draglastx) / zoomx; - fy = (my - data->draglasty) / zoomy; + fx = (mx - dragx) / zoomx; + fy = (my - dragy) / zoomy; fx *= mval_factor; fy *= mval_factor; @@ -4212,8 +4219,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, curvemapping_changed(cumap, FALSE); if (moved_point) { - data->draglastx = mx; - data->draglasty = my; + data->draglastx = evtx; + data->draglasty = evty; changed = 1; #ifdef USE_CONT_MOUSE_CORRECT @@ -4232,8 +4239,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, data->dragchange = 1; /* mark for selection */ } else { - fx = (mx - data->draglastx) / zoomx; - fy = (my - data->draglasty) / zoomy; + fx = (mx - dragx) / zoomx; + fy = (my - dragy) / zoomy; /* clamp for clip */ if (cumap->flag & CUMA_DO_CLIP) { @@ -4252,8 +4259,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, cumap->curr.xmax -= fx; cumap->curr.ymax -= fy; - data->draglastx = mx; - data->draglasty = my; + data->draglastx = evtx; + data->draglasty = evty; changed = 1; } @@ -4268,7 +4275,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt mx = event->x; my = event->y; ui_window_to_block(data->region, block, &mx, &my); - + if (data->state == BUTTON_STATE_HIGHLIGHT) { if (event->type == LEFTMOUSE && event->val == KM_PRESS) { CurveMapping *cumap = (CurveMapping *)but->poin; @@ -4358,11 +4365,11 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt } data->dragsel = sel; - - data->dragstartx = mx; - data->dragstarty = my; - data->draglastx = mx; - data->draglasty = my; + + data->dragstartx = event->x; + data->dragstarty = event->y; + data->draglastx = event->x; + data->draglasty = event->y; button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); return WM_UI_HANDLER_BREAK; @@ -4370,8 +4377,9 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt } else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == MOUSEMOVE) { - if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_CURVE(but, data, event->ctrl, mx, my, event->shift)) + if (event->x != data->draglastx || event->y != data->draglasty) { + + if (ui_numedit_but_CURVE(block, but, data, event->ctrl, event->x, event->y, event->shift)) ui_numedit_apply(C, block, but, data); } } |