From ea80a0b2e1a340b8240d247026688bbf0c05f602 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Sun, 20 Jul 2014 16:37:59 +0200 Subject: More functionality review fixes. * Fix context issues with paint curve keymaps. * Make paint curve cursor set operator modal. --- source/blender/editors/sculpt_paint/paint_curve.c | 50 ++++++++++++++-------- source/blender/editors/sculpt_paint/paint_ops.c | 3 +- source/blender/editors/space_image/space_image.c | 3 ++ source/blender/editors/space_view3d/space_view3d.c | 3 ++ .../editors/transform/transform_conversions.c | 5 ++- 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 82fe2fb01b0..6ca0a041388 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -743,31 +743,44 @@ void PAINTCURVE_OT_draw(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; } -static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) +static int paintcurve_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - PaintMode mode = BKE_paintmode_get_active_from_context(C); + op->customdata = SET_INT_IN_POINTER(event->type); + WM_event_add_modal_handler(C, op); - switch (mode) { - case PAINT_TEXTURE_2D: - { - ARegion *ar = CTX_wm_region(C); - SpaceImage *sima = CTX_wm_space_image(C); - float location[2]; + return OPERATOR_RUNNING_MODAL; +} - if (!sima) - return OPERATOR_CANCELLED; +static int paintcurve_cursor_modal(bContext *C, wmOperator *op, const wmEvent *event) +{ + if (event->type == GET_INT_FROM_POINTER(op->customdata) && event->val == KM_RELEASE) + return OPERATOR_FINISHED; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); - copy_v2_v2(sima->cursor, location); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL); - break; + if (event->type == MOUSEMOVE) { + PaintMode mode = BKE_paintmode_get_active_from_context(C); + + switch (mode) { + case PAINT_TEXTURE_2D: + { + ARegion *ar = CTX_wm_region(C); + SpaceImage *sima = CTX_wm_space_image(C); + float location[2]; + + if (!sima) + return OPERATOR_CANCELLED; + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); + copy_v2_v2(sima->cursor, location); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL); + break; + } + default: + ED_view3d_cursor3d_update(C, event->mval); + break; } - default: - ED_view3d_cursor3d_update(C, event->mval); - break; } - return OPERATOR_FINISHED; + return OPERATOR_RUNNING_MODAL; } void PAINTCURVE_OT_cursor(wmOperatorType *ot) @@ -779,6 +792,7 @@ void PAINTCURVE_OT_cursor(wmOperatorType *ot) /* api callbacks */ ot->invoke = paintcurve_cursor_invoke; + ot->modal = paintcurve_cursor_modal; ot->poll = paint_curve_poll; /* flags */ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index dedce2ed583..6aee7f9fc8b 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -1271,6 +1271,7 @@ static void paint_keymap_curve(wmKeyMap *keymap) WM_keymap_add_item(keymap, "PAINTCURVE_OT_delete_point", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINTCURVE_OT_draw", RETKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "TRANSFORM_OT_translate", GKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_translate", EVT_TWEAK_S, KM_ANY, 0, 0); RNA_boolean_set(kmi->ptr, "release_confirm", true); @@ -1284,7 +1285,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) wmKeyMapItem *kmi; int i; - keymap = WM_keymap_find(keyconf, "Curve", 0, 0); + keymap = WM_keymap_find(keyconf, "Paint Curve", 0, 0); keymap->poll = paint_curve_poll; paint_keymap_curve(keymap); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 1330144d05c..24b7f20007e 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -636,6 +636,9 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar) keymap = WM_keymap_find(wm->defaultconf, "Curve", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + keymap = WM_keymap_find(wm->defaultconf, "Paint Curve", 0, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); + keymap = WM_keymap_find(wm->defaultconf, "Image Paint", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index b2883c89703..1b749853b19 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -483,6 +483,9 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar) keymap = WM_keymap_find(wm->defaultconf, "Object Mode", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); + keymap = WM_keymap_find(wm->defaultconf, "Paint Curve", 0, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); + keymap = WM_keymap_find(wm->defaultconf, "Curve", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 30ec42e1166..32ec9bcdf29 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -7231,7 +7231,8 @@ void createTransData(bContext *C, TransInfo *t) } } else if (t->options & CTX_PAINT_CURVE) { - createTransPaintCurveVerts(C, t); + if(!ELEM(t->mode, TFM_SHEAR, TFM_SHRINKFATTEN)) + createTransPaintCurveVerts(C, t); } else if (t->obedit) { createTransUVs(C, t); @@ -7365,7 +7366,7 @@ void createTransData(bContext *C, TransInfo *t) } } else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { - if (t->options & CTX_PAINT_CURVE) { + if ((t->options & CTX_PAINT_CURVE) && !ELEM(t->mode, TFM_SHEAR, TFM_SHRINKFATTEN)) { t->flag |= T_POINTS | T_2D_EDIT; createTransPaintCurveVerts(C, t); } -- cgit v1.2.3