Bugfix #26249
authorTon Roosendaal <ton@blender.org>
Tue, 1 Mar 2011 16:26:37 +0000 (16:26 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 1 Mar 2011 16:26:37 +0000 (16:26 +0000)
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).

source/blender/editors/sculpt_paint/paint_intern.h
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c

index a5ebebcdacd5fd23350b2040062688147d760648..48fca04ac874033dedde2f4ecc8e73e20e66a060 100644 (file)
@@ -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);
index fc92b9c0208e48b4adfce132be054baca62abafe..d7fdf42fa62bdfd488e2786f32f622bf579f84f5 100644 (file)
@@ -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);
index 4985658fe518c34f28c11a1bed7898cc3a8c7cdb..c3522d0b5967d11c2c4d61daf7b5d099dfd8419c 100644 (file)
@@ -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);
index bd2bb255809a58c56ace3936ebfb6c9d59bac7cb..62f180e90664d5049ccf167e849ee4e825cfaa97 100644 (file)
@@ -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);