diff options
author | Ton Roosendaal <ton@blender.org> | 2011-03-01 19:26:37 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2011-03-01 19:26:37 +0300 |
commit | 32d87359e1e670cd47d3fb427f37de7217203785 (patch) | |
tree | aa53b09be122898ad5d460d437e58adbb81c01b7 /source/blender | |
parent | acd69b9c3ff944eb1a4bf75cf64a7b8d5add251e (diff) |
Bugfix #26249
Paint strokes now can be mapped to any key. The operators now store the
event it was started with, so it ends with a release. Even hotkeys work
(while hold).
Diffstat (limited to 'source/blender')
4 files changed, 13 insertions, 11 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index a5ebebcdacd..48fca04ac87 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -58,7 +58,7 @@ typedef void (*StrokeDone)(struct bContext *C, struct PaintStroke *stroke); struct PaintStroke *paint_stroke_new(struct bContext *C, StrokeGetLocation get_location, StrokeTestStart test_start, - StrokeUpdateStep update_step, StrokeDone done); + StrokeUpdateStep update_step, StrokeDone done, int event_type); void paint_stroke_free(struct PaintStroke *stroke); int paint_space_stroke_enabled(struct Brush *br); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index fc92b9c0208..d7fdf42fa62 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -79,7 +79,9 @@ typedef struct PaintStroke { e.g. in sculpt mode, stroke doesn't start until cursor passes over the mesh */ int stroke_started; - + /* event that started stroke, for modal() return */ + int event_type; + StrokeGetLocation get_location; StrokeTestStart test_start; StrokeUpdateStep update_step; @@ -374,7 +376,7 @@ static int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radiu float window[2]; int hit; - stroke = paint_stroke_new(C, NULL, NULL, NULL, NULL); + stroke = paint_stroke_new(C, NULL, NULL, NULL, NULL, 0); window[0] = x + stroke->vc.ar->winrct.xmin; window[1] = y + stroke->vc.ar->winrct.ymin; @@ -794,7 +796,7 @@ PaintStroke *paint_stroke_new(bContext *C, StrokeGetLocation get_location, StrokeTestStart test_start, StrokeUpdateStep update_step, - StrokeDone done) + StrokeDone done, int event_type) { PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke"); @@ -806,7 +808,8 @@ PaintStroke *paint_stroke_new(bContext *C, stroke->test_start = test_start; stroke->update_step = update_step; stroke->done = done; - + stroke->event_type= event_type; /* for modal, return event */ + return stroke; } @@ -846,8 +849,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) //ED_region_tag_redraw(ar); } - /* TODO: fix hardcoded events here */ - if(event->type == LEFTMOUSE && event->val == KM_RELEASE) { + if(event->type == stroke->event_type && event->val == KM_RELEASE) { /* exit stroke, free data */ if(stroke->smooth_stroke_cursor) WM_paint_cursor_end(CTX_wm_manager(C), stroke->smooth_stroke_cursor); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 4985658fe51..c3522d0b596 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1642,7 +1642,7 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) op->customdata = paint_stroke_new(C, NULL, wpaint_stroke_test_start, wpaint_stroke_update_step, - wpaint_stroke_done); + wpaint_stroke_done, event->type); /* add modal handler */ WM_event_add_modal_handler(C, op); @@ -1934,7 +1934,7 @@ static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) op->customdata = paint_stroke_new(C, NULL, vpaint_stroke_test_start, vpaint_stroke_update_step, - vpaint_stroke_done); + vpaint_stroke_done, event->type); /* add modal handler */ WM_event_add_modal_handler(C, op); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index bd2bb255809..62f180e9066 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3501,7 +3501,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even stroke = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, sculpt_stroke_update_step, - sculpt_stroke_done); + sculpt_stroke_done, event->type); op->customdata = stroke; @@ -3531,7 +3531,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, - sculpt_stroke_update_step, sculpt_stroke_done); + sculpt_stroke_update_step, sculpt_stroke_done, 0); sculpt_update_cache_invariants(C, sd, ss, op, NULL); |