diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-04 15:08:09 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-04 15:08:35 +0400 |
commit | 2a62a06e863270aa5635e4ae72ccd7c06f7fad1a (patch) | |
tree | 94d40557bc195470999a2092f11aaba10a5d2811 /source | |
parent | 8ff74bed9bad138430c58732800d342b27656ea1 (diff) |
Mask spline slide: holding Ctrl will make handles free
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/mask/mask_ops.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 78878ed3e4c..8011b296835 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -1201,20 +1201,48 @@ static void slide_spline_solve_P2(const float u, static int slide_spline_curvature_modal(bContext *C, wmOperator *op, const wmEvent *event) { + const float margin = 0.2f; SlideSplineCurvatureData *slide_data = (SlideSplineCurvatureData *) op->customdata; + float u = slide_data->u; switch (event->type) { case LEFTSHIFTKEY: case RIGHTSHIFTKEY: - if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) + case LEFTCTRLKEY: + case RIGHTCTRLKEY: + if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) { slide_data->accurate = (event->val == KM_PRESS); + } + + if (ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY)) { + if (event->val == KM_PRESS) { + slide_data->adjust_bezt->h1 = slide_data->adjust_bezt->h2 = HD_FREE; + if ((u > margin && u < 0.5f) || (u >= 0.5f && u < 1.0f - margin)) { + slide_data->other_bezt->h1 = slide_data->other_bezt->h2 = HD_FREE; + } + } + else if (event->val == KM_RELEASE) { + slide_data->adjust_bezt->h1 = slide_data->bezt_backup.h1; + slide_data->adjust_bezt->h2 = slide_data->bezt_backup.h2; + slide_data->other_bezt->h1 = slide_data->other_bezt_backup.h1; + slide_data->other_bezt->h2 = slide_data->other_bezt_backup.h2; + } + + if (u < 0.5f) { + copy_v2_v2(slide_data->adjust_bezt->vec[0], slide_data->bezt_backup.vec[0]); + copy_v2_v2(slide_data->other_bezt->vec[2], slide_data->other_bezt_backup.vec[2]); + } + else { + copy_v2_v2(slide_data->adjust_bezt->vec[2], slide_data->bezt_backup.vec[2]); + copy_v2_v2(slide_data->other_bezt->vec[0], slide_data->other_bezt_backup.vec[0]); + } + + } /* fall-through */ /* update CV position */ case MOUSEMOVE: { - const float margin = 0.2f; float B[2], mouse_coord[2], delta[2]; - float u = slide_data->u; /* Get coordinate spline is expected to go through. */ ED_mask_mouse_pos(CTX_wm_area(C), CTX_wm_region(C), event->mval, mouse_coord); |