Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-07-20 18:37:59 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-07-20 18:38:17 +0400
commitea80a0b2e1a340b8240d247026688bbf0c05f602 (patch)
tree17a6138e069b198bf4ab4932ca23e13f3db1ced7
parent66defcd9d52ecc59ff9e6a791fcb549d9c6a4450 (diff)
More functionality review fixes.soc-2013-paint
* Fix context issues with paint curve keymaps. * Make paint curve cursor set operator modal.
-rw-r--r--source/blender/editors/sculpt_paint/paint_curve.c50
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c3
-rw-r--r--source/blender/editors/space_image/space_image.c3
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c3
-rw-r--r--source/blender/editors/transform/transform_conversions.c5
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);
}